diff options
author | Sylwester Nawrocki <s.nawrocki@samsung.com> | 2011-12-12 13:45:56 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-12-30 11:38:06 -0500 |
commit | 5d4294b8ddf92092ffad61fe552adeeabb4242bd (patch) | |
tree | 670015258ae031f53b2422ef963337009a1ef7d1 | |
parent | d5048c9a289485f65d108ede183dd3f02f1cd408 (diff) |
[media] m5mols: Don't ignore v4l2_ctrl_handler_setup() return value
v4l2_ctrl_handler_setup() may fail so check its return value when
restoring controls after device is powered on. While at it simplify
the m5mols_restore_function() a bit.
Acked-by: HeungJun Kim <riverful.kim@samsung.com>
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>
-rw-r--r-- | drivers/media/video/m5mols/m5mols.h | 13 | ||||
-rw-r--r-- | drivers/media/video/m5mols/m5mols_capture.c | 2 | ||||
-rw-r--r-- | drivers/media/video/m5mols/m5mols_core.c | 31 |
3 files changed, 23 insertions, 23 deletions
diff --git a/drivers/media/video/m5mols/m5mols.h b/drivers/media/video/m5mols/m5mols.h index 0265ea602280..4b021e1ee5f2 100644 --- a/drivers/media/video/m5mols/m5mols.h +++ b/drivers/media/video/m5mols/m5mols.h | |||
@@ -188,15 +188,16 @@ struct m5mols_info { | |||
188 | struct media_pad pad; | 188 | struct media_pad pad; |
189 | struct v4l2_mbus_framefmt ffmt[M5MOLS_RESTYPE_MAX]; | 189 | struct v4l2_mbus_framefmt ffmt[M5MOLS_RESTYPE_MAX]; |
190 | int res_type; | 190 | int res_type; |
191 | |||
191 | wait_queue_head_t irq_waitq; | 192 | wait_queue_head_t irq_waitq; |
192 | atomic_t irq_done; | 193 | atomic_t irq_done; |
193 | 194 | ||
194 | struct v4l2_ctrl_handler handle; | 195 | struct v4l2_ctrl_handler handle; |
196 | |||
195 | /* Autoexposure/exposure control cluster */ | 197 | /* Autoexposure/exposure control cluster */ |
196 | struct { | 198 | struct v4l2_ctrl *autoexposure; |
197 | struct v4l2_ctrl *autoexposure; | 199 | struct v4l2_ctrl *exposure; |
198 | struct v4l2_ctrl *exposure; | 200 | |
199 | }; | ||
200 | struct v4l2_ctrl *autowb; | 201 | struct v4l2_ctrl *autowb; |
201 | struct v4l2_ctrl *colorfx; | 202 | struct v4l2_ctrl *colorfx; |
202 | struct v4l2_ctrl *saturation; | 203 | struct v4l2_ctrl *saturation; |
@@ -213,10 +214,10 @@ struct m5mols_info { | |||
213 | bool lock_awb; | 214 | bool lock_awb; |
214 | u8 resolution; | 215 | u8 resolution; |
215 | u8 mode; | 216 | u8 mode; |
217 | |||
216 | int (*set_power)(struct device *dev, int on); | 218 | int (*set_power)(struct device *dev, int on); |
217 | }; | 219 | }; |
218 | 220 | ||
219 | #define is_ctrl_synced(__info) (__info->ctrl_sync) | ||
220 | #define is_available_af(__info) (__info->ver.af) | 221 | #define is_available_af(__info) (__info->ver.af) |
221 | #define is_code(__code, __type) (__code == m5mols_default_ffmt[__type].code) | 222 | #define is_code(__code, __type) (__code == m5mols_default_ffmt[__type].code) |
222 | #define is_manufacturer(__info, __manufacturer) \ | 223 | #define is_manufacturer(__info, __manufacturer) \ |
@@ -285,7 +286,7 @@ int m5mols_mode(struct m5mols_info *info, u8 mode); | |||
285 | 286 | ||
286 | int m5mols_enable_interrupt(struct v4l2_subdev *sd, u8 reg); | 287 | int m5mols_enable_interrupt(struct v4l2_subdev *sd, u8 reg); |
287 | int m5mols_wait_interrupt(struct v4l2_subdev *sd, u8 condition, u32 timeout); | 288 | int m5mols_wait_interrupt(struct v4l2_subdev *sd, u8 condition, u32 timeout); |
288 | int m5mols_sync_controls(struct m5mols_info *info); | 289 | int m5mols_restore_controls(struct m5mols_info *info); |
289 | int m5mols_start_capture(struct m5mols_info *info); | 290 | int m5mols_start_capture(struct m5mols_info *info); |
290 | int m5mols_do_scenemode(struct m5mols_info *info, u8 mode); | 291 | int m5mols_do_scenemode(struct m5mols_info *info, u8 mode); |
291 | int m5mols_lock_3a(struct m5mols_info *info, bool lock); | 292 | int m5mols_lock_3a(struct m5mols_info *info, bool lock); |
diff --git a/drivers/media/video/m5mols/m5mols_capture.c b/drivers/media/video/m5mols/m5mols_capture.c index 6814a9d53bf5..ba25e8e2ba4c 100644 --- a/drivers/media/video/m5mols/m5mols_capture.c +++ b/drivers/media/video/m5mols/m5mols_capture.c | |||
@@ -116,7 +116,7 @@ int m5mols_start_capture(struct m5mols_info *info) | |||
116 | */ | 116 | */ |
117 | ret = m5mols_mode(info, REG_MONITOR); | 117 | ret = m5mols_mode(info, REG_MONITOR); |
118 | if (!ret) | 118 | if (!ret) |
119 | ret = m5mols_sync_controls(info); | 119 | ret = m5mols_restore_controls(info); |
120 | if (!ret) | 120 | if (!ret) |
121 | ret = m5mols_write(sd, CAPP_YUVOUT_MAIN, REG_JPEG); | 121 | ret = m5mols_write(sd, CAPP_YUVOUT_MAIN, REG_JPEG); |
122 | if (!ret) | 122 | if (!ret) |
diff --git a/drivers/media/video/m5mols/m5mols_core.c b/drivers/media/video/m5mols/m5mols_core.c index 049b8ee1138d..9966d2e687f6 100644 --- a/drivers/media/video/m5mols/m5mols_core.c +++ b/drivers/media/video/m5mols/m5mols_core.c | |||
@@ -611,26 +611,25 @@ static struct v4l2_subdev_pad_ops m5mols_pad_ops = { | |||
611 | }; | 611 | }; |
612 | 612 | ||
613 | /** | 613 | /** |
614 | * m5mols_sync_controls - Apply default scene mode and the current controls | 614 | * m5mols_restore_controls - Apply current control values to the registers |
615 | * | 615 | * |
616 | * This is used only streaming for syncing between v4l2_ctrl framework and | 616 | * m5mols_do_scenemode() handles all parameters for which there is yet no |
617 | * m5mols's controls. First, do the scenemode to the sensor, then call | 617 | * individual control. It should be replaced at some point by setting each |
618 | * v4l2_ctrl_handler_setup. It can be same between some commands and | 618 | * control individually, in required register set up order. |
619 | * the scenemode's in the default v4l2_ctrls. But, such commands of control | ||
620 | * should be prior to the scenemode's one. | ||
621 | */ | 619 | */ |
622 | int m5mols_sync_controls(struct m5mols_info *info) | 620 | int m5mols_restore_controls(struct m5mols_info *info) |
623 | { | 621 | { |
624 | int ret = -EINVAL; | 622 | int ret; |
625 | 623 | ||
626 | if (!is_ctrl_synced(info)) { | 624 | if (info->ctrl_sync) |
627 | ret = m5mols_do_scenemode(info, REG_SCENE_NORMAL); | 625 | return 0; |
628 | if (ret) | ||
629 | return ret; | ||
630 | 626 | ||
631 | v4l2_ctrl_handler_setup(&info->handle); | 627 | ret = m5mols_do_scenemode(info, REG_SCENE_NORMAL); |
632 | info->ctrl_sync = 1; | 628 | if (ret) |
633 | } | 629 | return ret; |
630 | |||
631 | ret = v4l2_ctrl_handler_setup(&info->handle); | ||
632 | info->ctrl_sync = !ret; | ||
634 | 633 | ||
635 | return ret; | 634 | return ret; |
636 | } | 635 | } |
@@ -654,7 +653,7 @@ static int m5mols_start_monitor(struct m5mols_info *info) | |||
654 | if (!ret) | 653 | if (!ret) |
655 | ret = m5mols_mode(info, REG_MONITOR); | 654 | ret = m5mols_mode(info, REG_MONITOR); |
656 | if (!ret) | 655 | if (!ret) |
657 | ret = m5mols_sync_controls(info); | 656 | ret = m5mols_restore_controls(info); |
658 | 657 | ||
659 | return ret; | 658 | return ret; |
660 | } | 659 | } |