What is the basic process for using ioctl in C code?

Dear Nvidia support team,;
recently I encountered a problem in developing custom ioctl function. I implemented a custom ioctl with CID TEGRA_CAMERA_CID_DEMOSENSV300STR in the driver, and it could be executed normally using the v4l2-ctl --set-ctrl /–get-ctrl command, and the desired result could be obtained. However, when I tried to use it in my C code, there was a problem. There was no such problem for a s64 data type ioctl TEGRA_CAMERA_CID_DEMOSENSV300CMD implemented in the same way. The specific code and error message for the problem are as follows.
1:VIDIOC_S_EXT_CTRLS :Error EEPROM VIDIOC_S_EXT_CTRLS No space left on device
2:VIDIOC_S_EXT_CTRLS:Error EEPROM VIDIOC_S_EXT_CTRLS Numerical result out of range

    char test[10]="hello11";
    struct v4l2_ext_controls ctrls;
    struct v4l2_ext_control ctrl;
    CLEAR(ctrl);
    CLEAR(ctrls);
    ctrls.controls = &ctrl;
    ctrls.count = 1;
    //ctrls.which = V4L2_CTRL_WHICH_CUR_VAL;
    ctrl.string=test;
    //qDebug("ctrl.ptr = %p %p %x\n",ptr,*ptr,ptr->regAddr);
    ctrl.id = TEGRA_CAMERA_CID_DEMOSENSV300STR;
    if (ioctl(fd, VIDIOC_S_EXT_CTRLS, &ctrls) == -1) {
         fprintf(stderr, "Error EEPROM VIDIOC_S_EXT_CTRLS %s\n",strerror(errno));
     }

USE 4VL2-CTL WITH NO PROBLEM :


[ 1653.399476] imx318 30-0010: [IMX318]: imx318_demosensv300str_ctrl_ex at  cmd value =demosens =============flag = 1.
[ 1681.528605] imx318 30-0010: [IMX318]: imx318_demosensv300str_ctrl_ex at  cmd value =demosens =============flag = 1.
[ 1696.683679] imx318 30-0010: [IMX318]: imx318_demosensv300str_ctrl_ex at  cmd value =aaaaa =============flag = 1.
smartsens@smartsens-desktop:~/Downloads$ v4l2-ctl --get-ctrl demosensv300str
demosensv300str: 'aaaaa'
smartsens@smartsens-desktop:~/Downloads$ v4l2-ctl --set-ctrl demosensv300str="hello nvidia"
smartsens@smartsens-desktop:~/Downloads$ v4l2-ctl --get-ctrl demosensv300str
demosensv300str: 'hello nvidia'
smartsens@smartsens-desktop:~/Downloads$

I found the source code of v4l2-ctl, so I think it should be fine. Thank you for your support.

1 Like

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