Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1264719rwl; Fri, 24 Mar 2023 08:17:05 -0700 (PDT) X-Google-Smtp-Source: AKy350aThcR+ERBSV7C8LTllHc+6kbR6MyeU22/ILssvOxewhaxN2eiuGvGfD/ApdhkSvhB8bHZk X-Received: by 2002:aa7:9696:0:b0:5a8:bcf2:125 with SMTP id f22-20020aa79696000000b005a8bcf20125mr3412398pfk.21.1679671024787; Fri, 24 Mar 2023 08:17:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679671024; cv=none; d=google.com; s=arc-20160816; b=uSFm72ezHYvA87oWl2G++Nl+coonZCTP2SOp0NLhXHawYR/o0MSTVbkOvFYsR8H2RU Gud6U6zwSbUzt3zXKn1n/Ue0ago/3Iu3khxbipoSpfAnJvJv+3XMJkWQBpn7u5pvg3uX fzDE+gM4u4NpTocjjBqXnzVhV3Kvw04k2/8fWBw6BrK6MFKA+emnz+WsmyetPGFoMphi lkS0NioNpwJPK3CBanYUfTm++XSLp9SLzyMJUUt46lyuRs4bZa5H0q5x3vAuAiSdbKfP I+VbA1yq7ZqtAJ60FFgo4Bk6svQybBmsa2Knh2gYnwqD4L9Ej/Wth0yKCur5OaSSLaq9 DTMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ibm3tSrzHRilK0eBOck6yRC9NMDYkOhhKkBru4BHJTA=; b=IisoFxGfz5EfbVl0t2lIAm5dTMoQ3U7VVsLmeCKQgJ3miruEVNd9EOsFEzEdiSOCS6 WMDVIbXEh3sr1pfgTmLOPBg/YqKAuRwlgdtWVR/KpRf9YI/ZOB5gEWtTCVtLfRNRm1kL D72npZxgbXOeK8j1pVzcbpmF2CSXDiIoxEks+KkpliCR7c6Nm9ZEXPGSCDMt56g30vKS hMahcYgk85HfciNWmjWpQADx7xfRtVjQcY4+KKFu/35P2hZX74NtDlRyuQ2sdqviPR/V RhSNER7NYqn1qeSyEcbHViyT+Z27R+NxTmS2I1+d93W7SOU+zT0TjlAuVaZmfkGUhjvT vhpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=maCXEZC9; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w10-20020a056a0014ca00b005a8cf0d93cbsi22538628pfu.3.2023.03.24.08.16.52; Fri, 24 Mar 2023 08:17:04 -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 header.i=@bootlin.com header.s=gm1 header.b=maCXEZC9; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232512AbjCXPNY (ORCPT + 99 others); Fri, 24 Mar 2023 11:13:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232421AbjCXPNK (ORCPT ); Fri, 24 Mar 2023 11:13:10 -0400 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::224]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5380BB476; Fri, 24 Mar 2023 08:12:51 -0700 (PDT) Received: (Authenticated sender: paul.kocialkowski@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 87CD6E000F; Fri, 24 Mar 2023 15:12:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1679670769; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ibm3tSrzHRilK0eBOck6yRC9NMDYkOhhKkBru4BHJTA=; b=maCXEZC95D2g/i9VZ5tpBHfFcnTLOUQJ1MypJvDDCf74A0M9WoHL5bs+RIwRk8bgrDLnXN ua+6SzvTtX7A4/h0T2boXWqL1VIW6zkPeSCNR52PjXpryFVOjA6Oz6PBLrvsX1wfsnaL1E qclE37AWysUEkygHd3MtLrv4KLfIs5Y8gjsghOpL6KtjSRx17KThxcbBbvCcOHnABoymVD c1MHQi4omFqhwewKM1z0AAYQXC9qoHtqm42V6XMfGgF0u/oAxzDYdcEsSvqLAg+8usLb53 MyqNJceNgYZwmqZsRjerh54qvZj3tWEhcGtvZL5gXJVE11aNVvUDVHvoouwQ7A== From: Paul Kocialkowski To: 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 Cc: Paul Kocialkowski , Mauro Carvalho Chehab , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Laurent Pinchart , Adam Pigg , Thomas Petazzoni Subject: [PATCH 6/9] media: sun6i-csi: capture: Implement MC I/O with extended enum_fmt Date: Fri, 24 Mar 2023 16:12:25 +0100 Message-Id: <20230324151228.2778112-7-paul.kocialkowski@bootlin.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230324151228.2778112-1-paul.kocialkowski@bootlin.com> References: <20230324151228.2778112-1-paul.kocialkowski@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,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 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; + + if (index == index_valid) { + 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; video_dev->fops = &sun6i_csi_capture_fops; -- 2.39.2