aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab+samsung@kernel.org>2018-12-23 14:50:57 -0200
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>2018-12-23 15:05:26 -0200
commitfd0012dc863fa13b7c4e23cbf90f92051aca8cf7 (patch)
tree4e64b246396a2f9fe38ba4412837a9d97275a535
parent4ee19584c0cf1048d5cc813ec82f9be249411d3f (diff)
v4l: make zoom logic more complete
There are 3 types of zoom controls on V4L2 API. Instead of assuming just one type, autodetect between all 3 types of control. Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
-rw-r--r--src/callbacks.c2
-rw-r--r--src/v4l.c27
-rw-r--r--src/v4l.h2
3 files changed, 27 insertions, 4 deletions
diff --git a/src/callbacks.c b/src/callbacks.c
index 732b79c..cd72a19 100644
--- a/src/callbacks.c
+++ b/src/callbacks.c
@@ -766,7 +766,7 @@ void zoom_change(GtkScale *sc1, cam_t *cam)
{
cam->zoom = 256 * (int)gtk_range_get_value((GtkRange *) sc1);
- v4l2_set_control(cam->dev, V4L2_CID_ZOOM_ABSOLUTE, cam->zoom);
+ v4l2_set_control(cam->dev, cam->zoom_cid, cam->zoom);
}
void colour_change(GtkScale *sc1, cam_t *cam)
diff --git a/src/v4l.c b/src/v4l.c
index 10c4494..43c9547 100644
--- a/src/v4l.c
+++ b/src/v4l.c
@@ -274,6 +274,29 @@ int camera_cap(cam_t *cam)
return 0;
}
+static int v4l_get_zoom(cam_t *cam)
+{
+ int i;
+
+ cam->zoom_cid = V4L2_CID_ZOOM_ABSOLUTE;
+ i = v4l2_get_control(cam->dev, cam->zoom_cid);
+ if (i >= 0)
+ return i;
+
+ cam->zoom_cid = V4L2_CID_ZOOM_RELATIVE;
+ i = v4l2_get_control(cam->dev, cam->zoom_cid);
+ if (i >= 0)
+ return i;
+
+ cam->zoom_cid = V4L2_CID_ZOOM_CONTINUOUS;
+ i = v4l2_get_control(cam->dev, cam->zoom_cid);
+ if (i >= 0)
+ return i;
+
+ cam->zoom_cid = -1;
+ return -1;
+}
+
void get_pic_info(cam_t *cam)
{
int i;
@@ -297,8 +320,8 @@ void get_pic_info(cam_t *cam)
} else {
cam->colour = -1;
}
- i = v4l2_get_control(cam->dev, V4L2_CID_ZOOM_ABSOLUTE);
- if (i >= 0) {
+ i = v4l_get_zoom(cam);
+ if (cam->zoom_cid) {
cam->zoom = i;
if (cam->debug == TRUE)
printf("zoom = %d\n", cam->zoom);
diff --git a/src/v4l.h b/src/v4l.h
index 323f3db..4aaf976 100644
--- a/src/v4l.h
+++ b/src/v4l.h
@@ -55,7 +55,7 @@ typedef struct camera {
float scale;
CamoImageSize size;
char name[32];
- int contrast, brightness, whiteness, colour, hue, zoom, bytesperline;
+ int contrast, brightness, whiteness, colour, hue, zoom, zoom_cid, bytesperline;
unsigned int pixformat;
int frame_number;

Privacy Policy