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/spi/rk1608_core.c | 165 ++++++++++++++++++++++++++++++++++++++++++------------
1 files changed, 127 insertions(+), 38 deletions(-)
diff --git a/kernel/drivers/media/spi/rk1608_core.c b/kernel/drivers/media/spi/rk1608_core.c
index cf2c3f6..0ca6d27 100644
--- a/kernel/drivers/media/spi/rk1608_core.c
+++ b/kernel/drivers/media/spi/rk1608_core.c
@@ -556,16 +556,17 @@
}
static int rk1608_msg_init_sensor(struct rk1608_state *pdata,
- struct msg_init *msg, int id)
+ struct msg_init *msg, int in_mipi, int out_mipi,
+ int id, int cam_id)
{
u32 idx = pdata->dphy[id]->fmt_inf_idx;
msg->msg_head.size = sizeof(struct msg_init);
msg->msg_head.type = id_msg_init_sensor_t;
- msg->msg_head.id.camera_id = id;
+ msg->msg_head.id.camera_id = cam_id;
msg->msg_head.mux.sync = 1;
- msg->in_mipi_phy = pdata->dphy[id]->in_mipi;
- msg->out_mipi_phy = pdata->dphy[id]->out_mipi;
+ msg->in_mipi_phy = in_mipi;
+ msg->out_mipi_phy = out_mipi;
msg->mipi_lane = pdata->dphy[id]->fmt_inf[idx].mipi_lane;
msg->bayer = 0;
memcpy(msg->sensor_name, pdata->dphy[id]->sensor_name,
@@ -573,6 +574,7 @@
msg->i2c_slave_addr = pdata->dphy[id]->i2c_addr;
msg->i2c_bus = pdata->dphy[id]->i2c_bus;
+ msg->sub_sensor_num = pdata->dphy[id]->sub_sensor_num;
return rk1608_send_msg_to_dsp(pdata, &msg->msg_head);
}
@@ -580,22 +582,25 @@
static int rk1608_msg_init_dsp_time(struct rk1608_state *pdata,
struct msg_init_dsp_time *msg, int id)
{
- struct timeval tv;
+ u64 usecs64;
+ u32 mod;
msg->msg_head.size = sizeof(struct msg_init_dsp_time);
msg->msg_head.type = id_msg_sys_time_set_t;
msg->msg_head.id.camera_id = id;
msg->msg_head.mux.sync = 0;
- do_gettimeofday(&tv);
- msg->tv_sec = tv.tv_sec;
- msg->tv_usec = tv.tv_usec;
+ usecs64 = ktime_to_us(ktime_get());
+
+ mod = do_div(usecs64, USEC_PER_MSEC);
+ msg->tv_usec = mod;
+ msg->tv_sec = usecs64;
return rk1608_send_msg_to_dsp(pdata, &msg->msg_head);
}
static int rk1608_msg_set_input_size(struct rk1608_state *pdata,
- struct msg_in_size *msg, int id)
+ struct msg_in_size *msg, int id, int cam_id)
{
u32 i;
u32 msg_size = sizeof(struct msg);
@@ -617,14 +622,14 @@
msg->msg_head.size = msg_size / sizeof(int);
msg->msg_head.type = id_msg_set_input_size_t;
- msg->msg_head.id.camera_id = id;
+ msg->msg_head.id.camera_id = cam_id;
msg->msg_head.mux.sync = 1;
return rk1608_send_msg_to_dsp(pdata, &msg->msg_head);
}
static int rk1608_msg_set_output_size(struct rk1608_state *pdata,
- struct msg_set_output_size *msg, int id)
+ struct msg_set_output_size *msg, int id, int cam_id)
{
u32 i;
u32 msg_size = sizeof(struct msg_out_size_head);
@@ -646,14 +651,14 @@
msg->head.msg_head.size = msg_size / sizeof(int);
msg->head.msg_head.type = id_msg_set_output_size_t;
- msg->head.msg_head.id.camera_id = id;
+ msg->head.msg_head.id.camera_id = cam_id;
msg->head.msg_head.mux.sync = 1;
msg->head.width = fmt_inf->hactive;
msg->head.height = fmt_inf->vactive;
msg->head.mipi_clk = 2 * pdata->dphy[id]->link_freqs;
msg->head.line_length_pclk = fmt_inf->htotal;
msg->head.frame_length_lines = fmt_inf->vtotal;
- msg->head.mipi_lane = fmt_inf->mipi_lane;
+ msg->head.mipi_lane = fmt_inf->mipi_lane_out;
msg->head.flip = pdata->flip;
return rk1608_send_msg_to_dsp(pdata, &msg->head.msg_head);
@@ -930,6 +935,54 @@
return ret;
}
+static int rk1608_init_virtual_sub_sensor(
+ struct rk1608_state *pdata, int id, int index)
+{
+ struct msg *msg = NULL;
+ struct msg_init *msg_init = NULL;
+ struct msg_in_size *msg_in_size = NULL;
+ struct msg_set_output_size *msg_out_size = NULL;
+ int cam_id = pdata->dphy[id]->sub_sensor[index].id;
+ int in_mipi = pdata->dphy[id]->sub_sensor[index].in_mipi;
+ int out_mipi = pdata->dphy[id]->sub_sensor[index].out_mipi;
+ int ret = 0;
+
+ msg = kzalloc(sizeof(*msg), GFP_KERNEL);
+ if (!msg) {
+ ret = -ENOMEM;
+ goto err;
+ }
+ msg_init = kzalloc(sizeof(*msg_init), GFP_KERNEL);
+ if (!msg_init) {
+ ret = -ENOMEM;
+ goto err;
+ }
+
+ msg_in_size = kzalloc(sizeof(*msg_in_size), GFP_KERNEL);
+ if (!msg_in_size) {
+ ret = -ENOMEM;
+ goto err;
+ }
+ msg_out_size = kzalloc(sizeof(*msg_out_size), GFP_KERNEL);
+ if (!msg_out_size) {
+ ret = -ENOMEM;
+ goto err;
+ }
+
+ ret = rk1608_msg_init_sensor(pdata, msg_init, in_mipi, out_mipi, id, cam_id);
+ ret |= rk1608_msg_set_input_size(pdata, msg_in_size, id, cam_id);
+ ret |= rk1608_msg_set_output_size(pdata, msg_out_size, id, cam_id);
+ ret |= rk1608_msg_set_stream_in_on(pdata, msg, cam_id);
+
+err:
+ kfree(msg_init);
+ kfree(msg_in_size);
+ kfree(msg_out_size);
+ kfree(msg);
+
+ return ret;
+}
+
static int rk1608_init_sensor(struct rk1608_state *pdata, int id)
{
struct msg *msg = NULL;
@@ -937,6 +990,9 @@
struct msg_in_size *msg_in_size = NULL;
struct msg_set_output_size *msg_out_size = NULL;
struct msg_init_dsp_time *msg_init_time = NULL;
+ int in_mipi = pdata->dphy[id]->in_mipi;
+ int out_mipi = pdata->dphy[id]->out_mipi;
+ int cam_id = id;
int ret = 0;
if (!pdata->sensor[id]) {
@@ -972,12 +1028,13 @@
goto err;
}
- ret = rk1608_msg_init_sensor(pdata, msg_init, id);
+
+ ret = rk1608_msg_init_sensor(pdata, msg_init, in_mipi, out_mipi, id, cam_id);
ret |= rk1608_msg_init_dsp_time(pdata, msg_init_time, id);
- ret |= rk1608_msg_set_input_size(pdata, msg_in_size, id);
- ret |= rk1608_msg_set_output_size(pdata, msg_out_size, id);
- ret |= rk1608_msg_set_stream_in_on(pdata, msg, id);
- ret |= rk1608_msg_set_stream_out_on(pdata, msg, id);
+ ret |= rk1608_msg_set_input_size(pdata, msg_in_size, id, cam_id);
+ ret |= rk1608_msg_set_output_size(pdata, msg_out_size, id, cam_id);
+ ret |= rk1608_msg_set_stream_in_on(pdata, msg, cam_id);
+ ret |= rk1608_msg_set_stream_out_on(pdata, msg, cam_id);
err:
kfree(msg_init);
@@ -1029,6 +1086,9 @@
{
struct spi_device *spi = pdata->spi;
int ret = 0;
+
+ if (pdata->pwren_gpio)
+ gpiod_direction_output(pdata->pwren_gpio, 1);
if (!IS_ERR(pdata->mclk)) {
ret = clk_set_rate(pdata->mclk, RK1608_MCLK_RATE);
@@ -1093,6 +1153,9 @@
if (pdata->reset_gpio)
gpiod_direction_output(pdata->reset_gpio, 0);
rk1608_cs_set_value(pdata, 0);
+
+ if (pdata->pwren_gpio)
+ gpiod_direction_output(pdata->pwren_gpio, 0);
if (!IS_ERR(pdata->mclk))
clk_disable_unprepare(pdata->mclk);
@@ -1166,11 +1229,25 @@
static int rk1608_stream_on(struct rk1608_state *pdata)
{
int id = 0, cnt = 0, ret = 0;
+ int sub_sensor_num = 0, index = 0;
mutex_lock(&pdata->lock);
id = pdata->sd.grp_id;
pdata->sensor_cnt = 0;
pdata->set_exp_cnt = 1;
+
+ sub_sensor_num = pdata->dphy[id]->sub_sensor_num;
+ for (index = 0; index < sub_sensor_num; index++) {
+ ret = rk1608_init_virtual_sub_sensor(pdata, id, index);
+ if (ret) {
+ dev_err(pdata->dev, "Init rk1608[%d] sub[%d] is failed!",
+ id,
+ index);
+ mutex_unlock(&pdata->lock);
+ return ret;
+ }
+ }
+
ret = rk1608_init_sensor(pdata, id);
if (ret) {
dev_err(pdata->dev, "Init rk1608[%d] is failed!",
@@ -1212,12 +1289,31 @@
static int rk1608_stream_off(struct rk1608_state *pdata)
{
+ u32 sub_sensor_num = 0, index = 0, sub_id = 0;
+
mutex_lock(&pdata->sensor_lock);
pdata->sensor_cnt = 0;
mutex_unlock(&pdata->sensor_lock);
+
+ sub_sensor_num = pdata->dphy[pdata->sd.grp_id]->sub_sensor_num;
+ for (index = 0; index < sub_sensor_num; index++) {
+ sub_id = pdata->dphy[pdata->sd.grp_id]->sub_sensor[index].id;
+ rk1608_deinit(pdata, sub_id);
+ }
+
rk1608_deinit(pdata, pdata->sd.grp_id);
return 0;
+}
+
+static int rk1608_set_quick_stream(struct rk1608_state *pdata, void *args)
+{
+ u32 stream = *(u32 *)args;
+
+ if (stream)
+ return rk1608_stream_on(pdata);
+ else
+ return rk1608_stream_off(pdata);
}
static int rk1608_s_stream(struct v4l2_subdev *sd, int enable)
@@ -1338,6 +1434,9 @@
break;
case PREISP_DISP_SET_LED_ON_OFF:
rk1608_disp_set_led_on_off(pdata, arg);
+ break;
+ case RKMODULE_SET_QUICK_STREAM:
+ rk1608_set_quick_stream(pdata, arg);
break;
default:
return -ENOTTY;
@@ -1880,7 +1979,6 @@
unsigned int file_size = 0;
unsigned int write_size = 0;
char *file_data = NULL;
- struct kstat *stat;
struct msg_xfile *xfile;
char *ref_data_path = REF_DATA_PATH;
@@ -1899,30 +1997,21 @@
return -EFAULT;
}
- stat = kmalloc(sizeof(*stat), GFP_KERNEL);
- if (!stat) {
- ret = -ENOMEM;
- goto err;
- }
-
- vfs_stat(file_path, stat);
-
- file_size = stat->size;
- file_size = (file_size+0x3)&(~0x3);
-
dev_info(pdata->dev, "start import %s to addr:0x%x size:%d\n",
- file_path, xfile->addr, file_size);
+ file_path, xfile->addr, xfile->data_size);
- file_data = vmalloc(file_size);
+ file_data = vmalloc(xfile->data_size);
if (!file_data) {
ret = -ENOMEM;
goto err;
}
- ret = kernel_read(fp, file_data, file_size, &pos);
- if (ret <= 0)
+ file_size = kernel_read(fp, file_data, xfile->data_size, &pos);
+ if (file_size <= 0) {
dev_err(pdata->dev, "%s: read error: ret=%d\n",
__func__, ret);
+ goto err;
+ }
write_size = (file_size <= xfile->data_size)?file_size:xfile->data_size;
if (file_size != xfile->data_size)
@@ -1946,7 +2035,6 @@
xfile->path, xfile->addr, file_size);
err:
- kfree(stat);
if (file_data)
vfree(file_data);
if (fp)
@@ -2098,7 +2186,7 @@
goto err;
}
- if (head->item[i].size > 128) {
+ if (head->item[i].size > sizeof(calibdata_->calib_sn_code)) {
dev_err(pdata->dev, "%s: %s size:%d error!\n",
__func__, head->item[i].name, head->item[i].size);
goto err;
@@ -2115,7 +2203,7 @@
pos = head->item[i].offset;
- ret = kernel_read(fp, (char *)&calibdata_->calib_sn_code, head->item[i].size, &pos);
+ ret = kernel_read(fp, (char *)calibdata_->calib_sn_code, head->item[i].size, &pos);
if (ret <= 0) {
dev_err(pdata->dev, "%s: read error: ret=%d\n", __func__, ret);
goto err;
@@ -2299,7 +2387,7 @@
#define PREISP_DCROP_CALIB_RATIO 192
#define PREISP_DCROP_CALIB_XOFFSET 196
#define PREISP_DCROP_CALIB_YOFFSET 198
-static int rk1608_get_dcrop_cfg(struct v4l2_rect *crop_in,
+int rk1608_get_dcrop_cfg(struct v4l2_rect *crop_in,
struct v4l2_rect *crop_out)
{
struct file *fp;
@@ -2706,3 +2794,4 @@
MODULE_AUTHOR("Rockchip Camera/ISP team");
MODULE_DESCRIPTION("A DSP driver for rk1608 chip");
MODULE_LICENSE("GPL v2");
+MODULE_IMPORT_NS(VFS_internal_I_am_really_a_filesystem_and_am_NOT_a_driver);
--
Gitblit v1.6.2