return ret;
}
-static int power_down(struct v4l2_subdev *sd);
-
static int power_up(struct v4l2_subdev *sd)
{
struct gc0310_device *dev = to_gc0310_sensor(sd);
return -ENODEV;
}
+ if (dev->power_on)
+ return 0; /* Already on */
+
/* power control */
ret = power_ctrl(sd, 1);
if (ret)
msleep(100);
+ dev->power_on = true;
return 0;
fail_gpio:
return -ENODEV;
}
+ if (!dev->power_on)
+ return 0; /* Already off */
+
/* gpio ctrl */
ret = gpio_ctrl(sd, 0);
if (ret) {
if (ret)
dev_err(&client->dev, "vprog failed.\n");
+ dev->power_on = false;
return ret;
}
return 0;
}
+ /* s_power has not been called yet for std v4l2 clients (camorama) */
+ power_up(sd);
+
dev_dbg(&client->dev, "%s: before gc0310_write_reg_array %s\n",
__func__, dev->res->desc);
ret = startup(sd);
* as first power on by board may not fulfill the
* power on sequqence needed by the module
*/
+ dev->power_on = true; /* force power_down() to run */
ret = power_down(sd);
if (ret) {
dev_err(&client->dev, "gc0310 power-off err.\n");