Commit 5d4294b8 authored by Sylwester Nawrocki's avatar Sylwester Nawrocki Committed by Mauro Carvalho Chehab

[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: default avatarHeungJun Kim <riverful.kim@samsung.com>
Signed-off-by: default avatarSylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: default avatarKyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent d5048c9a
...@@ -188,15 +188,16 @@ struct m5mols_info { ...@@ -188,15 +188,16 @@ struct m5mols_info {
struct media_pad pad; struct media_pad pad;
struct v4l2_mbus_framefmt ffmt[M5MOLS_RESTYPE_MAX]; struct v4l2_mbus_framefmt ffmt[M5MOLS_RESTYPE_MAX];
int res_type; int res_type;
wait_queue_head_t irq_waitq; wait_queue_head_t irq_waitq;
atomic_t irq_done; atomic_t irq_done;
struct v4l2_ctrl_handler handle; struct v4l2_ctrl_handler handle;
/* Autoexposure/exposure control cluster */ /* Autoexposure/exposure control cluster */
struct { struct v4l2_ctrl *autoexposure;
struct v4l2_ctrl *autoexposure; struct v4l2_ctrl *exposure;
struct v4l2_ctrl *exposure;
};
struct v4l2_ctrl *autowb; struct v4l2_ctrl *autowb;
struct v4l2_ctrl *colorfx; struct v4l2_ctrl *colorfx;
struct v4l2_ctrl *saturation; struct v4l2_ctrl *saturation;
...@@ -213,10 +214,10 @@ struct m5mols_info { ...@@ -213,10 +214,10 @@ struct m5mols_info {
bool lock_awb; bool lock_awb;
u8 resolution; u8 resolution;
u8 mode; u8 mode;
int (*set_power)(struct device *dev, int on); int (*set_power)(struct device *dev, int on);
}; };
#define is_ctrl_synced(__info) (__info->ctrl_sync)
#define is_available_af(__info) (__info->ver.af) #define is_available_af(__info) (__info->ver.af)
#define is_code(__code, __type) (__code == m5mols_default_ffmt[__type].code) #define is_code(__code, __type) (__code == m5mols_default_ffmt[__type].code)
#define is_manufacturer(__info, __manufacturer) \ #define is_manufacturer(__info, __manufacturer) \
...@@ -285,7 +286,7 @@ int m5mols_mode(struct m5mols_info *info, u8 mode); ...@@ -285,7 +286,7 @@ int m5mols_mode(struct m5mols_info *info, u8 mode);
int m5mols_enable_interrupt(struct v4l2_subdev *sd, u8 reg); int m5mols_enable_interrupt(struct v4l2_subdev *sd, u8 reg);
int m5mols_wait_interrupt(struct v4l2_subdev *sd, u8 condition, u32 timeout); int m5mols_wait_interrupt(struct v4l2_subdev *sd, u8 condition, u32 timeout);
int m5mols_sync_controls(struct m5mols_info *info); int m5mols_restore_controls(struct m5mols_info *info);
int m5mols_start_capture(struct m5mols_info *info); int m5mols_start_capture(struct m5mols_info *info);
int m5mols_do_scenemode(struct m5mols_info *info, u8 mode); int m5mols_do_scenemode(struct m5mols_info *info, u8 mode);
int m5mols_lock_3a(struct m5mols_info *info, bool lock); int m5mols_lock_3a(struct m5mols_info *info, bool lock);
......
...@@ -116,7 +116,7 @@ int m5mols_start_capture(struct m5mols_info *info) ...@@ -116,7 +116,7 @@ int m5mols_start_capture(struct m5mols_info *info)
*/ */
ret = m5mols_mode(info, REG_MONITOR); ret = m5mols_mode(info, REG_MONITOR);
if (!ret) if (!ret)
ret = m5mols_sync_controls(info); ret = m5mols_restore_controls(info);
if (!ret) if (!ret)
ret = m5mols_write(sd, CAPP_YUVOUT_MAIN, REG_JPEG); ret = m5mols_write(sd, CAPP_YUVOUT_MAIN, REG_JPEG);
if (!ret) if (!ret)
......
...@@ -611,26 +611,25 @@ static struct v4l2_subdev_pad_ops m5mols_pad_ops = { ...@@ -611,26 +611,25 @@ static struct v4l2_subdev_pad_ops m5mols_pad_ops = {
}; };
/** /**
* m5mols_sync_controls - Apply default scene mode and the current controls * m5mols_restore_controls - Apply current control values to the registers
* *
* This is used only streaming for syncing between v4l2_ctrl framework and * m5mols_do_scenemode() handles all parameters for which there is yet no
* m5mols's controls. First, do the scenemode to the sensor, then call * individual control. It should be replaced at some point by setting each
* v4l2_ctrl_handler_setup. It can be same between some commands and * control individually, in required register set up order.
* the scenemode's in the default v4l2_ctrls. But, such commands of control
* should be prior to the scenemode's one.
*/ */
int m5mols_sync_controls(struct m5mols_info *info) int m5mols_restore_controls(struct m5mols_info *info)
{ {
int ret = -EINVAL; int ret;
if (!is_ctrl_synced(info)) { if (info->ctrl_sync)
ret = m5mols_do_scenemode(info, REG_SCENE_NORMAL); return 0;
if (ret)
return ret;
v4l2_ctrl_handler_setup(&info->handle); ret = m5mols_do_scenemode(info, REG_SCENE_NORMAL);
info->ctrl_sync = 1; if (ret)
} return ret;
ret = v4l2_ctrl_handler_setup(&info->handle);
info->ctrl_sync = !ret;
return ret; return ret;
} }
...@@ -654,7 +653,7 @@ static int m5mols_start_monitor(struct m5mols_info *info) ...@@ -654,7 +653,7 @@ static int m5mols_start_monitor(struct m5mols_info *info)
if (!ret) if (!ret)
ret = m5mols_mode(info, REG_MONITOR); ret = m5mols_mode(info, REG_MONITOR);
if (!ret) if (!ret)
ret = m5mols_sync_controls(info); ret = m5mols_restore_controls(info);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment