Re: [PATCH RFC 2/4] media: i2c: imx678: Parameterise the configuration to allow for other models
From: Jai Luthra
Date: Thu Sep 03 2026 - 00:17:29 EST
Quoting Dave Stevenson (2026-08-05 21:39:17)
> Several of the Sony Starvis 2 sensors are identical in the
> majority of their programming, but differ largely only in the
> size of pixel array and some timing parameters.
>
> Parameterise those parameters in preparation for supporting other
> variants.
>
> Signed-off-by: Dave Stevenson <dave.stevenson@xxxxxxxxxxxxxxx>
> ---
> drivers/media/i2c/imx678.c | 161 +++++++++++++++++++++++++++++----------------
> 1 file changed, 106 insertions(+), 55 deletions(-)
>
> diff --git a/drivers/media/i2c/imx678.c b/drivers/media/i2c/imx678.c
> index f7b988dca2ac..40ba6661b366 100644
> --- a/drivers/media/i2c/imx678.c
> +++ b/drivers/media/i2c/imx678.c
> @@ -148,32 +148,11 @@
> /* Subdev pads */
> #define IMX678_SOURCE_PAD 0
>
> -/* IMX678 native and active pixel array size. */
> -static const struct v4l2_rect imx678_native_area = {
> - .top = 0,
> - .left = 0,
> - .width = 3857,
> - .height = 2201,
> -};
> -
> -static const struct v4l2_rect imx678_active_area = {
> - .top = 20,
> - .left = 0,
> - .width = 3856,
> - .height = 2180,
> -};
> -
> enum imx678_type {
> IMX678_COLOR = 0,
> IMX678_MONOCHROME = 1,
> };
>
> -struct imx678_model_info {
> - enum imx678_type type;
> - const u32 *codes;
> - unsigned int num_codes;
> -};
> -
> enum imx678_lanemode {
> IMX678_LANEMODE_2L = 1,
> IMX678_LANEMODE_4L = 3,
> @@ -213,7 +192,7 @@ static const u64 link_freqs[] = {
> [IMX678_LINK_FREQ_1188MHZ] = 1188000000,
> };
>
> -static const u16 min_hmax_4lane[] = {
> +static const u16 imx678_min_hmax_4lane[] = {
> [IMX678_LINK_FREQ_297MHZ] = 1584,
> [IMX678_LINK_FREQ_360MHZ] = 1320,
> [IMX678_LINK_FREQ_445MHZ] = 1100,
> @@ -273,7 +252,7 @@ static const int imx678_tpg_val[] = {
> };
>
> /* Common configuration */
> -static const struct cci_reg_sequence common_regs[] = {
> +static const struct cci_reg_sequence imx678_common_regs[] = {
> { IMX678_REG_THIN_V_EN, 0x00 },
> { IMX678_REG_VCMODE, 0x01 },
> { CCI_REG8(0x306b), 0x00 },
> @@ -656,16 +635,72 @@ static const u32 codes_monochrome[] = {
> MEDIA_BUS_FMT_Y12_1X12,
> };
>
> +struct imx678_variant {
> + const char *name;
> + u32 id_reg;
> + u32 id_value;
> + struct v4l2_rect native_area;
> + struct v4l2_rect active_area;
> + u64 pixel_rate;
> + unsigned int pix_per_clk;
> + const struct cci_reg_sequence *common_regs;
> + unsigned int num_common_regs;
> + unsigned int vmax_default;
> + const u16 *hmax_min;
> +};
> +
> +const struct imx678_variant imx678_variant_def = {
> + .name = "imx678",
> + .id_reg = IMX678_REG_MODULE_ID,
> + .id_value = IMX678_ID,
> + .native_area = {
> + .top = 0,
> + .left = 0,
> + .width = 3857,
> + .height = 2201,
> + },
> + .active_area = {
> + .top = 20,
> + .left = 0,
> + .width = 3856,
> + .height = 2180,
> + },
> + .pixel_rate = IMX678_PIXEL_RATE,
> + .pix_per_clk = IMX678_PIX_PER_CLK,
> + .common_regs = imx678_common_regs,
> + .num_common_regs = ARRAY_SIZE(imx678_common_regs),
> + .vmax_default = IMX678_VMAX_DEFAULT,
There are a couple of places where IMX678_PIX_PER_CLK and
IMX678_VMAX_DEFAULT were still being used. I've fixed those in my branch:
https://github.com/jailuthra/linux/commit/3c656e370e06ceb41e69ba0406f685d4556133d0
Thanks,
Jai
[...]