armbian-build/patch/kernel/sunxi-dev/general-ov5640-support-5M-2542x1944-resolution.patch
Igor Pečovnik a57ce78b37
Reverting sunxi/sunxi64 NEXT to 4.14. (#1087)
* Bump to 4.18, removing the obvious, fixing build problems, put some on waiting.

* Pin 4.18 to DEV, rollback 4.14 to NEXT, adjust configs, remove one deprecated patch from NEXT and add board-h3-address-some-stability-issues.patch

* Adjust few boards in development to new reality, removing it from NEXT for now

* Adjust few board configs

* Board config adjustement

* Adjust few boards configs

* Port NeoCore2 and Neo21.1 to 4.14.y

* Adjust board config

* Adjust board config
2018-08-21 10:41:10 +02:00

212 lines
6.8 KiB
Diff

From 05a8864b512a6555c92e693a0cfaf4af177105f4 Mon Sep 17 00:00:00 2001
From: wuweidong <625769020@qq.com>
Date: Mon, 26 Mar 2018 18:57:58 +0800
Subject: [PATCH 45/60] media: ov5640: Support 5M(2542x1944) resolution
---
drivers/media/i2c/ov5640.c | 153 +++++++++++++++++++++++++++++++++++++
1 file changed, 153 insertions(+)
diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c
index e2dd352224c7..aa204e50c045 100644
--- a/drivers/media/i2c/ov5640.c
+++ b/drivers/media/i2c/ov5640.c
@@ -105,6 +105,8 @@ enum ov5640_mode_id {
enum ov5640_frame_rate {
OV5640_15_FPS = 0,
OV5640_30_FPS,
+ OV5640_7P5_FPS,
+ OV5640_5_FPS,
OV5640_NUM_FRAMERATES,
};
@@ -132,6 +134,8 @@ MODULE_PARM_DESC(virtual_channel,
static const int ov5640_framerates[] = {
[OV5640_15_FPS] = 15,
[OV5640_30_FPS] = 30,
+ [OV5640_7P5_FPS] = 7,
+ [OV5640_5_FPS] = 5,
};
/* regulator supplies */
@@ -703,6 +707,42 @@ static const struct reg_value ov5640_setting_15fps_1080P_1920_1080[] = {
{0x4005, 0x1a, 0, 0}, {0x3008, 0x02, 0, 0}, {0x3503, 0, 0, 0},
};
+static const struct reg_value ov5640_setting_7p5_fps_1080P_1920_1080[] = {
+ {0x3008, 0x42, 0, 0},
+ {0x3035, 0x21, 0, 0}, {0x3036, 0x54, 0, 0}, {0x3c07, 0x08, 0, 0},
+ {0x3c09, 0x1c, 0, 0}, {0x3c0a, 0x9c, 0, 0}, {0x3c0b, 0x40, 0, 0},
+ {0x3820, 0x40, 0, 0}, {0x3821, 0x06, 0, 0}, {0x3814, 0x11, 0, 0},
+ {0x3815, 0x11, 0, 0}, {0x3800, 0x00, 0, 0}, {0x3801, 0x00, 0, 0},
+ {0x3802, 0x00, 0, 0}, {0x3803, 0x00, 0, 0}, {0x3804, 0x0a, 0, 0},
+ {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, {0x3807, 0x9f, 0, 0},
+ {0x3808, 0x0a, 0, 0}, {0x3809, 0x20, 0, 0}, {0x380a, 0x07, 0, 0},
+ {0x380b, 0x98, 0, 0}, {0x380c, 0x0b, 0, 0}, {0x380d, 0x1c, 0, 0},
+ {0x380e, 0x07, 0, 0}, {0x380f, 0xb0, 0, 0}, {0x3810, 0x00, 0, 0},
+ {0x3811, 0x10, 0, 0}, {0x3812, 0x00, 0, 0}, {0x3813, 0x04, 0, 0},
+ {0x3618, 0x04, 0, 0}, {0x3612, 0x29, 0, 0}, {0x3708, 0x21, 0, 0},
+ {0x3709, 0x12, 0, 0}, {0x370c, 0x00, 0, 0}, {0x3a02, 0x03, 0, 0},
+ {0x3a03, 0xd8, 0, 0}, {0x3a08, 0x01, 0, 0}, {0x3a09, 0x27, 0, 0},
+ {0x3a0a, 0x00, 0, 0}, {0x3a0b, 0xf6, 0, 0}, {0x3a0e, 0x03, 0, 0},
+ {0x3a0d, 0x04, 0, 0}, {0x3a14, 0x03, 0, 0}, {0x3a15, 0xd8, 0, 0},
+ {0x4001, 0x02, 0, 0}, {0x4004, 0x06, 0, 0}, {0x4713, 0x03, 0, 0},
+ {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, {0x460c, 0x22, 0, 0},
+ {0x3824, 0x02, 0, 0}, {0x5001, 0x83, 0, 0}, {0x3035, 0x41, 0, 0},
+ {0x3036, 0x54, 0, 1}, {0x3c07, 0x07, 0, 0}, {0x3c08, 0x00, 0, 0},
+ {0x3c09, 0x1c, 0, 0}, {0x3c0a, 0x9c, 0, 0}, {0x3c0b, 0x40, 0, 0},
+ {0x3800, 0x01, 0, 0}, {0x3801, 0x50, 0, 0}, {0x3802, 0x01, 0, 0},
+ {0x3803, 0xb2, 0, 0}, {0x3804, 0x08, 0, 0}, {0x3805, 0xef, 0, 0},
+ {0x3806, 0x05, 0, 0}, {0x3807, 0xf1, 0, 0}, {0x3808, 0x07, 0, 0},
+ {0x3809, 0x80, 0, 0}, {0x380a, 0x04, 0, 0}, {0x380b, 0x38, 0, 0},
+ {0x380c, 0x09, 0, 0}, {0x380d, 0xc4, 0, 0}, {0x380e, 0x04, 0, 0},
+ {0x380f, 0x60, 0, 0}, {0x3612, 0x2b, 0, 0}, {0x3708, 0x64, 0, 0},
+ {0x3a02, 0x04, 0, 0}, {0x3a03, 0x60, 0, 0}, {0x3a08, 0x01, 0, 0},
+ {0x3a09, 0x50, 0, 0}, {0x3a0a, 0x01, 0, 0}, {0x3a0b, 0x18, 0, 0},
+ {0x3a0e, 0x03, 0, 0}, {0x3a0d, 0x04, 0, 0}, {0x3a14, 0x04, 0, 0},
+ {0x3a15, 0x60, 0, 0}, {0x4713, 0x02, 0, 0}, {0x4407, 0x04, 0, 0},
+ {0x460b, 0x37, 0, 0}, {0x460c, 0x20, 0, 0}, {0x3824, 0x04, 0, 0},
+ {0x4005, 0x1a, 0, 0}, {0x3008, 0x02, 0, 0}, {0x3503, 0, 0, 0},
+};
+
static const struct reg_value ov5640_setting_15fps_QSXGA_2592_1944[] = {
{0x3820, 0x40, 0, 0}, {0x3821, 0x06, 0, 0},
{0x3035, 0x21, 0, 0}, {0x3036, 0x54, 0, 0}, {0x3c07, 0x08, 0, 0},
@@ -725,6 +765,103 @@ static const struct reg_value ov5640_setting_15fps_QSXGA_2592_1944[] = {
{0x3824, 0x02, 0, 0}, {0x5001, 0x83, 0, 70},
};
+static const struct reg_value ov5640_setting_5_fps_QSXGA_2592_1944[] = {
+ // YUV 2592x1944 5fps
+ // Input Clock = 24Mhz, PCLK = 56MHz
+ {0x3035, 0x21, 0, 0},
+ // PLL
+ {0x3036, 0x46, 0, 0},
+ // PLL
+ {0x3c07, 0x07, 0, 0},
+ // lightm eter 1 threshold[7:0]
+ {0x3820, 0x40, 0, 0},
+ // flip
+ {0x3821, 0x06, 0, 0},
+ // mirror
+ {0x3814, 0x11, 0, 0},
+ // timing X inc
+ {0x3815, 0x11, 0, 0},
+ // timing Y inc
+ {0x3800, 0x00, 0, 0},
+ // HS
+ {0x3801, 0x00, 0, 0},
+ // HS
+ {0x3802, 0x00, 0, 0},
+ // VS
+ {0x3803, 0x00, 0, 0},
+ // VS
+ {0x3804, 0x0a, 0, 0},
+ // HW {HE)
+ {0x3805, 0x3f, 0, 0},
+ // HW {HE)
+ {0x3806, 0x07, 0, 0},
+ // VH {VE)
+ {0x3807, 0x9f, 0, 0},
+ // VH {VE)
+ {0x3808, 0x0a, 0, 0},
+ // DVPHO
+ {0x3809, 0x20, 0, 0},
+ // DVPHO
+ {0x380a, 0x07, 0, 0},
+ // DVPVO
+ {0x380b, 0x98, 0, 0},
+ // DVPVO
+ {0x380c, 0x0b, 0, 0},
+ // HTS
+ {0x380d, 0x1c, 0, 0},
+ // HTS
+ {0x380e, 0x07, 0, 0},
+ // VTS
+ {0x380f, 0xb0, 0, 0},
+ // VTS
+ {0x3813, 0x04, 0, 0},
+ // timing V offset
+ {0x3618, 0x04, 0, 0},
+ {0x3612, 0x2b, 0, 0},
+ {0x3709, 0x12, 0, 0},
+ {0x370c, 0x00, 0, 0},
+ // banding filters are calculated automatically in camera driver
+ //{0x3a02, 0x07, 0, 0},
+ // 60Hz max exposure
+ //{0x3a03, 0xae, 0, 0},
+ // 60Hz max exposure
+ //{0x3a08, 0x01, 0, 0},
+ // B50 step
+ //{0x3a09, 0x27, 0, 0},
+ // B50 step
+ //{0x3a0a, 0x00, 0, 0},
+ // B60 step
+ //{0x3a0b, 0xf6, 0, 0},
+ // B60 step
+ //{0x3a0e, 0x06, 0, 0},
+ // 50Hz max band
+ //{0x3a0d, 0x08, 0, 0},
+ // 60Hz max band
+ //{0x3a14, 0x07, 0, 0},
+ // 50Hz max exposure
+ //{0x3a15, 0xae, 0, 0},
+ // 50Hz max exposure
+ {0x4004, 0x06, 0, 0},
+ // BLC line number
+ {0x3002, 0x1c, 0, 0},
+ // reset JFIFO, SFIFO, JPG
+ {0x3006, 0xc3, 0, 0},
+ // disable clock of JPEG2x, JPEG
+ {0x4713, 0x02, 0, 0},
+ // JPEG mode 3
+ {0x4407, 0x0c, 0, 0},
+ // Quantization sacle
+ {0x460b, 0x37, 0, 0},
+ {0x460c, 0x20, 0, 0},
+ {0x4837, 0x2c, 0, 0},
+ // MIPI global timing
+ {0x3824, 0x01, 0, 0},
+ // PCLK manual divider
+ {0x5001, 0x83, 0, 0},
+ // SDE on, CMX on, AWB on
+ {0x3503, 0x03, 0, 0},
+};
+
/* power-on sensor init reg table */
static const struct ov5640_mode_info ov5640_mode_init_data = {
0, SUBSAMPLING, 640, 480, ov5640_init_setting_30fps_VGA,
@@ -909,6 +909,14 @@ ov5640_mode_data[OV5640_NUM_FRAMERATES][OV5640_NUM_MODES] = {
ov5640_setting_30fps_1080P_1920_1080,
ARRAY_SIZE(ov5640_setting_30fps_1080P_1920_1080)},
{OV5640_MODE_QSXGA_2592_1944, -1, 0, 0, 0, 0, NULL, 0},
+ }, {
+ {OV5640_MODE_1080P_1920_1080, SCALING, 1920, 1080,
+ ov5640_setting_7p5_fps_1080P_1920_1080,
+ ARRAY_SIZE(ov5640_setting_7p5_fps_1080P_1920_1080)}
+ }, {
+ {OV5640_MODE_1080P_1920_1080, SCALING, 2592, 1944,
+ ov5640_setting_5_fps_QSXGA_2592_1944,
+ ARRAY_SIZE(ov5640_setting_5_fps_QSXGA_2592_1944)}
},
};
@@ -1376,6 +1521,14 @@ ov5640_find_mode(struct ov5640_dev *sensor, enum ov5640_frame_rate fr,
const struct ov5640_mode_info *mode = NULL;
int i;
+ printk("%s fps=%d width=%d height=%d nearest=%d\n", __func__, fr, width, height, nearest);
+
+ if (width >= 2592 && height >= 1944)
+ fr = OV5640_5_FPS;
+ else if (width >= 1920 && height >= 1080)
+ fr = OV5640_7P5_FPS;
+ else
+ fr = OV5640_30_FPS;
for (i = OV5640_NUM_MODES - 1; i >= 0; i--) {
mode = &ov5640_mode_data[fr][i];
--
2.17.1