mirror of
https://github.com/torvalds/linux.git
synced 2026-05-29 17:43:52 +02:00
media: imx335: Handle runtime PM in leaf functions
Simplify .s_stream callback implementation by moving the runtime PM calls to the leaf functions. This patch should not affect any functionality. Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
This commit is contained in:
parent
d64ec84ac0
commit
34af620e67
|
|
@ -912,13 +912,17 @@ static int imx335_start_streaming(struct imx335 *imx335)
|
|||
const struct imx335_reg_list *reg_list;
|
||||
int ret;
|
||||
|
||||
ret = pm_runtime_resume_and_get(imx335->dev);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
/* Setup PLL */
|
||||
reg_list = &link_freq_reglist[__ffs(imx335->link_freq_bitmap)];
|
||||
ret = cci_multi_reg_write(imx335->cci, reg_list->regs,
|
||||
reg_list->num_of_regs, NULL);
|
||||
if (ret) {
|
||||
dev_err(imx335->dev, "%s failed to set plls\n", __func__);
|
||||
return ret;
|
||||
goto err_rpm_put;
|
||||
}
|
||||
|
||||
/* Write sensor mode registers */
|
||||
|
|
@ -927,27 +931,27 @@ static int imx335_start_streaming(struct imx335 *imx335)
|
|||
reg_list->num_of_regs, NULL);
|
||||
if (ret) {
|
||||
dev_err(imx335->dev, "fail to write initial registers\n");
|
||||
return ret;
|
||||
goto err_rpm_put;
|
||||
}
|
||||
|
||||
ret = imx335_set_framefmt(imx335);
|
||||
if (ret) {
|
||||
dev_err(imx335->dev, "%s failed to set frame format: %d\n",
|
||||
__func__, ret);
|
||||
return ret;
|
||||
goto err_rpm_put;
|
||||
}
|
||||
|
||||
/* Configure lanes */
|
||||
ret = cci_write(imx335->cci, IMX335_REG_LANEMODE,
|
||||
imx335->lane_mode, NULL);
|
||||
if (ret)
|
||||
return ret;
|
||||
goto err_rpm_put;
|
||||
|
||||
/* Setup handler will write actual exposure and gain */
|
||||
ret = __v4l2_ctrl_handler_setup(imx335->sd.ctrl_handler);
|
||||
if (ret) {
|
||||
dev_err(imx335->dev, "fail to setup handler\n");
|
||||
return ret;
|
||||
goto err_rpm_put;
|
||||
}
|
||||
|
||||
/* Start streaming */
|
||||
|
|
@ -955,25 +959,29 @@ static int imx335_start_streaming(struct imx335 *imx335)
|
|||
IMX335_MODE_STREAMING, NULL);
|
||||
if (ret) {
|
||||
dev_err(imx335->dev, "fail to start streaming\n");
|
||||
return ret;
|
||||
goto err_rpm_put;
|
||||
}
|
||||
|
||||
/* Initial regulator stabilization period */
|
||||
usleep_range(18000, 20000);
|
||||
|
||||
return 0;
|
||||
|
||||
err_rpm_put:
|
||||
pm_runtime_put(imx335->dev);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* imx335_stop_streaming() - Stop sensor stream
|
||||
* @imx335: pointer to imx335 device
|
||||
*
|
||||
* Return: 0 if successful, error code otherwise.
|
||||
*/
|
||||
static int imx335_stop_streaming(struct imx335 *imx335)
|
||||
static void imx335_stop_streaming(struct imx335 *imx335)
|
||||
{
|
||||
return cci_write(imx335->cci, IMX335_REG_MODE_SELECT,
|
||||
IMX335_MODE_STANDBY, NULL);
|
||||
cci_write(imx335->cci, IMX335_REG_MODE_SELECT,
|
||||
IMX335_MODE_STANDBY, NULL);
|
||||
pm_runtime_put(imx335->dev);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -986,32 +994,17 @@ static int imx335_stop_streaming(struct imx335 *imx335)
|
|||
static int imx335_set_stream(struct v4l2_subdev *sd, int enable)
|
||||
{
|
||||
struct imx335 *imx335 = to_imx335(sd);
|
||||
int ret;
|
||||
int ret = 0;
|
||||
|
||||
mutex_lock(&imx335->mutex);
|
||||
|
||||
if (enable) {
|
||||
ret = pm_runtime_resume_and_get(imx335->dev);
|
||||
if (ret)
|
||||
goto error_unlock;
|
||||
|
||||
if (enable)
|
||||
ret = imx335_start_streaming(imx335);
|
||||
if (ret)
|
||||
goto error_power_off;
|
||||
} else {
|
||||
else
|
||||
imx335_stop_streaming(imx335);
|
||||
pm_runtime_put(imx335->dev);
|
||||
}
|
||||
|
||||
mutex_unlock(&imx335->mutex);
|
||||
|
||||
return 0;
|
||||
|
||||
error_power_off:
|
||||
pm_runtime_put(imx335->dev);
|
||||
error_unlock:
|
||||
mutex_unlock(&imx335->mutex);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user