hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/drivers/media/i2c/sc230ai.c
....@@ -61,9 +61,6 @@
6161 #define SC230AI_REG_SEXPOSURE_L 0x3e05
6262 #define SC230AI_EXPOSURE_MIN 1
6363 #define SC230AI_EXPOSURE_STEP 1
64
-#define SC230AI_EXPOSURE_LIN_MAX (2 * 0x465 - 9)
65
-#define SC230AI_EXPOSURE_HDR_MAX_S (2 * 0x465 - 9)
66
-#define SC230AI_EXPOSURE_HDR_MAX_L (2 * 0x465 - 9)
6764 #define SC230AI_VTS_MAX 0x7fff
6865
6966 #define SC230AI_REG_DIG_GAIN 0x3e06
....@@ -74,7 +71,7 @@
7471 #define SC230AI_REG_SANA_GAIN 0x3e12
7572 #define SC230AI_REG_SANA_FINE_GAIN 0x3e13
7673 #define SC230AI_GAIN_MIN 1000
77
-#define SC230AI_GAIN_MAX 1722628 //108.512*15.875*1000
74
+#define SC230AI_GAIN_MAX 1574800 // 99.2*15.875*1000
7875 #define SC230AI_GAIN_STEP 1
7976 #define SC230AI_GAIN_DEFAULT 1000
8077 #define SC230AI_LGAIN 0
....@@ -678,46 +675,46 @@
678675 *again = 0x00;
679676 *dgain = 0x00;
680677 *dgain_fine = total_gain * 128 / 1000;
681
- } else if (total_gain < 3391) { /* 2 ~ 3.391 gain*/
678
+ } else if (total_gain < 3100) { /* 2 ~ 3.1 gain*/
682679 *again = 0x01;
683680 *dgain = 0x00;
684681 *dgain_fine = total_gain * 128 / 1000 / 2;
685
- } else if (total_gain < 3391 * 2) { /* 3.391 ~ 6.782 gain*/
682
+ } else if (total_gain < 3100 * 2) { /* 3.100 ~ 6.200 gain*/
686683 *again = 0x40;
687684 *dgain = 0x00;
688
- *dgain_fine = total_gain * 128 / 3391;
689
- } else if (total_gain < 3391 * 4) { /* 6.782 ~ 13.564 gain*/
685
+ *dgain_fine = total_gain * 128 / 3100;
686
+ } else if (total_gain < 3100 * 4) { /* 6.200 ~ 12.400 gain*/
690687 *again = 0x48;
691688 *dgain = 0x00;
692
- *dgain_fine = total_gain * 128 / 3391 / 2;
693
- } else if (total_gain < 3391 * 8) { /* 13.564 ~ 27.128 gain*/
689
+ *dgain_fine = total_gain * 128 / 3100 / 2;
690
+ } else if (total_gain < 3100 * 8) { /* 12.400 ~ 24.800 gain*/
694691 *again = 0x49;
695692 *dgain = 0x00;
696
- *dgain_fine = total_gain * 128 / 3391 / 4;
697
- } else if (total_gain < 3391 * 16) { /* 27.128 ~ 54.256 gain*/
693
+ *dgain_fine = total_gain * 128 / 3100 / 4;
694
+ } else if (total_gain < 3100 * 16) { /* 24.800 ~ 49.600 gain*/
698695 *again = 0x4b;
699696 *dgain = 0x00;
700
- *dgain_fine = total_gain * 128 / 3391 / 8;
701
- } else if (total_gain < 3391 * 32) { /* 54.256 ~ 108.512 gain*/
697
+ *dgain_fine = total_gain * 128 / 3100 / 8;
698
+ } else if (total_gain < 3100 * 32) { /* 49.600 ~ 99.200 gain*/
702699 *again = 0x4f;
703700 *dgain = 0x00;
704
- *dgain_fine = total_gain * 128 / 3391 / 16;
705
- } else if (total_gain < 3391 * 64) { /* 108.512 ~ 217.024 gain*/
701
+ *dgain_fine = total_gain * 128 / 3100 / 16;
702
+ } else if (total_gain < 3100 * 64) { /* 99.200 ~ 198.400 gain*/
706703 *again = 0x5f;
707704 *dgain = 0x00;
708
- *dgain_fine = total_gain * 128 / 3391 / 32;
709
- } else if (total_gain < 3391 * 128) { /* 217.024 ~ 434.048 gain*/
705
+ *dgain_fine = total_gain * 128 / 3100 / 32;
706
+ } else if (total_gain < 3100 * 128) { /* 198.400 ~ 396.800 gain*/
710707 *again = 0x5f;
711708 *dgain = 0x01;
712
- *dgain_fine = total_gain * 128 / 3391 / 64;
713
- } else if (total_gain < 3391 * 256) { /* 434.048 ~ 868.096 gain*/
709
+ *dgain_fine = total_gain * 128 / 3100 / 64;
710
+ } else if (total_gain < 3100 * 256) { /* 396.800 ~ 793.600 gain*/
714711 *again = 0x5f;
715712 *dgain = 0x03;
716
- *dgain_fine = total_gain * 128 / 3391 / 128;
717
- } else if (total_gain < 3391 * 512) { /* 868.096 ~ 1736.192 gain*/
713
+ *dgain_fine = total_gain * 128 / 3100 / 128;
714
+ } else { /* 793.600 ~ 1587.200 gain*/
718715 *again = 0x5f;
719716 *dgain = 0x07;
720
- *dgain_fine = total_gain * 128 / 3391 / 128;
717
+ *dgain_fine = total_gain * 128 / 3100 / 128;
721718 }
722719
723720 return ret;
....@@ -1406,7 +1403,7 @@
14061403 switch (ctrl->id) {
14071404 case V4L2_CID_VBLANK:
14081405 /* Update max exposure while meeting expected vblanking */
1409
- max = sc230ai->cur_mode->height + ctrl->val - 4;
1406
+ max = sc230ai->cur_mode->height + ctrl->val - 5;
14101407 __v4l2_ctrl_modify_range(sc230ai->exposure,
14111408 sc230ai->exposure->minimum, max,
14121409 sc230ai->exposure->step,
....@@ -1469,8 +1466,7 @@
14691466 (ctrl->val + sc230ai->cur_mode->height)
14701467 & 0xff);
14711468 sc230ai->cur_vts = ctrl->val + sc230ai->cur_mode->height;
1472
- if (sc230ai->cur_vts != sc230ai->cur_mode->vts_def)
1473
- sc230ai_modify_fps_info(sc230ai);
1469
+ sc230ai_modify_fps_info(sc230ai);
14741470 break;
14751471 case V4L2_CID_TEST_PATTERN:
14761472 ret = sc230ai_enable_test_pattern(sc230ai, ctrl->val);
....@@ -1546,7 +1542,7 @@
15461542 V4L2_CID_VBLANK, vblank_def,
15471543 SC230AI_VTS_MAX - mode->height,
15481544 1, vblank_def);
1549
- exposure_max = SC230AI_EXPOSURE_LIN_MAX;
1545
+ exposure_max = mode->vts_def - 5;
15501546 sc230ai->exposure = v4l2_ctrl_new_std(handler, &sc230ai_ctrl_ops,
15511547 V4L2_CID_EXPOSURE, SC230AI_EXPOSURE_MIN,
15521548 exposure_max, SC230AI_EXPOSURE_STEP,