From patchwork Fri Apr 26 01:22:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Almeida?= X-Patchwork-Id: 10917913 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2BC1614C0 for ; Fri, 26 Apr 2019 01:24:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 16FC428D3A for ; Fri, 26 Apr 2019 01:24:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 08B5C28D48; Fri, 26 Apr 2019 01:24:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A1C0C28D3A for ; Fri, 26 Apr 2019 01:24:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730529AbfDZBYe (ORCPT ); Thu, 25 Apr 2019 21:24:34 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:36622 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726427AbfDZBYe (ORCPT ); Thu, 25 Apr 2019 21:24:34 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: tonyk) with ESMTPSA id D1473280154 From: =?utf-8?q?Andr=C3=A9_Almeida?= To: linux-media@vger.kernel.org Cc: mchehab@kernel.org, hverkuil@xs4all.nl, helen.koike@collabora.com, kernel@collabora.com, lucmaga@gmail.com, lkcamp@lists.libreplanetbr.org, =?utf-8?q?Andr=C3=A9_Almeida?= Subject: [PATCH v4 07/14] media: vimc: cap: Add multiplanar formats Date: Thu, 25 Apr 2019 22:22:16 -0300 Message-Id: <20190426012223.17826-8-andrealmeid@collabora.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190426012223.17826-1-andrealmeid@collabora.com> References: <20190426012223.17826-1-andrealmeid@collabora.com> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Helen Koike --- Changes in v4: none Changes in v3: none 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 652d3d08bc50..a7dafc601033 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; @@ -156,13 +173,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; }