Error using V4l2 API's VIDIOC_G_CTRL

Hi Team,

I have written v4l2 driver for AP1302. I am able to control V4l2 parameters with cmds.

v4l2-ctl -d /dev/v4l-subdev4 -L

User Controls

                 brightness 0x00980900 (int)    : min=0 max=65535 step=256 default=0 value=0
                   contrast 0x00980901 (int)    : min=0 max=65535 step=256 default=0 value=0
                 saturation 0x00980902 (int)    : min=0 max=65535 step=256 default=4096 value=4096
         white_balance_mode 0x0098090c (menu)   : min=0 max=1 default=1 value=1
			0: Manual Temp Mode
			1: Auto Mode
                      gamma 0x00980910 (int)    : min=0 max=65535 step=256 default=0 value=0
                   exposure 0x00980911 (int)    : min=0 max=1000000 step=1 default=10000 value=10000
                       gain 0x00980913 (int)    : min=0 max=65535 step=256 default=256 value=256
                      hflip 0x00980914 (bool)   : default=0 value=0
                      vflip 0x00980915 (bool)   : default=0 value=0
  white_balance_temperature 0x0098091a (int)    : min=2300 max=15000 step=1 default=5000 value=5000
                  sharpness 0x0098091b (int)    : min=0 max=65535 step=256 default=0 value=0
     backlight_compensation 0x0098091c (int)    : min=0 max=65535 step=256 default=256 value=256
             special_effect 0x0098091f (menu)   : min=0 max=4 default=0 value=0
			0: Normal Mode
			1: Black and White Mode
			2: Grayscale Mode
			3: Negative Mode
			4: Sketch Mode

Camera Controls

              exposure_mode 0x009a0901 (menu)   : min=0 max=1 default=1 value=1
			0: Manual Mode
			1: Auto Mode
                 pan_target 0x009a0908 (int)    : min=0 max=256 step=1 default=128 value=128
                tilt_target 0x009a0909 (int)    : min=0 max=256 step=1 default=128 value=128
                zoom_target 0x009a090d (int)    : min=256 max=2048 step=1 default=256 value=256
                 scene_mode 0x009a091a (menu)   : min=0 max=13 default=0 value=0
			0: None
			1: Backlight
			2: Beach/Snow
			3: Candle Light
			6: Fireworks
			7: Landscape
			8: Night
			9: Party/Indoor
			10: Portrait
			11: Sports
			12: Sunset
			13: Text
                 group_hold 0x009a2003 (bool)   : default=0 value=0 flags=execute-on-write
                sensor_mode 0x009a2008 (int64)  : min=0 max=4 step=1 default=0 value=0 flags=slider
                 frame_rate 0x009a200b (int64)  : min=2000000 max=30000000 step=1 default=30000000 value=2000000 flags=slider

I am able to change it cmd but with API it is giving me error 22.
I am using sample API /usr/src/jetson_multimedia_api/samples/12_v4l2_camera_cuda/camera_v4l2_cuda.cpp and added following function.

static bool
control_v4l2(context_t*ctx)
{
struct v4l2_ext_controls ctrls;
struct v4l2_ext_control ctrl;
ctrls.ctrl_class = V4L2_CTRL_ID2CLASS(V4L2_CID_GAIN);
ctrls.count = 1;
ctrls.controls = &ctrl;

memset(&ctrl, 0, sizeof(ctrl));
ctrl.id = V4L2_CID_GAIN;

if (ioctl(ctx->cam_fd, VIDIOC_G_EXT_CTRLS, &ctrls) < 0)
     ERROR_RETURN("Failed to dequeue camera buff: %s (%d)",
     strerror(errno), errno);

return 1;
}

But after this I am getting ERROR: control_v4l2(): (line:576) Failed to dequeue camera buff: Invalid argument (22)

I have taken reference of topic Failed to configure sensor_mode by using v4l2 API

Thank you,

Hi @shree24,

sorry for the delay in answering. I think your question might better be suited for the Jetson categories in our forums.

I hope you don’t mind me moving the post.

Thanks!

Hi @MarkusHoHo ,

I don’t mind if you move this post to another category but I didn’t get any reply even after a week. So what should I do according to you.

Thank you

Hey No reply from 2 weeks

Sorry for the late response.
Is this still an issue to support? Any result can be shared?

please also examine your driver by v4l2-compliance test.

v4l2-compliance
v4l2-compliance SHA: not available, 64 bits

Compliance test for tegra-video device /dev/video0:

Driver Info:
Driver name : tegra-video
Card type : vi-output, tevi-ap1302 12-003d
Bus info : platform:tegra-capture-vi:0
Driver version : 5.10.120
Capabilities : 0x84200001
Video Capture
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04200001
Video Capture
Streaming
Extended Pix Format
Media Driver Info:
Driver name : tegra-camrtc-ca
Model : NVIDIA Tegra Video Input Device
Serial :
Bus info :
Media version : 5.10.120
Hardware revision: 0x00000003 (3)
Driver version : 5.10.120
Interface Info:
ID : 0x03000011
Type : V4L Video
Entity Info:
ID : 0x0000000f (15)
Name : vi-output, tevi-ap1302 12-003d
Function : V4L2 I/O
Pad 0x01000010 : 0: Sink
Link 0x02000015: from remote pad 0x100000c of entity ‘13e10000.host1x:nvcsi@15a00000-’: Data, Enabled

Required ioctls:
test MC information (see ‘Media Driver Info’ above): OK
test VIDIOC_QUERYCAP: OK

Allow for multiple opens:
test second /dev/video0 open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK
test for unlimited opens: OK

Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported)
test VIDIOC_LOG_STATUS: OK

Input ioctls:
test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported)
test VIDIOC_ENUMAUDIO: OK (Not Supported)
test VIDIOC_G/S/ENUMINPUT: OK
test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 1 Audio Inputs: 0 Tuners: 0

Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_ENUMAUDOUT: OK (Not Supported)
test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported)
test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0

Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported)
test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)
test VIDIOC_G/S_EDID: OK (Not Supported)

Control ioctls (Input 0):
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK
test VIDIOC_QUERYCTRL: OK
test VIDIOC_G/S_CTRL: OK
test VIDIOC_G/S/TRY_EXT_CTRLS: OK
test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK
test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
Standard Controls: 1 Private Controls: 18

Format ioctls (Input 0):
fail: v4l2-test-formats.cpp(280): duplicate format 59565955 (UYVY)
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: FAIL
fail: v4l2-test-formats.cpp(1280): ret && node->has_frmintervals
test VIDIOC_G/S_PARM: FAIL
test VIDIOC_G_FBUF: OK (Not Supported)
test VIDIOC_G_FMT: OK
test VIDIOC_TRY_FMT: OK
test VIDIOC_S_FMT: OK
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)
test Cropping: OK (Not Supported)
test Composing: OK (Not Supported)
test Scaling: OK (Not Supported)

Codec ioctls (Input 0):
test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported)
test VIDIOC_G_ENC_INDEX: OK (Not Supported)
test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)

Buffer ioctls (Input 0):
fail: v4l2-test-buffers.cpp(715): q.create_bufs(node, 1, &fmt) != EINVAL
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: FAIL
test VIDIOC_EXPBUF: OK
test Requests: OK (Not Supported)

Total for tegra-video device /dev/video0: 45, Succeeded: 42, Failed: 3, Warnings: 0

hello shree24,

it looks sanity test of these controls has passed.
please examine your implementation, and… may I know what’s the real use-case for sending gain controls.

I just want to control all the v4l2 control parameters. I am able to set and get all the parameters from cmd line. When I am trying to use it from wrapper there it is not working.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.