ioctl() for dev/video0 gives ENOTTY error

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

ioctl() for dev/video0 gives ENOTTY error

跳至解决方案
2,788 次查看
btarnowski
Contributor III

Hi all
There is device list in my Linux system
image.png

and Im going to set exposure to my camera sensor. I work on C/C++ application.
I can make a picture and set exposure from command this way:

v4l2-ctl --device=/dev/v4l-subdev0 --get-ctrl=exposure
v4l2-ctl -d /dev/v4l-subdev0 --set-ctrl exposure=512 
v4l2-ctl --device=/dev/v4l-subdev0 --get-ctrl=analogue_gain

it uses subdevice concept.

And there is my piece of code, here I work with video0. 
open(...) works ok but I can not set any parameter like exposure.
The v4l2_ioctl(...) returns errno= ENOTTY  (the same errno I get with ioct(...) )

ENOTTY - Not a typewriter

    char *videodevice = (char*)"/dev/video0";
	v4l2_control c;
	int descriptor;

	descriptor = open(videodevice, O_RDWR);
    if(descriptor < 0){
        printf("Error Opening VideoDevice,  errno=%d\n",errno);
    }

 	c.id = V4L2_CID_EXPOSURE_ABSOLUTE;
	c.value = 300;
	if(v4l2_ioctl(descriptor, VIDIOC_S_CTRL, &c) == 0)
		printf("V4L2_CID_EXPOSURE_ABSOLUTE:  Value : %d \n",c.value);
	else
		printf("V4L2_CID_EXPOSURE_ABSOLUTE fail,  errno=%d\n",errno);

 

What is wrong ? What can I check/debug ?

 

 

 

 

标签 (1)
0 项奖励
回复
1 解答
2,675 次查看
btarnowski
Contributor III

The control name is wrong. I had to use V4L2_CID_EXPOSURE and  V4L2_CID_ANALOGUE_GAIN as a control id.

Conclusion - do not trust in examples or other working solutions, your specific code can depend on specific details differ than you see in examples

在原帖中查看解决方案

0 项奖励
回复
3 回复数
2,676 次查看
btarnowski
Contributor III

The control name is wrong. I had to use V4L2_CID_EXPOSURE and  V4L2_CID_ANALOGUE_GAIN as a control id.

Conclusion - do not trust in examples or other working solutions, your specific code can depend on specific details differ than you see in examples

0 项奖励
回复
2,770 次查看
Bio_TICFSL
NXP TechSupport
NXP TechSupport

Hello,

Yes you can debug it, but the ENOTY error mean the frmsize structure was left initialize to 0, as side effect, the driver was reporting an invalid frmsize. Size: Stepwise 0x0 - 0x0 with step 0/0 Fix this by replicating the constraints in the raw formats too. This fixes is with software using GSteamer encodebin feature.

 Regards

2,765 次查看
btarnowski
Contributor III

Thank you for your replay,
Do you mean this one structure ?

I found this as your base for answer and it is not so clear for me.
https://lkml.org/lkml/2022/12/23/380

By the way, I can get picture with gstreamer
image.png

0 项奖励
回复