ov5640_write_reg error?

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

ov5640_write_reg error?

跳至解决方案
2,464 次查看
gbiradar
Contributor IV

Hi Guys,

well i have actually able to create sysfs entry and able to pass some value to desired brightness level  but it is returning ov5640_write_reg fail. i have only modified ov5640_mipi.c file only.

Below is my code snippet please check.

ov5640_mipi.c

===================================================================================================

static struct kobject *ov5640_mipi_kobj;

static ssize_t ov5640_mipi_brightness_set(struct device *dev, struct device_attribute *attr, char *buf,size_t size)

{

   int err;

  unsigned long val;

  if (strict_strtoul(buf, 10, &val))

                return -EINVAL;

  pr_info("GB : ov5640_mipi_brightness_set\n");

  switch(val){

  case 0 :      ov5640_write_reg(0x5001, 0xff);

                     ov5640_write_reg(0x5587, 0x40);

                     ov5640_write_reg(0x5580, 0x04);

                     ov5640_write_reg(0x5588, 0x01);

                     break;

..................

..................

}

static struct kobj_attribute brightness = __ATTR(brightness_ctrl, 0664, NULL, ov5640_mipi_brightness_set);

static struct attribute *attributes_ov5640_mipi[] = {

        &brightness.attr,

        NULL,

};

static struct attribute_group attr_group_ov5640_mipi = {

        .attrs = attributes_ov5640_mipi,

};

static int create_sysfs_interfaces(struct device *dev)// calling from probe function

{

        int err;

        ov5640_mipi_kobj = kobject_create_and_add("ov5640_mipi_sensor", &dev->kobj);

        if(!ov5640_mipi_kobj)

                return -ENOMEM;

        err = sysfs_create_group(ov5640_mipi_kobj, &attr_group_ov5640_mipi);

        if (err)

        {

                kobject_put(ov5640_mipi_kobj);

                dev_err(dev, "%s:Unable to create interface\n", __func__);

                 return -1;

        }

  pr_info("GB : create_sysfs_interfaces\n");

  return 0;

}

$ echo 0 > /sys/bus/i2c/../devices/ov5640_brightness_set/brightness_ctrl

GB : ov5640_mipi_brightness_set

ov5640_write_reg:write reg error:reg=5001,val=ff

ov5640_write_reg:write reg error:reg=5587,val=40

ov5640_write_reg:write reg error:reg=5580,val=4

ov5640_write_reg:write reg error:reg=5588,val=1

标记 (5)
0 项奖励
回复
1 解答
2,147 次查看
gbiradar
Contributor IV

For the above question update is :

when board boot up when it comes to shell the camera will be in power down mode so until unless some application is run to start the camera in active mode you can't modify any register. in my case i have to run gstreamer after that i used my sysfs entries to modify brightness it worked.

在原帖中查看解决方案

0 项奖励
回复
3 回复数
2,147 次查看
jimmychan
NXP TechSupport
NXP TechSupport

have you try to make it as a ioctl function and then control the brightness via ioctl?

0 项奖励
回复
2,147 次查看
gbiradar
Contributor IV

Hi jimmychan​,

                          Well yes i have tried and set brightness value through ioctl call.

regards,

Ganesh Biradar

0 项奖励
回复
2,148 次查看
gbiradar
Contributor IV

For the above question update is :

when board boot up when it comes to shell the camera will be in power down mode so until unless some application is run to start the camera in active mode you can't modify any register. in my case i have to run gstreamer after that i used my sysfs entries to modify brightness it worked.

0 项奖励
回复