Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp371575pxa; Fri, 14 Aug 2020 06:42:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxQfykyVvD+bWGrU0doqeSZ/LO2q0mJNTcJxOoQSTj3TnTNuQXdD227RTwGB/1OgcHKqwsd X-Received: by 2002:a17:907:7287:: with SMTP id dt7mr2387302ejc.224.1597412532103; Fri, 14 Aug 2020 06:42:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597412532; cv=none; d=google.com; s=arc-20160816; b=zZ/PAtI7+LktgmSIskh/6p0ohFhpH9MwNZoAItUSTXSFtJTQ+F7ugaL+zZFhVbe07U Yqeau5RwFcRw6wB3gAJkP5WGq9ZReALtAfYdhF3MY4vqDqy22xUIkC5CyT6iRkoir9fE Ns9GcDawLglyWfWxEFjnuMu7iRsbQXXjAsEtXVllb7Vy3u953kLkJ+YmhAKKOYLQ1myT jPZ1Ukwyyts7lgP7J03uafSW9toZmpaBoko30MoDNtYv2/sDub6Um+xTzVKEMRrYV7+C T5Z7Zbpbsie3MH0KPfzSeG2ImMq7c+d7u2R4P5+0gZjEaso1VGx7f/M05p3q1PTRFrzQ cUaw== 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=n2q0SBB8iUR5L/PaGB9Ngy4z0IsdUtaMzhihxJVn1wo=; b=gStYAdBQgd3c2JuzGTEhGeKbJ3o7pA7fg50itQn1e54vJzsXpPFHhOOdgRf6frBQIl R7s8HjSYWlxjo8jLhuXm37P3xB8w6jgRrL8B7kyeSCfPrzrIJC/IC/sim9ExKulAUWK1 8Mvv6IvZmZ0zzGPOey+DN+t0/Bc4MVNX38K23XSjg4tcmke6MxbnIRWcl1A0dO3/PPNg elqO15W6HSh9EpjYaanHl17wZTocQw0S1qLOOumjugUs4PV+ZOwd6ErO8MYaVU7TYkPl slkaLetd2SpRUL/FzktaSmtrTu1EyPd2gPHvYOeB1VtDipN+C4lgvodzxFvrpdocPxWK 7mgA== 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 by29si5455449edb.452.2020.08.14.06.41.48; Fri, 14 Aug 2020 06:42:12 -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 S1728904AbgHNNiF (ORCPT + 99 others); Fri, 14 Aug 2020 09:38:05 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:43438 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728865AbgHNNiC (ORCPT ); Fri, 14 Aug 2020 09:38:02 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: ezequiel) with ESMTPSA id E6F5D29A598 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 17/19] media: rkvdec: Use H264_SCALING_MATRIX only when required Date: Fri, 14 Aug 2020 10:36:32 -0300 Message-Id: <20200814133634.95665-18-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 rkvdec, which has hardware support for this case. Signed-off-by: Ezequiel Garcia --- drivers/staging/media/rkvdec/rkvdec-h264.c | 10 +++++++--- drivers/staging/media/rkvdec/rkvdec.c | 1 - 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/staging/media/rkvdec/rkvdec-h264.c b/drivers/staging/media/rkvdec/rkvdec-h264.c index 584e0d5c493b..9233260e14c1 100644 --- a/drivers/staging/media/rkvdec/rkvdec-h264.c +++ b/drivers/staging/media/rkvdec/rkvdec-h264.c @@ -708,9 +708,9 @@ static void assemble_hw_pps(struct rkvdec_ctx *ctx, WRITE_PPS(pps->second_chroma_qp_index_offset, SECOND_CHROMA_QP_INDEX_OFFSET); - /* always use the matrix sent from userspace */ - WRITE_PPS(1, SCALING_LIST_ENABLE_FLAG); - + WRITE_PPS(!!(pps->flags & V4L2_H264_PPS_FLAG_SCALING_MATRIX_PRESENT), + SCALING_LIST_ENABLE_FLAG); + /* To be on the safe side, program the scaling matrix address */ scaling_distance = offsetof(struct rkvdec_h264_priv_tbl, scaling_list); scaling_list_address = h264_ctx->priv_tbl.dma + scaling_distance; WRITE_PPS(scaling_list_address, SCALING_LIST_ADDRESS); @@ -792,9 +792,13 @@ static void assemble_hw_scaling_list(struct rkvdec_ctx *ctx, struct rkvdec_h264_run *run) { const struct v4l2_ctrl_h264_scaling_matrix *scaling = run->scaling_matrix; + const struct v4l2_ctrl_h264_pps *pps = run->pps; struct rkvdec_h264_ctx *h264_ctx = ctx->priv; struct rkvdec_h264_priv_tbl *tbl = h264_ctx->priv_tbl.cpu; + if (!(pps->flags & V4L2_H264_PPS_FLAG_SCALING_MATRIX_PRESENT)) + return; + BUILD_BUG_ON(sizeof(tbl->scaling_list.scaling_list_4x4) != sizeof(scaling->scaling_list_4x4)); BUILD_BUG_ON(sizeof(tbl->scaling_list.scaling_list_8x8) != diff --git a/drivers/staging/media/rkvdec/rkvdec.c b/drivers/staging/media/rkvdec/rkvdec.c index cd720d726d7f..16d006b554b0 100644 --- a/drivers/staging/media/rkvdec/rkvdec.c +++ b/drivers/staging/media/rkvdec/rkvdec.c @@ -68,7 +68,6 @@ static const struct rkvdec_ctrl_desc rkvdec_h264_ctrl_descs[] = { .cfg.id = V4L2_CID_MPEG_VIDEO_H264_PPS, }, { - .mandatory = true, .cfg.id = V4L2_CID_MPEG_VIDEO_H264_SCALING_MATRIX, }, { -- 2.27.0