Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp372203pxa; Fri, 14 Aug 2020 06:43:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJznEa6szpCnF9koD1ourF3IpztyKWI8nt+Gl0TDkIeZTvMwBoLJRRhhfaPAPvJ2oQQhNQ15 X-Received: by 2002:a17:906:a0c5:: with SMTP id bh5mr2423822ejb.120.1597412583214; Fri, 14 Aug 2020 06:43:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597412583; cv=none; d=google.com; s=arc-20160816; b=L/gbK++/D09oUBpYhOF1QwLJUlq9KjwI8BPNcGXhlG3/w2adQ+gbNebH/RDcL4Tys7 mySy93eB0wuP/84LJLGhZjEyIAA9MNmqFyvRz73PycOy5CStV2QczfBlZ6ZORaFeiD0w EZkWUB4daYKG0IMGC9zT8f4J9eP2/dpPHh9O/Aj4vuckeOaA1jq9eja/0xTyTCC0hQRK c5MFSHMSmFJE01IDrbHodQHO5aGjSHvBrjPjdB+3HKE9IJnjm6ZBynXqvMBp8wm+N4E4 EZc54SDsvm+O/DOY+ht9Sn8mEmmc5RmtEQJV4P/J6inzxhZAq61r0j9UW3IvS07BTy/Q ulmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=cf6qmbwI8xSUaHTVi8ZdyUeBJ6vgEvyVYtaqR7tnp2s=; b=m33LWDcKS+DViFBnIMLSKdg1aloiHUyPlhzOy1x1Pbu+pOuHr8XyjSTSbzwIxeA5mR 9a7bCANkXieetrrDib4m3pdlK4Kz0njUK2ZPeZit/1JSVIDvtSaKv97ZyfMqPeKrCzKK p5R7gIehMztGsTuVFMkBPWrNYQQAu1iBFNzRepvr3trNwFp92NGFORS0pSFIeOr3w7mb /Jo1r0gKFcQKkph3XvMTtr065LYXiXBZWqffwo8Rdn+OqQD879KajxD8RU/U+0JMVtOb QrqWUP3dyIUbFq/JzuS2WBQ0WCFSFv8A0ECdFS4pjYai0iqlay78n3oeU+SZI/yGKSLC OtRg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g13si5254222edv.263.2020.08.14.06.42.40; Fri, 14 Aug 2020 06:43:03 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728915AbgHNNiI (ORCPT + 99 others); Fri, 14 Aug 2020 09:38:08 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:43456 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728905AbgHNNiH (ORCPT ); Fri, 14 Aug 2020 09:38:07 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: ezequiel) with ESMTPSA id 643A529A825 From: Ezequiel Garcia To: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Tomasz Figa , kernel@collabora.com, Jonas Karlman , Hans Verkuil , Alexandre Courbot , Jeffrey Kardatzke , Nicolas Dufresne , Philipp Zabel , Maxime Ripard , Paul Kocialkowski , Jernej Skrabec , Ezequiel Garcia Subject: [PATCH v3 18/19] media: hantro: Use H264_SCALING_MATRIX only when required Date: Fri, 14 Aug 2020 10:36:33 -0300 Message-Id: <20200814133634.95665-19-ezequiel@collabora.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200814133634.95665-1-ezequiel@collabora.com> References: <20200814133634.95665-1-ezequiel@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Baseline, Main and Extended profiles are specified to not support a scaling matrix. Also, High profiles can optionally specify a scaling matrix, using SPS and PPS NAL units. To meet this expectation, applications are required to set the V4L2_CID_MPEG_VIDEO_H264_SCALING_MATRIX control and set the V4L2_H264_PPS_FLAG_SCALING_MATRIX_PRESENT flag only when a scaling matrix is specified for a picture. Implement this on hantro, which has hardware support for this case. Signed-off-by: Ezequiel Garcia --- drivers/staging/media/hantro/hantro_g1_h264_dec.c | 5 ++--- drivers/staging/media/hantro/hantro_h264.c | 4 ++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/staging/media/hantro/hantro_g1_h264_dec.c b/drivers/staging/media/hantro/hantro_g1_h264_dec.c index f9839e9c6da5..845bef73d218 100644 --- a/drivers/staging/media/hantro/hantro_g1_h264_dec.c +++ b/drivers/staging/media/hantro/hantro_g1_h264_dec.c @@ -59,9 +59,8 @@ static void set_params(struct hantro_ctx *ctx) reg = G1_REG_DEC_CTRL2_CH_QP_OFFSET(pps->chroma_qp_index_offset) | G1_REG_DEC_CTRL2_CH_QP_OFFSET2(pps->second_chroma_qp_index_offset); - /* always use the matrix sent from userspace */ - reg |= G1_REG_DEC_CTRL2_TYPE1_QUANT_E; - + if (pps->flags & V4L2_H264_PPS_FLAG_SCALING_MATRIX_PRESENT) + reg |= G1_REG_DEC_CTRL2_TYPE1_QUANT_E; if (!(sps->flags & V4L2_H264_SPS_FLAG_FRAME_MBS_ONLY)) reg |= G1_REG_DEC_CTRL2_FIELDPIC_FLAG_E; vdpu_write_relaxed(vpu, reg, G1_REG_DEC_CTRL2); diff --git a/drivers/staging/media/hantro/hantro_h264.c b/drivers/staging/media/hantro/hantro_h264.c index 6887318ed4d8..8af399c8d20e 100644 --- a/drivers/staging/media/hantro/hantro_h264.c +++ b/drivers/staging/media/hantro/hantro_h264.c @@ -197,6 +197,7 @@ assemble_scaling_list(struct hantro_ctx *ctx) { const struct hantro_h264_dec_ctrls *ctrls = &ctx->h264_dec.ctrls; const struct v4l2_ctrl_h264_scaling_matrix *scaling = ctrls->scaling; + const struct v4l2_ctrl_h264_pps *pps = ctrls->pps; const size_t num_list_4x4 = ARRAY_SIZE(scaling->scaling_list_4x4); const size_t list_len_4x4 = ARRAY_SIZE(scaling->scaling_list_4x4[0]); const size_t list_len_8x8 = ARRAY_SIZE(scaling->scaling_list_8x8[0]); @@ -205,6 +206,9 @@ assemble_scaling_list(struct hantro_ctx *ctx) const u32 *src; int i, j; + if (!(pps->flags & V4L2_H264_PPS_FLAG_SCALING_MATRIX_PRESENT)) + return; + for (i = 0; i < num_list_4x4; i++) { src = (u32 *)&scaling->scaling_list_4x4[i]; for (j = 0; j < list_len_4x4 / 4; j++) -- 2.27.0