From patchwork Sat Dec 16 13:09:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jernej_=C5=A0krabec?= X-Patchwork-Id: 13495564 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 50CE9C46CCD for ; Sat, 16 Dec 2023 13:10:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=4mEmx4LijWiI0r+CHdiLqm52d5jsSvMlkatId0CSg7A=; b=Pqo5St8Hm2WDtH ca/NFXFfx/7y9v245bM29u9+KN01G35fz3bIKpqFEpoXKkB4rO0Ow6gX1taZbvW6RcNno91DCz8tT M2g3migDEwdjfY5nY/nUmYBxLANdt4CLJUes6td6kTzUtGs+nWGI0E8GuArl8939Z6UqKHRAeGjBe EAFURModGvMyIgh1C8kl6C8rZY7GMZ4q58JR8zzmMWp0xrFiex/TW9iLPUNApvfBIxzxV8+/ukJ5e pcyp1KXa7ys45O6IqarMIRUrWNbiGC10ArgZu8u7QBNCYGFhHIz1qYGhSuDWF0VdacMpxuCIFbdQf wV6V147j3ohTcNyVib/Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rEUQC-0065SI-1M; Sat, 16 Dec 2023 13:09:36 +0000 Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rEUQ9-0065RX-0o for linux-arm-kernel@lists.infradead.org; Sat, 16 Dec 2023 13:09:34 +0000 Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-552e4a68de0so1821166a12.0 for ; Sat, 16 Dec 2023 05:09:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702732170; x=1703336970; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=n89IuR5gUSQ4BVQ0By1D6c8QjvjYZ+sxQ5eQOMT0DAg=; b=cC4UFsdzO6Bhb+lLPmbGZkLQTA368AykNGdTkqojBgsq99NDrjw9ihuZU5S09KKukK Zm/Y6idmR6UauNmK9HiOILkHlXRyc+d2ZEHF/WY0kGBYUV5AfKL2KQgiRLIRyizfqtPR tFK1A33Am0nNyRufZLv3gOEDd4OUxole+157IyixYjlsRLG6ywK7fZdcsIoRYErC462D 6ipZF51jiFud+l7q0+BPQbvFPGzGVPmwpEWqndKsN1ewgf0mGrvRQo+yiIM3XeNzpGNG ZcCj6eFsKrt4RLTC4v4HH9MTeNQY0Ba4ypzJuhaJmHSSvMv9JrAqaqBQwxrSBGgYbn7R qUDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702732170; x=1703336970; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=n89IuR5gUSQ4BVQ0By1D6c8QjvjYZ+sxQ5eQOMT0DAg=; b=HRux7/Alt5MdZw/+zwmf/iYxROIQoVvSzv8vneKIF/KmEfnK/PeXEy4GMGmxkYENaV 9kX+Kf53AIjzAXKJDlBqfGUJo7hiNFw/hl5XvyYsAwGuZ/FzskV1utm6m7RneCIPiMCb KQTuNOITsVJzZBMHNwuXsS1o80P70LCR6OFctWTSrR9w4DVHAWc5KPrBqlDMHX7pg/Pb 0qpqK3/+u2nro9rjbU0qhmugrgSSyorGwCOL+SbQ1vgPD6TU0Yaewg4vZYfjzVYxPSyx D57z8twy9ZWbOMGfrOZmIAwbe4EBns5LXGCy0vq2QmyXV9UgA5+QfyVtHsbI3HQfXfLk MBjA== X-Gm-Message-State: AOJu0YzGGnwXMsHaeVeJjgUjmdp1aZMnSNyB0pNOKHwN9Tiy0sLmmYQJ BdvMgu+VTQiVZ3+xsH/4564= X-Google-Smtp-Source: AGHT+IHkWr7Mj3eKXJJud+PAc5UQeJZpEKzpZ43hzhunTp0Fynlbb806wfnWNJcKola3DEFkl9bo+g== X-Received: by 2002:a50:baea:0:b0:54c:bb9c:4b88 with SMTP id x97-20020a50baea000000b0054cbb9c4b88mr13586805ede.5.1702732170257; Sat, 16 Dec 2023 05:09:30 -0800 (PST) Received: from localhost.localdomain (82-149-12-148.dynamic.telemach.net. [82.149.12.148]) by smtp.gmail.com with ESMTPSA id ew12-20020a056402538c00b00552691fc7f9sm2628963edb.66.2023.12.16.05.09.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Dec 2023 05:09:29 -0800 (PST) From: Jernej Skrabec To: mripard@kernel.org, paul.kocialkowski@bootlin.com Cc: mchehab@kernel.org, gregkh@linuxfoundation.org, wens@csie.org, samuel@sholland.org, hverkuil-cisco@xs4all.nl, linux-media@vger.kernel.org, linux-staging@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Jernej Skrabec Subject: [PATCH] media: cedrus: h265: Fix configuring bitstream size Date: Sat, 16 Dec 2023 14:09:25 +0100 Message-ID: <20231216130925.2533395-1-jernej.skrabec@gmail.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231216_050933_334336_E3823D86 X-CRM114-Status: GOOD ( 11.52 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org bit_size field holds size of slice, not slice + header. Because of HW quirks, driver can't program in just slice, but also preceding header. But that means that currently used bit_size is wrong (too small). Instead, just use size of whole buffer. There is no harm in doing this. Fixes: 86caab29da78 ("media: cedrus: Add HEVC/H.265 decoding support") Suggested-by: Paul Kocialkowski Signed-off-by: Jernej Skrabec --- drivers/staging/media/sunxi/cedrus/cedrus_h265.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_h265.c b/drivers/staging/media/sunxi/cedrus/cedrus_h265.c index fc9297232456..16c822637dc6 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_h265.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_h265.c @@ -427,11 +427,11 @@ static int cedrus_h265_setup(struct cedrus_ctx *ctx, struct cedrus_run *run) unsigned int ctb_addr_x, ctb_addr_y; struct cedrus_buffer *cedrus_buf; dma_addr_t src_buf_addr; - dma_addr_t src_buf_end_addr; u32 chroma_log2_weight_denom; u32 num_entry_point_offsets; u32 output_pic_list_index; u32 pic_order_cnt[2]; + size_t slice_bytes; u8 padding; int count; u32 reg; @@ -443,6 +443,7 @@ static int cedrus_h265_setup(struct cedrus_ctx *ctx, struct cedrus_run *run) pred_weight_table = &slice_params->pred_weight_table; num_entry_point_offsets = slice_params->num_entry_point_offsets; cedrus_buf = vb2_to_cedrus_buffer(&run->dst->vb2_buf); + slice_bytes = vb2_get_plane_payload(&run->src->vb2_buf, 0); /* * If entry points offsets are present, we should get them @@ -490,7 +491,7 @@ static int cedrus_h265_setup(struct cedrus_ctx *ctx, struct cedrus_run *run) cedrus_write(dev, VE_DEC_H265_BITS_OFFSET, 0); - reg = slice_params->bit_size; + reg = slice_bytes * 8; cedrus_write(dev, VE_DEC_H265_BITS_LEN, reg); /* Source beginning and end addresses. */ @@ -504,10 +505,7 @@ static int cedrus_h265_setup(struct cedrus_ctx *ctx, struct cedrus_run *run) cedrus_write(dev, VE_DEC_H265_BITS_ADDR, reg); - src_buf_end_addr = src_buf_addr + - DIV_ROUND_UP(slice_params->bit_size, 8); - - reg = VE_DEC_H265_BITS_END_ADDR_BASE(src_buf_end_addr); + reg = VE_DEC_H265_BITS_END_ADDR_BASE(src_buf_addr + slice_bytes); cedrus_write(dev, VE_DEC_H265_BITS_END_ADDR, reg); /* Coding tree block address */