Received: by 2002:ac0:a874:0:0:0:0:0 with SMTP id c49csp603668ima; Fri, 15 Mar 2019 09:46:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqzWMf2oYyzqDxa0QuF2eWgREwgPyeHPvPRM5a63kcnjLaw5Nv7A0rwAEBJA/pBiE7Vknghv X-Received: by 2002:a63:7341:: with SMTP id d1mr4389556pgn.405.1552668406850; Fri, 15 Mar 2019 09:46:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552668406; cv=none; d=google.com; s=arc-20160816; b=d4p1ETDEk5UcriOsOmH43GdW2PzOtLR3MqoF1pI2OyNam9ZzX/uo0BtimkqvEoWV59 ncFn/8awrFLY9PGrDTxXdzVf7LUpVDskgIMlh5eCZ6fcxXTryuj5DBbLHMU0e3djjevg bVjx4MuAJiw8jYYLzADEw+uMaWe7wd43z0rzbLHOfTPiMbnl7FVsySqimMkXHEgqyA1o ivgiWXH1j7hG9wKSInTWqyzmHTWU5gVsEUug7Nqt6Dj359ZBGG2DdSV7jMU/tTYhvQ5P 3mRqWq9aYpuK4Mj/9yXutdHGNl2w6kNWBppVfQXotn5tWhgzIHIBqP6pZ1/iHf2uTV1+ zHMg== 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=YjUwCzskrpNChbdojXgvsEKmWfRIQnHhcv6Us5f3LpY=; b=bYcrHbFhs1yeL2K4FN3dYUgV5RAa1j/C/hZ872JtgTM78KfhuSbhAv6ifR5no3RwvY SGueqct8hNUaxXlyTwsI/zOodJj/WDa0IImIXLQxjh9cOpTd9VKIEc9Lw+xzwHc8Ja1U zI6+A3nRCIo+AOO/tmIUc4pyJ+ABDztGCMR5eA7bZi99o6QlZGoovGwCUQHmhusNER2n yeTSLacJ8FnZVTCVfRTlTMdZ5jFqnuBkpWOmxHV+wN/Sbs+LgC33kYHf9Cn6VJKHsUiq 0mtYYUwCtgJD074QupB8+yozuY6xhIDsWLPHB4k62QPl0+lXBMlPQavY1n3VneTIEPAZ VuvA== 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 136si2305592pfu.221.2019.03.15.09.46.31; Fri, 15 Mar 2019 09:46:46 -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 S1729797AbfCOQpb (ORCPT + 99 others); Fri, 15 Mar 2019 12:45:31 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:49036 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729783AbfCOQp3 (ORCPT ); Fri, 15 Mar 2019 12:45:29 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: tonyk) with ESMTPSA id 0F6D7281585 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 Subject: [PATCH 09/16] media: vimc: cap: Add multiplanar formats Date: Fri, 15 Mar 2019 13:43:52 -0300 Message-Id: <20190315164359.626-10-andrealmeid@collabora.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190315164359.626-1-andrealmeid@collabora.com> References: <20190315164359.626-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 --- drivers/media/platform/vimc/vimc-capture.c | 30 ++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/vimc/vimc-capture.c b/drivers/media/platform/vimc/vimc-capture.c index 09a8fd618b12..2d668012e9e9 100644 --- a/drivers/media/platform/vimc/vimc-capture.c +++ b/drivers/media/platform/vimc/vimc-capture.c @@ -54,6 +54,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; @@ -153,13 +166,26 @@ static int vimc_cap_try_fmt_vid_cap(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)) + 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 + (multiplanar ? 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]; + strncpy(f->description, v4l2_get_fourcc_name(f->pixelformat), 4); f->description[4] = '\0'; -- 2.21.0