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/sc530ai.c | 152 ++++++++++++++++++++++++++++++++++----------------
1 files changed, 102 insertions(+), 50 deletions(-)
diff --git a/kernel/drivers/media/i2c/sc530ai.c b/kernel/drivers/media/i2c/sc530ai.c
index 6725245..d8e3548 100644
--- a/kernel/drivers/media/i2c/sc530ai.c
+++ b/kernel/drivers/media/i2c/sc530ai.c
@@ -43,6 +43,7 @@
#include <linux/printk.h>
#include <linux/rk-camera-module.h>
+#include "../platform/rockchip/isp/rkisp_tb_helper.h"
#define DRIVER_VERSION KERNEL_VERSION(0, 0x01, 0x01)
#ifndef V4L2_CID_DIGITAL_GAIN
@@ -52,6 +53,7 @@
#define SC530AI_LINK_FREQ_396M 198000000 // 396Mbps
#define SC530AI_LINK_FREQ_792M 396000000 // 792Mbps
#define SC530AI_LINK_FREQ_792M_2LANE 396000000 // 792Mbps
+#define SC530AI_LINK_FREQ_936M_2LANE 468000000 // 936Mbps
#define SC530AI_LINEAR_PIXEL_RATES (SC530AI_LINK_FREQ_396M / 10 * 2 * 4)
#define SC530AI_HDR_PIXEL_RATES (SC530AI_LINK_FREQ_792M / 10 * 2 * 4)
@@ -194,6 +196,8 @@
const char *module_name;
const char *len_name;
bool has_init_exp;
+ bool is_thunderboot;
+ bool is_first_streamoff;
struct preisp_hdrae_exp_s init_hdrae_exp;
};
@@ -520,18 +524,22 @@
{0x37f9, 0x80},
{0x3018, 0x32},
{0x3019, 0x0c},
- {0x301f, 0x18},
+ {0x301f, 0x42},
+ {0x320c, 0x06},
+ {0x320d, 0x27},
+ {0x320e, 0x07},
+ {0x320f, 0xbc},
{0x3250, 0x40},
{0x3251, 0x98},
{0x3253, 0x0c},
{0x325f, 0x20},
{0x3301, 0x08},
{0x3304, 0x50},
- {0x3306, 0x78},
+ {0x3306, 0x88},
{0x3308, 0x14},
{0x3309, 0x70},
{0x330a, 0x00},
- {0x330b, 0xd8},
+ {0x330b, 0xf8},
{0x330d, 0x10},
{0x331e, 0x41},
{0x331f, 0x61},
@@ -560,18 +568,18 @@
{0x33ae, 0x30},
{0x33af, 0x50},
{0x33b1, 0x80},
- {0x33b2, 0x80},
- {0x33b3, 0x40},
+ {0x33b2, 0x48},
+ {0x33b3, 0x30},
{0x349f, 0x02},
{0x34a6, 0x48},
- {0x34a7, 0x49},
- {0x34a8, 0x40},
- {0x34a9, 0x30},
- {0x34f8, 0x4b},
- {0x34f9, 0x30},
+ {0x34a7, 0x4b},
+ {0x34a8, 0x30},
+ {0x34a9, 0x18},
+ {0x34f8, 0x5f},
+ {0x34f9, 0x08},
{0x3632, 0x48},
{0x3633, 0x32},
- {0x3637, 0x2b},
+ {0x3637, 0x29},
{0x3638, 0xc1},
{0x363b, 0x20},
{0x363d, 0x02},
@@ -582,7 +590,7 @@
{0x367c, 0x40},
{0x367d, 0x48},
{0x3690, 0x32},
- {0x3691, 0x32},
+ {0x3691, 0x43},
{0x3692, 0x33},
{0x3693, 0x40},
{0x3694, 0x4b},
@@ -594,7 +602,10 @@
{0x36a3, 0x4b},
{0x36a4, 0x4f},
{0x36d0, 0x01},
+ {0x36ea, 0x0d},
+ {0x36eb, 0x04},
{0x36ec, 0x03},
+ {0x36ed, 0x14},
{0x370f, 0x01},
{0x3722, 0x00},
{0x3728, 0x10},
@@ -603,8 +614,10 @@
{0x37b2, 0x83},
{0x37b3, 0x48},
{0x37b4, 0x49},
- {0x37fb, 0x25},
+ {0x37fa, 0x0d},
+ {0x37fb, 0x24},
{0x37fc, 0x01},
+ {0x37fd, 0x14},
{0x3901, 0x00},
{0x3902, 0xc5},
{0x3904, 0x08},
@@ -614,19 +627,20 @@
{0x391f, 0x44},
{0x3926, 0x21},
{0x3929, 0x18},
- {0x3933, 0x81},
- {0x3934, 0x81},
- {0x3937, 0x69},
+ {0x3933, 0x82},
+ {0x3934, 0x0a},
+ {0x3937, 0x5f},
{0x3939, 0x00},
{0x393a, 0x00},
{0x39dc, 0x02},
- {0x3e01, 0xcd},
- {0x3e02, 0xa0},
+ {0x3e01, 0xf6},
+ {0x3e02, 0xe0},
{0x440e, 0x02},
{0x4509, 0x20},
- {0x4800, 0x04},
- {0x4837, 0x14},
+ {0x4837, 0x22},
{0x5010, 0x10},
+ {0x5780, 0x66},
+ {0x578d, 0x40},
{0x5799, 0x06},
{0x57ad, 0x00},
{0x5ae0, 0xfe},
@@ -658,8 +672,7 @@
{0x5afe, 0x30},
{0x5aff, 0x28},
{0x36e9, 0x44},
- {0x37f9, 0x34},
-// {0x0100, 0x01},
+ {0x37f9, 0x44},
{REG_NULL, 0x00},
};
@@ -713,10 +726,10 @@
},
.exp_def = 0xcda / 2,
.hts_def = 0xb40,
- .vts_def = 0x0672,
+ .vts_def = 0x07bc,
.bus_fmt = MEDIA_BUS_FMT_SBGGR10_1X10,
.reg_list = sc530ai_10_30fps_2880x1620_2lane_regs,
- .mipi_freq_idx = 2,
+ .mipi_freq_idx = 3,
.bpp = 10,
.hdr_mode = NO_HDR,
.vc[PAD0] = V4L2_MBUS_CSI2_CHANNEL_0,
@@ -727,6 +740,7 @@
SC530AI_LINK_FREQ_396M,
SC530AI_LINK_FREQ_792M,
SC530AI_LINK_FREQ_792M_2LANE,
+ SC530AI_LINK_FREQ_936M_2LANE,
};
/* Write registers up to 4 at a time */
@@ -1340,21 +1354,23 @@
{
int ret;
- ret = sc530ai_write_array(sc530ai->client, sc530ai->cur_mode->reg_list);
- if (ret)
- return ret;
-
- /* In case these controls are set before streaming */
- ret = __v4l2_ctrl_handler_setup(&sc530ai->ctrl_handler);
- if (ret)
- return ret;
- if (sc530ai->has_init_exp && sc530ai->cur_mode->hdr_mode != NO_HDR) {
- ret = sc530ai_ioctl(&sc530ai->subdev, PREISP_CMD_SET_HDRAE_EXP,
- &sc530ai->init_hdrae_exp);
- if (ret) {
- dev_err(&sc530ai->client->dev,
- "init exp fail in hdr mode\n");
+ if (!sc530ai->is_thunderboot) {
+ ret = sc530ai_write_array(sc530ai->client, sc530ai->cur_mode->reg_list);
+ if (ret)
return ret;
+
+ /* In case these controls are set before streaming */
+ ret = __v4l2_ctrl_handler_setup(&sc530ai->ctrl_handler);
+ if (ret)
+ return ret;
+ if (sc530ai->has_init_exp && sc530ai->cur_mode->hdr_mode != NO_HDR) {
+ ret = sc530ai_ioctl(&sc530ai->subdev, PREISP_CMD_SET_HDRAE_EXP,
+ &sc530ai->init_hdrae_exp);
+ if (ret) {
+ dev_err(&sc530ai->client->dev,
+ "init exp fail in hdr mode\n");
+ return ret;
+ }
}
}
return sc530ai_write_reg(sc530ai->client, SC530AI_REG_CTRL_MODE,
@@ -1365,11 +1381,16 @@
static int __sc530ai_stop_stream(struct sc530ai *sc530ai)
{
sc530ai->has_init_exp = false;
+ if (sc530ai->is_thunderboot) {
+ sc530ai->is_first_streamoff = true;
+ pm_runtime_put(&sc530ai->client->dev);
+ }
return sc530ai_write_reg(sc530ai->client, SC530AI_REG_CTRL_MODE,
SC530AI_REG_VALUE_08BIT,
SC530AI_MODE_SW_STANDBY);
}
+static int __sc530ai_power_on(struct sc530ai *sc530ai);
static int sc530ai_s_stream(struct v4l2_subdev *sd, int on)
{
struct sc530ai *sc530ai = to_sc530ai(sd);
@@ -1381,6 +1402,10 @@
if (on == sc530ai->streaming)
goto unlock_and_return;
if (on) {
+ if (sc530ai->is_thunderboot && rkisp_tb_get_state() == RKISP_TB_NG) {
+ sc530ai->is_thunderboot = false;
+ __sc530ai_power_on(sc530ai);
+ }
ret = pm_runtime_get_sync(&client->dev);
if (ret < 0) {
pm_runtime_put_noidle(&client->dev);
@@ -1423,13 +1448,18 @@
pm_runtime_put_noidle(&client->dev);
goto unlock_and_return;
}
-
- ret |= sc530ai_write_reg(sc530ai->client,
- SC530AI_SOFTWARE_RESET_REG,
- SC530AI_REG_VALUE_08BIT,
- 0x01);
- usleep_range(100, 200);
-
+ if (!sc530ai->is_thunderboot) {
+ ret |= sc530ai_write_reg(sc530ai->client,
+ SC530AI_SOFTWARE_RESET_REG,
+ SC530AI_REG_VALUE_08BIT,
+ 0x01);
+ if (ret) {
+ v4l2_err(sd, "could not set init registers\n");
+ pm_runtime_put_noidle(&client->dev);
+ goto unlock_and_return;
+ }
+ usleep_range(100, 200);
+ }
sc530ai->power_on = true;
} else {
pm_runtime_put(&client->dev);
@@ -1463,6 +1493,10 @@
dev_err(dev, "Failed to enable xvclk\n");
return ret;
}
+
+ if (sc530ai->is_thunderboot)
+ return 0;
+
if (!IS_ERR(sc530ai->reset_gpio))
gpiod_set_value_cansleep(sc530ai->reset_gpio, 0);
@@ -1492,6 +1526,15 @@
{
int ret;
struct device *dev = &sc530ai->client->dev;
+
+ if (sc530ai->is_thunderboot) {
+ if (sc530ai->is_first_streamoff) {
+ sc530ai->is_thunderboot = false;
+ sc530ai->is_first_streamoff = false;
+ } else {
+ return;
+ }
+ }
if (!IS_ERR(sc530ai->pwdn_gpio))
gpiod_set_value_cansleep(sc530ai->pwdn_gpio, 0);
@@ -1716,8 +1759,7 @@
vts & 0xff);
if (!ret)
sc530ai->cur_vts = vts;
- if (sc530ai->cur_vts != sc530ai->cur_mode->vts_def)
- sc530ai_modify_fps_info(sc530ai);
+ sc530ai_modify_fps_info(sc530ai);
dev_dbg(&client->dev, "set vblank 0x%x\n", ctrl->val);
break;
case V4L2_CID_HFLIP:
@@ -1893,6 +1935,10 @@
u32 id = 0;
int ret;
+ if (sc530ai->is_thunderboot) {
+ dev_info(dev, "Enable thunderboot mode, skip sensor id check\n");
+ return 0;
+ }
ret = sc530ai_read_reg(client, SC530AI_REG_CHIP_ID,
SC530AI_REG_VALUE_16BIT, &id);
if (id != SC530AI_CHIP_ID) {
@@ -1951,6 +1997,7 @@
return -EINVAL;
}
+ sc530ai->is_thunderboot = IS_ENABLED(CONFIG_VIDEO_ROCKCHIP_THUNDER_BOOT_ISP);
sc530ai->client = client;
ret = sc530ai_parse_of(sc530ai);
@@ -1963,11 +2010,13 @@
return -EINVAL;
}
- sc530ai->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);
+ sc530ai->reset_gpio = devm_gpiod_get(dev, "reset",
+ sc530ai->is_thunderboot ? GPIOD_ASIS : GPIOD_OUT_LOW);
if (IS_ERR(sc530ai->reset_gpio))
dev_warn(dev, "Failed to get reset-gpios\n");
- sc530ai->pwdn_gpio = devm_gpiod_get(dev, "pwdn", GPIOD_OUT_LOW);
+ sc530ai->pwdn_gpio = devm_gpiod_get(dev, "pwdn",
+ sc530ai->is_thunderboot ? GPIOD_ASIS : GPIOD_OUT_LOW);
if (IS_ERR(sc530ai->pwdn_gpio))
dev_warn(dev, "Failed to get pwdn-gpios\n");
@@ -2041,7 +2090,10 @@
pm_runtime_set_active(dev);
pm_runtime_enable(dev);
- pm_runtime_idle(dev);
+ if (sc530ai->is_thunderboot)
+ pm_runtime_get_sync(dev);
+ else
+ pm_runtime_idle(dev);
return 0;
--
Gitblit v1.6.2