@@ -33,7 +33,10 @@ LOG_MODULE_REGISTER(video_gc2145, CONFIG_VIDEO_LOG_LEVEL);
33
33
#define GC2145_REG_SYNC_MODE_ROW_SWITCH 0x20
34
34
#define GC2145_REG_RESET 0xFE
35
35
#define GC2145_REG_SW_RESET 0x80
36
- #define GC2145_SET_P0_REGS 0x00
36
+ #define GC2145_REG_RESET_P0_REGS 0x00
37
+ #define GC2145_REG_RESET_P1_REGS 0x01
38
+ #define GC2145_REG_RESET_P2_REGS 0x02
39
+ #define GC2145_REG_RESET_P3_REGS 0x03
37
40
#define GC2145_REG_CROP_ENABLE 0x90
38
41
#define GC2145_CROP_SET_ENABLE 0x01
39
42
#define GC2145_REG_BLANK_WINDOW_BASE 0x09
@@ -99,9 +102,9 @@ struct gc2145_reg {
99
102
};
100
103
101
104
static const struct gc2145_reg default_regs [] = {
102
- {0xfe , 0xf0 },
103
- {0xfe , 0xf0 },
104
- {0xfe , 0xf0 },
105
+ {GC2145_REG_RESET , 0xf0 },
106
+ {GC2145_REG_RESET , 0xf0 },
107
+ {GC2145_REG_RESET , 0xf0 },
105
108
{0xfc , 0x06 },
106
109
{0xf6 , 0x00 },
107
110
{0xf7 , 0x1d },
@@ -111,7 +114,7 @@ static const struct gc2145_reg default_regs[] = {
111
114
{0xf2 , 0x00 },
112
115
113
116
/* ISP settings */
114
- {0xfe , 0x00 },
117
+ {GC2145_REG_RESET , GC2145_REG_RESET_P0_REGS },
115
118
{0x03 , 0x04 },
116
119
{0x04 , 0xe2 },
117
120
@@ -196,7 +199,7 @@ static const struct gc2145_reg default_regs[] = {
196
199
{0xa2 , 0x00 },
197
200
198
201
/* BLK Settings */
199
- {0xfe , 0x00 },
202
+ {GC2145_REG_RESET , GC2145_REG_RESET_P0_REGS },
200
203
{0x40 , 0x42 },
201
204
{0x41 , 0x00 },
202
205
{0x43 , 0x5b },
@@ -225,14 +228,14 @@ static const struct gc2145_reg default_regs[] = {
225
228
{0x72 , 0xf0 },
226
229
{0x7e , 0x3c },
227
230
{0x7f , 0x00 },
228
- {0xfe , 0x02 },
231
+ {GC2145_REG_RESET , GC2145_REG_RESET_P2_REGS },
229
232
{0x48 , 0x15 },
230
233
{0x49 , 0x00 },
231
234
{0x4b , 0x0b },
232
- {0xfe , 0x00 },
235
+ {GC2145_REG_RESET , GC2145_REG_RESET_P0_REGS },
233
236
234
237
/* AEC Settings */
235
- {0xfe , 0x01 },
238
+ {GC2145_REG_RESET , GC2145_REG_RESET_P1_REGS },
236
239
{0x01 , 0x04 },
237
240
{0x02 , 0xc0 },
238
241
{0x03 , 0x04 },
@@ -254,26 +257,26 @@ static const struct gc2145_reg default_regs[] = {
254
257
{0x20 , 0x40 },
255
258
{0x22 , 0x40 },
256
259
{0x23 , 0x20 },
257
- {0xfe , 0x02 },
260
+ {GC2145_REG_RESET , GC2145_REG_RESET_P2_REGS },
258
261
{0x0f , 0x04 },
259
- {0xfe , 0x01 },
262
+ {GC2145_REG_RESET , GC2145_REG_RESET_P1_REGS },
260
263
{0x12 , 0x30 },
261
264
{0x15 , 0xb0 },
262
265
{0x10 , 0x31 },
263
266
{0x3e , 0x28 },
264
267
{0x3f , 0xb0 },
265
268
{0x40 , 0x90 },
266
269
{0x41 , 0x0f },
267
- {0xfe , 0x02 },
270
+ {GC2145_REG_RESET , GC2145_REG_RESET_P2_REGS },
268
271
{0x90 , 0x6c },
269
272
{0x91 , 0x03 },
270
273
{0x92 , 0xcb },
271
274
{0x94 , 0x33 },
272
275
{0x95 , 0x84 },
273
276
{0x97 , 0x65 },
274
277
{0xa2 , 0x11 },
275
- {0xfe , 0x00 },
276
- {0xfe , 0x02 },
278
+ {GC2145_REG_RESET , GC2145_REG_RESET_P0_REGS },
279
+ {GC2145_REG_RESET , GC2145_REG_RESET_P2_REGS },
277
280
{0x80 , 0xc1 },
278
281
{0x81 , 0x08 },
279
282
{0x82 , 0x05 },
@@ -285,9 +288,9 @@ static const struct gc2145_reg default_regs[] = {
285
288
{0x89 , 0xb0 },
286
289
{0x8a , 0x30 },
287
290
{0x8b , 0x10 },
288
- {0xfe , 0x01 },
291
+ {GC2145_REG_RESET , GC2145_REG_RESET_P1_REGS },
289
292
{0x21 , 0x04 },
290
- {0xfe , 0x02 },
293
+ {GC2145_REG_RESET , GC2145_REG_RESET_P2_REGS },
291
294
{0xa3 , 0x50 },
292
295
{0xa4 , 0x20 },
293
296
{0xa5 , 0x40 },
@@ -303,10 +306,10 @@ static const struct gc2145_reg default_regs[] = {
303
306
{0x3d , 0x15 },
304
307
{0x4b , 0x06 },
305
308
{0x4c , 0x20 },
306
- {0xfe , 0x00 },
309
+ {GC2145_REG_RESET , GC2145_REG_RESET_P0_REGS },
307
310
308
311
/* Gamma Control */
309
- {0xfe , 0x02 },
312
+ {GC2145_REG_RESET , GC2145_REG_RESET_P2_REGS },
310
313
{0x10 , 0x09 },
311
314
{0x11 , 0x0d },
312
315
{0x12 , 0x13 },
@@ -329,10 +332,10 @@ static const struct gc2145_reg default_regs[] = {
329
332
{0x23 , 0xf5 },
330
333
{0x24 , 0xf9 },
331
334
{0x25 , 0xff },
332
- {0xfe , 0x00 },
335
+ {GC2145_REG_RESET , GC2145_REG_RESET_P0_REGS },
333
336
{0xc6 , 0x20 },
334
337
{0xc7 , 0x2b },
335
- {0xfe , 0x02 },
338
+ {GC2145_REG_RESET , GC2145_REG_RESET_P2_REGS },
336
339
{0x26 , 0x0f },
337
340
{0x27 , 0x14 },
338
341
{0x28 , 0x19 },
@@ -355,7 +358,7 @@ static const struct gc2145_reg default_regs[] = {
355
358
{0x39 , 0xf3 },
356
359
{0x3a , 0xf9 },
357
360
{0x3b , 0xff },
358
- {0xfe , 0x02 },
361
+ {GC2145_REG_RESET , GC2145_REG_RESET_P2_REGS },
359
362
{0xd1 , 0x32 },
360
363
{0xd2 , 0x32 },
361
364
{0xd3 , 0x40 },
@@ -368,9 +371,9 @@ static const struct gc2145_reg default_regs[] = {
368
371
{0xee , 0x00 },
369
372
{0xef , 0x3f },
370
373
{0xd8 , 0xd8 },
371
- {0xfe , 0x01 },
374
+ {GC2145_REG_RESET , GC2145_REG_RESET_P1_REGS },
372
375
{0x9f , 0x40 },
373
- {0xfe , 0x01 },
376
+ {GC2145_REG_RESET , GC2145_REG_RESET_P1_REGS },
374
377
{0xc2 , 0x14 },
375
378
{0xc3 , 0x0d },
376
379
{0xc4 , 0x0c },
@@ -428,7 +431,7 @@ static const struct gc2145_reg default_regs[] = {
428
431
{0xa1 , 0x80 },
429
432
{0xa2 , 0x80 },
430
433
431
- {0xfe , 0x01 },
434
+ {GC2145_REG_RESET , GC2145_REG_RESET_P1_REGS },
432
435
{0xdf , 0x0d },
433
436
{0xdc , 0x25 },
434
437
{0xdd , 0x30 },
@@ -440,8 +443,8 @@ static const struct gc2145_reg default_regs[] = {
440
443
{0xe7 , 0xa0 },
441
444
{0xe8 , 0x90 },
442
445
{0xe9 , 0xa0 },
443
- {0xfe , 0x00 },
444
- {0xfe , 0x01 },
446
+ {GC2145_REG_RESET , GC2145_REG_RESET_P0_REGS },
447
+ {GC2145_REG_RESET , GC2145_REG_RESET_P1_REGS },
445
448
{0x4f , 0x00 },
446
449
{0x4f , 0x00 },
447
450
{0x4b , 0x01 },
@@ -681,8 +684,8 @@ static const struct gc2145_reg default_regs[] = {
681
684
{0x79 , 0x5e },
682
685
{0x7a , 0x54 },
683
686
{0x7b , 0x58 },
684
- {0xfe , 0x00 },
685
- {0xfe , 0x02 },
687
+ {GC2145_REG_RESET , GC2145_REG_RESET_P0_REGS },
688
+ {GC2145_REG_RESET , GC2145_REG_RESET_P2_REGS },
686
689
{0xc0 , 0x01 },
687
690
{0xc1 , 0x44 },
688
691
{0xc2 , 0xfd },
@@ -702,17 +705,17 @@ static const struct gc2145_reg default_regs[] = {
702
705
{0xe3 , 0x0c },
703
706
{0xe4 , 0x4b },
704
707
{0xe5 , 0xe0 },
705
- {0xfe , 0x01 },
708
+ {GC2145_REG_RESET , GC2145_REG_RESET_P1_REGS },
706
709
{0x9f , 0x40 },
707
- {0xfe , 0x00 },
710
+ {GC2145_REG_RESET , GC2145_REG_RESET_P0_REGS },
708
711
709
712
/* Output Control */
710
- {0xfe , 0x02 },
713
+ {GC2145_REG_RESET , GC2145_REG_RESET_P2_REGS },
711
714
{0x40 , 0xbf },
712
715
{0x46 , 0xcf },
713
- {0xfe , 0x00 },
716
+ {GC2145_REG_RESET , GC2145_REG_RESET_P0_REGS },
714
717
715
- {0xfe , 0x00 },
718
+ {GC2145_REG_RESET , GC2145_REG_RESET_P0_REGS },
716
719
{0x05 , 0x01 },
717
720
{0x06 , 0x1C },
718
721
{0x07 , 0x00 },
@@ -722,16 +725,16 @@ static const struct gc2145_reg default_regs[] = {
722
725
{0x13 , 0x00 },
723
726
{0x14 , 0x00 },
724
727
725
- {0xfe , 0x01 },
728
+ {GC2145_REG_RESET , GC2145_REG_RESET_P1_REGS },
726
729
{0x3c , 0x00 },
727
730
{0x3d , 0x04 },
728
- {0xfe , 0x00 },
731
+ {GC2145_REG_RESET , GC2145_REG_RESET_P0_REGS },
729
732
{0x00 , 0x00 },
730
733
};
731
734
732
735
static const struct gc2145_reg default_mipi_csi_regs [] = {
733
736
/* Switch to page 3 */
734
- {0xfe , 0x03 },
737
+ {GC2145_REG_RESET , GC2145_REG_RESET_P3_REGS },
735
738
{GC2145_REG_DPHY_MODE1 , GC2145_DPHY_MODE1_CLK_EN |
736
739
GC2145_DPHY_MODE1_LANE0_EN | GC2145_DPHY_MODE1_LANE1_EN |
737
740
GC2145_DPHY_MODE1_CLK_LANE_P2S_SEL },
@@ -918,7 +921,7 @@ static int gc2145_set_window(const struct device *dev, uint16_t reg, uint16_t x,
918
921
int ret ;
919
922
const struct gc2145_config * cfg = dev -> config ;
920
923
921
- ret = gc2145_write_reg (& cfg -> i2c , GC2145_REG_RESET , GC2145_SET_P0_REGS );
924
+ ret = gc2145_write_reg (& cfg -> i2c , GC2145_REG_RESET , GC2145_REG_RESET_P0_REGS );
922
925
if (ret < 0 ) {
923
926
return ret ;
924
927
}
@@ -976,7 +979,7 @@ static int gc2145_set_output_format(const struct device *dev, int output_format)
976
979
uint8_t old_value ;
977
980
const struct gc2145_config * cfg = dev -> config ;
978
981
979
- ret = gc2145_write_reg (& cfg -> i2c , GC2145_REG_RESET , GC2145_SET_P0_REGS );
982
+ ret = gc2145_write_reg (& cfg -> i2c , GC2145_REG_RESET , GC2145_REG_RESET_P0_REGS );
980
983
if (ret < 0 ) {
981
984
return ret ;
982
985
}
@@ -1190,7 +1193,7 @@ static int gc2145_config_csi(const struct device *dev, uint32_t pixelformat,
1190
1193
return ret ;
1191
1194
}
1192
1195
1193
- return gc2145_write_reg (& cfg -> i2c , 0xfe , 0x0 );
1196
+ return gc2145_write_reg (& cfg -> i2c , GC2145_REG_RESET , GC2145_REG_RESET_P0_REGS );
1194
1197
}
1195
1198
1196
1199
static int gc2145_set_fmt (const struct device * dev , struct video_format * fmt )
@@ -1268,7 +1271,7 @@ static int gc2145_set_stream_csi(const struct device *dev, bool enable)
1268
1271
const struct gc2145_config * cfg = dev -> config ;
1269
1272
int ret ;
1270
1273
1271
- ret = gc2145_write_reg (& cfg -> i2c , 0xfe , 0x03 );
1274
+ ret = gc2145_write_reg (& cfg -> i2c , GC2145_REG_RESET , GC2145_REG_RESET_P3_REGS );
1272
1275
if (ret < 0 ) {
1273
1276
return ret ;
1274
1277
}
@@ -1281,7 +1284,7 @@ static int gc2145_set_stream_csi(const struct device *dev, bool enable)
1281
1284
return ret ;
1282
1285
}
1283
1286
1284
- return gc2145_write_reg (& cfg -> i2c , 0xfe , 0x0 );
1287
+ return gc2145_write_reg (& cfg -> i2c , GC2145_REG_RESET , GC2145_REG_RESET_P0_REGS );
1285
1288
}
1286
1289
1287
1290
static int gc2145_set_stream (const struct device * dev , bool enable , enum video_buf_type type )
0 commit comments