From b184d7f27b9115b7532c7e021e11051a74e93fde Mon Sep 17 00:00:00 2001 From: Dave Hughes Date: Wed, 5 Mar 2014 02:44:40 +0000 Subject: [PATCH] Fix for #3554 v4l2_scan_controls_enumerate_menu is unused and causes ioctl error on RaspberryPi and possibly other Video4Linux variants. See http://www.raspberrypi.org/forum/viewtopic.php?f=43&t=65026 for more detail. --- modules/highgui/src/cap_libv4l.cpp | 29 ----------------------------- modules/highgui/src/cap_v4l.cpp | 24 ------------------------ 2 files changed, 53 deletions(-) diff --git a/modules/highgui/src/cap_libv4l.cpp b/modules/highgui/src/cap_libv4l.cpp index 91047de1f1..e7aa5b5dfe 100644 --- a/modules/highgui/src/cap_libv4l.cpp +++ b/modules/highgui/src/cap_libv4l.cpp @@ -321,7 +321,6 @@ typedef struct CvCaptureCAM_V4L struct v4l2_control control; enum v4l2_buf_type type; struct v4l2_queryctrl queryctrl; - struct v4l2_querymenu querymenu; /* V4L2 control variables */ v4l2_ctrl_range** v4l2_ctrl_ranges; @@ -491,25 +490,6 @@ static int try_init_v4l2(CvCaptureCAM_V4L* capture, char *deviceName) } -static void v4l2_scan_controls_enumerate_menu(CvCaptureCAM_V4L* capture) -{ -// printf (" Menu items:\n"); - CLEAR (capture->querymenu); - capture->querymenu.id = capture->queryctrl.id; - for (capture->querymenu.index = capture->queryctrl.minimum; - (int)capture->querymenu.index <= capture->queryctrl.maximum; - capture->querymenu.index++) - { - if (0 == xioctl (capture->deviceHandle, VIDIOC_QUERYMENU, - &capture->querymenu)) - { - //printf (" %s\n", capture->querymenu.name); - } else { - perror ("VIDIOC_QUERYMENU"); - } - } -} - static void v4l2_free_ranges(CvCaptureCAM_V4L* capture) { int i; if (capture->v4l2_ctrl_ranges != NULL) { @@ -590,9 +570,6 @@ static void v4l2_scan_controls(CvCaptureCAM_V4L* capture) { if(capture->queryctrl.flags & V4L2_CTRL_FLAG_DISABLED) { continue; } - if (capture->queryctrl.type == V4L2_CTRL_TYPE_MENU) { - v4l2_scan_controls_enumerate_menu(capture); - } if(capture->queryctrl.type != V4L2_CTRL_TYPE_INTEGER && capture->queryctrl.type != V4L2_CTRL_TYPE_BOOLEAN && capture->queryctrl.type != V4L2_CTRL_TYPE_MENU) { @@ -613,9 +590,6 @@ static void v4l2_scan_controls(CvCaptureCAM_V4L* capture) { if(capture->queryctrl.flags & V4L2_CTRL_FLAG_DISABLED) { continue; } - if (capture->queryctrl.type == V4L2_CTRL_TYPE_MENU) { - v4l2_scan_controls_enumerate_menu(capture); - } if(capture->queryctrl.type != V4L2_CTRL_TYPE_INTEGER && capture->queryctrl.type != V4L2_CTRL_TYPE_BOOLEAN && capture->queryctrl.type != V4L2_CTRL_TYPE_MENU) { @@ -637,9 +611,6 @@ static void v4l2_scan_controls(CvCaptureCAM_V4L* capture) { continue; } - if (capture->queryctrl.type == V4L2_CTRL_TYPE_MENU) { - v4l2_scan_controls_enumerate_menu(capture); - } if(capture->queryctrl.type != V4L2_CTRL_TYPE_INTEGER && capture->queryctrl.type != V4L2_CTRL_TYPE_BOOLEAN && diff --git a/modules/highgui/src/cap_v4l.cpp b/modules/highgui/src/cap_v4l.cpp index 045c6f889c..c9fca05819 100644 --- a/modules/highgui/src/cap_v4l.cpp +++ b/modules/highgui/src/cap_v4l.cpp @@ -325,7 +325,6 @@ typedef struct CvCaptureCAM_V4L struct v4l2_control control; enum v4l2_buf_type type; struct v4l2_queryctrl queryctrl; - struct v4l2_querymenu querymenu; struct timeval timestamp; @@ -641,24 +640,6 @@ static int autosetup_capture_mode_v4l(CvCaptureCAM_V4L* capture) #ifdef HAVE_CAMV4L2 -static void v4l2_scan_controls_enumerate_menu(CvCaptureCAM_V4L* capture) -{ -// printf (" Menu items:\n"); - CLEAR (capture->querymenu); - capture->querymenu.id = capture->queryctrl.id; - for (capture->querymenu.index = capture->queryctrl.minimum; - (int)capture->querymenu.index <= capture->queryctrl.maximum; - capture->querymenu.index++) - { - if (0 == ioctl (capture->deviceHandle, VIDIOC_QUERYMENU, - &capture->querymenu)) - { -// printf (" %s\n", capture->querymenu.name); - } else { - perror ("VIDIOC_QUERYMENU"); - } - } -} static void v4l2_scan_controls(CvCaptureCAM_V4L* capture) { @@ -723,8 +704,6 @@ static void v4l2_scan_controls(CvCaptureCAM_V4L* capture) capture->v4l2_exposure_max = capture->queryctrl.maximum; } - if (capture->queryctrl.type == V4L2_CTRL_TYPE_MENU) - v4l2_scan_controls_enumerate_menu(capture); } else { @@ -793,9 +772,6 @@ static void v4l2_scan_controls(CvCaptureCAM_V4L* capture) capture->v4l2_exposure_max = capture->queryctrl.maximum; } - if (capture->queryctrl.type == V4L2_CTRL_TYPE_MENU) - v4l2_scan_controls_enumerate_menu(capture); - } else { if (errno == EINVAL)