Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp2204144pxb; Fri, 8 Oct 2021 03:09:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyiAcesPagJi3FOGQ4Cy0em7oGPX9xzndFRXNUDQmt869pfK3wB389i0kRB4foAfatPkHBy X-Received: by 2002:a17:906:d1d6:: with SMTP id bs22mr3115801ejb.554.1633687751333; Fri, 08 Oct 2021 03:09:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633687751; cv=none; d=google.com; s=arc-20160816; b=Zk+NQxZDarGyE9sgyP95OTOLJa4MrWfTizLeE7ROE1i65JTPQzIBaOxlTDLCTfnUK+ BHPI+F/n5YQyD51MIAWTN/zsog1M3lNTTGJ6Zk5P0f2anCNihsLub/K2+6wjnmOp5WAX Vaa5VLB4hCN0HnY6bB91Jnb/qqaEfAR8AC+TZ0Vcfqy/lZnGaQhO3bje2oFugJl9pD8C +3ProzPoInFhrGzes3rr6JN1s775J2onlKM/l8w56/U+CCEjxY8V3NfDWJLXv9P8uyHJ fvRs+0e0aI/4YYEVW+JtgfA1gFf/1kDK0gBVntvi8XPgtkjjtSTfeXzq9Zq/2Lk2LYMs 9Pxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=0tE+OjKJHdX0YaSq/SP0LPgcFSSGhc57aktXdnN08Jk=; b=NYaTpEj9SHBaxppnZSFadRfB9+ymwgFkO/QMf0A1dYeqoJSvHLvTG/IUT1RA0/iFyV yKYSUSqAm2yMT1UqxZBnlFjxLVsc2dbg8+Z442d68LowaSThdy1IypCJJU1sdiM3sViE vwxddsLTHzPElcTRw/+hOX6HM/NiiseIRMBhrfhqq2h5G6zSSwf60eH9n8NMuQh+E4nF /GN5YAkkOY0RyISiMyl8VqmC7MyyPLxOESkYsJrOdm9iGsQ2NkjoBv1eGVr0nSR1bHdr psXc/Ol/OrqFXkVt51z1DQ5KwyOH36ROnBf8oFNsLuBEwXPW80uND2OVlqvAJz3W4K1i J+Ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=gOYHix4W; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 23si2778814ejg.540.2021.10.08.03.08.47; Fri, 08 Oct 2021 03:09:11 -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=@chromium.org header.s=google header.b=gOYHix4W; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239711AbhJHKI0 (ORCPT + 99 others); Fri, 8 Oct 2021 06:08:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239609AbhJHKIG (ORCPT ); Fri, 8 Oct 2021 06:08:06 -0400 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF36EC061755 for ; Fri, 8 Oct 2021 03:06:11 -0700 (PDT) Received: by mail-pf1-x42d.google.com with SMTP id p1so7774135pfh.8 for ; Fri, 08 Oct 2021 03:06:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0tE+OjKJHdX0YaSq/SP0LPgcFSSGhc57aktXdnN08Jk=; b=gOYHix4WHmVCBUetpODWqRHCtKw2zkRnlOzILi/AukbRmbFzIF1A3ycyJH5Uic3j49 /kAhOSbW2sTpnedQcMvZ5FWgr/YAuVFNZuMd12Z5tSVWB+vGT1a5SazFy1uhjMuCZP4h d37OVXxIsaoh1xvhKMJvG9b2iq4QG4qjX47Ec= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0tE+OjKJHdX0YaSq/SP0LPgcFSSGhc57aktXdnN08Jk=; b=1vQanDeqjQf1iwPEYp1dOAyEwTtuSel0BpUAvI6pibFWA7pmwR8gHFPWbUYatp5yaU mXN6soqR9o+cNOz3QUi7mHwmTC7F3UpLp1ygDq/1+MQ8z3b2BdAHdEd7FNFae/pYpZzO TH426rphhEJx8uRilUfccjvWTpAvsJU8YzTEgbck1uV5HmM1KX/jTTfhNaOu+nlDnN57 W/PPVD9/IFHz3s257W+zm769dBMRy4HjUPWajmyb2+lD26EyXiGon3JbqO0T8SbcUmz2 VA0aflsXW9kiAEf4KMSxSQM6D2lHqHVjjVbjuy8nq/0xkMRpwRcOFDC5/njLGVqN/R4/ /clQ== X-Gm-Message-State: AOAM533I6VA02ZO1cBCX2N5Sjp5jfLMOSrmX/zl3tYs5VciBJR941k2g WOFa2J02aqDuyq1HTLsOumTdrg== X-Received: by 2002:a63:d34f:: with SMTP id u15mr3879802pgi.200.1633687571528; Fri, 08 Oct 2021 03:06:11 -0700 (PDT) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:ad8d:f936:2048:d735]) by smtp.gmail.com with ESMTPSA id a7sm2082255pfn.150.2021.10.08.03.06.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Oct 2021 03:06:11 -0700 (PDT) From: Chen-Yu Tsai To: Ezequiel Garcia , Mauro Carvalho Chehab Cc: Chen-Yu Tsai , linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Andrzej Pietrasiewicz , stable@vger.kernel.org Subject: [PATCH 2/2] media: rkvdec: Support dynamic resolution changes Date: Fri, 8 Oct 2021 18:04:23 +0800 Message-Id: <20211008100423.739462-3-wenst@chromium.org> X-Mailer: git-send-email 2.33.0.882.g93a45727a2-goog In-Reply-To: <20211008100423.739462-1-wenst@chromium.org> References: <20211008100423.739462-1-wenst@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The mem-to-mem stateless decoder API specifies support for dynamic resolution changes. In particular, the decoder should accept format changes on the OUTPUT queue even when buffers have been allocated, as long as it is not streaming. Relax restrictions for S_FMT as described in the previous paragraph, and as long as the codec format remains the same. This aligns it with the Hantro and Cedrus decoders. This change was mostly based on commit ae02d49493b5 ("media: hantro: Fix s_fmt for dynamic resolution changes"). Since rkvdec_s_fmt() is now just a wrapper around the output/capture variants without any additional shared functionality, drop the wrapper and call the respective functions directly. Fixes: cd33c830448b ("media: rkvdec: Add the rkvdec driver") Cc: Signed-off-by: Chen-Yu Tsai --- drivers/staging/media/rkvdec/rkvdec.c | 40 +++++++++++++-------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/drivers/staging/media/rkvdec/rkvdec.c b/drivers/staging/media/rkvdec/rkvdec.c index 7131156c1f2c..3f3f96488d74 100644 --- a/drivers/staging/media/rkvdec/rkvdec.c +++ b/drivers/staging/media/rkvdec/rkvdec.c @@ -280,31 +280,20 @@ static int rkvdec_try_output_fmt(struct file *file, void *priv, return 0; } -static int rkvdec_s_fmt(struct file *file, void *priv, - struct v4l2_format *f, - int (*try_fmt)(struct file *, void *, - struct v4l2_format *)) +static int rkvdec_s_capture_fmt(struct file *file, void *priv, + struct v4l2_format *f) { struct rkvdec_ctx *ctx = fh_to_rkvdec_ctx(priv); struct vb2_queue *vq; + int ret; - if (!try_fmt) - return -EINVAL; - - vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type); + /* Change not allowed if queue is busy */ + vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, + V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE); if (vb2_is_busy(vq)) return -EBUSY; - return try_fmt(file, priv, f); -} - -static int rkvdec_s_capture_fmt(struct file *file, void *priv, - struct v4l2_format *f) -{ - struct rkvdec_ctx *ctx = fh_to_rkvdec_ctx(priv); - int ret; - - ret = rkvdec_s_fmt(file, priv, f, rkvdec_try_capture_fmt); + ret = rkvdec_try_capture_fmt(file, priv, f); if (ret) return ret; @@ -319,9 +308,20 @@ static int rkvdec_s_output_fmt(struct file *file, void *priv, struct v4l2_m2m_ctx *m2m_ctx = ctx->fh.m2m_ctx; const struct rkvdec_coded_fmt_desc *desc; struct v4l2_format *cap_fmt; - struct vb2_queue *peer_vq; + struct vb2_queue *peer_vq, *vq; int ret; + /* + * In order to support dynamic resolution change, the decoder admits + * a resolution change, as long as the pixelformat remains. Can't be + * done if streaming. + */ + vq = v4l2_m2m_get_vq(m2m_ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); + if (vb2_is_streaming(vq) || + (vb2_is_busy(vq) && + f->fmt.pix_mp.pixelformat != ctx->coded_fmt.fmt.pix_mp.pixelformat)) + return -EBUSY; + /* * Since format change on the OUTPUT queue will reset the CAPTURE * queue, we can't allow doing so when the CAPTURE queue has buffers @@ -331,7 +331,7 @@ static int rkvdec_s_output_fmt(struct file *file, void *priv, if (vb2_is_busy(peer_vq)) return -EBUSY; - ret = rkvdec_s_fmt(file, priv, f, rkvdec_try_output_fmt); + ret = rkvdec_try_output_fmt(file, priv, f); if (ret) return ret; -- 2.33.0.882.g93a45727a2-goog