Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2086637ybt; Thu, 2 Jul 2020 23:58:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyKxc4blq3CnzIM7qE62fY46nFPTIuYdtL+Eab1TtMxu0LtdActC6WoklNvlK2WcxTsUZ1O X-Received: by 2002:a17:906:e2ca:: with SMTP id gr10mr29851006ejb.81.1593759537009; Thu, 02 Jul 2020 23:58:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593759537; cv=none; d=google.com; s=arc-20160816; b=EOcufx6rN5UWcRJ/00N2tlqerEt5v5x5VIK2RMoHr4owyxA8R1O3MFJmqv5HkjdWyM 4QwBe2g1uWULTISoOmksFtHkHt3tAXRY6ZBye8ZpLFfsqaJnb+hGjL9C19WiYmU+k1tF kVuMrZfHpA6LGy+s+YknpbdvKuWF+Tkeq1vymjA3LHiEHouwk6/Y3SYDQRPVX/gB/z/I FCsPXHHNZ9prC4KRA2TMR2DYZsgZ0+1lNtr9XYcXiTZURZB/j8tGzHOv54NBRg49SNVx ykyysHD6sVwFUAMigGVD97a5LvneIIHtoitSgmx6DeZljpfJXyBcC2hUBaJIYL8DFTD+ yiUw== 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 :content-language:cc:to:in-reply-to:mime-version:user-agent:date :message-id:from:references:subject:dkim-signature; bh=bXBX9AqKrpqo2PvMRRcHawGUdglyj9K4bWgKMbLBmSA=; b=W/tJkK/gS4ex5W3lzCU83HN0tLoUfD6rNZy7klgM633VziZbnJMJeyZAczNJPoByv2 peTZdtrWPBY+Q7ZugNXXqzthsYgR+9oJkVW8LNkIZx+IIE59FV0YFuirfJ80bwwMaCqX 3TTgj62nETqCQE3h9h3eJiIsqT9eAOMXowxXlUGxVosLf/mgkI0WFs9NkBcQtGgDykHx Fg6bhzuH2qcOSUQ23dF3JYW8oSCKkIh9aMq8aZW0wplu2KJQ6fVXtlVkGj+trSnps3fY ALzncvXbKaWAo6zPAW9bLz8y5Ejmzpaov0mDOboGcbsE+IoNV/xNwOX1DrTUZl/JmISK oOSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kwiboo.se header.s=001 header.b=b4lGXOZ+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r12si7519439ejs.370.2020.07.02.23.58.34; Thu, 02 Jul 2020 23:58:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kwiboo.se header.s=001 header.b=b4lGXOZ+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726169AbgGCGzp (ORCPT + 99 others); Fri, 3 Jul 2020 02:55:45 -0400 Received: from o1.b.az.sendgrid.net ([208.117.55.133]:55025 "EHLO o1.b.az.sendgrid.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725972AbgGCGzo (ORCPT ); Fri, 3 Jul 2020 02:55:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kwiboo.se; h=subject:references:from:mime-version:in-reply-to:to:cc:content-type: content-transfer-encoding; s=001; bh=bXBX9AqKrpqo2PvMRRcHawGUdglyj9K4bWgKMbLBmSA=; b=b4lGXOZ+rGATeNBg/RrABOYpi2F1tlLKmD/2P57/GzWMy4jYzMZMywZGnJZgnEbq7AeN HeeGW91YLI9sR/4/2hegUb4LWLwgaJg5LHs4A+cxEKyQVy8JLrqdAVmCRgPOIZgLlMNqhX M77njjWCqajYBJCDx5FPCbT5EViNNLtSY= Received: by filterdrecv-p3iad2-5b55dcd864-t97fw with SMTP id filterdrecv-p3iad2-5b55dcd864-t97fw-17-5EFED66F-9 2020-07-03 06:55:43.176672884 +0000 UTC m=+567984.810966751 Received: from [192.168.1.14] (unknown) by ismtpd0007p1lon1.sendgrid.net (SG) with ESMTP id M5lUjmBcRDyWB4rIzm5Tdw Fri, 03 Jul 2020 06:55:42.063 +0000 (UTC) Subject: Re: [PATCH 8/9] media: rkvdec: Add validate_fmt ops for pixelformat validation References: <20200701215616.30874-1-jonas@kwiboo.se> <20200701215616.30874-9-jonas@kwiboo.se> <67a130a8fd8874c5dc639c924de959f88357b480.camel@collabora.com> From: Jonas Karlman Message-ID: Date: Fri, 03 Jul 2020 06:55:43 +0000 (UTC) User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <67a130a8fd8874c5dc639c924de959f88357b480.camel@collabora.com> X-SG-EID: =?us-ascii?Q?TdbjyGynYnRZWhH+7lKUQJL+ZxmxpowvO2O9SQF5CwCVrYgcwUXgU5DKUU3QxA?= =?us-ascii?Q?fZekEeQsTe+RrMu3cja6a0h6sHjUdwPJ2Gv904R?= =?us-ascii?Q?cSBw1tmCZqqkY+AOXJh=2FTNkFHeTtWLg9RIc7mVK?= =?us-ascii?Q?sznxuZOh=2FgL2IIT3stWUvJuEs=2FnHP=2Fh3ljz56i=2F?= =?us-ascii?Q?apsZXZmSHQPij7vbL63seY9xMZSHGRiPt3mec3o?= =?us-ascii?Q?AVdlFGzlZMUWpyNGTPcoQm+R5iXkVPkD19mV7e+?= =?us-ascii?Q?ovE329ptmgwg0sLxuTFRg=3D=3D?= To: Ezequiel Garcia , linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Hans Verkuil , Nicolas Dufresne , Tomasz Figa , Alexandre Courbot Content-Type: text/plain; charset=us-ascii Content-Language: sv Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-07-03 05:14, Ezequiel Garcia wrote: > Hi Jonas, > > Thanks for working on this. > > On Wed, 2020-07-01 at 21:56 +0000, Jonas Karlman wrote: >> Add an optional validate_fmt operation that is used to validate the >> pixelformat of CAPTURE buffers. >> >> This is used in next patch to ensure correct pixelformat is used for 10-bit >> and 4:2:2 content. >> >> Signed-off-by: Jonas Karlman >> --- >> drivers/staging/media/rkvdec/rkvdec.c | 8 ++++++++ >> drivers/staging/media/rkvdec/rkvdec.h | 1 + >> 2 files changed, 9 insertions(+) >> >> diff --git a/drivers/staging/media/rkvdec/rkvdec.c b/drivers/staging/media/rkvdec/rkvdec.c >> index b1de55aa6535..465444c58f13 100644 >> --- a/drivers/staging/media/rkvdec/rkvdec.c >> +++ b/drivers/staging/media/rkvdec/rkvdec.c >> @@ -239,6 +239,14 @@ static int rkvdec_try_capture_fmt(struct file *file, void *priv, >> if (WARN_ON(!coded_desc)) >> return -EINVAL; >> >> + if (coded_desc->ops->validate_fmt) { >> + int ret; >> + >> + ret = coded_desc->ops->validate_fmt(ctx, pix_mp->pixelformat); >> + if (ret) >> + return ret; >> + } >> + > > I don't think this approach will be enough. Unless I'm mistaken, > it's perfectly legal as per the stateless spec to first > call S_FMT on the OUTPUT queue (which is propagated to the CAPTURE side), > and then set the SPS and other controls. I agree that this will not be enough to cover all use cases stated in the spec. > > The application is not required to do a TRY_FMT after S_EXT_CTRLS. If I remember correctly we were required to implement a TRY_FMT loop in ffmpeg due to cedrus defaulting to SUNXI_TILED_NV12 instead of linear NV12 on platforms where display controller did not support the tiled modifier. So having TRY_FMT as part of the init sequence has been my only test-case. > > What I believe is needed is for the S_EXT_CTRLS to modify > and restrict the CAPTURE format accordingly, so the application > gets the correct format on G_FMT (and restrict future TRY_FMT). This sounds like a proper solution, I do belive we may have a chicken or the egg problem depending on if application call S_EXT_CTRLS or S_FMT first. I guess we may need to lock down on a format at whatever comes first, S_FMT on CAPTURE or S_EXT_CTRLS with SPS ctrl. I have an idea on how this could be addressed, will explore and see if I can come up with something new. Regards, Jonas > > Also, V4L2 spec asks drivers not to fail on S_FMT > format mismatch, but instead to adjust and return a legal format > back to the application [1]. > > Let me know what you think and thanks again. > > Ezequiel > > [1] Documentation/userspace-api/media/v4l/vidioc-g-fmt.rst > >> for (i = 0; i < coded_desc->num_decoded_fmts; i++) { >> if (coded_desc->decoded_fmts[i] == pix_mp->pixelformat) >> break; >> diff --git a/drivers/staging/media/rkvdec/rkvdec.h b/drivers/staging/media/rkvdec/rkvdec.h >> index 2fc9f46b6910..be4fc3645cde 100644 >> --- a/drivers/staging/media/rkvdec/rkvdec.h >> +++ b/drivers/staging/media/rkvdec/rkvdec.h >> @@ -64,6 +64,7 @@ vb2_to_rkvdec_decoded_buf(struct vb2_buffer *buf) >> struct rkvdec_coded_fmt_ops { >> int (*adjust_fmt)(struct rkvdec_ctx *ctx, >> struct v4l2_format *f); >> + int (*validate_fmt)(struct rkvdec_ctx *ctx, u32 pixelformat); >> int (*start)(struct rkvdec_ctx *ctx); >> void (*stop)(struct rkvdec_ctx *ctx); >> int (*run)(struct rkvdec_ctx *ctx); > >