Skip to content

Commit 0292614

Browse files
6by9pelwell
authored andcommitted
media: i2c: imx415: Link frequencies are not exclusive to num lanes
The link frequencies are equally valid in 2 or 4 lane modes, but they change the hmax_min value for the mode as the MIPI block has to have sufficient time to send the pixel data for each line. Remove the association with number of lanes, and add hmax_min configuration for both lane options. Signed-off-by: Dave Stevenson <[email protected]>
1 parent 6722e13 commit 0292614

File tree

1 file changed

+22
-27
lines changed

1 file changed

+22
-27
lines changed

drivers/media/i2c/imx415.c

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -462,9 +462,8 @@ static const struct imx415_clk_params imx415_clk_params[] = {
462462
},
463463
};
464464

465-
/* all-pixel 2-lane 720 Mbps 15.74 Hz mode */
466-
static const struct imx415_reg imx415_mode_2_720[] = {
467-
{ IMX415_LANEMODE, IMX415_LANEMODE_2 },
465+
/* 720 Mbps CSI configuration */
466+
static const struct imx415_reg imx415_linkrate_720mbps[] = {
468467
{ IMX415_TCLKPOST, 0x006F },
469468
{ IMX415_TCLKPREPARE, 0x002F },
470469
{ IMX415_TCLKTRAIL, 0x002F },
@@ -476,9 +475,8 @@ static const struct imx415_reg imx415_mode_2_720[] = {
476475
{ IMX415_TLPX, 0x0027 },
477476
};
478477

479-
/* all-pixel 2-lane 1440 Mbps 30.01 Hz mode */
480-
static const struct imx415_reg imx415_mode_2_1440[] = {
481-
{ IMX415_LANEMODE, IMX415_LANEMODE_2 },
478+
/* 1440 Mbps CSI configuration */
479+
static const struct imx415_reg imx415_linkrate_1440mbps[] = {
482480
{ IMX415_TCLKPOST, 0x009F },
483481
{ IMX415_TCLKPREPARE, 0x0057 },
484482
{ IMX415_TCLKTRAIL, 0x0057 },
@@ -490,9 +488,8 @@ static const struct imx415_reg imx415_mode_2_1440[] = {
490488
{ IMX415_TLPX, 0x004F },
491489
};
492490

493-
/* all-pixel 4-lane 891 Mbps 30 Hz mode */
494-
static const struct imx415_reg imx415_mode_4_891[] = {
495-
{ IMX415_LANEMODE, IMX415_LANEMODE_4 },
491+
/* 891 Mbps */
492+
static const struct imx415_reg imx415_linkrate_891mbps[] = {
496493
{ IMX415_TCLKPOST, 0x007F },
497494
{ IMX415_TCLKPREPARE, 0x0037 },
498495
{ IMX415_TCLKTRAIL, 0x0037 },
@@ -511,38 +508,34 @@ struct imx415_mode_reg_list {
511508

512509
struct imx415_mode {
513510
u64 lane_rate;
514-
u32 lanes;
515-
u32 hmax_min;
511+
u32 hmax_min[2];
516512
struct imx415_mode_reg_list reg_list;
517513
};
518514

519515
/* mode configs */
520516
static const struct imx415_mode supported_modes[] = {
521517
{
522518
.lane_rate = 720000000,
523-
.lanes = 2,
524-
.hmax_min = 2032,
519+
.hmax_min = { 2032, 1066 },
525520
.reg_list = {
526-
.num_of_regs = ARRAY_SIZE(imx415_mode_2_720),
527-
.regs = imx415_mode_2_720,
521+
.num_of_regs = ARRAY_SIZE(imx415_linkrate_720mbps),
522+
.regs = imx415_linkrate_720mbps,
528523
},
529524
},
530525
{
531526
.lane_rate = 1440000000,
532-
.lanes = 2,
533-
.hmax_min = 1066,
527+
.hmax_min = { 1066, 533 },
534528
.reg_list = {
535-
.num_of_regs = ARRAY_SIZE(imx415_mode_2_1440),
536-
.regs = imx415_mode_2_1440,
529+
.num_of_regs = ARRAY_SIZE(imx415_linkrate_1440mbps),
530+
.regs = imx415_linkrate_1440mbps,
537531
},
538532
},
539533
{
540534
.lane_rate = 891000000,
541-
.lanes = 4,
542-
.hmax_min = 1100,
535+
.hmax_min = { 1100, 550 },
543536
.reg_list = {
544-
.num_of_regs = ARRAY_SIZE(imx415_mode_4_891),
545-
.regs = imx415_mode_4_891,
537+
.num_of_regs = ARRAY_SIZE(imx415_linkrate_891mbps),
538+
.regs = imx415_linkrate_891mbps,
546539
},
547540
},
548541
};
@@ -876,7 +869,7 @@ static int imx415_ctrls_init(struct imx415 *sensor)
876869
IMX415_AGAIN_MAX, IMX415_AGAIN_STEP,
877870
IMX415_AGAIN_MIN);
878871

879-
hblank_min = (supported_modes[sensor->cur_mode].hmax_min *
872+
hblank_min = (supported_modes[sensor->cur_mode].hmax_min[sensor->num_data_lanes == 2 ? 0 : 1] *
880873
IMX415_HMAX_MULTIPLIER) - IMX415_PIXEL_ARRAY_WIDTH;
881874
hblank_max = (IMX415_HMAX_MAX * IMX415_HMAX_MULTIPLIER) -
882875
IMX415_PIXEL_ARRAY_WIDTH;
@@ -944,7 +937,11 @@ static int imx415_set_mode(struct imx415 *sensor, int mode)
944937
return ret;
945938
}
946939

947-
return 0;
940+
ret = imx415_write(sensor, IMX415_LANEMODE,
941+
sensor->num_data_lanes == 2 ? IMX415_LANEMODE_2 :
942+
IMX415_LANEMODE_4);
943+
944+
return ret;
948945
}
949946

950947
static int imx415_setup(struct imx415 *sensor, struct v4l2_subdev_state *state)
@@ -1373,8 +1370,6 @@ static int imx415_parse_hw_config(struct imx415 *sensor)
13731370
}
13741371

13751372
for (j = 0; j < ARRAY_SIZE(supported_modes); ++j) {
1376-
if (sensor->num_data_lanes != supported_modes[j].lanes)
1377-
continue;
13781373
if (bus_cfg.link_frequencies[i] * 2 !=
13791374
supported_modes[j].lane_rate)
13801375
continue;

0 commit comments

Comments
 (0)