全志 v4l2 VIDIOC_S_CTRL 报错Inappropriate ioctl for device
最近,有个热成像的uvc摄像头,在v4l2 ioctlv4l2 VIDIOC_S_CTRL报错
v4l2 VIDIOC_S_CTRL 报错
错误信息:
iioctl(fd, VIDIOC_S_CTRL, &ctrl) == -1)
报错: Inappropriate ioctl for device
跟踪内核代码:linux-3.4/drivers/media/video/uvc/uvc_v4l2.c
函数: uvc_v4l2_do_ioctl()
default:
uvc_trace(UVC_TRACE_IOCTL, "Unknown ioctl 0x%08x\n", cmd);
return -ENOTTY;
}
没找到命令? 奇怪了,
根据信息 uvcvideo: Unknown ioctl 0xc008561c
难度VIDIOC_S_CTRL的值不为0xc008561c,在内核打印VIDIOC_S_CTRL的值为:c00c561c
说明VIDIOC_S_CTRL的定义在应用程序头文件和内核不一样
内核查找VIDIOC_S_CTRL定义
include/linux/videodev2.h:2497:#define VIDIOC_S_CTRL _IOWR('V', 28, struct v4l2_control)
应用程序定义
libc/usr/include/linux/videodev2.h:1874:#define VIDIOC_S_CTRL _IOWR('V', 28, struct v4l2_control)
看似应该是一样,差别应该在_IOWR和struct v4l2_control的定义,
继续查找struct v4l2_control定义
内核:
1147 /*
1148 * C O N T R O L S
1149 */
1150 struct v4l2_control {
1151 __u32 id;
1152 __s32 value;
1153 __u32 user_pt; /* Add user pointer by raymonxiu */
1154 };
应用程序
libc/usr/include/linux/videodev2.h
/*
* C O N T R O L S
*/
struct v4l2_control {
__u32 id;
__s32 value;
};
终于明白了,全志修改了v4l2_control定义
[问题解决]
在libc/usr/include/linux/videodev2.h头文件修改
struct v4l2_control {
__u32 id;
__s32 value;
};
为
struct v4l2_control {
__u32 id;
__s32 value;
__u32 user_pt; /* Add user pointer by raymonxiu */
};