summaryrefslogtreecommitdiffstats
path: root/src/grabbers
diff options
context:
space:
mode:
authorMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2011-03-24 11:06:52 +0100
committerMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2011-03-24 11:06:52 +0100
commit22b2e4f0947bae6cbfc303fe15141b766cc88c04 (patch)
treea425450a1cce7879baaf8dbd2654313b29d014b9 /src/grabbers
parent46d38f50041e45cf878fa9a194b0f2dc7aa4dcf7 (diff)
downloadlibuca-22b2e4f0947bae6cbfc303fe15141b766cc88c04.tar.gz
libuca-22b2e4f0947bae6cbfc303fe15141b766cc88c04.tar.bz2
libuca-22b2e4f0947bae6cbfc303fe15141b766cc88c04.tar.xz
libuca-22b2e4f0947bae6cbfc303fe15141b766cc88c04.zip
Convert me4 constants back to uca constants
Diffstat (limited to 'src/grabbers')
-rw-r--r--src/grabbers/me4.c35
1 files changed, 30 insertions, 5 deletions
diff --git a/src/grabbers/me4.c b/src/grabbers/me4.c
index ceac483..6d20a71 100644
--- a/src/grabbers/me4.c
+++ b/src/grabbers/me4.c
@@ -59,7 +59,7 @@ uint32_t uca_me4_destroy(struct uca_grabber *grabber)
return UCA_NO_ERROR;
}
-static struct uca_sisofg_map_t *uca_me4_find_property(enum uca_grabber_constants property)
+static struct uca_sisofg_map_t *uca_me4_find_fg_property(enum uca_grabber_constants property)
{
int i = 0;
/* Find a valid frame grabber id for the property */
@@ -71,6 +71,18 @@ static struct uca_sisofg_map_t *uca_me4_find_property(enum uca_grabber_constants
return NULL;
}
+static struct uca_sisofg_map_t *uca_me4_find_uca_property(int fg_id)
+{
+ int i = 0;
+ /* Find a valid frame grabber id for the property */
+ while (uca_to_fg[i].fg_id != 0) {
+ if (uca_to_fg[i].fg_id == fg_id)
+ return &uca_to_fg[i];
+ i++;
+ }
+ return NULL;
+}
+
uint32_t uca_me4_set_property(struct uca_grabber *grabber, int32_t property, void *data)
{
/* Handle all properties not related specifically to the me4 */
@@ -90,7 +102,7 @@ uint32_t uca_me4_set_property(struct uca_grabber *grabber, int32_t property, voi
/* Try to find a matching me4 property */
uint32_t err = UCA_ERR_GRABBER | UCA_ERR_PROP;
- struct uca_sisofg_map_t *fg_prop = uca_me4_find_property(property);
+ struct uca_sisofg_map_t *fg_prop = uca_me4_find_fg_property(property);
if (fg_prop == NULL)
return err | UCA_ERR_INVALID;
@@ -98,7 +110,7 @@ uint32_t uca_me4_set_property(struct uca_grabber *grabber, int32_t property, voi
/* Data is not a value but a SiSo specific constant that we need to
* translate to Silicon Software speak. Therefore, we try to find it in
* the map. */
- struct uca_sisofg_map_t *constant = uca_me4_find_property(*((uint32_t *) data));
+ struct uca_sisofg_map_t *constant = uca_me4_find_fg_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 : err | UCA_ERR_INVALID;
@@ -121,11 +133,24 @@ uint32_t uca_me4_get_property(struct uca_grabber *grabber, int32_t property, voi
}
uint32_t err = UCA_ERR_GRABBER | UCA_ERR_PROP;
- struct uca_sisofg_map_t *fg_prop = uca_me4_find_property(property);
+ struct uca_sisofg_map_t *fg_prop = uca_me4_find_fg_property(property);
if (fg_prop == NULL)
return err | UCA_ERR_INVALID;
- /* FIXME: translate data back to UCA_ normalized constants */
+ if (fg_prop->interpret_data) {
+ int constant;
+ if (Fg_getParameter(GET_FG(grabber), fg_prop->fg_id, &constant, PORT_A) != FG_OK)
+ return err | UCA_ERR_INVALID;
+
+ /* Try to find the constant value */
+ struct uca_sisofg_map_t *uca_prop = uca_me4_find_uca_property(constant);
+ if (uca_prop == NULL)
+ return err | UCA_ERR_INVALID;
+
+ *((uint32_t *) data) = uca_prop->uca_prop;
+ return UCA_NO_ERROR;
+ }
+
return Fg_getParameter(GET_FG(grabber), fg_prop->fg_id, data, PORT_A) == FG_OK ? \
UCA_NO_ERROR : err | UCA_ERR_INVALID;
}