From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=213.167.242.64 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796098162; b=2NsoWW8wSZia7Hp3A9b36M3hiB9SbcEmLtfJl4Zm40E2nXbUNfrOL8MAK1joNuRq58yH H8Kswe9C3RyOtyGwTfnBZ5RqOMEOCFbbT+zJzazSmCGRz9qP9aUSK392nsqRu2qGSH5wO i48cH0K8gw2SAMdTnkkwbEaT/92Sj6CbdC7uPztI/u568K+UWGtByQlAK8nZOGYesI4SN AyZTFPJfZ50IJ3pj9tarGjURqPvF0TsgvEi/nHw9zaycdtoi7Hqdny1Eb+z5AGQA1PVfk lSYhVvIc6BaPeiR3uV5lIS/IICvk48CQCkh+mCqd/5eKr4oqwTnw2VeLnMC15iA1jWg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796098162; h=DMARC-Filter:Received:DKIM-Signature:Date:From:To:Cc:Subject: Message-ID:References:MIME-Version:Content-Type:Content-Disposition: In-Reply-To; bh=44a59lMgyxn7wB24k/SFoeCtymKEnGiJkWtl1Jw+kJ0=; b=oF3+v9aKpMQRVcCHz0VhvxT/JsFXl1y2anB2sIsIYu+Fk7lrs7m9GLRp4/GFzGX8Gr0P pB6a0joBkGjwPBZssF9n/EhubBaZKwApedVRqu9wKudTgY8EQz/mmkNNB5Ev2KOSL3JsW Y1wbQBPui9HX5x0AAIupAZzjrRredQz8sDhl3rk9Ae1q6QpswwUaaMlqtQrdDfTq4X4vR uCafHOyLUetg5TvmbFJy7pGWZV7w8RhGL3+/RBJ+rJmzswQMLvCvuO1UE2hUdOn8ilMjD PhoNNvDC+dGGdE5WSqQmKfkwU1PO/4eJl0iljxXp4DPzJK1LPQ6K25skeaVbI9thaqw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass header.d=ideasonboard.com header.i=@ideasonboard.com header.a=rsa-sha256 header.s=mail header.b=R4lJgRlD; arc=none smtp.remote-ip=213.167.242.64 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A25EB606A31A; Tue, 1 Dec 2026 04:09:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A25EB606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.a=rsa-sha256 header.s=mail header.b=R4lJgRlD Received: from killaraus.ideasonboard.com (fp7965754b.ap.nuro.jp [121.101.117.75]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 753C7D0; Tue, 1 Dec 2026 05:06:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1796098002; bh=PuW00Z3+UGtM6uJT5x1NVdnsmlRxj0jX/FsHvh4gaak=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=R4lJgRlDTbBqTTJ444LLZplvUJZrqSKswyw5i1x6KbVOFPASYO04T6BclKZI/Pa7F 5bQkdV0fuR9IiOZydwd1AuNbP/P11IShgoU4KVHTwKT5+F9epZaeMMzjTl3+TizKLV 2AW0A67ATQTGqaVOSMOWAWS3IBzsbE0BqpuC7sAY= Date: Tue, 1 Dec 2026 13:09:15 +0900 From: Laurent Pinchart To: Dave Stevenson Cc: Sakari Ailus , Jai Luthra , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Alexander Shiyan , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: Re: [PATCH v7 04/18] media: sony-starvis2: Parameterise the configuration to allow for other models Message-ID: <20261201040915.GR24781@killaraus.ideasonboard.com> References: <20261029-media-starvis2-v7-0-b33a1332fdfc@raspberrypi.com> <20261029-media-starvis2-v7-4-b33a1332fdfc@raspberrypi.com> <20261130031352.GE4286@killaraus.ideasonboard.com> <20261130040801.GA29477@killaraus.ideasonboard.com> X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: On Mon, Nov 30, 2026 at 03:33:31PM +0000, Dave Stevenson wrote: > On Mon, 30 Nov 2026 at 04:08, Laurent Pinchart wrote: > > > > One more comment. > > > > On Mon, Nov 30, 2026 at 12:14:01PM +0900, Laurent Pinchart wrote: > > > Hi Dave, > > > > > > It appears Sakari has merged this series without any reviews. Could you > > > please address the comments below as follow-up patches ? Same for > > > comments to the other patches in the series, if any. > > The series has been out for a month at this revision, and Jai as > maintainer was well aware of it. Sakari's entitled to review it > himself and pick it up. As far as I can tell Sakari hasn't reviewed it, as there's no R-b tag from him. > > > On Thu, Oct 29, 2026 at 02:18:25PM +0000, Dave Stevenson wrote: > > > > 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 > > > > --- > > > > drivers/media/i2c/sony-starvis2.c | 178 ++++++++++++++++++++++++-------------- > > > > 1 file changed, 114 insertions(+), 64 deletions(-) > > > > > > > > diff --git a/drivers/media/i2c/sony-starvis2.c b/drivers/media/i2c/sony-starvis2.c > > > > index 31aa1ec6ba40..b54e1c68afa0 100644 > > > > --- a/drivers/media/i2c/sony-starvis2.c > > > > +++ b/drivers/media/i2c/sony-starvis2.c > > > > @@ -52,17 +52,9 @@ > > > > /* Lane Count */ > > > > #define STARVIS2_REG_LANEMODE CCI_REG8(0x3040) > > > > > > > > -/* > > > > - * 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 > > > > > > This is an important comment, please restore it. > > As written it's only relevant to IMX678, not any of the other Starvis > 2 sensors, and the define it's referring to is deleted. > I'll add an extra comment to struct starvis2_variant pix_per_clk / pixel_clock. > > > > > - */ > > > > -#define IMX678_PIXEL_RATE 594000000 > > > > -#define IMX678_PIX_PER_CLK 8 > > > > - > > > > /* VMAX - Frame Length in Lines */ > > > > #define STARVIS2_REG_VMAX CCI_REG24_LE(0x3028) > > > > #define STARVIS2_VMAX_MAX 0xfffff > > > > -#define IMX678_VMAX_DEFAULT 2250 > > > > > > > > /* HMAX - Line Length in Cycles */ > > > > #define STARVIS2_REG_HMAX CCI_REG16_LE(0x302c) > > > > @@ -103,8 +95,6 @@ > > > > /* Sensor Identification */ > > > > #define STARVIS2_REG_MONOCHROME CCI_REG8(0x4d18) > > > > #define STARVIS2_TYPE BIT(0) > > > > -#define IMX678_REG_MODULE_ID CCI_REG16_LE(0x4d1c) > > > > -#define IMX678_ID 0x02a6 > > > > #define STARVIS2_MODULE_ID_DELAY 80000 > > > > > > > > /* Common configuration registers */ > > > > @@ -137,7 +127,6 @@ > > > > #define STARVIS2_TPG_COLORWIDTH_320PIX 2 > > > > #define STARVIS2_TPG_COLORWIDTH_640PIX 3 > > > > > > > > -#define STARVIS2_REG_INTERFACE_SEL CCI_REG8(0x4e3c) > > > > #define STARVIS2_INTERFACE_2L_4L 0x07 > > > > #define STARVIS2_INTERFACE_8L_2x4L 0x7f > > > > > > > > @@ -154,32 +143,11 @@ > > > > /* Subdev pads */ > > > > #define STARVIS2_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 starvis2_type { > > > > STARVIS2_COLOR = 0, > > > > STARVIS2_MONOCHROME = 1, > > > > }; > > > > > > > > -struct starvis2_model_info { > > > > - enum starvis2_type type; > > > > - const u32 *codes; > > > > - unsigned int num_codes; > > > > -}; > > > > - > > > > enum starvis2_lanemode { > > > > STARVIS2_LANEMODE_2L = 1, > > > > STARVIS2_LANEMODE_4L = 3, > > > > @@ -208,7 +176,7 @@ static const u64 link_freqs[] = { > > > > [STARVIS2_LINK_FREQ_1188MHZ] = 1188000000, > > > > }; > > > > > > > > -static const u16 min_hmax_4lane[] = { > > > > +static const u16 imx678_min_hmax_4lane[] = { > > > > [STARVIS2_LINK_FREQ_297MHZ] = 1584, > > > > [STARVIS2_LINK_FREQ_360MHZ] = 1320, > > > > [STARVIS2_LINK_FREQ_445MHZ] = 1100, > > > > @@ -268,7 +236,7 @@ static const int starvis2_tpg_val[] = { > > > > }; > > > > > > > > /* Common configuration */ > > > > -static const struct cci_reg_sequence common_regs[] = { > > > > +static const struct cci_reg_sequence imx678_common_regs[] = { > > > > { STARVIS2_REG_THIN_V_EN, 0x00 }, > > > > { STARVIS2_REG_VCMODE, 0x01 }, > > > > { CCI_REG8(0x306b), 0x00 }, > > > > @@ -651,16 +619,76 @@ static const u32 codes_monochrome[] = { > > > > MEDIA_BUS_FMT_Y12_1X12, > > > > }; > > > > > > > > +struct starvis2_variant { > > > > + const char *name; > > > > + u32 id_reg; > > > > + u32 id_mask; > > > > + u32 id_value; > > > > + u32 interface_sel_reg; > > > > > > I suppose two per-variant register addresses are not too bad, as long as > > > we don't introduce more later. > > The alternative would be 6 identical boilerplate drivers which just > vary by a few dozen registers and the output resolution. Which is more > manageable? I didn't claim separate drivers were a better solution. Most of the boilerplate isn't related to starvis 2 sensors, I hope to see heavy rework of sensor drivers once the raw camera model will be merged (Jai has posted the libcamera side). I'm curious to see what will be left of starvis-specific code then. That doesn't invalidate your efforts, they go in the right direction. > > > > + 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; > > > > +}; > > > > + > > > > +static const struct starvis2_variant imx678_variant_def = { > > > > + .name = "imx678", > > > > + .id_reg = CCI_REG16_LE(0x4d1c), > > > > + .id_mask = 0x3ff, > > > > > > There was no masking in the imx678 driver, why do you introduce one here > > > ? This should have been a separate commit. > > Too late to fix as a separate commit. Of course, but could you please tell why you introduced masking ? Does the IMX678 store other data in bits 15-10 ? > > > > + .id_value = 0x2a6, > > > > + .interface_sel_reg = CCI_REG8(0x4e3c), > > > > + .native_area = { > > > > + .top = 0, > > > > + .left = 0, > > > > + .width = 3857, > > > > + .height = 2201, > > > > + }, > > > > + .active_area = { > > > > + .top = 20, > > > > + .left = 0, > > > > + .width = 3856, > > > > + .height = 2180, > > > > + }, > > > > + .pixel_rate = 594000000, > > > > + .pix_per_clk = 8, > > > > + .common_regs = imx678_common_regs, > > > > + .num_common_regs = ARRAY_SIZE(imx678_common_regs), > > > > + .vmax_default = 2250, > > > > + .hmax_min = imx678_min_hmax_4lane, > > > > +}; > > > > + > > > > +struct starvis2_model_info { > > > > + enum starvis2_type type; > > > > + const u32 *codes; > > > > + unsigned int num_codes; > > > > + const struct starvis2_variant *variant; > > > > + > > > > + const struct starvis2_model_info *auto_detect_colour; > > > > + const struct starvis2_model_info *auto_detect_mono; > > > > > > I don't like this. There is a comment in the match table that states > > > > > > /* for non-conforming DTs that rely on runtime check */ > > > > > > We shouldn't extend non-conforming behaviour to new sensors in the > > > driver. > > Policy needs to be decided: Exactly my point :-) > Does V4L2 wish to support autodetection of > sensor type at probe as eg imx296 does, or only support hard-coding > from DT/ACPI? > You've got the secondary debate about not powering up at probe, but > that's currently only an option under ACPI. > > It's Jai's comment about "non-conforming behaviour". The discussion > was had when that original binding was merged [1] [2], so please say > what in that original discussion doesn't apply to the new sensors. I wasn't involved there. What I dislike is having drivers that implement usage of DT bindings rejected by DT maintainers. We need to find an agreement, and then proceed to implement the outcome. > TBH I'd go further with a simple compatible of "sony,starvis2" that > autodetects the sensor type too, but obviously that requires powering > on at probe. Sakari implied he'd be behind this[3], but I only backed > out as I'm currently not in a place to take up the discussion with DT > maintainers, and nothing in what we currently have blocks it being > added in future. I expect that will be even more contentious. Linux used to have I2C device auto-detection, and that caused quite some pain. For systems that have different hardware options, where runtime probing is guaranteed by the integrator to be safe, the boot loader typically handles probing the hardware and updating DT. > [1] https://lore.kernel.org/linux-media/20260520-imx678-v3-1-8b5f9676486e@ideasonboard.com/ > [2] https://lore.kernel.org/linux-media/20260605-imx678-v4-1-58e57c67143d@ideasonboard.com/ > [3] https://lore.kernel.org/linux-media/atc9Uxt_hsyYu2o5@kekkonen.localdomain/ > > > > > +}; > > > > + > > > > static const struct starvis2_model_info imx678_aaqr_info = { > > > > .type = STARVIS2_COLOR, > > > > .codes = codes_bayer, > > > > .num_codes = ARRAY_SIZE(codes_bayer), > > > > + .variant = &imx678_variant_def, > > > > }; > > > > > > > > static const struct starvis2_model_info imx678_aamr_info = { > > > > .type = STARVIS2_MONOCHROME, > > > > .codes = codes_monochrome, > > > > .num_codes = ARRAY_SIZE(codes_monochrome), > > > > + .variant = &imx678_variant_def, > > > > +}; > > > > + > > > > +static const struct starvis2_model_info imx678_autodetect_info = { > > > > + .variant = &imx678_variant_def, > > > > + .auto_detect_colour = &imx678_aaqr_info, > > > > + .auto_detect_mono = &imx678_aamr_info, > > > > }; > > > > > > > > static const char * const starvis2_supply_name[] = { > > > > @@ -675,6 +703,7 @@ struct starvis2 { > > > > struct regmap *cci; > > > > > > > > const struct starvis2_model_info *info; > > > > + const struct starvis2_variant *variant; > > > > > > > > struct clk *xclk; > > > > u32 xclk_freq; > > > > @@ -771,7 +800,8 @@ static int starvis2_set_ctrl(struct v4l2_ctrl *ctrl) > > > > cci_write(starvis2->cci, STARVIS2_REG_GAIN, ctrl->val, &ret); > > > > break; > > > > case V4L2_CID_HBLANK: { > > > > - u32 hmax = (format->width + ctrl->val) / IMX678_PIX_PER_CLK; > > > > + u32 hmax = (format->width + ctrl->val) / > > > > + starvis2->variant->pix_per_clk; > > > > > > Wrong indentation. > > > > > > > > > > > cci_write(starvis2->cci, STARVIS2_REG_HMAX, hmax, &ret); > > > > break; > > > > @@ -852,18 +882,20 @@ static int starvis2_get_selection(struct v4l2_subdev *sd, > > > > struct v4l2_subdev_state *sd_state, > > > > struct v4l2_subdev_selection *sel) > > > > { > > > > + struct starvis2 *starvis2 = to_starvis2(sd); > > > > + > > > > switch (sel->target) { > > > > case V4L2_SEL_TGT_CROP: > > > > sel->r = *v4l2_subdev_state_get_crop(sd_state, sel->pad); > > > > return 0; > > > > > > > > case V4L2_SEL_TGT_NATIVE_SIZE: > > > > - sel->r = imx678_native_area; > > > > + sel->r = starvis2->variant->native_area; > > > > return 0; > > > > > > > > case V4L2_SEL_TGT_CROP_DEFAULT: > > > > case V4L2_SEL_TGT_CROP_BOUNDS: > > > > - sel->r = imx678_active_area; > > > > + sel->r = starvis2->variant->active_area; > > > > return 0; > > > > } > > > > > > > > @@ -878,12 +910,12 @@ static int starvis2_init_state(struct v4l2_subdev *sd, > > > > struct v4l2_rect *crop; > > > > > > > > crop = v4l2_subdev_state_get_crop(state, STARVIS2_SOURCE_PAD); > > > > - *crop = imx678_active_area; > > > > + *crop = starvis2->variant->active_area; > > > > > > > > format = v4l2_subdev_state_get_format(state, STARVIS2_SOURCE_PAD); > > > > format->code = starvis2_default_mbus_code(starvis2); > > > > - format->width = imx678_active_area.width; > > > > - format->height = imx678_active_area.height; > > > > + format->width = starvis2->variant->active_area.width; > > > > + format->height = starvis2->variant->active_area.height; > > > > format->field = V4L2_FIELD_NONE; > > > > format->colorspace = V4L2_COLORSPACE_RAW; > > > > format->ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT; > > > > @@ -897,8 +929,12 @@ static int starvis2_write_common(struct starvis2 *starvis2) > > > > { > > > > int ret = 0; > > > > > > > > - cci_multi_reg_write(starvis2->cci, common_regs, ARRAY_SIZE(common_regs), > > > > - &ret); > > > > + if (!starvis2->variant) > > > > + /* Powered on during probe to do detection. Variant unknown. */ > > > > + return 0; > > > > > > Is the common_regs_written logic introduced in patch 01/18 meant to go > > > with this ? A separate patch would have been nice. > > > > > > > + > > > > + cci_multi_reg_write(starvis2->cci, starvis2->variant->common_regs, > > > > + starvis2->variant->num_common_regs, &ret); > > > > > > > > cci_write(starvis2->cci, STARVIS2_REG_INCK_SEL, starvis2->inck_sel_val, > > > > &ret); > > > > @@ -908,8 +944,9 @@ static int starvis2_write_common(struct starvis2 *starvis2) > > > > cci_write(starvis2->cci, STARVIS2_REG_LANEMODE, starvis2->lane_mode, > > > > &ret); > > > > > > > > - cci_write(starvis2->cci, STARVIS2_REG_INTERFACE_SEL, > > > > - STARVIS2_INTERFACE_2L_4L, &ret); > > > > + if (starvis2->variant->interface_sel_reg) > > > > + cci_write(starvis2->cci, starvis2->variant->interface_sel_reg, > > > > + STARVIS2_INTERFACE_2L_4L, &ret); > > > > > > > > if (!ret) > > > > starvis2->common_regs_written = true; > > > > @@ -925,10 +962,10 @@ static int starvis2_program_window(struct starvis2 *starvis2, > > > > cci_write(starvis2->cci, STARVIS2_REG_ADDMODE, 0x00, &ret); > > > > cci_write(starvis2->cci, STARVIS2_REG_WINMODE, 0x04, &ret); > > > > cci_write(starvis2->cci, STARVIS2_REG_PIX_HST, > > > > - crop->left - imx678_active_area.left, &ret); > > > > + crop->left - starvis2->variant->active_area.left, &ret); > > > > cci_write(starvis2->cci, STARVIS2_REG_PIX_HWIDTH, crop->width, &ret); > > > > cci_write(starvis2->cci, STARVIS2_REG_PIX_VST, > > > > - crop->top - imx678_active_area.top, &ret); > > > > + crop->top - starvis2->variant->active_area.top, &ret); > > > > cci_write(starvis2->cci, STARVIS2_REG_PIX_VWIDTH, crop->height, &ret); > > > > cci_write(starvis2->cci, STARVIS2_REG_ADBIT, 0x01, &ret); > > > > > > > > @@ -1082,11 +1119,16 @@ static int starvis2_identify_model(struct starvis2 *starvis2) > > > > { > > > > struct i2c_client *client = v4l2_get_subdevdata(&starvis2->sd); > > > > const struct starvis2_model_info *info; > > > > + const struct starvis2_variant *variant; > > > > enum starvis2_type detected; > > > > int ret = 0; > > > > u64 val = 0; > > > > > > > > info = device_get_match_data(&client->dev); > > > > + if (!info) > > > > + return -EINVAL; > > > > + > > > > + variant = info->variant; > > > > > > > > /* > > > > * This sensor's ID registers become accessible 80ms after coming out > > > > @@ -1095,7 +1137,7 @@ static int starvis2_identify_model(struct starvis2 *starvis2) > > > > cci_write(starvis2->cci, STARVIS2_REG_MODE_SELECT, 0, &ret); > > > > fsleep(STARVIS2_MODULE_ID_DELAY); > > > > > > > > - cci_read(starvis2->cci, IMX678_REG_MODULE_ID, &val, &ret); > > > > + cci_read(starvis2->cci, variant->id_reg, &val, &ret); > > > > > > > > if (ret) { > > > > dev_err(&client->dev, > > > > @@ -1103,9 +1145,10 @@ static int starvis2_identify_model(struct starvis2 *starvis2) > > > > return ret; > > > > } > > > > > > > > - if (val != IMX678_ID) { > > > > - dev_err(&client->dev, > > > > - "Chip ID mismatch: %x!=%llx\n", IMX678_ID, val); > > > > + val &= variant->id_mask; > > > > + if (val != variant->id_value) { > > > > + dev_err(&client->dev, "Chip ID mismatch: %x!=%llx\n", > > > > + variant->id_value, val); > > > > return -ENXIO; > > > > } > > > > > > > > @@ -1120,7 +1163,7 @@ static int starvis2_identify_model(struct starvis2 *starvis2) > > > > detected = val & STARVIS2_TYPE; > > > > > > > > /* Prefer to use sensor type specified in device tree */ > > > > - if (info) { > > > > + if (info->codes) { > > > > It would be clearer to modify the type enum as > > > > enum starvis2_type { > > STARVIS2_TYPE_COLOR = 0, > > STARVIS2_TYPE_MONOCHROME = 1, > > STARVIS2_TYPE_UNKNOWN = 2, > > }; > > > > ('UNKNOWN' may not be the best name) > > > > and replace the above condition with > > > > if (info->type != STARVIS2_TYPE_UNKNOWN) { > > STARVIS2_TYPE_AUTODETECT ? That would work. > > > > starvis2->info = info; > > > > if (detected != info->type) > > > > dev_err(&client->dev, > > > > @@ -1129,11 +1172,12 @@ static int starvis2_identify_model(struct starvis2 *starvis2) > > > > info->type == STARVIS2_COLOR ? "color" : "mono"); > > > > } else { > > > > starvis2->info = detected == STARVIS2_MONOCHROME ? > > > > - &imx678_aamr_info : &imx678_aaqr_info; > > > > + info->auto_detect_mono : info->auto_detect_colour; > > > > dev_info(&client->dev, > > > > "sensor type missing in DT; detected %s sensor\n", > > > > detected == STARVIS2_MONOCHROME ? "mono" : "color"); > > > > } > > > > + starvis2->variant = starvis2->info->variant; > > > > > > If starvis2->variant is always equal to starvis2->info->variant you can > > > drop the former. > > It just saves an extra dereference in a lot of places, but if you wish. > > Actually it's probably better to: > - STARVIS2_COLOR always gets codes_bayer and the size of that, and > STARVIS2_MONOCHROME always gets codes_monochrome and size. > - remove codes and num_codes from model_info. > - copy the type the main struct. > - drop starvis2->info. > Then starvis2_model_info is only referenced during probe, and it > removes all the codes/num_codes duplication from the different > model_info structs. Sounds good. The number of codes should always be the same for mono and colour, I think you can also hardcode that assumption where useful. > > > > > > > > return 0; > > > > } > > > > @@ -1164,7 +1208,7 @@ static int starvis2_init_controls(struct starvis2 *starvis2) > > > > { > > > > struct v4l2_ctrl_handler *ctrl_hdlr; > > > > const u32 hmax_4lane = > > > > - min_hmax_4lane[__fls(starvis2->link_freq_bitmap)]; > > > > + starvis2->variant->hmax_min[__fls(starvis2->link_freq_bitmap)]; > > > > const u32 lane_scale = > > > > starvis2->lane_mode == STARVIS2_LANEMODE_2L ? 2 : 1; > > > > struct i2c_client *client = v4l2_get_subdevdata(&starvis2->sd); > > > > @@ -1183,13 +1227,14 @@ static int starvis2_init_controls(struct starvis2 *starvis2) > > > > if (ret) > > > > return ret; > > > > > > > > - starvis2->vmax = IMX678_VMAX_DEFAULT; > > > > + starvis2->vmax = starvis2->variant->vmax_default; > > > > hmax = hmax_4lane * lane_scale; > > > > > > > > /* PIXEL_RATE is fixed and read-only */ > > > > v4l2_ctrl_new_std(ctrl_hdlr, &starvis2_ctrl_ops, V4L2_CID_PIXEL_RATE, > > > > - IMX678_PIXEL_RATE, IMX678_PIXEL_RATE, 1, > > > > - IMX678_PIXEL_RATE); > > > > + starvis2->variant->pixel_rate, > > > > + starvis2->variant->pixel_rate, 1, > > > > + starvis2->variant->pixel_rate); > > > > > > > > /* LINK_FREQ is also read only */ > > > > link_freq = v4l2_ctrl_new_int_menu(ctrl_hdlr, &starvis2_ctrl_ops, > > > > @@ -1201,23 +1246,25 @@ static int starvis2_init_controls(struct starvis2 *starvis2) > > > > if (link_freq) > > > > link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY; > > > > > > > > - vblank = starvis2->vmax - imx678_active_area.height; > > > > - max_vblank = STARVIS2_VMAX_MAX - imx678_active_area.height; > > > > + vblank = starvis2->vmax - starvis2->variant->active_area.height; > > > > + max_vblank = STARVIS2_VMAX_MAX - starvis2->variant->active_area.height; > > > > starvis2->vblank = v4l2_ctrl_new_std(ctrl_hdlr, &starvis2_ctrl_ops, > > > > V4L2_CID_VBLANK, vblank, max_vblank, > > > > 2, vblank); > > > > > > > > - hblank = hmax * IMX678_PIX_PER_CLK - imx678_active_area.width; > > > > - max_hblank = STARVIS2_HMAX_MAX * IMX678_PIX_PER_CLK - > > > > - imx678_active_area.width; > > > > + hblank = hmax * starvis2->variant->pix_per_clk - > > > > + starvis2->variant->active_area.width; > > > > > > Wrong indentation. I wonder where that comes from, as the next line is > > > correct. > > I don't see a correct indentation being specified in the kernel coding > style nor the media subsystem addendum[4] for this situation. When there's no explicit rule, consistency is favoured. Usual indentation is to align the lines after the '=', as in hblank = hmax * starvis2->variant->pix_per_clk - starvis2->variant->active_area.width; which is what you did just below: max_hblank = STARVIS2_HMAX_MAX * starvis2->variant->pix_per_clk - starvis2->variant->active_area.width; > Closest is [5] > "Descendants are always substantially shorter than the parent and are > placed substantially to the right. A very commonly used style is to > align descendants to a function open parenthesis." > > There isn't an open parenthesis to align to, and the line is > substantially to the right. Is there some extra criteria you're > requiring that isn't documented? > Checkpatch doesn't check for anything specific here either. > > [4] https://github.com/torvalds/linux/blob/master/Documentation/driver-api/media/maintainer-entry-profile.rst#coding-style-addendum > [5] https://www.kernel.org/doc/html/latest/process/coding-style.html#breaking-long-lines-and-strings > > > > > + max_hblank = STARVIS2_HMAX_MAX * starvis2->variant->pix_per_clk - > > > > + starvis2->variant->active_area.width; > > > > starvis2->hblank = v4l2_ctrl_new_std(ctrl_hdlr, &starvis2_ctrl_ops, > > > > V4L2_CID_HBLANK, hblank, max_hblank, > > > > - IMX678_PIX_PER_CLK, hblank); > > > > + starvis2->variant->pix_per_clk, > > > > + hblank); > > > > > > > > starvis2->exposure = v4l2_ctrl_new_std(ctrl_hdlr, &starvis2_ctrl_ops, > > > > V4L2_CID_EXPOSURE, > > > > STARVIS2_EXPOSURE_MIN, > > > > - IMX678_VMAX_DEFAULT - > > > > + starvis2->variant->vmax_default - > > > > STARVIS2_SHR_MIN, > > > > STARVIS2_EXPOSURE_STEP, > > > > STARVIS2_EXPOSURE_DEFAULT); > > > > @@ -1358,6 +1405,9 @@ static int starvis2_probe(struct i2c_client *client) > > > > if (ret) > > > > goto error_power_off; > > > > > > > > + v4l2_i2c_subdev_set_name(&starvis2->sd, client, starvis2->variant->name, > > > > + NULL); > > > > + > > > > pm_runtime_set_active(dev); > > > > pm_runtime_enable(dev); > > > > > > > > @@ -1438,7 +1488,7 @@ static const struct of_device_id starvis2_of_match[] = { > > > > { .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,imx678" }, > > > > + { .compatible = "sony,imx678", .data = &imx678_autodetect_info }, > > > > { /* sentinel */ } > > > > }; > > > > -- Regards, Laurent Pinchart