RE: [PATCH 1/2] drm/adi: axi-hdmi-tx: Add support for AXI HDMI TX IP core

2020-10-24 Thread Togorean, Bogdan
Thank you Sam for your review,
I'll send now V2 implementing all your remarks.

Best regards,
Bogdan

> 
> Hi Bogdan
> 
> On Mon, Oct 05, 2020 at 05:12:08PM +0300, Bogdan Togorean wrote:
> > From: Lars-Peter Clausen 
> >
> > The AXI HDMI HDL driver is the driver for the HDL graphics core which is
> > used on various FPGA designs. It's mostly used to interface with the
> > ADV7511 driver on some Zynq boards (e.g. ZC702 & ZedBoard).
> >
> > Link: 
> > https://wiki.analog.com/resources/tools-software/linux-drivers/drm/hdl-
> axi-hdmi
> > Link: https://wiki.analog.com/resources/fpga/docs/axi_hdmi_tx
> 
> Thanks for submitting the driver - a few high level comments after
> browsing the driver:
> 
> - Use drmm_mode_config_init() to utilize new cleanup
> - Look at other uses of drm_driver - there is macros that makes this
>   much simpler / smaller
> - Use devm_drm_dev_alloc() to allocate axi_hdmi_tx_private
>   To do so embed drm_device in axi_hdmi_tx_private - which is the way to
>   do it today
> - Do not use ddev->dev_private, it is deprecated
> - Use dev_err_probe() when you risk to see a PROBE_DEFER
> - In all include blocks sort the include alphabetically
> - Use the new interface to drm_bridge_attach() - where display driver
>   creates the connector
> - See if the Kconfig selects can be trimmed - the framebuffer releated
>   selects looks wrong (others get it wrong too)
> - Check if you can use the simple encoder - see
>   drm_simple_encoder_init()
> 
> If this is a simple one plane, one crtc display driver then it should
> use the drm_simple_* support. Or the changelog should explain why not.
> 
> We want the drivers as simple as we can - and they shall use as much of
> the helper infrastructure as they can.
> 
> We continue to develop the helper infrastructure so it is expected that
> there is some lacking behind as is the case here.
> 
> Sam
> 

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 1/2] drm/adi: axi-hdmi-tx: Add support for AXI HDMI TX IP core

2020-10-16 Thread Sam Ravnborg
Hi Bogdan

On Mon, Oct 05, 2020 at 05:12:08PM +0300, Bogdan Togorean wrote:
> From: Lars-Peter Clausen 
> 
> The AXI HDMI HDL driver is the driver for the HDL graphics core which is
> used on various FPGA designs. It's mostly used to interface with the
> ADV7511 driver on some Zynq boards (e.g. ZC702 & ZedBoard).
> 
> Link: 
> https://wiki.analog.com/resources/tools-software/linux-drivers/drm/hdl-axi-hdmi
> Link: https://wiki.analog.com/resources/fpga/docs/axi_hdmi_tx

Thanks for submitting the driver - a few high level comments after
browsing the driver:

- Use drmm_mode_config_init() to utilize new cleanup
- Look at other uses of drm_driver - there is macros that makes this
  much simpler / smaller
- Use devm_drm_dev_alloc() to allocate axi_hdmi_tx_private
  To do so embed drm_device in axi_hdmi_tx_private - which is the way to
  do it today
- Do not use ddev->dev_private, it is deprecated
- Use dev_err_probe() when you risk to see a PROBE_DEFER
- In all include blocks sort the include alphabetically
- Use the new interface to drm_bridge_attach() - where display driver
  creates the connector
- See if the Kconfig selects can be trimmed - the framebuffer releated
  selects looks wrong (others get it wrong too)
- Check if you can use the simple encoder - see
  drm_simple_encoder_init()

If this is a simple one plane, one crtc display driver then it should
use the drm_simple_* support. Or the changelog should explain why not.

We want the drivers as simple as we can - and they shall use as much of
the helper infrastructure as they can.

We continue to develop the helper infrastructure so it is expected that
there is some lacking behind as is the case here.

Sam


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 1/2] drm/adi: axi-hdmi-tx: Add support for AXI HDMI TX IP core

2020-10-06 Thread Bogdan Togorean
From: Lars-Peter Clausen 

The AXI HDMI HDL driver is the driver for the HDL graphics core which is
used on various FPGA designs. It's mostly used to interface with the
ADV7511 driver on some Zynq boards (e.g. ZC702 & ZedBoard).

Link: 
https://wiki.analog.com/resources/tools-software/linux-drivers/drm/hdl-axi-hdmi
Link: https://wiki.analog.com/resources/fpga/docs/axi_hdmi_tx

Signed-off-by: Lars-Peter Clausen 
Signed-off-by: Mike Looijmans 
Signed-off-by: Alexandru Ardelean 
Signed-off-by: Bogdan Togorean 
---
 drivers/gpu/drm/Kconfig   |   2 +
 drivers/gpu/drm/Makefile  |   1 +
 drivers/gpu/drm/adi/Kconfig   |  16 +
 drivers/gpu/drm/adi/Makefile  |   4 +
 drivers/gpu/drm/adi/axi_hdmi_tx_crtc.c| 219 ++
 drivers/gpu/drm/adi/axi_hdmi_tx_drv.c | 225 ++
 drivers/gpu/drm/adi/axi_hdmi_tx_drv.h |  45 +++
 drivers/gpu/drm/adi/axi_hdmi_tx_encoder.c | 344 ++
 8 files changed, 856 insertions(+)
 create mode 100644 drivers/gpu/drm/adi/Kconfig
 create mode 100644 drivers/gpu/drm/adi/Makefile
 create mode 100644 drivers/gpu/drm/adi/axi_hdmi_tx_crtc.c
 create mode 100644 drivers/gpu/drm/adi/axi_hdmi_tx_drv.c
 create mode 100644 drivers/gpu/drm/adi/axi_hdmi_tx_drv.h
 create mode 100644 drivers/gpu/drm/adi/axi_hdmi_tx_encoder.c

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 147d61b9674e..fca4c7e89fab 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -231,6 +231,8 @@ config DRM_SCHED
 
 source "drivers/gpu/drm/i2c/Kconfig"
 
+source "drivers/gpu/drm/adi/Kconfig"
+
 source "drivers/gpu/drm/arm/Kconfig"
 
 config DRM_RADEON
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 2f31579f91d4..6ef28d1422ee 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -61,6 +61,7 @@ obj-$(CONFIG_DRM) += drm.o
 obj-$(CONFIG_DRM_MIPI_DBI) += drm_mipi_dbi.o
 obj-$(CONFIG_DRM_MIPI_DSI) += drm_mipi_dsi.o
 obj-$(CONFIG_DRM_PANEL_ORIENTATION_QUIRKS) += drm_panel_orientation_quirks.o
+obj-y  += adi/
 obj-y  += arm/
 obj-$(CONFIG_DRM_TTM)  += ttm/
 obj-$(CONFIG_DRM_SCHED)+= scheduler/
diff --git a/drivers/gpu/drm/adi/Kconfig b/drivers/gpu/drm/adi/Kconfig
new file mode 100644
index ..bcb230e6d7de
--- /dev/null
+++ b/drivers/gpu/drm/adi/Kconfig
@@ -0,0 +1,16 @@
+# SPDX-License-Identifier: GPL-2.0-only
+config DRM_ADI_AXI_HDMI_TX
+   tristate "DRM Support for Analog Devices HDMI FPGA platforms"
+   depends on DRM
+   default n
+   select DRM_KMS_HELPER
+   select DRM_KMS_CMA_HELPER
+   select DMA_CMA if HAVE_DMA_CONTIGUOUS
+   select CMA if HAVE_DMA_CONTIGUOUS
+   select AXI_DMAC
+   select VT_HW_CONSOLE_BINDING if FRAMEBUFFER_CONSOLE
+   help
+ Choose this option if you have an FPGA board using this AXI HDMI
+ Controller (aka GFX).
+
+ If M is selected this module will be called adi_axi_hdmi_tx.
diff --git a/drivers/gpu/drm/adi/Makefile b/drivers/gpu/drm/adi/Makefile
new file mode 100644
index ..2451cdc4480f
--- /dev/null
+++ b/drivers/gpu/drm/adi/Makefile
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0-only
+adi_axi_hdmi_tx-y := axi_hdmi_tx_encoder.o axi_hdmi_tx_crtc.o axi_hdmi_tx_drv.o
+
+obj-$(CONFIG_DRM_ADI_AXI_HDMI_TX) += adi_axi_hdmi_tx.o
diff --git a/drivers/gpu/drm/adi/axi_hdmi_tx_crtc.c 
b/drivers/gpu/drm/adi/axi_hdmi_tx_crtc.c
new file mode 100644
index ..40dfe5c93f39
--- /dev/null
+++ b/drivers/gpu/drm/adi/axi_hdmi_tx_crtc.c
@@ -0,0 +1,219 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Analog Devices AXI HDMI TX DRM driver.
+ *
+ * Copyright 2012-2020 Analog Devices Inc.
+ *  Author: Lars-Peter Clausen 
+ */
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "axi_hdmi_tx_drv.h"
+
+struct axi_hdmi_tx_crtc {
+   struct drm_crtc drm_crtc;
+   struct drm_plane plane;
+
+   struct dma_chan *dma;
+   struct dma_interleaved_template *dma_template;
+};
+
+static struct axi_hdmi_tx_crtc *plane_to_axi_hdmi_tx_crtc(struct drm_plane 
*plane)
+{
+   return container_of(plane, struct axi_hdmi_tx_crtc, plane);
+}
+
+static struct axi_hdmi_tx_crtc *to_axi_hdmi_tx_crtc(struct drm_crtc *crtc)
+{
+   return container_of(crtc, struct axi_hdmi_tx_crtc, drm_crtc);
+}
+
+static struct dma_async_tx_descriptor *axi_hdmi_tx_vdma_prep_interleaved_desc(
+   struct drm_plane *plane)
+{
+   struct axi_hdmi_tx_crtc *axi_hdmi_tx_crtc = 
plane_to_axi_hdmi_tx_crtc(plane);
+   struct drm_framebuffer *fb = plane->state->fb;
+   size_t offset, hw_row_size;
+   struct drm_gem_cma_object *obj;
+
+   obj = drm_fb_cma_get_gem_obj(plane->state->fb, 0);
+
+   offset = plane->state->crtc_x * fb->format->cpp[0] +
+   plane->state->crtc_y * fb->pitches[0];
+
+   /* Interleaved DMA is used that way:
+* Each