Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp371616pxa; Fri, 14 Aug 2020 06:42:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3RBZSKdUFO+XYbCtmxC4C+kjVJZNTt7c6BJOQGrvS5QddjOJ8xdaGKV3ScdzF0wH0WTML X-Received: by 2002:a17:906:9618:: with SMTP id s24mr2435250ejx.53.1597412534342; Fri, 14 Aug 2020 06:42:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597412534; cv=none; d=google.com; s=arc-20160816; b=IAXFeOke7+P1/WcA0qtlNArbFzkRH93/P73gpbEpg8cOEkx2xwhtw8g98AKXDM3Lon T5wnW5E62SrE1QRT5JUIDhIFm/wRUM9z/TFd84pPw/lummDrTXfG/d4hH/Cl6yvcmH2w 6aGfYrmb1aG5IpifJbf8SjD7xVD5zM1HgsPjicQEH+t/vPFMiVgu4R0I13zWyigHq89k 6IzDF5Kh3GuWcaEWjLh3jPYCzxoPFMVydhxKN3tec51vbexzqinGBBosT8MAa+w6hCX8 Fhj1Y03ZM9HfFQMKQGrW/9P4T6tSYbKUTMtgeSNPpAOC8ST55/OmZut/yOpPFW6ySyUA /Q0g== 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=zDIAv4fHiR0o5HYuGXOMFEwOumZ8kG8/d/HaJ0qlJOE=; b=bBv7vbHvGTK7ur4TEG5zYBNr6AKqp9P30ftJVrj0uGvx/24bcdtqiMDtwfQrnA9CO6 3P1NBdrMUjS6+xLO+ywvDmiHy/3aeyxob7Gy2stoomzQU415ApYqrBwPKruXVufT1i2U nKP6AlxFRSCaroYj/KyowfSYAL0gzQA3U3LfkVcwTPRLPc0cVq1asKLxy1bANtdME+/5 jdRRTio+obXKMtqWkY80tO/Y7WLSVawgBjdqdQdgaKBL87saBdUTCrUfYSUBp09+uTDq iKff9fi7W3NepV4XmJ+K1JqOa9zuJVELbhpDzb1GK/y6AT7DtV22pu8Xqisjvhf85Qam 0wSw== 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 a6si5213025edr.403.2020.08.14.06.41.51; Fri, 14 Aug 2020 06:42:14 -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 S1728925AbgHNNiN (ORCPT + 99 others); Fri, 14 Aug 2020 09:38:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728252AbgHNNiL (ORCPT ); Fri, 14 Aug 2020 09:38:11 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E10A6C061384; Fri, 14 Aug 2020 06:38:10 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: ezequiel) with ESMTPSA id E680329A829 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 19/19] media: cedrus: Use H264_SCALING_MATRIX only when required Date: Fri, 14 Aug 2020 10:36:34 -0300 Message-Id: <20200814133634.95665-20-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 cedrus, which has hardware support for this case. Signed-off-by: Ezequiel Garcia --- drivers/staging/media/sunxi/cedrus/cedrus.c | 2 +- drivers/staging/media/sunxi/cedrus/cedrus_h264.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.c b/drivers/staging/media/sunxi/cedrus/cedrus.c index 826324faad7e..6ebb39e0c0ce 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus.c @@ -76,7 +76,7 @@ static const struct cedrus_control cedrus_controls[] = { .id = V4L2_CID_MPEG_VIDEO_H264_SCALING_MATRIX, }, .codec = CEDRUS_CODEC_H264, - .required = true, + .required = false, }, { .cfg = { diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_h264.c b/drivers/staging/media/sunxi/cedrus/cedrus_h264.c index fe041b444385..28319351e909 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_h264.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_h264.c @@ -238,8 +238,12 @@ static void cedrus_write_scaling_lists(struct cedrus_ctx *ctx, { const struct v4l2_ctrl_h264_scaling_matrix *scaling = run->h264.scaling_matrix; + const struct v4l2_ctrl_h264_pps *pps = run->h264.pps; struct cedrus_dev *dev = ctx->dev; + if (!(pps->flags & V4L2_H264_PPS_FLAG_SCALING_MATRIX_PRESENT)) + return; + cedrus_h264_write_sram(dev, CEDRUS_SRAM_H264_SCALING_LIST_8x8_0, scaling->scaling_list_8x8[0], sizeof(scaling->scaling_list_8x8[0])); @@ -442,6 +446,8 @@ static void cedrus_set_params(struct cedrus_ctx *ctx, reg |= (pps->second_chroma_qp_index_offset & 0x3f) << 16; reg |= (pps->chroma_qp_index_offset & 0x3f) << 8; reg |= (pps->pic_init_qp_minus26 + 26 + slice->slice_qp_delta) & 0x3f; + if (pps->flags & V4L2_H264_PPS_FLAG_SCALING_MATRIX_PRESENT) + reg |= VE_H264_SHS_QP_SCALING_MATRIX_DEFAULT; cedrus_write(dev, VE_H264_SHS_QP, reg); // clear status flags -- 2.27.0