Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 23 additions & 14 deletions drivers/media/i2c/imx708.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand All @@ -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);

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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:
Expand All @@ -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);
Expand Down