ov5640 ioctl_s_ctrl is not happening

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

ov5640 ioctl_s_ctrl is not happening

1,922 次查看
gbiradar
Contributor IV

Hi Guys,

                   i'm trying to create a c application which will change brightness value of ov5640.

i have modified the following things:

1-> i have added support for brightness in ioctl_s_ctrl in ov5640_mipi.c

     pr_debug("In ov5640:ioctl_s_ctrl %d\n", vc->id);

       switch (vc->id) {

       case V4L2_CID_BRIGHTNESS:

       pr_debug("GB : %s in V4L2_CID_BRIGHTNESS\n",__FUNCTION__);

       ov5640_brightness(vc->value);  //--> this function hold sitch case for different brightness levels.

2-> in c application i'm opening /dev/video1

      struct v4l2_control control;

      control.value = seek;//-> seek is range say -4 to +4 from user input.

      with help of ioctl(fd,VIDIOC_S_CTRL,&control)

well so far so good.

i have added some debug statement also at regular interval in probe, s_ctrl and g_ctrl also.

but when i'm trying to run application and try to set ctrl value it is not changing. i have checked kernel log also it is not displaying debug statement also.

any help very useful.

regards,

Ganesh 

0 项奖励
回复
6 回复数

1,450 次查看
gbiradar
Contributor IV

Hi Guys,

             Update to my question, now it is working fine but i have on more issue. well after setting brightness value i'm trying to read but brightness value is not updating. i'm using VIDIOC_G_CTRL

control.id = V4L2_CID_BRIGHTNESS;

ioctl(fd,VIDIOC_G_CTRL,&control)

printf("Current value of brightness level is %d\n",control.value);

but the value is zero.

0 项奖励
回复

1,450 次查看
alejandrolozan1
NXP Employee
NXP Employee

Hi,

Are you modifying the ov5640_data structure when setting the brightness?

As I see the value must be set in the below function.

static int ioctl_s_ctrl(struct v4l2_int_device *s, struct v4l2_control *vc)

{

        int retval = 0;

        pr_debug("In ov5640:ioctl_s_ctrl %d\n",

                 vc->id);

        switch (vc->id) {

        case V4L2_CID_BRIGHTNESS:

                break;

        case V4L2_CID_CONTRAST:

                break;

        case V4L2_CID_SATURATION:

                break;

        case V4L2_CID_HUE:

                break;

        case V4L2_CID_AUTO_WHITE_BALANCE:

                break;

        case V4L2_CID_DO_WHITE_BALANCE:

                break;

        case V4L2_CID_RED_BALANCE:

                break;

        case V4L2_CID_BLUE_BALANCE:

                break;

        case V4L2_CID_GAMMA:

                break;

        case V4L2_CID_EXPOSURE:

                break;

        case V4L2_CID_AUTOGAIN:

                break;

        case V4L2_CID_GAIN:

                break;

        case V4L2_CID_HFLIP:

                break;

        case V4L2_CID_VFLIP:

                break;

        default:

                retval = -EPERM;

                break;

        }

        return retval;

}

And it is returned in this one:

static int ioctl_g_ctrl(struct v4l2_int_device *s, struct v4l2_control *vc)

{

        int ret = 0;

        switch (vc->id) {

        case V4L2_CID_BRIGHTNESS:

                vc->value = ov5640_data.brightness;

                break;

        case V4L2_CID_HUE:

                vc->value = ov5640_data.hue;

                break;

        case V4L2_CID_CONTRAST:

                vc->value = ov5640_data.contrast;

                break;

        case V4L2_CID_SATURATION:

                vc->value = ov5640_data.saturation;

                break;

        case V4L2_CID_RED_BALANCE:

                vc->value = ov5640_data.red;

                break;

        case V4L2_CID_BLUE_BALANCE:

                vc->value = ov5640_data.blue;

                break;

        case V4L2_CID_EXPOSURE:

                vc->value = ov5640_data.ae_mode;

                break;

        default:

                ret = -EINVAL;

        }

        return ret;

}

As you may notice in the code the ov5640_data.brightness is not modified.

Best Regards,

Alejandro

0 项奖励
回复

1,450 次查看
gbiradar
Contributor IV

Hi alejandrolozano​ yes what you said is correct.

static int ioctl_s_ctrl(struct v4l2_int_device *s, struct v4l2_control *vc)

{

        int retval = 0;

        pr_debug("In ov5640:ioctl_s_ctrl %d\n",

                 vc->id);

        switch (vc->id) {

        case V4L2_CID_BRIGHTNESS: ov5640_brightness(vc->value);

                break;

  ov5640_brightness(vc->value); -----> it's a function which has switch case statement with different brightness level which can be selected by vc->value from ioctl_s_ctrl by calling ov5640_brightness().

this i have got i'm able to set the values but while i'm trying to read using ioctl_g_ctrl for V4L2_CID_BRIGHTNESS i'm trying to read brightness value but i'm getting '0'. please check my follow up post with my original question.

0 项奖励
回复

1,450 次查看
alejandrolozan1
NXP Employee
NXP Employee

Hi,

I also mean that you may need to save the brigthness data in the internal driver variable ov5640_data.brightness and return that value in the function you mention.

Best Regards,

Alejandro

0 项奖励
回复

1,450 次查看
gbiradar
Contributor IV

Hi alejandrolozano,

        i already did that i given my return value like this ov5640.brightness =  ov5640_read_reg(0x5587,&value). when i'm reading the register the outcome is zero. i just want to read brightness value.

0 项奖励
回复

1,450 次查看
alejandrolozan1
NXP Employee
NXP Employee

Hi,

Have you checked with a logic analyzer or a scope the i2c lines and make sure the ov5649_read_reg is working as expected?

That will help to narrow down the problem.

Best Regards,

Alejandro

0 项奖励
回复