VC-MIPI-modules / vc_mipi_nvidia

Vision Components MIPI CSI-2 driver for NVIDIA Jetson Nano, Xavier NX, AGX Xavier, TX2 and Orin Nano, Orin NX
69 stars 31 forks source link

v4l2_control invalid argument and permission denied error #63

Open xaprier opened 5 months ago

xaprier commented 5 months ago

Using Auvidea JNX30D with L4T 32.7.3 Camera: IMX568

I'm writing a module for setting camera controls with v4l, and when i try to get/set values of controls, i have got an error with specific controls.

Code block:

bool getControl(int controlId, int &value) {
    struct v4l2_control ctrl;
    std::memset(&ctrl, 0, sizeof(ctrl));
    ctrl.id = controlId;

    if (ioctl(_fd, VIDIOC_G_CTRL, &ctrl) == -1) {
        std::perror(std::string("Error getting control of " + std::to_string(controlId)).c_str());
        return false;
    }
    value = ctrl.value;
    return true;
}

I'm getting the controlId with querying the controls:

void queryControls(const std::string &devicePath) {
    int fd = open(devicePath.c_str(), O_RDWR);
    if (fd == -1) {
        std::perror("error opening device");
        return;
    }

    v4l2_queryctrl queryctrl;
    std::memset(&queryctrl, 0, sizeof(queryctrl));
    queryctrl.id = V4L2_CTRL_FLAG_NEXT_CTRL;
    while (ioctl(fd, VIDIOC_QUERYCTRL, &queryctrl) == 0) {
        std::cout << "Control id = " << queryctrl.id << std::endl;
        std::cout << "Control Name = " << queryctrl.name << std::endl;

        // next control
        queryctrl.id |= V4L2_CTRL_FLAG_NEXT_CTRL;
    }

    close(fd);
}

But when I try to get all control values, i have faced with this output:

ID        Name                Value     
10100752  Black Level         0         
10100836  Bypass Mode         1         
Error getting control of 10092545: Permission denied
10092545  Camera Controls     1         
Error getting control of 10100746: Invalid argument
10100746  Exposure            1         
Error getting control of 10100747: Invalid argument
10100747  Frame Rate          1         
Error getting control of 10100745: Invalid argument
10100745  Gain                1         
10100739  Group Hold          0         
10100838  Height Align        1         
10100751  IO Mode             0         
10100845  Low Latency Mode    0         
10100837  Override Enable     1         
10100846  Preferred Stride    0         
Error getting control of 10100744: Invalid argument
10100744  Sensor Mode         0         
10100866  Sensor Modes        1         
Error getting control of 10100753: Permission denied
10100753  Single Trigger      1         
10100839  Size Align          0         
10100750  Trigger Mode        0         
10100840  Write ISP format    1

Any ideas why and how to fix it?

Best regards.