diff --git a/drivers/media/i2c/imx708.c b/drivers/media/i2c/imx708.c index 03469721e11838..6ab38e6a30e567 100644 --- a/drivers/media/i2c/imx708.c +++ b/drivers/media/i2c/imx708.c @@ -1236,7 +1236,8 @@ static int imx708_set_ctrl(struct v4l2_ctrl *ctrl) break; } - pm_runtime_put(&client->dev); + pm_runtime_mark_last_busy(&client->dev); + pm_runtime_put_autosuspend(&client->dev); return ret; } @@ -1592,22 +1593,23 @@ static int imx708_set_stream(struct v4l2_subdev *sd, int enable) } if (enable) { - ret = pm_runtime_get_sync(&client->dev); - if (ret < 0) { - pm_runtime_put_noidle(&client->dev); + ret = pm_runtime_resume_and_get(&client->dev); + if (ret < 0) goto err_unlock; - } /* * Apply default & customized values * and then start streaming. */ ret = imx708_start_streaming(imx708); - if (ret) - goto err_rpm_put; + if (ret) { + pm_runtime_put_sync(&client->dev); + goto err_unlock; + } } else { imx708_stop_streaming(imx708); - pm_runtime_put(&client->dev); + pm_runtime_mark_last_busy(&client->dev); + pm_runtime_put_autosuspend(&client->dev); } imx708->streaming = enable; @@ -1621,8 +1623,6 @@ static int imx708_set_stream(struct v4l2_subdev *sd, int enable) return ret; -err_rpm_put: - pm_runtime_put(&client->dev); err_unlock: mutex_unlock(&imx708->mutex); @@ -2032,10 +2032,16 @@ static int imx708_probe(struct i2c_client *client) /* Initialize default format */ imx708_set_default_format(imx708); - /* Enable runtime PM and turn off the device */ + /* + * Enable runtime PM with autosuspend. As the device has been powered + * manually, mark it as active, and increase the usage count without + * resuming the device. + */ pm_runtime_set_active(dev); + pm_runtime_get_noresume(dev); pm_runtime_enable(dev); - pm_runtime_idle(dev); + pm_runtime_set_autosuspend_delay(dev, 5000); + pm_runtime_use_autosuspend(dev); /* This needs the pm runtime to be registered. */ ret = imx708_init_controls(imx708); @@ -2064,6 +2070,9 @@ static int imx708_probe(struct i2c_client *client) goto error_media_entity; } + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); + return 0; error_media_entity: @@ -2073,8 +2082,8 @@ static int imx708_probe(struct i2c_client *client) imx708_free_controls(imx708); error_pm_runtime: - pm_runtime_disable(&client->dev); - pm_runtime_set_suspended(&client->dev); + pm_runtime_disable(dev); + pm_runtime_put_noidle(dev); error_power_off: imx708_power_off(&client->dev);