Skip to contentSkip to conversation

drm: shmobile: Fixes and enhancements

PATCH Superseded Geert Uytterhoeven 3 participants 10 messages Apr 17, 2023 – Apr 18, 2023

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover drm: shmobile: Fixes and enhancements

Hi all,

Currently, there are two drivers for the LCD controller on Renesas SuperH-based and ARM-based SH-Mobile and R-Mobile SoCs:
1. sh_mobile_lcdcfb, using the fbdev framework,
2. shmob_drm, using the DRM framework.
However, only the former driver can be used, as all platform support integrates the former. None of these drivers support DT-based systems.

This patch series is a first step to enable the SH-Mobile DRM driver for Renesas ARM-based SH-Mobile and R-Mobile SoCs. The next step planned is to add DT support.

Changes compared to v1:
- Add Reviewed-by,
- Drop dependency on ARM.

This has been tested on the R-Mobile A1-based Atmark Techno Armadillo-800-EVA development board, using a temporary platform-enablement patch[1].

Thanks for applying to drm-misc!

[1] https://lore.kernel.org/r/c03d4edbd650836bf6a96504df82338ec6d800ff.1680272980.git.geert+renesas@glider.be

Geert Uytterhoeven (5):
drm: shmobile: Use %p4cc to print fourcc codes
drm: shmobile: Add support for DRM_FORMAT_XRGB8888
drm: shmobile: Switch to drm_crtc_init_with_planes()
drm: shmobile: Add missing call to drm_fbdev_generic_setup()
drm: shmobile: Make DRM_SHMOBILE visible on Renesas SoC platforms

 drivers/gpu/drm/shmobile/Kconfig           |  4 +--
 drivers/gpu/drm/shmobile/shmob_drm_crtc.c  | 35 +++++++++++++++++++---
 drivers/gpu/drm/shmobile/shmob_drm_drv.c   |  3 ++
 drivers/gpu/drm/shmobile/shmob_drm_kms.c   |  9 ++++--
 drivers/gpu/drm/shmobile/shmob_drm_plane.c |  5 ++++
 5 files changed, 48 insertions(+), 8 deletions(-)
Signature · 12 lines
2.34.1

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds
#1 lore raw

PATCH v2 1/5 drm: shmobile: Use %p4cc to print fourcc codes

Replace the printing of hexadecimal fourcc format codes by pretty-printed format names, using the "%p4cc" format specifier.

---
v2:
- Add Reviewed-by.

---
 drivers/gpu/drm/shmobile/shmob_drm_crtc.c | 4 ++--
 drivers/gpu/drm/shmobile/shmob_drm_kms.c  | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/shmobile/shmob_drm_crtc.c +2 -2
index d354ab3077cecf94..713a7612244c647a 100644
@@ -355,8 +355,8 @@ static int shmob_drm_crtc_mode_set(struct drm_crtc *crtc,
 
 	format = shmob_drm_format_info(crtc->primary->fb->format->format);
 	if (format == NULL) {
-		dev_dbg(sdev->dev, "mode_set: unsupported format %08x\n",
-			crtc->primary->fb->format->format);
+		dev_dbg(sdev->dev, "mode_set: unsupported format %p4cc\n",
+			&crtc->primary->fb->format->format);
 		return -EINVAL;
 	}
 
drivers/gpu/drm/shmobile/shmob_drm_kms.c +2 -2
index 60a2c8d8a0d947d2..3c5fe3bc183c7c13 100644
@@ -96,8 +96,8 @@ shmob_drm_fb_create(struct drm_device *dev, struct drm_file *file_priv,
 
 	format = shmob_drm_format_info(mode_cmd->pixel_format);
 	if (format == NULL) {
-		dev_dbg(dev->dev, "unsupported pixel format %08x\n",
-			mode_cmd->pixel_format);
+		dev_dbg(dev->dev, "unsupported pixel format %p4cc\n",
+			&mode_cmd->pixel_format);
 		return ERR_PTR(-EINVAL);
 	}
 
Signature · 1 line
2.34.1
Reviewed-by on v2 1/5
#2 lore raw

Re: [PATCH v2 1/5] drm: shmobile: Use %p4cc to print fourcc codes

Hi Geert,

Thank you for the patch.

Quoted 5 lines · Geert Uytterhoeven

Replace the printing of hexadecimal fourcc format codes by pretty-printed format names, using the "%p4cc" format specifier.

Quoted 38 lines

---
v2:
- Add Reviewed-by.

---
 drivers/gpu/drm/shmobile/shmob_drm_crtc.c | 4 ++--
 drivers/gpu/drm/shmobile/shmob_drm_kms.c  | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/shmobile/shmob_drm_crtc.c +2 -2
index d354ab3077cecf94..713a7612244c647a 100644
@@ -355,8 +355,8 @@ static int shmob_drm_crtc_mode_set(struct drm_crtc *crtc,
 
 	format = shmob_drm_format_info(crtc->primary->fb->format->format);
 	if (format == NULL) {
-		dev_dbg(sdev->dev, "mode_set: unsupported format %08x\n",
-			crtc->primary->fb->format->format);
+		dev_dbg(sdev->dev, "mode_set: unsupported format %p4cc\n",
+			&crtc->primary->fb->format->format);
 		return -EINVAL;
 	}
 
drivers/gpu/drm/shmobile/shmob_drm_kms.c +2 -2
index 60a2c8d8a0d947d2..3c5fe3bc183c7c13 100644
@@ -96,8 +96,8 @@ shmob_drm_fb_create(struct drm_device *dev, struct drm_file *file_priv,
 
 	format = shmob_drm_format_info(mode_cmd->pixel_format);
 	if (format == NULL) {
-		dev_dbg(dev->dev, "unsupported pixel format %08x\n",
-			mode_cmd->pixel_format);
+		dev_dbg(dev->dev, "unsupported pixel format %p4cc\n",
+			&mode_cmd->pixel_format);
 		return ERR_PTR(-EINVAL);
 	}
 
Signature · 3 lines
Regards,

Laurent Pinchart
#3 lore raw

PATCH v2 2/5 drm: shmobile: Add support for DRM_FORMAT_XRGB8888

In reply to Geert Uytterhoeven

DRM_FORMAT_XRGB8888 aka XR24 is the modus francus of DRM, and should be supported by all drivers.

The handling for DRM_FORMAT_XRGB8888 is similar to DRM_FORMAT_ARGB8888, just ignore the alpha channel.

---
v2:
- Add Reviewed-by.

---
 drivers/gpu/drm/shmobile/shmob_drm_crtc.c  | 1 +
 drivers/gpu/drm/shmobile/shmob_drm_kms.c   | 5 +++++
 drivers/gpu/drm/shmobile/shmob_drm_plane.c | 5 +++++
 3 files changed, 11 insertions(+)
drivers/gpu/drm/shmobile/shmob_drm_crtc.c +1 -0
index 713a7612244c647a..08dc1428aa16caf0 100644
@@ -232,6 +232,7 @@ static void shmob_drm_crtc_start(struct shmob_drm_crtc *scrtc)
 		value = LDDDSR_LS | LDDDSR_WS | LDDDSR_BS;
 		break;
 	case DRM_FORMAT_ARGB8888:
+	case DRM_FORMAT_XRGB8888:
 	default:
 		value = LDDDSR_LS;
 		break;
drivers/gpu/drm/shmobile/shmob_drm_kms.c +5 -0
index 3c5fe3bc183c7c13..99381cc0abf3ae1f 100644
@@ -39,6 +39,11 @@ static const struct shmob_drm_format_info shmob_drm_format_infos[] = {
 		.bpp = 32,
 		.yuv = false,
 		.lddfr = LDDFR_PKF_ARGB32,
+	}, {
+		.fourcc = DRM_FORMAT_XRGB8888,
+		.bpp = 32,
+		.yuv = false,
+		.lddfr = LDDFR_PKF_ARGB32,
 	}, {
 		.fourcc = DRM_FORMAT_NV12,
 		.bpp = 12,
drivers/gpu/drm/shmobile/shmob_drm_plane.c +5 -0
index 604ae23825daaafd..850986cee848226a 100644
@@ -80,6 +80,7 @@ static void __shmob_drm_plane_setup(struct shmob_drm_plane *splane,
 		format |= LDBBSIFR_SWPL | LDBBSIFR_SWPW | LDBBSIFR_SWPB;
 		break;
 	case DRM_FORMAT_ARGB8888:
+	case DRM_FORMAT_XRGB8888:
 	default:
 		format |= LDBBSIFR_SWPL;
 		break;
@@ -95,6 +96,9 @@ static void __shmob_drm_plane_setup(struct shmob_drm_plane *splane,
 	case DRM_FORMAT_ARGB8888:
 		format |= LDBBSIFR_AL_PK | LDBBSIFR_RY | LDDFR_PKF_ARGB32;
 		break;
+	case DRM_FORMAT_XRGB8888:
+		format |= LDBBSIFR_AL_1 | LDBBSIFR_RY | LDDFR_PKF_ARGB32;
+		break;
 	case DRM_FORMAT_NV12:
 	case DRM_FORMAT_NV21:
 		format |= LDBBSIFR_AL_1 | LDBBSIFR_CHRR_420;
@@ -231,6 +235,7 @@ static const uint32_t formats[] = {
 	DRM_FORMAT_RGB565,
 	DRM_FORMAT_RGB888,
 	DRM_FORMAT_ARGB8888,
+	DRM_FORMAT_XRGB8888,
 	DRM_FORMAT_NV12,
 	DRM_FORMAT_NV21,
 	DRM_FORMAT_NV16,
Signature · 1 line
2.34.1
#4 lore raw

PATCH v2 3/5 drm: shmobile: Switch to drm_crtc_init_with_planes()

In reply to Geert Uytterhoeven

The SH-Mobile DRM driver uses the legacy drm_crtc_init(), which advertizes only the formats in safe_modeset_formats[] (XR24 and AR24) as being supported.

Switch to drm_crtc_init_with_planes(), and advertize all supported (A)RGB modes, so we can use RGB565 as the default mode for the console.

---
v2:
- Add Reviewed-by.

---
 drivers/gpu/drm/shmobile/shmob_drm_crtc.c | 30 +++++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)
drivers/gpu/drm/shmobile/shmob_drm_crtc.c +28 -2
index 08dc1428aa16caf0..11dd2bc803e7cb62 100644
@@ -18,6 +18,7 @@
 #include <drm/drm_gem_dma_helper.h>
 #include <drm/drm_modeset_helper.h>
 #include <drm/drm_modeset_helper_vtables.h>
+#include <drm/drm_plane_helper.h>
 #include <drm/drm_probe_helper.h>
 #include <drm/drm_simple_kms_helper.h>
 #include <drm/drm_vblank.h>
@@ -478,16 +479,41 @@ static const struct drm_crtc_funcs crtc_funcs = {
 	.disable_vblank = shmob_drm_disable_vblank,
 };
 
+static const uint32_t modeset_formats[] = {
+	DRM_FORMAT_RGB565,
+	DRM_FORMAT_RGB888,
+	DRM_FORMAT_ARGB8888,
+	DRM_FORMAT_XRGB8888,
+};
+
+static const struct drm_plane_funcs primary_plane_funcs = {
+	DRM_PLANE_NON_ATOMIC_FUNCS,
+};
+
 int shmob_drm_crtc_create(struct shmob_drm_device *sdev)
 {
 	struct drm_crtc *crtc = &sdev->crtc.crtc;
+	struct drm_plane *primary;
 	int ret;
 
 	sdev->crtc.dpms = DRM_MODE_DPMS_OFF;
 
-	ret = drm_crtc_init(sdev->ddev, crtc, &crtc_funcs);
-	if (ret < 0)
+	primary = __drm_universal_plane_alloc(sdev->ddev, sizeof(*primary), 0,
+					      0, &primary_plane_funcs,
+					      modeset_formats,
+					      ARRAY_SIZE(modeset_formats),
+					      NULL, DRM_PLANE_TYPE_PRIMARY,
+					      NULL);
+	if (IS_ERR(primary))
+		return PTR_ERR(primary);
+
+	ret = drm_crtc_init_with_planes(sdev->ddev, crtc, primary, NULL,
+					&crtc_funcs, NULL);
+	if (ret < 0) {
+		drm_plane_cleanup(primary);
+		kfree(primary);
 		return ret;
+	}
 
 	drm_crtc_helper_add(crtc, &crtc_helper_funcs);
 
Signature · 1 line
2.34.1
#5 lore raw

PATCH v2 4/5 drm: shmobile: Add missing call to drm_fbdev_generic_setup()

In reply to Geert Uytterhoeven

Set up generic fbdev emulation, to enable support for the Linux console.

Use 16 as the preferred depth, as that is a good compromise between colorfulness and resource utilization, and the default of the fbdev driver.

---
v2:
- Add Reviewed-by.

---
 drivers/gpu/drm/shmobile/shmob_drm_drv.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/shmobile/shmob_drm_drv.c +3 -0
index faacfee24763b1d4..30493ce874192e3e 100644
@@ -16,6 +16,7 @@
 #include <linux/slab.h>
 
 #include <drm/drm_drv.h>
+#include <drm/drm_fbdev_generic.h>
 #include <drm/drm_gem_dma_helper.h>
 #include <drm/drm_module.h>
 #include <drm/drm_probe_helper.h>
@@ -271,6 +272,8 @@ static int shmob_drm_probe(struct platform_device *pdev)
 	if (ret < 0)
 		goto err_irq_uninstall;
 
+	drm_fbdev_generic_setup(ddev, 16);
+
 	return 0;
 
 err_irq_uninstall:
Signature · 1 line
2.34.1
#6 lore raw

PATCH v2 5/5 drm: shmobile: Make DRM_SHMOBILE visible on Renesas SoC platforms

In reply to Geert Uytterhoeven

The LCD Controller supported by the drm-shmob driver is present on SuperH SH-Mobile SoCs, and on Renesas ARM SH/R-Mobile SoCs. Unfortunately its config option is not visible on either, so the user can never enable the support.

Fix this by dropping the dependency on ARM (for SuperH), and by widening the dependency range to ARCH_RENESAS (for ARM).

---
v2:
- Add Reviewed-by,
- Drop dependency on ARM, reword.

This driver was disabled on SuperH in commit c66de8cc2ea62941 ("drm/shmobile: Add run-time dependencies") in v3.16 because of build issues. I couldn't find further details, but currently it builds fine on (at least) arm, arm64, sh, riscv, and m68k.

---
 drivers/gpu/drm/shmobile/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/shmobile/Kconfig +2 -2
index 4ec5dc74a6b0b880..ad14112999ad8aba 100644
@@ -1,8 +1,8 @@
 # SPDX-License-Identifier: GPL-2.0
 config DRM_SHMOBILE
 	tristate "DRM Support for SH Mobile"
-	depends on DRM && ARM
-	depends on ARCH_SHMOBILE || COMPILE_TEST
+	depends on DRM
+	depends on ARCH_RENESAS || ARCH_SHMOBILE || COMPILE_TEST
 	select BACKLIGHT_CLASS_DEVICE
 	select DRM_KMS_HELPER
 	select DRM_GEM_DMA_HELPER
Signature · 1 line
2.34.1
#7 lore raw
In reply to Geert Uytterhoeven

Hi Geert,

Quoted 17 lines · Geert Uytterhoeven

Hi all,

Currently, there are two drivers for the LCD controller on Renesas SuperH-based and ARM-based SH-Mobile and R-Mobile SoCs:
1. sh_mobile_lcdcfb, using the fbdev framework,
2. shmob_drm, using the DRM framework.
However, only the former driver can be used, as all platform support integrates the former. None of these drivers support DT-based systems.

This patch series is a first step to enable the SH-Mobile DRM driver for Renesas ARM-based SH-Mobile and R-Mobile SoCs. The next step planned is to add DT support.

Changes compared to v1:
- Add Reviewed-by,
- Drop dependency on ARM.

Quoted 5 lines

This has been tested on the R-Mobile A1-based Atmark Techno Armadillo-800-EVA development board, using a temporary platform-enablement patch[1].

Thanks for applying to drm-misc!

Would you like to request drm-misc committer rights ? :-)

Quoted 16 lines

[1] https://lore.kernel.org/r/c03d4edbd650836bf6a96504df82338ec6d800ff.1680272980.git.geert+renesas@glider.be

Geert Uytterhoeven (5):
drm: shmobile: Use %p4cc to print fourcc codes
drm: shmobile: Add support for DRM_FORMAT_XRGB8888
drm: shmobile: Switch to drm_crtc_init_with_planes()
drm: shmobile: Add missing call to drm_fbdev_generic_setup()
drm: shmobile: Make DRM_SHMOBILE visible on Renesas SoC platforms

 drivers/gpu/drm/shmobile/Kconfig           |  4 +--
 drivers/gpu/drm/shmobile/shmob_drm_crtc.c  | 35 +++++++++++++++++++---
 drivers/gpu/drm/shmobile/shmob_drm_drv.c   |  3 ++
 drivers/gpu/drm/shmobile/shmob_drm_kms.c   |  9 ++++--
 drivers/gpu/drm/shmobile/shmob_drm_plane.c |  5 ++++
 5 files changed, 48 insertions(+), 8 deletions(-)
Signature · 3 lines
Regards,

Laurent Pinchart
#8 lore raw

Hi Laurent,

Quoted 16 lines · Laurent Pinchart
Quoted 15 lines · Geert Uytterhoeven

Currently, there are two drivers for the LCD controller on Renesas SuperH-based and ARM-based SH-Mobile and R-Mobile SoCs:
1. sh_mobile_lcdcfb, using the fbdev framework,
2. shmob_drm, using the DRM framework.
However, only the former driver can be used, as all platform support integrates the former. None of these drivers support DT-based systems.

This patch series is a first step to enable the SH-Mobile DRM driver for Renesas ARM-based SH-Mobile and R-Mobile SoCs. The next step planned is to add DT support.

Changes compared to v1:
- Add Reviewed-by,
- Drop dependency on ARM.

Quoted 7 lines
Quoted 5 lines

This has been tested on the R-Mobile A1-based Atmark Techno Armadillo-800-EVA development board, using a temporary platform-enablement patch[1].

Thanks for applying to drm-misc!

Would you like to request drm-misc committer rights ? :-)

Don't the listed maintainers for drivers/gpu/drm/shmobile/ don't have such access already?

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#9 lore raw

Hi Geert,

Quoted 21 lines · Geert Uytterhoeven
Quoted 20 lines · Laurent Pinchart
Quoted 19 lines · Geert Uytterhoeven

Currently, there are two drivers for the LCD controller on Renesas SuperH-based and ARM-based SH-Mobile and R-Mobile SoCs:
1. sh_mobile_lcdcfb, using the fbdev framework,
2. shmob_drm, using the DRM framework.
However, only the former driver can be used, as all platform support integrates the former. None of these drivers support DT-based systems.

This patch series is a first step to enable the SH-Mobile DRM driver for Renesas ARM-based SH-Mobile and R-Mobile SoCs. The next step planned is to add DT support.

Changes compared to v1:
- Add Reviewed-by,
- Drop dependency on ARM.

This has been tested on the R-Mobile A1-based Atmark Techno Armadillo-800-EVA development board, using a temporary platform-enablement patch[1].

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Thanks for applying to drm-misc!

Would you like to request drm-misc committer rights ? :-)

Don't the listed maintainers for drivers/gpu/drm/shmobile/ don't have such access already?

Actually, as you're taking over maintenance for this driver, would you send a patch to update MAINTAINERS ?

Signature · 3 lines
Regards,

Laurent Pinchart