summaryrefslogtreecommitdiffstats
path: root/uca-ufo-camera.c
diff options
context:
space:
mode:
authorMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2016-01-19 09:51:01 +0100
committerMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2016-01-19 09:53:53 +0100
commitcc8f325af1004f375c66a23c22634cfb69aee3fb (patch)
treec0654c484e395fd334ec987fa898d0b75ec4978b /uca-ufo-camera.c
parent27f8f43c64d76f3130ac17e853c87bf5f438776a (diff)
downloaduca-ufo-cc8f325af1004f375c66a23c22634cfb69aee3fb.tar.gz
uca-ufo-cc8f325af1004f375c66a23c22634cfb69aee3fb.tar.bz2
uca-ufo-cc8f325af1004f375c66a23c22634cfb69aee3fb.tar.xz
uca-ufo-cc8f325af1004f375c66a23c22634cfb69aee3fb.zip
Use common write_register_value function
Diffstat (limited to 'uca-ufo-camera.c')
-rw-r--r--uca-ufo-camera.c40
1 files changed, 14 insertions, 26 deletions
diff --git a/uca-ufo-camera.c b/uca-ufo-camera.c
index eddf93f..7455824 100644
--- a/uca-ufo-camera.c
+++ b/uca-ufo-camera.c
@@ -145,6 +145,15 @@ read_register_value (pcilib_t *handle, const gchar *name)
return (guint) reg_value;
}
+static void
+write_register_value (pcilib_t *handle, const gchar *name, pcilib_register_value_t value)
+{
+ int err;
+
+ err = pcilib_write_register (handle, NULL, name, value);
+ PCILIB_WARN_ON_ERROR (err);
+}
+
static int
event_callback(pcilib_event_id_t event_id, pcilib_event_info_t *info, void *user)
{
@@ -235,27 +244,13 @@ read_cmosis_start (UcaUfoCameraPrivate *priv)
static void
write_cmosis_start (UcaUfoCameraPrivate *priv, guint32 start)
{
- gint err;
-
- if (priv->firmware > 5)
- err = pcilib_write_register (priv->handle, NULL, "cmosis_start_single", start);
- else
- err = pcilib_write_register (priv->handle, NULL, "cmosis_start1", start);
-
- PCILIB_WARN_ON_ERROR (err);
+ write_register_value (priv->handle, priv->firmware > 5 ? "cmosis_start_single" : "cmosis_start1", start);
}
static void
write_cmosis_height (UcaUfoCameraPrivate *priv, guint32 number)
{
- gint err;
-
- if (priv->firmware > 5)
- err = pcilib_write_register (priv->handle, NULL, "cmosis_number_lines_single", number);
- else
- err = pcilib_write_register (priv->handle, NULL, "cmosis_number_lines", number);
-
- PCILIB_WARN_ON_ERROR (err);
+ write_register_value (priv->handle, priv->firmware > 5 ? "cmosis_number_lines_single" : "cmosis_number_lines", number);
}
static gboolean
@@ -290,7 +285,6 @@ set_control_bit (UcaUfoCameraPrivate *priv, guint bit, gboolean set)
static const gchar *name = "control";
pcilib_register_value_t flags;
pcilib_register_value_t mask;
- gint err;
flags = read_register_value (priv->handle, name);
mask = 1 << bit;
@@ -300,8 +294,7 @@ set_control_bit (UcaUfoCameraPrivate *priv, guint bit, gboolean set)
else
flags = flags & ~mask;
- err = pcilib_write_register (priv->handle, NULL, name, flags);
- PCILIB_WARN_ON_ERROR (err);
+ write_register_value (priv->handle, name, flags);
}
static gpointer
@@ -491,11 +484,9 @@ uca_ufo_camera_set_property(GObject *object, guint property_id, const GValue *va
{
const guint frequency = priv->frequency == FPGA_40MHZ ? 40 : 48;
const gdouble user_exposure_time = g_value_get_double(value);
- gint err;
pcilib_register_value_t reg_value = (pcilib_register_value_t) (1e6 * user_exposure_time * frequency / 129.0 - 0.43 * 10);
- err = pcilib_write_register(priv->handle, NULL, "cmosis_exp_time", reg_value);
- PCILIB_WARN_ON_ERROR (err);
+ write_register_value (priv->handle, "cmosis_exp_time", reg_value);
}
break;
case PROP_FRAMES_PER_SECOND:
@@ -557,12 +548,9 @@ uca_ufo_camera_set_property(GObject *object, guint property_id, const GValue *va
if (reg_info != NULL) {
pcilib_register_value_t reg_value = 0;
- gint err;
reg_value = g_value_get_uint (value);
-
- err = pcilib_write_register (priv->handle, NULL, reg_info->name, reg_value);
- PCILIB_WARN_ON_ERROR (err);
+ write_register_value (priv->handle, reg_info->name, reg_value);
reg_value = read_register_value (priv->handle, reg_info->name);
reg_info->cached_value = (guint) reg_value;