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=1796096968; b=V1aN71Fh5HlmfLiE5pPSwboEYEt7NgVBa1d8xzwGKMLe6depUu0u3v7SHTvi9LijQTdQ QJM6DcT0gZn6G+ubazSs10/MNhsqNyjwIVLgE1Y4bGL+GOs7pX7d+tldIq6hC55LBjUkR 9PTZ1A+V6hxR1epHhkFBf7IE/ABYcF15ALaIa175pvuxYm/mOWvyK8I2ptUMkwj+dx4oy pK6OUyIFKiKkSlX+mOVxlR6TO37gQ0u1/K6N1M2o0JhxQ35SIXmL4yE8HAT5FPG/EYGE/ ObJCCFyxKgEpKm9i8xZpmNniM9DT313MWw70zFxm+oODkBrcaZ4XyxzQC9y+8r5I3ig== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796096968; h=DMARC-Filter:Received:DKIM-Signature:Date:From:To:Cc:Subject: Message-ID:References:MIME-Version:Content-Type:Content-Disposition: In-Reply-To; bh=9pi/pDuQj7RFUa8kMg5rILmyTquBel9Qxakt/kLABww=; b=amhLVHMUMt2DrGaB3DtYoJZDum5zpkTgIY4XqRrpG8aRSMG8yIRtgLiehIPXOnWEpfpc PAxHJNIMbpEDv21CAOtLyag7NZIeHkJ6MyfeoZNX9TJyS+Daik6843yi/g6r3Y3HjCQRk GP/kuqpNJiRzU/LzSN4huczA7koelKQig28tWXTC8QVq6NxHL0z8gU45vW2/amyAnfTDp zePDoz5JEg+qir730kCzlE13tKomJetAac76i6wrm6nzibJdm7XOEdvLVn58v/gy9/XWX ZVafQarYR/rCbW6wQeO4MNQTvbDIbQL+NKAEyCc6dGrfNPX1L2Qr2G5i/Mpid9/T2kA== 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=N4nXd2S4; 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) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 84186606A333; Tue, 1 Dec 2026 03:49:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 84186606A333 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=N4nXd2S4 Received: from killaraus.ideasonboard.com (fp7965754b.ap.nuro.jp [121.101.117.75]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 6ABEA4B0; Tue, 1 Dec 2026 04:46:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1796096808; bh=GIFzjfeZgeaWW7Be5TEOBg/uVHv2FS24QXDl3RYNcWQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=N4nXd2S4hTOtj7EmV2alMk8uguc+BykchINUnCXwCKGE5+JwSbpKNLGwsLrbuFYaa RCBXpmPhFw6j7jp5TPt4kXRO13ZJXCK3jr/PHGLV4bG8LZGOH29rVaPKIB5Jbp1E3X TKOuFV8JAey2QhmkjHK8FXkcQrxztXHHacUZ1p2g= Date: Tue, 1 Dec 2026 12:49:20 +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 02/18] media: sony-starvis2: Reorder link frequencies to remove lookup Message-ID: <20261201034920.GP24781@killaraus.ideasonboard.com> References: <20261029-media-starvis2-v7-0-b33a1332fdfc@raspberrypi.com> <20261029-media-starvis2-v7-2-b33a1332fdfc@raspberrypi.com> <20261130024407.GC4286@killaraus.ideasonboard.com> X-Mailing-List: devicetree@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 02:16:37PM +0000, Dave Stevenson wrote: > On Mon, 30 Nov 2026 at 02:44, Laurent Pinchart wrote: > > On Thu, Oct 29, 2026 at 02:18:23PM +0000, Dave Stevenson wrote: > > > link_freqs_reg_value is table that just reverses the order of the > > > link frequency enum. > > > > > > Reverse the order of the link frequencies so that the table is > > > redundant, and remove it. > > > > > > Signed-off-by: Dave Stevenson > > > --- > > > drivers/media/i2c/sony-starvis2.c | 31 ++++++++++--------------------- > > > 1 file changed, 10 insertions(+), 21 deletions(-) > > > > > > diff --git a/drivers/media/i2c/sony-starvis2.c b/drivers/media/i2c/sony-starvis2.c > > > index e62cde583324..134fececac5c 100644 > > > --- a/drivers/media/i2c/sony-starvis2.c > > > +++ b/drivers/media/i2c/sony-starvis2.c > > > @@ -187,25 +187,14 @@ enum starvis2_lanemode { > > > > > > /* Link frequency setup (DDR: lane rate = 2 x link freq) */ > > > enum { > > > - STARVIS2_LINK_FREQ_297MHZ, > > > - STARVIS2_LINK_FREQ_360MHZ, > > > - STARVIS2_LINK_FREQ_445MHZ, > > > - STARVIS2_LINK_FREQ_594MHZ, > > > - STARVIS2_LINK_FREQ_720MHZ, > > > - STARVIS2_LINK_FREQ_891MHZ, > > > - STARVIS2_LINK_FREQ_1039MHZ, > > > - STARVIS2_LINK_FREQ_1188MHZ, > > > -}; > > > - > > > -static const u8 link_freqs_reg_value[] = { > > > - [STARVIS2_LINK_FREQ_297MHZ] = 0x07, > > > - [STARVIS2_LINK_FREQ_360MHZ] = 0x06, > > > - [STARVIS2_LINK_FREQ_445MHZ] = 0x05, > > > - [STARVIS2_LINK_FREQ_594MHZ] = 0x04, > > > - [STARVIS2_LINK_FREQ_720MHZ] = 0x03, > > > - [STARVIS2_LINK_FREQ_891MHZ] = 0x02, > > > - [STARVIS2_LINK_FREQ_1039MHZ] = 0x01, > > > - [STARVIS2_LINK_FREQ_1188MHZ] = 0x00, > > > + STARVIS2_LINK_FREQ_1188MHZ = 0x00, > > > + STARVIS2_LINK_FREQ_1039MHZ = 0x01, > > > + STARVIS2_LINK_FREQ_891MHZ = 0x02, > > > + STARVIS2_LINK_FREQ_720MHZ = 0x03, > > > + STARVIS2_LINK_FREQ_594MHZ = 0x04, > > > + STARVIS2_LINK_FREQ_445MHZ = 0x05, > > > + STARVIS2_LINK_FREQ_360MHZ = 0x06, > > > + STARVIS2_LINK_FREQ_297MHZ = 0x07, > > > }; > > > > > > static const u64 link_freqs[] = { > > > @@ -914,7 +903,7 @@ static int starvis2_write_common(struct starvis2 *starvis2) > > > cci_write(starvis2->cci, STARVIS2_REG_INCK_SEL, starvis2->inck_sel_val, > > > &ret); > > > cci_write(starvis2->cci, STARVIS2_REG_DATARATE_SEL, > > > - link_freqs_reg_value[__ffs(starvis2->link_freq_bitmap)], > > > + __fls(starvis2->link_freq_bitmap), > > > &ret); > > > cci_write(starvis2->cci, STARVIS2_REG_LANEMODE, starvis2->lane_mode, > > > &ret); > > > @@ -1177,7 +1166,7 @@ static int starvis2_init_controls(struct starvis2 *starvis2) > > > { > > > struct v4l2_ctrl_handler *ctrl_hdlr; > > > const u32 hmax_4lane = > > > - min_hmax_4lane[__ffs(starvis2->link_freq_bitmap)]; > > > + min_hmax_4lane[__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); > > > > As far as I understand, the driver hardcodes usage of the lowest link > > frequency. The LINK_FREQ control is initialized with > > > > link_freq = v4l2_ctrl_new_int_menu(ctrl_hdlr, &starvis2_ctrl_ops, > > V4L2_CID_LINK_FREQ, > > ARRAY_SIZE(link_freqs) - 1, > > __ffs(starvis2->link_freq_bitmap), > > link_freqs); > > > > which I think should also be updated, otherwise the control will report > > the highest frequency. > > Potentially, but rendered irrelevant by patch 6 "media: sony-starvis2: > Allow runtime control of link frequency" which removes this hard > coding of which link frequency is chosen. Yes, I noticed that when reviewing patch 06/18. The issue is only present in the git history, nobody should notice unless they try to bisect issues with the driver. > > A side effect of this patch is that it reverses the order of link > > frequencies exposed to userspace in the LINK_FREQ control, from highest > > to lowest. The order isn't defined in the V4L2 specification, but I > > wonder if it could cause breakages in userspace. > > V4L2_CID_LINK_FREQ is defined as a read-only control at this point, so Sure, but the reversed order is preserved when making LINK_FREQ writable. > what is userspace going to do with it at all? I don't think it's an issue, but I'd like Sakari's confirmation that he also doesn't see a problem. > The likely only consumer that is going to do anything with it is the > CSI2 receiver, and that will just read the menu entry indicated by the > current val. -- Regards, Laurent Pinchart