Devicetree
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Jai Luthra <jai.luthra@ideasonboard.com>
Cc: Dave Stevenson <dave.stevenson@raspberrypi.com>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Alexander Shiyan <eagle.alexander923@gmail.com>,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	devicetree@vger.kernel.org
Subject: Re: [PATCH v7 11/18] media: sony-starvis2: Add support for IMX662
Date: Tue, 1 Dec 2026 14:21:27 +0900	[thread overview]
Message-ID: <20261201052127.GS24781@killaraus.ideasonboard.com> (raw)
In-Reply-To: <179605595333.15503.5537212855160862455@freya>

On Mon, Nov 30, 2026 at 09:55:53PM +0530, Jai Luthra wrote:
> Quoting Dave Stevenson (2026-11-30 21:13:12)
> > On Mon, 30 Nov 2026 at 04:08, Laurent Pinchart wrote:
> > > On Thu, Oct 29, 2026 at 02:18:32PM +0000, Dave Stevenson wrote:
> > > > IMX662 is a 1080p Starvis 2 sensor that follows the same programming
> > > > pattern as IMX678, so add it to the newly parameterised common
> > > > driver.
> > > >
> > > > Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
> > > > ---
> > > >  drivers/media/i2c/sony-starvis2.c | 155 ++++++++++++++++++++++++++++++++++++++
> > > >  1 file changed, 155 insertions(+)
> > > >
> > > > diff --git a/drivers/media/i2c/sony-starvis2.c b/drivers/media/i2c/sony-starvis2.c
> > > > index 27357cc293be..2db9ac28308a 100644
> > > > --- a/drivers/media/i2c/sony-starvis2.c
> > > > +++ b/drivers/media/i2c/sony-starvis2.c
> > > > @@ -8,6 +8,8 @@
> > > >   * Currently supported are:
> > > >   * IMX678: Diagonal 8.86 mm (Type 1/1.8) CMOS image sensor with 8.40 M effective
> > > >   *         pixels.
> > > > + * IMX662: Diagonal 6.45mm (Type 1/2.8) CMOS image sensor with 2.12 M effective
> > > > + *         pixels.
> > >
> > > Let's sort entries alphabetically, here and everywhere below.
> > >
> > > >   *
> > > >   * Copyright (C) 2026 Ideas On Board Oy.
> > > >   * Copyright (C) 2026 Raspberry Pi
> > > > @@ -663,6 +665,136 @@ static const struct starvis2_variant imx678_variant_def = {
> > > >       .hmax_min_pixel_array = 550,
> > > >  };
> > > >
> > > > +static const struct cci_reg_sequence imx662_common_regs[] = {
> > > > +     { CCI_REG8(0x3444), 0xac },
> > > > +     { CCI_REG8(0x3492), 0x08 },
> > > > +     { CCI_REG8(0x3b00), 0x39 },
> > > > +     { CCI_REG8(0x3b23), 0x2d },
> > > > +     { CCI_REG8(0x3b45), 0x04 },
> > > > +     { CCI_REG8(0x3c0a), 0x1f },
> > > > +     { CCI_REG8(0x3c0b), 0x1e },
> > > > +     { CCI_REG8(0x3c38), 0x21 },
> > > > +     { CCI_REG8(0x3c44), 0x00 },
> > > > +     { CCI_REG8(0x3cb6), 0xd8 },
> > > > +     { CCI_REG8(0x3cc4), 0xda },
> > > > +     { CCI_REG8(0x3e24), 0x79 },
> > > > +     { CCI_REG8(0x3e2c), 0x15 },
> > > > +     { CCI_REG8(0x3edc), 0x2d },
> > > > +     { CCI_REG8(0x4498), 0x05 },
> > > > +     { CCI_REG8(0x449c), 0x19 },
> > > > +     { CCI_REG8(0x449d), 0x00 },
> > > > +     { CCI_REG8(0x449e), 0x32 },
> > > > +     { CCI_REG8(0x449f), 0x01 },
> > > > +     { CCI_REG8(0x44a0), 0x92 },
> > > > +     { CCI_REG8(0x44a2), 0x91 },
> > > > +     { CCI_REG8(0x44a4), 0x8c },
> > > > +     { CCI_REG8(0x44a6), 0x87 },
> > > > +     { CCI_REG8(0x44a8), 0x82 },
> > > > +     { CCI_REG8(0x44aa), 0x78 },
> > > > +     { CCI_REG8(0x44ac), 0x6e },
> > > > +     { CCI_REG8(0x44ae), 0x69 },
> > > > +     { CCI_REG8(0x44b0), 0x92 },
> > > > +     { CCI_REG8(0x44b2), 0x91 },
> > > > +     { CCI_REG8(0x44b4), 0x8c },
> > > > +     { CCI_REG8(0x44b6), 0x87 },
> > > > +     { CCI_REG8(0x44b8), 0x82 },
> > > > +     { CCI_REG8(0x44ba), 0x78 },
> > > > +     { CCI_REG8(0x44bc), 0x6e },
> > > > +     { CCI_REG8(0x44be), 0x69 },
> > > > +     { CCI_REG8(0x44c0), 0x7f },
> > > > +     { CCI_REG8(0x44c1), 0x01 },
> > > > +     { CCI_REG8(0x44c2), 0x7f },
> > > > +     { CCI_REG8(0x44c3), 0x01 },
> > > > +     { CCI_REG8(0x44c4), 0x7a },
> > > > +     { CCI_REG8(0x44c5), 0x01 },
> > > > +     { CCI_REG8(0x44c6), 0x7a },
> > > > +     { CCI_REG8(0x44c7), 0x01 },
> > > > +     { CCI_REG8(0x44c8), 0x70 },
> > > > +     { CCI_REG8(0x44c9), 0x01 },
> > > > +     { CCI_REG8(0x44ca), 0x6b },
> > > > +     { CCI_REG8(0x44cb), 0x01 },
> > > > +     { CCI_REG8(0x44cc), 0x6b },
> > > > +     { CCI_REG8(0x44cd), 0x01 },
> > > > +     { CCI_REG8(0x44ce), 0x5c },
> > > > +     { CCI_REG8(0x44cf), 0x01 },
> > > > +     { CCI_REG8(0x44d0), 0x7f },
> > > > +     { CCI_REG8(0x44d1), 0x01 },
> > > > +     { CCI_REG8(0x44d2), 0x7f },
> > > > +     { CCI_REG8(0x44d3), 0x01 },
> > > > +     { CCI_REG8(0x44d4), 0x7a },
> > > > +     { CCI_REG8(0x44d5), 0x01 },
> > > > +     { CCI_REG8(0x44d6), 0x7a },
> > > > +     { CCI_REG8(0x44d7), 0x01 },
> > > > +     { CCI_REG8(0x44d8), 0x70 },
> > > > +     { CCI_REG8(0x44d9), 0x01 },
> > > > +     { CCI_REG8(0x44da), 0x6b },
> > > > +     { CCI_REG8(0x44db), 0x01 },
> > > > +     { CCI_REG8(0x44dc), 0x6b },
> > > > +     { CCI_REG8(0x44dd), 0x01 },
> > > > +     { CCI_REG8(0x44de), 0x5c },
> > > > +     { CCI_REG8(0x44df), 0x01 },
> > > > +     { CCI_REG8(0x4534), 0x1c },
> > > > +     { CCI_REG8(0x4535), 0x03 },
> > > > +     { CCI_REG8(0x4538), 0x1c },
> > > > +     { CCI_REG8(0x4539), 0x1c },
> > > > +     { CCI_REG8(0x453a), 0x1c },
> > > > +     { CCI_REG8(0x453b), 0x1c },
> > > > +     { CCI_REG8(0x453c), 0x1c },
> > > > +     { CCI_REG8(0x453d), 0x1c },
> > > > +     { CCI_REG8(0x453e), 0x1c },
> > > > +     { CCI_REG8(0x453f), 0x1c },
> > > > +     { CCI_REG8(0x4540), 0x1c },
> > > > +     { CCI_REG8(0x4541), 0x03 },
> > > > +     { CCI_REG8(0x4542), 0x03 },
> > > > +     { CCI_REG8(0x4543), 0x03 },
> > > > +     { CCI_REG8(0x4544), 0x03 },
> > > > +     { CCI_REG8(0x4545), 0x03 },
> > > > +     { CCI_REG8(0x4546), 0x03 },
> > > > +     { CCI_REG8(0x4547), 0x03 },
> > > > +     { CCI_REG8(0x4548), 0x03 },
> > > > +     { CCI_REG8(0x4549), 0x03 },
> > > > +     { STARVIS2_REG_WDMODE, 0x00 },
> > > > +     { STARVIS2_REG_MDBIT, 0x01 },
> > > > +     { STARVIS2_REG_XXS_DRV, 0x00 },
> > > > +};
> > > > +
> > > > +static const u16 imx662_min_hmax_2lane[] = {
> > > > +     [STARVIS2_LINK_FREQ_297MHZ] = 1980,
> > > > +     [STARVIS2_LINK_FREQ_360MHZ] = 1980,
> > > > +     [STARVIS2_LINK_FREQ_445MHZ] = 1188,
> > > > +     [STARVIS2_LINK_FREQ_594MHZ] = 990,
> > > > +     [STARVIS2_LINK_FREQ_720MHZ] = 990,
> > > > +     [STARVIS2_LINK_FREQ_891MHZ] = 990,
> > > > +     [STARVIS2_LINK_FREQ_1039MHZ] = 990,
> > > > +     [STARVIS2_LINK_FREQ_1188MHZ] = 990,
> > > > +};
> > > > +
> > > > +static const struct starvis2_variant imx662_variant_def = {
> > >
> > > There are no variants other than this one, so you can call it
> > > imx662_variant (or starvis2_variant_imx662). Same for all other models.
> > >
> > > > +     .name = "imx662",
> > > > +     .id_reg = CCI_REG16_LE(0x4d1c),
> > > > +     .id_mask = 0x3ff,
> > > > +     .id_value = 0x296,
> > > > +     .native_area = {
> > > > +             .top = 0,
> > > > +             .left = 0,
> > > > +             .width = 1937,
> > > > +             .height = 1101,
> > > > +     },
> > > > +     .active_area = {
> > > > +             .top = 0,
> > > > +             .left = 0,
> > > > +             .width = 1936,
> > > > +             .height = 1096,
> > > > +     },
> > > > +     .pixel_rate = 222750000,
> > > > +     .pix_per_clk = 3,
> > >
> > > 3 is a fairly strange value. Where does it come from ?
> > 
> > See your request to reinstate the comment
> > -/*
> > - * The internal readout clock runs at 74.25 MHz. In one cycle the AD reads 8
> > - * pixels, thus giving us a rate of 74.25 * 8 = 594 MPix/s
> > - */
> > It's the number of pixels per 74.25MHz clock that the sensor reads out.
> > IMX678 reads out 8. IMX662 reads out 3. HMAX is programmed in units of
> > 74.25MHz clock.
> > 
> > Same on IMX908 where it reads 16 pixels per 74.25MHz clock cycle.
> 
> I think for both IMX908 and Starvis 2 sensors, this multiplication factor
> can be mapped quite cleanly to the `num_of_vt_lanes` defined in the CCS
> specification (I know these sensors are no where close to that model, but
> still)
> 
> "line_length_pck shall be based on vt_pix_clk_freq_mhz * num_of_vt_lanes."
> 
> Which does make me think 3 is a bit odd (in both senses of the word), and a
> value of 4 might make more sense. We'll need input from Sony to be sure.

4 with a pixel rate of 297 MHz would not have looked odd to me. I don't
know if it's correct though, but if 3 is enough to avoid negative
hblank, then 4 should be fine too, and seems more logical.

> > (More likely there's a PLL multiplying by that factor rather than it
> > actually actioning multiple pixels per clock cycle, but that's
> > semantics)
> 
> But yes, for now I think 3 is fine. Practical implication of getting this
> wrong is reporting negative values for the HBLANK. IIRC you mentioned
> testing the sensor with various link frequencies and lanes to find the
> value of 3, so it should be alright.
> 
> > > > +     .common_regs = imx662_common_regs,
> > > > +     .num_common_regs = ARRAY_SIZE(imx662_common_regs),
> > > > +     .vmax_default = 1136,
> > > > +     .hmax_min_link_freq = imx662_min_hmax_2lane,
> > > > +     .hmax_min_pixel_array = 990,
> > > > +};
> > > > +
> > > >  struct starvis2_model_info {
> > > >       enum starvis2_type type;
> > > >       const u32 *codes;
> > > > @@ -693,6 +825,26 @@ static const struct starvis2_model_info imx678_autodetect_info = {
> > > >       .auto_detect_mono = &imx678_aamr_info,
> > > >  };
> > > >
> > > > +static const struct starvis2_model_info imx662_aaqr_info = {
> > > > +     .type = STARVIS2_COLOR,
> > > > +     .codes = codes_bayer,
> > > > +     .num_codes = ARRAY_SIZE(codes_bayer),
> > > > +     .variant = &imx662_variant_def,
> > > > +};
> > > > +
> > > > +static const struct starvis2_model_info imx662_aamr_info = {
> > > > +     .type = STARVIS2_MONOCHROME,
> > > > +     .codes = codes_monochrome,
> > > > +     .num_codes = ARRAY_SIZE(codes_monochrome),
> > > > +     .variant = &imx662_variant_def,
> > > > +};
> > >
> > > Given that the media bus codes are the same across all variants, it
> > > could be nice not to store them in starvis2_model_info structure.
> > 
> > Agreed, and I've just made the same comment on 4/12.
> > It was keeping the code in the same style as the original imx678,
> > although it was largely redundant there too.
> > 
> > > > +
> > > > +static const struct starvis2_model_info imx662_autodetect_info = {
> > > > +     .variant = &imx662_variant_def,
> > > > +     .auto_detect_colour = &imx662_aaqr_info,
> > > > +     .auto_detect_mono = &imx662_aamr_info,
> > > > +};
> > > > +
> > > >  static const char * const starvis2_supply_name[] = {
> > > >       "avdd",  /* Analog (3.3V) supply */
> > > >       "dvdd",  /* Digital Core (1.1V) supply */
> > > > @@ -1528,9 +1680,12 @@ static const struct dev_pm_ops starvis2_pm_ops = {
> > > >  };
> > > >
> > > >  static const struct of_device_id starvis2_of_match[] = {
> > > > +     { .compatible = "sony,imx662-aamr", .data = &imx662_aamr_info },
> > > > +     { .compatible = "sony,imx662-aaqr", .data = &imx662_aaqr_info },
> > > >       { .compatible = "sony,imx678-aamr", .data = &imx678_aamr_info },
> > > >       { .compatible = "sony,imx678-aaqr", .data = &imx678_aaqr_info },
> > > >       /* for non-conforming DTs that rely on runtime check */
> > > > +     { .compatible = "sony,imx662", .data = &imx662_autodetect_info },
> > >
> > > See my comment in 04/18.
> > >
> > > >       { .compatible = "sony,imx678", .data = &imx678_autodetect_info },
> > > >       { /* sentinel */ }
> > > >  };

-- 
Regards,

Laurent Pinchart

  reply	other threads:[~2026-12-01  5:21 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-29 14:18 [PATCH v7 00/18] Update imx678 to act as a common Sony Starvis 2 driver Dave Stevenson
2026-10-29 14:18 ` [PATCH v7 01/18] media: imx678: Rework into a common Starvis 2 sensor driver Dave Stevenson
2026-11-30  2:31   ` Laurent Pinchart
2026-10-29 14:18 ` [PATCH v7 02/18] media: sony-starvis2: Reorder link frequencies to remove lookup Dave Stevenson
2026-11-30  2:44   ` Laurent Pinchart
2026-11-30 14:16     ` Dave Stevenson
2026-12-01  3:49       ` Laurent Pinchart
2026-10-29 14:18 ` [PATCH v7 03/18] media: sony-starvis2: Always program the sensor in window mode Dave Stevenson
2026-11-30  2:46   ` Laurent Pinchart
2026-11-30 15:47     ` Dave Stevenson
2026-12-01  3:50       ` Laurent Pinchart
2026-10-29 14:18 ` [PATCH v7 04/18] media: sony-starvis2: Parameterise the configuration to allow for other models Dave Stevenson
2026-11-30  3:13   ` Laurent Pinchart
2026-11-30  4:08     ` Laurent Pinchart
2026-11-30 15:33       ` Dave Stevenson
2026-12-01  4:09         ` Laurent Pinchart
2026-10-29 14:18 ` [PATCH v7 05/18] media: sony-starvis2: Rework 2 lane support for higher link freqs Dave Stevenson
2026-10-29 14:18 ` [PATCH v7 06/18] media: sony-starvis2: Allow runtime control of link frequency Dave Stevenson
2026-11-30  3:27   ` Laurent Pinchart
2026-10-29 14:18 ` [PATCH v7 07/18] media: sony-starvis2: Correct the exposure range Dave Stevenson
2026-10-29 14:18 ` [PATCH v7 08/18] media: sony-starvis2: Put module into standby after identify Dave Stevenson
2026-11-30  3:30   ` Laurent Pinchart
2026-10-29 14:18 ` [PATCH v7 09/18] media: sony-starvis2: Use pm_runtime_autosuspend Dave Stevenson
2026-10-29 14:18 ` [PATCH v7 10/18] media: dt-bindings: sony,imx678: Add other Starvis 2 family members Dave Stevenson
2026-10-29 14:18 ` [PATCH v7 11/18] media: sony-starvis2: Add support for IMX662 Dave Stevenson
2026-11-30  4:08   ` Laurent Pinchart
2026-11-30 15:43     ` Dave Stevenson
2026-11-30 16:25       ` Jai Luthra
2026-12-01  5:21         ` Laurent Pinchart [this message]
2026-10-29 14:18 ` [PATCH v7 12/18] media: sony-starvis2: Add support for IMX675 Dave Stevenson
2026-10-29 14:18 ` [PATCH v7 13/18] media: sony-starvis2: Add support for IMX832 Dave Stevenson
2026-10-29 14:18 ` [PATCH v7 14/18] media: sony-starvis2: Only update bits for window mode Dave Stevenson
2026-10-29 14:18 ` [PATCH v7 15/18] media: sony-starvis2: Parameterise exposure min and step Dave Stevenson
2026-11-30  5:39   ` Laurent Pinchart
2026-10-29 14:18 ` [PATCH v7 16/18] media: sony-starvis2: Parameterise the mono ID register Dave Stevenson
2026-10-29 14:18 ` [PATCH v7 17/18] media: sony-starvis2: Add support for IMX585 Dave Stevenson
2026-10-29 14:18 ` [PATCH v7 18/18] media: sony-starvis2: Add support for IMX676 Dave Stevenson
2026-11-30  5:45 ` [PATCH v7 00/18] Update imx678 to act as a common Sony Starvis 2 driver Laurent Pinchart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261201052127.GS24781@killaraus.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=conor+dt@kernel.org \
    --cc=dave.stevenson@raspberrypi.com \
    --cc=devicetree@vger.kernel.org \
    --cc=eagle.alexander923@gmail.com \
    --cc=jai.luthra@ideasonboard.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=robh@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox