Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5428625img; Wed, 27 Mar 2019 08:20:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqw6X5d5ydNkp/XlbqdqO7xJAyGcZQg9q8TrTBt5ZXhYJF0FBnTcHb4rTaFV1bSBm/1yxxNi X-Received: by 2002:a17:902:b788:: with SMTP id e8mr27276720pls.339.1553700047461; Wed, 27 Mar 2019 08:20:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553700047; cv=none; d=google.com; s=arc-20160816; b=XqVcWTsfUbqxgilTfZnyhbd9wUv3HjgILC1SQizjkqmxpl2XBq/4MGyjIMur9xXiEe mn/8fhsY6q1XMAP9quylGfqovmbef3mfs+e2X15Hyug5eqN17YqW+sHQ3WGUXNKPsWTu ke4oc79FrG/TperO/+gva9I7wj+gToPI8w9PqA0bOb1+jbEkYfl9OLnDMXgMfhKrnYvb 3X8jp737eLJTpRZupbElYHGJ3pQIQkGeurub1HgK+6zepJG4QwEDHr6hm2I3KDJ3LEC1 m9h6AIdtBh+teT/ucM8fxeDsnGoUgcZMVPaZU/iUeDCWbpy31BJQ4ZvG4mqvasFTe8ka xtdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=pOEt082/qmHuQ+1wqx6lYhB6M7Scgu0MHHIU9N4kG/U=; b=fzYTOPU+lIL0OHSasC4FbX7qzJCG6RHsuF5s3TAAPqWeOM19s1zAenuB0y2KgDIaVr 1oj3SDtmnlOnyAT48C22maYQm0py9iG5jGaUXa7V8EKsIJKGa3RVDuNLHQtIVtT9rOHp USCZlrxGw3KIeHifB6V6KnB4ipoWUm4spqAzmiYfu4/xsP7+eeJEqaB/0WMMDnm5bCub 4O1BjQNQSRXCBEPoVEhyb5Cbaq6jGTRnyCkAaZFn0VISgfOxuJKK3V/Rro9q/sTFDlSb 4iaY+fcWbd7MDNMqj9o5PgGyMd6s6/Y0I3MbJhIVvPvYCpAjiQ+CIqjAKtVv+1jW5nCo L+3w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m18si18317766pgl.483.2019.03.27.08.20.31; Wed, 27 Mar 2019 08:20:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730800AbfC0PT1 (ORCPT + 99 others); Wed, 27 Mar 2019 11:19:27 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:48542 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730546AbfC0PTV (ORCPT ); Wed, 27 Mar 2019 11:19:21 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: tonyk) with ESMTPSA id 603A8281FF3 From: =?UTF-8?q?Andr=C3=A9=20Almeida?= To: linux-media@vger.kernel.org Cc: mchehab@kernel.org, hverkuil@xs4all.nl, helen.koike@collabora.com, lucmaga@gmail.com, linux-kernel@vger.kernel.org, kernel@collabora.com, lkcamp@lists.libreplanetbr.org Subject: [PATCH v2 07/15] media: vimc: cap: Add multiplanar formats Date: Wed, 27 Mar 2019 12:17:35 -0300 Message-Id: <20190327151743.18528-8-andrealmeid@collabora.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190327151743.18528-1-andrealmeid@collabora.com> References: <20190327151743.18528-1-andrealmeid@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add multiplanar formats to be exposed to the userspace as supported formats. Since we don't want to support multiplanar formats when the driver is in singleplanar mode, we only access the multiplanar formats array if the multiplanar mode is enabled. Signed-off-by: André Almeida --- Changes in v2: - Change line break style - Add TODO comment drivers/media/platform/vimc/vimc-capture.c | 34 ++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/vimc/vimc-capture.c b/drivers/media/platform/vimc/vimc-capture.c index 5e13c6580aff..a65611be63bb 100644 --- a/drivers/media/platform/vimc/vimc-capture.c +++ b/drivers/media/platform/vimc/vimc-capture.c @@ -32,6 +32,10 @@ #define IS_MULTIPLANAR(vcap) \ (vcap->vdev.device_caps & V4L2_CAP_VIDEO_CAPTURE_MPLANE) +/** + * TODO: capture device should only enum formats that all subdevices on + * topology accepts + */ static const u32 vimc_cap_supported_pixfmt[] = { V4L2_PIX_FMT_BGR24, V4L2_PIX_FMT_RGB24, @@ -58,6 +62,19 @@ static const u32 vimc_cap_supported_pixfmt[] = { V4L2_PIX_FMT_SRGGB12, }; +static const u32 vimc_cap_supported_pixfmt_mp[] = { + V4L2_PIX_FMT_YUV420M, + V4L2_PIX_FMT_YVU420M, + V4L2_PIX_FMT_YUV422M, + V4L2_PIX_FMT_YVU422M, + V4L2_PIX_FMT_YUV444M, + V4L2_PIX_FMT_YVU444M, + V4L2_PIX_FMT_NV12M, + V4L2_PIX_FMT_NV21M, + V4L2_PIX_FMT_NV16M, + V4L2_PIX_FMT_NV61M, +}; + struct vimc_cap_device { struct vimc_ent_device ved; struct video_device vdev; @@ -157,13 +174,26 @@ static int _vimc_cap_try_fmt_vid_cap_mp(struct file *file, void *priv, format->width, format->height); } +/** + * When multiplanar is true, consider that the vimc_cap_enum_fmt_vid_cap_mp + * is concantenate in the vimc_cap_enum_fmt_vid_cap array. Otherwise, just + * consider the single-planar array + */ static int vimc_cap_enum_fmt_vid_cap(struct file *file, void *priv, struct v4l2_fmtdesc *f) { - if (f->index >= ARRAY_SIZE(vimc_cap_supported_pixfmt)) + struct vimc_cap_device *vcap = video_drvdata(file); + const unsigned int sp_size = ARRAY_SIZE(vimc_cap_supported_pixfmt); + const unsigned int mp_size = ARRAY_SIZE(vimc_cap_supported_pixfmt_mp); + + if (f->index >= sp_size + (IS_MULTIPLANAR(vcap) ? mp_size : 0)) return -EINVAL; - f->pixelformat = vimc_cap_supported_pixfmt[f->index]; + if (f->index >= sp_size) + f->pixelformat = + vimc_cap_supported_pixfmt_mp[f->index - sp_size]; + else + f->pixelformat = vimc_cap_supported_pixfmt[f->index]; return 0; } -- 2.21.0