linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Alex Bee <knaerzche@gmail.com>
To: Ezequiel Garcia <ezequiel@collabora.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Rob Herring <robh+dt@kernel.org>,
	Heiko Stuebner <heiko@sntech.de>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	Lee Jones <lee.jones@linaro.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org,
	devicetree@vger.kernel.org
Cc: Alex Bee <knaerzche@gmail.com>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH v3 5/6] media: hantro: add support for Rockchip RK3066
Date: Mon, 14 Jun 2021 23:32:14 +0200	[thread overview]
Message-ID: <20210614213215.99389-6-knaerzche@gmail.com> (raw)
In-Reply-To: <20210614213215.99389-1-knaerzche@gmail.com>

RK3066's VPU IP block is the predecessor from what RK3288 has.
The hardware differences are:
  - supports decoding frame sizes up to 1920x1088 only
  - doesn't have the 'G1_REG_SOFT_RESET' register
    (requires another .reset callback for hantro_codec_ops,
     since writing this register will result in non-working
     IP block)
  - has one ACLK/HCLK per vdpu/vepu
  - ACLKs can be clocked up to 300 MHz only
  - no MMU
    (no changes required: CMA will be transparently used)

Add a new RK3066 variant which reflect this differences. This variant
can be used for RK3188 as well.

Signed-off-by: Alex Bee <knaerzche@gmail.com>
Reviewed-by: Ezequiel Garcia <ezequiel@collabora.com>
---

 Changes in v3:
 - rename rk3066_clk_names -> rk3066_vpu_clk_names
 - collect Reviewed-tag

 Changes in v2:
 - fixed wrong index in clk array for vepu clock in rk3066_vpu_hw_init
 - added comment, why this variant can't be splitted in g1/h1 variants

 drivers/staging/media/hantro/hantro_drv.c     |   1 +
 drivers/staging/media/hantro/hantro_hw.h      |   1 +
 .../staging/media/hantro/rockchip_vpu_hw.c    | 121 ++++++++++++++++++
 3 files changed, 123 insertions(+)

diff --git a/drivers/staging/media/hantro/hantro_drv.c b/drivers/staging/media/hantro/hantro_drv.c
index 34e778e1cea1..aaef66c4c795 100644
--- a/drivers/staging/media/hantro/hantro_drv.c
+++ b/drivers/staging/media/hantro/hantro_drv.c
@@ -582,6 +582,7 @@ static const struct v4l2_file_operations hantro_fops = {
 
 static const struct of_device_id of_hantro_match[] = {
 #ifdef CONFIG_VIDEO_HANTRO_ROCKCHIP
+	{ .compatible = "rockchip,rk3066-vpu", .data = &rk3066_vpu_variant, },
 	{ .compatible = "rockchip,rk3288-vpu", .data = &rk3288_vpu_variant, },
 	{ .compatible = "rockchip,rk3328-vpu", .data = &rk3328_vpu_variant, },
 	{ .compatible = "rockchip,rk3399-vpu", .data = &rk3399_vpu_variant, },
diff --git a/drivers/staging/media/hantro/hantro_hw.h b/drivers/staging/media/hantro/hantro_hw.h
index a7b75b05e849..77df0eba4e6f 100644
--- a/drivers/staging/media/hantro/hantro_hw.h
+++ b/drivers/staging/media/hantro/hantro_hw.h
@@ -205,6 +205,7 @@ enum hantro_enc_fmt {
 
 extern const struct hantro_variant imx8mq_vpu_g2_variant;
 extern const struct hantro_variant imx8mq_vpu_variant;
+extern const struct hantro_variant rk3066_vpu_variant;
 extern const struct hantro_variant rk3288_vpu_variant;
 extern const struct hantro_variant rk3328_vpu_variant;
 extern const struct hantro_variant rk3399_vpu_variant;
diff --git a/drivers/staging/media/hantro/rockchip_vpu_hw.c b/drivers/staging/media/hantro/rockchip_vpu_hw.c
index bf760e8e65ce..b370b5e802fa 100644
--- a/drivers/staging/media/hantro/rockchip_vpu_hw.c
+++ b/drivers/staging/media/hantro/rockchip_vpu_hw.c
@@ -10,9 +10,11 @@
 
 #include "hantro.h"
 #include "hantro_jpeg.h"
+#include "hantro_g1_regs.h"
 #include "hantro_h1_regs.h"
 #include "rockchip_vpu2_regs.h"
 
+#define RK3066_ACLK_MAX_FREQ (300 * 1000 * 1000)
 #define RK3288_ACLK_MAX_FREQ (400 * 1000 * 1000)
 
 /*
@@ -63,6 +65,52 @@ static const struct hantro_fmt rockchip_vpu1_postproc_fmts[] = {
 	},
 };
 
+static const struct hantro_fmt rk3066_vpu_dec_fmts[] = {
+	{
+		.fourcc = V4L2_PIX_FMT_NV12,
+		.codec_mode = HANTRO_MODE_NONE,
+	},
+	{
+		.fourcc = V4L2_PIX_FMT_H264_SLICE,
+		.codec_mode = HANTRO_MODE_H264_DEC,
+		.max_depth = 2,
+		.frmsize = {
+			.min_width = 48,
+			.max_width = 1920,
+			.step_width = MB_DIM,
+			.min_height = 48,
+			.max_height = 1088,
+			.step_height = MB_DIM,
+		},
+	},
+	{
+		.fourcc = V4L2_PIX_FMT_MPEG2_SLICE,
+		.codec_mode = HANTRO_MODE_MPEG2_DEC,
+		.max_depth = 2,
+		.frmsize = {
+			.min_width = 48,
+			.max_width = 1920,
+			.step_width = MB_DIM,
+			.min_height = 48,
+			.max_height = 1088,
+			.step_height = MB_DIM,
+		},
+	},
+	{
+		.fourcc = V4L2_PIX_FMT_VP8_FRAME,
+		.codec_mode = HANTRO_MODE_VP8_DEC,
+		.max_depth = 2,
+		.frmsize = {
+			.min_width = 48,
+			.max_width = 1920,
+			.step_width = MB_DIM,
+			.min_height = 48,
+			.max_height = 1088,
+			.step_height = MB_DIM,
+		},
+	},
+};
+
 static const struct hantro_fmt rk3288_vpu_dec_fmts[] = {
 	{
 		.fourcc = V4L2_PIX_FMT_NV12,
@@ -196,6 +244,14 @@ static irqreturn_t rockchip_vpu2_vepu_irq(int irq, void *dev_id)
 	return IRQ_HANDLED;
 }
 
+static int rk3066_vpu_hw_init(struct hantro_dev *vpu)
+{
+	/* Bump ACLKs to max. possible freq. to improve performance. */
+	clk_set_rate(vpu->clocks[0].clk, RK3066_ACLK_MAX_FREQ);
+	clk_set_rate(vpu->clocks[2].clk, RK3066_ACLK_MAX_FREQ);
+	return 0;
+}
+
 static int rockchip_vpu_hw_init(struct hantro_dev *vpu)
 {
 	/* Bump ACLK to max. possible freq. to improve performance. */
@@ -203,6 +259,14 @@ static int rockchip_vpu_hw_init(struct hantro_dev *vpu)
 	return 0;
 }
 
+static void rk3066_vpu_dec_reset(struct hantro_ctx *ctx)
+{
+	struct hantro_dev *vpu = ctx->dev;
+
+	vdpu_write(vpu, G1_REG_INTERRUPT_DEC_IRQ_DIS, G1_REG_INTERRUPT);
+	vdpu_write(vpu, G1_REG_CONFIG_DEC_CLK_GATE_E, G1_REG_CONFIG);
+}
+
 static void rockchip_vpu1_enc_reset(struct hantro_ctx *ctx)
 {
 	struct hantro_dev *vpu = ctx->dev;
@@ -233,6 +297,33 @@ static void rockchip_vpu2_enc_reset(struct hantro_ctx *ctx)
 /*
  * Supported codec ops.
  */
+static const struct hantro_codec_ops rk3066_vpu_codec_ops[] = {
+	[HANTRO_MODE_JPEG_ENC] = {
+		.run = hantro_h1_jpeg_enc_run,
+		.reset = rockchip_vpu1_enc_reset,
+		.init = hantro_jpeg_enc_init,
+		.done = hantro_jpeg_enc_done,
+		.exit = hantro_jpeg_enc_exit,
+	},
+	[HANTRO_MODE_H264_DEC] = {
+		.run = hantro_g1_h264_dec_run,
+		.reset = rk3066_vpu_dec_reset,
+		.init = hantro_h264_dec_init,
+		.exit = hantro_h264_dec_exit,
+	},
+	[HANTRO_MODE_MPEG2_DEC] = {
+		.run = hantro_g1_mpeg2_dec_run,
+		.reset = rk3066_vpu_dec_reset,
+		.init = hantro_mpeg2_dec_init,
+		.exit = hantro_mpeg2_dec_exit,
+	},
+	[HANTRO_MODE_VP8_DEC] = {
+		.run = hantro_g1_vp8_dec_run,
+		.reset = rk3066_vpu_dec_reset,
+		.init = hantro_vp8_dec_init,
+		.exit = hantro_vp8_dec_exit,
+	},
+};
 
 static const struct hantro_codec_ops rk3288_vpu_codec_ops[] = {
 	[HANTRO_MODE_JPEG_ENC] = {
@@ -301,10 +392,40 @@ static const struct hantro_irq rockchip_vpu2_irqs[] = {
 	{ "vdpu", rockchip_vpu2_vdpu_irq },
 };
 
+static const char * const rk3066_vpu_clk_names[] = {
+	"aclk_vdpu", "hclk_vdpu",
+	"aclk_vepu", "hclk_vepu"
+};
+
 static const char * const rockchip_vpu_clk_names[] = {
 	"aclk", "hclk"
 };
 
+/*
+ * Despite this variant has separate clocks for decoder and encoder,
+ * it's still required to enable all four of them for either decoding
+ * or encoding and we can't split it in separate g1/h1 variants.
+ */
+const struct hantro_variant rk3066_vpu_variant = {
+	.enc_offset = 0x0,
+	.enc_fmts = rockchip_vpu_enc_fmts,
+	.num_enc_fmts = ARRAY_SIZE(rockchip_vpu_enc_fmts),
+	.dec_offset = 0x400,
+	.dec_fmts = rk3066_vpu_dec_fmts,
+	.num_dec_fmts = ARRAY_SIZE(rk3066_vpu_dec_fmts),
+	.postproc_fmts = rockchip_vpu1_postproc_fmts,
+	.num_postproc_fmts = ARRAY_SIZE(rockchip_vpu1_postproc_fmts),
+	.postproc_regs = &hantro_g1_postproc_regs,
+	.codec = HANTRO_JPEG_ENCODER | HANTRO_MPEG2_DECODER |
+		 HANTRO_VP8_DECODER | HANTRO_H264_DECODER,
+	.codec_ops = rk3066_vpu_codec_ops,
+	.irqs = rockchip_vpu1_irqs,
+	.num_irqs = ARRAY_SIZE(rockchip_vpu1_irqs),
+	.init = rk3066_vpu_hw_init,
+	.clk_names = rk3066_vpu_clk_names,
+	.num_clocks = ARRAY_SIZE(rk3066_vpu_clk_names)
+};
+
 const struct hantro_variant rk3288_vpu_variant = {
 	.enc_offset = 0x0,
 	.enc_fmts = rockchip_vpu_enc_fmts,
-- 
2.27.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2021-06-14 21:36 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-25 15:22 [PATCH 00/10] Add support for older Rockchip SoCs to V4L2 hantro and rkvdec drivers Alex Bee
2021-05-25 15:22 ` [PATCH 01/10] ARM: dts: rockchip: add power controller for RK322x Alex Bee
2021-05-25 15:22 ` [PATCH 02/10] ARM: dts: rockchip: add power controller for RK3036 Alex Bee
2021-05-25 15:22 ` [PATCH 03/10] dt-bindings: mfd: syscon: add Rockchip RK3036/RK3228 qos compatibles Alex Bee
2021-05-25 15:26   ` Heiko Stübner
2021-05-25 15:22 ` [PATCH 04/10] media: hantro: add support for Rockchip RK3066 Alex Bee
2021-05-25 22:49   ` Heiko Stübner
2021-05-26 10:32   ` Ezequiel Garcia
2021-05-26 23:22     ` Alex Bee
2021-05-27  1:38       ` Ezequiel Garcia
2021-05-25 15:22 ` [PATCH 05/10] media: hantro: add support for Rockchip RK3036 Alex Bee
2021-05-26 10:28   ` Ezequiel Garcia
2021-05-26 23:27     ` Alex Bee
2021-05-26 23:58       ` Heiko Stübner
2021-05-27  1:27         ` Ezequiel Garcia
2021-05-27 20:11           ` Alex Bee
2021-05-25 15:22 ` [PATCH 06/10] ARM: dts: rockchip: add vpu nodes for RK3066 and RK3188 Alex Bee
2021-05-25 15:22 ` [PATCH 07/10] ARM: dts: rockchip: add vpu node for RK322x Alex Bee
2021-05-25 23:05   ` Heiko Stübner
2021-05-25 15:22 ` [PATCH 08/10] media: dt-bindings: media: rockchip-vpu: add new compatibles Alex Bee
2021-05-26 12:56   ` Rob Herring
2021-05-25 15:22 ` [PATCH 09/10] ARM: dts: rockchip: add vdec node for RK322x Alex Bee
2021-05-25 15:22 ` [PATCH 10/10] media: dt-bindings: media: rockchip-vdec: add RK3228 compatible Alex Bee
2021-05-26 12:56   ` Rob Herring
2021-05-25 23:01 ` [PATCH 00/10] Add support for older Rockchip SoCs to V4L2 hantro and rkvdec drivers Heiko Stübner
2021-05-26 23:38   ` Alex Bee
2021-05-27 15:44 ` [PATCH v2 00/12] " Alex Bee
2021-05-27 15:44   ` [PATCH v2 01/12] dt-bindings: mfd: syscon: add Rockchip RK3036/RK3228 qos compatibles Alex Bee
2021-06-01 15:46     ` Lee Jones
2021-07-11 11:55       ` Heiko Stübner
2021-07-15 10:09         ` Alex Bee
2021-07-15 11:07           ` Lee Jones
2021-06-04 20:24     ` Rob Herring
2021-05-27 15:44   ` [PATCH v2 02/12] dt-bindings: media: rockchip-vpu: add new compatibles Alex Bee
2021-06-04 20:44     ` Rob Herring
2021-05-27 15:44   ` [PATCH v2 03/12] dt-bindings: media: rockchip-vdec: add RK3228 compatible Alex Bee
2021-06-04 20:45     ` Rob Herring
2021-05-27 15:44   ` [PATCH v2 04/12] media: hantro: reorder variants Alex Bee
2021-06-11 15:26     ` Ezequiel Garcia
2021-05-27 15:44   ` [PATCH v2 05/12] media: hantro: merge Rockchip platform drivers Alex Bee
2021-06-11 15:36     ` Ezequiel Garcia
2021-06-14 17:02       ` Alex Bee
2021-05-27 15:44   ` [PATCH v2 06/12] media: hantro: add support for Rockchip RK3066 Alex Bee
2021-06-11 15:50     ` Ezequiel Garcia
2021-06-14 16:46       ` Alex Bee
2021-05-27 15:44   ` [PATCH v2 07/12] media: hantro: add support for Rockchip RK3036 Alex Bee
2021-06-11 16:02     ` Ezequiel Garcia
2021-05-27 15:44   ` [PATCH v2 08/12] ARM: dts: rockchip: add power controller for RK3036 Alex Bee
2021-06-11 15:58     ` Ezequiel Garcia
2021-06-13 16:22       ` Heiko Stuebner
2021-06-21 11:58         ` Alex Bee
2021-05-27 15:44   ` [PATCH v2 09/12] ARM: dts: rockchip: add power controller for RK322x Alex Bee
2021-05-27 15:44   ` [PATCH v2 10/12] ARM: dts: rockchip: add vpu node for RK3036 Alex Bee
2021-05-27 15:44   ` [PATCH v2 11/12] ARM: dts: rockchip: add vpu nodes for RK3066 and RK3188 Alex Bee
2021-05-27 15:44   ` [PATCH v2 12/12] ARM: dts: rockchip: add vpu and vdec node for RK322x Alex Bee
2021-06-13 16:27   ` (subset) [PATCH v2 00/12] Add support for older Rockchip SoCs to V4L2 hantro and rkvdec drivers Heiko Stuebner
2021-06-14 11:09   ` Hans Verkuil
2021-06-14 11:13     ` Hans Verkuil
2021-06-21 23:04   ` (subset) " Heiko Stuebner
2021-06-14 21:32 ` [PATCH v3 0/6] " Alex Bee
2021-06-14 21:32   ` [PATCH v3 1/6] dt-bindings: media: rockchip-vpu: add new compatibles Alex Bee
2021-06-14 21:32   ` [PATCH v3 2/6] dt-bindings: media: rockchip-vdec: add RK3228 compatible Alex Bee
2021-06-14 21:32   ` [PATCH v3 3/6] media: hantro: reorder variants Alex Bee
2021-06-14 21:32   ` [PATCH v3 4/6] media: hantro: merge Rockchip platform drivers Alex Bee
2021-06-14 21:32   ` Alex Bee [this message]
2021-06-14 21:32   ` [PATCH v3 6/6] media: hantro: add support for Rockchip RK3036 Alex Bee

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210614213215.99389-6-knaerzche@gmail.com \
    --to=knaerzche@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=ezequiel@collabora.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=heiko@sntech.de \
    --cc=lee.jones@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=mchehab@kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).