summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cameras/pco.c37
-rw-r--r--src/cameras/pf.c63
-rw-r--r--src/grabbers/me4.c21
-rw-r--r--src/uca-grabber.h11
4 files changed, 49 insertions, 83 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;
diff --git a/src/grabbers/me4.c b/src/grabbers/me4.c
index 01b908d..d1667ff 100644
--- a/src/grabbers/me4.c
+++ b/src/grabbers/me4.c
@@ -27,12 +27,13 @@ struct uca_sisofg_map_t {
static struct uca_sisofg_map_t uca_to_fg[] = {
/* properties */
- { UCA_GRABBER_WIDTH, FG_WIDTH, false },
- { UCA_GRABBER_HEIGHT, FG_HEIGHT, false },
- { UCA_GRABBER_OFFSET_X, FG_XOFFSET, false },
- { UCA_GRABBER_OFFSET_Y, FG_YOFFSET, false },
- { UCA_GRABBER_EXPOSURE, FG_EXPOSURE, false },
- { UCA_GRABBER_TIMEOUT, FG_TIMEOUT, false },
+ { UCA_PROP_WIDTH, FG_WIDTH, false },
+ { UCA_PROP_HEIGHT, FG_HEIGHT, false },
+ { UCA_PROP_X_OFFSET, FG_XOFFSET, false },
+ { UCA_PROP_Y_OFFSET, FG_YOFFSET, false },
+ { UCA_PROP_EXPOSURE, FG_EXPOSURE, false },
+ { UCA_PROP_GRAB_TIMEOUT, FG_TIMEOUT, false },
+
{ UCA_GRABBER_TRIGGER_MODE, FG_TRIGGERMODE, true},
{ UCA_GRABBER_FORMAT, FG_FORMAT, true},
{ UCA_GRABBER_CAMERALINK_TYPE, FG_CAMERA_LINK_CAMTYP, true },
@@ -70,7 +71,7 @@ static struct uca_sisofg_map_t *uca_me4_find_property(enum uca_grabber_constants
return NULL;
}
-uint32_t uca_me4_set_property(struct uca_grabber *grabber, enum uca_grabber_constants property, void *data)
+uint32_t uca_me4_set_property(struct uca_grabber *grabber, int32_t property, void *data)
{
uint32_t err = UCA_ERR_GRABBER | UCA_ERR_PROP;
struct uca_sisofg_map_t *fg_prop = uca_me4_find_property(property);
@@ -78,7 +79,7 @@ uint32_t uca_me4_set_property(struct uca_grabber *grabber, enum uca_grabber_cons
return err | UCA_ERR_INVALID;
switch (property) {
- case UCA_GRABBER_TIMEOUT:
+ case UCA_PROP_GRAB_TIMEOUT:
((struct fg_apc_data *) grabber->user)->timeout = *((uint32_t *) data);
break;
@@ -122,8 +123,8 @@ uint32_t uca_me4_alloc(struct uca_grabber *grabber, uint32_t pixel_size, uint32_
Fg_FreeMemEx(GET_FG(grabber), mem);
uint32_t width, height;
- uca_me4_get_property(grabber, UCA_GRABBER_WIDTH, &width);
- uca_me4_get_property(grabber, UCA_GRABBER_HEIGHT, &height);
+ uca_me4_get_property(grabber, UCA_PROP_WIDTH, &width);
+ uca_me4_get_property(grabber, UCA_PROP_HEIGHT, &height);
mem = Fg_AllocMemEx(GET_FG(grabber), n_buffers*width*height*pixel_size, n_buffers);
if (mem != NULL) {
diff --git a/src/uca-grabber.h b/src/uca-grabber.h
index 56c10e3..7b3185b 100644
--- a/src/uca-grabber.h
+++ b/src/uca-grabber.h
@@ -2,6 +2,7 @@
#define __UNIFIED_CAMERA_ACCESS_GRABBER_H
#include <stdbool.h>
+#include "uca.h"
#include "uca-cam.h"
/**
@@ -13,15 +14,7 @@ enum uca_grabber_constants {
UCA_GRABBER_INVALID = -1,
/* properties */
- UCA_GRABBER_WIDTH = 0,
- UCA_GRABBER_HEIGHT,
- UCA_GRABBER_WIDTH_MAX,
- UCA_GRABBER_WIDTH_MIN,
- UCA_GRABBER_OFFSET_X,
- UCA_GRABBER_OFFSET_Y,
- UCA_GRABBER_EXPOSURE,
- UCA_GRABBER_TIMEOUT,
- UCA_GRABBER_FORMAT,
+ UCA_GRABBER_FORMAT = UCA_PROP_LAST + 1,
UCA_GRABBER_TRIGGER_MODE,
UCA_GRABBER_CAMERALINK_TYPE,