aboutsummaryrefslogtreecommitdiffstats
path: root/src/v4l.c
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 /src/v4l.c
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>
Diffstat (limited to 'src/v4l.c')
-rw-r--r--src/v4l.c27
1 files changed, 25 insertions, 2 deletions
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);

Privacy Policy