From nobody Mon Nov 11 08:15:58 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9CCA9C433EF for ; Mon, 27 Jun 2022 11:25:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234969AbiF0LZj (ORCPT ); Mon, 27 Jun 2022 07:25:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234853AbiF0LZC (ORCPT ); Mon, 27 Jun 2022 07:25:02 -0400 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE30C65A5 for ; Mon, 27 Jun 2022 04:25:00 -0700 (PDT) Received: by mail-pf1-x434.google.com with SMTP id 65so8691435pfw.11 for ; Mon, 27 Jun 2022 04:25:00 -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=oXn3wWbVxQI6jCo/9N11UZ5IVbNzRYO/KcWY9DeSESE=; b=YnPlXzKkEPch/sWHvGKsHeXpd88h+buPua0eN4oyDaqM34DNBm0PGwC+tZGTzDadAh 8Wr4EbkdVWgOXhwf9B9sm20t0EpfN6y1ybvTGdiQLTO4MaIgo+ruM/RZ3UNuEaqt4yfk FvtJA6z6WkBX3v0VX40F+SeECrOgZaRAAtYfU= 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=oXn3wWbVxQI6jCo/9N11UZ5IVbNzRYO/KcWY9DeSESE=; b=G+0sjPRZPQr/6V+0U74YdbKOGEJ2QnEmBQDQ6ofQqOk90L7t4oTKSnVsPdycVRdC6x t05AZu0UnUtPKsnvlgnM9mkrvo59pAgQCiyKV0Ky2yKw1xUDS7fqg2aZ8zGB1I3VgQzC QKVwS/hLtqA8SV+gdXoBnyIGFQ68tMqFRBTBMG6wycaguyeAU+l9eG8omV5EBP3lckL5 ozi/KluYSIXTFRYPhwgaaG71DmTylpl+NHH0L7JAT0KYjmBXF84y0l0nAFwm3ZfWgzKa N5/TuCPje/nyB1DFk8oo9WDA4AJYIHi7zOs2cSt0adnFNc4A3MiuTXYEF00eOzFxSXcC 8vuQ== X-Gm-Message-State: AJIora9XGWCmLYv7Nnq38rYxvwT39KWepysUrVIOPWu7xORDWHKz/bVC 0/c7KMKHkz77Cyy9i9mRhB0mXg== X-Google-Smtp-Source: AGRyM1vaMaOkFM2pCPF4KFwOkt5DhQveHKus1rkl2C7vQO6ZDwtPdPvhygvlqcvYA0FYizMxom86mQ== X-Received: by 2002:a05:6a00:2187:b0:50c:ef4d:ef3b with SMTP id h7-20020a056a00218700b0050cef4def3bmr14510434pfi.83.1656329100033; Mon, 27 Jun 2022 04:25:00 -0700 (PDT) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:2dc1:c31b:b5ed:f3aa]) by smtp.gmail.com with ESMTPSA id lj4-20020a17090b344400b001ece32cbec9sm9246889pjb.24.2022.06.27.04.24.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jun 2022 04:24:59 -0700 (PDT) From: Chen-Yu Tsai To: Tiffany Lin , Andrew-CT Chen , Mauro Carvalho Chehab , Hans Verkuil Cc: Nicolas Dufresne , Chen-Yu Tsai , linux-media@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Nicolas Dufresne , AngeloGioacchino Del Regno , Yunfei Dong Subject: [PATCH 1/4] media: mediatek: vcodec: dec: Fix 4K frame size enumeration Date: Mon, 27 Jun 2022 19:23:59 +0800 Message-Id: <20220627112402.2332046-2-wenst@chromium.org> X-Mailer: git-send-email 2.37.0.rc0.161.g10f37bed90-goog In-Reply-To: <20220627112402.2332046-1-wenst@chromium.org> References: <20220627112402.2332046-1-wenst@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This partially reverts commit b018be06f3c7 ("media: mediatek: vcodec: Read max resolution from dec_capability"). In this commit, the maximum resolution ended up being a function of both the firmware capability and the current set format. However, frame size enumeration for output (coded) formats should not depend on the format set, but should return supported resolutions for the format requested by userspace. Fix this so that the driver returns the supported resolutions correctly, even if the instance only has default settings, or if the output format is currently set to VP8F, which does not support 4K. Fixes: b018be06f3c7 ("media: mediatek: vcodec: Read max resolution from dec= _capability") Signed-off-by: Chen-Yu Tsai --- drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c | 2 -- .../platform/mediatek/vcodec/mtk_vcodec_dec_stateless.c | 7 +++++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c b/driv= ers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c index 5d6fdf18c3a6..fcb4b8131c49 100644 --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c @@ -595,8 +595,6 @@ static int vidioc_enum_framesizes(struct file *file, vo= id *priv, fsize->type =3D V4L2_FRMSIZE_TYPE_STEPWISE; fsize->stepwise =3D dec_pdata->vdec_framesizes[i].stepwise; =20 - fsize->stepwise.max_width =3D ctx->max_width; - fsize->stepwise.max_height =3D ctx->max_height; mtk_v4l2_debug(1, "%x, %d %d %d %d %d %d", ctx->dev->dec_capability, fsize->stepwise.min_width, diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_stateles= s.c b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_stateless.c index 16d55785d84b..9a4d3e3658aa 100644 --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_stateless.c +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_stateless.c @@ -360,6 +360,13 @@ static void mtk_vcodec_add_formats(unsigned int fourcc, =20 mtk_vdec_framesizes[count_framesizes].fourcc =3D fourcc; mtk_vdec_framesizes[count_framesizes].stepwise =3D stepwise_fhd; + if (!(ctx->dev->dec_capability & VCODEC_CAPABILITY_4K_DISABLED) && + fourcc !=3D V4L2_PIX_FMT_VP8_FRAME) { + mtk_vdec_framesizes[count_framesizes].stepwise.max_width =3D + VCODEC_DEC_4K_CODED_WIDTH; + mtk_vdec_framesizes[count_framesizes].stepwise.max_height =3D + VCODEC_DEC_4K_CODED_HEIGHT; + } num_framesizes++; break; case V4L2_PIX_FMT_MM21: --=20 2.37.0.rc0.161.g10f37bed90-goog From nobody Mon Nov 11 08:15:58 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AD2BDC433EF for ; Mon, 27 Jun 2022 11:25:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234975AbiF0LZm (ORCPT ); Mon, 27 Jun 2022 07:25:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234873AbiF0LZG (ORCPT ); Mon, 27 Jun 2022 07:25:06 -0400 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CCF565B6 for ; Mon, 27 Jun 2022 04:25:03 -0700 (PDT) Received: by mail-pj1-x1035.google.com with SMTP id n16-20020a17090ade9000b001ed15b37424so9109504pjv.3 for ; Mon, 27 Jun 2022 04:25:03 -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=7dXRxtZvr+s2XVNzWzC29rU2+VQvIIaYQPfnDdLc66o=; b=lCQwBZgKD56DJpohXiDdqChHVRMNjjSIqJXaJj7O+tImuokhzYLrf/x9F8WeAVXDLm QqC1o5Dd3iwCQnUcchQy2Yzm2viR+3DCLfQGVlr9mtRWSOsI3uJUFUi3FhZoVvQcx7aq FXZGJKa1Z/lT4IQCHxJq7hiO1ySSh4/+6HQk8= 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=7dXRxtZvr+s2XVNzWzC29rU2+VQvIIaYQPfnDdLc66o=; b=iNiKWZM9gTpsKG1SBqrL2KZO75981WQ75DxsXpR/SoouBV8VMmvZebf/ga7T9EScLB ODcgcdS9DPWjy3Zy7oyvN5/cKcQLc9zJ37FV1Z4FPHyYjWsXhC1659RvZYcUlW3CIzk6 n8H327rPizQzZIec9jCBWt4zAOvHrX7pyu2h+Ov4PmErkE/wVXrUH6nHXRXKAmQB3lri Ax/p909252+fIEqTGP23pAMalwzSmmzZzI7dmCzFSqTr7yifOiZiUfH9sJltra5GPgD5 +qRDW7qrvxFEsCp/21EetLKxPxpdpoGlT4gwbLCNjxX1kGN1kWhKvCxnX3qnpNXcQkDq 8eeg== X-Gm-Message-State: AJIora+BBUbQlpf1vGEStM6kUphhzq2HBpiglgBjvlxM+1AkEM4KUHMu eJs/uQgZEX3MdvozqwvollUMcg== X-Google-Smtp-Source: AGRyM1viOHWHl84VVlTGqpixiZ6FlTpaaah53khsejDs3LQ40SRGD8i9SytWAXzQY+IU7V1myB2eqQ== X-Received: by 2002:a17:902:f10b:b0:16a:198f:bedb with SMTP id e11-20020a170902f10b00b0016a198fbedbmr14357909plb.16.1656329102608; Mon, 27 Jun 2022 04:25:02 -0700 (PDT) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:2dc1:c31b:b5ed:f3aa]) by smtp.gmail.com with ESMTPSA id lj4-20020a17090b344400b001ece32cbec9sm9246889pjb.24.2022.06.27.04.25.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jun 2022 04:25:02 -0700 (PDT) From: Chen-Yu Tsai To: Tiffany Lin , Andrew-CT Chen , Mauro Carvalho Chehab , Hans Verkuil Cc: Nicolas Dufresne , Chen-Yu Tsai , linux-media@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Nicolas Dufresne , AngeloGioacchino Del Regno , Yunfei Dong Subject: [PATCH 2/4] media: mediatek: vcodec: dec: Set default max resolution based on format Date: Mon, 27 Jun 2022 19:24:00 +0800 Message-Id: <20220627112402.2332046-3-wenst@chromium.org> X-Mailer: git-send-email 2.37.0.rc0.161.g10f37bed90-goog In-Reply-To: <20220627112402.2332046-1-wenst@chromium.org> References: <20220627112402.2332046-1-wenst@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" In commit b018be06f3c7 ("media: mediatek: vcodec: Read max resolution from dec_capability") the driver ended up blindly setting the maximum resolution to 1080p, even if the hardware and default output format supported up to 4K. This would only be overridden by a subsequent S_FMT call. Correctly initialize the maximum resolution based on the default output format. Fixes: b018be06f3c7 ("media: mediatek: vcodec: Read max resolution from dec= _capability") Signed-off-by: Chen-Yu Tsai --- .../media/platform/mediatek/vcodec/mtk_vcodec_dec.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c b/driv= ers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c index fcb4b8131c49..f1b82d4c5be5 100644 --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c @@ -169,6 +169,16 @@ void mtk_vcodec_dec_set_default_params(struct mtk_vcod= ec_ctx *ctx) q_data->sizeimage[0] =3D DFT_CFG_WIDTH * DFT_CFG_HEIGHT; q_data->bytesperline[0] =3D 0; =20 + if (!(ctx->dev->dec_capability & VCODEC_CAPABILITY_4K_DISABLED) && + q_data->fmt->fourcc !=3D V4L2_PIX_FMT_VP8_FRAME) { + mtk_v4l2_debug(3, "4K is enabled"); + ctx->max_width =3D VCODEC_DEC_4K_CODED_WIDTH; + ctx->max_height =3D VCODEC_DEC_4K_CODED_HEIGHT; + } else { + ctx->max_width =3D MTK_VDEC_MAX_W; + ctx->max_height =3D MTK_VDEC_MAX_H; + } + q_data =3D &ctx->q_data[MTK_Q_DATA_DST]; memset(q_data, 0, sizeof(struct mtk_q_data)); q_data->visible_width =3D DFT_CFG_WIDTH; @@ -177,8 +187,6 @@ void mtk_vcodec_dec_set_default_params(struct mtk_vcode= c_ctx *ctx) q_data->coded_height =3D DFT_CFG_HEIGHT; q_data->fmt =3D ctx->dev->vdec_pdata->default_cap_fmt; q_data->field =3D V4L2_FIELD_NONE; - ctx->max_width =3D MTK_VDEC_MAX_W; - ctx->max_height =3D MTK_VDEC_MAX_H; =20 v4l_bound_align_image(&q_data->coded_width, MTK_VDEC_MIN_W, --=20 2.37.0.rc0.161.g10f37bed90-goog From nobody Mon Nov 11 08:15:58 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 872ADC433EF for ; Mon, 27 Jun 2022 11:25:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234845AbiF0LZ5 (ORCPT ); Mon, 27 Jun 2022 07:25:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234887AbiF0LZP (ORCPT ); Mon, 27 Jun 2022 07:25:15 -0400 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE9A8659E for ; Mon, 27 Jun 2022 04:25:05 -0700 (PDT) Received: by mail-pj1-x102c.google.com with SMTP id l2so7786495pjf.1 for ; Mon, 27 Jun 2022 04:25:05 -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=D2+1y0LCJVkrfpHsQlRGxEvdnIAFt/zhTxrdy/ouAhU=; b=FRaInAGaTCaXwvPDQiOiybyVs1ZTq7aqp376IA6xTXMeo48fL1QiC0oNsa5/HetL55 9HUHwrtKWYZ1Pn3nxng6Lr66Ut1zka2dTP94nT+yTufd+icL2WJ59mHZ/iaNZK4dkxE7 7+g5zJGUIdsmMd22pGGmiLmu4Xk3PdkamGcOk= 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=D2+1y0LCJVkrfpHsQlRGxEvdnIAFt/zhTxrdy/ouAhU=; b=PdcnPR7BQE1bo4oeMpwGFsFceaLqtZ+ULs215ceHj9Ktjog9PyaH2FU0mOQC2QzcEB Cz66Y75/u38RWli+NqqxhF9bxQrx+Fv7Y6+ClqPLIDAOmBXzC1sr6E+hj7gUKYyyc+lb B4TENhGKvvoejoenwWW0Tc8zlGLgbQb1jP1pVYGAgU+QG+zEMKMstUfCixybDi6T3I5g 6xm9OhvD9MTfo5XJ9yYhV24hzgRcnXYh4CIniQRJZ49s7K8kQYXAbnaYLsScHb2deFrH CaHpktsTjzaTjhj0E/U90cZgoz7G7UwKFHO4xJT/LVDmyz55zT/rkoudEKnE+Be5reAL 0gHQ== X-Gm-Message-State: AJIora+a2wRr0HiaAo7JVSbJyFB3rBZSYB+onOTjWOeFETnSNH7q14PO y+Daw8YraQ47yGOFSg9Nd6jDKg== X-Google-Smtp-Source: AGRyM1vq1tIU8x5lkBrW/7ilQI/Txpt0kSZaL6oXEJkTV+khkTTmLOcOfrxjLLVXkYCHw9PaRKrIdA== X-Received: by 2002:a17:902:c2c6:b0:168:d8ce:90b2 with SMTP id c6-20020a170902c2c600b00168d8ce90b2mr14451592pla.110.1656329105228; Mon, 27 Jun 2022 04:25:05 -0700 (PDT) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:2dc1:c31b:b5ed:f3aa]) by smtp.gmail.com with ESMTPSA id lj4-20020a17090b344400b001ece32cbec9sm9246889pjb.24.2022.06.27.04.25.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jun 2022 04:25:04 -0700 (PDT) From: Chen-Yu Tsai To: Tiffany Lin , Andrew-CT Chen , Mauro Carvalho Chehab , Hans Verkuil Cc: Nicolas Dufresne , Chen-Yu Tsai , linux-media@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Nicolas Dufresne , AngeloGioacchino Del Regno , Yunfei Dong Subject: [PATCH 3/4] media: mediatek: vcodec: dec: Fix resolution clamping in TRY_FMT Date: Mon, 27 Jun 2022 19:24:01 +0800 Message-Id: <20220627112402.2332046-4-wenst@chromium.org> X-Mailer: git-send-email 2.37.0.rc0.161.g10f37bed90-goog In-Reply-To: <20220627112402.2332046-1-wenst@chromium.org> References: <20220627112402.2332046-1-wenst@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" In commit b018be06f3c7 ("media: mediatek: vcodec: Read max resolution from dec_capability"), TRY_FMT clamps the resolution to the maximum that was previously set either by default 1080p or the limit set by a previous S_FMT call. This does not make sense when doing TRY_FMT for the output side, which may have different capabilities. Instead, for the output side, find the maximum resolution based on the pixel format requested. For the capture side, continue to use the maximum resolution set by default or by a previous S_FMT call. The maximum resolution is found from the list of per-format frame sizes, so the patch "media: mediatek: vcodec: dec: Fix 4K frame size enumeration" is needed. Fixes: b018be06f3c7 ("media: mediatek: vcodec: Read max resolution from dec= _capability") Signed-off-by: Chen-Yu Tsai --- .../platform/mediatek/vcodec/mtk_vcodec_dec.c | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c b/driv= ers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c index f1b82d4c5be5..ea951cb3b927 100644 --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c @@ -282,13 +282,29 @@ static int vidioc_try_fmt(struct mtk_vcodec_ctx *ctx,= struct v4l2_format *f, const struct mtk_video_fmt *fmt) { struct v4l2_pix_format_mplane *pix_fmt_mp =3D &f->fmt.pix_mp; + const struct mtk_vcodec_dec_pdata *dec_pdata =3D ctx->dev->vdec_pdata; + unsigned int max_width, max_height; + int i; + + if (V4L2_TYPE_IS_OUTPUT(f->type)) { + max_width =3D MTK_VDEC_MAX_W; + max_height =3D MTK_VDEC_MAX_H; + for (i =3D 0; i < *dec_pdata->num_framesizes; ++i) + if (f->fmt.pix_mp.pixelformat =3D=3D dec_pdata->vdec_framesizes[i].four= cc) { + max_width =3D dec_pdata->vdec_framesizes[i].stepwise.max_width; + max_height =3D dec_pdata->vdec_framesizes[i].stepwise.max_height; + } + } else { + max_width =3D ctx->max_width; + max_height =3D ctx->max_height; + } =20 pix_fmt_mp->field =3D V4L2_FIELD_NONE; =20 pix_fmt_mp->width =3D - clamp(pix_fmt_mp->width, MTK_VDEC_MIN_W, ctx->max_width); + clamp(pix_fmt_mp->width, MTK_VDEC_MIN_W, max_width); pix_fmt_mp->height =3D - clamp(pix_fmt_mp->height, MTK_VDEC_MIN_H, ctx->max_height); + clamp(pix_fmt_mp->height, MTK_VDEC_MIN_H, max_height); =20 if (f->type =3D=3D V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { pix_fmt_mp->num_planes =3D 1; @@ -306,16 +322,16 @@ static int vidioc_try_fmt(struct mtk_vcodec_ctx *ctx,= struct v4l2_format *f, tmp_h =3D pix_fmt_mp->height; v4l_bound_align_image(&pix_fmt_mp->width, MTK_VDEC_MIN_W, - ctx->max_width, 6, + max_width, 6, &pix_fmt_mp->height, MTK_VDEC_MIN_H, - ctx->max_height, 6, 9); + max_height, 6, 9); =20 if (pix_fmt_mp->width < tmp_w && - (pix_fmt_mp->width + 64) <=3D ctx->max_width) + (pix_fmt_mp->width + 64) <=3D max_width) pix_fmt_mp->width +=3D 64; if (pix_fmt_mp->height < tmp_h && - (pix_fmt_mp->height + 64) <=3D ctx->max_height) + (pix_fmt_mp->height + 64) <=3D max_height) pix_fmt_mp->height +=3D 64; =20 mtk_v4l2_debug(0, --=20 2.37.0.rc0.161.g10f37bed90-goog From nobody Mon Nov 11 08:15:58 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B48C3C43334 for ; Mon, 27 Jun 2022 11:26:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235019AbiF0L0G (ORCPT ); Mon, 27 Jun 2022 07:26:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234898AbiF0LZQ (ORCPT ); Mon, 27 Jun 2022 07:25:16 -0400 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C091965C3 for ; Mon, 27 Jun 2022 04:25:08 -0700 (PDT) Received: by mail-pf1-x432.google.com with SMTP id a15so8692281pfv.13 for ; Mon, 27 Jun 2022 04:25:08 -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=+Bdt/pZAOacqJuCFzII9rBWAKqWiyNAPCi+XwvqCQy0=; b=gND2N7zr6zJtFEQ1/Qh++AaC/I3sYIjuvDxr52m7Vusjymll7C22xQJnXtQSAgXqpJ r89NGcuSNrr6jtyaN6WQTCKIh/3bqzP4HhpSMrh/aHkJRp7fHeZuEPYn9tacdAUncKNg MRC5No3iihpOW7bs07Qq05whWNJSKaynJZWv8= 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=+Bdt/pZAOacqJuCFzII9rBWAKqWiyNAPCi+XwvqCQy0=; b=gHYCdkuA053mbQfsojIGCd4+MkXoN/ztH14H079cdv4EsALF2LnZCUnGGhll3FKJF/ OVhY/X8p6Gum9Noje6WQG9VmHsEC1K9PQzpdUf7OV0Vp1LAoun1kNWvf/v+gYdimC0kq tA9NS5klDmIBc4cSWhiwqDubKKcVvY7pwkjOhjaQKxyRiw8pNVRo/vECJYtYIRonIyVR Qfwl4ANzfIfOk9yzfOBMrOnrgbBOGtUwKg/6DV1ty6dgAdae2TiQ6CJSlKJs4kFEYThM Mcv3SM2frvdtX7Mh+pgnMDgC8zcreoQQqAfYr6YtHpSV4JeNzmblmaTLz38EObdz/d0d cNLQ== X-Gm-Message-State: AJIora9oFMrjGQjRGoFJHEC8O84XL4TnFk/cL8lOBFAEILPgVPjgB3Nz BlOjyNCnVACPohbr++c07uMPnf74076r7A== X-Google-Smtp-Source: AGRyM1upMeiOln1K4lkc+rTedGu7rooW/59+/KUoBEA/D4qTE+BzMxTrodbWQsrklKjwp/RQ1Lgmcw== X-Received: by 2002:a65:6045:0:b0:399:3a5e:e25a with SMTP id a5-20020a656045000000b003993a5ee25amr12685653pgp.139.1656329107880; Mon, 27 Jun 2022 04:25:07 -0700 (PDT) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:2dc1:c31b:b5ed:f3aa]) by smtp.gmail.com with ESMTPSA id lj4-20020a17090b344400b001ece32cbec9sm9246889pjb.24.2022.06.27.04.25.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jun 2022 04:25:07 -0700 (PDT) From: Chen-Yu Tsai To: Tiffany Lin , Andrew-CT Chen , Mauro Carvalho Chehab , Hans Verkuil Cc: Nicolas Dufresne , Chen-Yu Tsai , linux-media@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Nicolas Dufresne , AngeloGioacchino Del Regno , Yunfei Dong Subject: [PATCH 4/4] media: mediatek: vcodec: dec: Set maximum resolution when S_FMT on output only Date: Mon, 27 Jun 2022 19:24:02 +0800 Message-Id: <20220627112402.2332046-5-wenst@chromium.org> X-Mailer: git-send-email 2.37.0.rc0.161.g10f37bed90-goog In-Reply-To: <20220627112402.2332046-1-wenst@chromium.org> References: <20220627112402.2332046-1-wenst@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Only the coded format impacts whether 4K resolution is supported: the decoder does not support 4K for VP8, but does for other formats. Update the maximum resolution in S_FMT only when called for the output format. Otherwise we could set output format for VP8, then set capture format, and then the resolution limit becomes inconsistent. Fixes: b018be06f3c7 ("media: mediatek: vcodec: Read max resolution from dec= _capability") Signed-off-by: Chen-Yu Tsai --- drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c b/driv= ers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c index ea951cb3b927..995c61d6a40e 100644 --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c @@ -521,7 +521,8 @@ static int vidioc_vdec_s_fmt(struct file *file, void *p= riv, if (fmt =3D=3D NULL) return -EINVAL; =20 - if (!(ctx->dev->dec_capability & VCODEC_CAPABILITY_4K_DISABLED) && + if (V4L2_TYPE_IS_OUTPUT(f->type) && + !(ctx->dev->dec_capability & VCODEC_CAPABILITY_4K_DISABLED) && fmt->fourcc !=3D V4L2_PIX_FMT_VP8_FRAME) { mtk_v4l2_debug(3, "4K is enabled"); ctx->max_width =3D VCODEC_DEC_4K_CODED_WIDTH; --=20 2.37.0.rc0.161.g10f37bed90-goog