From patchwork Thu Nov 26 15:01:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 333021 Delivered-To: patch@linaro.org Received: by 2002:a92:5e16:0:0:0:0:0 with SMTP id s22csp1385040ilb; Thu, 26 Nov 2020 07:02:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJzfmG/pD5Y9L6rwbTnYJVhJdQL6wpPqnD7xALAn/aXupxpvRnj90kPTYbSjDkCuJ4R8BII6 X-Received: by 2002:a50:9f2b:: with SMTP id b40mr3054930edf.20.1606402942626; Thu, 26 Nov 2020 07:02:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606402942; cv=none; d=google.com; s=arc-20160816; b=I+NkbPu0ITonNt2zQMMcVIBcOGYmvnMnX1Rzf7CSdf0YYav4ArnnIprFq/f7Iix33i u14TPVf86K93oyOtn6uCbpk+IfQCWEykJh6HPbaBMGD17dPDNAXd7opZFXB5GvE1J1EA sOKM0AnmNG2824ZLO0V4rojcMoSKo2mjLO94kssFnuGmP58QckKbAbCbCBn36A0dN9e1 pfts+XBLN7xrRzCmX4ku1KDo7+SqZBjaYHCweVRI+4peI1pIbi9huaXQnZn3wrwiVvy0 vIR5gv0vOeVKpnvpYySTo0FRAOttuYQcb00R7wMQ7FiyoKS7+HLMCfRTEI2xnVujkUin noZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=P8v5qCpTMD0dws38PXKVsDk7ryFQPD3D9X3Qd0ARTjA=; b=nqKrF7fh2TNhgk0qYNxCq4PIhsiVz0VWJjqdT6itgEpaGV6wsH6HUbIThQGCYny1e/ AyVpQRdQ+Ifl6vVF62451zPT9Mt8taim1SwPTyK6HVcxfos4g4BbuRkFedcFfFKZSqUs 8hmOUDyY3L/RfmTrxwPWQ4SMYLInzaNJsBYC50jdYIxiO3Sg2MaGa9r0RC7AnqmatG1P v2VUBLhDsf4TF3HiiPpQhaXdwzqvtNQOAt5W0WK6UQHYxFnzoMMLTuVRYFzoKIxRjImB 7zgdvMm+TL/mu095sf6rmGmkQDxGB8Te/rrFi4MGOqwnhUuua+jETuD3JK6+Cd5Ktyta nG7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DrUDjw3P; spf=pass (google.com: domain of linux-media-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lt13si3372230ejb.564.2020.11.26.07.02.22; Thu, 26 Nov 2020 07:02:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-media-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DrUDjw3P; spf=pass (google.com: domain of linux-media-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391298AbgKZPCV (ORCPT + 4 others); Thu, 26 Nov 2020 10:02:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391130AbgKZPCT (ORCPT ); Thu, 26 Nov 2020 10:02:19 -0500 Received: from mail-lf1-x144.google.com (mail-lf1-x144.google.com [IPv6:2a00:1450:4864:20::144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C87FC0613D4 for ; Thu, 26 Nov 2020 07:02:19 -0800 (PST) Received: by mail-lf1-x144.google.com with SMTP id z21so2900748lfe.12 for ; Thu, 26 Nov 2020 07:02:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=P8v5qCpTMD0dws38PXKVsDk7ryFQPD3D9X3Qd0ARTjA=; b=DrUDjw3PuSHaxWq12cEqrR3lUFkuVHGxGGVFOVbiXfiCHUR85rk+guQ1e6owOzPZHy 9jI4XJfZuuHh0wOsZJok2CezwTXHGBXJQbNaOR5zm1rgCZAmtIvEvPwOBrmiv1dhgpez xhunng7JKKB3y8DhKmgrRV8ekxowHzlbfXdidplYM2szOOPtAAP6h3NjQzGzsyu1x6cl Q2iZoQAcVbFPD8SHZCiBcwxbksVBBW0YQ2mzIs+++4ZV5UE8L0K+4YLGFu6xDXdIOmzm jtRYvPCXa73DpEFNG6apIH65ZYY4clfDWxfnMkSoEAt7EyWE9x6sJHBYm4HsI7Jqt1EB ci9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=P8v5qCpTMD0dws38PXKVsDk7ryFQPD3D9X3Qd0ARTjA=; b=SbJ577SH2ogsAblhcu4rhLbL0AlXgHoF3hSsv5k7Y5BU/K/2w9STHs8fYXR8pSER3O JiwPR8qLVvxkxgStM9+08dFnoDzzbxDxPa2WPXvjDJG6dOEboogtzv/ZNq5Kp7Y14FYv 94qHoeLQTwHVjNmzNvHwmhgCPx3OmIdoW0nf7DCDtSwbUItvBq2OzZ/vlUpj46LT9Jz3 E3GAFEKR+rpM6D9GCi2X3jid7g16U3tyEo7/3vVv1oGfrWp52kTCufSHDaVjqjQRNTlm BXpZkB/Vl3EV8xJ8mnibOp6LefGJk/RdkxP2Dykv+wwA8Fy4jpHvCUbvdkO6WQ3nmHHM lgcg== X-Gm-Message-State: AOAM53354PjLkdRB6DP2wyzjmWYCsM0j1fm1xQf+lmC1KCwTHWzyrx+T UMUUrCP3xsG7lSSFW/2EEr/seQ== X-Received: by 2002:a19:715:: with SMTP id 21mr1436359lfh.289.1606402937696; Thu, 26 Nov 2020 07:02:17 -0800 (PST) Received: from localhost.localdomain ([85.249.45.205]) by smtp.googlemail.com with ESMTPSA id i12sm339481lfj.264.2020.11.26.07.02.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Nov 2020 07:02:16 -0800 (PST) From: Andrey Konovalov To: =mchehab@kernel.org, robert.foss@linaro.org Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, peter.griffin@linaro.org, marc.w.gonzalez@free.fr, Andrey Konovalov Subject: [PATCH v2 1/2] Revert "media: camss: Make use of V4L2_CAP_IO_MC" Date: Thu, 26 Nov 2020 18:01:56 +0300 Message-Id: <20201126150157.25870-1-andrey.konovalov@linaro.org> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org This reverts commit c90f1178dcac30dee5ddd29ec0513e7589aa866e. The assumption of "Each entry in formats[] table has unique mbus_code" is valid for the RDI entities, but not for the PIX ones. Reverting this patch and creating a new one which handles the PIX entities correctly results in smaller and more straightforward patch than doing the changes on top of the current version. Signed-off-by: Andrey Konovalov Reviewed-by: Robert Foss --- Changes in v2: - Fix the misprint in the commit description .../media/platform/qcom/camss/camss-video.c | 67 ++++--------------- 1 file changed, 13 insertions(+), 54 deletions(-) -- 2.17.1 diff --git a/drivers/media/platform/qcom/camss/camss-video.c b/drivers/media/platform/qcom/camss/camss-video.c index 114c3ae4a4ab..20673de9020e 100644 --- a/drivers/media/platform/qcom/camss/camss-video.c +++ b/drivers/media/platform/qcom/camss/camss-video.c @@ -535,16 +535,17 @@ static int video_querycap(struct file *file, void *fh, return 0; } -/* - * Returns the index in the video->formats[] array of the element which - * has the "ndx"th unique value of pixelformat field. - * If not found (no more unique pixelformat's) returns -EINVAL. - */ -static int video_get_unique_pixelformat_by_index(struct camss_video *video, - int ndx) +static int video_enum_fmt(struct file *file, void *fh, struct v4l2_fmtdesc *f) { + struct camss_video *video = video_drvdata(file); int i, j, k; + if (f->type != video->type) + return -EINVAL; + + if (f->index >= video->nformats) + return -EINVAL; + /* find index "i" of "k"th unique pixelformat in formats array */ k = -1; for (i = 0; i < video->nformats; i++) { @@ -557,53 +558,11 @@ static int video_get_unique_pixelformat_by_index(struct camss_video *video, if (j == i) k++; - if (k == ndx) - return i; - } - - return -EINVAL; -} - -/* - * Returns the index in the video->formats[] array of the element which - * has code equal to mcode. - * If not found returns -EINVAL. - */ -static int video_get_pixelformat_by_mbus_code(struct camss_video *video, - u32 mcode) -{ - int i; - - for (i = 0; i < video->nformats; i++) { - if (video->formats[i].code == mcode) - return i; - } - - return -EINVAL; -} - -static int video_enum_fmt(struct file *file, void *fh, struct v4l2_fmtdesc *f) -{ - struct camss_video *video = video_drvdata(file); - int i; - - if (f->type != video->type) - return -EINVAL; - - if (f->index >= video->nformats) - return -EINVAL; - - if (f->mbus_code) { - /* Each entry in formats[] table has unique mbus_code */ - if (f->index > 0) - return -EINVAL; - - i = video_get_pixelformat_by_mbus_code(video, f->mbus_code); - } else { - i = video_get_unique_pixelformat_by_index(video, f->index); + if (k == f->index) + break; } - if (i < 0) + if (k < f->index) return -EINVAL; f->pixelformat = video->formats[i].pixelformat; @@ -989,8 +948,8 @@ int msm_video_register(struct camss_video *video, struct v4l2_device *v4l2_dev, } vdev->fops = &msm_vid_fops; - vdev->device_caps = V4L2_CAP_VIDEO_CAPTURE_MPLANE | V4L2_CAP_STREAMING - | V4L2_CAP_READWRITE | V4L2_CAP_IO_MC; + vdev->device_caps = V4L2_CAP_VIDEO_CAPTURE_MPLANE | V4L2_CAP_STREAMING | + V4L2_CAP_READWRITE; vdev->ioctl_ops = &msm_vid_ioctl_ops; vdev->release = msm_video_release; vdev->v4l2_dev = v4l2_dev; From patchwork Thu Nov 26 15:01:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 333022 Delivered-To: patch@linaro.org Received: by 2002:a92:5e16:0:0:0:0:0 with SMTP id s22csp1385216ilb; Thu, 26 Nov 2020 07:02:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJyZ9sY/7kBWNDASn5dyrhiXGZwW34/am/cWp6DI3KVByXtjqm7G5p+0wsbYdniAQMnixIjN X-Received: by 2002:a17:906:179a:: with SMTP id t26mr3148901eje.49.1606402954683; Thu, 26 Nov 2020 07:02:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606402954; cv=none; d=google.com; s=arc-20160816; b=PSumNpwxbQFs1LwTjBGaVMkthCt6GjnssSPriiYFb2qJhSXStiNYnWEaF6km4Z6Jyr O+tl6U55AmimHQc1g3A1aHaQWagjzG11RW5qsGCoIQpAzDHDv7DhUJT+9/ZPjGDCpxe0 uabnny+SSbAoKliDjZcca7XzgwAG6ey71IJJ+CGC/qTRZfblUY37FD8xe6c0lmGddffy eHNqwJLmYskB+O4J5LUbaJIDZ9oHeoKqU7THHHKt7Vy0W/M7IG1ZUZNibD+5vK68/Ms6 Dq+YljLcl3n4CSXV39VcWz06pCqnz32oyjLYWdICxkB8F0ymJKkw8m+jnKN2TzWkuGXy j/cQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=tKIO7ZHqYV5jy4apxisfQrLSwqPSVll/CP0rdQ/t36s=; b=FnQ0kq4pT9A2sHTPrqdteAwkxJdLGFU+1sZD/uUTkyRwRuMWSmR9l8OcXmNKIXHRZp UNEQ/sE37g+C1iruhYVQKp87lZsGAdfojmKX/p/S0mO/Voa+/1ba1TG/SzkCUwlXZEb5 s5yrj0cpbwyhA4Wf6zjn6YTHZZDfk7iKJmTjmKr8De84g50y9ZLBVNHFUATqlIfR72UI u4PZ1Sx+L+XPilujfQ7SS0xw92j5QHMxr+IKiTzBe8J1kdu1Ne4XmSQyn9NiDHi0O2AE InUIX5Q2mSZs54m9Y9o9VetUuQ2N4Oi6HctFK9HZguKY/ZncpCInsaYfcq1M6rF6x0Je QoWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PzsXu+oH; spf=pass (google.com: domain of linux-media-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lt13si3372230ejb.564.2020.11.26.07.02.34; Thu, 26 Nov 2020 07:02:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-media-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PzsXu+oH; spf=pass (google.com: domain of linux-media-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391308AbgKZPCZ (ORCPT + 4 others); Thu, 26 Nov 2020 10:02:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391306AbgKZPCZ (ORCPT ); Thu, 26 Nov 2020 10:02:25 -0500 Received: from mail-lj1-x244.google.com (mail-lj1-x244.google.com [IPv6:2a00:1450:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00B74C0617A7 for ; Thu, 26 Nov 2020 07:02:25 -0800 (PST) Received: by mail-lj1-x244.google.com with SMTP id s9so2644271ljo.11 for ; Thu, 26 Nov 2020 07:02:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tKIO7ZHqYV5jy4apxisfQrLSwqPSVll/CP0rdQ/t36s=; b=PzsXu+oHHKcZsFBm1dpqOuWjNTBUgYFOZgHefsg5h3z3+9GSFA91iYeDFkvM2yWrt2 sec6fls3/ZYRba1XNNR/fpBrAJ8rL9MwrRngXY+RhjGhap8LHrlIXTJGCjPtXyz1qLC8 8NoPw9ZGOwXtptrYzbm4aAlzCKD9mgafWDsjXfrBG8sj3HIQEzMa7RWq7z3y+Nesxk0w vlNZVe6PUyFETNRmb8Eh3rTN/fElCGtTR4uEyl18dZ2MW2G8xioMBVVBES/0MCcULWr3 ddY3j9F/zaH1KN1ancw0Fv/yEnRqYKDlbuGvLR5ybdOC5CsBA6/zp3nEzEmHTW5V+dIg Kjsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=tKIO7ZHqYV5jy4apxisfQrLSwqPSVll/CP0rdQ/t36s=; b=jZvj5B+PIyEDxGihpMgcjPt2LMoO4moUtDwxfbIX+yWmjzgmqpswZWgJiFyItdOWo6 hWtZUQU6EHPG1hzM3i58JG7NzN0QAHG/ppwt2tq4Fim1mmI7z8g0128rlI6M9k0g2KZ6 bm9YEH9oY8Hpq1TCw3JIJ2S6C5HiRFDrs6dAvSFcdybF32Wl7bA4gwwlksONfbV7d/ou 27AQb1Fz4P9MuP5mJy/4oioCJogthhLe/L5FPKVYCDHVP0Ulh8Mcg9m91PJTM4P4glFL 2Oq7BztBzhDIOa6pDYRdsOh7ExSZNBOcBPUkQeVxJ0BwF1spAca74wTyz/Y5wRv3x4+K VQ9Q== X-Gm-Message-State: AOAM530TUjwy11+KPRQyw5ZSXg3AQn0ueZ+0HYqmQ8ciBgAAxNh+5zOz Fb1W73s5lJ4VzSQt9hMKHVP7MQ== X-Received: by 2002:a2e:9a02:: with SMTP id o2mr1422175lji.1.1606402942973; Thu, 26 Nov 2020 07:02:22 -0800 (PST) Received: from localhost.localdomain ([85.249.45.205]) by smtp.googlemail.com with ESMTPSA id i12sm339481lfj.264.2020.11.26.07.02.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Nov 2020 07:02:21 -0800 (PST) From: Andrey Konovalov To: =mchehab@kernel.org, robert.foss@linaro.org Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, peter.griffin@linaro.org, marc.w.gonzalez@free.fr, Andrey Konovalov Subject: [PATCH v2 2/2] media: camss: Make use of V4L2_CAP_IO_MC Date: Thu, 26 Nov 2020 18:01:57 +0300 Message-Id: <20201126150157.25870-2-andrey.konovalov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201126150157.25870-1-andrey.konovalov@linaro.org> References: <20201126150157.25870-1-andrey.konovalov@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Implement mbus_code filtering for format enumeration. Without this patch libcamera errors out with: "ERROR V4L2 v4l2_videodevice.cpp:982 /dev/video0[cap]: Media bus code filtering not supported by the device" This is the second version of this change which handles the case of several pixel formats corresponding to one media bus format correctly. Signed-off-by: Andrey Konovalov Reviewed-by: Robert Foss --- Changes in v2: - Added the comments to explain V4L2_CAP_IO_MC capability and the way it is implemented in camss driver .../media/platform/qcom/camss/camss-video.c | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/drivers/media/platform/qcom/camss/camss-video.c b/drivers/media/platform/qcom/camss/camss-video.c index 20673de9020e..a9bc5438ced3 100644 --- a/drivers/media/platform/qcom/camss/camss-video.c +++ b/drivers/media/platform/qcom/camss/camss-video.c @@ -539,6 +539,7 @@ static int video_enum_fmt(struct file *file, void *fh, struct v4l2_fmtdesc *f) { struct camss_video *video = video_drvdata(file); int i, j, k; + u32 mcode = f->mbus_code; if (f->type != video->type) return -EINVAL; @@ -546,10 +547,26 @@ static int video_enum_fmt(struct file *file, void *fh, struct v4l2_fmtdesc *f) if (f->index >= video->nformats) return -EINVAL; - /* find index "i" of "k"th unique pixelformat in formats array */ + /* + * Find index "i" of "k"th unique pixelformat in formats array. + * + * If f->mbus_code passed to video_enum_fmt() is not zero, a device + * with V4L2_CAP_IO_MC capability restricts enumeration to only the + * pixel formats that can be produced from that media bus code. + * This is implemented by skipping video->formats[] entries with + * code != f->mbus_code (if f->mbus_code is not zero). + * If the f->mbus_code passed to video_enum_fmt() is not supported, + * -EINVAL is returned. + * If f->mbus_code is zero, all the pixel formats are enumerated. + */ k = -1; for (i = 0; i < video->nformats; i++) { + if (mcode != 0 && video->formats[i].code != mcode) + continue; + for (j = 0; j < i; j++) { + if (mcode != 0 && video->formats[j].code != mcode) + continue; if (video->formats[i].pixelformat == video->formats[j].pixelformat) break; @@ -563,6 +580,11 @@ static int video_enum_fmt(struct file *file, void *fh, struct v4l2_fmtdesc *f) } if (k < f->index) + /* + * All the unique pixel formats matching the arguments + * have been enumerated (k >= 0 and f->index > 0), or + * no pixel formats match the non-zero f->mbus_code (k == -1). + */ return -EINVAL; f->pixelformat = video->formats[i].pixelformat; @@ -948,8 +970,8 @@ int msm_video_register(struct camss_video *video, struct v4l2_device *v4l2_dev, } vdev->fops = &msm_vid_fops; - vdev->device_caps = V4L2_CAP_VIDEO_CAPTURE_MPLANE | V4L2_CAP_STREAMING | - V4L2_CAP_READWRITE; + vdev->device_caps = V4L2_CAP_VIDEO_CAPTURE_MPLANE | V4L2_CAP_STREAMING + | V4L2_CAP_READWRITE | V4L2_CAP_IO_MC; vdev->ioctl_ops = &msm_vid_ioctl_ops; vdev->release = msm_video_release; vdev->v4l2_dev = v4l2_dev;