Skip to contentSkip to conversation

Support for LEGO MINDSTORMS EV3 LCD display

PATCH Superseded David Lechner 4 participants 30 messages Jul 29, 2017 – Aug 4, 2017

Subsystems (5)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover Support for LEGO MINDSTORMS EV3 LCD display

The goal of this series is to get the built-in LCD of the LEGO MINDSTORMS EV3 working. But, most of the content here is building up the infrastructure to do that.

The controller used in the EV3 uses MIPI commands, but it uses a different memory layout. The current tinydrm stuff is hard-coded for RGB565, so most of the patches are adding support for other memory layouts.

I've also made the one existing tinydrm driver generic so that it can work for any MIPI display rather than copying a bunch of boiler-plate code for each panel and/or controller.

Once all of this is done, it is really easy to add a new panel. :-)

David Lechner (6):
drm/tinydrm: Add parameter for MIPI DCS pixel format drm/tinydrm: add helpers for ST7586 controllers drm/tinydrm: rename mi028qt module to mipi-panel drm/tinydrm: mipi-panel: refactor to use driver id drm/tinydrm: add support for LEGO MINDSTORMS EV3 LCD
ARM: dts: da850-lego-ev3: Add node for LCD display

 .../devicetree/bindings/display/mipi-panel.txt     |  27 ++
 .../bindings/display/multi-inno,mi0283qt.txt       |  27 --
 MAINTAINERS                                        |   6 +-
 arch/arm/boot/dts/da850-lego-ev3.dts               |  24 ++
 drivers/gpu/drm/tinydrm/Kconfig                    |  13 +-
 drivers/gpu/drm/tinydrm/Makefile                   |   2 +-
 drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c     | 148 ++++++++
 drivers/gpu/drm/tinydrm/mi0283qt.c                 | 282 ---------------
 drivers/gpu/drm/tinydrm/mipi-dbi.c                 | 117 ++++--
 drivers/gpu/drm/tinydrm/mipi-panel.c               | 395 +++++++++++++++++++++
 include/drm/tinydrm/mipi-dbi.h                     |   9 +-
 include/drm/tinydrm/st7586.h                       |  34 ++
 include/drm/tinydrm/tinydrm-helpers.h              |   6 +
 include/video/mipi_display.h                       |  16 +-
 14 files changed, 759 insertions(+), 347 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/display/mipi-panel.txt
 delete mode 100644 Documentation/devicetree/bindings/display/multi-inno,mi0283qt.txt
 delete mode 100644 drivers/gpu/drm/tinydrm/mi0283qt.c
 create mode 100644 drivers/gpu/drm/tinydrm/mipi-panel.c
 create mode 100644 include/drm/tinydrm/st7586.h
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/6 drm/tinydrm: Add parameter for MIPI DCS pixel format

This adds a parameter for MIPI DCS pixel format to mipi_dbi_init(). This is in preparation for supporting displays that don't use a 16bpp memory layout.

---
 drivers/gpu/drm/tinydrm/mi0283qt.c |  3 ++-
 drivers/gpu/drm/tinydrm/mipi-dbi.c | 21 ++++++++++++++++++---
 include/drm/tinydrm/mipi-dbi.h     |  7 ++++++-
 include/video/mipi_display.h       | 14 ++++++++------
 4 files changed, 34 insertions(+), 11 deletions(-)
drivers/gpu/drm/tinydrm/mi0283qt.c +2 -1
index 482ff1c3..2680dab 100644
@@ -196,7 +196,8 @@ static int mi0283qt_probe(struct spi_device *spi)
 	device_property_read_u32(dev, "rotation", &rotation);
 
 	ret = mipi_dbi_spi_init(spi, mipi, dc, &mi0283qt_pipe_funcs,
-				&mi0283qt_driver, &mi0283qt_mode, rotation);
+				&mi0283qt_driver, &mi0283qt_mode,
+				MIPI_DCS_PIXEL_FMT_16BIT, rotation);
 	if (ret)
 		return ret;
 
drivers/gpu/drm/tinydrm/mipi-dbi.c +18 -3
index c83eeb7..7d49366 100644
@@ -336,6 +336,7 @@ static const uint32_t mipi_dbi_formats[] = {
  * @pipe_funcs: Display pipe functions
  * @driver: DRM driver
  * @mode: Display mode
+ * @pixel_fmt: The display memory's pixel format
  * @rotation: Initial rotation in degrees Counter Clock Wise
  *
  * This function initializes a &mipi_dbi structure and it's underlying
@@ -352,15 +353,26 @@ static const uint32_t mipi_dbi_formats[] = {
 int mipi_dbi_init(struct device *dev, struct mipi_dbi *mipi,
 		  const struct drm_simple_display_pipe_funcs *pipe_funcs,
 		  struct drm_driver *driver,
-		  const struct drm_display_mode *mode, unsigned int rotation)
+		  const struct drm_display_mode *mode,
+		  enum mipi_dcs_pixel_format pixel_fmt, unsigned int rotation)
 {
-	size_t bufsize = mode->vdisplay * mode->hdisplay * sizeof(u16);
 	struct tinydrm_device *tdev = &mipi->tinydrm;
+	size_t bufsize;
 	int ret;
 
 	if (!mipi->command)
 		return -EINVAL;
 
+	switch (pixel_fmt) {
+	case MIPI_DCS_PIXEL_FMT_16BIT:
+		bufsize = mode->vdisplay * mode->hdisplay * sizeof(u16);
+		break;
+	default:
+		DRM_ERROR("Pixel format is not supported\n");
+		return -EINVAL;
+	}
+	mipi->pixel_fmt = pixel_fmt;
+
 	mutex_init(&mipi->cmdlock);
 
 	mipi->tx_buf = devm_kmalloc(dev, bufsize, GFP_KERNEL);
@@ -781,6 +793,7 @@ static int mipi_dbi_typec3_command(struct mipi_dbi *mipi, u8 cmd,
  * @pipe_funcs: Display pipe functions
  * @driver: DRM driver
  * @mode: Display mode
+ * @pixel_fmt: The display memory's pixel format
  * @rotation: Initial rotation in degrees Counter Clock Wise
  *
  * This function sets &mipi_dbi->command, enables &mipi->read_commands for the
@@ -803,6 +816,7 @@ int mipi_dbi_spi_init(struct spi_device *spi, struct mipi_dbi *mipi,
 		      const struct drm_simple_display_pipe_funcs *pipe_funcs,
 		      struct drm_driver *driver,
 		      const struct drm_display_mode *mode,
+		      enum mipi_dcs_pixel_format pixel_fmt,
 		      unsigned int rotation)
 {
 	size_t tx_size = tinydrm_spi_max_transfer_size(spi, 0);
@@ -849,7 +863,8 @@ int mipi_dbi_spi_init(struct spi_device *spi, struct mipi_dbi *mipi,
 			return -ENOMEM;
 	}
 
-	return mipi_dbi_init(dev, mipi, pipe_funcs, driver, mode, rotation);
+	return mipi_dbi_init(dev, mipi, pipe_funcs, driver, mode, pixel_fmt,
+			     rotation);
 }
 EXPORT_SYMBOL(mipi_dbi_spi_init);
 
include/drm/tinydrm/mipi-dbi.h +6 -1
index d137b16..dda100c 100644
@@ -13,6 +13,7 @@
 #define __LINUX_MIPI_DBI_H
 
 #include <drm/tinydrm/tinydrm.h>
+#include <video/mipi_display.h>
 
 struct spi_device;
 struct gpio_desc;
@@ -33,6 +34,7 @@ struct regulator;
  * @tx_buf9_len: Size of tx_buf9.
  * @swap_bytes: Swap bytes in buffer before transfer
  * @reset: Optional reset gpio
+ * @pixel_fmt: The display memory's pixel format
  * @rotation: initial rotation in degrees Counter Clock Wise
  * @backlight: backlight device (optional)
  * @regulator: power regulator (optional)
@@ -50,6 +52,7 @@ struct mipi_dbi {
 	size_t tx_buf9_len;
 	bool swap_bytes;
 	struct gpio_desc *reset;
+	enum mipi_dcs_pixel_format pixel_fmt;
 	unsigned int rotation;
 	struct backlight_device *backlight;
 	struct regulator *regulator;
@@ -66,11 +69,13 @@ int mipi_dbi_spi_init(struct spi_device *spi, struct mipi_dbi *mipi,
 		      const struct drm_simple_display_pipe_funcs *pipe_funcs,
 		      struct drm_driver *driver,
 		      const struct drm_display_mode *mode,
+		      enum mipi_dcs_pixel_format pixel_fmt,
 		      unsigned int rotation);
 int mipi_dbi_init(struct device *dev, struct mipi_dbi *mipi,
 		  const struct drm_simple_display_pipe_funcs *pipe_funcs,
 		  struct drm_driver *driver,
-		  const struct drm_display_mode *mode, unsigned int rotation);
+		  const struct drm_display_mode *mode,
+		  enum mipi_dcs_pixel_format pixel_fmt, unsigned int rotation);
 void mipi_dbi_pipe_enable(struct drm_simple_display_pipe *pipe,
 			  struct drm_crtc_state *crtc_state);
 void mipi_dbi_pipe_disable(struct drm_simple_display_pipe *pipe);
include/video/mipi_display.h +8 -6
index 19aa65a..84b70cd 100644
@@ -128,11 +128,13 @@ enum {
 };
 
 /* MIPI DCS pixel formats */
-#define MIPI_DCS_PIXEL_FMT_24BIT	7
-#define MIPI_DCS_PIXEL_FMT_18BIT	6
-#define MIPI_DCS_PIXEL_FMT_16BIT	5
-#define MIPI_DCS_PIXEL_FMT_12BIT	3
-#define MIPI_DCS_PIXEL_FMT_8BIT		2
-#define MIPI_DCS_PIXEL_FMT_3BIT		1
+enum mipi_dcs_pixel_format {
+	MIPI_DCS_PIXEL_FMT_24BIT	= 7,
+	MIPI_DCS_PIXEL_FMT_18BIT	= 6,
+	MIPI_DCS_PIXEL_FMT_16BIT	= 5,
+	MIPI_DCS_PIXEL_FMT_12BIT	= 3,
+	MIPI_DCS_PIXEL_FMT_8BIT		= 2,
+	MIPI_DCS_PIXEL_FMT_3BIT		= 1,
+};
 
 #endif
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
#3 lore raw

PATCH 2/6 drm/tinydrm: add helpers for ST7586 controllers

In reply to David Lechner

This adds helper functions and support for ST7586 controllers. These controllers have an unusual memory layout where 3 pixels are packed into 1 byte.

+-------+-----------------+
| bit   | 7 6 5 4 3 2 1 0 |
+-------+-----------------+
| pixel | 0 0 0 1 1 1 2 2 |
+-------+-----------------+

So, there are a nuber of places in the tinydrm pipline where this format needs to be taken into consideration.

---
 drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c | 148 +++++++++++++++++++++++++
 drivers/gpu/drm/tinydrm/mipi-dbi.c             |  96 ++++++++++++----
 include/drm/tinydrm/tinydrm-helpers.h          |   6 +
 include/video/mipi_display.h                   |   2 +
 4 files changed, 232 insertions(+), 20 deletions(-)
drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c +148 -0
index d4cda33..4a36441 100644
@@ -181,6 +181,154 @@ void tinydrm_xrgb8888_to_rgb565(u16 *dst, void *vaddr,
 EXPORT_SYMBOL(tinydrm_xrgb8888_to_rgb565);
 
 /**
+ * tinydrm_rgb565_to_st7586 - Convert RGB565 to ST7586 clip buffer
+ * @dst: ST7586 destination buffer
+ * @vaddr: RGB565 source buffer
+ * @fb: DRM framebuffer
+ * @clip: Clip rectangle area to copy
+ * @swap: Swap bytes
+ *
+ * The ST7586 controller has a non-standard pixel layout. It is 2-bit grayscale
+ * (or 1-bit monochrome) packed into 3 pixels per byte.
+ *
+ * Note: the @clip x values are modified! They are aligned to the 3 pixel
+ * boundtry and divied by 3 to get the starting and ending byte (+ 1) in the
+ * @dst buffer.
+ */
+void tinydrm_rgb565_to_st7586(u8 *dst, void *vaddr,
+				struct drm_framebuffer *fb,
+				struct drm_clip_rect *clip)
+{
+	size_t len;
+	unsigned int x, y;
+	u16 *src, *buf;
+	u8 val;
+
+	/* 3 pixels per byte, so align to dst byte */
+	clip->x1 -= clip->x1 % 3;
+	clip->x2 = (clip->x2 + 2) / 3 * 3;
+	len = (clip->x2 - clip->x1) * sizeof(u16);
+
+	buf = kmalloc(len, GFP_KERNEL);
+	if (!buf)
+		return;
+
+	for (y = clip->y1; y < clip->y2; y++) {
+		src = vaddr + (y * fb->pitches[0]);
+		src += clip->x1;
+		memcpy(buf, src, len);
+		src = buf;
+		for (x = clip->x1; x < clip->x2; x += 3) {
+			/*
+			 * TODO: There is probably a better algorithm to get
+			 * a better downsampling.
+			 * If red or green is > 50%, set the high bit, which is
+			 * bright gray. If blue is greater than 50%, set the
+			 * low bit, which is dark gray.
+			 */
+			val =   ((*src & 0x8000) >>  8) |
+				((*src & 0x0400) >>  3) |
+				((*src & 0x0010) <<  2);
+			if (val & 0xC0)
+				val |= 0x20;
+			src++;
+			val |=  ((*src & 0x8000) >> 11) |
+				((*src & 0x0400) >>  6) |
+				((*src & 0x0010) >>  1);
+			if (val & 0x18)
+				val |= 0x04;
+			src++;
+			val |=  ((*src & 0x8000) >> 14) |
+				((*src & 0x0400) >>  9) |
+				((*src & 0x0010) >>  4);
+			src++;
+			*dst++ = ~val;
+		}
+	}
+
+	/* now adjust the clip so it applies to dst */
+	clip->x1 /= 3;
+	clip->x2 /= 3;
+
+	kfree(buf);
+}
+EXPORT_SYMBOL(tinydrm_rgb565_to_st7586);
+
+/**
+ * tinydrm_xrgb8888_to_st7586 - Convert XRGB8888 to ST7586 clip buffer
+ * @dst: ST7586 destination buffer
+ * @vaddr: XRGB8888 source buffer
+ * @fb: DRM framebuffer
+ * @clip: Clip rectangle area to copy
+ * @swap: Swap bytes
+ *
+ * The ST7586 controller has a non-standard pixel layout. It is 2-bit grayscale
+ * (or 1-bit monochrome) packed into 3 pixels per byte.
+ *
+ * Note: the @clip x values are modified! They are aligned to the 3 pixel
+ * boundtry and divied by 3 to get the starting and ending byte (+ 1) in the
+ * @dst buffer.
+ */
+void tinydrm_xrgb8888_to_st7586(u8 *dst, void *vaddr,
+				struct drm_framebuffer *fb,
+				struct drm_clip_rect *clip)
+{
+	size_t len;
+	unsigned int x, y;
+	u32 *src, *buf;
+	u8 val;
+
+	/* 3 pixels per byte, so align to dst byte */
+	clip->x1 -= clip->x1 % 3;
+	clip->x2 = (clip->x2 + 2) / 3 * 3;
+	len = (clip->x2 - clip->x1) * sizeof(u32);
+
+	buf = kmalloc(len, GFP_KERNEL);
+	if (!buf)
+		return;
+
+	for (y = clip->y1; y < clip->y2; y++) {
+		src = vaddr + (y * fb->pitches[0]);
+		src += clip->x1;
+		memcpy(buf, src, len);
+		src = buf;
+		for (x = clip->x1; x < clip->x2; x += 3) {
+			/*
+			 * TODO: There is probably a better algorithm to get
+			 * a better downsampling.
+			 * If red or green is > 50%, set the high bit, which is
+			 * bright gray. If blue is greater than 50%, set the
+			 * low bit, which is dark gray.
+			 */
+			val =   ((*src & 0x00800000) >> 16) |
+				((*src & 0x00008000) >>  8) |
+				((*src & 0x00000080) >>  1);
+			if (val & 0xC0)
+				val |= 0x20;
+			src++;
+			val |=  ((*src & 0x00800000) >> 19) |
+				((*src & 0x00008000) >> 11) |
+				((*src & 0x00000080) >>  4);
+			if (val & 0x18)
+				val |= 0x04;
+			src++;
+			val |=  ((*src & 0x00800000) >> 22) |
+				((*src & 0x00008000) >> 14) |
+				((*src & 0x00000080) >>  7);
+			src++;
+			*dst++ = ~val;
+		}
+	}
+
+	/* now adjust the clip so it applies to dst */
+	clip->x1 /= 3;
+	clip->x2 /= 3;
+
+	kfree(buf);
+}
+EXPORT_SYMBOL(tinydrm_xrgb8888_to_st7586);
+
+/**
  * tinydrm_of_find_backlight - Find backlight device in device-tree
  * @dev: Device
  *
drivers/gpu/drm/tinydrm/mipi-dbi.c +76 -20

160 lines not on this page · raw message

include/drm/tinydrm/tinydrm-helpers.h +6 -0
index 9b9b6cf..94792fb 100644
@@ -43,6 +43,12 @@ void tinydrm_swab16(u16 *dst, void *vaddr, struct drm_framebuffer *fb,
 void tinydrm_xrgb8888_to_rgb565(u16 *dst, void *vaddr,
 				struct drm_framebuffer *fb,
 				struct drm_clip_rect *clip, bool swap);
+void tinydrm_rgb565_to_st7586(u8 *dst, void *vaddr,
+				struct drm_framebuffer *fb,
+				struct drm_clip_rect *clip);
+void tinydrm_xrgb8888_to_st7586(u8 *dst, void *vaddr,
+				struct drm_framebuffer *fb,
+				struct drm_clip_rect *clip);
 
 struct backlight_device *tinydrm_of_find_backlight(struct device *dev);
 int tinydrm_enable_backlight(struct backlight_device *backlight);
include/video/mipi_display.h +2 -0
index 84b70cd..1c134c4 100644
@@ -135,6 +135,8 @@ enum mipi_dcs_pixel_format {
 	MIPI_DCS_PIXEL_FMT_12BIT	= 3,
 	MIPI_DCS_PIXEL_FMT_8BIT		= 2,
 	MIPI_DCS_PIXEL_FMT_3BIT		= 1,
+	/* non-standard format packing 1 or 2bpp in 3:3:2 bits */
+	MIPI_DCS_PIXEL_FMT_ST7586_332	= -1,
 };
 
 #endif
Signature · 1 line
2.7.4
#5 lore raw

PATCH 3/6 drm/tinydrm: rename mi028qt module to mipi-panel

In reply to David Lechner

This renames the mi028qt module to mipi-panel so that it can be used for other types of panels as well. There is no reason to copy a bunch of boiler-plate code for each panel or controller.

---
 .../devicetree/bindings/display/mipi-panel.txt     |  27 ++
 .../bindings/display/multi-inno,mi0283qt.txt       |  27 --
 MAINTAINERS                                        |   6 +-
 drivers/gpu/drm/tinydrm/Kconfig                    |  12 +-
 drivers/gpu/drm/tinydrm/Makefile                   |   2 +-
 drivers/gpu/drm/tinydrm/mi0283qt.c                 | 283 --------------------
 drivers/gpu/drm/tinydrm/mipi-panel.c               | 284 +++++++++++++++++++++
 7 files changed, 323 insertions(+), 318 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/display/mipi-panel.txt
 delete mode 100644 Documentation/devicetree/bindings/display/multi-inno,mi0283qt.txt
 delete mode 100644 drivers/gpu/drm/tinydrm/mi0283qt.c
 create mode 100644 drivers/gpu/drm/tinydrm/mipi-panel.c
Documentation/devicetree/bindings/display/mipi-panel.txt new file +27 -0
new file mode 100644
index 0000000..01d6ea9
@@ -0,0 +1,27 @@
+MIPI DBI compatible display panel
+
+Required properties:
+- compatible:	"multi-inno,mi0283qt".
+
+The node for this driver must be a child node of a SPI controller, hence
+all mandatory properties described in ../spi/spi-bus.txt must be specified.
+
+Optional properties:
+- dc-gpios:	D/C pin. The presence/absence of this GPIO determines
+		the panel interface mode (IM[3:0] pins):
+		- present: IM=x110 4-wire 8-bit data serial interface
+		- absent:  IM=x101 3-wire 9-bit data serial interface
+- reset-gpios:	Reset pin
+- power-supply:	A regulator node for the supply voltage.
+- backlight:	phandle of the backlight device attached to the panel
+- rotation:	panel rotation in degrees counter clockwise (0,90,180,270)
+
+Example:
+	display@0{
+		compatible = "multi-inno,mi0283qt";
+		reg = <0>;
+		spi-max-frequency = <32000000>;
+		rotation = <90>;
+		dc-gpios = <&gpio 25 0>;
+		backlight = <&backlight>;
+	};
Documentation/devicetree/bindings/display/multi-inno,mi0283qt.txt deleted +0 -27
deleted file mode 100644
index eed48c3..0000000
@@ -1,27 +0,0 @@
-Multi-Inno MI0283QT display panel
-
-Required properties:
-- compatible:	"multi-inno,mi0283qt".
-
-The node for this driver must be a child node of a SPI controller, hence
-all mandatory properties described in ../spi/spi-bus.txt must be specified.
-
-Optional properties:
-- dc-gpios:	D/C pin. The presence/absence of this GPIO determines
-		the panel interface mode (IM[3:0] pins):
-		- present: IM=x110 4-wire 8-bit data serial interface
-		- absent:  IM=x101 3-wire 9-bit data serial interface
-- reset-gpios:	Reset pin
-- power-supply:	A regulator node for the supply voltage.
-- backlight:	phandle of the backlight device attached to the panel
-- rotation:	panel rotation in degrees counter clockwise (0,90,180,270)
-
-Example:
-	mi0283qt@0{
-		compatible = "multi-inno,mi0283qt";
-		reg = <0>;
-		spi-max-frequency = <32000000>;
-		rotation = <90>;
-		dc-gpios = <&gpio 25 0>;
-		backlight = <&backlight>;
-	};
MAINTAINERS +3 -3
index f66488d..812ffd0 100644
@@ -4315,11 +4315,11 @@ M:	Dave Airlie <[email protected]>
 S:	Odd Fixes
 F:	drivers/gpu/drm/mgag200/
 
-DRM DRIVER FOR MI0283QT
+DRM DRIVER FOR MIPI DBI compatible panels
 M:	Noralf Trønnes <[email protected]>
 S:	Maintained
-F:	drivers/gpu/drm/tinydrm/mi0283qt.c
-F:	Documentation/devicetree/bindings/display/multi-inno,mi0283qt.txt
+F:	drivers/gpu/drm/tinydrm/mipi-panel.c
+F:	Documentation/devicetree/bindings/display/mipi-panel.txt
 
 DRM DRIVER FOR MSM ADRENO GPU
 M:	Rob Clark <[email protected]>
drivers/gpu/drm/tinydrm/Kconfig +8 -4
index 3504c53..394519b 100644
@@ -12,10 +12,14 @@ menuconfig DRM_TINYDRM
 config TINYDRM_MIPI_DBI
 	tristate
 
-config TINYDRM_MI0283QT
-	tristate "DRM support for MI0283QT"
+config TINYDRM_MIPI_PANEL
+	tristate "DRM support for MIPI DBI compatible display panels"
 	depends on DRM_TINYDRM && SPI
 	select TINYDRM_MIPI_DBI
 	help
-	  DRM driver for the Multi-Inno MI0283QT display panel
-	  If M is selected the module will be called mi0283qt.
+	  DRM driver for the MIPI DBI compatible display panels.
+
+	  Supported panels include:
+	  * Multi-Inno MI0283QT
+
+	  If M is selected the module will be called mipi-panel.
drivers/gpu/drm/tinydrm/Makefile +1 -1
index 7a3604c..7eae65e 100644
@@ -4,4 +4,4 @@ obj-$(CONFIG_DRM_TINYDRM)		+= core/
 obj-$(CONFIG_TINYDRM_MIPI_DBI)		+= mipi-dbi.o
 
 # Displays
-obj-$(CONFIG_TINYDRM_MI0283QT)		+= mi0283qt.o
+obj-$(CONFIG_TINYDRM_MIPI_PANEL)	+= mipi-panel.o
drivers/gpu/drm/tinydrm/mi0283qt.c deleted +0 -283

283 lines not on this page · raw message

drivers/gpu/drm/tinydrm/mipi-panel.c new file +284 -0

284 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
#7 lore raw

PATCH 4/6 drm/tinydrm: mipi-panel: refactor to use driver id

In reply to David Lechner

This refactors the mipi-panel module to use the driver id for panel-specific data. This is in preparation for adding additional panels.

---
 drivers/gpu/drm/tinydrm/mipi-panel.c | 40 ++++++++++++++++++++++++++++--------
 include/drm/tinydrm/mipi-dbi.h       |  2 ++
 2 files changed, 34 insertions(+), 8 deletions(-)
drivers/gpu/drm/tinydrm/mipi-panel.c +32 -8
index 64344f0..8aa1d8e 100644
@@ -21,7 +21,18 @@
 #include <linux/spi/spi.h>
 #include <video/mipi_display.h>
 
-static int mipi_panel_init(struct mipi_dbi *mipi)
+enum mipi_panel_type {
+	MIPI_PANEL_TYPE_UNKNOWN,
+	MIPI_PANEL_TYPE_MULTI_INNO_MI0283QT,
+};
+
+struct mipi_panel_info {
+	int (*init)(struct mipi_dbi *mipi);
+	const struct drm_display_mode mode;
+	enum mipi_dcs_pixel_format pixel_fmt;
+};
+
+static int mipi_panel_init_ili9341(struct mipi_dbi *mipi)
 {
 	struct tinydrm_device *tdev = &mipi->tinydrm;
 	struct device *dev = tdev->drm->dev;
@@ -129,8 +140,12 @@ static const struct drm_simple_display_pipe_funcs mipi_panel_pipe_funcs = {
 	.prepare_fb = tinydrm_display_pipe_prepare_fb,
 };
 
-static const struct drm_display_mode mipi_panel_mode = {
-	TINYDRM_MODE(320, 240, 58, 43),
+static const struct mipi_panel_info mipi_panel_infos[] = {
+	[MIPI_PANEL_TYPE_MULTI_INNO_MI0283QT] = {
+		.init		= mipi_panel_init_ili9341,
+		.mode		= { TINYDRM_MODE(320, 240, 58, 43) },
+		.pixel_fmt	= MIPI_DCS_PIXEL_FMT_16BIT,
+	},
 };
 
 DEFINE_DRM_GEM_CMA_FOPS(mipi_panel_fops);
@@ -156,13 +171,15 @@ static const struct of_device_id mipi_panel_of_match[] = {
 MODULE_DEVICE_TABLE(of, mipi_panel_of_match);
 
 static const struct spi_device_id mipi_panel_id[] = {
-	{ "mi0283qt", 0 },
+	{ "mi0283qt", MIPI_PANEL_TYPE_MULTI_INNO_MI0283QT },
 	{ },
 };
 MODULE_DEVICE_TABLE(spi, mipi_panel_id);
 
 static int mipi_panel_probe(struct spi_device *spi)
 {
+	const struct spi_device_id *id = spi_get_device_id(spi);
+	enum mipi_panel_type type = id->driver_data;
 	struct device *dev = &spi->dev;
 	struct tinydrm_device *tdev;
 	struct mipi_dbi *mipi;
@@ -170,10 +187,17 @@ static int mipi_panel_probe(struct spi_device *spi)
 	u32 rotation = 0;
 	int ret;
 
+	if (type == MIPI_PANEL_TYPE_UNKNOWN) {
+		dev_err(dev, "Unknown panel type\n");
+		return -EINVAL;
+	}
+
 	mipi = devm_kzalloc(dev, sizeof(*mipi), GFP_KERNEL);
 	if (!mipi)
 		return -ENOMEM;
 
+	mipi->init = mipi_panel_infos[type].init;
+
 	mipi->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
 	if (IS_ERR(mipi->reset)) {
 		dev_err(dev, "Failed to get gpio 'reset'\n");
@@ -197,12 +221,12 @@ static int mipi_panel_probe(struct spi_device *spi)
 	device_property_read_u32(dev, "rotation", &rotation);
 
 	ret = mipi_dbi_spi_init(spi, mipi, dc, &mipi_panel_pipe_funcs,
-				&mipi_panel_driver, &mipi_panel_mode,
-				MIPI_DCS_PIXEL_FMT_16BIT, rotation);
+				&mipi_panel_driver, &mipi_panel_infos[type].mode,
+				mipi_panel_infos[type].pixel_fmt, rotation);
 	if (ret)
 		return ret;
 
-	ret = mipi_panel_init(mipi);
+	ret = mipi->init(mipi);
 	if (ret)
 		return ret;
 
@@ -255,7 +279,7 @@ static int __maybe_unused mipi_panel_pm_resume(struct device *dev)
 	struct mipi_dbi *mipi = dev_get_drvdata(dev);
 	int ret;
 
-	ret = mipi_panel_init(mipi);
+	ret = mipi->init(mipi);
 	if (ret)
 		return ret;
 
include/drm/tinydrm/mipi-dbi.h +2 -0
index dda100c..f7ae5ae 100644
@@ -25,6 +25,7 @@ struct regulator;
  * @spi: SPI device
  * @enabled: Pipeline is enabled
  * @cmdlock: Command lock
+ * @init: Panel specific callback executing initialization command sequence.
  * @command: Bus specific callback executing commands.
  * @read_commands: Array of read commands terminated by a zero entry.
  *                 Reading is disabled if this is NULL.
@@ -44,6 +45,7 @@ struct mipi_dbi {
 	struct spi_device *spi;
 	bool enabled;
 	struct mutex cmdlock;
+	int (*init)(struct mipi_dbi *mipi);
 	int (*command)(struct mipi_dbi *mipi, u8 cmd, u8 *param, size_t num);
 	const u8 *read_commands;
 	struct gpio_desc *dc;
Signature · 1 line
2.7.4
#9 lore raw

PATCH 5/6 drm/tinydrm: add support for LEGO MINDSTORMS EV3 LCD

In reply to David Lechner

LEGO MINDSTORMS EV3 has an LCD with a ST7586 controller. This adds a new module for the ST7586 controller with parameters for the EV3 LCD dispay.

---
 .../devicetree/bindings/display/mipi-panel.txt     |  2 +-
 drivers/gpu/drm/tinydrm/Kconfig                    |  1 +
 drivers/gpu/drm/tinydrm/mipi-panel.c               | 87 ++++++++++++++++++++++
 include/drm/tinydrm/st7586.h                       | 34 +++++++++
 4 files changed, 123 insertions(+), 1 deletion(-)
 create mode 100644 include/drm/tinydrm/st7586.h
Documentation/devicetree/bindings/display/mipi-panel.txt +1 -1
index 01d6ea9..ba8c8ab 100644
@@ -1,7 +1,7 @@
 MIPI DBI compatible display panel
 
 Required properties:
-- compatible:	"multi-inno,mi0283qt".
+- compatible:	one of "lego,ev3-lcd", "multi-inno,mi0283qt".
 
 The node for this driver must be a child node of a SPI controller, hence
 all mandatory properties described in ../spi/spi-bus.txt must be specified.
drivers/gpu/drm/tinydrm/Kconfig +1 -0
index 394519b..6e90bb5 100644
@@ -20,6 +20,7 @@ config TINYDRM_MIPI_PANEL
 	  DRM driver for the MIPI DBI compatible display panels.
 	  
 	  Supported panels include:
+	  * LEGO MINDSTORMS EV3
 	  * Multi-Inno MI0283QT
 
 	  If M is selected the module will be called mipi-panel.
drivers/gpu/drm/tinydrm/mipi-panel.c +87 -0

123 lines not on this page · raw message

include/drm/tinydrm/st7586.h new file +34 -0
new file mode 100644
index 0000000..18fb56b
@@ -0,0 +1,34 @@
+/*
+ * ST7586 LCD controller
+ *
+ * Copyright (C) 2017 David Lechner <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef __LINUX_ST7856_H
+#define __LINUX_ST7856_H
+
+#define ST7586_DISP_MODE_GRAY	0x38
+#define ST7586_DISP_MODE_MONO	0x39
+#define ST7586_ENABLE_DDRAM	0x3a
+#define ST7586_SET_DISP_DUTY	0xb0
+#define ST7586_SET_PART_DISP	0xb4
+#define ST7586_SET_NLINE_INV	0xb5
+#define ST7586_SET_VOP		0xc0
+#define ST7586_SET_BIAS_SYSTEM	0xc3
+#define ST7586_SET_BOOST_LEVEL	0xc4
+#define ST7586_SET_VOP_OFFSET	0xc7
+#define ST7586_ENABLE_ANALOG	0xd0
+#define ST7586_AUTO_READ_CTRL	0xd7
+#define ST7586_OTP_RW_CTRL	0xe0
+#define ST7586_OTP_CTRL_OUT	0xe1
+#define ST7586_OTP_READ		0xe3
+
+#define ST7586_DISP_CTRL_MX	BIT(6)
+#define ST7586_DISP_CTRL_MY	BIT(7)
+
+#endif /* __LINUX_ST7856_H */
Signature · 1 line
2.7.4
#11 lore raw

PATCH 6/6 ARM: dts: da850-lego-ev3: Add node for LCD display

In reply to David Lechner

This adds a new node for the LEGO MINDSTORMS EV3 LCD display.

---
 arch/arm/boot/dts/da850-lego-ev3.dts | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
arch/arm/boot/dts/da850-lego-ev3.dts +24 -0
index 45983c0..249b317 100644
@@ -249,6 +249,15 @@
 			0x4c 0x00000080 0x000000f0
 		>;
 	};
+
+	ev3_lcd_pins: pinmux_lcd {
+		pinctrl-single,bits = <
+			/* SIMO, GP2[11], GP2[12], CLK */
+			0x14 0x00188100 0x00ffff00
+			/* GP5[0] */
+			0x30 0x80000000 0xf0000000
+		>;
+	};
 };
 
 &pinconf {
@@ -357,6 +366,21 @@
 	};
 };
 
+&spi1 {
+	status = "okay";
+	pinctrl-0 = <&ev3_lcd_pins>;
+	pinctrl-names = "default";
+	cs-gpios = <&gpio 44 GPIO_ACTIVE_LOW>;
+
+	display@0{
+		compatible = "lego,ev3-lcd";
+		reg = <0>;
+		spi-max-frequency = <10000000>;
+		dc-gpios = <&gpio 43 GPIO_ACTIVE_HIGH>;
+		reset-gpios = <&gpio 80 GPIO_ACTIVE_HIGH>;
+	};
+};
+
 &ehrpwm0 {
 	status = "okay";
 };
Signature · 1 line
2.7.4
#6 lore raw

Re: [PATCH 3/6] drm/tinydrm: rename mi028qt module to mipi-panel

In reply to David Lechner
Quoted 14 lines · David Lechner

This renames the mi028qt module to mipi-panel so that it can be used for other types of panels as well. There is no reason to copy a bunch of boiler-plate code for each panel or controller.

---
  .../devicetree/bindings/display/mipi-panel.txt     |  27 ++
  .../bindings/display/multi-inno,mi0283qt.txt       |  27 --
  MAINTAINERS                                        |   6 +-
  drivers/gpu/drm/tinydrm/Kconfig                    |  12 +-
  drivers/gpu/drm/tinydrm/Makefile                   |   2 +-
  drivers/gpu/drm/tinydrm/mi0283qt.c                 | 283 --------------------
  drivers/gpu/drm/tinydrm/mipi-panel.c               | 284 +++++++++++++++++++++
  7 files changed, 323 insertions(+), 318 deletions(-)
Quoted 5 lines

create mode 100644 Documentation/devicetree/bindings/display/mipi-panel.txt delete mode 100644 Documentation/devicetree/bindings/display/multi-inno,mi0283qt.txt delete mode 100644 drivers/gpu/drm/tinydrm/mi0283qt.c
create mode 100644 drivers/gpu/drm/tinydrm/mipi-panel.c

Apparently, I missed an option on git format-patch. This diff should be easier to look at...

---

Documentation/devicetree/bindings/display/mipi-panel.txt renamed from Documentation/devicetree/bindings/display/multi-inno,mi0283qt.txt +2 -2
similarity index 94%
rename from Documentation/devicetree/bindings/display/multi-inno,mi0283qt.txt
rename to Documentation/devicetree/bindings/display/mipi-panel.txt
index eed48c3..01d6ea9 100644
@@ -1,4 +1,4 @@
-Multi-Inno MI0283QT display panel
+MIPI DBI compatible display panel
 
 Required properties:
 - compatible:  "multi-inno,mi0283qt".
@@ -17,7 +17,7 @@ Optional properties:
 - rotation:    panel rotation in degrees counter clockwise (0,90,180,270)
 
 Example:
-       mi0283qt@0{
+       display@0{
                compatible = "multi-inno,mi0283qt";
                reg = <0>;
                spi-max-frequency = <32000000>;
MAINTAINERS +3 -3
index f66488d..812ffd0 100644
@@ -4315,11 +4315,11 @@ M:      Dave Airlie <[email protected]>
 S:     Odd Fixes
 F:     drivers/gpu/drm/mgag200/
 
-DRM DRIVER FOR MI0283QT
+DRM DRIVER FOR MIPI DBI compatible panels
 M:     Noralf Trønnes <[email protected]>
 S:     Maintained
-F:     drivers/gpu/drm/tinydrm/mi0283qt.c
-F:     Documentation/devicetree/bindings/display/multi-inno,mi0283qt.txt
+F:     drivers/gpu/drm/tinydrm/mipi-panel.c
+F:     Documentation/devicetree/bindings/display/mipi-panel.txt
 
 DRM DRIVER FOR MSM ADRENO GPU
 M:     Rob Clark <[email protected]>
drivers/gpu/drm/tinydrm/Kconfig +8 -4
index 3504c53..0a0db7a 100644
@@ -12,10 +12,14 @@ menuconfig DRM_TINYDRM
 config TINYDRM_MIPI_DBI
        tristate
 
-config TINYDRM_MI0283QT
-       tristate "DRM support for MI0283QT"
+config TINYDRM_MIPI_PANEL
+       tristate "DRM support for MIPI DBI compatible display panels"
        depends on DRM_TINYDRM && SPI
        select TINYDRM_MIPI_DBI
        help
-         DRM driver for the Multi-Inno MI0283QT display panel
-         If M is selected the module will be called mi0283qt.
+         DRM driver for the MIPI DBI compatible display panels.
+
+         Supported panels include:
+         * Multi-Inno MI0283QT
+
+         If M is selected the module will be called mipi-panel.
drivers/gpu/drm/tinydrm/Makefile +1 -1
index 7a3604c..7eae65e 100644
@@ -4,4 +4,4 @@ obj-$(CONFIG_DRM_TINYDRM)               += core/
 obj-$(CONFIG_TINYDRM_MIPI_DBI)         += mipi-dbi.o
 
 # Displays
-obj-$(CONFIG_TINYDRM_MI0283QT)         += mi0283qt.o
+obj-$(CONFIG_TINYDRM_MIPI_PANEL)       += mipi-panel.o
drivers/gpu/drm/tinydrm/mipi-panel.c renamed from drivers/gpu/drm/tinydrm/mi0283qt.c +8 -7
similarity index 76%
rename from drivers/gpu/drm/tinydrm/mi0283qt.c
rename to drivers/gpu/drm/tinydrm/mipi-panel.c
index 2680dab..64344f0 100644
@@ -1,7 +1,8 @@
 /*
- * DRM driver for Multi-Inno MI0283QT panels
+ * DRM driver for MIPI DBI compatible panels
  *
  * Copyright 2016 Noralf Trønnes
+ * Copyright 2017 David Lechner <david-nq/r/kbU++upp/[email protected]>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -20,7 +21,7 @@
 #include <linux/spi/spi.h>
 #include <video/mipi_display.h>
 
-static int mi0283qt_init(struct mipi_dbi *mipi)
+static int mipi_panel_init(struct mipi_dbi *mipi)
 {
        struct tinydrm_device *tdev = &mipi->tinydrm;
        struct device *dev = tdev->drm->dev;
@@ -113,7 +114,7 @@ static int mi0283qt_init(struct mipi_dbi *mipi)
        return 0;
 }
 
-static void mi0283qt_fini(void *data)
+static void mipi_panel_fini(void *data)
 {
        struct mipi_dbi *mipi = data;
 
@@ -121,46 +122,46 @@ static void mi0283qt_fini(void *data)
        regulator_disable(mipi->regulator);
 }
 
-static const struct drm_simple_display_pipe_funcs mi0283qt_pipe_funcs = {
+static const struct drm_simple_display_pipe_funcs mipi_panel_pipe_funcs = {
        .enable = mipi_dbi_pipe_enable,
        .disable = mipi_dbi_pipe_disable,
        .update = tinydrm_display_pipe_update,
        .prepare_fb = tinydrm_display_pipe_prepare_fb,
 };
 
-static const struct drm_display_mode mi0283qt_mode = {
+static const struct drm_display_mode mipi_panel_mode = {
        TINYDRM_MODE(320, 240, 58, 43),
 };
 
-DEFINE_DRM_GEM_CMA_FOPS(mi0283qt_fops);
+DEFINE_DRM_GEM_CMA_FOPS(mipi_panel_fops);
 
-static struct drm_driver mi0283qt_driver = {
+static struct drm_driver mipi_panel_driver = {
        .driver_features        = DRIVER_GEM | DRIVER_MODESET | 

DRIVER_PRIME |
DRIVER_ATOMIC,

-       .fops                   = &mi0283qt_fops,
+       .fops                   = &mipi_panel_fops,
        TINYDRM_GEM_DRIVER_OPS,
        .lastclose              = tinydrm_lastclose,
        .debugfs_init           = mipi_dbi_debugfs_init,
-       .name                   = "mi0283qt",
-       .desc                   = "Multi-Inno MI0283QT",
+       .name                   = "mipi-panel",
+       .desc                   = "MIPI DBI compatible panel",
        .date                   = "20160614",
        .major                  = 1,
        .minor                  = 0,

};

-static const struct of_device_id mi0283qt_of_match[] = {

+static const struct of_device_id mipi_panel_of_match[] = {
        { .compatible = "multi-inno,mi0283qt" },
        {},

};
-MODULE_DEVICE_TABLE(of, mi0283qt_of_match);
+MODULE_DEVICE_TABLE(of, mipi_panel_of_match);

-static const struct spi_device_id mi0283qt_id[] = {

+static const struct spi_device_id mipi_panel_id[] = {
        { "mi0283qt", 0 },
        { },

};
-MODULE_DEVICE_TABLE(spi, mi0283qt_id);
+MODULE_DEVICE_TABLE(spi, mipi_panel_id);

-static int mi0283qt_probe(struct spi_device *spi) +static int mipi_panel_probe(struct spi_device *spi)

 {
        struct device *dev = &spi->dev;
        struct tinydrm_device *tdev;

@@ -195,20 +196,20 @@ static int mi0283qt_probe(struct spi_device *spi)

        device_property_read_u32(dev, "rotation", &rotation);

- ret = mipi_dbi_spi_init(spi, mipi, dc, &mi0283qt_pipe_funcs,
- &mi0283qt_driver, &mi0283qt_mode,
+ ret = mipi_dbi_spi_init(spi, mipi, dc, &mipi_panel_pipe_funcs,
+ &mipi_panel_driver, &mipi_panel_mode,

                                MIPI_DCS_PIXEL_FMT_16BIT, rotation);
        if (ret)
                return ret;

- ret = mi0283qt_init(mipi);

+       ret = mipi_panel_init(mipi);
        if (ret)
                return ret;

        /* use devres to fini after drm unregister (drv->remove is 
before) */
-       ret = devm_add_action(dev, mi0283qt_fini, mipi);
+       ret = devm_add_action(dev, mipi_panel_fini, mipi);
        if (ret) {
-               mi0283qt_fini(mipi);
+               mipi_panel_fini(mipi);
                return ret;
        }

@@ -228,14 +229,14 @@ static int mi0283qt_probe(struct spi_device *spi)

        return 0;

}

-static void mi0283qt_shutdown(struct spi_device *spi) +static void mipi_panel_shutdown(struct spi_device *spi)

 {
        struct mipi_dbi *mipi = spi_get_drvdata(spi);

        tinydrm_shutdown(&mipi->tinydrm);

}

-static int __maybe_unused mi0283qt_pm_suspend(struct device *dev) +static int __maybe_unused mipi_panel_pm_suspend(struct device *dev)

 {
        struct mipi_dbi *mipi = dev_get_drvdata(dev);
        int ret;
@@ -244,40 +245,40 @@ static int __maybe_unused mi0283qt_pm_suspend(struct device *dev)
        if (ret)
                return ret;

- mi0283qt_fini(mipi);
+ mipi_panel_fini(mipi);

        return 0;

}

-static int __maybe_unused mi0283qt_pm_resume(struct device *dev) +static int __maybe_unused mipi_panel_pm_resume(struct device *dev)

 {
        struct mipi_dbi *mipi = dev_get_drvdata(dev);
        int ret;

- ret = mi0283qt_init(mipi);

+       ret = mipi_panel_init(mipi);
        if (ret)
                return ret;

        return tinydrm_resume(&mipi->tinydrm);

}

-static const struct dev_pm_ops mi0283qt_pm_ops = {
- SET_SYSTEM_SLEEP_PM_OPS(mi0283qt_pm_suspend, mi0283qt_pm_resume)
+static const struct dev_pm_ops mipi_panel_pm_ops = {
+ SET_SYSTEM_SLEEP_PM_OPS(mipi_panel_pm_suspend, mipi_panel_pm_resume)
};

-static struct spi_driver mi0283qt_spi_driver = {

+static struct spi_driver mipi_panel_spi_driver = {
        .driver = {
-               .name = "mi0283qt",
+               .name = "mipi-panel",
                .owner = THIS_MODULE,
-               .of_match_table = mi0283qt_of_match,
-               .pm = &mi0283qt_pm_ops,
+               .of_match_table = mipi_panel_of_match,
+               .pm = &mipi_panel_pm_ops,
        },
-       .id_table = mi0283qt_id,
-       .probe = mi0283qt_probe,
-       .shutdown = mi0283qt_shutdown,
+       .id_table = mipi_panel_id,
+       .probe = mipi_panel_probe,
+       .shutdown = mipi_panel_shutdown,

};
-module_spi_driver(mi0283qt_spi_driver);
+module_spi_driver(mipi_panel_spi_driver);

-MODULE_DESCRIPTION("Multi-Inno MI0283QT DRM driver"); +MODULE_DESCRIPTION("MIPI DBI panel DRM driver");
MODULE_AUTHOR("Noralf Trønnes");
MODULE_LICENSE("GPL");
--
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

#12 lore raw
In reply to David Lechner
Quoted 4 lines · David Lechner

The goal of this series is to get the built-in LCD of the LEGO MINDSTORMS EV3 working. But, most of the content here is building up the infrastructure to do that.

Some general comments/questions:

I have noticed that DRM doesn't really have support for monochrome displays. I'm guessing that is because no one really uses them anymore?

The LEGO EV3 display is just an LCD (not the backlit kind). It has two modes of operation. It can to 2bbp grayscale or it can do 1bpp monochrome. The grayscale isn't the best (looks splotchy in places), so it would be nice to be able to choose between these two modes. How would I implement something like that?

Also, how can I indicate to userspace that this display really is monochrome/grayscale since the reported color depth 16bpp?

#27 lore raw
In reply to David Lechner

Hi David,

I'm glad to see a new tinydrm driver!

Den 29.07.2017 21.17, skrev David Lechner:

Quoted 8 lines

The goal of this series is to get the built-in LCD of the LEGO MINDSTORMS EV3 working. But, most of the content here is building up the infrastructure to do that.

The controller used in the EV3 uses MIPI commands, but it uses a different memory layout. The current tinydrm stuff is hard-coded for RGB565, so most of the patches are adding support for other memory layouts.

Quoted 5 lines

I've also made the one existing tinydrm driver generic so that it can work for any MIPI display rather than copying a bunch of boiler-plate code for each panel and/or controller.

Once all of this is done, it is really easy to add a new panel. :-)

I've been down that path, and decided against it. Otherwise mi0283qt and mipi_dbi would have been one driver. I'm not keen on having one driver that supports 50 displays, each with their own initialization sequence. However if the sequences are very similar, then sharing a driver makes sense. Time will tell, it's early days for tinydrm.

With fbtft it's possible to override the init sequence, but the Device Tree guys NAK anything that looks like setting random registers directly from properties and certainly not delays. If we could have copied fbtft in this respect, one mipi_dbi driver would have been enough and the DT would contain the init sequence.
Trying to add DT properties for specific controller properties will most likely turn into a nightmare with the complexity of the controllers. With very simple controllers it's possible:
Documentation/devicetree/bindings/display/ssd1307fb.txt

Maybe over time a pattern emerges that gives us a simple way to describe these panels, but until then I don't want everything in one giant file. If someone from the industry had taken interest in this, then maybe we could have had a useful abstraction from the get go, but alas we're dealing with old technology here.

Now to the ST7586S:

MIPI among other things have standards for interfacing and driving display controllers. For our purpose there are 2 important ones:
- MIPI DCS - Defines a command set for operating the controller.
- MIPI DBI - Defines controller interface modes and pixel formats (RGB)

So is the ST7586S MIPI DCS/DBI compatible?

It's missing some of the commands, but it supports the ones necessary for mipi_dbi. Interface wise it looks to be DBI compatible, but the pixel format isn't.

I don't want to add a lot of complexity to mipi_dbi to support a non standard format, so for maintainability and readability it's better to write new code for this controller. DBI supports more formats than RGB565, but I don't expect any true DBI compatible displays to actually use those since RGB666 has no userspace support and RGB888 kills throughput by 30%.

I suggest you write a new standalone driver for this display including controller code, and if at a later point another ST7586 based display shows up, we can pull out the controller specific code into a library like mipi_dbi does.

You can use the newly merged repaper driver (monochrome) as a template:
https://cgit.freedesktop.org/drm/drm-misc/tree/drivers/gpu/drm/tinydrm/repaper.c

Since the ST7586 adheres to the DBI physical interface standard, you can unwrap this from mipi_dbi so you can use that part of the library.

You can make a patch that changes mipi_dbi_spi_init() so you can use it:

- * usual read commands and initializes @mipi using mipi_dbi_init().
+ * usual read commands.

int mipi_dbi_spi_init(struct spi_device *spi, struct mipi_dbi *mipi,

-              struct gpio_desc *dc,
-              const struct drm_simple_display_pipe_funcs *pipe_funcs,
-              struct drm_driver *driver,
-              const struct drm_display_mode *mode,
-              unsigned int rotation)
+              struct gpio_desc *dc)

{
[...]
- return mipi_dbi_init(dev, mipi, pipe_funcs, driver, mode, rotation);
+ return 0;
}

static int mi0283qt_probe(struct spi_device *spi) {
[...]
- ret = mipi_dbi_spi_init(spi, mipi, dc, &mi0283qt_pipe_funcs,
- &mi0283qt_driver, &mi0283qt_mode, rotation);

+    ret = mipi_dbi_spi_init(spi, mipi, dc);
    if (ret)
        return ret;

+ ret = mipi_dbi_init(dev, mipi, &mi0283qt_pipe_funcs, &mi0283qt_driver,
+ &mi0283qt_mode, rotation);
+ if (ret)
+ return ret;
+

Now you can use mipi_dbi_spi_init() to get the interface abstraction, but instead of calling mipi_dbi_init() you implement your own code.

Noralf.

Quoted 29 lines

David Lechner (6):
drm/tinydrm: Add parameter for MIPI DCS pixel format drm/tinydrm: add helpers for ST7586 controllers drm/tinydrm: rename mi028qt module to mipi-panel drm/tinydrm: mipi-panel: refactor to use driver id drm/tinydrm: add support for LEGO MINDSTORMS EV3 LCD
ARM: dts: da850-lego-ev3: Add node for LCD display

  .../devicetree/bindings/display/mipi-panel.txt     |  27 ++
  .../bindings/display/multi-inno,mi0283qt.txt       |  27 --
  MAINTAINERS                                        |   6 +-
  arch/arm/boot/dts/da850-lego-ev3.dts               |  24 ++
  drivers/gpu/drm/tinydrm/Kconfig                    |  13 +-
  drivers/gpu/drm/tinydrm/Makefile                   |   2 +-
  drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c     | 148 ++++++++
  drivers/gpu/drm/tinydrm/mi0283qt.c                 | 282 ---------------
  drivers/gpu/drm/tinydrm/mipi-dbi.c                 | 117 ++++--
  drivers/gpu/drm/tinydrm/mipi-panel.c               | 395 +++++++++++++++++++++
  include/drm/tinydrm/mipi-dbi.h                     |   9 +-
  include/drm/tinydrm/st7586.h                       |  34 ++
  include/drm/tinydrm/tinydrm-helpers.h              |   6 +
  include/video/mipi_display.h                       |  16 +-
  14 files changed, 759 insertions(+), 347 deletions(-)

create mode 100644 Documentation/devicetree/bindings/display/mipi-panel.txt delete mode 100644 Documentation/devicetree/bindings/display/multi-inno,mi0283qt.txt delete mode 100644 drivers/gpu/drm/tinydrm/mi0283qt.c
create mode 100644 drivers/gpu/drm/tinydrm/mipi-panel.c
create mode 100644 include/drm/tinydrm/st7586.h

#13 lore raw
In reply to David Lechner

Den 29.07.2017 21.40, skrev David Lechner:

Quoted 8 lines · David Lechner
Quoted 6 lines

The goal of this series is to get the built-in LCD of the LEGO MINDSTORMS EV3
working. But, most of the content here is building up the infrastructure to do
that.

Quoted 5 lines

Some general comments/questions:

I have noticed that DRM doesn't really have support for monochrome displays. I'm guessing that is because no one really uses them anymore?

The repaper driver was the first monochrome drm driver and I chose to present it to userspace as XRGB8888 and convert it to monochrome. The reason for this is that everything, libraries, apps, plymouth (boot splash, no rgb565) supports it. I didn't see any point in adding a new monochrome drm format that didn't have, or probably wouldn't get userspace support (by libraries at least). The application of course needs to know this to get a good result.

tinydrm_xrgb8888_to_gray8() does the conversion:
https://cgit.freedesktop.org/drm/drm-misc/commit/drivers/gpu/drm/tinydrm?id=379ea9a1a59a5a32c8db6f164e80a3fd00cb3781

Quoted 6 lines

The LEGO EV3 display is just an LCD (not the backlit kind). It has two modes of operation. It can to 2bbp grayscale or it can do 1bpp monochrome. The grayscale isn't the best (looks splotchy in places), so it would be nice to be able to choose between these two modes. How would I implement something like that?

Do you expect anyone to use grayscale if it doesn't look good? Maybe better to add it later if there's a demand for it.

Quoted 3 lines

Also, how can I indicate to userspace that this display really is monochrome/grayscale since the reported color depth 16bpp?

There isn't unless we add formats for it.
Since this display is in a Lego piece, doesn't it have custom userspace that already know it's monochrome?

Noralf.

#2 lore raw

Re: [PATCH 1/6] drm/tinydrm: Add parameter for MIPI DCS pixel format

In reply to David Lechner
Quoted 9 lines · David Lechner

This adds a parameter for MIPI DCS pixel format to mipi_dbi_init(). This is in preparation for supporting displays that don't use a 16bpp memory layout.

/* MIPI DCS pixel formats */

include/video/mipi_display.h +0 -4
-#define MIPI_DCS_PIXEL_FMT_24BIT       7
-#define MIPI_DCS_PIXEL_FMT_18BIT       6
-#define MIPI_DCS_PIXEL_FMT_16BIT       5
-#define MIPI_DCS_PIXEL_FMT_12BIT       3

include/video/mipi_display.h enum { · line 138

Quoted 10 lines
include/video/mipi_display.h +8 -2
-#define MIPI_DCS_PIXEL_FMT_8BIT                2
-#define MIPI_DCS_PIXEL_FMT_3BIT                1
+enum mipi_dcs_pixel_format {
+       MIPI_DCS_PIXEL_FMT_24BIT        = 7,
+       MIPI_DCS_PIXEL_FMT_18BIT        = 6,
+       MIPI_DCS_PIXEL_FMT_16BIT        = 5,
+       MIPI_DCS_PIXEL_FMT_12BIT        = 3,
+       MIPI_DCS_PIXEL_FMT_8BIT         = 2,
+       MIPI_DCS_PIXEL_FMT_3BIT         = 1,
+};

May I ask what prevents us to arrange enums in natural
ordering (you may keep = X parts, of course)?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#4 lore raw

Re: [PATCH 2/6] drm/tinydrm: add helpers for ST7586 controllers

In reply to David Lechner
Quoted 11 lines · David Lechner

This adds helper functions and support for ST7586 controllers. These controllers have an unusual memory layout where 3 pixels are packed into 1 byte.

+-------+-----------------+
| bit   | 7 6 5 4 3 2 1 0 |
+-------+-----------------+
| pixel | 0 0 0 1 1 1 2 2 |
+-------+-----------------+

So, there are a nuber of places in the tinydrm pipline where this format

number

Quoted 3 lines

needs to be taken into consideration.

+ * tinydrm_rgb565_to_st7586 - Convert RGB565 to ST7586 clip buffer

How this can be generic tinydrm helper?
Why driver can't handle it by its own and avoid spreading stuff into generic header?

drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c void tinydrm_xrgb8888_to_rgb565(u16 *dst, void *vaddr, · line 272

Quoted 5 lines
drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c +3 -0
+void tinydrm_rgb565_to_st7586(u8 *dst, void *vaddr,
 
+ * tinydrm_xrgb8888_to_st7586 - Convert XRGB8888 to ST7586 clip buffer
 
+void tinydrm_xrgb8888_to_st7586(u8 *dst, void *vaddr,

Ditto.

Quoted 5 lines
drivers/gpu/drm/tinydrm/mipi-dbi.c +0 -5
-       switch (fb->format->format) {
-       case DRM_FORMAT_RGB565:
-               if (swap)
-                       tinydrm_swab16(dst, src, fb, clip);
-               else

drivers/gpu/drm/tinydrm/mipi-dbi.c static int mipi_dbi_buf_copy(void *dst, struct drm_framebuffer *fb, · line 181

Quoted 10 lines
drivers/gpu/drm/tinydrm/mipi-dbi.c +9 -1
-                       tinydrm_memcpy(dst, src, fb, clip);
+       switch (pixel_fmt) {
+       case MIPI_DCS_PIXEL_FMT_16BIT:
+               switch (fb->format->format) {
+               case DRM_FORMAT_RGB565:
+                       if (swap)
+                               tinydrm_swab16(dst, src, fb, clip);
+                       else
+                               tinydrm_memcpy(dst, src, fb, clip);
+                       break;

Can't you use some other approach? Callbacks? Plugins?

drivers/gpu/drm/tinydrm/mipi-dbi.c static void mipi_dbi_blank(struct mipi_dbi *mipi) · line 338

Quoted 8 lines
drivers/gpu/drm/tinydrm/mipi-dbi.c +8 -0
+       switch (mipi->pixel_fmt) {
+       case MIPI_DCS_PIXEL_FMT_16BIT:
+               len = width * height * sizeof(u16);
+               break;
+       case MIPI_DCS_PIXEL_FMT_ST7586_332:
+               width = (width + 2) / 3;
+               len = width * height;
+               break;

Ditto.

drivers/gpu/drm/tinydrm/mipi-dbi.c int mipi_dbi_init(struct device *dev, struct mipi_dbi *mipi, · line 424

Quoted 4 lines
drivers/gpu/drm/tinydrm/mipi-dbi.c +4 -0
+       case MIPI_DCS_PIXEL_FMT_ST7586_332:
+               /* 3 pixels per byte */
+               bufsize = (mode->vdisplay + 2) / 3 * mode->hdisplay;
+               break;

Ditto.

drivers/gpu/drm/tinydrm/mipi-dbi.c static int mipi_dbi_typec3_command(struct mipi_dbi *mipi, u8 cmd, · line 835

Quoted 3 lines
drivers/gpu/drm/tinydrm/mipi-dbi.c +2 -1
-       if (cmd == MIPI_DCS_WRITE_MEMORY_START && !mipi->swap_bytes)
+       if (cmd == MIPI_DCS_WRITE_MEMORY_START && !mipi->swap_bytes &&
+           mipi->pixel_fmt != MIPI_DCS_PIXEL_FMT_ST7586_332)

Ditto.

If we allow this we end up to have 100500 LOCs in tinydrm-helpers.c which will have nothing to do with the framework itself.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#8 lore raw

Re: [PATCH 4/6] drm/tinydrm: mipi-panel: refactor to use driver id

In reply to David Lechner
Quoted 3 lines · David Lechner

This refactors the mipi-panel module to use the driver id for panel-specific data. This is in preparation for adding additional panels.

Wouldn't be better to split glue driver from what looks like more generic in the first place? Then you will not need to spread some stuff
over generic files.

Are we going to disrupt genericy of the framework already with second driver?!

Signature · 6 lines
With Best Regards,
Andy Shevchenko
--
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
#10 lore raw

Re: [PATCH 5/6] drm/tinydrm: add support for LEGO MINDSTORMS EV3 LCD

In reply to David Lechner
Quoted 5 lines · David Lechner

LEGO MINDSTORMS EV3 has an LCD with a ST7586 controller. This adds a new module for the ST7586 controller with parameters for the EV3 LCD dispay.

 .../devicetree/bindings/display/mipi-panel.txt     |  2 +-

drivers/gpu/drm/tinydrm/mipi-panel.c | 87 ++++++++++++++++++++++\]

C'mon, changes here have nothing to do with the framework itself!

Header, OTOH, has been looking fine.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#28 lore raw
In reply to David Lechner
Quoted 8 lines · David Lechner

The goal of this series is to get the built-in LCD of the LEGO MINDSTORMS EV3 working. But, most of the content here is building up the infrastructure to do that.

The controller used in the EV3 uses MIPI commands, but it uses a different memory layout. The current tinydrm stuff is hard-coded for RGB565, so most of the patches are adding support for other memory layouts.

Quoted 5 lines

I've also made the one existing tinydrm driver generic so that it can work for any MIPI display rather than copying a bunch of boiler-plate code for each panel and/or controller.

Once all of this is done, it is really easy to add a new panel. :-)

Perhaps pathes are good, but logically completely incorrect.

Signature · 6 lines
With Best Regards,
Andy Shevchenko
--
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
#29 lore raw
Quoted 5 lines · Andy Shevchenko
Quoted 1 line · David Lechner

Once all of this is done, it is really easy to add a new panel. :-)

Perhaps pathes are good, but logically completely incorrect.

s/pathes/patches/

Signature · 6 lines
With Best Regards,
Andy Shevchenko
--
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
#14 lore raw
In reply to Noralf Trønnes
Quoted 35 lines · Noralf Tr?nnes

Den 29.07.2017 21.40, skrev David Lechner:

Quoted 8 lines · David Lechner
Quoted 6 lines

The goal of this series is to get the built-in LCD of the LEGO MINDSTORMS EV3
working. But, most of the content here is building up the infrastructure to do
that.

Quoted 5 lines

Some general comments/questions:

I have noticed that DRM doesn't really have support for monochrome displays. I'm guessing that is because no one really uses them anymore?

The repaper driver was the first monochrome drm driver and I chose to present it to userspace as XRGB8888 and convert it to monochrome. The reason for this is that everything, libraries, apps, plymouth (boot splash, no rgb565) supports it. I didn't see any point in adding a new monochrome drm format that didn't have, or probably wouldn't get userspace support (by libraries at least). The application of course needs to know this to get a good result.

tinydrm_xrgb8888_to_gray8() does the conversion:
https://cgit.freedesktop.org/drm/drm-misc/commit/drivers/gpu/drm/tinydrm?id=379ea9a1a59a5a32c8db6f164e80a3fd00cb3781

Quoted 6 lines

The LEGO EV3 display is just an LCD (not the backlit kind). It has two modes of operation. It can to 2bbp grayscale or it can do 1bpp monochrome. The grayscale isn't the best (looks splotchy in places), so it would be nice to be able to choose between these two modes. How would I implement something like that?

Quoted 2 lines

Do you expect anyone to use grayscale if it doesn't look good? Maybe better to add it later if there's a demand for it.

I don't expect many people to use it at all. The people that do will be hackers like me that want to see what it is capable of, so I think I will keep it grayscale by default.

Quoted 8 lines
Quoted 4 lines

Also, how can I indicate to userspace that this display really is monochrome/grayscale since the reported color depth 16bpp?

There isn't unless we add formats for it.
Since this display is in a Lego piece, doesn't it have custom userspace that already know it's monochrome?

The official LEGO software is like this, yes. But I am working on a project that supports other LEGO compatible devices that have color screens, so the same software needs to be able to detect at runtime which type of screen it is using. Currently I have a plain fbdev driver that provides FB_VISUAL_MONO10 for the EV3 display and so the software knows when it has a monochrome screen and when it doesn't. But since plain fbdev drivers can't be accepted into mainline, I need to find a different way to detect what type of screen this is so that my graphics library can treat it differently.

#15 lore raw

(cc: Daniel Vetter)

Den 01.08.2017 18.51, skrev David Lechner:

Quoted 36 lines · Noralf Tr?nnes
Quoted 35 lines

Den 29.07.2017 21.40, skrev David Lechner:

Quoted 8 lines · David Lechner
Quoted 6 lines

The goal of this series is to get the built-in LCD of the LEGO MINDSTORMS EV3
working. But, most of the content here is building up the infrastructure to do
that.

Quoted 5 lines

Some general comments/questions:

I have noticed that DRM doesn't really have support for monochrome displays. I'm guessing that is because no one really uses them anymore?

The repaper driver was the first monochrome drm driver and I chose to present it to userspace as XRGB8888 and convert it to monochrome. The reason for this is that everything, libraries, apps, plymouth (boot splash, no rgb565) supports it. I didn't see any point in adding a new monochrome drm format that didn't have, or probably wouldn't get userspace support (by libraries at least). The application of course needs to know this to get a good result.

tinydrm_xrgb8888_to_gray8() does the conversion:
https://cgit.freedesktop.org/drm/drm-misc/commit/drivers/gpu/drm/tinydrm?id=379ea9a1a59a5a32c8db6f164e80a3fd00cb3781

Quoted 6 lines

The LEGO EV3 display is just an LCD (not the backlit kind). It has two modes of operation. It can to 2bbp grayscale or it can do 1bpp monochrome. The grayscale isn't the best (looks splotchy in places), so it would be nice to be able to choose between these two modes. How would I implement something like that?

Quoted 7 lines
Quoted 2 lines

Do you expect anyone to use grayscale if it doesn't look good? Maybe better to add it later if there's a demand for it.

I don't expect many people to use it at all. The people that do will be hackers like me that want to see what it is capable of, so I think I will keep it grayscale by default.

It looks like the best way to satisfy your needs is to add specific formats.

Video for Linux have these:

include/uapi/linux/videodev2.h

/* Grey formats */
#define V4L2_PIX_FMT_GREY v4l2_fourcc('G', 'R', 'E', 'Y') /* 8
Greyscale */
#define V4L2_PIX_FMT_Y4 v4l2_fourcc('Y', '0', '4', ' ') /* 4
Greyscale */
#define V4L2_PIX_FMT_Y6 v4l2_fourcc('Y', '0', '6', ' ') /* 6
Greyscale */
#define V4L2_PIX_FMT_Y10 v4l2_fourcc('Y', '1', '0', ' ') /* 10
Greyscale */
#define V4L2_PIX_FMT_Y12 v4l2_fourcc('Y', '1', '2', ' ') /* 12
Greyscale */
#define V4L2_PIX_FMT_Y16 v4l2_fourcc('Y', '1', '6', ' ') /* 16
Greyscale */
#define V4L2_PIX_FMT_Y16_BE v4l2_fourcc_be('Y', '1', '6', ' ') /* 16 Greyscale BE */

Maybe we can add formats like these:

include/uapi/drm/drm_fourcc.h

#define DRM_FORMAT_MONO fourcc_code('Y', '0', '1', ' ') /* [0]
Monochrome */
or
#define DRM_FORMAT_Y1 fourcc_code('Y', '0', '1', ' ') /* [0]
Monochrome */

#define DRM_FORMAT_Y2 fourcc_code('Y', '0', '2', ' ') /* [1:0]
Greyscale */

Daniel, what do you think?

Quoted 9 lines
Quoted 8 lines
Quoted 4 lines

Also, how can I indicate to userspace that this display really is monochrome/grayscale since the reported color depth 16bpp?

There isn't unless we add formats for it.
Since this display is in a Lego piece, doesn't it have custom userspace that already know it's monochrome?

Quoted 11 lines

The official LEGO software is like this, yes. But I am working on a project that supports other LEGO compatible devices that have color screens, so the same software needs to be able to detect at runtime which type of screen it is using. Currently I have a plain fbdev driver that provides FB_VISUAL_MONO10 for the EV3 display and so the software knows when it has a monochrome screen and when it doesn't. But since plain fbdev drivers can't be accepted into mainline, I need to find a different way to detect what type of screen this is so that my graphics library can treat it differently.

You can tell userspace about the preferred bitdepth:
drm->mode_config.preferred_depth

Noralf.

#16 lore raw
Quoted 59 lines · Noralf Trønnes

(cc: Daniel Vetter)

Den 01.08.2017 18.51, skrev David Lechner:

Quoted 26 lines · Noralf Trønnes
Quoted 25 lines

Den 29.07.2017 21.40, skrev David Lechner:

Quoted 10 lines · David Lechner
Quoted 4 lines

The goal of this series is to get the built-in LCD of the LEGO MINDSTORMS EV3 working. But, most of the content here is building up the infrastructure to do that.

Some general comments/questions:

I have noticed that DRM doesn't really have support for monochrome displays. I'm guessing that is because no one really uses them anymore?

The repaper driver was the first monochrome drm driver and I chose to present it to userspace as XRGB8888 and convert it to monochrome. The reason for this is that everything, libraries, apps, plymouth (boot splash, no rgb565) supports it. I didn't see any point in adding a new monochrome drm format that didn't have, or probably wouldn't get userspace support (by libraries at least). The application of course needs to know this to get a good result.

tinydrm_xrgb8888_to_gray8() does the conversion:
https://cgit.freedesktop.org/drm/drm-misc/commit/drivers/gpu/drm/tinydrm?id=379ea9a1a59a5a32c8db6f164e80a3fd00cb3781

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

The LEGO EV3 display is just an LCD (not the backlit kind). It has two modes of operation. It can to 2bbp grayscale or it can do 1bpp monochrome. The grayscale isn't the best (looks splotchy in places), so it would be nice to be able to choose between these two modes. How would I implement something like that?

Do you expect anyone to use grayscale if it doesn't look good? Maybe better to add it later if there's a demand for it.

I don't expect many people to use it at all. The people that do will be hackers like me that want to see what it is capable of, so I think I will keep it grayscale by default.

It looks like the best way to satisfy your needs is to add specific formats.

Video for Linux have these:

include/uapi/linux/videodev2.h

/* Grey formats */

#define V4L2_PIX_FMT_GREY    v4l2_fourcc('G', 'R', 'E', 'Y') /*  8 Greyscale     */
#define V4L2_PIX_FMT_Y4      v4l2_fourcc('Y', '0', '4', ' ') /*  4 Greyscale     */
#define V4L2_PIX_FMT_Y6      v4l2_fourcc('Y', '0', '6', ' ') /*  6 Greyscale     */
#define V4L2_PIX_FMT_Y10     v4l2_fourcc('Y', '1', '0', ' ') /* 10 Greyscale     */
#define V4L2_PIX_FMT_Y12     v4l2_fourcc('Y', '1', '2', ' ') /* 12 Greyscale     */
#define V4L2_PIX_FMT_Y16     v4l2_fourcc('Y', '1', '6', ' ') /* 16 Greyscale     */
#define V4L2_PIX_FMT_Y16_BE  v4l2_fourcc_be('Y', '1', '6', ' ') /* 16 Greyscale BE  */

Maybe we can add formats like these:

include/uapi/drm/drm_fourcc.h

Quoted 7 lines

#define DRM_FORMAT_MONO fourcc_code('Y', '0', '1', ' ') /* [0] Monochrome */
or
#define DRM_FORMAT_Y1 fourcc_code('Y', '0', '1', ' ') /* [0] Monochrome */

#define DRM_FORMAT_Y2 fourcc_code('Y', '0', '2', ' ') /* [1:0] Greyscale */

Daniel, what do you think?

2 of the first 3 tinydrm drivers are monochrome (and I would like to write a driver for the Seeed/Grove I2C OLED displays which are also monochrome), so I think the 1bpp modes would definitely be useful. I think there is enough userspace code still around that knows about FB_VISUAL_MONO01 and FB_VISUAL_MONO10 that could use these.

I don't think a Y02 mode would be useful though. There is pretty much nothing out there (that I could find) that uses such a mode.

A Y08 mode for 8bpp grayscale would be useful though. This is another more commonly used format.

Quoted 13 lines
Quoted 12 lines
Quoted 8 lines
Quoted 4 lines

Also, how can I indicate to userspace that this display really is monochrome/grayscale since the reported color depth 16bpp?

There isn't unless we add formats for it.
Since this display is in a Lego piece, doesn't it have custom userspace that already know it's monochrome?

The official LEGO software is like this, yes. But I am working on a project that supports other LEGO compatible devices that have color screens, so the same software needs to be able to detect at runtime which type of screen it is using. Currently I have a plain fbdev driver that provides FB_VISUAL_MONO10 for the EV3 display and so the software knows when it has a monochrome screen and when it doesn't. But since plain fbdev drivers can't be accepted into mainline, I need to find a different way to detect what type of screen this is so that my graphics library can treat it differently.

Quoted 6 lines

You can tell userspace about the preferred bitdepth:
drm->mode_config.preferred_depth

Noralf.

--
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

#17 lore raw

Den 02.08.2017 00.26, skrev David Lechner:

Quoted 64 lines · Noralf Trønnes
Quoted 63 lines

(cc: Daniel Vetter)

Den 01.08.2017 18.51, skrev David Lechner:

Quoted 26 lines · Noralf Trønnes
Quoted 25 lines

Den 29.07.2017 21.40, skrev David Lechner:

Quoted 10 lines · David Lechner
Quoted 4 lines

The goal of this series is to get the built-in LCD of the LEGO MINDSTORMS EV3 working. But, most of the content here is building up the infrastructure to do that.

Some general comments/questions:

I have noticed that DRM doesn't really have support for monochrome displays. I'm guessing that is because no one really uses them anymore?

The repaper driver was the first monochrome drm driver and I chose to present it to userspace as XRGB8888 and convert it to monochrome. The reason for this is that everything, libraries, apps, plymouth (boot splash, no rgb565) supports it. I didn't see any point in adding a new monochrome drm format that didn't have, or probably wouldn't get userspace support (by libraries at least). The application of course needs to know this to get a good result.

tinydrm_xrgb8888_to_gray8() does the conversion:
https://cgit.freedesktop.org/drm/drm-misc/commit/drivers/gpu/drm/tinydrm?id=379ea9a1a59a5a32c8db6f164e80a3fd00cb3781

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

The LEGO EV3 display is just an LCD (not the backlit kind). It has two modes of operation. It can to 2bbp grayscale or it can do 1bpp monochrome. The grayscale isn't the best (looks splotchy in places), so it would be nice to be able to choose between these two modes. How would I implement something like that?

Do you expect anyone to use grayscale if it doesn't look good? Maybe better to add it later if there's a demand for it.

I don't expect many people to use it at all. The people that do will be hackers like me that want to see what it is capable of, so I think I will keep it grayscale by default.

It looks like the best way to satisfy your needs is to add specific formats.

Video for Linux have these:

include/uapi/linux/videodev2.h

/* Grey formats */

#define V4L2_PIX_FMT_GREY    v4l2_fourcc('G', 'R', 'E', 'Y') /* 8 Greyscale     */
#define V4L2_PIX_FMT_Y4      v4l2_fourcc('Y', '0', '4', ' ') /* 4 Greyscale     */
#define V4L2_PIX_FMT_Y6      v4l2_fourcc('Y', '0', '6', ' ') /* 6 Greyscale     */
#define V4L2_PIX_FMT_Y10     v4l2_fourcc('Y', '1', '0', ' ') /* 10 Greyscale     */
#define V4L2_PIX_FMT_Y12     v4l2_fourcc('Y', '1', '2', ' ') /* 12 Greyscale     */
#define V4L2_PIX_FMT_Y16     v4l2_fourcc('Y', '1', '6', ' ') /* 16 Greyscale     */
#define V4L2_PIX_FMT_Y16_BE  v4l2_fourcc_be('Y', '1', '6', ' ') /* 16 Greyscale BE  */

Maybe we can add formats like these:

include/uapi/drm/drm_fourcc.h

#define DRM_FORMAT_MONO fourcc_code('Y', '0', '1', ' ') /* [0] Monochrome */
or
#define DRM_FORMAT_Y1 fourcc_code('Y', '0', '1', ' ') /* [0] Monochrome */

Quoted 6 lines
Quoted 3 lines

#define DRM_FORMAT_Y2 fourcc_code('Y', '0', '2', ' ') /* [1:0] Greyscale */

Daniel, what do you think?

2 of the first 3 tinydrm drivers are monochrome (and I would like to write a driver for the Seeed/Grove I2C OLED displays which are also monochrome), so I think the 1bpp modes would definitely be useful. I think there is enough userspace code still around that knows about FB_VISUAL_MONO01 and FB_VISUAL_MONO10 that could use these.

Can you elaborate, would you use the display trough monochrome fbdev or through drm?

Quoted 4 lines

I don't think a Y02 mode would be useful though. There is pretty much nothing out there (that I could find) that uses such a mode.

A Y08 mode for 8bpp grayscale would be useful though. This is another more commonly used format.

Another source of fourcc's is FFmpeg which has these:

    { AV_PIX_FMT_GRAY8,    MKTAG('Y', '8', '0', '0') },
    { AV_PIX_FMT_GRAY8,    MKTAG('Y', '8', ' ', ' ') },
    { AV_PIX_FMT_GRAY8,   MKTAG('G', 'R', 'E', 'Y') },

    { AV_PIX_FMT_MONOWHITE,MKTAG('B', '1', 'W', '0') },
    { AV_PIX_FMT_MONOBLACK,MKTAG('B', '0', 'W', '1') },

AV_PIX_FMT_GRAY8
Y , 8bpp.
AV_PIX_FMT_MONOWHITE
Y , 1bpp, 0 is white, 1 is black,
in each byte pixels are ordered from the msb to the lsb.
AV_PIX_FMT_MONOBLACK
Y , 1bpp, 0 is black, 1 is white,
in each byte pixels are ordered from the msb to the lsb.

__drm_format_info() provides details about formats:
{ .format = DRM_FORMAT_MONO, .depth = 1, .num_planes = 1, .cpp
= { 0, 0, 0 }, .hsub = 1, .vsub = 1 },
{ .format = DRM_FORMAT_GREY, .depth = 8, .num_planes = 1, .cpp
= { 1, 0, 0 }, .hsub = 1, .vsub = 1 },

framebuffer_check() and drm_fb_cma_create_with_funcs() use cpp for validation and they don't expect it to be zero.

Noralf.

Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Quoted 8 lines
Quoted 4 lines

Also, how can I indicate to userspace that this display really is monochrome/grayscale since the reported color depth 16bpp?

There isn't unless we add formats for it.
Since this display is in a Lego piece, doesn't it have custom userspace that already know it's monochrome?

The official LEGO software is like this, yes. But I am working on a project that supports other LEGO compatible devices that have color screens, so the same software needs to be able to detect at runtime which type of screen it is using. Currently I have a plain fbdev driver that provides FB_VISUAL_MONO10 for the EV3 display and so the software knows when it has a monochrome screen and when it doesn't. But since plain fbdev drivers can't be accepted into mainline, I need to find a different way to detect what type of screen this is so that my graphics library can treat it differently.

Quoted 7 lines
Quoted 6 lines

You can tell userspace about the preferred bitdepth:
drm->mode_config.preferred_depth

Noralf.

--
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

#18 lore raw
Quoted 68 lines · Noralf Trønnes

Den 02.08.2017 00.26, skrev David Lechner:

Quoted 66 lines · Noralf Trønnes
Quoted 65 lines

(cc: Daniel Vetter)

Den 01.08.2017 18.51, skrev David Lechner:

Quoted 26 lines · Noralf Trønnes
Quoted 25 lines

Den 29.07.2017 21.40, skrev David Lechner:

Quoted 10 lines · David Lechner
Quoted 4 lines

The goal of this series is to get the built-in LCD of the LEGO MINDSTORMS EV3 working. But, most of the content here is building up the infrastructure to do that.

Some general comments/questions:

I have noticed that DRM doesn't really have support for monochrome displays. I'm guessing that is because no one really uses them anymore?

The repaper driver was the first monochrome drm driver and I chose to present it to userspace as XRGB8888 and convert it to monochrome. The reason for this is that everything, libraries, apps, plymouth (boot splash, no rgb565) supports it. I didn't see any point in adding a new monochrome drm format that didn't have, or probably wouldn't get userspace support (by libraries at least). The application of course needs to know this to get a good result.

tinydrm_xrgb8888_to_gray8() does the conversion:
https://cgit.freedesktop.org/drm/drm-misc/commit/drivers/gpu/drm/tinydrm?id=379ea9a1a59a5a32c8db6f164e80a3fd00cb3781

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

The LEGO EV3 display is just an LCD (not the backlit kind). It has two modes of operation. It can to 2bbp grayscale or it can do 1bpp monochrome. The grayscale isn't the best (looks splotchy in places), so it would be nice to be able to choose between these two modes. How would I implement something like that?

Do you expect anyone to use grayscale if it doesn't look good? Maybe better to add it later if there's a demand for it.

I don't expect many people to use it at all. The people that do will be hackers like me that want to see what it is capable of, so I think I will keep it grayscale by default.

It looks like the best way to satisfy your needs is to add specific formats.

Video for Linux have these:

include/uapi/linux/videodev2.h

/* Grey formats */

#define V4L2_PIX_FMT_GREY    v4l2_fourcc('G', 'R', 'E', 'Y') /* 8 Greyscale     */
#define V4L2_PIX_FMT_Y4      v4l2_fourcc('Y', '0', '4', ' ') /* 4 Greyscale     */
#define V4L2_PIX_FMT_Y6      v4l2_fourcc('Y', '0', '6', ' ') /* 6 Greyscale     */
#define V4L2_PIX_FMT_Y10     v4l2_fourcc('Y', '1', '0', ' ') /* 10 Greyscale     */
#define V4L2_PIX_FMT_Y12     v4l2_fourcc('Y', '1', '2', ' ') /* 12 Greyscale     */
#define V4L2_PIX_FMT_Y16     v4l2_fourcc('Y', '1', '6', ' ') /* 16 Greyscale     */
#define V4L2_PIX_FMT_Y16_BE  v4l2_fourcc_be('Y', '1', '6', ' ') /* 16 Greyscale BE  */

Maybe we can add formats like these:

include/uapi/drm/drm_fourcc.h

#define DRM_FORMAT_MONO fourcc_code('Y', '0', '1', ' ') /* [0] Monochrome */
or
#define DRM_FORMAT_Y1 fourcc_code('Y', '0', '1', ' ') /* [0] Monochrome */

#define DRM_FORMAT_Y2 fourcc_code('Y', '0', '2', ' ') /* [1:0] Greyscale */

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Daniel, what do you think?

2 of the first 3 tinydrm drivers are monochrome (and I would like to write a driver for the Seeed/Grove I2C OLED displays which are also monochrome), so I think the 1bpp modes would definitely be useful. I think there is enough userspace code still around that knows about FB_VISUAL_MONO01 and FB_VISUAL_MONO10 that could use these.

Can you elaborate, would you use the display trough monochrome fbdev or through drm?

I have a small collection of programs and libraries that work using monochrome fbdev. I would like to just keep using them without having to convert everything to drm.

Quoted 57 lines
Quoted 4 lines

I don't think a Y02 mode would be useful though. There is pretty much nothing out there (that I could find) that uses such a mode.

A Y08 mode for 8bpp grayscale would be useful though. This is another more commonly used format.

Another source of fourcc's is FFmpeg which has these:

     { AV_PIX_FMT_GRAY8,    MKTAG('Y', '8', '0', '0') },
     { AV_PIX_FMT_GRAY8,    MKTAG('Y', '8', ' ', ' ') },
     { AV_PIX_FMT_GRAY8,   MKTAG('G', 'R', 'E', 'Y') },

     { AV_PIX_FMT_MONOWHITE,MKTAG('B', '1', 'W', '0') },
     { AV_PIX_FMT_MONOBLACK,MKTAG('B', '0', 'W', '1') },

AV_PIX_FMT_GRAY8
Y , 8bpp.
AV_PIX_FMT_MONOWHITE
Y , 1bpp, 0 is white, 1 is black,
in each byte pixels are ordered from the msb to the lsb.
AV_PIX_FMT_MONOBLACK
Y , 1bpp, 0 is black, 1 is white,
in each byte pixels are ordered from the msb to the lsb.

__drm_format_info() provides details about formats:
{ .format = DRM_FORMAT_MONO, .depth = 1, .num_planes = 1, .cpp
= { 0, 0, 0 }, .hsub = 1, .vsub = 1 },
{ .format = DRM_FORMAT_GREY, .depth = 8, .num_planes = 1, .cpp
= { 1, 0, 0 }, .hsub = 1, .vsub = 1 },

framebuffer_check() and drm_fb_cma_create_with_funcs() use cpp for validation and they don't expect it to be zero.

Noralf.

Quoted 20 lines
Quoted 19 lines
Quoted 12 lines
Quoted 8 lines
Quoted 4 lines

Also, how can I indicate to userspace that this display really is monochrome/grayscale since the reported color depth 16bpp?

There isn't unless we add formats for it.
Since this display is in a Lego piece, doesn't it have custom userspace that already know it's monochrome?

The official LEGO software is like this, yes. But I am working on a project that supports other LEGO compatible devices that have color screens, so the same software needs to be able to detect at runtime which type of screen it is using. Currently I have a plain fbdev driver that provides FB_VISUAL_MONO10 for the EV3 display and so the software knows when it has a monochrome screen and when it doesn't. But since plain fbdev drivers can't be accepted into mainline, I need to find a different way to detect what type of screen this is so that my graphics library can treat it differently.

You can tell userspace about the preferred bitdepth:
drm->mode_config.preferred_depth

Noralf.

#19 lore raw
Quoted 102 lines · David Lechner
Quoted 101 lines · Noralf Tr?nnes

Den 02.08.2017 00.26, skrev David Lechner:

Quoted 98 lines · Noralf Tr?nnes
Quoted 86 lines

(cc: Daniel Vetter)

Den 01.08.2017 18.51, skrev David Lechner:

Quoted 40 lines · Noralf Tr?nnes
Quoted 39 lines

Den 29.07.2017 21.40, skrev David Lechner:

Quoted 8 lines · David Lechner
Quoted 6 lines

The goal of this series is to get the built-in LCD of the LEGO MINDSTORMS EV3
working. But, most of the content here is building up the infrastructure to do that.

Quoted 6 lines

Some general comments/questions:

I have noticed that DRM doesn't really have support for monochrome displays. I'm guessing that is because no one really uses them anymore?

The repaper driver was the first monochrome drm driver and I chose to present it to userspace as XRGB8888 and convert it to monochrome. The reason for this is that everything, libraries, apps, plymouth (boot
splash, no rgb565) supports it. I didn't see any point in adding a new monochrome drm format that didn't have, or probably wouldn't get userspace support (by libraries at least). The application of course needs to know this to get a good result.

tinydrm_xrgb8888_to_gray8() does the conversion:
https://cgit.freedesktop.org/drm/drm-misc/commit/drivers/gpu/drm/tinydrm?id=379ea9a1a59a5a32c8db6f164e80a3fd00cb3781

Quoted 8 lines

The LEGO EV3 display is just an LCD (not the backlit kind). It has two modes of operation. It can to 2bbp grayscale or it can do 1bpp monochrome. The grayscale isn't the best (looks splotchy in places), so it would be nice to be able to choose between these two modes. How would I implement something like that?

Quoted 7 lines
Quoted 2 lines

Do you expect anyone to use grayscale if it doesn't look good? Maybe better to add it later if there's a demand for it.

I don't expect many people to use it at all. The people that do will be hackers like me that want to see what it is capable of, so I think I will keep it grayscale by default.

It looks like the best way to satisfy your needs is to add specific formats.

Video for Linux have these:

include/uapi/linux/videodev2.h

/* Grey formats */
#define V4L2_PIX_FMT_GREY v4l2_fourcc('G', 'R', 'E', 'Y') /*
8 Greyscale */
#define V4L2_PIX_FMT_Y4 v4l2_fourcc('Y', '0', '4', ' ') /*
4 Greyscale */
#define V4L2_PIX_FMT_Y6 v4l2_fourcc('Y', '0', '6', ' ') /*
6 Greyscale */
#define V4L2_PIX_FMT_Y10 v4l2_fourcc('Y', '1', '0', ' ') /*
10 Greyscale */
#define V4L2_PIX_FMT_Y12 v4l2_fourcc('Y', '1', '2', ' ') /*
12 Greyscale */
#define V4L2_PIX_FMT_Y16 v4l2_fourcc('Y', '1', '6', ' ') /*
16 Greyscale */
#define V4L2_PIX_FMT_Y16_BE v4l2_fourcc_be('Y', '1', '6', ' ') /* 16 Greyscale BE */

Maybe we can add formats like these:

include/uapi/drm/drm_fourcc.h

#define DRM_FORMAT_MONO fourcc_code('Y', '0', '1', ' ')
/* [0] Monochrome */
or
#define DRM_FORMAT_Y1 fourcc_code('Y', '0', '1', ' ') /*
[0] Monochrome */

Quoted 4 lines

#define DRM_FORMAT_Y2 fourcc_code('Y', '0', '2', ' ') /*
[1:0] Greyscale */

Daniel, what do you think?

2 of the first 3 tinydrm drivers are monochrome (and I would like to write a driver for the Seeed/Grove I2C OLED displays which are also monochrome), so I think the 1bpp modes would definitely be useful. I think there is enough userspace code still around that knows about FB_VISUAL_MONO01 and FB_VISUAL_MONO10 that could use these.

Quoted 6 lines
Quoted 2 lines

Can you elaborate, would you use the display trough monochrome fbdev or through drm?

I have a small collection of programs and libraries that work using monochrome fbdev. I would like to just keep using them without having to convert everything to drm.

That probably means we'd need to extend fbdev emulation helpers in drm to support Monochrome modes better. Shouldn't be that much work really. -Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
#20 lore raw
In reply to David Lechner

Den 02.08.2017 00.26, skrev David Lechner:

Quoted 64 lines · Noralf Trønnes
Quoted 63 lines

(cc: Daniel Vetter)

Den 01.08.2017 18.51, skrev David Lechner:

Quoted 26 lines · Noralf Trønnes
Quoted 25 lines

Den 29.07.2017 21.40, skrev David Lechner:

Quoted 10 lines · David Lechner
Quoted 4 lines

The goal of this series is to get the built-in LCD of the LEGO MINDSTORMS EV3 working. But, most of the content here is building up the infrastructure to do that.

Some general comments/questions:

I have noticed that DRM doesn't really have support for monochrome displays. I'm guessing that is because no one really uses them anymore?

The repaper driver was the first monochrome drm driver and I chose to present it to userspace as XRGB8888 and convert it to monochrome. The reason for this is that everything, libraries, apps, plymouth (boot splash, no rgb565) supports it. I didn't see any point in adding a new monochrome drm format that didn't have, or probably wouldn't get userspace support (by libraries at least). The application of course needs to know this to get a good result.

tinydrm_xrgb8888_to_gray8() does the conversion:
https://cgit.freedesktop.org/drm/drm-misc/commit/drivers/gpu/drm/tinydrm?id=379ea9a1a59a5a32c8db6f164e80a3fd00cb3781

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

The LEGO EV3 display is just an LCD (not the backlit kind). It has two modes of operation. It can to 2bbp grayscale or it can do 1bpp monochrome. The grayscale isn't the best (looks splotchy in places), so it would be nice to be able to choose between these two modes. How would I implement something like that?

Do you expect anyone to use grayscale if it doesn't look good? Maybe better to add it later if there's a demand for it.

I don't expect many people to use it at all. The people that do will be hackers like me that want to see what it is capable of, so I think I will keep it grayscale by default.

It looks like the best way to satisfy your needs is to add specific formats.

Video for Linux have these:

include/uapi/linux/videodev2.h

/* Grey formats */

#define V4L2_PIX_FMT_GREY    v4l2_fourcc('G', 'R', 'E', 'Y') /* 8 Greyscale     */
#define V4L2_PIX_FMT_Y4      v4l2_fourcc('Y', '0', '4', ' ') /* 4 Greyscale     */
#define V4L2_PIX_FMT_Y6      v4l2_fourcc('Y', '0', '6', ' ') /* 6 Greyscale     */
#define V4L2_PIX_FMT_Y10     v4l2_fourcc('Y', '1', '0', ' ') /* 10 Greyscale     */
#define V4L2_PIX_FMT_Y12     v4l2_fourcc('Y', '1', '2', ' ') /* 12 Greyscale     */
#define V4L2_PIX_FMT_Y16     v4l2_fourcc('Y', '1', '6', ' ') /* 16 Greyscale     */
#define V4L2_PIX_FMT_Y16_BE  v4l2_fourcc_be('Y', '1', '6', ' ') /* 16 Greyscale BE  */

Maybe we can add formats like these:

include/uapi/drm/drm_fourcc.h

#define DRM_FORMAT_MONO fourcc_code('Y', '0', '1', ' ') /* [0] Monochrome */
or
#define DRM_FORMAT_Y1 fourcc_code('Y', '0', '1', ' ') /* [0] Monochrome */

Quoted 5 lines
Quoted 3 lines

#define DRM_FORMAT_Y2 fourcc_code('Y', '0', '2', ' ') /* [1:0] Greyscale */

Daniel, what do you think?

2 of the first 3 tinydrm drivers are monochrome (and I would like to write a driver for the Seeed/Grove I2C OLED displays which are also monochrome), so I think the 1bpp modes would definitely be useful.

David, I'm curious about those displays what controller/interface they use. I have been hoping that it would be possible to use regmap as an abstraction for many of these controllers and their registers.

For MIPI DCS it wasn't possible because it's command oriented with arguments. Since zero arguments is possible, a register with no value is nonsense, even though the regmap implementation happily let me do it. There's also the problem that regmap doesn't support registers with different widths. Which is a problem if all registers are 8-bit wide, except the GRAM register being 16-bit on RGB565 formats.

regmap is especially helpful with controllers that also have gpios/keypad/touch/pwm, since the mfd (multi function device) subsystem has good support for sharing regmaps between drivers. Multi function devices are split into several drivers.

Noralf.

--
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

#21 lore raw
Quoted 92 lines · Noralf Tr?nnes

Den 02.08.2017 00.26, skrev David Lechner:

Quoted 90 lines · Noralf Tr?nnes
Quoted 88 lines

(cc: Daniel Vetter)

Den 01.08.2017 18.51, skrev David Lechner:

Quoted 38 lines · Noralf Tr?nnes
Quoted 37 lines

Den 29.07.2017 21.40, skrev David Lechner:

Quoted 8 lines · David Lechner
Quoted 6 lines

The goal of this series is to get the built-in LCD of the LEGO MINDSTORMS EV3
working. But, most of the content here is building up the infrastructure to do
that.

Quoted 6 lines

Some general comments/questions:

I have noticed that DRM doesn't really have support for monochrome displays. I'm guessing that is because no one really uses them anymore?

The repaper driver was the first monochrome drm driver and I chose to present it to userspace as XRGB8888 and convert it to monochrome. The reason for this is that everything, libraries, apps, plymouth (boot
splash, no rgb565) supports it. I didn't see any point in adding a new monochrome drm format that didn't have, or probably wouldn't get userspace support (by libraries at least). The application of course needs to know this to get a good result.

tinydrm_xrgb8888_to_gray8() does the conversion:
https://cgit.freedesktop.org/drm/drm-misc/commit/drivers/gpu/drm/tinydrm?id=379ea9a1a59a5a32c8db6f164e80a3fd00cb3781

Quoted 6 lines

The LEGO EV3 display is just an LCD (not the backlit kind). It has two modes of operation. It can to 2bbp grayscale or it can do 1bpp monochrome. The grayscale isn't the best (looks splotchy in places), so it would be nice to be able to choose between these two modes. How would I implement something like that?

Quoted 7 lines
Quoted 2 lines

Do you expect anyone to use grayscale if it doesn't look good? Maybe better to add it later if there's a demand for it.

I don't expect many people to use it at all. The people that do will be hackers like me that want to see what it is capable of, so I think I will keep it grayscale by default.

It looks like the best way to satisfy your needs is to add specific formats.

Video for Linux have these:

include/uapi/linux/videodev2.h

/* Grey formats */
#define V4L2_PIX_FMT_GREY v4l2_fourcc('G', 'R', 'E', 'Y') /* 8
Greyscale */
#define V4L2_PIX_FMT_Y4 v4l2_fourcc('Y', '0', '4', ' ') /* 4
Greyscale */
#define V4L2_PIX_FMT_Y6 v4l2_fourcc('Y', '0', '6', ' ') /* 6
Greyscale */
#define V4L2_PIX_FMT_Y10 v4l2_fourcc('Y', '1', '0', ' ') /* 10
Greyscale */
#define V4L2_PIX_FMT_Y12 v4l2_fourcc('Y', '1', '2', ' ') /* 12
Greyscale */
#define V4L2_PIX_FMT_Y16 v4l2_fourcc('Y', '1', '6', ' ') /* 16
Greyscale */
#define V4L2_PIX_FMT_Y16_BE v4l2_fourcc_be('Y', '1', '6', ' ') /* 16 Greyscale BE */

Maybe we can add formats like these:

include/uapi/drm/drm_fourcc.h

#define DRM_FORMAT_MONO fourcc_code('Y', '0', '1', ' ') /* [0]
Monochrome */
or
#define DRM_FORMAT_Y1 fourcc_code('Y', '0', '1', ' ') /* [0]
Monochrome */

#define DRM_FORMAT_Y2 fourcc_code('Y', '0', '2', ' ') /* [1:0]
Greyscale */

Daniel, what do you think?

Quoted 7 lines
Quoted 3 lines

2 of the first 3 tinydrm drivers are monochrome (and I would like to write a driver for the Seeed/Grove I2C OLED displays which are also monochrome), so I think the 1bpp modes would definitely be useful.

David, I'm curious about those displays what controller/interface they use. I have been hoping that it would be possible to use regmap as an abstraction for many of these controllers and their registers.

The particular display I have is this one:
http://wiki.seeed.cc/Grove-OLED_Display_1.12inch/

It looks like it uses a command/data scheme like the MIPI displays, but doesn't use any of the standard values for the commands. The controller can do parallel, SPI and I2C, but the display I have is wired for I2C.

Quoted 15 lines

For MIPI DCS it wasn't possible because it's command oriented with arguments. Since zero arguments is possible, a register with no value is nonsense, even though the regmap implementation happily let me do it. There's also the problem that regmap doesn't support registers with different widths. Which is a problem if all registers are 8-bit wide, except the GRAM register being 16-bit on RGB565 formats.

regmap is especially helpful with controllers that also have gpios/keypad/touch/pwm, since the mfd (multi function device) subsystem has good support for sharing regmaps between drivers. Multi function devices are split into several drivers.

Noralf.

#22 lore raw
Quoted 6 lines · David Lechner

The particular display I have is this one:
http://wiki.seeed.cc/Grove-OLED_Display_1.12inch/

It looks like it uses a command/data scheme like the MIPI displays, but doesn't use any of the standard values for the commands. The controller can do parallel, SPI and I2C, but the display I have is wired for I2C.

It looks very similar to ssd1306. Some description refers to ssd1308.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#23 lore raw
Quoted 10 lines · Andy Shevchenko
Quoted 6 lines · David Lechner

The particular display I have is this one:
http://wiki.seeed.cc/Grove-OLED_Display_1.12inch/

It looks like it uses a command/data scheme like the MIPI displays, but doesn't use any of the standard values for the commands. The controller can do parallel, SPI and I2C, but the display I have is wired for I2C.

It looks very similar to ssd1306. Some description refers to ssd1308.

http://www.mouser.com/catalog/specsheets/Seeed_104030008.pdf

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#24 lore raw

Den 03.08.2017 19.11, skrev Andy Shevchenko:

Quoted 4 lines
Quoted 2 lines · Andy Shevchenko

On Thu, Aug 3, 2017 at 6:18 PM, David Lechner <david-nq/r/kbU++upp/[email protected]> wrote:

Quoted 9 lines
Quoted 7 lines
Quoted 6 lines

The particular display I have is this one:
http://wiki.seeed.cc/Grove-OLED_Display_1.12inch/

It looks like it uses a command/data scheme like the MIPI displays, but doesn't use any of the standard values for the commands. The controller can do parallel, SPI and I2C, but the display I have is wired for I2C.

It looks very similar to ssd1306. Some description refers to ssd1308.

http://www.mouser.com/catalog/specsheets/Seeed_104030008.pdf

That pdf refers to another one: http://wiki.seeed.cc/Grove-OLED_Display_0.96inch/
There's an fbdev driver that supports ssd1305, ssd1306, ssd1307 and ssd1309:
https://www.kernel.org/doc/Documentation/devicetree/bindings/display/ssd1307fb.txt
http://elixir.free-electrons.com/linux/latest/source/drivers/video/fbdev/ssd1307fb.c
Maybe the ssd1308 will work with that driver...

Noralf.

--
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

#25 lore raw
Quoted 24 lines · Noralf Tr?nnes

Den 03.08.2017 19.11, skrev Andy Shevchenko:

Quoted 8 lines
Quoted 6 lines · Andy Shevchenko
Quoted 3 lines · David Lechner

The particular display I have is this one:
http://wiki.seeed.cc/Grove-OLED_Display_1.12inch/

Quoted 7 lines
Quoted 5 lines
Quoted 4 lines

It looks like it uses a command/data scheme like the MIPI displays, but doesn't use any of the standard values for the commands. The controller can
do parallel, SPI and I2C, but the display I have is wired for I2C.

It looks very similar to ssd1306. Some description refers to ssd1308.

http://www.mouser.com/catalog/specsheets/Seeed_104030008.pdf

That pdf refers to another one:
http://wiki.seeed.cc/Grove-OLED_Display_0.96inch/
There's an fbdev driver that supports ssd1305, ssd1306, ssd1307 and ssd1309:
https://www.kernel.org/doc/Documentation/devicetree/bindings/display/ssd1307fb.txt

Quoted 4 lines

http://elixir.free-electrons.com/linux/latest/source/drivers/video/fbdev/ssd1307fb.c

Maybe the ssd1308 will work with that driver...

The display I have uses a ssd1327 controller. It is 16-bit grayscale. The ssd130x are all 1-bit monochrome. So, probably more like the ssd1325 driver in fbftf.

#26 lore raw
Quoted 21 lines · David Lechner
Quoted 20 lines · Noralf Trønnes

Den 03.08.2017 19.11, skrev Andy Shevchenko:

Quoted 4 lines
Quoted 2 lines · Andy Shevchenko

On Thu, Aug 3, 2017 at 6:18 PM, David Lechner <david-nq/r/kbU++upp/[email protected]> wrote:

Quoted 9 lines
Quoted 7 lines
Quoted 6 lines

The particular display I have is this one:
http://wiki.seeed.cc/Grove-OLED_Display_1.12inch/

It looks like it uses a command/data scheme like the MIPI displays, but doesn't use any of the standard values for the commands. The controller can do parallel, SPI and I2C, but the display I have is wired for I2C.

It looks very similar to ssd1306. Some description refers to ssd1308.

http://www.mouser.com/catalog/specsheets/Seeed_104030008.pdf

That pdf refers to another one: http://wiki.seeed.cc/Grove-OLED_Display_0.96inch/
There's an fbdev driver that supports ssd1305, ssd1306, ssd1307 and ssd1309:
https://www.kernel.org/doc/Documentation/devicetree/bindings/display/ssd1307fb.txt

Quoted 6 lines
Quoted 4 lines

http://elixir.free-electrons.com/linux/latest/source/drivers/video/fbdev/ssd1307fb.c

Maybe the ssd1308 will work with that driver...

The display I have uses a ssd1327 controller. It is 16-bit grayscale. The ssd130x are all 1-bit monochrome. So, probably more like the ssd1325 driver in fbftf.

correction, 4-bit grayscale
--
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