Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp956040rwl; Sat, 25 Mar 2023 14:32:57 -0700 (PDT) X-Google-Smtp-Source: AKy350a3UmeOBTWNr5GMWzQxSYggKn3k/WpkRZVfUw5f6tW/ZEbSZcr8ROnEVufwnSmxE3Q6kHCP X-Received: by 2002:a17:906:94c2:b0:932:d2bb:4fd with SMTP id d2-20020a17090694c200b00932d2bb04fdmr6672879ejy.58.1679779977242; Sat, 25 Mar 2023 14:32:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679779977; cv=none; d=google.com; s=arc-20160816; b=SzWVcipibgtitCvN9YGuDnd6a5T16naLder4aV+BJ4iucf44/zRYW/YLfJlrNCkzl9 CF1JJwvlmU1RBinCn02GvdXBWEGnCZ1ab5JFOGF+muH9kVhpXOUf6pld+Jc8BwnqwOPo RKFLj14p+fxH7YD1nGK5zh/A6GjdxuIJ28Try3rl2VeQFA4EEIeFITOLLmhbkkcdBu8P 6Q0yKl28DpnwTRxNkShGrUh9J3uIg/rCE6nFDmY4ucFxa8BWJ+SsiCN/8jZsnuKetYQW z5zDpydFt6dqwrVvVx+JRAuGlGJvJbx5kHlcrkmFAQfkMvSN5A+XtBsZPoqa9dEKhWPp 73yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ZRKsN9sXV5vGggYcbO0yr2Nl7bTQ0e7zGu8CXsmf03I=; b=YzZ+oy1OE46vigb0HRX48q17lYxGoaZs1CCDpobt+g1kZgK7pDPPO4Rasfwa3ucbsN 03THsMz0J5TehEvWW3pvChPBoYgQCoSAdUubycSfFuMiw1TtGUu9PJp2/ifmrXeM9ZT2 JCJ12qf68VMPDl1JdcpJzB3gOzMNqcx/hygT6IyI5LIPQRs0ToBcH8uq6K5BVzrKhMZy 6jEPJULMvF6gkC67Lkdx/TNo78ki47Z53dY5zEzmiOUbkUjMQ2ul2zcrWd9/jezHO8FL YKfNTAKAy2e4WFrgcxMtnvYvCNjSaml0sbhWHi51QeRERvBBllaNnrQxNYSH5gC2RYC9 QPEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=iRjNIJ5F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hr8-20020a1709073f8800b0093545cb338esi19627074ejc.747.2023.03.25.14.32.31; Sat, 25 Mar 2023 14:32:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=iRjNIJ5F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229596AbjCYV3u (ORCPT + 99 others); Sat, 25 Mar 2023 17:29:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229528AbjCYV3t (ORCPT ); Sat, 25 Mar 2023 17:29:49 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A25BCA36; Sat, 25 Mar 2023 14:29:48 -0700 (PDT) Received: from pendragon.ideasonboard.com (213-243-189-158.bb.dnainternet.fi [213.243.189.158]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 5500A8BE; Sat, 25 Mar 2023 22:29:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1679779786; bh=Jpj+akEfg2jGUqXOXG5JWaUslPt6fAU0Vc613gWhvT0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=iRjNIJ5FwvxoAj4MESIMf+5qXpJxHj/nxIU/EQ+GUL3Yd8VLhtwda9uFVFgBprHsw 97fp1wiGJlIPH/xaoZ7pwHofdeKrrDd/SVtAOd02nZ0pphEmJyhTc/OhWwPQhmsCsQ VDrEA1pyLEdi4cub86kR9/LLr2/Ylso5qyPQ86jY= Date: Sat, 25 Mar 2023 23:29:53 +0200 From: Laurent Pinchart To: Paul Kocialkowski Cc: linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, Mauro Carvalho Chehab , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Adam Pigg , Thomas Petazzoni Subject: Re: [PATCH 6/9] media: sun6i-csi: capture: Implement MC I/O with extended enum_fmt Message-ID: <20230325212953.GD22214@pendragon.ideasonboard.com> References: <20230324151228.2778112-1-paul.kocialkowski@bootlin.com> <20230324151228.2778112-7-paul.kocialkowski@bootlin.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20230324151228.2778112-7-paul.kocialkowski@bootlin.com> X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Paul, Thank you for the patch. On Fri, Mar 24, 2023 at 04:12:25PM +0100, Paul Kocialkowski wrote: > This driver needs the media-controller API to operate and should not be > considered as a video-device-centric implementation. > > Properly report the IO_MC device cap and extend the enum_fmt > implementation to support enumeration with an explicit mbus_code. > > Signed-off-by: Paul Kocialkowski > --- > .../sunxi/sun6i-csi/sun6i_csi_capture.c | 36 ++++++++++++++++--- > 1 file changed, 32 insertions(+), 4 deletions(-) > > diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c > index 6ce7f1d3ed57..9627030ff060 100644 > --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c > +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c > @@ -777,13 +777,40 @@ static int sun6i_csi_capture_enum_fmt(struct file *file, void *private, > struct v4l2_fmtdesc *fmtdesc) > { > u32 index = fmtdesc->index; > + u32 mbus_code = fmtdesc->mbus_code; > + unsigned int index_valid = 0; > + unsigned int i; > + > + if (!mbus_code) { > + if (index >= ARRAY_SIZE(sun6i_csi_capture_formats)) > + return -EINVAL; > + > + fmtdesc->pixelformat = > + sun6i_csi_capture_formats[index].pixelformat; > + > + return 0; > + } > + > + /* Check capture pixel format matching with mbus code. */ > > - if (index >= ARRAY_SIZE(sun6i_csi_capture_formats)) > + if (!sun6i_csi_bridge_format_find(mbus_code)) > return -EINVAL; > > - fmtdesc->pixelformat = sun6i_csi_capture_formats[index].pixelformat; > + for (i = 0; i < ARRAY_SIZE(sun6i_csi_capture_formats); i++) { > + u32 pixelformat = sun6i_csi_capture_formats[i].pixelformat; > > - return 0; > + if (!sun6i_csi_capture_format_check(pixelformat, mbus_code)) > + continue; I would probably have added compatible media bus codes to the sun6i_csi_capture_format structure. This should work though, even if it is more CPU-intensive. I'm OK with either option. > + > + if (index == index_valid) { You can replace this with if (index == 0) { and index_valid++; with index--; below, and drop the index_valid variable. > + fmtdesc->pixelformat = pixelformat; > + return 0; > + } > + > + index_valid++; > + } > + > + return -EINVAL; > } > > static int sun6i_csi_capture_g_fmt(struct file *file, void *private, > @@ -1039,7 +1066,8 @@ int sun6i_csi_capture_setup(struct sun6i_csi_device *csi_dev) > > strscpy(video_dev->name, SUN6I_CSI_CAPTURE_NAME, > sizeof(video_dev->name)); > - video_dev->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING; > + video_dev->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING | > + V4L2_CAP_IO_MC; > video_dev->vfl_dir = VFL_DIR_RX; > video_dev->release = video_device_release_empty; -- Regards, Laurent Pinchart