summaryrefslogtreecommitdiffstats
path: root/src/cameras/pf.c
diff options
context:
space:
mode:
authorMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2011-03-23 14:46:09 +0100
committerMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2011-03-23 14:46:09 +0100
commit146ac46ab25b3510e34b6fdeb680d4810b48a91a (patch)
treebc971c943fee9220dda9fe66a1bc040a63c6d7e0 /src/cameras/pf.c
parentff7f2398283f5059e3b8e0149e0582ee7d30ad21 (diff)
downloaduca-146ac46ab25b3510e34b6fdeb680d4810b48a91a.tar.gz
uca-146ac46ab25b3510e34b6fdeb680d4810b48a91a.tar.bz2
uca-146ac46ab25b3510e34b6fdeb680d4810b48a91a.tar.xz
uca-146ac46ab25b3510e34b6fdeb680d4810b48a91a.zip
Share common properties between camera and grabber to let the camera just call
grabber->set_property once
Diffstat (limited to 'src/cameras/pf.c')
-rw-r--r--src/cameras/pf.c63
1 files changed, 23 insertions, 40 deletions
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;