Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix AE slow and bounce #197

Merged
merged 5 commits into from
Jul 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package/isp-tuningd/src/isp-tuningd.c
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,7 @@ int main(int argc, char *argv[]) {
PROT_READ | PROT_WRITE, MAP_SHARED,
mem_fd, (uint64_t)mem_yuv_phy_addr | 0x100000000);
assert(mem_yuv_logic_addr != MAP_FAILED);
fprintf(stderr, "map share mem phy addr: 0x%08X, size: %u\n", mem_yuv_phy_addr, mem_yuv_map_size);

if (argc > 1 && strcmp(argv[1], "-j") == 0) {
// open encoder
Expand Down
2 changes: 1 addition & 1 deletion package/mediactl_lib/src/config/imx219_0.conf
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
"ae_agc" :256,
"ae_ad_shuttle_freq" :1,
"ae_ad_gain_freq" :0,
"ae_adjust_step_max":36,
"ae_adjust_step_max":255,
"ae_ex_value_max" :1162,
"ae_ex_value_mid" :256,
"ae_ex_value_min" :1,
Expand Down
2 changes: 1 addition & 1 deletion package/mediactl_lib/src/config/imx219_1.conf
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
"ae_agc" :256,
"ae_ad_shuttle_freq" :1,
"ae_ad_gain_freq" :0,
"ae_adjust_step_max":36,
"ae_adjust_step_max":255,
"ae_ex_value_max" :1162,
"ae_ex_value_mid" :256,
"ae_ex_value_min" :1,
Expand Down
2 changes: 1 addition & 1 deletion package/mediactl_lib/src/config/imx219_1080x1920_0.conf
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
"ae_agc" :256,
"ae_ad_shuttle_freq" :1,
"ae_ad_gain_freq" :0,
"ae_adjust_step_max":36,
"ae_adjust_step_max":255,
"ae_ex_value_max" :1975,
"ae_ex_value_mid" :256,
"ae_ex_value_min" :1,
Expand Down
2 changes: 1 addition & 1 deletion package/mediactl_lib/src/config/imx219_1080x1920_1.conf
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
"ae_agc" :256,
"ae_ad_shuttle_freq" :1,
"ae_ad_gain_freq" :0,
"ae_adjust_step_max":36,
"ae_adjust_step_max":255,
"ae_ex_value_max" :1975,
"ae_ex_value_mid" :256,
"ae_ex_value_min" :1,
Expand Down
20 changes: 2 additions & 18 deletions package/mediactl_lib/src/media_ctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ static int isp_share_memory_alloc(void)
return 1 ;
}

allocAlignMem[0].size = MEMORY_TEST_BLOCK_SIZE * 1024 ;//MEMORY_TEST_BLOCK_SIZE; 1920x1080*3/2+1920*1080
allocAlignMem[0].size = MEMORY_TEST_BLOCK_SIZE * 1024 * 3;//MEMORY_TEST_BLOCK_SIZE; 1920x1080*3/2+1920*1080
allocAlignMem[0].alignment = MEMORY_TEST_BLOCK_ALIGN;
allocAlignMem[0].phyAddr = 0;

Expand All @@ -848,7 +848,7 @@ static int isp_share_memory_alloc(void)
printf("main block alloc:0x%08x,size:%d,align %d\r\n",allocAlignMem[0].phyAddr,allocAlignMem[0].size,allocAlignMem[0].alignment);
}

allocAlignMem[1].size = MEMORY_TEST_BLOCK_SIZE * 1024 ;//MEMORY_TEST_BLOCK_SIZE; 1920x1080*3/2+1920*1080
allocAlignMem[1].size = MEMORY_TEST_BLOCK_SIZE * 1024 * 3;//MEMORY_TEST_BLOCK_SIZE; 1920x1080*3/2+1920*1080
allocAlignMem[1].alignment = MEMORY_TEST_BLOCK_ALIGN;
allocAlignMem[1].phyAddr = 0;

Expand Down Expand Up @@ -1004,14 +1004,6 @@ int mediactl_all_set_ae(enum isp_pipeline_e pipeline)

if(ISP_F2K_PIPELINE == pipeline)
{
// FIXME: lantency, skip 3 frames
static uint32_t counter = 0;
counter += 1;
if (counter % 3) {
// do nothing
return ret;
}

pipe = v4l_isp.f2k;
ret = v4l2_subdev_open(pipe);
if (ret < 0)
Expand Down Expand Up @@ -1073,14 +1065,6 @@ int mediactl_all_set_ae(enum isp_pipeline_e pipeline)

if(ISP_R2K_PIPELINE == pipeline)
{
// lantency
static uint32_t counter = 0;
counter += 1;
if (counter % 3) {
// do nothing
return ret;
}

pipe = v4l_isp.r2k;
ret = v4l2_subdev_open(pipe);
if (ret < 0)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
From 339e562403d2fa0d12e057d45f38dfe158a8e1ee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=BB=84=E5=AD=90=E6=87=BF?=
<[email protected]>
Date: Tue, 19 Jul 2022 17:15:00 +0800
Subject: [PATCH] fix imx219 gain and exposure parameter settings
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: 黄子懿 <[email protected]>
---
.../i2c/soc_camera/canaanchip/imx219_0.c | 28 +++++++++++++++----
.../i2c/soc_camera/canaanchip/imx219_1.c | 28 +++++++++++++++----
2 files changed, 46 insertions(+), 10 deletions(-)

diff --git a/drivers/media/i2c/soc_camera/canaanchip/imx219_0.c b/drivers/media/i2c/soc_camera/canaanchip/imx219_0.c
index e25d9bfe..c8002b24 100644
--- a/drivers/media/i2c/soc_camera/canaanchip/imx219_0.c
+++ b/drivers/media/i2c/soc_camera/canaanchip/imx219_0.c
@@ -766,6 +766,27 @@ static int reg_write(struct i2c_client *client, const u16 addr, const u8 data)
return ret == 1 ? 0 : -EIO;
}

+static int reg16_write(struct i2c_client *client, const u16 addr, const u16 data)
+{
+ struct i2c_adapter *adap = client->adapter;
+ struct i2c_msg msg;
+ u8 tx[4];
+ int ret;
+
+ msg.addr = client->addr;
+ msg.buf = tx;
+ msg.len = 4;
+ msg.flags = 0;
+ tx[0] = addr >> 8;
+ tx[1] = addr & 0xff;
+ tx[2] = data >> 8;
+ tx[3] = data & 0xff;
+ ret = i2c_transfer(adap, &msg, 1);
+ mdelay(2);
+
+ return ret == 1 ? 0 : -EIO;
+}
+
static int reg_read(struct i2c_client *client, const u16 addr)
{
u8 buf[2] = {addr >> 8, addr & 0xff};
@@ -1099,16 +1120,13 @@ static int imx219_s_ctrl(struct v4l2_ctrl *ctrl)
*/

ret = reg_write(client, 0x0157, priv->analogue_gain);
- ret |= reg_write(client, 0x0158, priv->digital_gain >> 8);
- ret |= reg_write(client, 0x0159, priv->digital_gain & 0xff);
+ ret |= reg16_write(client, 0x0158, priv->digital_gain);

return ret;

case V4L2_CID_EXPOSURE:
priv->exposure_time = ctrl->val;
-
- ret = reg_write(client, 0x015a, priv->exposure_time >> 8);
- ret |= reg_write(client, 0x015b, priv->exposure_time & 0xff);
+ ret = reg16_write(client, 0x015a, priv->exposure_time);
return ret;

case V4L2_CID_TEST_PATTERN:
diff --git a/drivers/media/i2c/soc_camera/canaanchip/imx219_1.c b/drivers/media/i2c/soc_camera/canaanchip/imx219_1.c
index f11986c9..d30c8a51 100644
--- a/drivers/media/i2c/soc_camera/canaanchip/imx219_1.c
+++ b/drivers/media/i2c/soc_camera/canaanchip/imx219_1.c
@@ -764,6 +764,27 @@ static int reg_write(struct i2c_client *client, const u16 addr, const u8 data)
return ret == 1 ? 0 : -EIO;
}

+static int reg16_write(struct i2c_client *client, const u16 addr, const u16 data)
+{
+ struct i2c_adapter *adap = client->adapter;
+ struct i2c_msg msg;
+ u8 tx[4];
+ int ret;
+
+ msg.addr = client->addr;
+ msg.buf = tx;
+ msg.len = 4;
+ msg.flags = 0;
+ tx[0] = addr >> 8;
+ tx[1] = addr & 0xff;
+ tx[2] = data >> 8;
+ tx[3] = data & 0xff;
+ ret = i2c_transfer(adap, &msg, 1);
+ mdelay(2);
+
+ return ret == 1 ? 0 : -EIO;
+}
+
static int reg_read(struct i2c_client *client, const u16 addr)
{
u8 buf[2] = {addr >> 8, addr & 0xff};
@@ -1092,16 +1113,13 @@ static int imx219_s_ctrl(struct v4l2_ctrl *ctrl)
*/

ret = reg_write(client, 0x0157, priv->analogue_gain);
- ret |= reg_write(client, 0x0158, priv->digital_gain >> 8);
- ret |= reg_write(client, 0x0159, priv->digital_gain & 0xff);
+ ret |= reg16_write(client, 0x0158, priv->digital_gain);

return ret;

case V4L2_CID_EXPOSURE:
priv->exposure_time = ctrl->val;
-
- ret = reg_write(client, 0x015a, priv->exposure_time >> 8);
- ret |= reg_write(client, 0x015b, priv->exposure_time & 0xff);
+ ret = reg16_write(client, 0x015a, priv->exposure_time);
return ret;

case V4L2_CID_TEST_PATTERN:
--
2.36.1