From 38e6bdbf4593ff3b4a3d43fef2da24e522350ff2 Mon Sep 17 00:00:00 2001 From: Ondrej Jirman Date: Sun, 26 Jan 2020 00:28:10 +0100 Subject: [PATCH 054/323] 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 --- drivers/media/i2c/ov5640.c | 40 ++++++++------------------------------ 1 file changed, 8 insertions(+), 32 deletions(-) diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c index bfc7cdea8..69be02648 100644 --- a/drivers/media/i2c/ov5640.c +++ b/drivers/media/i2c/ov5640.c @@ -1906,6 +1906,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); @@ -1930,6 +1931,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: @@ -3011,34 +3019,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_set_power_on(sensor); - if (ret) - return ret; - - 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; - } - - if (chip_id != 0x5640) { - dev_err(&client->dev, "%s: wrong chip identifier, expected 0x5640, got 0x%x\n", - __func__, chip_id); - ret = -ENXIO; - } - -power_off: - ov5640_set_power_off(sensor); - return ret; -} - static int ov5640_probe(struct i2c_client *client) { struct device *dev = &client->dev; @@ -3156,10 +3136,6 @@ static int ov5640_probe(struct i2c_client *client) mutex_init(&sensor->lock); - ret = ov5640_check_chip_id(sensor); - if (ret) - goto entity_cleanup; - ret = ov5640_init_controls(sensor); if (ret) goto entity_cleanup; -- 2.34.0