armbian_build/patch/kernel/archive/sunxi-6.6/patches.megous/media-ov5640-Fix-focus-commands-blocking-until-complete.patch
Gunjan Gupta d1186b8a0e kernel: sunxi: Add patches for 6.6 kernel
I have changed the way the patches are generated a bit. Instead of using orange-pi branch from megous tree for 6.6 kernel, I have used the following kernel branches

	a83t-suspend, af8133j, anx, audio,
	axp, cam, drm, err, fixes, mbus,
	modem, opi3, pb, pinetab, pp, ppkb,
	samuel, speed, tbs-a711, ths

These branches were carefully chosen to include only allwinner related patches and remove importing of the rockchip related patches into the allwinner kernel.

Following patches are modified to fix patch application failure
- patches.armbian/arm64-dts-sun50i-h616-orangepi-zero2-reg_usb1_vbus-status-ok.patch
- patches.armbian/arm64-dts-sun50i-h616-orangepi-zero2-Enable-GPU-mali.patch
- patches.armbian/arm64-dts-allwinner-h616-Add-efuse_xlate-cpu-frequency-scaling-v1_6_2.patch
- patches.armbian/arm64-dts-allwinner-h616-LED-green_power_on-red_status_heartbeat.patch
- patches.armbian/arm64-dts-allwinner-overlay-Add-Overlays-for-sunxi64.patch
- patches.armbian/arm64-dts-sun50i-h616-bigtreetech-cb1.patch

Following patches are modified because of kernel api change to fix compilation failure
- patches.armbian/drv-gpu-drm-sun4i-Add-HDMI-audio-sun4i-hdmi-encoder.patch
- patches.armbian/drv-of-Device-Tree-Overlay-ConfigFS-interface.patch
2023-10-30 22:58:11 +05:30

114 lines
2.7 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Benjamin Schaaf <ben.schaaf@gmail.com>
Date: Mon, 22 Nov 2021 23:38:26 +1100
Subject: media: ov5640: Fix focus commands blocking until complete
Previously setting the focus controls would block until the sensor
completed the focus routine.
---
drivers/media/i2c/ov5640.c | 67 +++-------
1 file changed, 18 insertions(+), 49 deletions(-)
diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c
index 46132af43802..e9421590efd6 100644
--- a/drivers/media/i2c/ov5640.c
+++ b/drivers/media/i2c/ov5640.c
@@ -2642,6 +2642,19 @@ static int ov5640_copy_fw_to_device(struct ov5640_dev *sensor,
return -ETIMEDOUT;
}
+static int ov5640_fw_command(struct ov5640_dev *sensor, int command)
+{
+ int ret;
+
+ ret = ov5640_write_reg(sensor, OV5640_REG_FW_CMD_MAIN, command);
+ if(ret)
+ return ret;
+
+ msleep(5);
+
+ return 0;
+}
+
static int ov5640_af_init(struct ov5640_dev *sensor)
{
struct i2c_client *client = sensor->i2c_client;
@@ -2679,6 +2692,11 @@ static int ov5640_af_init(struct ov5640_dev *sensor)
// Set lens focus driver on
ret = ov5640_write_reg(sensor, OV5640_REG_VCM_CONTROL4, 0x3f);
+ if (ret)
+ return ret;
+
+ // Set the default focus zone
+ ret = ov5640_fw_command(sensor, OV5640_FW_CMD_ZONE_CONFIG);
if (ret)
return ret;
return ret;
@@ -3295,35 +3313,6 @@ static int ov5640_set_framefmt(struct ov5640_dev *sensor,
is_jpeg ? (BIT(5) | BIT(3)) : 0);
}
-static int ov5640_fw_command(struct ov5640_dev *sensor, int command)
-{
- u8 fw_ack;
- int i;
- int ret;
-
- ret = ov5640_write_reg(sensor, OV5640_REG_FW_CMD_ACK, 0x01);
- if(ret)
- return ret;
-
- ret = ov5640_write_reg(sensor, OV5640_REG_FW_CMD_MAIN, command);
- if(ret)
- return ret;
-
- for (i = 0; i < 100; i++) {
- ret = ov5640_read_reg(sensor, OV5640_REG_FW_CMD_ACK, &fw_ack);
- if (ret)
- return ret;
-
- if (fw_ack == 0){
- return ret;
- }
-
- msleep(50);
- }
- return -ETIMEDOUT;
-}
-
-
/*
* Sensor Controls.
*/
@@ -3459,26 +3448,6 @@ static int ov5640_set_ctrl_focus(struct ov5640_dev *sensor, int command)
return 0;
}
- if (command == OV5640_FW_CMD_RELEASE_FOCUS) {
- dev_dbg(&client->dev, "%s: Releasing autofocus\n",
- __func__);
- return ov5640_fw_command(sensor, OV5640_FW_CMD_RELEASE_FOCUS);
- }
-
- // Restart zone config
- ret = ov5640_fw_command(sensor, OV5640_FW_CMD_ZONE_CONFIG);
- if (ret)
- return ret;
-
- // Set default focus zones
- ret = ov5640_fw_command(sensor, OV5640_FW_CMD_DEFAULT_ZONES);
- if (ret)
- return ret;
-
- dev_dbg(&client->dev, "%s: Triggering autofocus\n",
- __func__);
-
- // Start focussing
return ov5640_fw_command(sensor, command);
}
--
Armbian