media: i2c: ov4689: Use runtime PM autosuspend
authorMikhail Rudenko <mike.rudenko@gmail.com>
Tue, 16 Apr 2024 22:45:17 +0000 (23:45 +0100)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Fri, 26 Apr 2024 10:24:32 +0000 (11:24 +0100)
Use runtime PM autosuspend to avoid powering off the sensor during
fast stop-reconfigure-restart cycles.

Signed-off-by: Mikhail Rudenko <mike.rudenko@gmail.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
drivers/media/i2c/ov4689.c

index dcbffa270deafabb919b01015f2288399e2ba731..b6337aee047126057e3472960dd6d78c7b4ee50d 100644 (file)
@@ -426,7 +426,8 @@ static int ov4689_s_stream(struct v4l2_subdev *sd, int on)
        } else {
                cci_write(ov4689->regmap, OV4689_REG_CTRL_MODE,
                          OV4689_MODE_SW_STANDBY, NULL);
-               pm_runtime_put(dev);
+               pm_runtime_mark_last_busy(dev);
+               pm_runtime_put_autosuspend(dev);
        }
 
 unlock_and_return:
@@ -606,7 +607,8 @@ static int ov4689_set_ctrl(struct v4l2_ctrl *ctrl)
                break;
        }
 
-       pm_runtime_put(dev);
+       pm_runtime_mark_last_busy(dev);
+       pm_runtime_put_autosuspend(dev);
 
        return ret;
 }
@@ -876,8 +878,10 @@ static int ov4689_probe(struct i2c_client *client)
        }
 
        pm_runtime_set_active(dev);
+       pm_runtime_get_noresume(dev);
        pm_runtime_enable(dev);
-       pm_runtime_idle(dev);
+       pm_runtime_set_autosuspend_delay(dev, 1000);
+       pm_runtime_use_autosuspend(dev);
 
        ret = v4l2_async_register_subdev_sensor(sd);
        if (ret) {
@@ -885,11 +889,14 @@ static int ov4689_probe(struct i2c_client *client)
                goto err_clean_subdev_pm;
        }
 
+       pm_runtime_mark_last_busy(dev);
+       pm_runtime_put_autosuspend(dev);
+
        return 0;
 
 err_clean_subdev_pm:
        pm_runtime_disable(dev);
-       pm_runtime_set_suspended(dev);
+       pm_runtime_put_noidle(dev);
        v4l2_subdev_cleanup(sd);
 err_clean_entity:
        media_entity_cleanup(&sd->entity);