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

89 lines
2.4 KiB
Diff

From bf497b85e834e1a730cf542f6a42ad4c8d2e30c9 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 050/388] 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 | 35 ++++++++---------------------------
1 file changed, 8 insertions(+), 27 deletions(-)
diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c
index 75d7ed443..a9fee7ed9 100644
--- a/drivers/media/i2c/ov5640.c
+++ b/drivers/media/i2c/ov5640.c
@@ -2472,6 +2472,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);
@@ -2496,6 +2497,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:
@@ -3797,28 +3805,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;
@@ -3922,14 +3908,9 @@ static int ov5640_probe(struct i2c_client *client)
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;
--
2.35.3