Skip to content

Commit 6b7a0de

Browse files
naushirpelwell
authored andcommitted
drivers: i2c: imx708: Use pm_runtime_use_autosuspend()
Switch the power management in the imx708 device driver to use auto- suspend with a 5s timeout. This improves mode switching time that avoids additional regulator switch-on delays and common register I2C writes. Signed-off-by: Naushir Patuck <[email protected]>
1 parent ea23f08 commit 6b7a0de

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

drivers/media/i2c/imx708.c

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,7 +1236,8 @@ static int imx708_set_ctrl(struct v4l2_ctrl *ctrl)
12361236
break;
12371237
}
12381238

1239-
pm_runtime_put(&client->dev);
1239+
pm_runtime_mark_last_busy(&client->dev);
1240+
pm_runtime_put_autosuspend(&client->dev);
12401241

12411242
return ret;
12421243
}
@@ -1592,22 +1593,23 @@ static int imx708_set_stream(struct v4l2_subdev *sd, int enable)
15921593
}
15931594

15941595
if (enable) {
1595-
ret = pm_runtime_get_sync(&client->dev);
1596-
if (ret < 0) {
1597-
pm_runtime_put_noidle(&client->dev);
1596+
ret = pm_runtime_resume_and_get(&client->dev);
1597+
if (ret < 0)
15981598
goto err_unlock;
1599-
}
16001599

16011600
/*
16021601
* Apply default & customized values
16031602
* and then start streaming.
16041603
*/
16051604
ret = imx708_start_streaming(imx708);
1606-
if (ret)
1607-
goto err_rpm_put;
1605+
if (ret) {
1606+
pm_runtime_put_sync(&client->dev);
1607+
goto err_unlock;
1608+
}
16081609
} else {
16091610
imx708_stop_streaming(imx708);
1610-
pm_runtime_put(&client->dev);
1611+
pm_runtime_mark_last_busy(&client->dev);
1612+
pm_runtime_put_autosuspend(&client->dev);
16111613
}
16121614

16131615
imx708->streaming = enable;
@@ -1621,8 +1623,6 @@ static int imx708_set_stream(struct v4l2_subdev *sd, int enable)
16211623

16221624
return ret;
16231625

1624-
err_rpm_put:
1625-
pm_runtime_put(&client->dev);
16261626
err_unlock:
16271627
mutex_unlock(&imx708->mutex);
16281628

@@ -2032,10 +2032,16 @@ static int imx708_probe(struct i2c_client *client)
20322032
/* Initialize default format */
20332033
imx708_set_default_format(imx708);
20342034

2035-
/* Enable runtime PM and turn off the device */
2035+
/*
2036+
* Enable runtime PM with autosuspend. As the device has been powered
2037+
* manually, mark it as active, and increase the usage count without
2038+
* resuming the device.
2039+
*/
20362040
pm_runtime_set_active(dev);
2041+
pm_runtime_get_noresume(dev);
20372042
pm_runtime_enable(dev);
2038-
pm_runtime_idle(dev);
2043+
pm_runtime_set_autosuspend_delay(dev, 5000);
2044+
pm_runtime_use_autosuspend(dev);
20392045

20402046
/* This needs the pm runtime to be registered. */
20412047
ret = imx708_init_controls(imx708);
@@ -2064,6 +2070,9 @@ static int imx708_probe(struct i2c_client *client)
20642070
goto error_media_entity;
20652071
}
20662072

2073+
pm_runtime_mark_last_busy(dev);
2074+
pm_runtime_put_autosuspend(dev);
2075+
20672076
return 0;
20682077

20692078
error_media_entity:
@@ -2073,8 +2082,8 @@ static int imx708_probe(struct i2c_client *client)
20732082
imx708_free_controls(imx708);
20742083

20752084
error_pm_runtime:
2076-
pm_runtime_disable(&client->dev);
2077-
pm_runtime_set_suspended(&client->dev);
2085+
pm_runtime_disable(dev);
2086+
pm_runtime_put_noidle(dev);
20782087

20792088
error_power_off:
20802089
imx708_power_off(&client->dev);

0 commit comments

Comments
 (0)