From 1543e317f1da31b75942316931e8f491a8920811 Mon Sep 17 00:00:00 2001
From: hc <hc@nodka.com>
Date: Thu, 04 Jan 2024 10:08:02 +0000
Subject: [PATCH] disable FB
---
kernel/drivers/media/i2c/os02k10.c | 51 +++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 41 insertions(+), 10 deletions(-)
diff --git a/kernel/drivers/media/i2c/os02k10.c b/kernel/drivers/media/i2c/os02k10.c
index 3988053..0a064cd 100644
--- a/kernel/drivers/media/i2c/os02k10.c
+++ b/kernel/drivers/media/i2c/os02k10.c
@@ -47,7 +47,7 @@
#define OS02K10_XVCLK_FREQ 24000000
-#define CHIP_ID 0x530243
+#define CHIP_ID 0x005302
#define OS02K10_REG_CHIP_ID 0x300a
#define OS02K10_REG_CTRL_MODE 0x0100
@@ -1806,6 +1806,7 @@
s64 max;
int ret = 0;
u32 val = 0;
+ u32 reg_data;
/* Propagate change of current control to all related controls */
switch (ctrl->id) {
@@ -1835,23 +1836,53 @@
}
break;
case V4L2_CID_ANALOGUE_GAIN:
+ /*
+ * dgain reg format is 4.10bits, again reg format is 4.4bits
+ * 1x is 64, 6 decimal places
+ */
if (ctrl->val > 992) {
- dgain = ctrl->val * 1024 / 992;
+ dgain = ctrl->val * 1024 / 992; //15.5X * 64 = 992
again = 992;
} else {
- dgain = 1024;
+ dgain = 1024; //move 10 bits left
again = ctrl->val;
}
dev_dbg(&client->dev, "gain %d, ag 0x%x, dg 0x%x\n",
ctrl->val, again, dgain);
- ret = os02k10_write_reg(os02k10->client,
+
+ ret |= os02k10_read_reg(os02k10->client, OS02K10_AEC_LONG_REL_GAIN_REG_H,
+ OS02K10_REG_VALUE_08BIT, ®_data);
+ reg_data = reg_data & 0xf0;
+ ret |= os02k10_write_reg(os02k10->client,
OS02K10_AEC_LONG_REL_GAIN_REG_H,
- OS02K10_REG_VALUE_16BIT,
- (again << 2) & 0xff0);
+ OS02K10_REG_VALUE_08BIT,
+ ((again >> 6) & 0x0f) | reg_data);
+ ret |= os02k10_read_reg(os02k10->client, OS02K10_AEC_LONG_REL_GAIN_REG_L,
+ OS02K10_REG_VALUE_08BIT, ®_data);
+ reg_data = reg_data & 0x0f;
+ ret |= os02k10_write_reg(os02k10->client,
+ OS02K10_AEC_LONG_REL_GAIN_REG_L,
+ OS02K10_REG_VALUE_08BIT,
+ (((again >> 2) & 0x0f) << 4) | reg_data);
+
+ ret |= os02k10_read_reg(os02k10->client, OS02K10_AEC_LONG_DIG_GAIN_REG_H,
+ OS02K10_REG_VALUE_08BIT, ®_data);
+ reg_data = reg_data & 0xf0;
ret |= os02k10_write_reg(os02k10->client,
OS02K10_AEC_LONG_DIG_GAIN_REG_H,
- OS02K10_REG_VALUE_24BIT,
- (dgain << 6) & 0xfffc0);
+ OS02K10_REG_VALUE_08BIT,
+ ((dgain >> 10) & 0x0f) | reg_data);
+ ret |= os02k10_write_reg(os02k10->client,
+ OS02K10_AEC_LONG_DIG_GAIN_REG_M,
+ OS02K10_REG_VALUE_08BIT,
+ (dgain >> 2) & 0xff);
+ ret |= os02k10_read_reg(os02k10->client, OS02K10_AEC_LONG_DIG_GAIN_REG_L,
+ OS02K10_REG_VALUE_08BIT, ®_data);
+ reg_data = reg_data & 0x3f;
+ ret |= os02k10_write_reg(os02k10->client,
+ OS02K10_AEC_LONG_DIG_GAIN_REG_L,
+ OS02K10_REG_VALUE_08BIT,
+ ((dgain & 0x03) << 6) | reg_data);
break;
case V4L2_CID_VBLANK:
dev_dbg(&client->dev, "set blank value 0x%x\n", ctrl->val);
@@ -2095,11 +2126,11 @@
return -EINVAL;
}
- os02k10->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_ASIS);
+ os02k10->reset_gpio = devm_gpiod_get(dev, "reset", os02k10->is_thunderboot ? GPIOD_ASIS : GPIOD_OUT_LOW);
if (IS_ERR(os02k10->reset_gpio))
dev_warn(dev, "Failed to get reset-gpios\n");
- os02k10->pwdn_gpio = devm_gpiod_get(dev, "pwdn", GPIOD_ASIS);
+ os02k10->pwdn_gpio = devm_gpiod_get(dev, "pwdn", os02k10->is_thunderboot ? GPIOD_ASIS : GPIOD_OUT_LOW);
if (IS_ERR(os02k10->pwdn_gpio))
dev_warn(dev, "Failed to get pwdn-gpios\n");
--
Gitblit v1.6.2