Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3087625rwb; Mon, 15 Aug 2022 17:49:39 -0700 (PDT) X-Google-Smtp-Source: AA6agR7LyePs+h9Xo35+hVjzLkRWXPk+jdyJU8dPcNCqzoTfKJ7rHLycoQMhkhDO+y9uwhssrPYO X-Received: by 2002:a17:907:6e1e:b0:730:a923:421d with SMTP id sd30-20020a1709076e1e00b00730a923421dmr11669448ejc.118.1660610979293; Mon, 15 Aug 2022 17:49:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660610979; cv=none; d=google.com; s=arc-20160816; b=HGuj8PXgvqU5qU9x/Vh4hqTr9l4eF5boMNBLI++ZJuL2nLAqqO4xUO123Kvr9rp1Fq rnHeB736cfjqOMXRk3BHFWX4OCULNwtCad3kNziF6orbM9bY4gJE2Hu2a9/XgM6wUZgo aTCtkA4IL31fQgJxMp+Lpv44sdn3U45V8u96Lw1qILG49GnZKFjiJK+y2WtPJ2SRdxyI BHS3FpQFNFeoOImbVaL/pkNxa69hW1JhL1zGyrTnVGwfzl98xxl0g99eFh7howUP8I+c RhKyJ+S4cA/wFNqUjkhbM6oXRcHtu+8dg3nJHQYTAMVCP356SP6E9uigjnffSRP2QRIb 7TOg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=bnl52k70jAT5nX8eAQI1LC+fVFdFAB48OMpaxXZGe1k=; b=nyTSOlfGtXyf4K+3PWNQd4k91Xqch0rWJboxoiXAUTTcwohZeYaB2/HGwToyyesp+X RrobXOZ32opLC4lpvtGA6Czi0TPnP5TNOSQY+6pcyxZt1BXEHYea+jOhN5gkXL5lDHvd +k1PIThtBjPb50hMwuy6Qor5BBGFy9gyWsRaHkTH9rPiU0cbmjj/bBBIpfGKBBdUYHOx s6WTTKkykt5JdDlPhbxfp31gau7TIrolLXg5OteBqFpKkSy0gYJ7eP9DS9NM+DiIg/kP K+An3R7WHV6g7o/R+2uuQ+O/MmFWPtqaUALPbgPUfOeu4hEtkVJfuGuN/4147QDNHTxQ IOfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vVgPQ9SX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g17-20020aa7c591000000b0043c0288d312si7833207edq.584.2022.08.15.17.49.13; Mon, 15 Aug 2022 17:49:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vVgPQ9SX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354216AbiHOXu2 (ORCPT + 99 others); Mon, 15 Aug 2022 19:50:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354657AbiHOXqI (ORCPT ); Mon, 15 Aug 2022 19:46:08 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CBFF399C7; Mon, 15 Aug 2022 13:14:33 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id A7724B80EAB; Mon, 15 Aug 2022 20:14:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D6081C433B5; Mon, 15 Aug 2022 20:14:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660594469; bh=rtP5UkxezjL2rl/T3mDG4gHvrm9VQE6BfFamIZzDzOM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vVgPQ9SXUNJBH4FvkJX+X9bqWOPbNUYoHks4j7P3qvwOiAdxBZn/nBbLkDE+BpkpL 5xypjebIRsnwGUvuskOSaEWT6xmoMPYQj19SgO8Sby81sXnZ3u4R0bhAcbIm0Bsppn YPT2tNcvYwVmIvI6p16bGZ9XKUjxhArcWh1KMZBc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chen-Yu Tsai , AngeloGioacchino Del Regno , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.19 0458/1157] media: mediatek: vcodec: decoder: Fix 4K frame size enumeration Date: Mon, 15 Aug 2022 19:56:54 +0200 Message-Id: <20220815180457.921894012@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chen-Yu Tsai [ Upstream commit f1748f8f8174a65a885a8e6c0dc11658a6705ac2 ] 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. This adds an copy of special casing for !VP8 and 4K support. The other existing copy will be removed when .max_{width,height} are removed from |struct mtk_vcodec_ctx| in a subsequent patch. Fixes: b018be06f3c7 ("media: mediatek: vcodec: Read max resolution from dec_capability") Signed-off-by: Chen-Yu Tsai Tested-by: AngeloGioacchino Del Regno Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- 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/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c index 01836a1c7d3f..393b127138f3 100644 --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c @@ -536,8 +536,6 @@ static int vidioc_enum_framesizes(struct file *file, void *priv, fsize->type = V4L2_FRMSIZE_TYPE_STEPWISE; fsize->stepwise = dec_pdata->vdec_framesizes[i].stepwise; - fsize->stepwise.max_width = ctx->max_width; - fsize->stepwise.max_height = 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_stateless.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, mtk_vdec_framesizes[count_framesizes].fourcc = fourcc; mtk_vdec_framesizes[count_framesizes].stepwise = stepwise_fhd; + if (!(ctx->dev->dec_capability & VCODEC_CAPABILITY_4K_DISABLED) && + fourcc != V4L2_PIX_FMT_VP8_FRAME) { + mtk_vdec_framesizes[count_framesizes].stepwise.max_width = + VCODEC_DEC_4K_CODED_WIDTH; + mtk_vdec_framesizes[count_framesizes].stepwise.max_height = + VCODEC_DEC_4K_CODED_HEIGHT; + } num_framesizes++; break; case V4L2_PIX_FMT_MM21: -- 2.35.1