Skip to content

Commit 8637b97

Browse files
committed
media: i2c: imx415: Add support for further link rates
The sensor supports more link rates than the 3 currently supported, although some are only listed as being valid when running with 2 data lanes. Add these additional modes, with setting hblank_min to 0 to denote that it is invalid in that mode. Signed-off-by: Dave Stevenson <[email protected]> --- I'm unable to successfully test 2376Mbit/s mode as it exceeds the hardware specs of the Pi5 CSI2 block. I get an image, but it's got incorrect colours, even with the horizontal timings extended significantly. All the register values follow the datasheet though. I have a suspicion that the modes listed as not permitted in a 2 lanes configuration will work, but I haven't the time to test it at present. Likewise the hmax_min values can almost certainly be decreased as it looks like Sony are just listing values for nice round frame rate values, not the limits. I can't determine the limits easily as Pi5 is limited to a maximum rate of approx 380MPix/s so can't run this sensor above 43fps.
1 parent e4bcd6a commit 8637b97

File tree

1 file changed

+114
-1
lines changed

1 file changed

+114
-1
lines changed

drivers/media/i2c/imx415.c

Lines changed: 114 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ static const char *const imx415_supply_names[] = {
109109
*/
110110
static const s64 link_freq_menu_items[] = {
111111
594000000 / 2, 720000000 / 2, 891000000 / 2,
112-
1440000000 / 2, 1485000000 / 2,
112+
1440000000 / 2, 1485000000 / 2, 1782000000 / 2,
113+
2079000000 / 2, 2376000000 / 2,
113114
};
114115

115116
struct imx415_clk_params {
@@ -452,6 +453,19 @@ static const struct imx415_clk_params imx415_clk_params[] = {
452453
},
453454
};
454455

456+
/* 594 Mbps CSI configuration */
457+
static const struct cci_reg_sequence imx415_linkrate_594mbps[] = {
458+
{ IMX415_TCLKPOST, 0x0067 },
459+
{ IMX415_TCLKPREPARE, 0x0027 },
460+
{ IMX415_TCLKTRAIL, 0x0027 },
461+
{ IMX415_TCLKZERO, 0x00B7 },
462+
{ IMX415_THSPREPARE, 0x002F },
463+
{ IMX415_THSZERO, 0x004F },
464+
{ IMX415_THSTRAIL, 0x002F },
465+
{ IMX415_THSEXIT, 0x0047 },
466+
{ IMX415_TLPX, 0x0027 },
467+
};
468+
455469
/* 720 Mbps CSI configuration */
456470
static const struct cci_reg_sequence imx415_linkrate_720mbps[] = {
457471
{ IMX415_TCLKPOST, 0x006F },
@@ -491,6 +505,58 @@ static const struct cci_reg_sequence imx415_linkrate_891mbps[] = {
491505
{ IMX415_TLPX, 0x002F },
492506
};
493507

508+
/* 1485 Mbps CSI configuration */
509+
static const struct cci_reg_sequence imx415_linkrate_1485mbps[] = {
510+
{ IMX415_TCLKPOST, 0x00A7 },
511+
{ IMX415_TCLKPREPARE, 0x0057 },
512+
{ IMX415_TCLKTRAIL, 0x005F },
513+
{ IMX415_TCLKZERO, 0x0197 },
514+
{ IMX415_THSPREPARE, 0x005F },
515+
{ IMX415_THSZERO, 0x00AF },
516+
{ IMX415_THSTRAIL, 0x005F },
517+
{ IMX415_THSEXIT, 0x009F },
518+
{ IMX415_TLPX, 0x004F },
519+
};
520+
521+
/* 1782 Mbps CSI configuration */
522+
static const struct cci_reg_sequence imx415_linkrate_1782mbps[] = {
523+
{ IMX415_TCLKPOST, 0x00B7 },
524+
{ IMX415_TCLKPREPARE, 0x0067 },
525+
{ IMX415_TCLKTRAIL, 0x006F },
526+
{ IMX415_TCLKZERO, 0x01DF },
527+
{ IMX415_THSPREPARE, 0x006F },
528+
{ IMX415_THSZERO, 0x00CF },
529+
{ IMX415_THSTRAIL, 0x006F },
530+
{ IMX415_THSEXIT, 0x00B7 },
531+
{ IMX415_TLPX, 0x005F },
532+
};
533+
534+
/* 2079 Mbps CSI configuration */
535+
static const struct cci_reg_sequence imx415_linkrate_2079mbps[] = {
536+
{ IMX415_TCLKPOST, 0x00D7 },
537+
{ IMX415_TCLKPREPARE, 0x007F },
538+
{ IMX415_TCLKTRAIL, 0x007F },
539+
{ IMX415_TCLKZERO, 0x0237 },
540+
{ IMX415_THSPREPARE, 0x0087 },
541+
{ IMX415_THSZERO, 0x00EF },
542+
{ IMX415_THSTRAIL, 0x0087 },
543+
{ IMX415_THSEXIT, 0x00DF },
544+
{ IMX415_TLPX, 0x006F },
545+
};
546+
547+
/* 2376 Mbps CSI configuration */
548+
static const struct cci_reg_sequence imx415_linkrate_2376mbps[] = {
549+
{ IMX415_TCLKPOST, 0x00E7 },
550+
{ IMX415_TCLKPREPARE, 0x008F },
551+
{ IMX415_TCLKTRAIL, 0x008F },
552+
{ IMX415_TCLKZERO, 0x027F },
553+
{ IMX415_THSPREPARE, 0x0097 },
554+
{ IMX415_THSZERO, 0x010F },
555+
{ IMX415_THSTRAIL, 0x0097 },
556+
{ IMX415_THSEXIT, 0x00F7 },
557+
{ IMX415_TLPX, 0x007F },
558+
};
559+
494560
struct imx415_mode_reg_list {
495561
u32 num_of_regs;
496562
const struct cci_reg_sequence *regs;
@@ -504,6 +570,15 @@ struct imx415_mode {
504570

505571
/* mode configs */
506572
static const struct imx415_mode supported_modes[] = {
573+
{
574+
.lane_rate = 594000000,
575+
/* 2 lane mode lists 10fps. 4 lane mode lists 25fps */
576+
.hmax_min = { 3300, 1320 },
577+
.reg_list = {
578+
.num_of_regs = ARRAY_SIZE(imx415_linkrate_594mbps),
579+
.regs = imx415_linkrate_594mbps,
580+
},
581+
},
507582
{
508583
.lane_rate = 720000000,
509584
.hmax_min = { 2032, 1066 },
@@ -528,6 +603,40 @@ static const struct imx415_mode supported_modes[] = {
528603
.regs = imx415_linkrate_1440mbps,
529604
},
530605
},
606+
{
607+
.lane_rate = 1485000000,
608+
/* Datasheet says this lane rate is only supported on 4 lanes */
609+
.hmax_min = { 0, 550 },
610+
.reg_list = {
611+
.num_of_regs = ARRAY_SIZE(imx415_linkrate_1485mbps),
612+
.regs = imx415_linkrate_1485mbps,
613+
},
614+
},
615+
{
616+
.lane_rate = 1782000000,
617+
.hmax_min = { 1100, 550 },
618+
.reg_list = {
619+
.num_of_regs = ARRAY_SIZE(imx415_linkrate_1782mbps),
620+
.regs = imx415_linkrate_1782mbps,
621+
},
622+
},
623+
{
624+
.lane_rate = 2079000000,
625+
.hmax_min = { 1100, 550 },
626+
.reg_list = {
627+
.num_of_regs = ARRAY_SIZE(imx415_linkrate_2079mbps),
628+
.regs = imx415_linkrate_2079mbps,
629+
},
630+
},
631+
{
632+
.lane_rate = 2376000000,
633+
/* Datasheet says this lane rate is only supported on 4 lanes */
634+
.hmax_min = { 0, 366 },
635+
.reg_list = {
636+
.num_of_regs = ARRAY_SIZE(imx415_linkrate_2376mbps),
637+
.regs = imx415_linkrate_2376mbps,
638+
},
639+
},
531640
};
532641

533642
static const char *const imx415_test_pattern_menu[] = {
@@ -1300,6 +1409,10 @@ static int imx415_parse_hw_config(struct imx415 *sensor)
13001409
if (bus_cfg.link_frequencies[i] * 2 !=
13011410
supported_modes[j].lane_rate)
13021411
continue;
1412+
if (sensor->num_data_lanes == 2 &&
1413+
!supported_modes[j].hmax_min[0])
1414+
continue;
1415+
13031416
sensor->cur_mode = j;
13041417
break;
13051418
}

0 commit comments

Comments
 (0)