1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
|
From dd40e2ef1f8e6cded376b928451740a828e5e6ef Mon Sep 17 00:00:00 2001
From: Dave Stevenson <dave.stevenson@raspberrypi.com>
Date: Sun, 22 Nov 2020 11:01:08 +0000
Subject: [PATCH] media: ov9281: Add 1280x720 and 640x480 modes
Breaks out common register set and adds the different registers
for 1280x720 (cropped) and 640x480 (skipped) modes
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
---
drivers/media/i2c/ov9281.c | 146 ++++++++++++++++++++++++++++++++-----
1 file changed, 126 insertions(+), 20 deletions(-)
--- a/drivers/media/i2c/ov9281.c
+++ b/drivers/media/i2c/ov9281.c
@@ -139,7 +139,7 @@ struct ov9281 {
* max_framerate 120fps for 10 bit, 144fps for 8 bit.
* mipi_datarate per lane 800Mbps
*/
-static const struct regval ov9281_1280x800_regs[] = {
+static const struct regval ov9281_common_regs[] = {
{0x0103, 0x01},
{0x0302, 0x32},
{0x030e, 0x02},
@@ -177,13 +177,35 @@ static const struct regval ov9281_1280x8
{0x372d, 0x22},
{0x3731, 0x80},
{0x3732, 0x30},
- {0x3778, 0x00},
{0x377d, 0x22},
{0x3788, 0x02},
{0x3789, 0xa4},
{0x378a, 0x00},
{0x378b, 0x4a},
{0x3799, 0x20},
+ {0x3881, 0x42},
+ {0x38b1, 0x00},
+ {0x3920, 0xff},
+ {0x4010, 0x40},
+ {0x4043, 0x40},
+ {0x4307, 0x30},
+ {0x4317, 0x00},
+ {0x4501, 0x00},
+ {0x450a, 0x08},
+ {0x4601, 0x04},
+ {0x470f, 0x00},
+ {0x4f07, 0x00},
+ {0x4800, 0x00},
+ {0x5000, 0x9f},
+ {0x5001, 0x00},
+ {0x5e00, 0x00},
+ {0x5d00, 0x07},
+ {0x5d01, 0x00},
+ {REG_NULL, 0x00},
+};
+
+static const struct regval ov9281_1280x800_regs[] = {
+ {0x3778, 0x10},
{0x3800, 0x00},
{0x3801, 0x00},
{0x3802, 0x00},
@@ -208,31 +230,83 @@ static const struct regval ov9281_1280x8
{0x3815, 0x11},
{0x3820, 0x40},
{0x3821, 0x00},
- {0x3881, 0x42},
- {0x38b1, 0x00},
- {0x3920, 0xff},
{0x4003, 0x40},
{0x4008, 0x04},
{0x4009, 0x0b},
{0x400c, 0x00},
{0x400d, 0x07},
- {0x4010, 0x40},
- {0x4043, 0x40},
- {0x4307, 0x30},
- {0x4317, 0x00},
- {0x4501, 0x00},
{0x4507, 0x00},
{0x4509, 0x00},
- {0x450a, 0x08},
- {0x4601, 0x04},
- {0x470f, 0x00},
- {0x4f07, 0x00},
- {0x4800, 0x00},
- {0x5000, 0x9f},
- {0x5001, 0x00},
- {0x5e00, 0x00},
- {0x5d00, 0x07},
- {0x5d01, 0x00},
+ {REG_NULL, 0x00},
+};
+
+static const struct regval ov9281_1280x720_regs[] = {
+ {0x3778, 0x10},
+ {0x3800, 0x00},
+ {0x3801, 0x00},
+ {0x3802, 0x00},
+ {0x3803, 0x28},
+ {0x3804, 0x05},
+ {0x3805, 0x0f},
+ {0x3806, 0x03},
+ {0x3807, 0x07},
+ {0x3808, 0x05},
+ {0x3809, 0x00},
+ {0x380a, 0x02},
+ {0x380b, 0xd0},
+ {0x380c, 0x02},
+ {0x380d, 0xd8},
+ {0x380e, 0x03},
+ {0x380f, 0x8e},
+ {0x3810, 0x00},
+ {0x3811, 0x08},
+ {0x3812, 0x00},
+ {0x3813, 0x08},
+ {0x3814, 0x11},
+ {0x3815, 0x11},
+ {0x3820, 0x40},
+ {0x3821, 0x00},
+ {0x4003, 0x40},
+ {0x4008, 0x04},
+ {0x4009, 0x0b},
+ {0x400c, 0x00},
+ {0x400d, 0x07},
+ {0x4507, 0x00},
+ {0x4509, 0x00},
+ {REG_NULL, 0x00},
+};
+
+static const struct regval ov9281_640x400_regs[] = {
+ {0x3800, 0x00},
+ {0x3801, 0x00},
+ {0x3802, 0x00},
+ {0x3803, 0x00},
+ {0x3804, 0x05},
+ {0x3805, 0x0f},
+ {0x3806, 0x03},
+ {0x3807, 0x2f},
+ {0x3808, 0x02},
+ {0x3809, 0x80},
+ {0x380a, 0x01},
+ {0x380b, 0x90},
+ {0x380c, 0x02},
+ {0x380d, 0xd8},
+ {0x380e, 0x02},
+ {0x380f, 0x08},
+ {0x3810, 0x00},
+ {0x3811, 0x04},
+ {0x3812, 0x00},
+ {0x3813, 0x04},
+ {0x3814, 0x31},
+ {0x3815, 0x22},
+ {0x3820, 0x60},
+ {0x3821, 0x01},
+ {0x4008, 0x02},
+ {0x4009, 0x05},
+ {0x400c, 0x00},
+ {0x400d, 0x03},
+ {0x4507, 0x03},
+ {0x4509, 0x80},
{REG_NULL, 0x00},
};
@@ -263,6 +337,34 @@ static const struct ov9281_mode supporte
},
.reg_list = ov9281_1280x800_regs,
},
+ {
+ .width = 1280,
+ .height = 720,
+ .exp_def = 0x0320,
+ .hts_def = 0x05b0,
+ .vts_def = 761,
+ .crop = {
+ .left = 0,
+ .top = 40,
+ .width = 1280,
+ .height = 720
+ },
+ .reg_list = ov9281_1280x720_regs,
+ },
+ {
+ .width = 640,
+ .height = 400,
+ .exp_def = 0x0320,
+ .hts_def = 0x05b0,
+ .vts_def = 421,
+ .crop = {
+ .left = 0,
+ .top = 0,
+ .width = 1280,
+ .height = 800
+ },
+ .reg_list = ov9281_640x400_regs,
+ },
};
static const s64 link_freq_menu_items[] = {
@@ -567,6 +669,10 @@ static int __ov9281_start_stream(struct
{
int ret;
+ ret = ov9281_write_array(ov9281->client, ov9281_common_regs);
+ if (ret)
+ return ret;
+
ret = ov9281_write_array(ov9281->client, ov9281->cur_mode->reg_list);
if (ret)
return ret;
|