Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp2290100ybx; Fri, 8 Nov 2019 02:21:03 -0800 (PST) X-Google-Smtp-Source: APXvYqwYdbXsKZrPhIliZ/FjZC6fAfBisdi100VDyVZIwsfbhEgPS7d8CJECv2ql2bw7vQGRJr+l X-Received: by 2002:a05:6402:19:: with SMTP id d25mr9271424edu.186.1573208463525; Fri, 08 Nov 2019 02:21:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573208463; cv=none; d=google.com; s=arc-20160816; b=sybATR7qp/3O6A78Z4PTB7J6yaAc7r6VE+lqn8XnCt0VSr9e4NQw8xnWYfP7nwq3o6 qCFUdnV3MLq5pmEY85zTKwua7z9gpM3kqpwwLYJikmHcQ2gdwiUGBTPLODZIQl0pBM6N g4arjkaHX0Zcr7rVhGsjSuwo9mrLsmVPJis/DQSgreEnHDBT26nyULzRexiUIY0Kw3O2 BrfyKQmDganHl26eGytpNGXr9iBHzGBT0ITZQGZUVSLkzbACBG5iM0P/mi0V9xea1yS0 SEY9n71dVcrShpKYY0+Ozb1sikOTVCHIKesq1BEDW0a8Ap1918cZS28itaY7NkGw83Rk ljtQ== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=mcSeWuq6rakGkShna/HRrhRdk7in9g4ND10YgETxX08=; b=K4cHqRh5UHSsVM81VIzxDKXCYf50ZnSEUnpQkAuG3KFcU+z095FRUG7WV4unLSm9r7 9ScKzA3gCisXixWUx8uTIf1asebtdTjwA3MUO5AP0x3cyEJBb91Jrsd6w2L0ebca1lLB 1CF1b7liay1G0erT8EYQPADx1ASLLWZ6b0kgfJm2SeCu30W/26+8f28bXqFccv6gcote PWlIc4Rx9P/0CaHwuxJ3KsPREOMKNfTpFRwtrK/6YlJ8cq+Fn34fuT3xTzkG6DZ8iDKP k5/ZkI5NBPqlSpYNcqAyqDJSDArwnbsiq8gz7VdqUnVACKiCJbmlAaeYL3wG1+Ipq8lW KpDw== 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 np1si3546146ejb.370.2019.11.08.02.20.39; Fri, 08 Nov 2019 02:21:03 -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; 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 S1730622AbfKHKT6 (ORCPT + 99 others); Fri, 8 Nov 2019 05:19:58 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:32984 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726149AbfKHKT6 (ORCPT ); Fri, 8 Nov 2019 05:19:58 -0500 Received: from localhost (unknown [IPv6:2a01:e0a:2c:6930:5cf4:84a1:2763:fe0d]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: bbrezillon) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id D8B0828EE5A; Fri, 8 Nov 2019 10:19:55 +0000 (GMT) Date: Fri, 8 Nov 2019 11:19:50 +0100 From: Boris Brezillon To: Ezequiel Garcia , Tomasz Figa , Hans Verkuil Cc: linux-media@vger.kernel.org, kernel@collabora.com, Nicolas Dufresne , linux-rockchip@lists.infradead.org, Heiko Stuebner , Jonas Karlman , Philipp Zabel , Alexandre Courbot , fbuergisser@chromium.org, linux-kernel@vger.kernel.org, Douglas Anderson Subject: Re: [PATCH v2 for 5.4 1/4] media: hantro: Fix s_fmt for dynamic resolution changes Message-ID: <20191108111950.717db5ce@collabora.com> In-Reply-To: <20191007174505.10681-2-ezequiel@collabora.com> References: <20191007174505.10681-1-ezequiel@collabora.com> <20191007174505.10681-2-ezequiel@collabora.com> Organization: Collabora X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? > /* > * 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