Skip to contentSkip to conversation

Intel FPGA VIP Frame Buffer II drm driver

PATCH Superseded Hean Loong, Ong 2 participants 7 messages Aug 1, 2017 – Aug 2, 2017

Subsystems (5)

v4 of 16 Superseded Latest is v16 →

lore
Share & tools
lore
#0 lore raw

v4 cover Intel FPGA VIP Frame Buffer II drm driver

From: Ong Hean Loong <[email protected]>

The FPGA FrameBuffer Soft IP could be seen as the GPU and the DRM driver patch here is allocating memory for information to be streamed from the ARM/Linux to the display port. Basically the driver just wraps the information such as the pixels to be drawn by the FPGA FrameBuffer 2.

The piece of hardware in discussion is the SoC FPGA where Linux runs on the ARM chip and the FGPA is driven by its NIOS soft core with its own proprietary firmware.

For example the application from the ARM Linux would have to write information on the /dev/fb0 with the information stored in the SDRAM to be fetched by the FPGA framebuffer IP and displayed on the Display Port Monitor.

Ong Hean Loong (3):
ARM:dt-bindings Intel FPGA Video and Image Processing Suite ARM:socfpga-defconfig Intel FPGA Video and Image Processing Suite DRM:ivip Intel FPGA Video and Image Processing Suite

 .../devicetree/bindings/display/altr,vip-fb2.txt   |  39 ++++
 arch/arm/configs/socfpga_defconfig                 |   6 +
 drivers/gpu/drm/Kconfig                            |   2 +
 drivers/gpu/drm/Makefile                           |   1 +
 drivers/gpu/drm/ivip/Kconfig                       |  13 ++
 drivers/gpu/drm/ivip/Makefile                      |   9 +
 drivers/gpu/drm/ivip/intel_vip_conn.c              |  96 ++++++++++
 drivers/gpu/drm/ivip/intel_vip_core.c              | 183 ++++++++++++++++++
 drivers/gpu/drm/ivip/intel_vip_drv.h               |  54 ++++++
 drivers/gpu/drm/ivip/intel_vip_of.c                | 204 +++++++++++++++++++++
 10 files changed, 607 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/display/altr,vip-fb2.txt
 create mode 100644 drivers/gpu/drm/ivip/Kconfig
 create mode 100644 drivers/gpu/drm/ivip/Makefile
 create mode 100644 drivers/gpu/drm/ivip/intel_vip_conn.c
 create mode 100644 drivers/gpu/drm/ivip/intel_vip_core.c
 create mode 100644 drivers/gpu/drm/ivip/intel_vip_drv.h
 create mode 100644 drivers/gpu/drm/ivip/intel_vip_of.c
Signature · 6 lines
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#1 lore raw

PATCH v4 1/3 ARM:dt-bindings Intel FPGA Video and Image Processing Suite

From: Ong Hean Loong <[email protected]>

Device tree binding for Intel FPGA Video and Image Processing Suite. The binding involved would be generated from the Altera (Intel) Qsys system. The bindings would set the max width, max height, buts per pixel and memory port width. The device tree binding only supports the Intel Arria10 devkit and its variants. Vendor name retained as altr.

---
 .../devicetree/bindings/display/altr,vip-fb2.txt   | 39 ++++++++++++++++++++++
 1 file changed, 39 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/display/altr,vip-fb2.txt
Documentation/devicetree/bindings/display/altr,vip-fb2.txt new file +39 -0
new file mode 100644
index 0000000..c4338d9
@@ -0,0 +1,39 @@
+Intel Video and Image Processing(VIP) Frame Buffer II bindings
+
+Supported hardware: Arria 10 and above with display port IP
+
+The hardware associated with this device tree is a SoC FPGA. Where there is an ARM controller
+and a FPGA device. The ARM controller would host the Linux OS while the FPGA device runs on its
+individual IP firmware. In the Intel VIP Frame Buffer II the ARM controller would be
+driving data from the Linux OS to the FPGA device programmed with the Frame Buffer II IP
+to render pixels to be streamed to the Display Port connector.
+
+The Frame Buffer II device is a simple frame buffer device. The device contains the display
+properties and the bridge or connector register. The output for this device currently
+is a dedicated to a single Display Port. Currently the max resolution supported is 1280 x 720 at
+60Hz.
+
+More information the FPGA video IP component can be acquired from
+https://www.altera.com/content/dam/altera-www/global/en_US/pdfs/literature/ug/ug_vip.pdf
+
+
+New bindings:
+=============
+Required properties:
+----------------------------
+- compatible: "altr,vip-frame-buffer-2.0"
+- reg: Physical base address and length of the framebuffer controller's
+  registers.
+- altr,max-width: The width of the framebuffer in pixels.
+- altr,max-height: The height of the framebuffer in pixels.
+- altr,mem-port-width = the bus width of the avalon master port on the frame reader
+
+Example:
+----------------------------
+       dp_0_frame_buf: display-controller@100000280 {
+                       compatible = "altr,vip-frame-buffer-2.0";
+                       reg = <0x00000001 0x00000280 0x00000040>;
+                       altr,max-width = <1280>;
+                       altr,max-height = <720>;
+                       altr,mem-port-width = <128>;
+       };
Signature · 6 lines
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw

Re: [PATCHv4 1/3] ARM:dt-bindings Intel FPGA Video and Image Processing Suite

Hi Hean Loong,

Thank you for the patch.

Quoted 29 lines · Ong

From: Ong Hean Loong <[email protected]>

Device tree binding for Intel FPGA Video and Image Processing Suite. The binding involved would be generated from the Altera (Intel) Qsys system. The bindings would set the max width, max height, buts per pixel and memory port width. The device tree binding only supports the Intel Arria10 devkit and its variants. Vendor name retained as altr.

---
 .../devicetree/bindings/display/altr,vip-fb2.txt   | 39 ++++++++++++++++++
 1 file changed, 39 insertions(+
 create mode 100644

Documentation/devicetree/bindings/display/altr,vip-fb2.txt

(quoted diff) +0 -0

b/Documentation/devicetree/bindings/display/altr,vip-fb2.txt new file mode 100644
index 0000000..c4338d9

Documentation/devicetree/bindings/display/altr,vip-fb2.txt new file +5 -0
@@ -0,0 +1,39 @@
+Intel Video and Image Processing(VIP) Frame Buffer II bindings
+
+Supported hardware: Arria 10 and above with display port IP
+
+The hardware associated with this device tree is a SoC FPGA. Where there is
Quoted 2 lines

an ARM controller +and a FPGA device. The ARM controller would host the Linux OS while the FPGA device runs on its +individual IP firmware.

DT bindings should not be OS-specific, you shouldn't mention Linux here.

Quoted 13 lines

In the
Intel VIP Frame Buffer II the ARM controller would be +driving data from the Linux OS to the FPGA device programmed with the Frame Buffer II IP +to render pixels to be streamed to the Display Port connector.

Documentation/devicetree/bindings/display/altr,vip-fb2.txt new file +2 -0
+
+The Frame Buffer II device is a simple frame buffer device. The device

contains the display +properties and the bridge or connector register. The output for this device currently +is a dedicated to a single Display Port. Currently the max resolution supported is 1280 x 720 at +60Hz.

Documentation/devicetree/bindings/display/altr,vip-fb2.txt new file +3 -0
+
+More information the FPGA video IP component can be acquired from
+https://www.altera.com/content/dam/altera-www/global/en_US/pdfs/literature/

ug/ug_vip.pdf +

Documentation/devicetree/bindings/display/altr,vip-fb2.txt line 28

Quoted 10 lines
Documentation/devicetree/bindings/display/altr,vip-fb2.txt new file +10 -0
+
+New bindings:
+=============
+Required properties:
+----------------------------
+- compatible: "altr,vip-frame-buffer-2.0"
+- reg: Physical base address and length of the framebuffer controller's
+  registers.
+- altr,max-width: The width of the framebuffer in pixels.
+- altr,max-height: The height of the framebuffer in pixels.

The properties hint that those are the maximum values, but the descriptions don't match. One of the two needs to be fixed.

Quoted 12 lines

+- altr,mem-port-width = the bus width of the avalon master port on the frame reader

Documentation/devicetree/bindings/display/altr,vip-fb2.txt new file +10 -0
+
+Example:
+----------------------------
+       dp_0_frame_buf: display-controller@100000280 {
+                       compatible = "altr,vip-frame-buffer-2.0";
+                       reg = <0x00000001 0x00000280 0x00000040>;
+                       altr,max-width = <1280>;
+                       altr,max-height = <720>;
+                       altr,mem-port-width = <128>;
+       };
Signature · 3 lines
Regards,

Laurent Pinchart
#3 lore raw

PATCH v4 2/3 ARM:socfpga-defconfig Intel FPGA Video and Image Processing Suite

In reply to Hean Loong, Ong

From: Ong Hean Loong <[email protected]>

Intel FPGA Video and Image Processing Suite Frame Buffer II driver config for Arria 10 devkit and its variants

---
 arch/arm/configs/socfpga_defconfig | 6 ++++++
 1 file changed, 6 insertions(+)
arch/arm/configs/socfpga_defconfig +6 -0
index 2620ce7..255f553 100644
@@ -111,6 +111,12 @@ CONFIG_MFD_ALTERA_A10SR=y
 CONFIG_MFD_STMPE=y
 CONFIG_REGULATOR=y
 CONFIG_REGULATOR_FIXED_VOLTAGE=y
+CONFIG_DRM=m
+CONFIG_DRM_IVIP=m
+CONFIG_DRM_IVIP_OF=m
+CONFIG_FB=y
+CONFIG_FB_SIMPLE=y
+CONFIG_FRAMEBUFFER_CONSOLE=m
 CONFIG_USB=y
 CONFIG_USB_STORAGE=y
 CONFIG_USB_DWC2=y
Signature · 6 lines
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#4 lore raw

PATCH v4 3/3 DRM:ivip Intel FPGA Video and Image Processing Suite

In reply to Hean Loong, Ong

From: Ong Hean Loong <[email protected]>

Driver for Intel FPGA Video and Image Processing Suite Frame Buffer II. The driver only supports the Intel Arria10 devkit and its variants. This driver can be either loaded staticlly or in modules. The OF device tree binding is located at:
Documentation/devicetree/bindings/display/altr,vip-fb2.txt

---
V3:
*Changes to fixing drm_simple_pipe
*Used drm_fb_cma_get_gem_addr

V2:
*Adding drm_simple_display_pipe_init

---
 drivers/gpu/drm/Kconfig               |   2 +
 drivers/gpu/drm/Makefile              |   1 +
 drivers/gpu/drm/ivip/Kconfig          |  13 +++
 drivers/gpu/drm/ivip/Makefile         |   9 ++
 drivers/gpu/drm/ivip/intel_vip_conn.c |  96 ++++++++++++++++
 drivers/gpu/drm/ivip/intel_vip_core.c | 183 ++++++++++++++++++++++++++++++
 drivers/gpu/drm/ivip/intel_vip_drv.h  |  54 +++++++++
 drivers/gpu/drm/ivip/intel_vip_of.c   | 204 ++++++++++++++++++++++++++++++++++
 8 files changed, 562 insertions(+)
 create mode 100644 drivers/gpu/drm/ivip/Kconfig
 create mode 100644 drivers/gpu/drm/ivip/Makefile
 create mode 100644 drivers/gpu/drm/ivip/intel_vip_conn.c
 create mode 100644 drivers/gpu/drm/ivip/intel_vip_core.c
 create mode 100644 drivers/gpu/drm/ivip/intel_vip_drv.h
 create mode 100644 drivers/gpu/drm/ivip/intel_vip_of.c
drivers/gpu/drm/Kconfig +2 -0
index 83cb2a8..38a184d 100644
@@ -195,6 +195,8 @@ source "drivers/gpu/drm/nouveau/Kconfig"
 
 source "drivers/gpu/drm/i915/Kconfig"
 
+source "drivers/gpu/drm/ivip/Kconfig"
+
 config DRM_VGEM
 	tristate "Virtual GEM provider"
 	depends on DRM
drivers/gpu/drm/Makefile +1 -0
index 24a066e..4162a0e 100644
@@ -58,6 +58,7 @@ obj-$(CONFIG_DRM_AMDGPU)+= amd/amdgpu/
 obj-$(CONFIG_DRM_MGA)	+= mga/
 obj-$(CONFIG_DRM_I810)	+= i810/
 obj-$(CONFIG_DRM_I915)	+= i915/
+obj-$(CONFIG_DRM_IVIP) += ivip/
 obj-$(CONFIG_DRM_MGAG200) += mgag200/
 obj-$(CONFIG_DRM_VC4)  += vc4/
 obj-$(CONFIG_DRM_CIRRUS_QEMU) += cirrus/
drivers/gpu/drm/ivip/Kconfig new file +13 -0
new file mode 100644
index 0000000..9a8c5ce
@@ -0,0 +1,13 @@
+config DRM_IVIP
+	 tristate "Intel FGPA Video and Image Processing"
+	 depends on DRM && OF
+	 select DRM_GEM_CMA_HELPER
+	 select DRM_KMS_HELPER
+	 select DRM_KMS_FB_HELPER
+	 select DRM_KMS_CMA_HELPER
+	 help
+	     Choose this option if you have a Intel FPGA Arria 10 system
+	     and above with a Display Port IP. This does not support legacy
+	     Intel FPGA Cyclone V display port. Currently only single frame
+	     buffer is supported. Note that ACPI and X_86 architecture is yet
+	     to be supported.If M is selected the module would be called ivip.
drivers/gpu/drm/ivip/Makefile new file +9 -0
new file mode 100644
index 0000000..95291c6
@@ -0,0 +1,9 @@
+#
+# Makefile for the drm device driver.  This driver provides support for the
+# Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
+
+ccflags-y := -Iinclude/drm
+
+obj-$(CONFIG_DRM_IVIP) += ivip.o
+ivip-objs := intel_vip_of.o intel_vip_core.o \
+intel_vip_conn.o
drivers/gpu/drm/ivip/intel_vip_conn.c new file +96 -0

96 lines not on this page · raw message

drivers/gpu/drm/ivip/intel_vip_core.c new file +183 -0

183 lines not on this page · raw message

drivers/gpu/drm/ivip/intel_vip_drv.h new file +54 -0

54 lines not on this page · raw message

drivers/gpu/drm/ivip/intel_vip_of.c new file +204 -0

204 lines not on this page · raw message

Signature · 6 lines
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#5 lore raw

Re: [PATCHv4 3/3] DRM:ivip Intel FPGA Video and Image Processing Suite

Hi Hean Loong,

Thank you for the patch.

Quoted 33 lines · Ong

From: Ong Hean Loong <[email protected]>

Driver for Intel FPGA Video and Image Processing Suite Frame Buffer II. The driver only supports the Intel Arria10 devkit and its variants. This driver can be either loaded staticlly or in modules. The OF device tree binding is located at:
Documentation/devicetree/bindings/display/altr,vip-fb2.txt

---
V3:
*Changes to fixing drm_simple_pipe
*Used drm_fb_cma_get_gem_addr

V2:
*Adding drm_simple_display_pipe_init

---
 drivers/gpu/drm/Kconfig               |   2 +
 drivers/gpu/drm/Makefile              |   1 +
 drivers/gpu/drm/ivip/Kconfig          |  13 +++
 drivers/gpu/drm/ivip/Makefile         |   9 ++
 drivers/gpu/drm/ivip/intel_vip_conn.c |  96 ++++++++++++++++
 drivers/gpu/drm/ivip/intel_vip_core.c | 183 ++++++++++++++++++++++++++++++
 drivers/gpu/drm/ivip/intel_vip_drv.h  |  54 +++++++++
 drivers/gpu/drm/ivip/intel_vip_of.c   | 204 +++++++++++++++++++++++++++++++
 8 files changed, 562 insertions(+)
 create mode 100644 drivers/gpu/drm/ivip/Kconfig
 create mode 100644 drivers/gpu/drm/ivip/Makefile
 create mode 100644 drivers/gpu/drm/ivip/intel_vip_conn.c
 create mode 100644 drivers/gpu/drm/ivip/intel_vip_core.c
 create mode 100644 drivers/gpu/drm/ivip/intel_vip_drv.h
 create mode 100644 drivers/gpu/drm/ivip/intel_vip_of.c

[snip]

Quoted 8 lines
drivers/gpu/drm/ivip/Kconfig new file +2 -0
new file mode 100644
index 0000000..9a8c5ce
@@ -0,0 +1,13 @@
+config DRM_IVIP
+	 tristate "Intel FGPA Video and Image Processing"

drivers/gpu/drm/ivip/Kconfig line 12

Quoted 10 lines
drivers/gpu/drm/ivip/Kconfig new file +10 -0
+	 depends on DRM && OF
+	 select DRM_GEM_CMA_HELPER
+	 select DRM_KMS_HELPER
+	 select DRM_KMS_FB_HELPER
+	 select DRM_KMS_CMA_HELPER
+	 help
+	     Choose this option if you have a Intel FPGA Arria 10 system
+	     and above with a Display Port IP. This does not support legacy
+	     Intel FPGA Cyclone V display port. Currently only single frame
+	     buffer is supported.

I think this should be fixed to upstream this driver.

Quoted 1 line

Note that ACPI and X_86 architecture is yet

ACPI on FPGA... I wonder if it could get any crazier than that :-)

drivers/gpu/drm/ivip/Kconfig line 13

Quoted 1 line
drivers/gpu/drm/ivip/Kconfig new file +1 -0
+	     to be supported.If M is selected the module would be called ivip.

s/.If/. If/

[snip]

Quoted 40 lines
(quoted diff) +0 -0

b/drivers/gpu/drm/ivip/intel_vip_core.c new file mode 100644 index 0000000..ea85715

drivers/gpu/drm/ivip/intel_vip_core.c new file +16 -0
@@ -0,0 +1,183 @@
+/*
+ * intel_vip_core.c -- Intel Video and Image Processing(VIP)
+ * Frame Buffer II driver
+ *
+ * This driver supports the Intel VIP Frame Reader component.
+ * More info on the hardware can be found in the Intel Video
+ * and Image Processing Suite User Guide at this address
+ * http://www.altera.com/literature/ug/ug_vip.pdf.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License

for + * more details.
+ *
+ * Authors:
+ * Ong, Hean-Loong <[email protected]>
+ *
+ */

drivers/gpu/drm/ivip/intel_vip_core.c new file +12 -0
+
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+
+#include <drm/drmP.h>
+#include <drm/drm_atomic.h>
+#include <drm/drm_atomic_helper.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_fb_helper.h>
+#include <drm/drm_fb_cma_helper.h>
+#include <drm/drm_gem_cma_helper.h>

drivers/gpu/drm/ivip/intel_vip_core.c

Quoted 10 lines
drivers/gpu/drm/ivip/intel_vip_core.c new file +10 -0
+#include <drm/drm_plane_helper.h>
+#include <drm/drm_simple_kms_helper.h>
+
+#include "intel_vip_drv.h"
+
+static void intelvipfb_enable(struct drm_simple_display_pipe *pipe,
+	struct drm_crtc_state *crtc_state)
+{
+	/*
+	 * The frameinfo variable has to correspond to the size of the VIP 

Suite

Quoted 16 lines
drivers/gpu/drm/ivip/intel_vip_core.c new file +16 -0
+	 * Frame Reader register 7 which will determine the maximum size used
+	 * in this frameinfo
+	 */
+
+	u32 frameinfo;
+	struct intelvipfb_priv *priv = pipe->plane.dev->dev_private;
+	void __iomem *base = priv->base;
+	struct drm_plane_state *state = pipe->plane.state;
+	dma_addr_t addr;
+
+	addr = drm_fb_cma_get_gem_addr(state->fb, state, 0);
+
+	dev_info(pipe->plane.dev->dev, "Address 0x%x\n", addr);
+
+	frameinfo =
+		  readl(base + INTELVIPFB_FRAME_READER) & 0x00ffffff;

drivers/gpu/drm/ivip/intel_vip_core.c line 70

Quoted 10 lines
drivers/gpu/drm/ivip/intel_vip_core.c new file +10 -0
+	writel(frameinfo, base + INTELVIPFB_FRAME_INFO);
+	writel(addr, base + INTELVIPFB_FRAME_START);
+	/* Finally set the control register to 1 to start streaming */
+	writel(1, base + INTELVIPFB_CONTROL);
+}
+
+static void intelvipfb_disable(struct drm_simple_display_pipe *pipe)
+{
+	struct intelvipfb_priv *priv = pipe->plane.dev->dev_private;
+	void __iomem *base = priv->base;

Missing blank line.

Quoted 23 lines
drivers/gpu/drm/ivip/intel_vip_core.c new file +23 -0
+	/* set the control register to 0 to stop streaming */
+	writel(0, base + INTELVIPFB_CONTROL);
+}
+
+static const struct drm_mode_config_funcs intelvipfb_mode_config_funcs = {
+	.fb_create = drm_fb_cma_create,
+	.atomic_check = drm_atomic_helper_check,
+	.atomic_commit = drm_atomic_helper_commit,
+};
+
+static void intelvipfb_setup_mode_config(struct drm_device *drm)
+{
+	drm_mode_config_init(drm);
+	drm->mode_config.funcs = &intelvipfb_mode_config_funcs;
+}
+
+static int intelvipfb_pipe_prepare_fb(struct drm_simple_display_pipe *pipe,
+		struct drm_plane_state *plane_state)
+{
+	return drm_fb_cma_prepare_fb(&pipe->plane, plane_state);
+}
+
+static void intelvipfb_update(struct drm_simple_display_pipe *pipe,

drivers/gpu/drm/ivip/intel_vip_core.c line 103

Quoted 10 lines
drivers/gpu/drm/ivip/intel_vip_core.c new file +10 -0
+		struct drm_plane_state *old_state)
+{
+	struct drm_crtc *crtc = &pipe->crtc;
+
+	if (crtc->state->event) {
+		spin_lock_irq(&crtc->dev->event_lock);
+		drm_crtc_send_vblank_event(crtc, crtc->state->event);
+		spin_unlock_irq(&crtc->dev->event_lock);
+		crtc->state->event = NULL;
+	}

This is not quite right. Userspace expects the driver to perform a page flip here, and you just signal page flip completion without doing anything.

drivers/gpu/drm/ivip/intel_vip_core.c line 113

Quoted 10 lines
drivers/gpu/drm/ivip/intel_vip_core.c new file +10 -0
+}
+
+static struct drm_simple_display_pipe_funcs fbpriv_funcs = {
+	.prepare_fb = intelvipfb_pipe_prepare_fb,
+	.update = intelvipfb_update,
+	.enable = intelvipfb_enable,
+	.disable = intelvipfb_disable
+};
+
+int intelvipfb_probe(struct device *dev, void __iomem *base)

You don't use the base argument, you can remove it.

drivers/gpu/drm/ivip/intel_vip_core.c line 119

Quoted 6 lines
drivers/gpu/drm/ivip/intel_vip_core.c new file +6 -0
+{
+	int retval;
+	struct drm_device *drm;
+	struct intelvipfb_priv *fbpriv = dev_get_drvdata(dev);
+	struct drm_connector *connector;
+

Extra blank line.

drivers/gpu/drm/ivip/intel_vip_core.c line 122

Quoted 3 lines
drivers/gpu/drm/ivip/intel_vip_core.c new file +3 -0
+	u32 formats[] = {DRM_FORMAT_XRGB8888};
+
+	dev_set_drvdata(dev, fbpriv);

As fbpriv is obtained by a call to dev_get_drvdata(), this isn't needed.

A better option would be to pass the intelvipfb_priv pointer as an argument to this function.

Quoted 26 lines
drivers/gpu/drm/ivip/intel_vip_core.c new file +26 -0
+	drm = fbpriv->drm;
+
+	drm->dev_private = fbpriv;
+
+	intelvipfb_setup_mode_config(drm);
+
+	connector = intelvipfb_conn_setup(drm);
+	if (!connector) {
+		dev_err(drm->dev, "Connector setup failed\n");
+		goto err_mode_config;
+	}
+
+	retval = drm_simple_display_pipe_init(drm, &fbpriv->pipe,
+		&fbpriv_funcs, formats,
+		ARRAY_SIZE(formats), connector);
+	if (retval < 0) {
+		dev_err(drm->dev, "Cannot setup simple display pipe\n");
+		goto err_mode_config;
+	}
+
+	fbpriv->fbcma = drm_fbdev_cma_init(drm,
+		drm->mode_config.preferred_depth,
+		drm->mode_config.num_connector);
+
+	drm_mode_config_reset(drm);
+

drivers/gpu/drm/ivip/intel_vip_core.c line 159

Quoted 10 lines
drivers/gpu/drm/ivip/intel_vip_core.c new file +10 -0
+	drm_dev_register(drm, 0);
+
+	return retval;
+
+err_mode_config:
+
+	drm_mode_config_cleanup(drm);
+	return -ENODEV;
+}
+EXPORT_SYMBOL_GPL(intelvipfb_probe);

Why do you need to export this symbol ?

Quoted 5 lines
drivers/gpu/drm/ivip/intel_vip_core.c new file +5 -0
+int intelvipfb_remove(struct device *dev)
+{
+	struct intelvipfb_priv *fbpriv = dev_get_drvdata(dev);
+	struct drm_device *drm =  fbpriv->drm;
+

drivers/gpu/drm/ivip/intel_vip_core.c line 175

Quoted 10 lines
drivers/gpu/drm/ivip/intel_vip_core.c new file +10 -0
+	drm_dev_unregister(drm);
+
+	if (fbpriv->fbcma)
+		drm_fbdev_cma_fini(fbpriv->fbcma);
+
+	drm_mode_config_cleanup(drm);
+
+	drm_dev_unref(drm);
+
+	devm_kfree(dev, fbpriv);

The whole point of devm_kzalloc() is that you don't need to free the memory at remove time.

Quoted 35 lines
drivers/gpu/drm/ivip/intel_vip_core.c new file +8 -0
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(intelvipfb_remove);
+
+MODULE_AUTHOR("Ong, Hean-Loong <[email protected]>");
+MODULE_DESCRIPTION("Intel VIP Frame Buffer II driver");
+MODULE_LICENSE("GPL v2");
(quoted diff) +0 -0

b/drivers/gpu/drm/ivip/intel_vip_drv.h new file mode 100644 index 0000000..ebdbd50

drivers/gpu/drm/ivip/intel_vip_drv.h new file +12 -0
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2017 Intel Corporation.
+ *
+ * Intel Video and Image Processing(VIP) Frame Buffer II driver.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License

for + * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with + * this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ * Ong, Hean-Loong <[email protected]>
+ *
+ */

drivers/gpu/drm/ivip/intel_vip_drv.h line 23

Quoted 2 lines
drivers/gpu/drm/ivip/intel_vip_drv.h new file +2 -0
+#ifndef _INTEL_VIP_DRV_H
+#define _INTEL_VIP_DRV_H

Missing blank line.

drivers/gpu/drm/ivip/intel_vip_drv.h line 25

Quoted 2 lines
drivers/gpu/drm/ivip/intel_vip_drv.h new file +2 -0
+#include <linux/io.h>
+#include <linux/fb.h>

I don't think this header is needed.

Quoted 57 lines
drivers/gpu/drm/ivip/intel_vip_drv.h new file +28 -0
+#define DRIVER_NAME    "intelvipfb"
+#define BYTES_PER_PIXEL        4
+#define CRTC_NUM               1
+#define CONN_NUM               1
+
+/* control registers */
+#define INTELVIPFB_CONTROL             0
+#define INTELVIPFB_STATUS              0x4
+#define INTELVIPFB_INTERRUPT           0x8
+#define INTELVIPFB_FRAME_COUNTER       0xC
+#define INTELVIPFB_FRAME_DROP          0x10
+#define INTELVIPFB_FRAME_INFO          0x14
+#define INTELVIPFB_FRAME_START         0x18
+#define INTELVIPFB_FRAME_READER                0x1C
+
+int intelvipfb_probe(struct device *dev, void __iomem *base);
+int intelvipfb_remove(struct device *dev);
+int intelvipfb_setup_crtc(struct drm_device *drm);
+struct drm_connector *intelvipfb_conn_setup(struct drm_device *drm);
+
+struct intelvipfb_priv {
+	struct drm_simple_display_pipe pipe;
+	struct drm_fbdev_cma *fbcma;
+	struct drm_device *drm;
+	void    __iomem *base;
+};
+
+#endif
(quoted diff) +0 -0

b/drivers/gpu/drm/ivip/intel_vip_of.c new file mode 100644 index 0000000..5a7c63b

drivers/gpu/drm/ivip/intel_vip_of.c new file +16 -0
@@ -0,0 +1,204 @@
+/*
+ * intel_vip_of.c -- Intel Video and Image Processing(VIP)
+ * Frame Buffer II driver
+ *
+ * This driver supports the Intel VIP Frame Reader component.
+ * More info on the hardware can be found in the Intel Video
+ * and Image Processing Suite User Guide at this address
+ * http://www.altera.com/literature/ug/ug_vip.pdf.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License

for
+ * more details.
+ *
+ * Authors:
+ * Ong, Hean-Loong <[email protected]>
+ *
+ */

drivers/gpu/drm/ivip/intel_vip_of.c line 25

Quoted 3 lines
drivers/gpu/drm/ivip/intel_vip_of.c new file +3 -0
+
+#include <linux/component.h>
+#include <linux/fb.h>

I don't think those two headers are needed.

drivers/gpu/drm/ivip/intel_vip_of.c line 35

Quoted 10 lines
drivers/gpu/drm/ivip/intel_vip_of.c new file +10 -0
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+
+#include <drm/drm_fb_helper.h>
+#include <drm/drm_of.h>
+#include <drm/drm_fb_cma_helper.h>
+#include <drm/drm_gem_cma_helper.h>
+#include <drm/drm_simple_kms_helper.h>

Please sort these alphabetically.

Quoted 61 lines
drivers/gpu/drm/ivip/intel_vip_of.c new file +61 -0
+
+#include "intel_vip_drv.h"
+
+DEFINE_DRM_GEM_CMA_FOPS(drm_fops);
+
+static void intelvipfb_lastclose(struct drm_device *drm)
+{
+	struct intelvipfb_priv *priv = drm->dev_private;
+
+	drm_fbdev_cma_restore_mode(priv->fbcma);
+}
+
+static struct drm_driver intelvipfb_drm = {
+	.driver_features =
+		DRIVER_MODESET | DRIVER_GEM |
+		DRIVER_PRIME | DRIVER_ATOMIC,
+	.gem_free_object_unlocked = drm_gem_cma_free_object,
+	.gem_vm_ops = &drm_gem_cma_vm_ops,
+	.dumb_create = drm_gem_cma_dumb_create,
+	.dumb_map_offset = drm_gem_cma_dumb_map_offset,
+	.dumb_destroy = drm_gem_dumb_destroy,
+	.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
+	.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
+	.gem_prime_export = drm_gem_prime_export,
+	.gem_prime_import = drm_gem_prime_import,
+	.gem_prime_get_sg_table = drm_gem_cma_prime_get_sg_table,
+	.gem_prime_import_sg_table = drm_gem_cma_prime_import_sg_table,
+	.gem_prime_vmap = drm_gem_cma_prime_vmap,
+	.gem_prime_vunmap = drm_gem_cma_prime_vunmap,
+	.gem_prime_mmap = drm_gem_cma_prime_mmap,
+	.lastclose = intelvipfb_lastclose,
+	.name = DRIVER_NAME,
+	.date = "20170729",
+	.desc = "Intel FPGA VIP SUITE",
+	.major = 1,
+	.minor = 0,
+	.ioctls = NULL,
+	.patchlevel = 0,
+	.fops = &drm_fops,
+};
+
+/*
+ * Setting up information derived from OF Device Tree Nodes
+ * max-width, max-height, bits per pixel, memory port width
+ */
+
+static int intelvipfb_drm_setup(struct device *dev,
+			struct intelvipfb_priv *fbpriv)
+{
+	struct drm_device *drm = fbpriv->drm;
+	struct device_node *np = dev->of_node;
+	int mem_word_width;
+	int max_h, max_w;
+	int bpp;
+	int ret;
+
+	ret = of_property_read_u32(np, "altr,max-width", &max_w);
+	if (ret) {
+		dev_err(dev,
+		"Missing required parameter 'altr,max-width'");
+		return ret;

drivers/gpu/drm/ivip/intel_vip_of.c line 106

Quoted 10 lines
drivers/gpu/drm/ivip/intel_vip_of.c new file +10 -0
+	}
+
+	ret = of_property_read_u32(np, "altr,max-height", &max_h);
+	if (ret) {
+		dev_err(dev,
+		"Missing required parameter 'altr,max-height'");
+		return ret;
+	}
+
+	ret = of_property_read_u32(np, "altr,bits-per-symbol", &bpp);

This property is not documented in patch 1/3.

drivers/gpu/drm/ivip/intel_vip_of.c

Quoted 7 lines
drivers/gpu/drm/ivip/intel_vip_of.c new file +7 -0
+	if (ret) {
+		dev_err(dev,
+		"Missing required parameter 'altr,bits-per-symbol'");
+		return ret;
+	}
+
+	ret = of_property_read_u32(np, "altr,mem-port-width", 

&mem_word_width);

drivers/gpu/drm/ivip/intel_vip_of.c

Quoted 2 lines
drivers/gpu/drm/ivip/intel_vip_of.c new file +2 -0
+	if (ret) {
+		dev_err(dev, "Missing required parameter 'altr,mem-port-width 

'");

drivers/gpu/drm/ivip/intel_vip_of.c

Quoted 6 lines
drivers/gpu/drm/ivip/intel_vip_of.c new file +6 -0
+		return ret;
+	}
+
+	if (!(mem_word_width >= 32 && mem_word_width % 32 == 0)) {
+		dev_err(dev,
+		"mem-word-width is set to %i. must be >= 32 and multiple of 

32.",

Quoted 12 lines
drivers/gpu/drm/ivip/intel_vip_of.c new file +12 -0
+		mem_word_width);
+		return -ENODEV;
+	}
+
+	drm->mode_config.min_width = 640;
+	drm->mode_config.min_height = 480;
+	drm->mode_config.max_width = max_w;
+	drm->mode_config.max_height = max_h;
+	drm->mode_config.preferred_depth = bpp * BYTES_PER_PIXEL;
+
+	return 0;
+}
Signature · 8 lines
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#6 lore raw

Re: [PATCHv4 3/3] DRM:ivip Intel FPGA Video and Image Processing Suite

Quoted 69 lines · Laurent Pinchart

Hi Hean Loong,

Thank you for the patch.

Quoted 36 lines · Ong

From: Ong Hean Loong <[email protected]>

Driver for Intel FPGA Video and Image Processing Suite Frame Buffer II. The driver only supports the Intel Arria10 devkit and its variants. This driver can be either loaded staticlly or in modules. The OF device tree binding is located at:
Documentation/devicetree/bindings/display/altr,vip-fb2.txt

---
V3:
*Changes to fixing drm_simple_pipe
*Used drm_fb_cma_get_gem_addr

V2:
*Adding drm_simple_display_pipe_init
---
 drivers/gpu/drm/Kconfig               |   2 + drivers/gpu/drm/Makefile              |   1 + drivers/gpu/drm/ivip/Kconfig          |  13 +++ drivers/gpu/drm/ivip/Makefile         |   9 ++ drivers/gpu/drm/ivip/intel_vip_conn.c |  96 ++++++++++++++++ drivers/gpu/drm/ivip/intel_vip_core.c | 183
++++++++++++++++++++++++++++++
 drivers/gpu/drm/ivip/intel_vip_drv.h  |  54 +++++++++ drivers/gpu/drm/ivip/intel_vip_of.c   | 204
+++++++++++++++++++++++++++++++

 8 files changed, 562 insertions(+)

 create mode 100644 drivers/gpu/drm/ivip/Kconfig create mode 100644 drivers/gpu/drm/ivip/Makefile create mode 100644 drivers/gpu/drm/ivip/intel_vip_conn.c create mode 100644 drivers/gpu/drm/ivip/intel_vip_core.c create mode 100644 drivers/gpu/drm/ivip/intel_vip_drv.h create mode 100644 drivers/gpu/drm/ivip/intel_vip_of.c

[snip]

Quoted 22 lines
drivers/gpu/drm/ivip/Kconfig new file +9 -0
new file mode 100644
index 0000000..9a8c5ce
@@ -0,0 +1,13 @@
+config DRM_IVIP
+	 tristate "Intel FGPA Video and Image Processing"
+	 depends on DRM && OF
+	 select DRM_GEM_CMA_HELPER
+	 select DRM_KMS_HELPER
+	 select DRM_KMS_FB_HELPER
+	 select DRM_KMS_CMA_HELPER
+	 help
+	     Choose this option if you have a Intel FPGA Arria 10

system

drivers/gpu/drm/ivip/Kconfig new file +1 -0
+	     and above with a Display Port IP. This does not

support legacy

drivers/gpu/drm/ivip/Kconfig new file +1 -0
+	     Intel FPGA Cyclone V display port. Currently only

single frame

drivers/gpu/drm/ivip/Kconfig

Quoted 1 line
drivers/gpu/drm/ivip/Kconfig new file +1 -0
+	     buffer is supported.

I think this should be fixed to upstream this driver.

Quoted 1 line
Quoted 3 lines
Quoted 1 line

Note that ACPI and X_86 architecture is yet

ACPI on FPGA... I wonder if it could get any crazier than that :-)

The driver is meant for the product Intel FPGA Arria10 devkit. We do not have plans for the devkit to be shipped with ACPI and X_86 in a forseeable future. Currently most the commercial SoC devkits are shipped with ARM + FPGA.

Quoted 471 lines
Quoted 3 lines
drivers/gpu/drm/ivip/Kconfig new file +1 -0
+	     to be supported.If M is selected the module would be

called ivip.

s/.If/. If/

[snip]

Quoted 57 lines
(quoted diff) +0 -0

b/drivers/gpu/drm/ivip/intel_vip_core.c new file mode 100644 index 0000000..ea85715

drivers/gpu/drm/ivip/intel_vip_core.c new file +10 -0
@@ -0,0 +1,183 @@
+/*
+ * intel_vip_core.c -- Intel Video and Image Processing(VIP)
+ * Frame Buffer II driver
+ *
+ * This driver supports the Intel VIP Frame Reader component.
+ * More info on the hardware can be found in the Intel Video
+ * and Image Processing Suite User Guide at this address
+ * http://www.altera.com/literature/ug/ug_vip.pdf.
+ *
+ * This program is free software; you can redistribute it and/or

modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for + * more details.
+ *
+ * Authors:
+ * Ong, Hean-Loong <[email protected]>
+ *
+ */

drivers/gpu/drm/ivip/intel_vip_core.c new file +18 -0
+
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+
+#include <drm/drmP.h>
+#include <drm/drm_atomic.h>
+#include <drm/drm_atomic_helper.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_fb_helper.h>
+#include <drm/drm_fb_cma_helper.h>
+#include <drm/drm_gem_cma_helper.h>
+#include <drm/drm_plane_helper.h>
+#include <drm/drm_simple_kms_helper.h>
+
+#include "intel_vip_drv.h"
+
+static void intelvipfb_enable(struct drm_simple_display_pipe

*pipe,

drivers/gpu/drm/ivip/intel_vip_core.c new file +4 -0
+	struct drm_crtc_state *crtc_state)
+{
+	/*
+	 * The frameinfo variable has to correspond to the size of
Quoted 1 line

the VIP

Suite

Quoted 32 lines
drivers/gpu/drm/ivip/intel_vip_core.c new file +1 -0
+	 * Frame Reader register 7 which will determine the

maximum size used

drivers/gpu/drm/ivip/intel_vip_core.c new file +5 -0
+	 * in this frameinfo
+	 */
+
+	u32 frameinfo;
+	struct intelvipfb_priv *priv = pipe->plane.dev-
Quoted 1 line

dev_private;

drivers/gpu/drm/ivip/intel_vip_core.c new file +10 -0
+	void __iomem *base = priv->base;
+	struct drm_plane_state *state = pipe->plane.state;
+	dma_addr_t addr;
+
+	addr = drm_fb_cma_get_gem_addr(state->fb, state, 0);
+
+	dev_info(pipe->plane.dev->dev, "Address 0x%x\n", addr);
+
+	frameinfo =
+		  readl(base + INTELVIPFB_FRAME_READER) &

0x00ffffff;

drivers/gpu/drm/ivip/intel_vip_core.c new file +3 -0
+	writel(frameinfo, base + INTELVIPFB_FRAME_INFO);
+	writel(addr, base + INTELVIPFB_FRAME_START);
+	/* Finally set the control register to 1 to start

streaming */

drivers/gpu/drm/ivip/intel_vip_core.c new file +4 -0
+	writel(1, base + INTELVIPFB_CONTROL);
+}
+
+static void intelvipfb_disable(struct drm_simple_display_pipe

*pipe)

drivers/gpu/drm/ivip/intel_vip_core.c new file +2 -0
+{
+	struct intelvipfb_priv *priv = pipe->plane.dev-
Quoted 1 line

dev_private;

drivers/gpu/drm/ivip/intel_vip_core.c

Quoted 1 line
drivers/gpu/drm/ivip/intel_vip_core.c new file +1 -0
+	void __iomem *base = priv->base;

Missing blank line.

Quoted 35 lines
drivers/gpu/drm/ivip/intel_vip_core.c new file +5 -0
+	/* set the control register to 0 to stop streaming */
+	writel(0, base + INTELVIPFB_CONTROL);
+}
+
+static const struct drm_mode_config_funcs

intelvipfb_mode_config_funcs = {

drivers/gpu/drm/ivip/intel_vip_core.c new file +12 -0
+	.fb_create = drm_fb_cma_create,
+	.atomic_check = drm_atomic_helper_check,
+	.atomic_commit = drm_atomic_helper_commit,
+};
+
+static void intelvipfb_setup_mode_config(struct drm_device *drm)
+{
+	drm_mode_config_init(drm);
+	drm->mode_config.funcs = &intelvipfb_mode_config_funcs;
+}
+
+static int intelvipfb_pipe_prepare_fb(struct

drm_simple_display_pipe *pipe,

drivers/gpu/drm/ivip/intel_vip_core.c new file +6 -0
+		struct drm_plane_state *plane_state)
+{
+	return drm_fb_cma_prepare_fb(&pipe->plane, plane_state);
+}
+
+static void intelvipfb_update(struct drm_simple_display_pipe

*pipe,

drivers/gpu/drm/ivip/intel_vip_core.c new file +7 -0
+		struct drm_plane_state *old_state)
+{
+	struct drm_crtc *crtc = &pipe->crtc;
+
+	if (crtc->state->event) {
+		spin_lock_irq(&crtc->dev->event_lock);
+		drm_crtc_send_vblank_event(crtc, crtc->state-
Quoted 1 line

event);

drivers/gpu/drm/ivip/intel_vip_core.c line 103

Quoted 3 lines
drivers/gpu/drm/ivip/intel_vip_core.c new file +3 -0
+		spin_unlock_irq(&crtc->dev->event_lock);
+		crtc->state->event = NULL;
+	}

This is not quite right. Userspace expects the driver to perform a page flip
here, and you just signal page flip completion without doing anything.

drivers/gpu/drm/ivip/intel_vip_core.c line 113

Quoted 11 lines
drivers/gpu/drm/ivip/intel_vip_core.c new file +10 -0
+}
+
+static struct drm_simple_display_pipe_funcs fbpriv_funcs = {
+	.prepare_fb = intelvipfb_pipe_prepare_fb,
+	.update = intelvipfb_update,
+	.enable = intelvipfb_enable,
+	.disable = intelvipfb_disable
+};
+
+int intelvipfb_probe(struct device *dev, void __iomem *base)

You don't use the base argument, you can remove it.

drivers/gpu/drm/ivip/intel_vip_core.c line 119

Quoted 7 lines
drivers/gpu/drm/ivip/intel_vip_core.c new file +6 -0
+{
+	int retval;
+	struct drm_device *drm;
+	struct intelvipfb_priv *fbpriv = dev_get_drvdata(dev);
+	struct drm_connector *connector;
+

Extra blank line.

drivers/gpu/drm/ivip/intel_vip_core.c line 122

Quoted 4 lines
drivers/gpu/drm/ivip/intel_vip_core.c new file +3 -0
+	u32 formats[] = {DRM_FORMAT_XRGB8888};
+
+	dev_set_drvdata(dev, fbpriv);

As fbpriv is obtained by a call to dev_get_drvdata(), this isn't needed.

A better option would be to pass the intelvipfb_priv pointer as an argument to
this function.

Quoted 28 lines
drivers/gpu/drm/ivip/intel_vip_core.c new file +17 -0
+	drm = fbpriv->drm;
+
+	drm->dev_private = fbpriv;
+
+	intelvipfb_setup_mode_config(drm);
+
+	connector = intelvipfb_conn_setup(drm);
+	if (!connector) {
+		dev_err(drm->dev, "Connector setup failed\n");
+		goto err_mode_config;
+	}
+
+	retval = drm_simple_display_pipe_init(drm, &fbpriv->pipe,
+		&fbpriv_funcs, formats,
+		ARRAY_SIZE(formats), connector);
+	if (retval < 0) {
+		dev_err(drm->dev, "Cannot setup simple display

pipe\n");

drivers/gpu/drm/ivip/intel_vip_core.c new file +9 -0
+		goto err_mode_config;
+	}
+
+	fbpriv->fbcma = drm_fbdev_cma_init(drm,
+		drm->mode_config.preferred_depth,
+		drm->mode_config.num_connector);
+
+	drm_mode_config_reset(drm);
+

drivers/gpu/drm/ivip/intel_vip_core.c line 159

Quoted 10 lines
drivers/gpu/drm/ivip/intel_vip_core.c new file +10 -0
+	drm_dev_register(drm, 0);
+
+	return retval;
+
+err_mode_config:
+
+	drm_mode_config_cleanup(drm);
+	return -ENODEV;
+}
+EXPORT_SYMBOL_GPL(intelvipfb_probe);

Why do you need to export this symbol ?

Quoted 6 lines
drivers/gpu/drm/ivip/intel_vip_core.c new file +5 -0
+int intelvipfb_remove(struct device *dev)
+{
+	struct intelvipfb_priv *fbpriv = dev_get_drvdata(dev);
+	struct drm_device *drm =  fbpriv->drm;
+

drivers/gpu/drm/ivip/intel_vip_core.c line 175

Quoted 10 lines
drivers/gpu/drm/ivip/intel_vip_core.c new file +10 -0
+	drm_dev_unregister(drm);
+
+	if (fbpriv->fbcma)
+		drm_fbdev_cma_fini(fbpriv->fbcma);
+
+	drm_mode_config_cleanup(drm);
+
+	drm_dev_unref(drm);
+
+	devm_kfree(dev, fbpriv);

The whole point of devm_kzalloc() is that you don't need to free the memory at
remove time.

Quoted 42 lines
drivers/gpu/drm/ivip/intel_vip_core.c new file +8 -0
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(intelvipfb_remove);
+
+MODULE_AUTHOR("Ong, Hean-Loong <[email protected]>");
+MODULE_DESCRIPTION("Intel VIP Frame Buffer II driver");
+MODULE_LICENSE("GPL v2");
(quoted diff) +0 -0

b/drivers/gpu/drm/ivip/intel_vip_drv.h new file mode 100644 index 0000000..ebdbd50

drivers/gpu/drm/ivip/intel_vip_drv.h new file +6 -0
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2017 Intel Corporation.
+ *
+ * Intel Video and Image Processing(VIP) Frame Buffer II driver.
+ *
+ * This program is free software; you can redistribute it and/or

modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for + * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
with + * this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ * Ong, Hean-Loong <[email protected]>
+ *
+ */

drivers/gpu/drm/ivip/intel_vip_drv.h line 23

Quoted 2 lines
drivers/gpu/drm/ivip/intel_vip_drv.h new file +2 -0
+#ifndef _INTEL_VIP_DRV_H
+#define _INTEL_VIP_DRV_H

Missing blank line.

drivers/gpu/drm/ivip/intel_vip_drv.h line 25

Quoted 3 lines
drivers/gpu/drm/ivip/intel_vip_drv.h new file +2 -0
+#include <linux/io.h>
+#include <linux/fb.h>

I don't think this header is needed.

Quoted 64 lines
drivers/gpu/drm/ivip/intel_vip_drv.h new file +19 -0
+#define DRIVER_NAME    "intelvipfb"
+#define BYTES_PER_PIXEL        4
+#define CRTC_NUM               1
+#define CONN_NUM               1
+
+/* control registers */
+#define INTELVIPFB_CONTROL             0
+#define INTELVIPFB_STATUS              0x4
+#define INTELVIPFB_INTERRUPT           0x8
+#define INTELVIPFB_FRAME_COUNTER       0xC
+#define INTELVIPFB_FRAME_DROP          0x10
+#define INTELVIPFB_FRAME_INFO          0x14
+#define INTELVIPFB_FRAME_START         0x18
+#define INTELVIPFB_FRAME_READER                0x1C
+
+int intelvipfb_probe(struct device *dev, void __iomem *base);
+int intelvipfb_remove(struct device *dev);
+int intelvipfb_setup_crtc(struct drm_device *drm);
+struct drm_connector *intelvipfb_conn_setup(struct drm_device

*drm);

drivers/gpu/drm/ivip/intel_vip_drv.h new file +9 -0
+
+struct intelvipfb_priv {
+	struct drm_simple_display_pipe pipe;
+	struct drm_fbdev_cma *fbcma;
+	struct drm_device *drm;
+	void    __iomem *base;
+};
+
+#endif
(quoted diff) +0 -0

b/drivers/gpu/drm/ivip/intel_vip_of.c new file mode 100644 index 0000000..5a7c63b

drivers/gpu/drm/ivip/intel_vip_of.c new file +10 -0
@@ -0,0 +1,204 @@
+/*
+ * intel_vip_of.c -- Intel Video and Image Processing(VIP)
+ * Frame Buffer II driver
+ *
+ * This driver supports the Intel VIP Frame Reader component.
+ * More info on the hardware can be found in the Intel Video
+ * and Image Processing Suite User Guide at this address
+ * http://www.altera.com/literature/ug/ug_vip.pdf.
+ *
+ * This program is free software; you can redistribute it and/or

modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for
+ * more details.
+ *
+ * Authors:
+ * Ong, Hean-Loong <[email protected]>
+ *
+ */

drivers/gpu/drm/ivip/intel_vip_of.c line 25

Quoted 3 lines
drivers/gpu/drm/ivip/intel_vip_of.c new file +3 -0
+
+#include <linux/component.h>
+#include <linux/fb.h>

I don't think those two headers are needed.

drivers/gpu/drm/ivip/intel_vip_of.c line 35

Quoted 11 lines
drivers/gpu/drm/ivip/intel_vip_of.c new file +10 -0
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+
+#include <drm/drm_fb_helper.h>
+#include <drm/drm_of.h>
+#include <drm/drm_fb_cma_helper.h>
+#include <drm/drm_gem_cma_helper.h>
+#include <drm/drm_simple_kms_helper.h>

Please sort these alphabetically.

Quoted 73 lines
drivers/gpu/drm/ivip/intel_vip_of.c new file +27 -0
+
+#include "intel_vip_drv.h"
+
+DEFINE_DRM_GEM_CMA_FOPS(drm_fops);
+
+static void intelvipfb_lastclose(struct drm_device *drm)
+{
+	struct intelvipfb_priv *priv = drm->dev_private;
+
+	drm_fbdev_cma_restore_mode(priv->fbcma);
+}
+
+static struct drm_driver intelvipfb_drm = {
+	.driver_features =
+		DRIVER_MODESET | DRIVER_GEM |
+		DRIVER_PRIME | DRIVER_ATOMIC,
+	.gem_free_object_unlocked = drm_gem_cma_free_object,
+	.gem_vm_ops = &drm_gem_cma_vm_ops,
+	.dumb_create = drm_gem_cma_dumb_create,
+	.dumb_map_offset = drm_gem_cma_dumb_map_offset,
+	.dumb_destroy = drm_gem_dumb_destroy,
+	.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
+	.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
+	.gem_prime_export = drm_gem_prime_export,
+	.gem_prime_import = drm_gem_prime_import,
+	.gem_prime_get_sg_table = drm_gem_cma_prime_get_sg_table,
+	.gem_prime_import_sg_table =

drm_gem_cma_prime_import_sg_table,

drivers/gpu/drm/ivip/intel_vip_of.c new file +44 -0
+	.gem_prime_vmap = drm_gem_cma_prime_vmap,
+	.gem_prime_vunmap = drm_gem_cma_prime_vunmap,
+	.gem_prime_mmap = drm_gem_cma_prime_mmap,
+	.lastclose = intelvipfb_lastclose,
+	.name = DRIVER_NAME,
+	.date = "20170729",
+	.desc = "Intel FPGA VIP SUITE",
+	.major = 1,
+	.minor = 0,
+	.ioctls = NULL,
+	.patchlevel = 0,
+	.fops = &drm_fops,
+};
+
+/*
+ * Setting up information derived from OF Device Tree Nodes
+ * max-width, max-height, bits per pixel, memory port width
+ */
+
+static int intelvipfb_drm_setup(struct device *dev,
+			struct intelvipfb_priv *fbpriv)
+{
+	struct drm_device *drm = fbpriv->drm;
+	struct device_node *np = dev->of_node;
+	int mem_word_width;
+	int max_h, max_w;
+	int bpp;
+	int ret;
+
+	ret = of_property_read_u32(np, "altr,max-width", &max_w);
+	if (ret) {
+		dev_err(dev,
+		"Missing required parameter 'altr,max-width'");
+		return ret;
+	}
+
+	ret = of_property_read_u32(np, "altr,max-height", &max_h);
+	if (ret) {
+		dev_err(dev,
+		"Missing required parameter 'altr,max-height'");
+		return ret;
+	}
+
+	ret = of_property_read_u32(np, "altr,bits-per-symbol",
Quoted 1 line

&bpp);

This property is not documented in patch 1/3.

drivers/gpu/drm/ivip/intel_vip_of.c

Quoted 9 lines
drivers/gpu/drm/ivip/intel_vip_of.c new file +3 -0
+	if (ret) {
+		dev_err(dev,
+		"Missing required parameter 'altr,bits-per-

symbol'");

drivers/gpu/drm/ivip/intel_vip_of.c new file +4 -0
+		return ret;
+	}
+
+	ret = of_property_read_u32(np, "altr,mem-port-width", 

&mem_word_width);

Quoted 4 lines
drivers/gpu/drm/ivip/intel_vip_of.c new file +2 -0
+	if (ret) {
+		dev_err(dev, "Missing required parameter

'altr,mem-port-width

'");

Quoted 8 lines
drivers/gpu/drm/ivip/intel_vip_of.c new file +6 -0
+		return ret;
+	}
+
+	if (!(mem_word_width >= 32 && mem_word_width % 32 == 0)) {
+		dev_err(dev,
+		"mem-word-width is set to %i. must be >= 32 and

multiple of

32.",

Quoted 1 line
Quoted 12 lines

drivers/gpu/drm/ivip/intel_vip_of.c line 133

Quoted 12 lines
drivers/gpu/drm/ivip/intel_vip_of.c new file +12 -0
+		mem_word_width);
+		return -ENODEV;
+	}
+
+	drm->mode_config.min_width = 640;
+	drm->mode_config.min_height = 480;
+	drm->mode_config.max_width = max_w;
+	drm->mode_config.max_height = max_h;
+	drm->mode_config.preferred_depth = bpp * BYTES_PER_PIXEL;
+
+	return 0;
+}

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel