Message ID | 20250219094637.607615-4-eagle.alexander923@gmail.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [1/4] media: i2c: imx415: Add get_mbus_config() pad operation support | expand |
Hi Alexander On Wed, 19 Feb 2025 at 09:48, Alexander Shiyan <eagle.alexander923@gmail.com> wrote: > > Not all CSI configurations are suitable for both 2-lane and 4-lane mode. > To solve this, let's use a zero value in the hmax_min[] field of the > supported_modes[] structure to indicate which CSI configuration can not > be used for 2-lane or 4-lane mode. > Now that we have done that, let's add the remaining CSI configurations > that can be used for 4-lane mode. > > Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com> > --- > drivers/media/i2c/imx415.c | 46 ++++++++++++++++++++++++++++++++++++++ > 1 file changed, 46 insertions(+) > > diff --git a/drivers/media/i2c/imx415.c b/drivers/media/i2c/imx415.c > index 83b7929455b2..5f18d3f38ded 100644 > --- a/drivers/media/i2c/imx415.c > +++ b/drivers/media/i2c/imx415.c > @@ -505,6 +505,19 @@ static const struct cci_reg_sequence imx415_linkrate_1440mbps[] = { > { IMX415_TLPX, 0x004F }, > }; > > +/* 1485 Mbps CSI configuration */ > +static const struct cci_reg_sequence imx415_linkrate_1485mbps[] = { > + { IMX415_TCLKPOST, 0x00A7 }, > + { IMX415_TCLKPREPARE, 0x0057 }, > + { IMX415_TCLKTRAIL, 0x005F }, > + { IMX415_TCLKZERO, 0x0197 }, > + { IMX415_THSPREPARE, 0x005F }, > + { IMX415_THSZERO, 0x00AF }, > + { IMX415_THSTRAIL, 0x005F }, > + { IMX415_THSEXIT, 0x009F }, > + { IMX415_TLPX, 0x004F }, > +}; > + > /* 1782 Mbps CSI configuration */ > static const struct cci_reg_sequence imx415_linkrate_1782mbps[] = { > { IMX415_TCLKPOST, 0x00B7 }, > @@ -531,6 +544,19 @@ static const struct cci_reg_sequence imx415_linkrate_2079mbps[] = { > { IMX415_TLPX, 0x006F }, > }; > > +/* 2376 Mbps CSI configuration */ > +static const struct cci_reg_sequence imx415_linkrate_2376mbps[] = { > + { IMX415_TCLKPOST, 0x00E7 }, > + { IMX415_TCLKPREPARE, 0x008F }, > + { IMX415_TCLKTRAIL, 0x008F }, > + { IMX415_TCLKZERO, 0x027F }, > + { IMX415_THSPREPARE, 0x0097 }, > + { IMX415_THSZERO, 0x010F }, > + { IMX415_THSTRAIL, 0x0097 }, > + { IMX415_THSEXIT, 0x00F7 }, > + { IMX415_TLPX, 0x007F }, > +}; > + > struct imx415_mode_reg_list { > u32 num_of_regs; > const struct cci_reg_sequence *regs; > @@ -576,6 +602,14 @@ static const struct imx415_mode supported_modes[] = { > .regs = imx415_linkrate_1440mbps, > }, > }, > + { > + .lane_rate = 1485000000, > + .hmax_min = { 0, 550 }, > + .reg_list = { > + .num_of_regs = ARRAY_SIZE(imx415_linkrate_1485mbps), > + .regs = imx415_linkrate_1485mbps, > + }, > + }, > { > .lane_rate = 1782000000, > .hmax_min = { 1100, 550 }, > @@ -592,6 +626,14 @@ static const struct imx415_mode supported_modes[] = { > .regs = imx415_linkrate_2079mbps, > }, > }, > + { > + .lane_rate = 2376000000, > + .hmax_min = { 0, 366 }, > + .reg_list = { > + .num_of_regs = ARRAY_SIZE(imx415_linkrate_2376mbps), > + .regs = imx415_linkrate_2376mbps, > + }, > + }, > }; > > static const char *const imx415_test_pattern_menu[] = { > @@ -1375,9 +1417,13 @@ static int imx415_parse_hw_config(struct imx415 *sensor) > } > > for (j = 0; j < ARRAY_SIZE(supported_modes); ++j) { > + int lanes_idx = sensor->num_data_lanes == 2 ? 0 : 1; > + > if (bus_cfg.link_frequencies[i] * 2 != > supported_modes[j].lane_rate) > continue; > + if (!supported_modes[j].hmax_min[lanes_idx]) > + continue; You could lose the local variable by checking if (!supported_modes[j].hmax_min[0] && sensor->num_data_lanes == 2) Either way: Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com> I've checked the register settings against the datasheet, and they all appear to match. > sensor->cur_mode = j; > break; > } > -- > 2.39.1 > >
diff --git a/drivers/media/i2c/imx415.c b/drivers/media/i2c/imx415.c index 83b7929455b2..5f18d3f38ded 100644 --- a/drivers/media/i2c/imx415.c +++ b/drivers/media/i2c/imx415.c @@ -505,6 +505,19 @@ static const struct cci_reg_sequence imx415_linkrate_1440mbps[] = { { IMX415_TLPX, 0x004F }, }; +/* 1485 Mbps CSI configuration */ +static const struct cci_reg_sequence imx415_linkrate_1485mbps[] = { + { IMX415_TCLKPOST, 0x00A7 }, + { IMX415_TCLKPREPARE, 0x0057 }, + { IMX415_TCLKTRAIL, 0x005F }, + { IMX415_TCLKZERO, 0x0197 }, + { IMX415_THSPREPARE, 0x005F }, + { IMX415_THSZERO, 0x00AF }, + { IMX415_THSTRAIL, 0x005F }, + { IMX415_THSEXIT, 0x009F }, + { IMX415_TLPX, 0x004F }, +}; + /* 1782 Mbps CSI configuration */ static const struct cci_reg_sequence imx415_linkrate_1782mbps[] = { { IMX415_TCLKPOST, 0x00B7 }, @@ -531,6 +544,19 @@ static const struct cci_reg_sequence imx415_linkrate_2079mbps[] = { { IMX415_TLPX, 0x006F }, }; +/* 2376 Mbps CSI configuration */ +static const struct cci_reg_sequence imx415_linkrate_2376mbps[] = { + { IMX415_TCLKPOST, 0x00E7 }, + { IMX415_TCLKPREPARE, 0x008F }, + { IMX415_TCLKTRAIL, 0x008F }, + { IMX415_TCLKZERO, 0x027F }, + { IMX415_THSPREPARE, 0x0097 }, + { IMX415_THSZERO, 0x010F }, + { IMX415_THSTRAIL, 0x0097 }, + { IMX415_THSEXIT, 0x00F7 }, + { IMX415_TLPX, 0x007F }, +}; + struct imx415_mode_reg_list { u32 num_of_regs; const struct cci_reg_sequence *regs; @@ -576,6 +602,14 @@ static const struct imx415_mode supported_modes[] = { .regs = imx415_linkrate_1440mbps, }, }, + { + .lane_rate = 1485000000, + .hmax_min = { 0, 550 }, + .reg_list = { + .num_of_regs = ARRAY_SIZE(imx415_linkrate_1485mbps), + .regs = imx415_linkrate_1485mbps, + }, + }, { .lane_rate = 1782000000, .hmax_min = { 1100, 550 }, @@ -592,6 +626,14 @@ static const struct imx415_mode supported_modes[] = { .regs = imx415_linkrate_2079mbps, }, }, + { + .lane_rate = 2376000000, + .hmax_min = { 0, 366 }, + .reg_list = { + .num_of_regs = ARRAY_SIZE(imx415_linkrate_2376mbps), + .regs = imx415_linkrate_2376mbps, + }, + }, }; static const char *const imx415_test_pattern_menu[] = { @@ -1375,9 +1417,13 @@ static int imx415_parse_hw_config(struct imx415 *sensor) } for (j = 0; j < ARRAY_SIZE(supported_modes); ++j) { + int lanes_idx = sensor->num_data_lanes == 2 ? 0 : 1; + if (bus_cfg.link_frequencies[i] * 2 != supported_modes[j].lane_rate) continue; + if (!supported_modes[j].hmax_min[lanes_idx]) + continue; sensor->cur_mode = j; break; }
Not all CSI configurations are suitable for both 2-lane and 4-lane mode. To solve this, let's use a zero value in the hmax_min[] field of the supported_modes[] structure to indicate which CSI configuration can not be used for 2-lane or 4-lane mode. Now that we have done that, let's add the remaining CSI configurations that can be used for 4-lane mode. Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com> --- drivers/media/i2c/imx415.c | 46 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+)