Skip to contentSkip to conversation

Overview of Arm komeda display driver

PATCH Superseded james qian wang (Arm Technology China) 2 participants 12 messages Dec 5, 2018 – Dec 10, 2018

Subsystems (6)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover Overview of Arm komeda display driver

This is the first patchset of ARM new komeda display driver, this patchset added all basic structure of komeda, relationship of DRM-KMS with komeda, for tring to give a brife overview of komeda-driver.

komeda is for supporting the ARM display processor D71 and later IPs, Since from D71, Arm display IP begins to adopt a flexible and modularized architecture:
A display pipeline is made up of multiple individual and functional pipeline stages called components, and every component has some specific capabilities that can give the flowed pipeline pixel data a specific data processing.

The typical components like:

- Layer:
Layer is the first pipeline stage, It fetches the pixel from memory and prepare the source pixel data for the next stage, like rotation, format, color-space handling.

- Scaler:
As its name, scaler is for scaling and image enhancement.

- Compositor (compiz)
Compositor is for blending multiple layers or pixel data flows into one single display frame.

- Writeback Layer (wb_layer)
Writeback layer do the opposite things of Layer, Which connect to compiz for writing the composition result to memory.

- Post image processor (improc)
Post image processor is for adjusting frame data like gamma and color space to fit the requirements of the monitor.

- Timing controller (timing_ctrlr)
Final stage of display pipeline, Timing controller is not for the pixel handling, but only for controlling the display timing.

Benefit from the modularized architecture, D71 pipelines can be easily adjusted to fit different usages, two D71 pipelines can work independently and separately

- Single pipeline mode

  Layer_0 -> (scaler) ->\
  Layer_1 -> (scaler) ->\          /-> (scaler) -> wb_layer -> memory
                          compiz ->
  Layer_2 -> (scaler) ->/          \-> improc ->timing_ctrlr ->monitor
  Layer_3 -> (scaler) ->/

Or work together to drive only one display output. On this mode, the compositor output of pipeline_B will be merged into pipeline_A as an input of compositor of pipeline_A, then pipeline_B doesn't has its output and work as a slave of pipeline_A.

- Slave enabled data flow

  Layer_0 -> (scaler) ->\
  Layer_1 -> (scaler) ->\
                         compiz_B -> compiz_A
  Layer_2 -> (scaler) ->/
  Layer_3 -> (scaler) ->/
             compiz_B ->\
  Layer_4 -> (scaler) ->\
  Layer_5 -> (scaler) ->\            /-> (scaler) -> wb_layer -> memory
                          compiz_A ->

Layer_6 -> (scaler) ->/ \-> improc ->timing_ctrlr ->monitor
Layer_7 -> (scaler) ->/

To fully utilize and easily access/configure the HW, komeda use similar
architecture: Pipeline/Component to describe the HW features and capabilities. Add the DRM-KMS consideration. then:

A Komeda driver is comprised of two layers of data structures:

1. komeda_dev/pipeline/component
which are used by komeda driver to describe and abstract a display HW.
- komeda_layer/scaler/compiz/improc/timing_ctrlr
for describing a specific pipeline component stage.
- komeda_pipeline
for abstracting a display pipeline and the pipeline is composed of multiple components.
- komeda_dev
for the whole view of the device, manage the pipeline, irq, and the other control-abilites of device.

2. komeda_kms_dev/crtc/plane:
which connect Komeda-dev to DRM-KMS, basically it collects and organizes komeda_dev's capabilites and resurces by DRM-KMS's way (crtc/plane/connector), and convert the DRM-KMS's requirement to the real komeda_dev's configuration.

So generally, the komeda_dev is like a resource collection, and the komeda_kms is a group of users (crtc/plane/wb_connector), the drm_state defined or described the resource requirement of user, and every KMS-OBJ maps or represents to a specific komeda data pipeline:

- Plane: Layer -> (Scaler) -> Compiz
- Wb_connector: Compiz-> (scaler) -> Wb_layer -> memory
- Crtc: Compiz -> Improc -> Timing_Ctrlr -> Monitor

The features and properties of KMS-OBJ based on the mapping pipeline, and the komeda_kms level function (crtc/plane/wb_connector->atomic_check) actually is for pickuping suitable pipeline and component resources, configure them to a specific state and build these input/output pipeline of komeda to fit the requirement.

Furthermore, To support multiple IPs, komeda_dev has been split into two layers:

- Komeda-CORE or common layer.
for the common feature validation and handling
- Komeda-CHIP.
for reporting and exposing the HW resource by CORE's way, the HW register programming and updating.

With this two Layer's device abstraction, the most operations are handled in Komeda-CORE, the Komeda-CHIP is only for CHIP-specific stuff, easy for adding new chipset or IP in future.

James (Qian) Wang (9):
drm/komeda: komeda_dev/pipeline/component definition and initialzation dt/bindings: drm/komeda: Add DT bindings for ARM display processor D71 drm/komeda: Build komeda to be a platform module drm/komeda: Add DT parsing
drm/komeda: Add komeda_format_caps for format handling drm/komeda: Add komeda_framebuffer
drm/komeda: Attach komeda_dev to DRM-KMS
drm/doc: Add initial komeda driver documentation
MAINTAINERS: Add maintainer for arm komeda driver

 .../bindings/display/arm/arm,komeda.txt       |  87 ++++
 Documentation/gpu/drivers.rst                 |   1 +
 Documentation/gpu/komeda-kms.rst              | 483 ++++++++++++++++++
 MAINTAINERS                                   |   8 +
 drivers/gpu/drm/arm/Kconfig                   |   2 +
 drivers/gpu/drm/arm/Makefile                  |   1 +
 drivers/gpu/drm/arm/display/Kbuild            |   3 +
 drivers/gpu/drm/arm/display/Kconfig           |  14 +
 .../gpu/drm/arm/display/include/malidp_io.h   |  42 ++
 .../drm/arm/display/include/malidp_product.h  |  23 +
 .../drm/arm/display/include/malidp_utils.h    |  16 +
 drivers/gpu/drm/arm/display/komeda/Makefile   |  21 +
 .../gpu/drm/arm/display/komeda/d71/d71_dev.c  | 111 ++++
 .../gpu/drm/arm/display/komeda/komeda_crtc.c  | 106 ++++
 .../gpu/drm/arm/display/komeda/komeda_dev.c   | 193 +++++++
 .../gpu/drm/arm/display/komeda/komeda_dev.h   | 113 ++++
 .../gpu/drm/arm/display/komeda/komeda_drv.c   | 144 ++++++
 .../arm/display/komeda/komeda_format_caps.c   |  75 +++
 .../arm/display/komeda/komeda_format_caps.h   |  89 ++++
 .../arm/display/komeda/komeda_framebuffer.c   | 165 ++++++
 .../arm/display/komeda/komeda_framebuffer.h   |  31 ++
 .../gpu/drm/arm/display/komeda/komeda_kms.c   | 168 ++++++
 .../gpu/drm/arm/display/komeda/komeda_kms.h   | 113 ++++
 .../drm/arm/display/komeda/komeda_pipeline.c  | 202 ++++++++
 .../drm/arm/display/komeda/komeda_pipeline.h  | 356 +++++++++++++
 .../gpu/drm/arm/display/komeda/komeda_plane.c | 109 ++++
 .../arm/display/komeda/komeda_private_obj.c   |  87 ++++
 27 files changed, 2763 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/display/arm/arm,komeda.txt
 create mode 100644 Documentation/gpu/komeda-kms.rst
 create mode 100644 drivers/gpu/drm/arm/display/Kbuild
 create mode 100644 drivers/gpu/drm/arm/display/Kconfig
 create mode 100644 drivers/gpu/drm/arm/display/include/malidp_io.h
 create mode 100644 drivers/gpu/drm/arm/display/include/malidp_product.h
 create mode 100644 drivers/gpu/drm/arm/display/include/malidp_utils.h
 create mode 100644 drivers/gpu/drm/arm/display/komeda/Makefile
 create mode 100644 drivers/gpu/drm/arm/display/komeda/d71/d71_dev.c
 create mode 100644 drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
 create mode 100644 drivers/gpu/drm/arm/display/komeda/komeda_dev.c
 create mode 100644 drivers/gpu/drm/arm/display/komeda/komeda_dev.h
 create mode 100644 drivers/gpu/drm/arm/display/komeda/komeda_drv.c
 create mode 100644 drivers/gpu/drm/arm/display/komeda/komeda_format_caps.c
 create mode 100644 drivers/gpu/drm/arm/display/komeda/komeda_format_caps.h
 create mode 100644 drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c
 create mode 100644 drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.h
 create mode 100644 drivers/gpu/drm/arm/display/komeda/komeda_kms.c
 create mode 100644 drivers/gpu/drm/arm/display/komeda/komeda_kms.h
 create mode 100644 drivers/gpu/drm/arm/display/komeda/komeda_pipeline.c
 create mode 100644 drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h
 create mode 100644 drivers/gpu/drm/arm/display/komeda/komeda_plane.c
 create mode 100644 drivers/gpu/drm/arm/display/komeda/komeda_private_obj.c

--
2.17.1

#1 lore raw

PATCH 1/9 drm/komeda: komeda_dev/pipeline/component definition and initialzation

1. Added a brief definition of komeda_dev/pipeline/component, this change didn't add the detailed component features and capabilities, which will be added in the following changes.
2. Corresponding resources discovery and initialzation functions.

---
 drivers/gpu/drm/arm/Kconfig                   |   2 +
 drivers/gpu/drm/arm/Makefile                  |   1 +
 drivers/gpu/drm/arm/display/Kbuild            |   3 +
 drivers/gpu/drm/arm/display/Kconfig           |  14 +
 .../drm/arm/display/include/malidp_product.h  |  23 ++
 .../drm/arm/display/include/malidp_utils.h    |  16 +
 drivers/gpu/drm/arm/display/komeda/Makefile   |  11 +
 .../gpu/drm/arm/display/komeda/komeda_dev.c   | 117 ++++++
 .../gpu/drm/arm/display/komeda/komeda_dev.h   |  99 +++++
 .../drm/arm/display/komeda/komeda_pipeline.c  | 198 ++++++++++
 .../drm/arm/display/komeda/komeda_pipeline.h  | 345 ++++++++++++++++++
 11 files changed, 829 insertions(+)
 create mode 100644 drivers/gpu/drm/arm/display/Kbuild
 create mode 100644 drivers/gpu/drm/arm/display/Kconfig
 create mode 100644 drivers/gpu/drm/arm/display/include/malidp_product.h
 create mode 100644 drivers/gpu/drm/arm/display/include/malidp_utils.h
 create mode 100644 drivers/gpu/drm/arm/display/komeda/Makefile
 create mode 100644 drivers/gpu/drm/arm/display/komeda/komeda_dev.c
 create mode 100644 drivers/gpu/drm/arm/display/komeda/komeda_dev.h
 create mode 100644 drivers/gpu/drm/arm/display/komeda/komeda_pipeline.c
 create mode 100644 drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h
drivers/gpu/drm/arm/Kconfig +2 -0
index f9f7761cb2f4..a204103b3efb 100644
@@ -37,4 +37,6 @@ config DRM_MALI_DISPLAY
 
 	  If compiled as a module it will be called mali-dp.
 
+source "drivers/gpu/drm/arm/display/Kconfig"
+
 endmenu
drivers/gpu/drm/arm/Makefile +1 -0
index 3bf31d1a4722..120bef801fcf 100644
@@ -3,3 +3,4 @@ obj-$(CONFIG_DRM_HDLCD)	+= hdlcd.o
 mali-dp-y := malidp_drv.o malidp_hw.o malidp_planes.o malidp_crtc.o
 mali-dp-y += malidp_mw.o
 obj-$(CONFIG_DRM_MALI_DISPLAY)	+= mali-dp.o
+obj-$(CONFIG_DRM_KOMEDA) += display/
drivers/gpu/drm/arm/display/Kbuild new file +3 -0
new file mode 100644
index 000000000000..c78cd42f7c75
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0
+
+obj-$(CONFIG_DRM_KOMEDA) += komeda/
\ No newline at end of file
drivers/gpu/drm/arm/display/Kconfig new file +14 -0
new file mode 100644
index 000000000000..cec0639e3aa1
@@ -0,0 +1,14 @@
+# SPDX-License-Identifier: GPL-2.0
+config DRM_KOMEDA
+	tristate "ARM Komeda display driver"
+	depends on DRM && OF
+	depends on COMMON_CLK
+	select DRM_KMS_HELPER
+	select DRM_KMS_CMA_HELPER
+	select DRM_GEM_CMA_HELPER
+	select VIDEOMODE_HELPERS
+	help
+	  Choose this option if you want to compile the ARM Komeda display
+	  Processor driver. It supports the D71 variants of the hardware.
+
+	  If compiled as a module it will be called komeda.
drivers/gpu/drm/arm/display/include/malidp_product.h new file +23 -0
new file mode 100644
index 000000000000..b35fc5db866b
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * (C) COPYRIGHT 2018 ARM Limited. All rights reserved.
+ * Author: James.Qian.Wang <[email protected]>
+ *
+ */
+#ifndef _MALIDP_PRODUCT_H_
+#define _MALIDP_PRODUCT_H_
+
+/* Product identification */
+#define MALIDP_CORE_ID(__product, __major, __minor, __status) \
+	((((__product) & 0xFFFF) << 16) | (((__major) & 0xF) << 12) | \
+	(((__minor) & 0xF) << 8) | ((__status) & 0xFF))
+
+#define MALIDP_CORE_ID_PRODUCT_ID(__core_id) ((__u32)(__core_id) >> 16)
+#define MALIDP_CORE_ID_MAJOR(__core_id)      (((__u32)(__core_id) >> 12) & 0xF)
+#define MALIDP_CORE_ID_MINOR(__core_id)      (((__u32)(__core_id) >> 8) & 0xF)
+#define MALIDP_CORE_ID_STATUS(__core_id)     (((__u32)(__core_id)) & 0xFF)
+
+/* Mali-display product IDs */
+#define MALIDP_D71_PRODUCT_ID   0x0071
+
+#endif /* _MALIDP_PRODUCT_H_ */
drivers/gpu/drm/arm/display/include/malidp_utils.h new file +16 -0
new file mode 100644
index 000000000000..93d7725fe1c5
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * (C) COPYRIGHT 2018 ARM Limited. All rights reserved.
+ * Author: James.Qian.Wang <[email protected]>
+ *
+ */
+#ifndef _MALIDP_UTILS_
+#define _MALIDP_UTILS_
+
+#define has_bit(nr, mask)	(BIT(nr) & (mask))
+#define has_bits(bits, mask)	(((bits) & (mask)) == (bits))
+
+#define dp_for_each_set_bit(bit, mask) \
+	for_each_set_bit((bit), ((unsigned long *)(&mask)), sizeof(mask) * 8)
+
+#endif /* _MALIDP_UTILS_ */
drivers/gpu/drm/arm/display/komeda/Makefile new file +11 -0
new file mode 100644
index 000000000000..07b5965f3808
@@ -0,0 +1,11 @@
+# SPDX-License-Identifier: GPL-2.0
+
+ccflags-y := \
+	-I$(src)/../include \
+	-I$(src)
+
+komeda-y := \
+	komeda_dev.o \
+	komeda_pipeline.o \
+
+obj-$(CONFIG_DRM_KOMEDA) += komeda.o
\ No newline at end of file
drivers/gpu/drm/arm/display/komeda/komeda_dev.c new file +117 -0

117 lines not on this page · raw message

drivers/gpu/drm/arm/display/komeda/komeda_dev.h new file +99 -0

99 lines not on this page · raw message

drivers/gpu/drm/arm/display/komeda/komeda_pipeline.c new file +198 -0

198 lines not on this page · raw message

drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h new file +345 -0

345 lines not on this page · raw message

Signature · 1 line
2.17.1
#2 lore raw

PATCH 2/9 dt/bindings: drm/komeda: Add DT bindings for ARM display processor D71

In reply to james qian wang (Arm Technology China)

Add DT bindings documentation for the ARM display processor D71 and later IPs.

---
 .../bindings/display/arm/arm,komeda.txt       | 87 +++++++++++++++++++
 1 file changed, 87 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/display/arm/arm,komeda.txt
Documentation/devicetree/bindings/display/arm/arm,komeda.txt new file +87 -0
new file mode 100644
index 000000000000..d4b53c11b2a2
@@ -0,0 +1,87 @@
+Device Tree bindings for ARM Komeda display driver
+
+Required properties:
+- compatible: Should be "arm,mali-d71"
+- reg: Physical base address and length of the registers in the system
+- interrupts: the interrupt line numbers of the device in the system
+- interrupt-names: contains the names of the IRQs in the order they were
+    provided in the "interrupts" property. Must contain: "DPU".
+- clocks: A list of phandle + clock-specifier pairs, one for each entry
+    in 'clock-names'
+- clock-names: A list of clock names. It should contain:
+      - "pclk": for the APB interface clock
+      - "mclk": for the main processor clock
+- #address-cells: Must be 1
+- #size-cells: Must be 0
+
+Required properties for sub-node: pipeline@nq
+Each device contains one or two pipeline sub-nodes (at least one), each
+pipeline node should provide properties:
+- reg: Zero-indexed identifier for the pipeline
+- clocks: A list of phandle + clock-specifier pairs, one for each entry
+    in 'clock-names'
+- clock-names: should contain:
+      - "aclk": AXI interface clock
+      - "pxclk": pixel clock
+
+- port: each pipeline connect to an encoder input port. The connection is
+    modelled using the OF graph bindings specified in
+    Documentation/devicetree/bindings/graph.txt
+
+Optional properties:
+  - memory-region: phandle to a node describing memory (see
+    Documentation/devicetree/bindings/reserved-memory/reserved-memory.txt)
+    to be used for the framebuffer; if not present, the framebuffer may
+    be located anywhere in memory.
+
+Example:
+/ {
+	...
+
+	dp0: display@c00000 {
+		#address-cells = <1>;
+		#size-cells = <0>;
+		compatible = "arm,mali-d71";
+		reg = <0xc00000 0x20000>;
+		interrupts = <0 168 4>;
+		interrupt-names = "DPU";
+		clocks = <&dpu_mclk>, <&dpu_aclk>;
+		clock-names = "mclk", "pclk";
+
+		pl0: pipeline@0 {
+			clocks = <&fpgaosc2>, <&dpu_aclk>;
+			clock-names = "pxclk", "aclk";
+			reg = <0>;
+
+			ports {
+				#address-cells = <1>;
+				#size-cells = <0>;
+
+				port@0 {
+					reg = <0>;
+					dp0_pl0_out: endpoint {
+						remote-endpoint = <&db_dvi0_in>;
+					};
+				};
+			};
+		};
+		pl1: pipeline@1 {
+			clocks = <&fpgaosc2>, <&dpu_aclk>;
+			clock-names = "pxclk", "aclk";
+			reg = <1>;
+
+			ports {
+				#address-cells = <1>;
+				#size-cells = <0>;
+
+				port@0 {
+					reg = <0>;
+					dp0_pl1_out: endpoint {
+						remote-endpoint = <&db_dvi1_in>;
+					};
+				};
+			};
+		};
+	};
+	...
+};
Signature · 1 line
2.17.1
#3 lore raw

PATCH 3/9 drm/komeda: Build komeda to be a platform module

In reply to james qian wang (Arm Technology China)

Implement a simple wrapper for platform module to build komeda to module, Also add a very simple D71 layer code to show how to discover a product. Komeda driver direct bind the product ENTRY function xxx_identity to DT compatible name like:

d71_product = {
.product_id = MALIDP_D71_PRODUCT_ID,
.identify = d71_identify,
},

const struct of_device_id komeda_of_match[] = {
	{ .compatible = "arm,mali-d71", .data = &d71_product, },
	{},
};

Then when linux found a matched DT node and call driver to probe, we can easily get the of data, and call into the product to do the identify:

komeda_bind()

{
    ...
    product = of_device_get_match_data(dev);

    product->identify();
    ...
}
---
 .../gpu/drm/arm/display/include/malidp_io.h   |  42 ++++++
 drivers/gpu/drm/arm/display/komeda/Makefile   |   6 +-
 .../gpu/drm/arm/display/komeda/d71/d71_dev.c  |  33 +++++
 .../gpu/drm/arm/display/komeda/komeda_dev.h   |   4 +-
 .../gpu/drm/arm/display/komeda/komeda_drv.c   | 132 ++++++++++++++++++
 5 files changed, 215 insertions(+), 2 deletions(-)
 create mode 100644 drivers/gpu/drm/arm/display/include/malidp_io.h
 create mode 100644 drivers/gpu/drm/arm/display/komeda/d71/d71_dev.c
 create mode 100644 drivers/gpu/drm/arm/display/komeda/komeda_drv.c
drivers/gpu/drm/arm/display/include/malidp_io.h new file +42 -0
new file mode 100644
index 000000000000..4fb3caf864ce
@@ -0,0 +1,42 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * (C) COPYRIGHT 2018 ARM Limited. All rights reserved.
+ * Author: James.Qian.Wang <[email protected]>
+ *
+ */
+#ifndef _MALIDP_IO_H_
+#define _MALIDP_IO_H_
+
+#include <linux/io.h>
+
+static inline u32
+malidp_read32(u32 __iomem *base, u32 offset)
+{
+	return readl((base + (offset >> 2)));
+}
+
+static inline void
+malidp_write32(u32 __iomem *base, u32 offset, u32 v)
+{
+	writel(v, (base + (offset >> 2)));
+}
+
+static inline void
+malidp_write32_mask(u32 __iomem *base, u32 offset, u32 m, u32 v)
+{
+	u32 tmp = malidp_read32(base, offset);
+
+	tmp &= (~m);
+	malidp_write32(base, offset, v | tmp);
+}
+
+static inline void
+malidp_write_group(u32 __iomem *base, u32 offset, int num, const u32 *values)
+{
+	int i;
+
+	for (i = 0; i < num; i++)
+		malidp_write32(base, offset + i * 4, values[i]);
+}
+
+#endif /*_MALIDP_IO_H_*/
drivers/gpu/drm/arm/display/komeda/Makefile +5 -1
index 07b5965f3808..4efcce0cdce8 100644
@@ -5,7 +5,11 @@ ccflags-y := \
 	-I$(src)
 
 komeda-y := \
+	komeda_drv.o \
 	komeda_dev.o \
-	komeda_pipeline.o \
+	komeda_pipeline.o
+
+komeda-y += \
+	d71/d71_dev.o
 
 obj-$(CONFIG_DRM_KOMEDA) += komeda.o
\ No newline at end of file
drivers/gpu/drm/arm/display/komeda/d71/d71_dev.c new file +33 -0
new file mode 100644
index 000000000000..af3dabb499cd
@@ -0,0 +1,33 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * (C) COPYRIGHT 2018 ARM Limited. All rights reserved.
+ * Author: James.Qian.Wang <[email protected]>
+ *
+ */
+#include "malidp_io.h"
+#include "komeda_dev.h"
+
+static int d71_enum_resources(struct komeda_dev *mdev)
+{
+	/* TODO add enum resources */
+	return -1;
+}
+
+static struct komeda_dev_funcs d71_chip_funcs = {
+	.enum_resources	= d71_enum_resources,
+	.cleanup	= NULL,
+};
+
+#define GLB_ARCH_ID		0x000
+#define GLB_CORE_ID		0x004
+#define GLB_CORE_INFO		0x008
+
+struct komeda_dev_funcs *
+d71_identify(u32 __iomem *reg_base, struct komeda_chip_info *chip)
+{
+	chip->arch_id	= malidp_read32(reg_base, GLB_ARCH_ID);
+	chip->core_id	= malidp_read32(reg_base, GLB_CORE_ID);
+	chip->core_info	= malidp_read32(reg_base, GLB_CORE_INFO);
+
+	return &d71_chip_funcs;
+}
drivers/gpu/drm/arm/display/komeda/komeda_dev.h +3 -1
index 25c79528dac4..680e3e2cf100 100644
@@ -12,7 +12,6 @@
 #include "komeda_pipeline.h"
 #include "malidp_product.h"
 
-
 /* malidp device id */
 enum {
 	MALI_D71 = 0,
@@ -93,6 +92,9 @@ komeda_product_match(struct komeda_dev *mdev, u32 target)
 	return MALIDP_CORE_ID_PRODUCT_ID(mdev->chip.core_id) == target;
 }
 
+struct komeda_dev_funcs *
+d71_identify(u32 __iomem *reg, struct komeda_chip_info *chip);
+
 struct komeda_dev *komeda_dev_create(struct device *dev);
 void komeda_dev_destroy(struct komeda_dev *mdev);
 
drivers/gpu/drm/arm/display/komeda/komeda_drv.c new file +132 -0

132 lines not on this page · raw message

Signature · 1 line
2.17.1
#4 lore raw

PATCH 4/9 drm/komeda: Add DT parsing

In reply to james qian wang (Arm Technology China)

Parse DT and initialize corresponding dev/pipeline attributes.

---
 .../gpu/drm/arm/display/komeda/komeda_dev.c   | 74 +++++++++++++++++++
 .../gpu/drm/arm/display/komeda/komeda_dev.h   |  3 +
 .../drm/arm/display/komeda/komeda_pipeline.c  |  4 +
 .../drm/arm/display/komeda/komeda_pipeline.h  |  7 ++
 4 files changed, 88 insertions(+)
drivers/gpu/drm/arm/display/komeda/komeda_dev.c +74 -0
index 887a17005367..ace2db84cb1a 100644
@@ -12,6 +12,74 @@
 #include <linux/version.h>
 #include "komeda_dev.h"
 
+static int komeda_parse_ppl_dt(struct komeda_dev *mdev, struct device_node *np)
+{
+	struct komeda_pipeline *ppl;
+	struct clk *clk;
+	u32 pipe;
+	int ret = 0;
+
+	ret = of_property_read_u32(np, "reg", &pipe);
+	if (ret != 0 || pipe >= mdev->n_pipelines)
+		return -EINVAL;
+
+	ppl = mdev->pipelines[pipe];
+
+	clk = of_clk_get_by_name(np, "aclk");
+	if (IS_ERR(clk)) {
+		DRM_ERROR("get for aclk for pipeline %d failed!\n", pipe);
+		return PTR_ERR(clk);
+	}
+	ppl->aclk = clk;
+
+	clk = of_clk_get_by_name(np, "pxclk");
+	if (IS_ERR(clk)) {
+		DRM_ERROR("get for pxclk for pipeline %d failed!\n", pipe);
+		return PTR_ERR(clk);
+	}
+	ppl->pxlclk = clk;
+
+	/* enum ports */
+	ppl->of_output_dev  = of_graph_get_remote_node(np, KOMEDA_OF_PORT_OUTPUT, 0);
+	ppl->of_output_port = of_graph_get_port_by_id(np, KOMEDA_OF_PORT_OUTPUT);
+
+	ppl->of_node = np;
+
+	return 0;
+}
+
+static int komeda_parse_dt(struct device *dev, struct komeda_dev *mdev)
+{
+	struct platform_device *pdev = to_platform_device(dev);
+	struct device_node *child, *np = dev->of_node;
+	struct clk *clk;
+	int ret;
+
+	clk = devm_clk_get(dev, "mclk");
+	if (IS_ERR(clk))
+		return PTR_ERR(clk);
+
+	mdev->mclk = clk;
+	mdev->irq  = platform_get_irq_byname(pdev, "DPU");
+	if (mdev->irq < 0) {
+		DRM_ERROR("could not get IRQ number.\n");
+		return mdev->irq;
+	}
+
+	for_each_available_child_of_node(np, child) {
+		if (of_node_cmp(child->name, "pipeline") == 0) {
+			ret = komeda_parse_ppl_dt(mdev, child);
+			if (ret) {
+				DRM_ERROR("parse pipeline dt error!\n");
+				of_node_put(child);
+				break;
+			}
+		}
+	}
+
+	return ret;
+}
+
 struct komeda_dev *komeda_dev_create(struct device *dev)
 {
 	struct platform_device *pdev = to_platform_device(dev);
@@ -74,6 +142,12 @@ struct komeda_dev *komeda_dev_create(struct device *dev)
 		goto err_cleanup;
 	}
 
+	err = komeda_parse_dt(dev, mdev);
+	if (err) {
+		DRM_ERROR("parse device tree failed.\n");
+		goto err_cleanup;
+	}
+
 	return mdev;
 
 err_cleanup:
drivers/gpu/drm/arm/display/komeda/komeda_dev.h +3 -0
index 680e3e2cf100..4a27a44e2ec6 100644
@@ -72,6 +72,9 @@ struct komeda_dev {
 	/** @mck: HW main engine clk */
 	struct clk *mclk;
 
+	/** @irq: irq number */
+	u32 irq;
+
 	int n_pipelines;
 	struct komeda_pipeline *pipelines[KOMEDA_MAX_PIPELINES];
 
drivers/gpu/drm/arm/display/komeda/komeda_pipeline.c +4 -0
index 9a33f9d68bde..c1665c6dccc0 100644
@@ -55,6 +55,10 @@ void komeda_pipeline_destroy(struct komeda_dev *mdev,
 	clk_put(ppl->pxlclk);
 	clk_put(ppl->aclk);
 
+	of_node_put(ppl->of_output_dev);
+	of_node_put(ppl->of_output_port);
+	of_node_put(ppl->of_node);
+
 	devm_kfree(mdev->dev, ppl);
 }
 
drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h +7 -0
index 8759f54a4e09..506e5d1acf54 100644
@@ -286,6 +286,13 @@ struct komeda_pipeline {
 	struct komeda_improc *improc;
 	struct komeda_timing_ctrlr *ctrlr;
 	struct komeda_pipeline_funcs *funcs; /* private pipeline functions */
+
+	/** @of_node: pipeline dt node */
+	struct device_node *of_node;
+	/** @of_output_port: pipeline output port */
+	struct device_node *of_output_port;
+	/** @of_output_dev: output connector device node */
+	struct device_node *of_output_dev;
 };
 
 /**
Signature · 1 line
2.17.1
#5 lore raw

PATCH 5/9 drm/komeda: Add komeda_format_caps for format handling

In reply to james qian wang (Arm Technology China)

komeda_format_caps is for describing ARM display specific features and limitations of a specific format, and format_caps will be linked into &komeda_framebuffer like a extension of &drm_format_info.
And komed_format_caps_table will be initialized before the enum_resources, since the layer features description depend on this format_caps table, so we'd better initialize the table first.

---
 drivers/gpu/drm/arm/display/komeda/Makefile   |  1 +
 .../gpu/drm/arm/display/komeda/d71/d71_dev.c  | 78 ++++++++++++++++
 .../gpu/drm/arm/display/komeda/komeda_dev.c   |  2 +
 .../gpu/drm/arm/display/komeda/komeda_dev.h   | 11 ++-
 .../arm/display/komeda/komeda_format_caps.c   | 75 ++++++++++++++++
 .../arm/display/komeda/komeda_format_caps.h   | 89 +++++++++++++++++++
 .../drm/arm/display/komeda/komeda_pipeline.h  |  1 +
 7 files changed, 256 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/drm/arm/display/komeda/komeda_format_caps.c
 create mode 100644 drivers/gpu/drm/arm/display/komeda/komeda_format_caps.h
drivers/gpu/drm/arm/display/komeda/Makefile +1 -0
index 4efcce0cdce8..c86602131dbc 100644
@@ -7,6 +7,7 @@ ccflags-y := \
 komeda-y := \
 	komeda_drv.o \
 	komeda_dev.o \
+	komeda_format_caps.o \
 	komeda_pipeline.o
 
 komeda-y += \
drivers/gpu/drm/arm/display/komeda/d71/d71_dev.c +78 -0

85 lines not on this page · raw message

drivers/gpu/drm/arm/display/komeda/komeda_dev.c +2 -0
index ace2db84cb1a..eba7ba77391e 100644
@@ -136,6 +136,8 @@ struct komeda_dev *komeda_dev_create(struct device *dev)
 		 MALIDP_CORE_ID_MAJOR(mdev->chip.core_id),
 		 MALIDP_CORE_ID_MINOR(mdev->chip.core_id));
 
+	mdev->funcs->init_format_table(mdev);
+
 	err = mdev->funcs->enum_resources(mdev);
 	if (err) {
 		DRM_ERROR("enumerate display resource failed.\n");
drivers/gpu/drm/arm/display/komeda/komeda_dev.h +10 -1
index 4a27a44e2ec6..555510be66f1 100644
@@ -11,6 +11,7 @@
 #include <linux/interrupt.h>
 #include "komeda_pipeline.h"
 #include "malidp_product.h"
+#include "komeda_format_caps.h"
 
 /* malidp device id */
 enum {
@@ -44,6 +45,13 @@ struct komeda_dev;
  * Supplied by chip level and returned by the chip entry function xxx_identify,
  */
 struct komeda_dev_funcs {
+	/**
+	 * @init_format_table:
+	 *
+	 * initialize &komeda_dev->format_table, this function should be called
+	 * before the &enum_resource
+	 */
+	void (*init_format_table)(struct komeda_dev *mdev);
 	/**
 	 * @enum_resources:
 	 *
@@ -66,7 +74,8 @@ struct komeda_dev {
 	u32 __iomem   *reg_base;
 
 	struct komeda_chip_info chip;
-
+	/** @fmt_tbl: initialized by &komeda_dev_funcs->init_format_table */
+	struct komeda_format_caps_table fmt_tbl;
 	/** @pclk: APB clock for register access */
 	struct clk *pclk;
 	/** @mck: HW main engine clk */
drivers/gpu/drm/arm/display/komeda/komeda_format_caps.c new file +75 -0

76 lines not on this page · raw message

drivers/gpu/drm/arm/display/komeda/komeda_format_caps.h new file +89 -0

89 lines not on this page · raw message

drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h +1 -0
index 506e5d1acf54..0218762d2e53 100644
@@ -210,6 +210,7 @@ static inline u16 component_changed_inputs(struct komeda_component_state *st)
 struct komeda_layer {
 	struct komeda_component base;
 	/* layer specific features and caps */
+	int layer_type; /* RICH, SIMPLE or WB */
 };
 
 struct komeda_layer_state {
Signature · 1 line
2.17.1
#6 lore raw

PATCH 6/9 drm/komeda: Add komeda_framebuffer

In reply to james qian wang (Arm Technology China)

komeda_framebuffer is for extending drm_framebuffer to add komeda own attributes and komeda specific fb handling.

---
 drivers/gpu/drm/arm/display/komeda/Makefile   |   3 +-
 .../arm/display/komeda/komeda_framebuffer.c   | 165 ++++++++++++++++++
 .../arm/display/komeda/komeda_framebuffer.h   |  31 ++++
 3 files changed, 198 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c
 create mode 100644 drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.h
drivers/gpu/drm/arm/display/komeda/Makefile +2 -1
index c86602131dbc..d369317f72ab 100644
@@ -8,7 +8,8 @@ komeda-y := \
 	komeda_drv.o \
 	komeda_dev.o \
 	komeda_format_caps.o \
-	komeda_pipeline.o
+	komeda_pipeline.o \
+	komeda_framebuffer.o
 
 komeda-y += \
 	d71/d71_dev.o
drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c new file +165 -0

165 lines not on this page · raw message

drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.h new file +31 -0
new file mode 100644
index 000000000000..383780013bb9
@@ -0,0 +1,31 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * (C) COPYRIGHT 2018 ARM Limited. All rights reserved.
+ * Author: James.Qian.Wang <[email protected]>
+ *
+ */
+#ifndef _KOMEDA_FRAMEBUFFER_H_
+#define _KOMEDA_FRAMEBUFFER_H_
+
+/** struct komeda_fb - entend drm_framebuffer with komeda attribute */
+struct komeda_fb {
+	/** @base: &drm_framebuffer */
+	struct drm_framebuffer base;
+	/* @format_caps: &komeda_format_caps */
+	const struct komeda_format_caps *format_caps;
+	/** @aligned_w: aligned frame buffer width */
+	u32 aligned_w;
+	/** @aligned_h: aligned frame buffer height */
+	u32 aligned_h;
+};
+
+#define to_kfb(dfb)	container_of(dfb, struct komeda_fb, base)
+
+struct drm_framebuffer *
+komeda_fb_create(struct drm_device *dev, struct drm_file *file,
+		 const struct drm_mode_fb_cmd2 *mode_cmd);
+dma_addr_t
+komeda_fb_get_pixel_addr(struct komeda_fb *kfb, int x, int y, int plane);
+bool komeda_fb_is_layer_supported(struct komeda_fb *kfb, u32 layer_type);
+
+#endif
Signature · 1 line
2.17.1
#7 lore raw

PATCH 7/9 drm/komeda: Attach komeda_dev to DRM-KMS

In reply to james qian wang (Arm Technology China)

Add komeda_kms abstracton to attach komeda_dev to DRM-KMS
CRTC: according to the komeda_pipeline
PLANE: according to komeda_layer (layer input pipeline)
PRIVATE_OBJS: komeda_pipeline/component all will be treat as private_objs

komeda_kms is for connecting DRM-KMS and komeda_dev, like reporting the kms object properties according to the komeda_dev, and pass/convert KMS's requirement to komeda_dev.

---
 drivers/gpu/drm/arm/display/komeda/Makefile   |   6 +-
 .../gpu/drm/arm/display/komeda/komeda_crtc.c  | 106 +++++++++++
 .../gpu/drm/arm/display/komeda/komeda_drv.c   |  22 ++-
 .../gpu/drm/arm/display/komeda/komeda_kms.c   | 168 ++++++++++++++++++
 .../gpu/drm/arm/display/komeda/komeda_kms.h   | 113 ++++++++++++
 .../drm/arm/display/komeda/komeda_pipeline.h  |   3 +
 .../gpu/drm/arm/display/komeda/komeda_plane.c | 109 ++++++++++++
 .../arm/display/komeda/komeda_private_obj.c   |  87 +++++++++
 8 files changed, 608 insertions(+), 6 deletions(-)
 create mode 100644 drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
 create mode 100644 drivers/gpu/drm/arm/display/komeda/komeda_kms.c
 create mode 100644 drivers/gpu/drm/arm/display/komeda/komeda_kms.h
 create mode 100644 drivers/gpu/drm/arm/display/komeda/komeda_plane.c
 create mode 100644 drivers/gpu/drm/arm/display/komeda/komeda_private_obj.c
drivers/gpu/drm/arm/display/komeda/Makefile +5 -1
index d369317f72ab..1374c01d179e 100644
@@ -9,7 +9,11 @@ komeda-y := \
 	komeda_dev.o \
 	komeda_format_caps.o \
 	komeda_pipeline.o \
-	komeda_framebuffer.o
+	komeda_framebuffer.o \
+	komeda_kms.o \
+	komeda_crtc.o \
+	komeda_plane.o \
+	komeda_private_obj.o
 
 komeda-y += \
 	d71/d71_dev.o
drivers/gpu/drm/arm/display/komeda/komeda_crtc.c new file +106 -0

106 lines not on this page · raw message

drivers/gpu/drm/arm/display/komeda/komeda_drv.c +17 -5
index bf32d334d20d..11ec0d275917 100644
@@ -10,22 +10,26 @@
 #include <linux/component.h>
 #include <drm/drm_of.h>
 #include "komeda_dev.h"
+#include "komeda_kms.h"
 
 struct komeda_drv {
 	struct komeda_dev *mdev;
+	struct komeda_kms_dev *kms;
 };
 
 static void komeda_unbind(struct device *dev)
 {
 	struct komeda_drv *mdrv = dev_get_drvdata(dev);
 
-	dev_set_drvdata(dev, NULL);
-
 	if (mdrv == NULL)
 		return;
 
+	komeda_kms_detach(mdrv->kms);
+
 	komeda_dev_destroy(mdrv->mdev);
-	kfree(mdrv);
+
+	dev_set_drvdata(dev, NULL);
+	devm_kfree(dev, mdrv);
 }
 
 static int komeda_bind(struct device *dev)
@@ -33,7 +37,7 @@ static int komeda_bind(struct device *dev)
 	struct komeda_drv *mdrv;
 	int err;
 
-	mdrv = kzalloc(sizeof(*mdrv), GFP_KERNEL);
+	mdrv = devm_kzalloc(dev, sizeof(*mdrv), GFP_KERNEL);
 	if (mdrv == NULL)
 		return -ENOMEM;
 
@@ -45,10 +49,18 @@ static int komeda_bind(struct device *dev)
 
 	dev_set_drvdata(dev, mdrv);
 
+	mdrv->kms = komeda_kms_attach(mdrv->mdev);
+	if (IS_ERR(mdrv->kms)) {
+		err = PTR_ERR(mdrv->kms);
+		goto destroy_mdev;
+	}
+
 	return 0;
 
+destroy_mdev:
+	komeda_dev_destroy(mdrv->mdev);
 free_mdrv:
-	kfree(mdrv);
+	devm_kfree(dev, mdrv);
 	return err;
 }
 
drivers/gpu/drm/arm/display/komeda/komeda_kms.c new file +168 -0

168 lines not on this page · raw message

drivers/gpu/drm/arm/display/komeda/komeda_kms.h new file +113 -0

113 lines not on this page · raw message

drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h +3 -0
index 0218762d2e53..15ed109f9889 100644
@@ -328,6 +328,9 @@ struct komeda_pipeline_state {
 #define to_improc_st(c)	container_of(c, struct komeda_improc_state, base)
 #define to_ctrlr_st(c)	container_of(c, struct komeda_timing_ctrlr_state, base)
 
+#define priv_to_comp_st(o) container_of(o, struct komeda_component_state, obj)
+#define priv_to_ppl_st(o)  container_of(o, struct komeda_pipeline_state, obj)
+
 /* pipeline APIs */
 struct komeda_pipeline *
 komeda_pipeline_add(struct komeda_dev *mdev, size_t size,
drivers/gpu/drm/arm/display/komeda/komeda_plane.c new file +109 -0

109 lines not on this page · raw message

drivers/gpu/drm/arm/display/komeda/komeda_private_obj.c new file +87 -0

87 lines not on this page · raw message

Signature · 1 line
2.17.1
#8 lore raw

PATCH 8/9 drm/doc: Add initial komeda driver documentation

In reply to james qian wang (Arm Technology China)
---
 Documentation/gpu/drivers.rst    |   1 +
 Documentation/gpu/komeda-kms.rst | 483 +++++++++++++++++++++++++++++++
 2 files changed, 484 insertions(+)
 create mode 100644 Documentation/gpu/komeda-kms.rst
Documentation/gpu/drivers.rst +1 -0
index 7c1672118a73..978e6da9bbff 100644
@@ -17,6 +17,7 @@ GPU Driver Documentation
    vkms
    bridge/dw-hdmi
    xen-front
+   komeda-kms
 
 .. only::  subproject and html
 
Documentation/gpu/komeda-kms.rst new file +483 -0

483 lines not on this page · raw message

Signature · 1 line
2.17.1
#9 lore raw

PATCH 9/9 MAINTAINERS: Add maintainer for arm komeda driver

In reply to james qian wang (Arm Technology China)
---
 MAINTAINERS | 8 ++++++++
 1 file changed, 8 insertions(+)
MAINTAINERS +8 -0
index 254b7b267731..9e44c2c2e234 100644
@@ -1132,6 +1132,14 @@ S:	Supported
 F:	drivers/gpu/drm/arm/
 F:	Documentation/devicetree/bindings/display/arm,malidp.txt
 
+ARM KOMEDA DRM-KMS DRIVER
+M:	James (Qian) Wang <[email protected]>
+M:	Mali DP Maintainers <[email protected]>
+S:	Supported
+F:	drivers/gpu/drm/arm/display/komeda
+F:	Documentation/devicetree/bindings/display/arm/arm,komeda.txt
+F:	Documentation/gpu/komeda-kms.rst
+
 ARM MFM AND FLOPPY DRIVERS
 M:	Ian Molton <[email protected]>
 S:	Maintained
Signature · 1 line
2.17.1
#10 lore raw

Re: [PATCH v1 9/9] MAINTAINERS: Add maintainer for arm komeda driver

Hi James,

Quoted 10 lines · james qian wang (Arm Technology China)
---
 MAINTAINERS | 8 ++++++++
 1 file changed, 8 insertions(+)
MAINTAINERS +0 -0
index 254b7b267731..9e44c2c2e234 100644

MAINTAINERS S: Supported · line 1135

Quoted 4 lines
MAINTAINERS +1 -0
@@ -1132,6 +1132,14 @@ S:	Supported
 F:	drivers/gpu/drm/arm/
 F:	Documentation/devicetree/bindings/display/arm,malidp.txt
 
+ARM KOMEDA DRM-KMS DRIVER

The list is meant to be in alphabetical order, so I think this entry should be before the MALI-DP one.

Perhaps we should make the Mali-DP "F:" rule more specific too. At the moment any changes under display/komeda will match that too (so Liviu and myself are returned by get_maintainer.pl for Komeda patches).

MAINTAINERS S: Supported · line 1139

Quoted 4 lines
MAINTAINERS +4 -0
+M:	James (Qian) Wang <[email protected]>
+M:	Mali DP Maintainers <[email protected]>
+S:	Supported
+F:	drivers/gpu/drm/arm/display/komeda

This one should have a trailing slash to include the directory tree.

Cheers,
-Brian

Quoted 9 lines
MAINTAINERS +3 -0
+F:	Documentation/devicetree/bindings/display/arm/arm,komeda.txt
+F:	Documentation/gpu/komeda-kms.rst
+
 ARM MFM AND FLOPPY DRIVERS
 M:	Ian Molton <[email protected]>
 S:	Maintained
Signature · 1 line
2.17.1
#11 lore raw

Re: [PATCH v1 9/9] MAINTAINERS: Add maintainer for arm komeda driver

Quoted 21 lines · Brian Starkey

Hi James,

Quoted 10 lines · james qian wang (Arm Technology China)
---
 MAINTAINERS | 8 ++++++++
 1 file changed, 8 insertions(+)
MAINTAINERS +0 -0
index 254b7b267731..9e44c2c2e234 100644

MAINTAINERS S: Supported · line 1135

Quoted 4 lines
MAINTAINERS +1 -0
@@ -1132,6 +1132,14 @@ S:	Supported
 F:	drivers/gpu/drm/arm/
 F:	Documentation/devicetree/bindings/display/arm,malidp.txt
 
+ARM KOMEDA DRM-KMS DRIVER

The list is meant to be in alphabetical order, so I think this entry should be before the MALI-DP one.

Quoted 5 lines

Perhaps we should make the Mali-DP "F:" rule more specific too. At the moment any changes under display/komeda will match that too (so Liviu and myself are returned by get_maintainer.pl for Komeda patches).

OK, will fix it in the next version.

Quoted 10 lines

MAINTAINERS S: Supported · line 1139

Quoted 4 lines
MAINTAINERS +4 -0
+M:	James (Qian) Wang <[email protected]>
+M:	Mali DP Maintainers <[email protected]>
+S:	Supported
+F:	drivers/gpu/drm/arm/display/komeda

This one should have a trailing slash to include the directory tree.

Cheers,
-Brian

Yes, thank you

Quoted 9 lines
Quoted 9 lines
MAINTAINERS +3 -0
+F:	Documentation/devicetree/bindings/display/arm/arm,komeda.txt
+F:	Documentation/gpu/komeda-kms.rst
+
 ARM MFM AND FLOPPY DRIVERS
 M:	Ian Molton <[email protected]>
 S:	Maintained
Signature · 1 line
2.17.1

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