From patchwork Wed Apr 24 13:56:35 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: 10914865 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 07C44161F for ; Wed, 24 Apr 2019 13:58:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EBD492892C for ; Wed, 24 Apr 2019 13:58:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E02A5289F4; Wed, 24 Apr 2019 13:58:48 +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 0D91D2892E for ; Wed, 24 Apr 2019 13:58:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730227AbfDXN6p (ORCPT ); Wed, 24 Apr 2019 09:58:45 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:57044 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728842AbfDXN6p (ORCPT ); Wed, 24 Apr 2019 09:58:45 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: tonyk) with ESMTPSA id 869CF282C0F 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 v3 07/14] media: vimc: cap: Add multiplanar default format Date: Wed, 24 Apr 2019 10:56:35 -0300 Message-Id: <20190424135642.31973-8-andrealmeid@collabora.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190424135642.31973-1-andrealmeid@collabora.com> References: <20190424135642.31973-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 vimc already have a default single planar format. Add a multiplanar default pixel format to perform those same actions. Change where the default pixelformat is set to make sure that the vcap is with the right capabilities. Signed-off-by: André Almeida --- Change in v3: - Fix typo on commit message - Add `_sp` to single planar default format - Modify identation Change in v2: - Move here the default format is set to verify if the device have a multiplanar capability before assign the default format drivers/media/platform/vimc/vimc-capture.c | 42 ++++++++++++++++------ 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/drivers/media/platform/vimc/vimc-capture.c b/drivers/media/platform/vimc/vimc-capture.c index a23896dad9dd..10c8681de68e 100644 --- a/drivers/media/platform/vimc/vimc-capture.c +++ b/drivers/media/platform/vimc/vimc-capture.c @@ -95,7 +95,7 @@ struct vimc_cap_device { struct vimc_stream stream; }; -static const struct v4l2_format fmt_default = { +static const struct v4l2_format fmt_default_sp = { .type = V4L2_BUF_TYPE_VIDEO_CAPTURE, .fmt.pix.width = 640, .fmt.pix.height = 480, @@ -104,6 +104,15 @@ static const struct v4l2_format fmt_default = { .fmt.pix.colorspace = V4L2_COLORSPACE_DEFAULT, }; +static const struct v4l2_format fmt_default_mp = { + .type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, + .fmt.pix_mp.width = 640, + .fmt.pix_mp.height = 480, + .fmt.pix_mp.pixelformat = V4L2_PIX_FMT_YVU420M, + .fmt.pix_mp.field = V4L2_FIELD_NONE, + .fmt.pix_mp.colorspace = V4L2_COLORSPACE_DEFAULT, +}; + struct vimc_cap_buffer { /* * struct vb2_v4l2_buffer must be the first element @@ -149,6 +158,7 @@ static int vimc_cap_try_fmt_vid_cap_mp(struct file *file, void *priv, struct v4l2_format *f) { struct v4l2_pix_format_mplane *format = &f->fmt.pix_mp; + struct vimc_cap_device *vcap = video_drvdata(file); format->width = clamp_t(u32, format->width, VIMC_FRAME_MIN_WIDTH, VIMC_FRAME_MAX_WIDTH) & ~1; @@ -158,13 +168,15 @@ static int vimc_cap_try_fmt_vid_cap_mp(struct file *file, void *priv, vimc_colorimetry_clamp(format); if (format->field == V4L2_FIELD_ANY) - format->field = fmt_default.fmt.pix.field; + format->field = fmt_default_sp.fmt.pix.field; /* TODO: Add support for custom bytesperline values */ /* Don't accept a pixelformat that is not on the table */ if (!v4l2_format_info(format->pixelformat)) - format->pixelformat = fmt_default.fmt.pix.pixelformat; + format->pixelformat = IS_MULTIPLANAR(vcap) ? + fmt_default_mp.fmt.pix_mp.pixelformat : + fmt_default_sp.fmt.pix.pixelformat; return v4l2_fill_pixfmt_mp(format, format->pixelformat, format->width, format->height); @@ -531,13 +543,6 @@ static int vimc_cap_comp_bind(struct device *comp, struct device *master, INIT_LIST_HEAD(&vcap->buf_list); spin_lock_init(&vcap->qlock); - /* Set default frame format */ - vcap->format = fmt_default; - v4l2_fill_pixfmt(&vcap->format.fmt.pix, - vcap->format.fmt.pix.pixelformat, - vcap->format.fmt.pix.width, - vcap->format.fmt.pix.height); - /* Fill the vimc_ent_device struct */ vcap->ved.ent = &vcap->vdev.entity; vcap->ved.process_frame = vimc_cap_process_frame; @@ -559,6 +564,23 @@ static int vimc_cap_comp_bind(struct device *comp, struct device *master, strscpy(vdev->name, pdata->entity_name, sizeof(vdev->name)); video_set_drvdata(vdev, &vcap->ved); + dev_dbg(vcap->dev, "vimc-capture is in %s mode", + IS_MULTIPLANAR(vcap) ? "multiplanar" : "singleplanar"); + + if (IS_MULTIPLANAR(vcap)) { + vcap->format = fmt_default_mp; + v4l2_fill_pixfmt_mp(&vcap->format.fmt.pix_mp, + vcap->format.fmt.pix_mp.pixelformat, + vcap->format.fmt.pix_mp.width, + vcap->format.fmt.pix_mp.height); + } else { + vcap->format = fmt_default_sp; + v4l2_fill_pixfmt(&vcap->format.fmt.pix, + vcap->format.fmt.pix.pixelformat, + vcap->format.fmt.pix.width, + vcap->format.fmt.pix.height); + } + /* Register the video_device with the v4l2 and the media framework */ ret = video_register_device(vdev, VFL_TYPE_GRABBER, -1); if (ret) {