From patchwork Mon Jun 27 11:24:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 585367 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 F1158C43334 for ; Mon, 27 Jun 2022 11:25:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234971AbiF0LZj (ORCPT ); Mon, 27 Jun 2022 07:25:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234872AbiF0LZG (ORCPT ); Mon, 27 Jun 2022 07:25:06 -0400 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CA1D65B5 for ; Mon, 27 Jun 2022 04:25:03 -0700 (PDT) Received: by mail-pj1-x1029.google.com with SMTP id g20-20020a17090a579400b001ed52939d72so3663438pji.4 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=4IoKzgFLB5vGibM10bPPBHiYMFe8LGZhyvcHH77cpiMh10I4DAL5GLWzfVqHsvwdPE rlGtDxRC/2OWJJdN/p2Y6fC5+eG/LI0Z+2fGgQ7mHi+pd5D2cJR3MPc7v4UyB9sfiU7q O6AtuEtSmC1Ox8AHzKnU68b7CWZMcN6gHEVb3KMb+7a0EVc8j1YmFf3fEru2NJoKLkEk eb8X3/O0H/9Mx41Dl0rIQzlZt5B3OdP+WNRuevwkj/IoOGUGkTjdygKuSJO9+cZXJ5jF fpa2L5963bc98IccpinB9wyt2HVRrM2YnPGAi2HFXaSZWzwoVGVZpY1aXpRCpo4ewofi VIZQ== X-Gm-Message-State: AJIora98npIv+3PEAfnSvRCySkIOkp59gNJE8RCx0KhC4+P3N2TJXIXB EwASr6Qp/Vckb/zkncsz+3OFgQ== 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 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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/drivers/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_vcodec_ctx *ctx) q_data->sizeimage[0] = DFT_CFG_WIDTH * DFT_CFG_HEIGHT; q_data->bytesperline[0] = 0; + if (!(ctx->dev->dec_capability & VCODEC_CAPABILITY_4K_DISABLED) && + q_data->fmt->fourcc != V4L2_PIX_FMT_VP8_FRAME) { + mtk_v4l2_debug(3, "4K is enabled"); + ctx->max_width = VCODEC_DEC_4K_CODED_WIDTH; + ctx->max_height = VCODEC_DEC_4K_CODED_HEIGHT; + } else { + ctx->max_width = MTK_VDEC_MAX_W; + ctx->max_height = MTK_VDEC_MAX_H; + } + q_data = &ctx->q_data[MTK_Q_DATA_DST]; memset(q_data, 0, sizeof(struct mtk_q_data)); q_data->visible_width = DFT_CFG_WIDTH; @@ -177,8 +187,6 @@ void mtk_vcodec_dec_set_default_params(struct mtk_vcodec_ctx *ctx) q_data->coded_height = DFT_CFG_HEIGHT; q_data->fmt = ctx->dev->vdec_pdata->default_cap_fmt; q_data->field = V4L2_FIELD_NONE; - ctx->max_width = MTK_VDEC_MAX_W; - ctx->max_height = MTK_VDEC_MAX_H; v4l_bound_align_image(&q_data->coded_width, MTK_VDEC_MIN_W, From patchwork Mon Jun 27 11:24:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 585366 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 0BC6DC433EF for ; Mon, 27 Jun 2022 11:25:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234907AbiF0LZx (ORCPT ); Mon, 27 Jun 2022 07:25:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234899AbiF0LZQ (ORCPT ); Mon, 27 Jun 2022 07:25:16 -0400 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39EB665C7 for ; Mon, 27 Jun 2022 04:25:08 -0700 (PDT) Received: by mail-pg1-x52d.google.com with SMTP id x8so4217542pgj.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=idMqG40C/kS8UvBIkh+gz/5w0gk0noI3BkbZdp4rq0oqIaCRSIR6+cxV9rGvLLsAtn 2luwP8ZoFAoRusDUyfcwVwpONbUm2CPyI2zxffdStDReKfwxfChRQeQv/GEYwh2yY6pj gPLDOILhEcXdcixh3/lVC2vIxM6phY+7rw9TNqaQQ/XVgu50ToOft6FrICnKHEnefTBs XBmHmrTKqQFbqm8u7pDsVqD9+Y6w54W86find+GvrNAJTZcX30flLr18ZuSaMwJ73nOp XdqoDjo8fPSbJaAQoUq0P3UWPK4ZaCKs+UMDJzbtul6vNAuqRwMwSe30WYqa6mWlVRmR 8nYA== X-Gm-Message-State: AJIora99K6gyeAKKp2/N49r6mhRzJ/QTauurSIIgH/VZYfGZacjYDKJH ev+daTVelkHyApN37ETC/UW+NQ== 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 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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/drivers/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 *priv, if (fmt == NULL) return -EINVAL; - 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 != V4L2_PIX_FMT_VP8_FRAME) { mtk_v4l2_debug(3, "4K is enabled"); ctx->max_width = VCODEC_DEC_4K_CODED_WIDTH;