Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp7504720pxb; Thu, 18 Feb 2021 11:50:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJwfN4UjQDK5Hri2zGen5uI7suzHDFkbfNxYWtgz76ZBn/k5D7dNWM8cczC4hYhiVsU+Atxo X-Received: by 2002:a05:6402:2030:: with SMTP id ay16mr5636019edb.156.1613677854154; Thu, 18 Feb 2021 11:50:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613677854; cv=none; d=google.com; s=arc-20160816; b=Uwn/0vGYJ76dSH5qwvtdaz0TSrEsRYTjWYsLD0cVlZdMdZqJ9dxyqiT8mty3N+gbfO gcJZkTM0AQBDC4hmKJfebN0F6YKZDfd4LbT+Q2JZwQ5PB7rA5M/wemA7Mofk4ucAk2/o je0G8STNd/FCJ7M511xuh1WtCGMTJnRZ8itJkBi38eXzmyHwNsoWQe9X0WqxElyXkS7c oVHV4UadSAksC4AAzf9/L+VF7sUNuo+kB5Cn4WllhlC3saOJwWNi96tvRORoztxBPggA UzeHkdGcHOvuYFNwWwbPAC1GwyMbbVLb0WdAkMDFnbzLjaGW+afplUTbRNYVXVttCdgq dxnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=/reZKQMav8jMaLIJnuCgeaW6mnoyNKJYXae3xpFvhfc=; b=wsezR4er6bkWaBM+siYQVxHVVQU6NyL9Z3NcCcAzgC3E4xCWkwmPPEly+KS/A74vAe 36/bv4/5PGPePb4GW0vJThebwStwhALjIrfnx3WF18Y8HCPyG96NiBFNrPlCouHTBmii sgkde/X73d3cYbEtYzA+6+u0Aqbzs9iQ3f6v+iValpEqgtNFRWigjgjt+9pRqiKXh6Z2 fRAy6xUjl8XLRpaaGD8GdqVYDH0mnx767iZMNtTg/+O8J1KdJDEoO6f7+Z9SikOsD22c Br7U7QYjgbe44LvHjRsSMBqhWnTHRUsbx5DBkrYzRhti8erDExZNaITnEn9AvLMYnRz8 tIWw== 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 c24si4120519edv.48.2021.02.18.11.50.30; Thu, 18 Feb 2021 11:50:54 -0800 (PST) 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 S231320AbhBRTtp (ORCPT + 99 others); Thu, 18 Feb 2021 14:49:45 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:42492 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234073AbhBRTTs (ORCPT ); Thu, 18 Feb 2021 14:19:48 -0500 Received: from localhost.localdomain (unknown [IPv6:2a01:e0a:4cb:a870:851a:1dfb:a143:80e]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: benjamin.gaignard) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id B50871F445E2; Thu, 18 Feb 2021 19:19:01 +0000 (GMT) From: Benjamin Gaignard To: ezequiel@collabora.com, p.zabel@pengutronix.de, mchehab@kernel.org, robh+dt@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, gregkh@linuxfoundation.org, mripard@kernel.org, paul.kocialkowski@bootlin.com, wens@csie.org, jernej.skrabec@siol.net, peng.fan@nxp.com, hverkuil-cisco@xs4all.nl, dan.carpenter@oracle.com Cc: linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@collabora.com, Benjamin Gaignard Subject: [PATCH v2 3/9] media: hantro: Add a field to distinguish the hardware versions Date: Thu, 18 Feb 2021 20:18:38 +0100 Message-Id: <20210218191844.297869-4-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210218191844.297869-1-benjamin.gaignard@collabora.com> References: <20210218191844.297869-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Decoders hardware blocks could exist in multiple versions: add a field to distinguish them at runtime. G2 hardware block doesn't have postprocessor hantro_needs_postproc function should always returns false in for this hardware. hantro_needs_postproc function becoming to much complex to stay inline in .h file move it to .c file. Keep the default behavoir to be G1 hardware. Signed-off-by: Benjamin Gaignard --- version 2: - squash this commit with the post processor change to show one usage of core_hw_dec_rev drivers/staging/media/hantro/hantro.h | 13 +++++++------ drivers/staging/media/hantro/hantro_drv.c | 2 ++ drivers/staging/media/hantro/hantro_postproc.c | 17 +++++++++++++++++ 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/drivers/staging/media/hantro/hantro.h b/drivers/staging/media/hantro/hantro.h index bde65231f22f..352930bd49fc 100644 --- a/drivers/staging/media/hantro/hantro.h +++ b/drivers/staging/media/hantro/hantro.h @@ -36,6 +36,9 @@ struct hantro_codec_ops; #define HANTRO_H264_DECODER BIT(18) #define HANTRO_DECODERS 0xffff0000 +#define HANTRO_G1_REV 0x6731 +#define HANTRO_G2_REV 0x6732 + /** * struct hantro_irq - irq handler and name * @@ -170,6 +173,7 @@ hantro_vdev_to_func(struct video_device *vdev) * @enc_base: Mapped address of VPU encoder register for convenience. * @dec_base: Mapped address of VPU decoder register for convenience. * @ctrl_base: Mapped address of VPU control block. + * @core_hw_dec_rev Runtime detected HW decoder core revision * @vpu_mutex: Mutex to synchronize V4L2 calls. * @irqlock: Spinlock to synchronize access to data structures * shared with interrupt handlers. @@ -189,6 +193,7 @@ struct hantro_dev { void __iomem *enc_base; void __iomem *dec_base; void __iomem *ctrl_base; + u32 core_hw_dec_rev; struct mutex vpu_mutex; /* video_device lock */ spinlock_t irqlock; @@ -411,12 +416,8 @@ hantro_get_dst_buf(struct hantro_ctx *ctx) return v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx); } -static inline bool -hantro_needs_postproc(const struct hantro_ctx *ctx, - const struct hantro_fmt *fmt) -{ - return !ctx->is_encoder && fmt->fourcc != V4L2_PIX_FMT_NV12; -} +bool hantro_needs_postproc(const struct hantro_ctx *ctx, + const struct hantro_fmt *fmt); static inline dma_addr_t hantro_get_dec_buf_addr(struct hantro_ctx *ctx, struct vb2_buffer *vb) diff --git a/drivers/staging/media/hantro/hantro_drv.c b/drivers/staging/media/hantro/hantro_drv.c index d86e322a5980..0a62beb0bfbd 100644 --- a/drivers/staging/media/hantro/hantro_drv.c +++ b/drivers/staging/media/hantro/hantro_drv.c @@ -834,6 +834,8 @@ static int hantro_probe(struct platform_device *pdev) } vpu->enc_base = vpu->reg_bases[0] + vpu->variant->enc_offset; vpu->dec_base = vpu->reg_bases[0] + vpu->variant->dec_offset; + /* by default decoder is G1 */ + vpu->core_hw_dec_rev = HANTRO_G1_REV; ret = dma_set_coherent_mask(vpu->dev, DMA_BIT_MASK(32)); if (ret) { diff --git a/drivers/staging/media/hantro/hantro_postproc.c b/drivers/staging/media/hantro/hantro_postproc.c index 6d2a8f2a8f0b..050880f720d6 100644 --- a/drivers/staging/media/hantro/hantro_postproc.c +++ b/drivers/staging/media/hantro/hantro_postproc.c @@ -50,6 +50,23 @@ const struct hantro_postproc_regs hantro_g1_postproc_regs = { .display_width = {G1_REG_PP_DISPLAY_WIDTH, 0, 0xfff}, }; +bool hantro_needs_postproc(const struct hantro_ctx *ctx, + const struct hantro_fmt *fmt) +{ + struct hantro_dev *vpu = ctx->dev; + + if (ctx->is_encoder) + return false; + + if (vpu->core_hw_dec_rev == HANTRO_G1_REV) + return fmt->fourcc != V4L2_PIX_FMT_NV12; + + if (vpu->core_hw_dec_rev == HANTRO_G2_REV) + return false; + + return false; +} + void hantro_postproc_enable(struct hantro_ctx *ctx) { struct hantro_dev *vpu = ctx->dev; -- 2.25.1