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.