build/patch/kernel/archive/sunxi-6.2/patches.megous/media-ov5640-Don-t-powerup-the-sensor-during-driver-probe.patch

103 lines
2.6 KiB
Diff
Raw Normal View History

From 3ce70d299ed0778c109df06face51166477c41ee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ond=C5=99ej=20Jirman?= <megi@xff.cz>
Date: Sun, 26 Jan 2020 00:28:10 +0100
Subject: [PATCH 044/391] media: ov5640: Don't powerup the sensor during driver
probe
It causes autofocus clicking during boot on some devices, and
it's enough to do it when turning on the sensor power by media
pipeline via s_power callback, later on.
Signed-off-by: Ondrej Jirman <megi@xff.cz>
---
drivers/media/i2c/ov5640.c | 46 ++++++++------------------------------
1 file changed, 9 insertions(+), 37 deletions(-)
diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c
index 7f478f19b..9e8daaed2 100644
--- a/drivers/media/i2c/ov5640.c
+++ b/drivers/media/i2c/ov5640.c
@@ -2464,6 +2464,7 @@ static void ov5640_reset(struct ov5640_dev *sensor)
static int ov5640_set_power_on(struct ov5640_dev *sensor)
{
struct i2c_client *client = sensor->i2c_client;
+ u16 chip_id;
int ret;
ret = clk_prepare_enable(sensor->xclk);
@@ -2488,6 +2489,13 @@ static int ov5640_set_power_on(struct ov5640_dev *sensor)
if (ret)
goto power_off;
+ ret = ov5640_read_reg16(sensor, OV5640_REG_CHIP_ID, &chip_id);
+ if (ret) {
+ dev_err(&client->dev, "%s: failed to read chip identifier\n",
+ __func__);
+ goto power_off;
+ }
+
return 0;
power_off:
@@ -3791,28 +3799,6 @@ static int ov5640_get_regulators(struct ov5640_dev *sensor)
sensor->supplies);
}
-static int ov5640_check_chip_id(struct ov5640_dev *sensor)
-{
- struct i2c_client *client = sensor->i2c_client;
- int ret = 0;
- u16 chip_id;
-
- ret = ov5640_read_reg16(sensor, OV5640_REG_CHIP_ID, &chip_id);
- if (ret) {
- dev_err(&client->dev, "%s: failed to read chip identifier\n",
- __func__);
- return ret;
- }
-
- if (chip_id != 0x5640) {
- dev_err(&client->dev, "%s: wrong chip identifier, expected 0x5640, got 0x%x\n",
- __func__, chip_id);
- return -ENXIO;
- }
-
- return 0;
-}
-
static int ov5640_probe(struct i2c_client *client)
{
struct device *dev = &client->dev;
@@ -3910,27 +3896,13 @@ static int ov5640_probe(struct i2c_client *client)
if (ret)
goto entity_cleanup;
- ret = ov5640_sensor_resume(dev);
- if (ret) {
- dev_err(dev, "failed to power on\n");
- goto entity_cleanup;
- }
-
- pm_runtime_set_active(dev);
- pm_runtime_get_noresume(dev);
- pm_runtime_enable(dev);
-
- ret = ov5640_check_chip_id(sensor);
- if (ret)
- goto err_pm_runtime;
-
ret = v4l2_async_register_subdev_sensor(&sensor->sd);
if (ret)
goto err_pm_runtime;
+ pm_runtime_enable(dev);
pm_runtime_set_autosuspend_delay(dev, 1000);
pm_runtime_use_autosuspend(dev);
- pm_runtime_put_autosuspend(dev);
return 0;
--
2.35.3