Received: by 2002:ac0:a874:0:0:0:0:0 with SMTP id c49csp603572ima; Fri, 15 Mar 2019 09:46:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqwLMkTuxUIaf4MoJK2AF3Gl0SqmSfMUMh/bWz1zY2LqovZNZcfoFDwJvP+c7w58yqsxOsWH X-Received: by 2002:a17:902:ab82:: with SMTP id f2mr5057821plr.93.1552668400518; Fri, 15 Mar 2019 09:46:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552668400; cv=none; d=google.com; s=arc-20160816; b=q7uV/AGZSeP9jW4wDhM9X1NsEIAuO856xQVdPbucO+u+pXrqmDP1sPDxI64toCpHgc t1vSSVk5J6nBGzpIBTRSobWE/UTRB+2DcpCHHmvdeAWkcOEo+sW5hjVoXKOrlLD2ePBs qcJg9YVWbcFNQa2ojJIcyKHNZLDXXacYMfV5n9kqUPAmq5Hv2MprcSjbOhdnzSeOcGdb hw+xiCEwkN4OPU5jTQxvL4lf8xg9HwTlAVXLU4I05pgSww9fE+/656jAE+J2ufOGsgZV JSwwoAKN2uJp0KzeucIbsBAE3hKCQZDWi+kuYC+HPtqvkG8tGAOGxdm2FqX8R90jzdt9 OqcA== 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=aggrU+D8NmB+E8QwdmUbSUm+7XmjXY+jbEn6AzN4hFE=; b=cFFURgHoDzxVqHPzkyyx3IGdUMSn/BG/xFxTiDk6yC/ZQenGFRwNGmpS5i/Fkaai2z pYCdW/U8bSiCgx4pEELvTEGpwIvoSXXIaQvahZWPissg+zqIYFQ3/US05N7KEWU2SL4C x2c+REkDxegDJZP1QE84dM8jl+xjZ7aq/qcncy4tJci912p5rR4wsIrQoQIv3IQEoW4q GQAlgRbNnbmqpMhIZkdMKqyQgDH0jkk1/P2uIXrN5aYvDvt2mpq5JoEQlFgR/PbFPfm2 3GX70xX4yhRjCc6miJW3zuwOf7ymP+HYTmuyJHQ4tJZuewGNlX49PA8eocyUL+dr2UiM zayQ== 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 f9si2171546pgc.576.2019.03.15.09.46.25; Fri, 15 Mar 2019 09:46:40 -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 S1729787AbfCOQp2 (ORCPT + 99 others); Fri, 15 Mar 2019 12:45:28 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:49028 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729772AbfCOQp0 (ORCPT ); Fri, 15 Mar 2019 12:45:26 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: tonyk) with ESMTPSA id A152428157F 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 08/16] media: vimc: cap: Add handler for multiplanar fmt ioctls Date: Fri, 15 Mar 2019 13:43:51 -0300 Message-Id: <20190315164359.626-9-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 functions to handle multiplanar format ioctls, calling the generic format ioctls functions when possible. Signed-off-by: André Almeida --- drivers/media/platform/vimc/vimc-capture.c | 79 ++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/drivers/media/platform/vimc/vimc-capture.c b/drivers/media/platform/vimc/vimc-capture.c index 47acf50f1ad2..09a8fd618b12 100644 --- a/drivers/media/platform/vimc/vimc-capture.c +++ b/drivers/media/platform/vimc/vimc-capture.c @@ -114,6 +114,10 @@ static void vimc_cap_get_format(struct vimc_ent_device *ved, *fmt = vcap->format.fmt.pix; } +/* + * Functions to handle both single- and multi-planar VIDIOC FMT + */ + static int vimc_cap_g_fmt_vid_cap(struct file *file, void *priv, struct v4l2_format *f) { @@ -237,6 +241,71 @@ static bool vimc_cap_is_pixfmt_supported(u32 pixelformat) return true; return false; } +/* + * VIDIOC handlers for multi-planar formats + */ + +static int vimc_cap_g_fmt_vid_cap_mp(struct file *file, void *priv, + struct v4l2_format *f) +{ + if (!multiplanar) + return -EINVAL; + + return vimc_cap_g_fmt_vid_cap(file, priv, f); +} + +static int vimc_cap_try_fmt_vid_cap_mp(struct file *file, void *priv, + struct v4l2_format *f) +{ + if (!multiplanar) + return -EINVAL; + + return vimc_cap_try_fmt_vid_cap(file, priv, f); +} + +static int vimc_cap_s_fmt_vid_cap_mp(struct file *file, void *priv, + struct v4l2_format *f) +{ + struct vimc_cap_device *vcap = video_drvdata(file); + + if (!multiplanar) + return -EINVAL; + + /* Do not change the format while stream is on */ + if (vb2_is_busy(&vcap->queue)) + return -EBUSY; + + vimc_cap_try_fmt_vid_cap(file, priv, f); + + dev_dbg(vcap->dev, "%s: format update: " + "old:%dx%d (0x%x, %d, %d, %d, %d) " + "new:%dx%d (0x%x, %d, %d, %d, %d)\n", vcap->vdev.name, + /* old */ + vcap->format.fmt.pix_mp.width, vcap->format.fmt.pix_mp.height, + vcap->format.fmt.pix_mp.pixelformat, + vcap->format.fmt.pix_mp.colorspace, + vcap->format.fmt.pix_mp.quantization, + vcap->format.fmt.pix_mp.xfer_func, + vcap->format.fmt.pix_mp.ycbcr_enc, + /* new */ + f->fmt.pix_mp.width, f->fmt.pix_mp.height, + f->fmt.pix_mp.pixelformat, f->fmt.pix_mp.colorspace, + f->fmt.pix_mp.quantization, f->fmt.pix_mp.xfer_func, + f->fmt.pix_mp.ycbcr_enc); + + vcap->format = *f; + + return 0; +} + +static int vimc_cap_enum_fmt_vid_cap_mp(struct file *file, void *priv, + struct v4l2_fmtdesc *f) +{ + if (!multiplanar) + return -EINVAL; + + return vimc_cap_enum_fmt_vid_cap(file, priv, f); +} static int vimc_cap_enum_framesizes(struct file *file, void *fh, struct v4l2_frmsizeenum *fsize) @@ -268,14 +337,24 @@ static const struct v4l2_file_operations vimc_cap_fops = { .mmap = vb2_fop_mmap, }; + static const struct v4l2_ioctl_ops vimc_cap_ioctl_ops = { .vidioc_querycap = vimc_cap_querycap, + /** + * The vidioc_*_vid_cap* functions acts as a front end to + * vimc_*_vid_cap, dealing with the single- and multi-planar + */ .vidioc_g_fmt_vid_cap = vimc_cap_g_fmt_vid_cap_sp, .vidioc_s_fmt_vid_cap = vimc_cap_s_fmt_vid_cap_sp, .vidioc_try_fmt_vid_cap = vimc_cap_try_fmt_vid_cap_sp, .vidioc_enum_fmt_vid_cap = vimc_cap_enum_fmt_vid_cap_sp, + .vidioc_g_fmt_vid_cap_mplane = vimc_cap_g_fmt_vid_cap_mp, + .vidioc_s_fmt_vid_cap_mplane = vimc_cap_s_fmt_vid_cap_mp, + .vidioc_try_fmt_vid_cap_mplane = vimc_cap_try_fmt_vid_cap_mp, + .vidioc_enum_fmt_vid_cap_mplane = vimc_cap_enum_fmt_vid_cap_mp, + .vidioc_enum_framesizes = vimc_cap_enum_framesizes, .vidioc_reqbufs = vb2_ioctl_reqbufs, -- 2.21.0