Skip to content

Commit d1b5e41

Browse files
committed
drm/meson: Add AFBCD module driver
This adds the driver for the ARM Framebuffer Compression decoders found in the Amlogic GXM and G12A SoCs. The Amlogic GXM and G12A AFBC decoder are totally different, the GXM only handling only the AFBC v1.0 modes and the G12A decoder handling the AFBC v1.2 modes. The G12A AFBC decoder is an external IP integrated in the video pipeline, and the GXM AFBC decoder seems to the an Amlogic custom decoder more tighly integrated in the video pipeline. The GXM AFBC decoder can handle only one AFBC plane for 2 available OSD planes available in HW, and the G12A AFBC decoder can handle up to 4 AFBC planes for up to 3 OSD planes available in HW. The Amlogic GXM supports 16x16 SPARSE and 16x16 SPLIT AFBC buffers up to 4k. On the other side, for G12A SPLIT is mandatory in 16x16 block mode, but for 4k modes 32x8+SPLIT AFBC buffers is manadatory for performances reasons. The RDMA is used here to reset and program the AFBC decoder unit on each vsync without involving the interrupt handler that can be masked for a long period of time, producing display glitches. For this we use the meson_rdma_writel_sync() which adds the register write tuple (VPU register offset and register value) to the RDMA buffer and write the value to the HW. When enabled, the RDMA is enabled to rewrite the same sequence at the next VSYNC event, until a new buffer is committed to the OSD plane. Then the Amlogic G12A is switched to RDMA, the Amlogic GXM Decoder doesn't need a reset/reprogram at each vsync, but needs to keep the vsync interrupt enabled to trigger the RDMA module. Signed-off-by: Neil Armstrong <narmstrong@baylibre.com> Reviewed-by: Kevin Hilman <khilman@baylibre.com> [narmstrong: fixed typo in commit log] Link: https://patchwork.freedesktop.org/patch/msgid/20191021091509.3864-6-narmstrong@baylibre.com
1 parent 63fba24 commit d1b5e41

5 files changed

Lines changed: 473 additions & 8 deletions

File tree

‎drivers/gpu/drm/meson/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-License-Identifier: GPL-2.0-only
22
meson-drm-y := meson_drv.o meson_plane.o meson_crtc.o meson_venc_cvbs.o
33
meson-drm-y += meson_viu.o meson_vpp.o meson_venc.o meson_vclk.o meson_overlay.o
4-
meson-drm-y += meson_rdma.o
4+
meson-drm-y += meson_rdma.o meson_osd_afbcd.o
55

66
obj-$(CONFIG_DRM_MESON) += meson-drm.o
77
obj-$(CONFIG_DRM_MESON_DW_HDMI) += meson_dw_hdmi.o

‎drivers/gpu/drm/meson/meson_drv.c‎

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@
2828
#include "meson_drv.h"
2929
#include "meson_overlay.h"
3030
#include "meson_plane.h"
31+
#include "meson_osd_afbcd.h"
3132
#include "meson_registers.h"
3233
#include "meson_venc_cvbs.h"
3334
#include "meson_viu.h"
3435
#include "meson_vpp.h"
36+
#include "meson_rdma.h"
3537

3638
#define DRIVER_NAME "meson"
3739
#define DRIVER_DESC "Amlogic Meson DRM driver"
@@ -184,6 +186,7 @@ static void meson_remove_framebuffers(void)
184186
static int meson_drv_bind_master(struct device *dev, bool has_components)
185187
{
186188
struct platform_device *pdev = to_platform_device(dev);
189+
const struct meson_drm_match_data *match;
187190
struct meson_drm *priv;
188191
struct drm_device *drm;
189192
struct resource *res;
@@ -196,6 +199,10 @@ static int meson_drv_bind_master(struct device *dev, bool has_components)
196199
return -ENODEV;
197200
}
198201

202+
match = of_device_get_match_data(dev);
203+
if (!match)
204+
return -ENODEV;
205+
199206
drm = drm_dev_alloc(&meson_driver, dev);
200207
if (IS_ERR(drm))
201208
return PTR_ERR(drm);
@@ -208,8 +215,8 @@ static int meson_drv_bind_master(struct device *dev, bool has_components)
208215
drm->dev_private = priv;
209216
priv->drm = drm;
210217
priv->dev = dev;
211-
212-
priv->compat = (enum vpu_compatible)of_device_get_match_data(priv->dev);
218+
priv->compat = match->compat;
219+
priv->afbcd.ops = match->afbcd_ops;
213220

214221
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "vpu");
215222
regs = devm_ioremap_resource(dev, res);
@@ -289,6 +296,11 @@ static int meson_drv_bind_master(struct device *dev, bool has_components)
289296
meson_venc_init(priv);
290297
meson_vpp_init(priv);
291298
meson_viu_init(priv);
299+
if (priv->afbcd.ops) {
300+
ret = priv->afbcd.ops->init(priv);
301+
if (ret)
302+
return ret;
303+
}
292304

293305
/* Encoder Initialization */
294306

@@ -359,12 +371,16 @@ static void meson_drv_unbind(struct device *dev)
359371
meson_canvas_free(priv->canvas, priv->canvas_id_vd1_2);
360372
}
361373

374+
if (priv->afbcd.ops) {
375+
priv->afbcd.ops->reset(priv);
376+
meson_rdma_free(priv);
377+
}
378+
362379
drm_dev_unregister(drm);
363380
drm_irq_uninstall(drm);
364381
drm_kms_helper_poll_fini(drm);
365382
drm_mode_config_cleanup(drm);
366383
drm_dev_put(drm);
367-
368384
}
369385

370386
static const struct component_master_ops meson_drv_master_ops = {
@@ -393,6 +409,8 @@ static int __maybe_unused meson_drv_pm_resume(struct device *dev)
393409
meson_venc_init(priv);
394410
meson_vpp_init(priv);
395411
meson_viu_init(priv);
412+
if (priv->afbcd.ops)
413+
priv->afbcd.ops->init(priv);
396414

397415
drm_mode_config_helper_resume(priv->drm);
398416

@@ -481,15 +499,33 @@ static int meson_drv_probe(struct platform_device *pdev)
481499
return 0;
482500
};
483501

502+
static struct meson_drm_match_data meson_drm_gxbb_data = {
503+
.compat = VPU_COMPATIBLE_GXBB,
504+
};
505+
506+
static struct meson_drm_match_data meson_drm_gxl_data = {
507+
.compat = VPU_COMPATIBLE_GXL,
508+
};
509+
510+
static struct meson_drm_match_data meson_drm_gxm_data = {
511+
.compat = VPU_COMPATIBLE_GXM,
512+
.afbcd_ops = &meson_afbcd_gxm_ops,
513+
};
514+
515+
static struct meson_drm_match_data meson_drm_g12a_data = {
516+
.compat = VPU_COMPATIBLE_G12A,
517+
.afbcd_ops = &meson_afbcd_g12a_ops,
518+
};
519+
484520
static const struct of_device_id dt_match[] = {
485521
{ .compatible = "amlogic,meson-gxbb-vpu",
486-
.data = (void *)VPU_COMPATIBLE_GXBB },
522+
.data = (void *)&meson_drm_gxbb_data },
487523
{ .compatible = "amlogic,meson-gxl-vpu",
488-
.data = (void *)VPU_COMPATIBLE_GXL },
524+
.data = (void *)&meson_drm_gxl_data },
489525
{ .compatible = "amlogic,meson-gxm-vpu",
490-
.data = (void *)VPU_COMPATIBLE_GXM },
526+
.data = (void *)&meson_drm_gxm_data },
491527
{ .compatible = "amlogic,meson-g12a-vpu",
492-
.data = (void *)VPU_COMPATIBLE_G12A },
528+
.data = (void *)&meson_drm_g12a_data },
493529
{}
494530
};
495531
MODULE_DEVICE_TABLE(of, dt_match);

‎drivers/gpu/drm/meson/meson_drv.h‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ struct drm_crtc;
1616
struct drm_device;
1717
struct drm_plane;
1818
struct meson_drm;
19+
struct meson_afbcd_ops;
1920

2021
enum vpu_compatible {
2122
VPU_COMPATIBLE_GXBB = 0,
@@ -24,6 +25,11 @@ enum vpu_compatible {
2425
VPU_COMPATIBLE_G12A = 3,
2526
};
2627

28+
struct meson_drm_match_data {
29+
enum vpu_compatible compat;
30+
struct meson_afbcd_ops *afbcd_ops;
31+
};
32+
2733
struct meson_drm {
2834
struct device *dev;
2935
enum vpu_compatible compat;
@@ -129,6 +135,12 @@ struct meson_drm {
129135
uint32_t *addr;
130136
unsigned int offset;
131137
} rdma;
138+
139+
struct {
140+
struct meson_afbcd_ops *ops;
141+
u64 modifier;
142+
u32 format;
143+
} afbcd;
132144
};
133145

134146
static inline int meson_vpu_is_compatible(struct meson_drm *priv,

0 commit comments

Comments
 (0)