From patchwork Thu May 14 15:39:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Dufresne X-Patchwork-Id: 63823 X-Patchwork-Delegate: hverkuil@xs4all.nl Received: from vger.kernel.org ([23.128.96.18]) by www.linuxtv.org with esmtp (Exim 4.92) (envelope-from ) id 1jZFtw-0087tw-I6; Thu, 14 May 2020 15:36:04 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727999AbgENPjX (ORCPT + 1 other); Thu, 14 May 2020 11:39:23 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:33190 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726610AbgENPjX (ORCPT ); Thu, 14 May 2020 11:39:23 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: nicolas) with ESMTPSA id F13C12A0609 From: Nicolas Dufresne Cc: stable@vger.kernel.org, kernel@collabora.com, Maxime Ripard , Paul Kocialkowski , Mauro Carvalho Chehab , Greg Kroah-Hartman , Chen-Yu Tsai , linux-media@vger.kernel.org, devel@driverdev.osuosl.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] media: cedrus: Propagate OUTPUT resolution to CAPTURE Date: Thu, 14 May 2020 11:39:03 -0400 Message-Id: <20200514153903.341287-1-nicolas.dufresne@collabora.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 To: unlisted-recipients:; (no To-header on input) Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-LSpam-Score: -2.4 (--) X-LSpam-Report: No, score=-2.4 required=5.0 tests=BAYES_00=-1.9,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no As per spec, the CAPTURE resolution should be automatically set based on the OTUPUT resolution. This patch properly propagate width/height to the capture when the OUTPUT format is set and override the user provided width/height with configured OUTPUT resolution when the CAPTURE fmt is updated. This also prevents userspace from selecting a CAPTURE resolution that is too small, avoiding unwanted page faults. Signed-off-by: Nicolas Dufresne Reviewed-by: Ezequiel Garcia Acked-by: Paul Kocialkowski --- drivers/staging/media/sunxi/cedrus/cedrus_video.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_video.c b/drivers/staging/media/sunxi/cedrus/cedrus_video.c index 16d82309e7b6..a6d6b15adc2e 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_video.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_video.c @@ -247,6 +247,8 @@ static int cedrus_try_fmt_vid_cap(struct file *file, void *priv, return -EINVAL; pix_fmt->pixelformat = fmt->pixelformat; + pix_fmt->width = ctx->src_fmt.width; + pix_fmt->height = ctx->src_fmt.height; cedrus_prepare_format(pix_fmt); return 0; @@ -319,11 +321,14 @@ static int cedrus_s_fmt_vid_out(struct file *file, void *priv, break; } - /* Propagate colorspace information to capture. */ + /* Propagate format information to capture. */ ctx->dst_fmt.colorspace = f->fmt.pix.colorspace; ctx->dst_fmt.xfer_func = f->fmt.pix.xfer_func; ctx->dst_fmt.ycbcr_enc = f->fmt.pix.ycbcr_enc; ctx->dst_fmt.quantization = f->fmt.pix.quantization; + ctx->dst_fmt.width = ctx->src_fmt.width; + ctx->dst_fmt.height = ctx->src_fmt.height; + cedrus_prepare_format(&ctx->dst_fmt); return 0; }