iMX8MP - ISP Using V4L2 Interface

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

iMX8MP - ISP Using V4L2 Interface

跳至解决方案
7,307 次查看
khang_letruong
Senior Contributor III

Dear NXP Teams,

In order to use the ISP V4L2 API of iMX8MP that is described in Chapter 3 - ISP Using V4L2 Interface of i.MX_8M_Plus_Camera_and_Display_Guide.pdf document, I was looking for its source code / implementation of which location indicated as following  :

V4L2_Components-LF_5.10.52.png

I looked in https://source.codeaurora.org/external/imx/isp-vvcam/ with associated branch (lf-5.10.52-2.1.0) but unable to find the location/folder mentioned in above document.

Could you help to clarify? Knowing that I am using LF-5.10.52.

Thanks in advance and best regards,
Khang

 

0 项奖励
回复
1 解答
7,279 次查看
khang_letruong
Senior Contributor III

Hi @malik_cisse ,

Thanks for your reply.I know quite well about vvext.

The requirement of my client is that they would only use gst-launch for streaming and maybe v4l2-ctl for controlling the ISP parameters (which is WDR3 in my case).

Anyway, I found a work-around to do that in low level layer.

Regards,

Khang

 

在原帖中查看解决方案

8 回复数
7,286 次查看
malik_cisse
Senior Contributor I

Hi Khang,

What do you actually want to do?

as artsiomstaliaro said the v4L2 API examples are in isp-imx rather than isp-vvcam.

You will find a rather good example that does open V4L2 device, ISP process video, Downscale, configure ISP and render video on display using DRM. I tested it and it works great. Here is the full path:
isp-imx-4.***\appshell\v4l_drm_test\video_test.cpp

I did not find the folder mentioned in the doc either. I think NXP reused some docs from verisilicon without updating the path. It is hard to find the resources when following the pointers in the doc.

In order to configure the ISP dynamically (e.g set CCM Matrix, AWB, Gamma, etc.) you can use vvext example:
isp-imx-4.2.2.11.0\appshell\vvext\vvext.cpp
I used this successfully also. The only problem I had, is trying to compile this in a minimal self-contained environment.
I had to compile it within its original folder hierarchy.

0 项奖励
回复
7,280 次查看
khang_letruong
Senior Contributor III

Hi @malik_cisse ,

Thanks for your reply.I know quite well about vvext.

The requirement of my client is that they would only use gst-launch for streaming and maybe v4l2-ctl for controlling the ISP parameters (which is WDR3 in my case).

Anyway, I found a work-around to do that in low level layer.

Regards,

Khang

 

6,627 次查看
malik_cisse
Senior Contributor I

Hi Khang,

When you say:

The requirement of my client is that they would only use gst-launch for streaming and maybe v4l2-ctl for controlling the ISP parameters (which is WDR3 in my case).

Anyway, I found a work-around to do that in low level layer.


How do you control WDR3 in this case not using vvext?
I am still struggling making the ISP API work outside of vvext.
Thank you

0 项奖励
回复
6,620 次查看
khang_letruong
Senior Contributor III

Hi @malik_cisse ,

How do you control WDR3 in this case not using vvext?

I did not need to have WDR3 on so I hard-coded it to off in the driver.

I am still struggling making the ISP API work outside of vvext.

vvext is an example of using JSON request for controlling ISP parameters.

Regards,
Khang.

 

6,928 次查看
jiangyaqiang
Contributor V

HI khang_letruong:

 

        I'm also porting a camera IMX415 need to use ISP, could you show me how to use V4L2 to control it ?

       Thank you very much.

0 项奖励
回复
6,915 次查看
malik_cisse
Senior Contributor I

Hi jiangyaqiang

I would also like to know how Khang Letruong solve the issue.
Here is how I solved it.
The core processing is actually quite simple. For example enabling gamma correction is done as follows:

int viv_private_ioctl(const char *cmd, Json::Value& jsonRequest, Json::Value& jsonResponse) {
    if (!cmd) {
        ALOGE("cmd should not be null!");
        return -1;
    }
    jsonRequest["id"] = cmd;
    jsonRequest["streamid"] = streamid;

    struct v4l2_ext_controls ecs;
    struct v4l2_ext_control ec;
    memset(&ecs, 0, sizeof(ecs));
    memset(&ec, 0, sizeof(ec));
    ec.string = new char[VIV_JSON_BUFFER_SIZE];
    ec.id = V4L2_CID_VIV_EXTCTRL;
    ec.size = 0;
    ecs.controls = &ec;
    ecs.count = 1;

    ::ioctl(fd, VIDIOC_G_EXT_CTRLS, &ecs);

    strcpy(ec.string, jsonRequest.toStyledString().c_str());

    int ret = ::ioctl(fd, VIDIOC_S_EXT_CTRLS, &ecs);
    if (ret != 0) {
        ALOGE("failed to set ext ctrl\n");
        goto end;
    } else {
        ::ioctl(fd, VIDIOC_G_EXT_CTRLS, &ecs);
        Json::Reader reader;
        reader.parse(ec.string, jsonResponse, true);
        delete ec.string;
        ec.string = NULL;
        return jsonResponse["MC_RET"].asInt();
    }

end:
     delete ec.string;
     ec.string = NULL;
    return S_EXT_FLAG;
}

/*************************GAMMA**************************/
void enableGamma(bool enable)
{
    strError = enable ? "GAMMA enabled": "GAMMA disabled";
    Json::Value jRequest, jResponse;
    jRequest[GC_ENABLE_PARAMS] = enable;
    viv_private_ioctl(IF_GC_S_EN, jRequest, jResponse);
}

 

It is all based on  VIDIOC_S_EXT_CTRLS as described in " i.MX 8M Plus ISP Using V4L2 Interface User Guide" chap 2.5 Feature control API.

I could implement this using isp-imx-4.2.2.11.0\appshell\vvext\vvext.cpp as template. So far I was not able to compile this in a minimalistic environment only using v4l2 API and JSON library.

I am eager to see if Khang Letruong or someone else managed to do that before.
Full source code is in attachment.

0 项奖励
回复
6,912 次查看
jiangyaqiang
Contributor V

HI malik_cisse:

 

        Thanks a lot.

        I have impplemented my camera driver by reference to vvcam/v4l2/sensor/ov2775/ov2775_mipi_v3.c,

       and I want to test it by command  /opt/imx8-isp/bin/video_test  or gst-launch, but both of them fail.           gst-launch fail in vidioc_reqbufs( Failed to allocate required memory.). 

       video_test fail in :Get Caps Supports Failed.

      maybe there is something wrong in my driver. 

 

0 项奖励
回复
7,300 次查看
artsiomstaliaro
Contributor IV

This is part of the isp-imx-4.2.2.16.0 package. You can find it in the Yocto build.

0 项奖励
回复