mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-23 07:22:33 +00:00
20ea6adbf1
Build system: x86_64 Build-tested: bcm2708, bcm2709, bcm2710, bcm2711 Run-tested: bcm2708/RPiB+, bcm2709/RPi3B, bcm2710/RPi3B, bcm2711/RPi4B Signed-off-by: Marty Jones <mj8263788@gmail.com> Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
374 lines
9.2 KiB
Diff
374 lines
9.2 KiB
Diff
From 26934caec8e9a365d71e437333998002b2f2879c Mon Sep 17 00:00:00 2001
|
|
From: Dave Stevenson <dave.stevenson@raspberrypi.com>
|
|
Date: Thu, 17 Feb 2022 16:24:51 +0000
|
|
Subject: [PATCH] media: i2c: ov7251: Set VTS instead of having full
|
|
tables for FPS.
|
|
|
|
The driver did have a full copy of the registers for each of
|
|
the 30, 60, and 90 fps modes. The main difference between them were
|
|
registers 0x380e/f which set the total height of the frame (VTS).
|
|
|
|
Remove the excess register settings, and Set that register value
|
|
explicitly for each mode.
|
|
|
|
This has dropped a change for the 30fps mode to registers 0x3016,
|
|
0x3017, 0x3018, 0x301a, 0x301b, and 0x301c. The data available
|
|
doesn't describe these registers, but the sensor seems fully
|
|
functional without the alternate settings.
|
|
|
|
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
|
|
---
|
|
drivers/media/i2c/ov7251.c | 286 +++----------------------------------
|
|
1 file changed, 21 insertions(+), 265 deletions(-)
|
|
|
|
--- a/drivers/media/i2c/ov7251.c
|
|
+++ b/drivers/media/i2c/ov7251.c
|
|
@@ -39,6 +39,8 @@
|
|
#define OV7251_AEC_AGC_ADJ_1 0x350b
|
|
/* HTS is registers 0x380c and 0x380d */
|
|
#define OV7251_HTS 0x3a0
|
|
+#define OV7251_VTS_HIGH 0x380e
|
|
+#define OV7251_VTS_LOW 0x380f
|
|
#define OV7251_TIMING_FORMAT1 0x3820
|
|
#define OV7251_TIMING_FORMAT1_VFLIP BIT(2)
|
|
#define OV7251_TIMING_FORMAT2 0x3821
|
|
@@ -82,6 +84,7 @@ struct ov7251_mode_info {
|
|
u32 data_size;
|
|
u16 exposure_max;
|
|
u16 exposure_def;
|
|
+ u16 vts;
|
|
struct v4l2_fract timeperframe;
|
|
};
|
|
|
|
@@ -204,263 +207,7 @@ static const struct reg_value ov7251_glo
|
|
{ 0x303b, 0x02 },
|
|
};
|
|
|
|
-static const struct reg_value ov7251_setting_vga_30fps[] = {
|
|
- { 0x3005, 0x00 },
|
|
- { 0x3012, 0xc0 },
|
|
- { 0x3013, 0xd2 },
|
|
- { 0x3014, 0x04 },
|
|
- { 0x3016, 0xf0 },
|
|
- { 0x3017, 0xf0 },
|
|
- { 0x3018, 0xf0 },
|
|
- { 0x301a, 0xf0 },
|
|
- { 0x301b, 0xf0 },
|
|
- { 0x301c, 0xf0 },
|
|
- { 0x3023, 0x05 },
|
|
- { 0x3037, 0xf0 },
|
|
- { 0x3106, 0xda },
|
|
- { 0x3503, 0x07 },
|
|
- { 0x3509, 0x10 },
|
|
- { 0x3600, 0x1c },
|
|
- { 0x3602, 0x62 },
|
|
- { 0x3620, 0xb7 },
|
|
- { 0x3622, 0x04 },
|
|
- { 0x3626, 0x21 },
|
|
- { 0x3627, 0x30 },
|
|
- { 0x3630, 0x44 },
|
|
- { 0x3631, 0x35 },
|
|
- { 0x3634, 0x60 },
|
|
- { 0x3636, 0x00 },
|
|
- { 0x3662, 0x01 },
|
|
- { 0x3663, 0x70 },
|
|
- { 0x3664, 0x50 },
|
|
- { 0x3666, 0x0a },
|
|
- { 0x3669, 0x1a },
|
|
- { 0x366a, 0x00 },
|
|
- { 0x366b, 0x50 },
|
|
- { 0x3673, 0x01 },
|
|
- { 0x3674, 0xff },
|
|
- { 0x3675, 0x03 },
|
|
- { 0x3705, 0xc1 },
|
|
- { 0x3709, 0x40 },
|
|
- { 0x373c, 0x08 },
|
|
- { 0x3742, 0x00 },
|
|
- { 0x3757, 0xb3 },
|
|
- { 0x3788, 0x00 },
|
|
- { 0x37a8, 0x01 },
|
|
- { 0x37a9, 0xc0 },
|
|
- { 0x3800, 0x00 },
|
|
- { 0x3801, 0x04 },
|
|
- { 0x3802, 0x00 },
|
|
- { 0x3803, 0x04 },
|
|
- { 0x3804, 0x02 },
|
|
- { 0x3805, 0x8b },
|
|
- { 0x3806, 0x01 },
|
|
- { 0x3807, 0xeb },
|
|
- { 0x3808, 0x02 }, /* width high */
|
|
- { 0x3809, 0x80 }, /* width low */
|
|
- { 0x380a, 0x01 }, /* height high */
|
|
- { 0x380b, 0xe0 }, /* height low */
|
|
- { 0x380c, 0x03 }, /* total horiz timing high */
|
|
- { 0x380d, 0xa0 }, /* total horiz timing low */
|
|
- { 0x380e, 0x06 }, /* total vertical timing high */
|
|
- { 0x380f, 0xbc }, /* total vertical timing low */
|
|
- { 0x3810, 0x00 },
|
|
- { 0x3811, 0x04 },
|
|
- { 0x3812, 0x00 },
|
|
- { 0x3813, 0x05 },
|
|
- { 0x3814, 0x11 },
|
|
- { 0x3815, 0x11 },
|
|
- { 0x3820, 0x40 },
|
|
- { 0x3821, 0x00 },
|
|
- { 0x382f, 0x0e },
|
|
- { 0x3832, 0x00 },
|
|
- { 0x3833, 0x05 },
|
|
- { 0x3834, 0x00 },
|
|
- { 0x3835, 0x0c },
|
|
- { 0x3837, 0x00 },
|
|
- { 0x3b80, 0x00 },
|
|
- { 0x3b81, 0xa5 },
|
|
- { 0x3b82, 0x10 },
|
|
- { 0x3b83, 0x00 },
|
|
- { 0x3b84, 0x08 },
|
|
- { 0x3b85, 0x00 },
|
|
- { 0x3b86, 0x01 },
|
|
- { 0x3b87, 0x00 },
|
|
- { 0x3b88, 0x00 },
|
|
- { 0x3b89, 0x00 },
|
|
- { 0x3b8a, 0x00 },
|
|
- { 0x3b8b, 0x05 },
|
|
- { 0x3b8c, 0x00 },
|
|
- { 0x3b8d, 0x00 },
|
|
- { 0x3b8e, 0x00 },
|
|
- { 0x3b8f, 0x1a },
|
|
- { 0x3b94, 0x05 },
|
|
- { 0x3b95, 0xf2 },
|
|
- { 0x3b96, 0x40 },
|
|
- { 0x3c00, 0x89 },
|
|
- { 0x3c01, 0x63 },
|
|
- { 0x3c02, 0x01 },
|
|
- { 0x3c03, 0x00 },
|
|
- { 0x3c04, 0x00 },
|
|
- { 0x3c05, 0x03 },
|
|
- { 0x3c06, 0x00 },
|
|
- { 0x3c07, 0x06 },
|
|
- { 0x3c0c, 0x01 },
|
|
- { 0x3c0d, 0xd0 },
|
|
- { 0x3c0e, 0x02 },
|
|
- { 0x3c0f, 0x0a },
|
|
- { 0x4001, 0x42 },
|
|
- { 0x4004, 0x04 },
|
|
- { 0x4005, 0x00 },
|
|
- { 0x404e, 0x01 },
|
|
- { 0x4300, 0xff },
|
|
- { 0x4301, 0x00 },
|
|
- { 0x4315, 0x00 },
|
|
- { 0x4501, 0x48 },
|
|
- { 0x4600, 0x00 },
|
|
- { 0x4601, 0x4e },
|
|
- { 0x4801, 0x0f },
|
|
- { 0x4806, 0x0f },
|
|
- { 0x4819, 0xaa },
|
|
- { 0x4823, 0x3e },
|
|
- { 0x4837, 0x19 },
|
|
- { 0x4a0d, 0x00 },
|
|
- { 0x4a47, 0x7f },
|
|
- { 0x4a49, 0xf0 },
|
|
- { 0x4a4b, 0x30 },
|
|
- { 0x5000, 0x85 },
|
|
- { 0x5001, 0x80 },
|
|
-};
|
|
-
|
|
-static const struct reg_value ov7251_setting_vga_60fps[] = {
|
|
- { 0x3005, 0x00 },
|
|
- { 0x3012, 0xc0 },
|
|
- { 0x3013, 0xd2 },
|
|
- { 0x3014, 0x04 },
|
|
- { 0x3016, 0x10 },
|
|
- { 0x3017, 0x00 },
|
|
- { 0x3018, 0x00 },
|
|
- { 0x301a, 0x00 },
|
|
- { 0x301b, 0x00 },
|
|
- { 0x301c, 0x00 },
|
|
- { 0x3023, 0x05 },
|
|
- { 0x3037, 0xf0 },
|
|
- { 0x3106, 0xda },
|
|
- { 0x3503, 0x07 },
|
|
- { 0x3509, 0x10 },
|
|
- { 0x3600, 0x1c },
|
|
- { 0x3602, 0x62 },
|
|
- { 0x3620, 0xb7 },
|
|
- { 0x3622, 0x04 },
|
|
- { 0x3626, 0x21 },
|
|
- { 0x3627, 0x30 },
|
|
- { 0x3630, 0x44 },
|
|
- { 0x3631, 0x35 },
|
|
- { 0x3634, 0x60 },
|
|
- { 0x3636, 0x00 },
|
|
- { 0x3662, 0x01 },
|
|
- { 0x3663, 0x70 },
|
|
- { 0x3664, 0x50 },
|
|
- { 0x3666, 0x0a },
|
|
- { 0x3669, 0x1a },
|
|
- { 0x366a, 0x00 },
|
|
- { 0x366b, 0x50 },
|
|
- { 0x3673, 0x01 },
|
|
- { 0x3674, 0xff },
|
|
- { 0x3675, 0x03 },
|
|
- { 0x3705, 0xc1 },
|
|
- { 0x3709, 0x40 },
|
|
- { 0x373c, 0x08 },
|
|
- { 0x3742, 0x00 },
|
|
- { 0x3757, 0xb3 },
|
|
- { 0x3788, 0x00 },
|
|
- { 0x37a8, 0x01 },
|
|
- { 0x37a9, 0xc0 },
|
|
- { 0x3800, 0x00 },
|
|
- { 0x3801, 0x04 },
|
|
- { 0x3802, 0x00 },
|
|
- { 0x3803, 0x04 },
|
|
- { 0x3804, 0x02 },
|
|
- { 0x3805, 0x8b },
|
|
- { 0x3806, 0x01 },
|
|
- { 0x3807, 0xeb },
|
|
- { 0x3808, 0x02 }, /* width high */
|
|
- { 0x3809, 0x80 }, /* width low */
|
|
- { 0x380a, 0x01 }, /* height high */
|
|
- { 0x380b, 0xe0 }, /* height low */
|
|
- { 0x380c, 0x03 }, /* total horiz timing high */
|
|
- { 0x380d, 0xa0 }, /* total horiz timing low */
|
|
- { 0x380e, 0x03 }, /* total vertical timing high */
|
|
- { 0x380f, 0x5c }, /* total vertical timing low */
|
|
- { 0x3810, 0x00 },
|
|
- { 0x3811, 0x04 },
|
|
- { 0x3812, 0x00 },
|
|
- { 0x3813, 0x05 },
|
|
- { 0x3814, 0x11 },
|
|
- { 0x3815, 0x11 },
|
|
- { 0x3820, 0x40 },
|
|
- { 0x3821, 0x00 },
|
|
- { 0x382f, 0x0e },
|
|
- { 0x3832, 0x00 },
|
|
- { 0x3833, 0x05 },
|
|
- { 0x3834, 0x00 },
|
|
- { 0x3835, 0x0c },
|
|
- { 0x3837, 0x00 },
|
|
- { 0x3b80, 0x00 },
|
|
- { 0x3b81, 0xa5 },
|
|
- { 0x3b82, 0x10 },
|
|
- { 0x3b83, 0x00 },
|
|
- { 0x3b84, 0x08 },
|
|
- { 0x3b85, 0x00 },
|
|
- { 0x3b86, 0x01 },
|
|
- { 0x3b87, 0x00 },
|
|
- { 0x3b88, 0x00 },
|
|
- { 0x3b89, 0x00 },
|
|
- { 0x3b8a, 0x00 },
|
|
- { 0x3b8b, 0x05 },
|
|
- { 0x3b8c, 0x00 },
|
|
- { 0x3b8d, 0x00 },
|
|
- { 0x3b8e, 0x00 },
|
|
- { 0x3b8f, 0x1a },
|
|
- { 0x3b94, 0x05 },
|
|
- { 0x3b95, 0xf2 },
|
|
- { 0x3b96, 0x40 },
|
|
- { 0x3c00, 0x89 },
|
|
- { 0x3c01, 0x63 },
|
|
- { 0x3c02, 0x01 },
|
|
- { 0x3c03, 0x00 },
|
|
- { 0x3c04, 0x00 },
|
|
- { 0x3c05, 0x03 },
|
|
- { 0x3c06, 0x00 },
|
|
- { 0x3c07, 0x06 },
|
|
- { 0x3c0c, 0x01 },
|
|
- { 0x3c0d, 0xd0 },
|
|
- { 0x3c0e, 0x02 },
|
|
- { 0x3c0f, 0x0a },
|
|
- { 0x4001, 0x42 },
|
|
- { 0x4004, 0x04 },
|
|
- { 0x4005, 0x00 },
|
|
- { 0x404e, 0x01 },
|
|
- { 0x4300, 0xff },
|
|
- { 0x4301, 0x00 },
|
|
- { 0x4315, 0x00 },
|
|
- { 0x4501, 0x48 },
|
|
- { 0x4600, 0x00 },
|
|
- { 0x4601, 0x4e },
|
|
- { 0x4801, 0x0f },
|
|
- { 0x4806, 0x0f },
|
|
- { 0x4819, 0xaa },
|
|
- { 0x4823, 0x3e },
|
|
- { 0x4837, 0x19 },
|
|
- { 0x4a0d, 0x00 },
|
|
- { 0x4a47, 0x7f },
|
|
- { 0x4a49, 0xf0 },
|
|
- { 0x4a4b, 0x30 },
|
|
- { 0x5000, 0x85 },
|
|
- { 0x5001, 0x80 },
|
|
-};
|
|
-
|
|
-static const struct reg_value ov7251_setting_vga_90fps[] = {
|
|
+static const struct reg_value ov7251_setting_vga[] = {
|
|
{ 0x3005, 0x00 },
|
|
{ 0x3012, 0xc0 },
|
|
{ 0x3013, 0xd2 },
|
|
@@ -518,8 +265,6 @@ static const struct reg_value ov7251_set
|
|
{ 0x380b, 0xe0 }, /* height low */
|
|
{ 0x380c, 0x03 }, /* total horiz timing high */
|
|
{ 0x380d, 0xa0 }, /* total horiz timing low */
|
|
- { 0x380e, 0x02 }, /* total vertical timing high */
|
|
- { 0x380f, 0x3c }, /* total vertical timing low */
|
|
{ 0x3810, 0x00 },
|
|
{ 0x3811, 0x04 },
|
|
{ 0x3812, 0x00 },
|
|
@@ -601,10 +346,11 @@ static const struct ov7251_mode_info ov7
|
|
{
|
|
.width = 640,
|
|
.height = 480,
|
|
- .data = ov7251_setting_vga_30fps,
|
|
- .data_size = ARRAY_SIZE(ov7251_setting_vga_30fps),
|
|
+ .data = ov7251_setting_vga,
|
|
+ .data_size = ARRAY_SIZE(ov7251_setting_vga),
|
|
.exposure_max = 1704,
|
|
.exposure_def = 504,
|
|
+ .vts = 0x6bc,
|
|
.timeperframe = {
|
|
.numerator = 100,
|
|
.denominator = 3000
|
|
@@ -613,10 +359,11 @@ static const struct ov7251_mode_info ov7
|
|
{
|
|
.width = 640,
|
|
.height = 480,
|
|
- .data = ov7251_setting_vga_60fps,
|
|
- .data_size = ARRAY_SIZE(ov7251_setting_vga_60fps),
|
|
+ .data = ov7251_setting_vga,
|
|
+ .data_size = ARRAY_SIZE(ov7251_setting_vga),
|
|
.exposure_max = 840,
|
|
.exposure_def = 504,
|
|
+ .vts = 0x35c,
|
|
.timeperframe = {
|
|
.numerator = 100,
|
|
.denominator = 6014
|
|
@@ -625,10 +372,11 @@ static const struct ov7251_mode_info ov7
|
|
{
|
|
.width = 640,
|
|
.height = 480,
|
|
- .data = ov7251_setting_vga_90fps,
|
|
- .data_size = ARRAY_SIZE(ov7251_setting_vga_90fps),
|
|
+ .data = ov7251_setting_vga,
|
|
+ .data_size = ARRAY_SIZE(ov7251_setting_vga),
|
|
.exposure_max = 552,
|
|
.exposure_def = 504,
|
|
+ .vts = 0x23c,
|
|
.timeperframe = {
|
|
.numerator = 100,
|
|
.denominator = 9043
|
|
@@ -1289,6 +1037,14 @@ static int ov7251_s_stream(struct v4l2_s
|
|
ov7251->current_mode->height);
|
|
goto err_power_down;
|
|
}
|
|
+ ret = ov7251_write_reg(ov7251, OV7251_VTS_HIGH,
|
|
+ ov7251->current_mode->vts >> 8);
|
|
+ if (ret)
|
|
+ goto err_power_down;
|
|
+ ret = ov7251_write_reg(ov7251, OV7251_VTS_LOW,
|
|
+ ov7251->current_mode->vts & 0xff);
|
|
+ if (ret)
|
|
+ goto err_power_down;
|
|
ret = __v4l2_ctrl_handler_setup(&ov7251->ctrls);
|
|
if (ret < 0) {
|
|
dev_err(ov7251->dev, "could not sync v4l2 controls\n");
|