summaryrefslogtreecommitdiffstats
path: root/src/cameras
diff options
context:
space:
mode:
Diffstat (limited to 'src/cameras')
-rw-r--r--src/cameras/pco.c37
-rw-r--r--src/cameras/pf.c63
2 files changed, 36 insertions, 64 deletions
diff --git a/src/cameras/pco.c b/src/cameras/pco.c
index 1b9c8b8..4acbf17 100644
--- a/src/cameras/pco.c
+++ b/src/cameras/pco.c
@@ -46,29 +46,23 @@ static uint32_t uca_pco_set_property(struct uca_camera *cam, enum uca_property_i
struct uca_grabber *grabber = cam->grabber;
uint32_t err = UCA_ERR_CAMERA | UCA_ERR_PROP;
+ /* We try to set the property on the grabber. If it returns "invalid", we
+ * also try it via the libpco. Else, there was a more serious error. */
+ err = grabber->set_property(grabber, property, data);
+ if (((err & UCA_ERR_MASK_CODE) == UCA_ERR_INVALID) || (err == UCA_NO_ERROR))
+ err = UCA_ERR_CAMERA | UCA_ERR_PROP;
+ else
+ return err;
+
switch (property) {
case UCA_PROP_WIDTH:
- if (grabber->set_property(grabber, UCA_GRABBER_WIDTH, (uint32_t *) data) != UCA_NO_ERROR)
- return err | UCA_ERR_OUT_OF_RANGE;
cam->frame_width = *((uint32_t *) data);
break;
case UCA_PROP_HEIGHT:
- if (grabber->set_property(grabber, UCA_GRABBER_HEIGHT, (uint32_t *) data) != UCA_NO_ERROR)
- return err | UCA_ERR_OUT_OF_RANGE;
cam->frame_height = *((uint32_t *) data);
break;
- case UCA_PROP_X_OFFSET:
- if (grabber->set_property(grabber, UCA_GRABBER_OFFSET_X, (uint32_t *) data) != UCA_NO_ERROR)
- return err | UCA_ERR_OUT_OF_RANGE;
- break;
-
- case UCA_PROP_Y_OFFSET:
- if (grabber->set_property(grabber, UCA_GRABBER_OFFSET_Y, (uint32_t *) data) != UCA_NO_ERROR)
- return err | UCA_ERR_OUT_OF_RANGE;
- break;
-
case UCA_PROP_EXPOSURE:
return uca_pco_set_exposure(cam, (uint32_t *) data);
@@ -78,11 +72,6 @@ static uint32_t uca_pco_set_property(struct uca_camera *cam, enum uca_property_i
case UCA_PROP_TIMESTAMP_MODE:
return pco_set_timestamp_mode(GET_PCO(cam), *((uint16_t *) data));
- case UCA_PROP_GRAB_TIMEOUT:
- if (grabber->set_property(grabber, UCA_GRABBER_TIMEOUT, data) != UCA_NO_ERROR)
- return err | UCA_ERR_OUT_OF_RANGE;
- break;
-
default:
return err | UCA_ERR_INVALID;
}
@@ -151,10 +140,10 @@ static uint32_t uca_pco_get_property(struct uca_camera *cam, enum uca_property_i
break;
case UCA_PROP_X_OFFSET:
- return grabber->get_property(grabber, UCA_GRABBER_OFFSET_X, (uint32_t *) data);
+ return grabber->get_property(grabber, UCA_PROP_X_OFFSET, (uint32_t *) data);
case UCA_PROP_Y_OFFSET:
- return grabber->get_property(grabber, UCA_GRABBER_OFFSET_Y, (uint32_t *) data);
+ return grabber->get_property(grabber, UCA_PROP_Y_OFFSET, (uint32_t *) data);
case UCA_PROP_DELAY:
{
@@ -193,7 +182,7 @@ static uint32_t uca_pco_get_property(struct uca_camera *cam, enum uca_property_i
case UCA_PROP_GRAB_TIMEOUT:
{
uint32_t timeout;
- uint32_t err = cam->grabber->get_property(cam->grabber, UCA_GRABBER_TIMEOUT, &timeout);
+ uint32_t err = cam->grabber->get_property(cam->grabber, UCA_PROP_GRAB_TIMEOUT, &timeout);
if (err != UCA_NO_ERROR)
return err;
set_void(data, uint32_t, timeout);
@@ -298,8 +287,8 @@ uint32_t uca_pco_init(struct uca_camera **cam, struct uca_grabber *grabber)
/* Yes, we really have to take an image twice as large because we set the
* CameraLink interface to 8-bit 10 Taps, but are actually using 5x16 bits. */
width *= 2;
- grabber->set_property(grabber, UCA_GRABBER_WIDTH, &width);
- grabber->set_property(grabber, UCA_GRABBER_HEIGHT, &height);
+ grabber->set_property(grabber, UCA_PROP_WIDTH, &width);
+ grabber->set_property(grabber, UCA_PROP_HEIGHT, &height);
uca->state = UCA_CAM_CONFIGURABLE;
*cam = uca;
diff --git a/src/cameras/pf.c b/src/cameras/pf.c
index 4688cd4..5c35b70 100644
--- a/src/cameras/pf.c
+++ b/src/cameras/pf.c
@@ -54,7 +54,15 @@ static uint32_t uca_pf_set_property(struct uca_camera *cam, enum uca_property_id
struct uca_grabber *grabber = cam->grabber;
TOKEN token = INVALID_TOKEN;
int i = 0;
- int err = UCA_ERR_CAMERA | UCA_ERR_PROP;
+ int err = UCA_NO_ERROR;
+
+ /* We try to set the property on the grabber. If it returns "invalid", we
+ * also try it via the PF SDK. Else, there was a more serious error. */
+ err = grabber->set_property(grabber, property, data);
+ if (((err & UCA_ERR_MASK_CODE) == UCA_ERR_INVALID) || (err == UCA_NO_ERROR))
+ err = UCA_ERR_CAMERA | UCA_ERR_PROP;
+ else
+ return err;
/* Find a valid pf token for the property */
while (uca_to_pf[i].uca_prop != -1) {
@@ -71,29 +79,15 @@ static uint32_t uca_pf_set_property(struct uca_camera *cam, enum uca_property_id
switch (property) {
case UCA_PROP_WIDTH:
- if (grabber->set_property(grabber, UCA_GRABBER_WIDTH, data) != UCA_NO_ERROR)
- return err | UCA_ERR_OUT_OF_RANGE;
if (uca_pf_set_uint32_property(token, data, &cam->frame_width) < 0)
return err | UCA_ERR_OUT_OF_RANGE;
break;
case UCA_PROP_HEIGHT:
- if (grabber->set_property(grabber, UCA_GRABBER_HEIGHT, data) != UCA_NO_ERROR)
- return err | UCA_ERR_OUT_OF_RANGE;
if (uca_pf_set_uint32_property(token, data, &cam->frame_height) < 0)
return err | UCA_ERR_OUT_OF_RANGE;
break;
- case UCA_PROP_X_OFFSET:
- if (grabber->set_property(grabber, UCA_GRABBER_OFFSET_X, data) != UCA_NO_ERROR)
- return err | UCA_ERR_OUT_OF_RANGE;
- break;
-
- case UCA_PROP_Y_OFFSET:
- if (grabber->set_property(grabber, UCA_GRABBER_OFFSET_Y, data) != UCA_NO_ERROR)
- return err | UCA_ERR_OUT_OF_RANGE;
- break;
-
case UCA_PROP_EXPOSURE:
/* I haven't found a specification but it looks like PF uses milli
* seconds. We also by-pass the frame grabber... */
@@ -103,11 +97,6 @@ static uint32_t uca_pf_set_property(struct uca_camera *cam, enum uca_property_id
return err | UCA_ERR_OUT_OF_RANGE;
break;
- case UCA_PROP_GRAB_TIMEOUT:
- if (grabber->set_property(grabber, UCA_GRABBER_TIMEOUT, data) != UCA_NO_ERROR)
- return err | UCA_ERR_OUT_OF_RANGE;
- break;
-
default:
return err | UCA_ERR_INVALID;
}
@@ -120,6 +109,16 @@ static uint32_t uca_pf_get_property(struct uca_camera *cam, enum uca_property_id
TOKEN t; /* You gotta love developers who name types capitalized... */
PFValue value;
+ /* Handle all special cases */
+ switch (property) {
+ case UCA_PROP_BITDEPTH:
+ set_void(data, uint32_t, 8);
+ return UCA_NO_ERROR;
+
+ default:
+ break;
+ }
+
int i = 0;
while (uca_to_pf[i].uca_prop != -1) {
if (uca_to_pf[i].uca_prop == property) {
@@ -157,24 +156,8 @@ static uint32_t uca_pf_get_property(struct uca_camera *cam, enum uca_property_id
i++;
}
- /* Handle all special cases */
- switch (property) {
- case UCA_PROP_BITDEPTH:
- set_void(data, uint32_t, 8);
- break;
-
- case UCA_PROP_GRAB_TIMEOUT:
- {
- uint32_t timeout;
- cam->grabber->get_property(cam->grabber, UCA_GRABBER_TIMEOUT, &timeout);
- set_void(data, uint32_t, timeout);
- }
- break;
-
- default:
- return UCA_ERR_CAMERA | UCA_ERR_PROP | UCA_ERR_INVALID;
- }
- return UCA_NO_ERROR;
+ /* Try to get the property via frame grabber */
+ return cam->grabber->get_property(cam->grabber, property, data);
}
uint32_t uca_pf_start_recording(struct uca_camera *cam)
@@ -249,8 +232,8 @@ uint32_t uca_pf_init(struct uca_camera **cam, struct uca_grabber *grabber)
uca_pf_get_property(uca, UCA_PROP_WIDTH, &uca->frame_width, 0);
uca_pf_get_property(uca, UCA_PROP_HEIGHT, &uca->frame_height, 0);
- grabber->set_property(grabber, UCA_GRABBER_WIDTH, &uca->frame_width);
- grabber->set_property(grabber, UCA_GRABBER_HEIGHT, &uca->frame_height);
+ grabber->set_property(grabber, UCA_PROP_WIDTH, &uca->frame_width);
+ grabber->set_property(grabber, UCA_PROP_HEIGHT, &uca->frame_height);
uca->state = UCA_CAM_CONFIGURABLE;
*cam = uca;