Skip to content

Commit 7cdbd16

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 843f37f commit 7cdbd16

File tree

1 file changed

+23
-27
lines changed

1 file changed

+23
-27
lines changed

drivers/media/i2c/imx415.c

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -452,9 +452,8 @@ static const struct imx415_clk_params imx415_clk_params[] = {
452452
},
453453
};
454454

455-
/* all-pixel 2-lane 720 Mbps 15.74 Hz mode */
456-
static const struct cci_reg_sequence imx415_mode_2_720[] = {
457-
{ IMX415_LANEMODE, IMX415_LANEMODE_2 },
455+
/* 720 Mbps CSI configuration */
456+
static const struct cci_reg_sequence imx415_linkrate_720mbps[] = {
458457
{ IMX415_TCLKPOST, 0x006F },
459458
{ IMX415_TCLKPREPARE, 0x002F },
460459
{ IMX415_TCLKTRAIL, 0x002F },
@@ -466,9 +465,8 @@ static const struct cci_reg_sequence imx415_mode_2_720[] = {
466465
{ IMX415_TLPX, 0x0027 },
467466
};
468467

469-
/* all-pixel 2-lane 1440 Mbps 30.01 Hz mode */
470-
static const struct cci_reg_sequence imx415_mode_2_1440[] = {
471-
{ IMX415_LANEMODE, IMX415_LANEMODE_2 },
468+
/* 1440 Mbps CSI configuration */
469+
static const struct cci_reg_sequence imx415_linkrate_1440mbps[] = {
472470
{ IMX415_TCLKPOST, 0x009F },
473471
{ IMX415_TCLKPREPARE, 0x0057 },
474472
{ IMX415_TCLKTRAIL, 0x0057 },
@@ -480,9 +478,8 @@ static const struct cci_reg_sequence imx415_mode_2_1440[] = {
480478
{ IMX415_TLPX, 0x004F },
481479
};
482480

483-
/* all-pixel 4-lane 891 Mbps 30 Hz mode */
484-
static const struct cci_reg_sequence imx415_mode_4_891[] = {
485-
{ IMX415_LANEMODE, IMX415_LANEMODE_4 },
481+
/* 891 Mbps CSI configuration */
482+
static const struct cci_reg_sequence imx415_linkrate_891mbps[] = {
486483
{ IMX415_TCLKPOST, 0x007F },
487484
{ IMX415_TCLKPREPARE, 0x0037 },
488485
{ IMX415_TCLKTRAIL, 0x0037 },
@@ -501,38 +498,34 @@ struct imx415_mode_reg_list {
501498

502499
struct imx415_mode {
503500
u64 lane_rate;
504-
u32 lanes;
505-
u32 hmax_min;
501+
u32 hmax_min[2];
506502
struct imx415_mode_reg_list reg_list;
507503
};
508504

509505
/* mode configs */
510506
static const struct imx415_mode supported_modes[] = {
511507
{
512508
.lane_rate = 720000000,
513-
.lanes = 2,
514-
.hmax_min = 2032,
509+
.hmax_min = { 2032, 1066 },
515510
.reg_list = {
516-
.num_of_regs = ARRAY_SIZE(imx415_mode_2_720),
517-
.regs = imx415_mode_2_720,
511+
.num_of_regs = ARRAY_SIZE(imx415_linkrate_720mbps),
512+
.regs = imx415_linkrate_720mbps,
518513
},
519514
},
520515
{
521516
.lane_rate = 1440000000,
522-
.lanes = 2,
523-
.hmax_min = 1066,
517+
.hmax_min = { 1066, 533 },
524518
.reg_list = {
525-
.num_of_regs = ARRAY_SIZE(imx415_mode_2_1440),
526-
.regs = imx415_mode_2_1440,
519+
.num_of_regs = ARRAY_SIZE(imx415_linkrate_1440mbps),
520+
.regs = imx415_linkrate_1440mbps,
527521
},
528522
},
529523
{
530524
.lane_rate = 891000000,
531-
.lanes = 4,
532-
.hmax_min = 1100,
525+
.hmax_min = { 1100, 550 },
533526
.reg_list = {
534-
.num_of_regs = ARRAY_SIZE(imx415_mode_4_891),
535-
.regs = imx415_mode_4_891,
527+
.num_of_regs = ARRAY_SIZE(imx415_linkrate_891mbps),
528+
.regs = imx415_linkrate_891mbps,
536529
},
537530
},
538531
};
@@ -823,7 +816,7 @@ static int imx415_ctrls_init(struct imx415 *sensor)
823816
IMX415_AGAIN_MAX, IMX415_AGAIN_STEP,
824817
IMX415_AGAIN_MIN);
825818

826-
hblank_min = (supported_modes[sensor->cur_mode].hmax_min *
819+
hblank_min = (supported_modes[sensor->cur_mode].hmax_min[sensor->num_data_lanes == 2 ? 0 : 1] *
827820
IMX415_HMAX_MULTIPLIER) - IMX415_PIXEL_ARRAY_WIDTH;
828821
hblank_max = (IMX415_HMAX_MAX * IMX415_HMAX_MULTIPLIER) -
829822
IMX415_PIXEL_ARRAY_WIDTH;
@@ -885,7 +878,12 @@ static int imx415_set_mode(struct imx415 *sensor, int mode)
885878
IMX415_NUM_CLK_PARAM_REGS,
886879
&ret);
887880

888-
return 0;
881+
ret = cci_write(sensor->regmap, IMX415_LANEMODE,
882+
sensor->num_data_lanes == 2 ? IMX415_LANEMODE_2 :
883+
IMX415_LANEMODE_4,
884+
NULL);
885+
886+
return ret;
889887
}
890888

891889
static int imx415_setup(struct imx415 *sensor, struct v4l2_subdev_state *state)
@@ -1297,8 +1295,6 @@ static int imx415_parse_hw_config(struct imx415 *sensor)
12971295
}
12981296

12991297
for (j = 0; j < ARRAY_SIZE(supported_modes); ++j) {
1300-
if (sensor->num_data_lanes != supported_modes[j].lanes)
1301-
continue;
13021298
if (bus_cfg.link_frequencies[i] * 2 !=
13031299
supported_modes[j].lane_rate)
13041300
continue;

0 commit comments

Comments
 (0)