diff options
author | Matthias Vogelgesang <matthias.vogelgesang@ipe.fzk.de> | 2011-03-14 11:40:54 +0100 |
---|---|---|
committer | Matthias Vogelgesang <matthias.vogelgesang@ipe.fzk.de> | 2011-03-14 11:40:54 +0100 |
commit | b1b747d9f0f1065a6078dfc788fff60109fc007e (patch) | |
tree | 1b79b8d46a0742907d696eb5ed418d3e2cd942c7 | |
parent | d306da6a22d6f3dab9a3c3384896f6b29948e492 (diff) | |
download | uca-b1b747d9f0f1065a6078dfc788fff60109fc007e.tar.gz uca-b1b747d9f0f1065a6078dfc788fff60109fc007e.tar.bz2 uca-b1b747d9f0f1065a6078dfc788fff60109fc007e.tar.xz uca-b1b747d9f0f1065a6078dfc788fff60109fc007e.zip |
Get rid of SiSo-dependant grabber constants
-rw-r--r-- | src/cameras/pco.c | 31 | ||||
-rw-r--r-- | src/cameras/pf.c | 44 | ||||
-rw-r--r-- | src/grabbers/me4.c | 65 | ||||
-rw-r--r-- | src/uca-grabber.h | 28 |
4 files changed, 115 insertions, 53 deletions
diff --git a/src/cameras/pco.c b/src/cameras/pco.c index 9ae94c8..4f793dc 100644 --- a/src/cameras/pco.c +++ b/src/cameras/pco.c @@ -7,9 +7,6 @@ #include "uca-grabber.h" #include "pco.h" -/* TODO: REMOVE THIS ASAP */ -#include <fgrab_struct.h> - #define GET_PCO(uca) ((struct pco_edge_t *)(uca->user)) #define set_void(p, type, value) { *((type *) p) = (type) value; } @@ -48,24 +45,24 @@ static uint32_t uca_pco_set_property(struct uca_camera_t *cam, enum uca_property switch (property) { case UCA_PROP_WIDTH: - if (grabber->set_property(grabber, FG_WIDTH, (uint32_t *) data) != UCA_NO_ERROR) + if (grabber->set_property(grabber, UCA_GRABBER_WIDTH, (uint32_t *) data) != UCA_NO_ERROR) return UCA_ERR_PROP_VALUE_OUT_OF_RANGE; cam->frame_width = *((uint32_t *) data); break; case UCA_PROP_HEIGHT: - if (grabber->set_property(grabber, FG_HEIGHT, (uint32_t *) data) != UCA_NO_ERROR) + if (grabber->set_property(grabber, UCA_GRABBER_HEIGHT, (uint32_t *) data) != UCA_NO_ERROR) return UCA_ERR_PROP_VALUE_OUT_OF_RANGE; cam->frame_height = *((uint32_t *) data); break; case UCA_PROP_X_OFFSET: - if (grabber->set_property(grabber, FG_XOFFSET, (uint32_t *) data) != UCA_NO_ERROR) + if (grabber->set_property(grabber, UCA_GRABBER_OFFSET_X, (uint32_t *) data) != UCA_NO_ERROR) return UCA_ERR_PROP_VALUE_OUT_OF_RANGE; break; case UCA_PROP_Y_OFFSET: - if (grabber->set_property(grabber, FG_YOFFSET, (uint32_t *) data) != UCA_NO_ERROR) + if (grabber->set_property(grabber, UCA_GRABBER_OFFSET_Y, (uint32_t *) data) != UCA_NO_ERROR) return UCA_ERR_PROP_VALUE_OUT_OF_RANGE; break; @@ -147,12 +144,12 @@ static uint32_t uca_pco_get_property(struct uca_camera_t *cam, enum uca_property break; case UCA_PROP_X_OFFSET: - if (grabber->get_property(grabber, FG_XOFFSET, (uint32_t *) data) != UCA_NO_ERROR) + if (grabber->get_property(grabber, UCA_GRABBER_OFFSET_X, (uint32_t *) data) != UCA_NO_ERROR) return UCA_ERR_PROP_GENERAL; break; case UCA_PROP_Y_OFFSET: - if (grabber->get_property(grabber, FG_YOFFSET, (uint32_t *) data) != UCA_NO_ERROR) + if (grabber->get_property(grabber, UCA_GRABBER_OFFSET_Y, (uint32_t *) data) != UCA_NO_ERROR) return UCA_ERR_PROP_GENERAL; break; @@ -263,14 +260,14 @@ uint32_t uca_pco_init(struct uca_camera_t **cam, struct uca_grabber_t *grabber) pco_arm_camera(pco); /* Prepare frame grabber for recording */ - int val = FG_CL_8BIT_FULL_10; - grabber->set_property(grabber, FG_CAMERA_LINK_CAMTYP, &val); + int val = UCA_CL_8BIT_FULL_10; + grabber->set_property(grabber, UCA_GRABBER_CAMERALINK_TYPE, &val); - val = FG_GRAY; - grabber->set_property(grabber, FG_FORMAT, &val); + val = UCA_FORMAT_GRAY8; + grabber->set_property(grabber, UCA_GRABBER_FORMAT, &val); - val = FREE_RUN; - grabber->set_property(grabber, FG_TRIGGERMODE, &val); + val = UCA_TRIGGER_FREERUN; + grabber->set_property(grabber, UCA_GRABBER_TRIGGER_MODE, &val); uint32_t width, height; pco_get_actual_size(pco, &width, &height); @@ -280,8 +277,8 @@ uint32_t uca_pco_init(struct uca_camera_t **cam, struct uca_grabber_t *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, FG_WIDTH, &width); - grabber->set_property(grabber, FG_HEIGHT, &height); + grabber->set_property(grabber, UCA_GRABBER_WIDTH, &width); + grabber->set_property(grabber, UCA_GRABBER_HEIGHT, &height); uca->state = UCA_CAM_CONFIGURABLE; *cam = uca; diff --git a/src/cameras/pf.c b/src/cameras/pf.c index c199576..5b0679e 100644 --- a/src/cameras/pf.c +++ b/src/cameras/pf.c @@ -7,22 +7,6 @@ #include "uca-cam.h" #include "uca-grabber.h" -/* TODO: REMOVE THIS ASAP */ -#define FG_WIDTH 100 -#define FG_HEIGHT 200 - -#define FG_MAXWIDTH 6100 -#define FG_MAXHEIGHT 6200 -#define FG_ACTIVEPORT 6300 -#define FG_XOFFSET 300 -#define FG_YOFFSET 400 -#define FG_FORMAT 700 -#define FG_GRAY 3 -#define FG_CAMERA_LINK_CAMTYP 11011 -#define FG_CL_8BIT_FULL_8 308 -#define FG_TRIGGERMODE 8100 -#define FG_EXPOSURE 10020 /**< Exposure Time in us (Brigthness) (float) */ - #define set_void(p, type, value) { *((type *) p) = value; } struct uca_pf_map { @@ -63,8 +47,10 @@ static uint32_t uca_pf_set_property(struct uca_camera_t *cam, enum uca_property_ /* Find a valid pf token for the property */ while (uca_to_pf[i].uca_prop != -1) { - if (uca_to_pf[i].uca_prop == property) + if (uca_to_pf[i].uca_prop == property) { t = pfProperty_ParseName(0, uca_to_pf[i].pf_prop); + break; + } i++; } if (t == INVALID_TOKEN) @@ -74,7 +60,7 @@ static uint32_t uca_pf_set_property(struct uca_camera_t *cam, enum uca_property_ switch (property) { case UCA_PROP_WIDTH: - if (grabber->set_property(grabber, FG_WIDTH, (uint32_t *) data) != UCA_NO_ERROR) + if (grabber->set_property(grabber, UCA_GRABBER_WIDTH, (uint32_t *) data) != UCA_NO_ERROR) return UCA_ERR_PROP_VALUE_OUT_OF_RANGE; value.value.i = *((uint32_t *) data); @@ -85,7 +71,7 @@ static uint32_t uca_pf_set_property(struct uca_camera_t *cam, enum uca_property_ break; case UCA_PROP_HEIGHT: - if (grabber->set_property(grabber, FG_HEIGHT, (uint32_t *) data) != UCA_NO_ERROR) + if (grabber->set_property(grabber, UCA_GRABBER_HEIGHT, (uint32_t *) data) != UCA_NO_ERROR) return UCA_ERR_PROP_VALUE_OUT_OF_RANGE; value.value.i = *((uint32_t *) data); @@ -96,12 +82,12 @@ static uint32_t uca_pf_set_property(struct uca_camera_t *cam, enum uca_property_ break; case UCA_PROP_X_OFFSET: - if (grabber->set_property(grabber, FG_XOFFSET, (uint32_t *) data) != UCA_NO_ERROR) + if (grabber->set_property(grabber, UCA_GRABBER_OFFSET_X, (uint32_t *) data) != UCA_NO_ERROR) return UCA_ERR_PROP_VALUE_OUT_OF_RANGE; break; case UCA_PROP_Y_OFFSET: - if (grabber->set_property(grabber, FG_YOFFSET, (uint32_t *) data) != UCA_NO_ERROR) + if (grabber->set_property(grabber, UCA_GRABBER_OFFSET_Y, (uint32_t *) data) != UCA_NO_ERROR) return UCA_ERR_PROP_VALUE_OUT_OF_RANGE; break; @@ -224,20 +210,20 @@ uint32_t uca_pf_init(struct uca_camera_t **cam, struct uca_grabber_t *grabber) uca->grab = &uca_pf_grab; /* Prepare frame grabber for recording */ - int val = FG_CL_8BIT_FULL_8; - grabber->set_property(grabber, FG_CAMERA_LINK_CAMTYP, &val); + int val = UCA_CL_8BIT_FULL_8; + grabber->set_property(grabber, UCA_GRABBER_CAMERALINK_TYPE, &val); - val = FG_GRAY; - grabber->set_property(grabber, FG_FORMAT, &val); + val = UCA_FORMAT_GRAY8; + grabber->set_property(grabber, UCA_GRABBER_FORMAT, &val); - val = 0; - grabber->set_property(grabber, FG_TRIGGERMODE, &val); + val = UCA_TRIGGER_FREERUN; + grabber->set_property(grabber, UCA_GRABBER_TRIGGER_MODE, &val); uca_pf_get_property(uca, UCA_PROP_WIDTH, &uca->frame_width); uca_pf_get_property(uca, UCA_PROP_HEIGHT, &uca->frame_height); - grabber->set_property(grabber, FG_WIDTH, &uca->frame_width); - grabber->set_property(grabber, FG_HEIGHT, &uca->frame_height); + grabber->set_property(grabber, UCA_GRABBER_WIDTH, &uca->frame_width); + grabber->set_property(grabber, UCA_GRABBER_HEIGHT, &uca->frame_height); uca->state = UCA_CAM_CONFIGURABLE; *cam = uca; diff --git a/src/grabbers/me4.c b/src/grabbers/me4.c index e5ece38..f588298 100644 --- a/src/grabbers/me4.c +++ b/src/grabbers/me4.c @@ -13,6 +13,32 @@ struct uca_me4_grabber_t { dma_mem *mem; }; +struct uca_sisofg_map_t { + enum uca_grabber_constants uca_prop; + int fg_id; + bool interpret_data; /**< is data a constant or a value? */ +}; + +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_TRIGGER_MODE, FG_TRIGGERMODE, true}, + { UCA_GRABBER_FORMAT, FG_FORMAT, true}, + { UCA_GRABBER_CAMERALINK_TYPE, FG_CAMERA_LINK_CAMTYP, true }, + + /* values */ + { UCA_FORMAT_GRAY8, FG_GRAY, false }, + { UCA_FORMAT_GRAY16, FG_GRAY16, false }, + { UCA_CL_8BIT_FULL_8, FG_CL_8BIT_FULL_8, false }, + { UCA_CL_8BIT_FULL_10, FG_CL_8BIT_FULL_10, false }, + { UCA_TRIGGER_FREERUN, FREE_RUN, false }, + { UCA_GRABBER_INVALID, 0, false } +}; + #define GET_FG(grabber) (((struct uca_me4_grabber_t *) grabber->user)->fg) #define GET_MEM(grabber) (((struct uca_me4_grabber_t *) grabber->user)->mem) @@ -25,14 +51,44 @@ uint32_t uca_me4_destroy(struct uca_grabber_t *grabber) return UCA_NO_ERROR; } -uint32_t uca_me4_set_property(struct uca_grabber_t *grabber, enum uca_property_ids property, void *data) +static struct uca_sisofg_map_t *uca_me4_find_property(enum uca_grabber_constants property) +{ + int i = 0; + /* Find a valid frame grabber id for the property */ + while (uca_to_fg[i].uca_prop != UCA_GRABBER_INVALID) { + if (uca_to_fg[i].uca_prop == property) + return &uca_to_fg[i]; + i++; + } + return NULL; +} + +uint32_t uca_me4_set_property(struct uca_grabber_t *grabber, enum uca_grabber_constants property, void *data) { - return Fg_setParameter(GET_FG(grabber), property, data, PORT_A) == FG_OK ? UCA_NO_ERROR : UCA_ERR_PROP_GENERAL; + struct uca_sisofg_map_t *fg_prop = uca_me4_find_property(property); + if (fg_prop == NULL) + return UCA_ERR_PROP_INVALID; + + if (fg_prop->interpret_data) { + /* Data is not a value but a constant that we need to translate to + * Silicon Software speak. Therefore, we try to find it in the map also. */ + struct uca_sisofg_map_t *constant = uca_me4_find_property(*((uint32_t *) data)); + if (constant != NULL) + return Fg_setParameter(GET_FG(grabber), fg_prop->fg_id, &constant->fg_id, PORT_A) == FG_OK ? UCA_NO_ERROR : UCA_ERR_PROP_INVALID; + return UCA_ERR_PROP_INVALID; + } + else + return Fg_setParameter(GET_FG(grabber), fg_prop->fg_id, data, PORT_A) == FG_OK ? UCA_NO_ERROR : UCA_ERR_PROP_GENERAL; } -uint32_t uca_me4_get_property(struct uca_grabber_t *grabber, enum uca_property_ids property, void *data) +uint32_t uca_me4_get_property(struct uca_grabber_t *grabber, enum uca_grabber_constants property, void *data) { - return Fg_getParameter(GET_FG(grabber), property, data, PORT_A) == FG_OK ? UCA_NO_ERROR : UCA_ERR_PROP_GENERAL; + struct uca_sisofg_map_t *fg_prop = uca_me4_find_property(property); + if (fg_prop == NULL) + return UCA_ERR_PROP_INVALID; + + /* FIXME: translate data back to UCA_ normalized constants */ + return Fg_getParameter(GET_FG(grabber), fg_prop->fg_id, data, PORT_A) == FG_OK ? UCA_NO_ERROR : UCA_ERR_PROP_GENERAL; } uint32_t uca_me4_alloc(struct uca_grabber_t *grabber, uint32_t pixel_size, uint32_t n_buffers) @@ -45,7 +101,6 @@ uint32_t uca_me4_alloc(struct uca_grabber_t *grabber, uint32_t pixel_size, uint3 uca_me4_get_property(grabber, FG_WIDTH, &width); uca_me4_get_property(grabber, FG_HEIGHT, &height); - /* FIXME: get size of pixel */ dma_mem *mem = Fg_AllocMemEx(GET_FG(grabber), n_buffers*width*height*pixel_size, n_buffers); if (mem != NULL) { ((struct uca_me4_grabber_t *) grabber->user)->mem = mem; diff --git a/src/uca-grabber.h b/src/uca-grabber.h index 6ae7e8e..bf6bf31 100644 --- a/src/uca-grabber.h +++ b/src/uca-grabber.h @@ -3,6 +3,30 @@ #include <stdbool.h> +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_FORMAT, + UCA_GRABBER_TRIGGER_MODE, + UCA_GRABBER_CAMERALINK_TYPE, + + /* values */ + UCA_FORMAT_GRAY8, + UCA_FORMAT_GRAY16, + + UCA_CL_8BIT_FULL_8, + UCA_CL_8BIT_FULL_10, + + UCA_TRIGGER_FREERUN +}; + /* * --- virtual methods -------------------------------------------------------- */ @@ -24,14 +48,14 @@ typedef uint32_t (*uca_grabber_destroy) (struct uca_grabber_t *grabber); * \return UCA_ERR_PROP_INVALID if property is not supported on the frame * grabber or UCA_ERR_PROP_VALUE_OUT_OF_RANGE if value cannot be set. */ -typedef uint32_t (*uca_grabber_set_property) (struct uca_grabber_t *grabber, enum uca_property_ids property, void *data); +typedef uint32_t (*uca_grabber_set_property) (struct uca_grabber_t *grabber, enum uca_grabber_constants prop, void *data); /** * \brief Set a property * \param[in] property_name Name of the property as defined in XXX * \return UCA_ERR_PROP_INVALID if property is not supported on the frame grabber */ -typedef uint32_t (*uca_grabber_get_property) (struct uca_grabber_t *grabber, enum uca_property_ids property, void *data); +typedef uint32_t (*uca_grabber_get_property) (struct uca_grabber_t *grabber, enum uca_grabber_constants prop, void *data); /** * \brief Allocate buffers with current width, height and bitdepth |