ioctl() for dev/video0 gives ENOTTY error

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

ioctl() for dev/video0 gives ENOTTY error

ソリューションへジャンプ
2,796件の閲覧回数
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,683件の閲覧回数
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,684件の閲覧回数
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,778件の閲覧回数
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,773件の閲覧回数
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 件の賞賛
返信