hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/drivers/media/i2c/gc2093.c
....@@ -11,8 +11,6 @@
1111 * 2. add hdr mode exposure limit issue.
1212 * 3. fix hdr mode highlighting pink issue.
1313 * 4. add some debug info.
14
- * V0.0X01.0X03 fix hdr mode not support vts change
15
- * V0.0X01.0X04 add 24M MCLK register setting.
1614 */
1715 //#define DEBUG
1816 #include <linux/clk.h>
....@@ -34,22 +32,16 @@
3432 #include <media/v4l2-device.h>
3533 #include <media/v4l2-fwnode.h>
3634 #include <media/v4l2-subdev.h>
35
+#include "../platform/rockchip/isp/rkisp_tb_helper.h"
3736
38
-#define DRIVER_VERSION KERNEL_VERSION(0, 0x01, 0x04)
37
+#define DRIVER_VERSION KERNEL_VERSION(0, 0x01, 0x02)
3938 #define GC2093_NAME "gc2093"
4039 #define GC2093_MEDIA_BUS_FMT MEDIA_BUS_FMT_SRGGB10_1X10
4140
4241 #define MIPI_FREQ_297M 297000000
4342 #define MIPI_FREQ_396M 396000000
4443
45
-/* 27M or 24M */
46
-#define MCLK_27M
47
-
48
-#ifdef MCLK_27M
4944 #define GC2093_XVCLK_FREQ 27000000
50
-#else
51
-#define GC2093_XVCLK_FREQ 24000000
52
-#endif
5345
5446 #define GC2093_REG_CHIP_ID_H 0x03F0
5547 #define GC2093_REG_CHIP_ID_L 0x03F1
....@@ -99,14 +91,6 @@
9991 #define GC2093_NUM_SUPPLIES ARRAY_SIZE(gc2093_supply_names)
10092
10193 #define to_gc2093(sd) container_of(sd, struct gc2093, subdev)
102
-
103
-enum {
104
- PAD0,
105
- PAD1,
106
- PAD2,
107
- PAD3,
108
- PAD_MAX,
109
-};
11094
11195 enum {
11296 LINK_FREQ_297M_INDEX,
....@@ -165,9 +149,13 @@
165149 const char *module_facing;
166150 const char *module_name;
167151 const char *len_name;
168
- u32 cur_vts;
169152
170
- bool has_init_exp;
153
+ struct v4l2_fract cur_fps;
154
+ u32 cur_vts;
155
+
156
+ bool has_init_exp;
157
+ bool is_thunderboot;
158
+ bool is_first_streamoff;
171159 struct preisp_hdrae_exp_s init_hdrae_exp;
172160 };
173161
....@@ -189,7 +177,6 @@
189177 * row_time=29.62us frame_rate=30fps
190178 */
191179 static const struct reg_sequence gc2093_1080p_liner_settings[] = {
192
-#ifdef MCLK_27M
193180 /* System */
194181 {0x03fe, 0x80},
195182 {0x03fe, 0x80},
....@@ -300,157 +287,6 @@
300287 {0x0212, 0x80},
301288 {0x0213, 0x07},
302289 {0x003e, 0x91},
303
-#else
304
- /****system****/
305
- {0x03fe, 0xf0},
306
- {0x03fe, 0xf0},
307
- {0x03fe, 0xf0},
308
- {0x03fe, 0x00},
309
- {0x03f2, 0x00},
310
- {0x03f3, 0x00},
311
- {0x03f4, 0x36},
312
- {0x03f5, 0xc0},
313
- {0x03f6, 0x0B},
314
- {0x03f7, 0x11},
315
- {0x03f8, 0x30},
316
- {0x03f9, 0x42},
317
- {0x03fc, 0x8e},
318
- /****CISCTL & ANALOG****/
319
- {0x0087, 0x18},
320
- {0x00ee, 0x30},
321
- {0x00d0, 0xbf},
322
- {0x01a0, 0x00},
323
- {0x01a4, 0x40},
324
- {0x01a5, 0x40},
325
- {0x01a6, 0x40},
326
- {0x01af, 0x09},
327
- {0x0003, 0x04},
328
- {0x0004, 0x65},
329
- {0x0005, 0x05},
330
- {0x0006, 0x8e},
331
- {0x0007, 0x00},
332
- {0x0008, 0x11},
333
- {0x0009, 0x00},
334
- {0x000a, 0x02},
335
- {0x000b, 0x00},
336
- {0x000c, 0x04},
337
- {0x000d, 0x04},
338
- {0x000e, 0x40},
339
- {0x000f, 0x07},
340
- {0x0010, 0x8c},
341
- {0x0013, 0x15},
342
- {0x0019, 0x0c},
343
- {0x0041, 0x04},
344
- {0x0042, 0x65},
345
- {0x0053, 0x60},
346
- {0x008d, 0x92},
347
- {0x0090, 0x00},
348
- {0x00c7, 0xe1},
349
- {0x001b, 0x73},
350
- {0x0028, 0x0d},
351
- {0x0029, 0x40},
352
- {0x002b, 0x04},
353
- {0x002e, 0x23},
354
- {0x0037, 0x03},
355
- {0x0043, 0x04},
356
- {0x0044, 0x30},
357
- {0x004a, 0x01},
358
- {0x004b, 0x28},
359
- {0x0055, 0x30},
360
- {0x0066, 0x3f},
361
- {0x0068, 0x3f},
362
- {0x006b, 0x44},
363
- {0x0077, 0x00},
364
- {0x0078, 0x20},
365
- {0x007c, 0xa1},
366
- {0x00ce, 0x7c},
367
- {0x00d3, 0xd4},
368
- {0x00e6, 0x50},
369
- /*gain*/
370
- {0x00b6, 0xc0},
371
- {0x00b0, 0x68},
372
- {0x00b3, 0x00},
373
- {0x00b8, 0x01},
374
- {0x00b9, 0x00},
375
- {0x00b1, 0x01},
376
- {0x00b2, 0x00},
377
- /*isp*/
378
- {0x0101, 0x0c},
379
- {0x0102, 0x89},
380
- {0x0104, 0x01},
381
- {0x0107, 0xa6},
382
- {0x0108, 0xa9},
383
- {0x0109, 0xa8},
384
- {0x010a, 0xa7},
385
- {0x010b, 0xff},
386
- {0x010c, 0xff},
387
- {0x010f, 0x00},
388
- {0x0158, 0x00},
389
- {0x0428, 0x86},
390
- {0x0429, 0x86},
391
- {0x042a, 0x86},
392
- {0x042b, 0x68},
393
- {0x042c, 0x68},
394
- {0x042d, 0x68},
395
- {0x042e, 0x68},
396
- {0x042f, 0x68},
397
- {0x0430, 0x4f},
398
- {0x0431, 0x68},
399
- {0x0432, 0x67},
400
- {0x0433, 0x66},
401
- {0x0434, 0x66},
402
- {0x0435, 0x66},
403
- {0x0436, 0x66},
404
- {0x0437, 0x66},
405
- {0x0438, 0x62},
406
- {0x0439, 0x62},
407
- {0x043a, 0x62},
408
- {0x043b, 0x62},
409
- {0x043c, 0x62},
410
- {0x043d, 0x62},
411
- {0x043e, 0x62},
412
- {0x043f, 0x62},
413
- /*dark sun*/
414
- {0x0123, 0x08},
415
- {0x0123, 0x00},
416
- {0x0120, 0x01},
417
- {0x0121, 0x04},
418
- {0x0122, 0x65},
419
- {0x0124, 0x03},
420
- {0x0125, 0xff},
421
- {0x001a, 0x8c},
422
- {0x00c6, 0xe0},
423
- /*blk*/
424
- {0x0026, 0x30},
425
- {0x0142, 0x00},
426
- {0x0149, 0x1e},
427
- {0x014a, 0x0f},
428
- {0x014b, 0x00},
429
- {0x0155, 0x07},
430
- {0x0414, 0x78},
431
- {0x0415, 0x78},
432
- {0x0416, 0x78},
433
- {0x0417, 0x78},
434
- {0x04e0, 0x18},
435
- /*window*/
436
- {0x0192, 0x02},
437
- {0x0194, 0x03},
438
- {0x0195, 0x04},
439
- {0x0196, 0x38},
440
- {0x0197, 0x07},
441
- {0x0198, 0x80},
442
- /****DVP & MIPI****/
443
- {0x019a, 0x06},
444
- {0x007b, 0x2a},
445
- {0x0023, 0x2d},
446
- {0x0201, 0x27},
447
- {0x0202, 0x56},
448
- {0x0203, 0xb6},
449
- {0x0212, 0x80},
450
- {0x0213, 0x07},
451
- {0x0215, 0x10},
452
- {0x003e, 0x91},
453
-#endif
454290 };
455291
456292 /*
....@@ -460,7 +296,6 @@
460296 * row_time=13.33us frame_rate=60fps
461297 */
462298 static const struct reg_sequence gc2093_1080p_hdr_settings[] = {
463
-#ifdef MCLK_27M
464299 /* System */
465300 {0x03fe, 0x80},
466301 {0x03fe, 0x80},
....@@ -502,8 +337,8 @@
502337 {0x0010, 0x8c},
503338 {0x0013, 0x15},
504339 {0x0019, 0x0c},
505
- {0x0041, 0x05}, //30fps: 0x4e2; 25FPS: 0x5dc: 20FPS: 0x753
506
- {0x0042, 0xdc},
340
+ {0x0041, 0x04},
341
+ {0x0042, 0xe2},
507342 {0x0053, 0x60},
508343 {0x008d, 0x92},
509344 {0x0090, 0x00},
....@@ -584,135 +419,6 @@
584419 {0x0027, 0x71},
585420 {0x0215, 0x92},
586421 {0x024d, 0x01},
587
-#else
588
- /****system****/
589
- {0x03fe, 0xf0},
590
- {0x03fe, 0xf0},
591
- {0x03fe, 0xf0},
592
- {0x03fe, 0x00},
593
- {0x03f2, 0x00},
594
- {0x03f3, 0x00},
595
- {0x03f4, 0x36},
596
- {0x03f5, 0xc0},
597
- {0x03f6, 0x0B},
598
- {0x03f7, 0x01},
599
- {0x03f8, 0x63},
600
- {0x03f9, 0x40},
601
- {0x03fc, 0x8e},
602
- /****CISCTL & ANALOG****/
603
- {0x0087, 0x18},
604
- {0x00ee, 0x30},
605
- {0x00d0, 0xbf},
606
- {0x01a0, 0x00},
607
- {0x01a4, 0x40},
608
- {0x01a5, 0x40},
609
- {0x01a6, 0x40},
610
- {0x01af, 0x09},
611
- {0x0001, 0x00},
612
- {0x0002, 0x02},
613
- {0x0003, 0x04},
614
- {0x0004, 0x02},
615
- {0x0005, 0x02},
616
- {0x0006, 0x94},
617
- {0x0007, 0x00},
618
- {0x0008, 0x11},
619
- {0x0009, 0x00},
620
- {0x000a, 0x02},
621
- {0x000b, 0x00},
622
- {0x000c, 0x04},
623
- {0x000d, 0x04},
624
- {0x000e, 0x40},
625
- {0x000f, 0x07},
626
- {0x0010, 0x8c},
627
- {0x0013, 0x15},
628
- {0x0019, 0x0c},
629
- {0x0041, 0x05}, //30fps: 0x4e2; 25FPS: 0x5dc: 20FPS: 0x753
630
- {0x0042, 0xdc},
631
- {0x0053, 0x60},
632
- {0x008d, 0x92},
633
- {0x0090, 0x00},
634
- {0x00c7, 0xe1},
635
- {0x001b, 0x73},
636
- {0x0028, 0x0d},
637
- {0x0029, 0x24},
638
- {0x002b, 0x04},
639
- {0x002e, 0x23},
640
- {0x0037, 0x03},
641
- {0x0043, 0x04},
642
- {0x0044, 0x28},
643
- {0x004a, 0x01},
644
- {0x004b, 0x20},
645
- {0x0055, 0x28},
646
- {0x0066, 0x3f},
647
- {0x0068, 0x3f},
648
- {0x006b, 0x44},
649
- {0x0077, 0x00},
650
- {0x0078, 0x20},
651
- {0x007c, 0xa1},
652
- {0x00ce, 0x7c},
653
- {0x00d3, 0xd4},
654
- {0x00e6, 0x50},
655
- /*gain*/
656
- {0x00b6, 0xc0},
657
- {0x00b0, 0x68},
658
- /*isp*/
659
- {0x0101, 0x0c},
660
- {0x0102, 0x89},
661
- {0x0104, 0x01},
662
- {0x010e, 0x01},
663
- {0x010f, 0x00},
664
- {0x0158, 0x00},
665
- {0x0183, 0x01},
666
- {0x0187, 0x50},
667
- /*dark sun*/
668
- {0x0123, 0x08},
669
- {0x0123, 0x00},
670
- {0x0120, 0x01},
671
- {0x0121, 0x04},
672
- {0x0122, 0xd8},
673
- {0x0124, 0x03},
674
- {0x0125, 0xff},
675
- {0x001a, 0x8c},
676
- {0x00c6, 0xe0},
677
- /*blk*/
678
- {0x0026, 0x30},
679
- {0x0142, 0x00},
680
- {0x0149, 0x1e},
681
- {0x014a, 0x0f},
682
- {0x014b, 0x00},
683
- {0x0155, 0x07},
684
- {0x0414, 0x78},
685
- {0x0415, 0x78},
686
- {0x0416, 0x78},
687
- {0x0417, 0x78},
688
- {0x0454, 0x78},
689
- {0x0455, 0x78},
690
- {0x0456, 0x78},
691
- {0x0457, 0x78},
692
- {0x04e0, 0x18},
693
- /*window*/
694
- {0x0192, 0x02},
695
- {0x0194, 0x03},
696
- {0x0195, 0x04},
697
- {0x0196, 0x38},
698
- {0x0197, 0x07},
699
- {0x0198, 0x80},
700
- /****DVP & MIPI****/
701
- {0x019a, 0x06},
702
- {0x007b, 0x2a},
703
- {0x0023, 0x2d},
704
- {0x0201, 0x27},
705
- {0x0202, 0x56},
706
- {0x0203, 0xb6}, //try 0xce or 0x8e
707
- {0x0212, 0x80},
708
- {0x0213, 0x07},
709
- {0x0215, 0x10},
710
- {0x003e, 0x91},
711
- /****HDR EN****/
712
- {0x0027, 0x71},
713
- {0x0215, 0x92},
714
- {0x024d, 0x01},
715
-#endif
716422 };
717423
718424 static const struct gc2093_mode supported_modes[] = {
....@@ -737,11 +443,11 @@
737443 .height = 1080,
738444 .max_fps = {
739445 .numerator = 10000,
740
- .denominator = 250000,
446
+ .denominator = 300000,
741447 },
742448 .exp_def = 0x460,
743449 .hts_def = 0xa50,
744
- .vts_def = 0x5dc,//30fps: 0x4e2; 25FPS: 0x5dc: 20FPS: 0x753
450
+ .vts_def = 0x4e2,
745451 .link_freq_index = LINK_FREQ_396M_INDEX,
746452 .reg_list = gc2093_1080p_hdr_settings,
747453 .reg_num = ARRAY_SIZE(gc2093_1080p_hdr_settings),
....@@ -847,6 +553,14 @@
847553 return ret;
848554 }
849555
556
+static void gc2093_modify_fps_info(struct gc2093 *gc2093)
557
+{
558
+ const struct gc2093_mode *mode = gc2093->cur_mode;
559
+
560
+ gc2093->cur_fps.denominator = mode->max_fps.denominator * mode->vts_def /
561
+ gc2093->cur_vts;
562
+}
563
+
850564 static int gc2093_set_ctrl(struct v4l2_ctrl *ctrl)
851565 {
852566 struct gc2093 *gc2093 = container_of(ctrl->handler,
....@@ -886,14 +600,14 @@
886600 gc2093_set_gain(gc2093, ctrl->val);
887601 break;
888602 case V4L2_CID_VBLANK:
889
- if (gc2093->cur_mode->hdr_mode != NO_HDR)
890
- goto ctrl_end;
891603 vts = gc2093->cur_mode->height + ctrl->val;
892604 gc2093->cur_vts = vts;
893605 ret = gc2093_write_reg(gc2093, GC2093_REG_VTS_H,
894606 (vts >> 8) & 0x3f);
895607 ret |= gc2093_write_reg(gc2093, GC2093_REG_VTS_L,
896608 vts & 0xff);
609
+ if (gc2093->cur_vts != gc2093->cur_mode->vts_def)
610
+ gc2093_modify_fps_info(gc2093);
897611 dev_dbg(gc2093->dev, " set blank value 0x%x\n", ctrl->val);
898612 break;
899613 case V4L2_CID_HFLIP:
....@@ -992,6 +706,8 @@
992706
993707 gc2093->subdev.ctrl_handler = handler;
994708 gc2093->has_init_exp = false;
709
+ gc2093->cur_vts = mode->vts_def;
710
+ gc2093->cur_fps = mode->max_fps;
995711
996712 return 0;
997713
....@@ -1018,6 +734,9 @@
1018734 return ret;
1019735 }
1020736
737
+ if (gc2093->is_thunderboot)
738
+ return 0;
739
+
1021740 ret = regulator_bulk_enable(GC2093_NUM_SUPPLIES, gc2093->supplies);
1022741 if (ret < 0) {
1023742 dev_err(dev, "Failed to enable regulators\n");
....@@ -1025,14 +744,14 @@
1025744 }
1026745
1027746 if (!IS_ERR(gc2093->reset_gpio))
1028
- gpiod_set_value_cansleep(gc2093->reset_gpio, 1);
747
+ gpiod_direction_output(gc2093->reset_gpio, 1);
1029748
1030749 usleep_range(1000, 2000);
1031750
1032751 if (!IS_ERR(gc2093->pwdn_gpio))
1033
- gpiod_set_value_cansleep(gc2093->pwdn_gpio, 1);
752
+ gpiod_direction_output(gc2093->pwdn_gpio, 1);
1034753 if (!IS_ERR(gc2093->reset_gpio))
1035
- gpiod_set_value_cansleep(gc2093->reset_gpio, 0);
754
+ gpiod_direction_output(gc2093->reset_gpio, 0);
1036755
1037756 usleep_range(10000, 20000);
1038757
....@@ -1045,20 +764,35 @@
1045764
1046765 static void __gc2093_power_off(struct gc2093 *gc2093)
1047766 {
767
+ clk_disable_unprepare(gc2093->xvclk);
768
+ if (gc2093->is_thunderboot) {
769
+ if (gc2093->is_first_streamoff) {
770
+ gc2093->is_thunderboot = false;
771
+ gc2093->is_first_streamoff = false;
772
+ } else {
773
+ return;
774
+ }
775
+ }
776
+
1048777 if (!IS_ERR(gc2093->reset_gpio))
1049
- gpiod_set_value_cansleep(gc2093->reset_gpio, 1);
778
+ gpiod_direction_output(gc2093->reset_gpio, 1);
1050779 if (!IS_ERR(gc2093->pwdn_gpio))
1051
- gpiod_set_value_cansleep(gc2093->pwdn_gpio, 0);
780
+ gpiod_direction_output(gc2093->pwdn_gpio, 0);
1052781
1053782 regulator_bulk_disable(GC2093_NUM_SUPPLIES, gc2093->supplies);
1054
- clk_disable_unprepare(gc2093->xvclk);
1055783 }
1056784
1057785 static int gc2093_check_sensor_id(struct gc2093 *gc2093)
1058786 {
787
+ struct device *dev = gc2093->dev;
1059788 u8 id_h = 0, id_l = 0;
1060789 u16 id = 0;
1061790 int ret = 0;
791
+
792
+ if (gc2093->is_thunderboot) {
793
+ dev_info(dev, "Enable thunderboot mode, skip sensor id check\n");
794
+ return 0;
795
+ }
1062796
1063797 ret = gc2093_read_reg(gc2093, GC2093_REG_CHIP_ID_H, &id_h);
1064798 ret |= gc2093_read_reg(gc2093, GC2093_REG_CHIP_ID_L, &id_l);
....@@ -1107,8 +841,7 @@
1107841 dev_info(gc2093->dev, "don't streaming, record hdrae\n");
1108842 break;
1109843 }
1110
- /* group hold start*/
1111
- gc2093_write_reg(gc2093, 0x031d, 0x2c);
844
+
1112845 ret = gc2093_set_gain(gc2093, hdrae_exp->short_gain_reg);
1113846 if (ret) {
1114847 dev_err(gc2093->dev, "Failed to set gain!)\n");
....@@ -1171,8 +904,6 @@
1171904 (short_exp >> 8) & 0x3f);
1172905 ret |= gc2093_write_reg(gc2093, GC2093_REG_EXP_SHORT_L,
1173906 short_exp & 0xff);
1174
- /* group hold end*/
1175
- gc2093_write_reg(gc2093, 0x031d, 0x28);
1176907 break;
1177908 case RKMODULE_GET_HDR_CFG:
1178909 hdr_cfg = (struct rkmodule_hdr_cfg *)arg;
....@@ -1203,6 +934,7 @@
1203934 GC2093_VTS_MAX - gc2093->cur_mode->height,
1204935 1, h);
1205936 gc2093->cur_vts = gc2093->cur_mode->vts_def;
937
+ gc2093->cur_fps = gc2093->cur_mode->max_fps;
1206938 dev_info(gc2093->dev, "sensor mode: %d\n",
1207939 gc2093->cur_mode->hdr_mode);
1208940 }
....@@ -1237,26 +969,27 @@
1237969 {
1238970 int ret;
1239971
1240
- ret = regmap_multi_reg_write(gc2093->regmap,
1241
- gc2093->cur_mode->reg_list,
1242
- gc2093->cur_mode->reg_num);
1243
- if (ret)
1244
- return ret;
1245
-
1246
- /* Apply customized control from user */
1247
- mutex_unlock(&gc2093->lock);
1248
- v4l2_ctrl_handler_setup(&gc2093->ctrl_handler);
1249
- mutex_lock(&gc2093->lock);
1250
-
1251
- if (gc2093->has_init_exp && gc2093->cur_mode->hdr_mode != NO_HDR) {
1252
- ret = gc2093_ioctl(&gc2093->subdev, PREISP_CMD_SET_HDRAE_EXP,
1253
- &gc2093->init_hdrae_exp);
1254
- if (ret) {
1255
- dev_err(gc2093->dev, "init exp fail in hdr mode\n");
972
+ if (!gc2093->is_thunderboot) {
973
+ ret = regmap_multi_reg_write(gc2093->regmap,
974
+ gc2093->cur_mode->reg_list,
975
+ gc2093->cur_mode->reg_num);
976
+ if (ret)
1256977 return ret;
978
+
979
+ /* Apply customized control from user */
980
+ mutex_unlock(&gc2093->lock);
981
+ v4l2_ctrl_handler_setup(&gc2093->ctrl_handler);
982
+ mutex_lock(&gc2093->lock);
983
+
984
+ if (gc2093->has_init_exp && gc2093->cur_mode->hdr_mode != NO_HDR) {
985
+ ret = gc2093_ioctl(&gc2093->subdev, PREISP_CMD_SET_HDRAE_EXP,
986
+ &gc2093->init_hdrae_exp);
987
+ if (ret) {
988
+ dev_err(gc2093->dev, "init exp fail in hdr mode\n");
989
+ return ret;
990
+ }
1257991 }
1258992 }
1259
-
1260993 return gc2093_write_reg(gc2093, GC2093_REG_CTRL_MODE,
1261994 GC2093_MODE_STREAMING);
1262995 }
....@@ -1264,6 +997,10 @@
1264997 static int __gc2093_stop_stream(struct gc2093 *gc2093)
1265998 {
1266999 gc2093->has_init_exp = false;
1000
+ if (gc2093->is_thunderboot) {
1001
+ gc2093->is_first_streamoff = true;
1002
+ pm_runtime_put(gc2093->dev);
1003
+ }
12671004 return gc2093_write_reg(gc2093, GC2093_REG_CTRL_MODE,
12681005 GC2093_MODE_SW_STANDBY);
12691006 }
....@@ -1374,6 +1111,10 @@
13741111 goto unlock_and_return;
13751112
13761113 if (on) {
1114
+ if (gc2093->is_thunderboot && rkisp_tb_get_state() == RKISP_TB_NG) {
1115
+ gc2093->is_thunderboot = false;
1116
+ __gc2093_power_on(gc2093);
1117
+ }
13771118 ret = pm_runtime_get_sync(gc2093->dev);
13781119 if (ret < 0) {
13791120 pm_runtime_put_noidle(gc2093->dev);
....@@ -1410,21 +1151,19 @@
14101151 struct gc2093 *gc2093 = to_gc2093(sd);
14111152 const struct gc2093_mode *mode = gc2093->cur_mode;
14121153
1413
- mutex_lock(&gc2093->lock);
14141154 fi->interval = mode->max_fps;
1415
- mutex_unlock(&gc2093->lock);
14161155
14171156 return 0;
14181157 }
14191158
1420
-static int gc2093_g_mbus_config(struct v4l2_subdev *sd,
1159
+static int gc2093_g_mbus_config(struct v4l2_subdev *sd, unsigned int pad_id,
14211160 struct v4l2_mbus_config *config)
14221161 {
14231162 struct gc2093 *gc2093 = to_gc2093(sd);
14241163 u32 val = 1 << (GC2093_LANES - 1) | V4L2_MBUS_CSI2_CHANNEL_0 |
14251164 V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
14261165
1427
- config->type = V4L2_MBUS_CSI2;
1166
+ config->type = V4L2_MBUS_CSI2_DPHY;
14281167 config->flags = (gc2093->cur_mode->hdr_mode == NO_HDR) ?
14291168 val : (val | V4L2_MBUS_CSI2_CHANNEL_1);
14301169
....@@ -1515,6 +1254,8 @@
15151254 __v4l2_ctrl_modify_range(gc2093->vblank, vblank_def,
15161255 GC2093_VTS_MAX - mode->height,
15171256 1, vblank_def);
1257
+ gc2093->cur_vts = mode->vts_def;
1258
+ gc2093->cur_fps = mode->max_fps;
15181259 }
15191260
15201261 mutex_unlock(&gc2093->lock);
....@@ -1618,7 +1359,6 @@
16181359 static const struct v4l2_subdev_video_ops gc2093_video_ops = {
16191360 .s_stream = gc2093_s_stream,
16201361 .g_frame_interval = gc2093_g_frame_interval,
1621
- .g_mbus_config = gc2093_g_mbus_config,
16221362 };
16231363
16241364 static const struct v4l2_subdev_pad_ops gc2093_pad_ops = {
....@@ -1627,6 +1367,7 @@
16271367 .enum_frame_interval = gc2093_enum_frame_interval,
16281368 .get_fmt = gc2093_get_fmt,
16291369 .set_fmt = gc2093_set_fmt,
1370
+ .get_mbus_config = gc2093_g_mbus_config,
16301371 };
16311372
16321373 static const struct v4l2_subdev_ops gc2093_subdev_ops = {
....@@ -1635,7 +1376,7 @@
16351376 .pad = &gc2093_pad_ops,
16361377 };
16371378
1638
-static int gc2093_runtime_resume(struct device *dev)
1379
+static int __maybe_unused gc2093_runtime_resume(struct device *dev)
16391380 {
16401381 struct i2c_client *client = to_i2c_client(dev);
16411382 struct v4l2_subdev *sd = i2c_get_clientdata(client);
....@@ -1645,7 +1386,7 @@
16451386 return 0;
16461387 }
16471388
1648
-static int gc2093_runtime_suspend(struct device *dev)
1389
+static int __maybe_unused gc2093_runtime_suspend(struct device *dev)
16491390 {
16501391 struct i2c_client *client = to_i2c_client(dev);
16511392 struct v4l2_subdev *sd = i2c_get_clientdata(client);
....@@ -1699,17 +1440,19 @@
16991440 return -EINVAL;
17001441 }
17011442
1443
+ gc2093->is_thunderboot = IS_ENABLED(CONFIG_VIDEO_ROCKCHIP_THUNDER_BOOT_ISP);
1444
+
17021445 gc2093->xvclk = devm_clk_get(gc2093->dev, "xvclk");
17031446 if (IS_ERR(gc2093->xvclk)) {
17041447 dev_err(gc2093->dev, "Failed to get xvclk\n");
17051448 return -EINVAL;
17061449 }
17071450
1708
- gc2093->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);
1451
+ gc2093->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_ASIS);
17091452 if (IS_ERR(gc2093->reset_gpio))
17101453 dev_warn(dev, "Failed to get reset-gpios\n");
17111454
1712
- gc2093->pwdn_gpio = devm_gpiod_get(dev, "pwdn", GPIOD_OUT_HIGH);
1455
+ gc2093->pwdn_gpio = devm_gpiod_get(dev, "pwdn", GPIOD_ASIS);
17131456 if (IS_ERR(gc2093->pwdn_gpio))
17141457 dev_warn(dev, "Failed to get pwdn-gpios\n");
17151458
....@@ -1771,7 +1514,10 @@
17711514
17721515 pm_runtime_set_active(dev);
17731516 pm_runtime_enable(dev);
1774
- pm_runtime_idle(dev);
1517
+ if (gc2093->is_thunderboot)
1518
+ pm_runtime_get_sync(dev);
1519
+ else
1520
+ pm_runtime_idle(dev);
17751521
17761522 return 0;
17771523
....@@ -1839,7 +1585,11 @@
18391585 i2c_del_driver(&gc2093_i2c_driver);
18401586 }
18411587
1588
+#if defined(CONFIG_VIDEO_ROCKCHIP_THUNDER_BOOT_ISP) && !defined(CONFIG_INITCALL_ASYNC)
1589
+subsys_initcall(sensor_mod_init);
1590
+#else
18421591 device_initcall_sync(sensor_mod_init);
1592
+#endif
18431593 module_exit(sensor_mod_exit);
18441594
18451595 MODULE_DESCRIPTION("Galaxycore GC2093 Image Sensor driver");