Received: by 2002:a05:7412:a9a3:b0:f9:327e:43ab with SMTP id o35csp25217rdh; Mon, 18 Dec 2023 03:19:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IGpmXg/la7fYKHO4kSD/F5qxq6KdB4Ay03wMa0b7UJH8Wn9hBAqWT7Zjp7m3x29/axYbbqj X-Received: by 2002:a17:903:22cd:b0:1d3:c08d:ba9d with SMTP id y13-20020a17090322cd00b001d3c08dba9dmr1212703plg.68.1702898396202; Mon, 18 Dec 2023 03:19:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702898396; cv=none; d=google.com; s=arc-20160816; b=BipAgDsA13dE4QsCatxHT7uCRfZvFP3Hpp9Xx8nXaEFgsC3oMTY4iNwx8AnxH1euv/ iBlVbB6lJvdwmYXqVS4cBhc5IE58Jl6H0jgXM5p+xEPLo/fVPK9VP33oILWX7oQvl5ss 75DbyRS6c24yzjJX4psLZHppze+qBgDsrHKd2R9XgIAnIBoDUiCf1zM1AJ1C+X1l2PQ4 Ueb1X83at0RdRtNR/8zMfkK8qYVYffNg+VsJ8iryRYQtBHe7DRrEk6btmpwaTZ0j93BD 7X39QWN7oYAObsqxTfY3lgo+G6hyxWq2pwHFrQmyUYaD4bH6AEPmq7KCTg7ouNsykFIi fpsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=t8kHNFe/eGO0I6G9ZddI076fRWeZyLjc7sbCR2/u9Pw=; fh=YL4sK9lWJF+0xm1Zp3wdy3/DzOxZ7Q6XBCMrX4YtL4s=; b=GXXofyLVaVbo6PXAgY2vX0LM5iSFG2w5SLmZ5cpMMeTTjjuTzwzOE84HL3u3wCuBxw 1C7BOVlMH9a7WKT1DhgVeghJmt7FhO84j9UckINpDAcTA3rFfzIvE/1rm/CyNIy2xLz8 zpNkmDfwcQP2SfaWnpZYb8KeGt9QpEbv0puZsSunjRCgkEZuyzZLteP2rnS7uZ33Y46s LkRGgWZZQ+8YReL+7OJLDAqkL035glZL+u6ks4olbRv1XbhlXd/jy1itnW4lgQoJgefL Y41plN1p7Jaitl0iaAMn5AmZr4swGo0ZYqQ+QPYpTRSIBsDGtBV6/YYj8Kwe9ziLKQFn ZaJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=JQr5Yf7l; spf=pass (google.com: domain of linux-kernel+bounces-3423-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3423-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id u19-20020a17090ae01300b002773d013d02si17872494pjy.140.2023.12.18.03.19.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 03:19:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-3423-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=JQr5Yf7l; spf=pass (google.com: domain of linux-kernel+bounces-3423-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3423-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id E3F3A283E5D for ; Mon, 18 Dec 2023 11:19:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0326C199B2; Mon, 18 Dec 2023 11:19:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JQr5Yf7l" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-ed1-f50.google.com (mail-ed1-f50.google.com [209.85.208.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8A0D619BD8; Mon, 18 Dec 2023 11:19:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-f50.google.com with SMTP id 4fb4d7f45d1cf-553729ee917so389171a12.1; Mon, 18 Dec 2023 03:19:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702898379; x=1703503179; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=t8kHNFe/eGO0I6G9ZddI076fRWeZyLjc7sbCR2/u9Pw=; b=JQr5Yf7l8NQ2SmONhmoIvSATzhD5QPnuTK9hM/+05lPXoO4BzZ/n4z6toX0lKOPBbQ 1edZ6MRgv39+I8H0Bx/pt0wyC1kpZwMCyT7wDNMArDfZwttEvJs23PSphIJH5eyxKBLS g3HnSjQUQnI8AvDPoaNyprOa4sazBEcHqbJoAyNu4mxUMjUoiVPOzvD1tDuHbxsqfQLi 5yu7nS3wuO6LDAqe8Law1q0/6OsQyYZ4NjNiQdUzjMO5ANGlqgtL2nvZh5TpuawsvXDL BIM735tubovi/lWSCvV6t9QJuw7q/a/zgvC28/cv4KAaO3zBjHpO9lNH4bTRRVKYWfTq QlUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702898379; x=1703503179; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=t8kHNFe/eGO0I6G9ZddI076fRWeZyLjc7sbCR2/u9Pw=; b=XJYqILUxo9WfdArYKuaoIH5jVp5dNUyN0fL08D4J2lvCHyhvzFW5ggVURrryp9jTuy FomXqrPShyfWbQVkblvLwT1LFzXAQpEBqgQ/1ysrixowiPX6tdMbMoAASmObJwrkm4TI X4/lZxRAwUWIdfkrFlOo4bLhG3Y+ovHHvdwmrTIRBxe1d/Q9u0xNldFafKRGDzhgYqxE xbvw62A3x2hPORUmDpkHhxgMUvQn/8CgHybA1XBqLMLdG5giy4RlM/RqD3+SzUJOf3Pe csiyG/iwmX3tRxPH6EigK9LXl3vqHTryuTjltRa5f3PQeUfrUt2lG4BBn1wyJxt0xMXy nQzA== X-Gm-Message-State: AOJu0YxOnGliS79+vPg3ik6C40iO2IDybSaGdHZCwvJTP9pIbsFhOFSm Klw79xvSuJiwcfQS6LHCEnANPlqcmp4= X-Received: by 2002:a50:a69e:0:b0:54c:c9a4:83df with SMTP id e30-20020a50a69e000000b0054cc9a483dfmr10140643edc.26.1702898378705; Mon, 18 Dec 2023 03:19:38 -0800 (PST) Received: from tom-HP-ZBook-Fury-15-G7-Mobile-Workstation (net-188-217-59-229.cust.vodafonedsl.it. [188.217.59.229]) by smtp.gmail.com with ESMTPSA id k13-20020a50cb8d000000b0054cc7a4dc4csm10211082edi.13.2023.12.18.03.19.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 03:19:38 -0800 (PST) Date: Mon, 18 Dec 2023 12:19:36 +0100 From: Tommaso Merciai To: Laurent Pinchart Cc: linuxfancy@googlegroups.com, sakari.ailus@linux.intel.com, Martin Hecht , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/3] media: i2c: alvium: store frame interval in subdev state Message-ID: References: <20231215082452.1720481-1-tomm.merciai@gmail.com> <20231215082452.1720481-4-tomm.merciai@gmail.com> <20231218025905.GJ5290@pendragon.ideasonboard.com> <20231218110331.GQ5290@pendragon.ideasonboard.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231218110331.GQ5290@pendragon.ideasonboard.com> Hi Laurent, Thanks for your quick reply. On Mon, Dec 18, 2023 at 01:03:31PM +0200, Laurent Pinchart wrote: > On Mon, Dec 18, 2023 at 11:30:38AM +0100, Tommaso Merciai wrote: > > Hi Laurent, > > > > On Mon, Dec 18, 2023 at 04:59:05AM +0200, Laurent Pinchart wrote: > > > Hi Tommaso, > > > > > > Thank you for the patch. > > > > > > On Fri, Dec 15, 2023 at 09:24:52AM +0100, Tommaso Merciai wrote: > > > > Use the newly added storage for frame interval in the subdev state to > > > > simplify the driver. > > > > > > > > Signed-off-by: Tommaso Merciai > > > > --- > > > > drivers/media/i2c/alvium-csi2.c | 40 ++++++++++----------------------- > > > > drivers/media/i2c/alvium-csi2.h | 2 -- > > > > 2 files changed, 12 insertions(+), 30 deletions(-) > > > > > > > > diff --git a/drivers/media/i2c/alvium-csi2.c b/drivers/media/i2c/alvium-csi2.c > > > > index fde456357be1..81f683b3c849 100644 > > > > --- a/drivers/media/i2c/alvium-csi2.c > > > > +++ b/drivers/media/i2c/alvium-csi2.c > > > > @@ -1643,25 +1643,6 @@ static int alvium_hw_init(struct alvium_dev *alvium) > > > > } > > > > > > > > /* --------------- Subdev Operations --------------- */ > > > > - > > > > -static int alvium_g_frame_interval(struct v4l2_subdev *sd, > > > > - struct v4l2_subdev_state *sd_state, > > > > - struct v4l2_subdev_frame_interval *fi) > > > > -{ > > > > - struct alvium_dev *alvium = sd_to_alvium(sd); > > > > - > > > > - /* > > > > - * FIXME: Implement support for V4L2_SUBDEV_FORMAT_TRY, using the V4L2 > > > > - * subdev active state API. > > > > - */ > > > > - if (fi->which != V4L2_SUBDEV_FORMAT_ACTIVE) > > > > - return -EINVAL; > > > > - > > > > - fi->interval = alvium->frame_interval; > > > > - > > > > - return 0; > > > > -} > > > > - > > > > static int alvium_s_frame_interval(struct v4l2_subdev *sd, > > > > struct v4l2_subdev_state *sd_state, > > > > struct v4l2_subdev_frame_interval *fi) > > > > @@ -1669,6 +1650,7 @@ static int alvium_s_frame_interval(struct v4l2_subdev *sd, > > > > struct alvium_dev *alvium = sd_to_alvium(sd); > > > > struct device *dev = &alvium->i2c_client->dev; > > > > u64 req_fr, dft_fr, min_fr, max_fr; > > > > + struct v4l2_fract *interval; > > > > int ret; > > > > > > > > /* > > > > > > You should drop the FIXME comment here and the ACTIVE check... > > > > Oks, thanks. > > > > > > > > > @@ -1701,9 +1683,10 @@ static int alvium_s_frame_interval(struct v4l2_subdev *sd, > > > > if (req_fr >= max_fr && req_fr <= min_fr) > > > > req_fr = dft_fr; > > > > > > > > - alvium->fr = req_fr; > > > > - alvium->frame_interval.numerator = fi->interval.numerator; > > > > - alvium->frame_interval.denominator = fi->interval.denominator; > > > > + interval = v4l2_subdev_state_get_interval(sd_state, 0); > > > > + > > > > + interval->numerator = fi->interval.numerator; > > > > + interval->denominator = fi->interval.denominator; > > > > > > > > > > ... and here only call alvium_set_frame_rate() for the ACTIVE frame > > > interval. > > > > I don't completely got this comment, can you give me more details about > > please. Thanks in advance! > > alvium_s_frame_interval() can be called both for the TRY and ACTIVE > status. The hardware registers should be written only for the ACTIVE > state. Do you think could be sufficient an if check like this? - return alvium_set_frame_rate(alvium, req_fr); + if (fi->which == V4L2_SUBDEV_FORMAT_ACTIVE) + return alvium_set_frame_rate(alvium, req_fr); + + return ret; } Thanks & Regards, Tommaso > > > > @@ -1853,6 +1836,7 @@ static int alvium_init_state(struct v4l2_subdev *sd, > > > > { > > > > struct alvium_dev *alvium = sd_to_alvium(sd); > > > > struct alvium_mode *mode = &alvium->mode; > > > > + struct v4l2_fract *interval; > > > > struct v4l2_subdev_format sd_fmt = { > > > > .which = V4L2_SUBDEV_FORMAT_TRY, > > > > .format = alvium_csi2_default_fmt, > > > > @@ -1870,6 +1854,11 @@ static int alvium_init_state(struct v4l2_subdev *sd, > > > > *v4l2_subdev_state_get_crop(state, 0) = sd_crop.rect; > > > > *v4l2_subdev_state_get_format(state, 0) = sd_fmt.format; > > > > > > > > + /* Setup initial frame interval*/ > > > > + interval = v4l2_subdev_state_get_interval(state, 0); > > > > + interval->numerator = 1; > > > > + interval->denominator = ALVIUM_DEFAULT_FR_HZ; > > > > + > > > > return 0; > > > > } > > > > > > > > @@ -2239,7 +2228,7 @@ static const struct v4l2_subdev_pad_ops alvium_pad_ops = { > > > > .set_fmt = alvium_set_fmt, > > > > .get_selection = alvium_get_selection, > > > > .set_selection = alvium_set_selection, > > > > - .get_frame_interval = alvium_g_frame_interval, > > > > + .get_frame_interval = v4l2_subdev_get_frame_interval, > > > > .set_frame_interval = alvium_s_frame_interval, > > > > }; > > > > > > > > @@ -2260,11 +2249,6 @@ static int alvium_subdev_init(struct alvium_dev *alvium) > > > > struct v4l2_subdev *sd = &alvium->sd; > > > > int ret; > > > > > > > > - /* Setup initial frame interval*/ > > > > - alvium->frame_interval.numerator = 1; > > > > - alvium->frame_interval.denominator = ALVIUM_DEFAULT_FR_HZ; > > > > - alvium->fr = ALVIUM_DEFAULT_FR_HZ; > > > > - > > > > /* Setup the initial mode */ > > > > alvium->mode.fmt = alvium_csi2_default_fmt; > > > > alvium->mode.width = alvium_csi2_default_fmt.width; > > > > diff --git a/drivers/media/i2c/alvium-csi2.h b/drivers/media/i2c/alvium-csi2.h > > > > index a6529b28e7dd..f5e26257b042 100644 > > > > --- a/drivers/media/i2c/alvium-csi2.h > > > > +++ b/drivers/media/i2c/alvium-csi2.h > > > > @@ -442,8 +442,6 @@ struct alvium_dev { > > > > s32 inc_sharp; > > > > > > > > struct alvium_mode mode; > > > > - struct v4l2_fract frame_interval; > > > > - u64 fr; > > > > > > The fr field should have been removed by a previous patch (the one that > > > will go between 1/3 an 2/3, see my review of 1/3) as shown by the fact > > > that this patch only removes two locations where the field is set but > > > none where it's read. > > > > > > > > > > > u8 h_sup_csi_lanes; > > > > u64 link_freq; > > -- > Regards, > > Laurent Pinchart