aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorSylwester Nawrocki <s.nawrocki@samsung.com>2011-09-12 09:34:03 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-09-21 13:28:36 -0400
commitbc3603248fecbdeb4a2c0568fc6606f257b6ca23 (patch)
treefff7572f11ff5a4bab7c90dd12afe62cd063df90 /drivers
parent6426e14a7ebfaea831db8d95f55da334701f2c37 (diff)
[media] noon010pc30: Improve s_power operation handling
Remove the now unneeded check for the platform data in s_power handler and the platform data pointer in struct noon010_info. Also do not reset the configured output resolution and pixel format when cycling sensor's power. Add small delay for proper reset signal shape. Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/video/noon010pc30.c40
1 files changed, 17 insertions, 23 deletions
diff --git a/drivers/media/video/noon010pc30.c b/drivers/media/video/noon010pc30.c
index 1a874ec8f9e0..935c96b006bc 100644
--- a/drivers/media/video/noon010pc30.c
+++ b/drivers/media/video/noon010pc30.c
@@ -133,7 +133,6 @@ struct noon010_info {
133 struct v4l2_subdev sd; 133 struct v4l2_subdev sd;
134 struct media_pad pad; 134 struct media_pad pad;
135 struct v4l2_ctrl_handler hdl; 135 struct v4l2_ctrl_handler hdl;
136 const struct noon010pc30_platform_data *pdata;
137 struct regulator_bulk_data supply[NOON010_NUM_SUPPLIES]; 136 struct regulator_bulk_data supply[NOON010_NUM_SUPPLIES];
138 u32 gpio_nreset; 137 u32 gpio_nreset;
139 u32 gpio_nstby; 138 u32 gpio_nstby;
@@ -299,8 +298,10 @@ static int noon010_power_ctrl(struct v4l2_subdev *sd, bool reset, bool sleep)
299 u8 reg = sleep ? 0xF1 : 0xF0; 298 u8 reg = sleep ? 0xF1 : 0xF0;
300 int ret = 0; 299 int ret = 0;
301 300
302 if (reset) 301 if (reset) {
303 ret = cam_i2c_write(sd, POWER_CTRL_REG, reg | 0x02); 302 ret = cam_i2c_write(sd, POWER_CTRL_REG, reg | 0x02);
303 udelay(20);
304 }
304 if (!ret) { 305 if (!ret) {
305 ret = cam_i2c_write(sd, POWER_CTRL_REG, reg); 306 ret = cam_i2c_write(sd, POWER_CTRL_REG, reg);
306 if (reset && !ret) 307 if (reset && !ret)
@@ -573,45 +574,37 @@ static int noon010_set_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
573 return ret; 574 return ret;
574} 575}
575 576
577/* Called with struct noon010_info.lock mutex held */
576static int noon010_base_config(struct v4l2_subdev *sd) 578static int noon010_base_config(struct v4l2_subdev *sd)
577{ 579{
578 struct noon010_info *info = to_noon010(sd); 580 int ret = noon010_bulk_write_reg(sd, noon010_base_regs);
579 int ret; 581 if (!ret)
580
581 ret = noon010_bulk_write_reg(sd, noon010_base_regs);
582 if (!ret) {
583 info->curr_fmt = &noon010_formats[0];
584 info->curr_win = &noon010_sizes[0];
585 ret = noon010_set_params(sd); 582 ret = noon010_set_params(sd);
586 }
587 if (!ret) 583 if (!ret)
588 ret = noon010_set_flip(sd, 1, 0); 584 ret = noon010_set_flip(sd, 1, 0);
589 585
590 /* sync the handler and the registers state */
591 v4l2_ctrl_handler_setup(&to_noon010(sd)->hdl);
592 return ret; 586 return ret;
593} 587}
594 588
595static int noon010_s_power(struct v4l2_subdev *sd, int on) 589static int noon010_s_power(struct v4l2_subdev *sd, int on)
596{ 590{
597 struct noon010_info *info = to_noon010(sd); 591 struct noon010_info *info = to_noon010(sd);
598 const struct noon010pc30_platform_data *pdata = info->pdata; 592 int ret;
599 int ret = 0;
600
601 if (WARN(pdata == NULL, "No platform data!\n"))
602 return -ENOMEM;
603 593
594 mutex_lock(&info->lock);
604 if (on) { 595 if (on) {
605 ret = power_enable(info); 596 ret = power_enable(info);
606 if (ret) 597 if (!ret)
607 return ret; 598 ret = noon010_base_config(sd);
608 ret = noon010_base_config(sd);
609 } else { 599 } else {
610 noon010_power_ctrl(sd, false, true); 600 noon010_power_ctrl(sd, false, true);
611 ret = power_disable(info); 601 ret = power_disable(info);
612 info->curr_win = NULL;
613 info->curr_fmt = NULL;
614 } 602 }
603 mutex_unlock(&info->lock);
604
605 /* Restore the controls state */
606 if (!ret && on)
607 ret = v4l2_ctrl_handler_setup(&info->hdl);
615 608
616 return ret; 609 return ret;
617} 610}
@@ -762,10 +755,11 @@ static int noon010_probe(struct i2c_client *client,
762 if (ret) 755 if (ret)
763 goto np_err; 756 goto np_err;
764 757
765 info->pdata = client->dev.platform_data;
766 info->i2c_reg_page = -1; 758 info->i2c_reg_page = -1;
767 info->gpio_nreset = -EINVAL; 759 info->gpio_nreset = -EINVAL;
768 info->gpio_nstby = -EINVAL; 760 info->gpio_nstby = -EINVAL;
761 info->curr_fmt = &noon010_formats[0];
762 info->curr_win = &noon010_sizes[0];
769 763
770 if (gpio_is_valid(pdata->gpio_nreset)) { 764 if (gpio_is_valid(pdata->gpio_nreset)) {
771 ret = gpio_request(pdata->gpio_nreset, "NOON010PC30 NRST"); 765 ret = gpio_request(pdata->gpio_nreset, "NOON010PC30 NRST");