Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp2404013ybx; Fri, 8 Nov 2019 03:55:49 -0800 (PST) X-Google-Smtp-Source: APXvYqxwBmBR2PdH9lAdHmQaslN33DXSkCYTQaYsL7FbHSzppX8Qy5qetVy9p+5FtBg4hS6bfPWR X-Received: by 2002:a17:906:459:: with SMTP id e25mr8197406eja.259.1573214149331; Fri, 08 Nov 2019 03:55:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573214149; cv=none; d=google.com; s=arc-20160816; b=zmzLQ1xghqDcBZc1xM18OKMjplfA1JeLOpkv6Qv8k77wr9g3JzLCeHutsahHCJh7TB AJPMf4MiX9pArbQJ14sV9y3xem2hRjX92wyqcPdtQdLkPeTdKec1rhk5nIuNrG51wsLt UCTcio1H9eaNjZp3VUcQyWcBaOHv5We+tLAUyBBLwBVpVspt+a4ePpUxKpoUk2F/4njo LITpSqYahdsI9z9ilCLgLEwGatiM+fXoQoC2unsuH86qnHKr7RocpACycF7GxPVMDIID EG3MZSewtubbapwmfWMVp9qQO1czXQXJ3pYcvkRd+rnqXELVYvyoUFjV5CLU/16fD2K9 egIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=IOnxCFh4YN+0QSSZGQhAPojghrwSZUgGpZPmxcpF31E=; b=u4PSpYGBQtYt/vd7vhRrfeRTi1MjIVADayrsGyCZeDsOsEd1YeskTeFsJTktKCEgPJ 9dt5UHgh0mxL5SBRUYcpPtY9G7nmv5htRyBSA+t5kWQ9kA4pCsRupmjDmis8+ofG8RZH M3A04+hDZk9aQNIY1MZ9HhcIO1ONNrw6MVrYjgYdSJRlNMnbH1a7SPIeF2JUOuMKqdSZ zFbxa2uqvP65E4E8awePAOmdetMPlZ51qmcTGBt2czUNIwtUyw00opPXoByBFFyP7Ep1 tONeEm5bqRWTBxr/mXzoh631kp+aUooC0NU1A1JzAfAkxILH+r8cVKbXAPqhCuVPLVCC g9sA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=GjMU9TWS; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c25si3589860eja.24.2019.11.08.03.55.25; Fri, 08 Nov 2019 03:55:49 -0800 (PST) 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; dkim=pass header.i=@chromium.org header.s=google header.b=GjMU9TWS; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390073AbfKHLw2 (ORCPT + 99 others); Fri, 8 Nov 2019 06:52:28 -0500 Received: from mail-ed1-f65.google.com ([209.85.208.65]:33937 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388922AbfKHLwS (ORCPT ); Fri, 8 Nov 2019 06:52:18 -0500 Received: by mail-ed1-f65.google.com with SMTP id b72so4805466edf.1 for ; Fri, 08 Nov 2019 03:52:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=IOnxCFh4YN+0QSSZGQhAPojghrwSZUgGpZPmxcpF31E=; b=GjMU9TWSMias72NYZf8/pIAPsYqBU2Md+VpsSiGnnatFFveAw6xtOCFAzEi4WXWZHz nRfnfimUDj7TuifnpQh3avxk4E2EOp9sjleGFUPM5EGuAX5M85TUlLhYwm1B4mQl9a2c 0QMn+HUckzrpkgHa6z0QEbNfrdWxRlJE0y1OA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=IOnxCFh4YN+0QSSZGQhAPojghrwSZUgGpZPmxcpF31E=; b=kfjY7YF+LXScjv7ByGyE5e5Mo4/NWY8VV0f/fH2GuP2C3lAK/4MYeSV05hz5OIW4/T S+TCUi6es8xM2IBJCBbvDSOuaYxHlAYFswlzMDT+aiPlgWyriQXraFZkGLI/4ASt3afE 6U7tu0O1HzBymRQVxiEBF+jEqOoWj06xjrjzKpo/sgkbe0mREeo6Zml1ptggGgUeQYou Ul/CHhGFUD5JozsQL2FRM2oMtH5SNFpzsAxhbR2+RnDFDrlHK1w1AsxYEa3E9pUhpLny LUCtwAEflUN+uHk1oBhgc2aCvaJYjMobJOfEHS2ReoM55KIf7W6RaKhtXUca5BHXXPEU mRWA== X-Gm-Message-State: APjAAAWnwLO8i1GMbGLM+SoyoxVpSJhxkwGiXGT6yUNmdwgD8geWyKYS mS2ihxYdcrxh/tg+Scw9PSvK9rlQwrFtRg== X-Received: by 2002:a17:906:7c4e:: with SMTP id g14mr8043591ejp.150.1573213935779; Fri, 08 Nov 2019 03:52:15 -0800 (PST) Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com. [209.85.221.41]) by smtp.gmail.com with ESMTPSA id e13sm129724edv.42.2019.11.08.03.52.14 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 08 Nov 2019 03:52:14 -0800 (PST) Received: by mail-wr1-f41.google.com with SMTP id f2so6672292wrs.11 for ; Fri, 08 Nov 2019 03:52:14 -0800 (PST) X-Received: by 2002:adf:e505:: with SMTP id j5mr7683403wrm.46.1573213933783; Fri, 08 Nov 2019 03:52:13 -0800 (PST) MIME-Version: 1.0 References: <20191007174505.10681-1-ezequiel@collabora.com> <20191007174505.10681-2-ezequiel@collabora.com> <20191108111950.717db5ce@collabora.com> In-Reply-To: <20191108111950.717db5ce@collabora.com> From: Tomasz Figa Date: Fri, 8 Nov 2019 20:52:02 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 for 5.4 1/4] media: hantro: Fix s_fmt for dynamic resolution changes To: Boris Brezillon Cc: Ezequiel Garcia , Hans Verkuil , Linux Media Mailing List , kernel@collabora.com, Nicolas Dufresne , "open list:ARM/Rockchip SoC..." , Heiko Stuebner , Jonas Karlman , Philipp Zabel , Alexandre Courbot , fbuergisser@chromium.org, Linux Kernel Mailing List , Douglas Anderson Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 8, 2019 at 7:20 PM Boris Brezillon wrote: > > On Mon, 7 Oct 2019 14:45:02 -0300 > Ezequiel Garcia wrote: > > > Commit 953aaa1492c53 ("media: rockchip/vpu: Prepare things to support decoders") > > changed the conditions under S_FMT was allowed for OUTPUT > > CAPTURE buffers. > > > > However, and according to the mem-to-mem stateless decoder specification, > > in order to support dynamic resolution changes, S_FMT should be allowed > > even if OUTPUT buffers have been allocated. > > > > Relax decoder S_FMT restrictions on OUTPUT buffers, allowing a resolution > > modification, provided the pixel format stays the same. > > > > Tested on RK3288 platforms using ChromiumOS Video Decode/Encode Accelerator Unittests. > > > > Fixes: 953aaa1492c53 ("media: rockchip/vpu: Prepare things to support decoders") > > Signed-off-by: Ezequiel Garcia > > -- > > v2: > > * Call try_fmt_out before using the format, > > pointed out by Philipp. > > > > drivers/staging/media/hantro/hantro_v4l2.c | 28 +++++++++++++++------- > > 1 file changed, 19 insertions(+), 9 deletions(-) > > > > diff --git a/drivers/staging/media/hantro/hantro_v4l2.c b/drivers/staging/media/hantro/hantro_v4l2.c > > index 3dae52abb96c..586d243cc3cc 100644 > > --- a/drivers/staging/media/hantro/hantro_v4l2.c > > +++ b/drivers/staging/media/hantro/hantro_v4l2.c > > @@ -367,19 +367,26 @@ vidioc_s_fmt_out_mplane(struct file *file, void *priv, struct v4l2_format *f) > > { > > struct v4l2_pix_format_mplane *pix_mp = &f->fmt.pix_mp; > > struct hantro_ctx *ctx = fh_to_ctx(priv); > > + struct vb2_queue *vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type); > > const struct hantro_fmt *formats; > > unsigned int num_fmts; > > - struct vb2_queue *vq; > > int ret; > > > > - /* Change not allowed if queue is busy. */ > > - vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type); > > - if (vb2_is_busy(vq)) > > - return -EBUSY; > > + ret = vidioc_try_fmt_out_mplane(file, priv, f); > > + if (ret) > > + return ret; > > > > if (!hantro_is_encoder_ctx(ctx)) { > > struct vb2_queue *peer_vq; > > > > + /* > > + * In other to support dynamic resolution change, > > ^ order > > > + * the decoder admits a resolution change, as long > > + * as the pixelformat remains. Can't be done if streaming. > > + */ > > + if (vb2_is_streaming(vq) || (vb2_is_busy(vq) && > > + pix_mp->pixelformat != ctx->src_fmt.pixelformat)) > > + return -EBUSY; > > Sorry to chime in only now, but I'm currently looking at the VP9 spec > and it seems the resolution is allowed to change dynamically [1] (I > guess the same applies to VP8). IIU the spec correctly, coded frames > using the new resolution can reference decoded frames using the old > one (can be higher or lower res BTW). If we force a streamoff to change > the resolution (as seems to be the case here), we'll lose those ref > frames (see the hantro_return_bufs() in stop streaming), right? > Hans, Tomasz, any idea how this dynamic resolution change could/should > be supported? The same problem applies to stateful decoders as well. This is an inherent limitation of the current V4L2 API. To handle this kind of streams we would have to make the format a per-buffer parameter, rather than per-queue as it is defined currently. Best regards, Tomasz > > > /* > > * Since format change on the OUTPUT queue will reset > > * the CAPTURE queue, we can't allow doing so > > @@ -389,12 +396,15 @@ vidioc_s_fmt_out_mplane(struct file *file, void *priv, struct v4l2_format *f) > > V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE); > > if (vb2_is_busy(peer_vq)) > > return -EBUSY; > > + } else { > > + /* > > + * The encoder doesn't admit a format change if > > + * there are OUTPUT buffers allocated. > > + */ > > + if (vb2_is_busy(vq)) > > + return -EBUSY; > > } > > > > - ret = vidioc_try_fmt_out_mplane(file, priv, f); > > - if (ret) > > - return ret; > > - > > formats = hantro_get_formats(ctx, &num_fmts); > > ctx->vpu_src_fmt = hantro_find_format(formats, num_fmts, > > pix_mp->pixelformat); > > [1] Section "5.16 Reference frame scaling" of > https://storage.googleapis.com/downloads.webmproject.org/docs/vp9/vp9-bitstream-specification-v0.6-20160331-draft.pdf