2023-07-18 17:40:07

by Geert Uytterhoeven

[permalink] [raw]
Subject: [PATCH v2 00/41] drm: renesas: shmobile: Atomic conversion + DT support

Hi all,

It has been 3 years since the last conversion of a DRM driver to atomic
modesetting, so I guess it's time for another one? ;-)

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 is used, as all platform support
integrates the former. None of these drivers support DT-based systems.

This patch series converts the SH-Mobile DRM driver to atomic
modesetting, and adds DT support, complemented by the customary set of
fixes and improvements.

Overview:
- Patch 1 adds a separate maintainer entry.
- Patch 2 adds DT bindings for the SH-Mobile LCD controller,
- Patch 3 adds definitions for RGB666 9:9 media bus formats,
- Patches 4-35 contains miscellaneous fixes, improvements, and
cleanups for the SH-Mobile DRM driver,
- Patches 36-40 convert the SH-Mobile DRM driver to atomic
modesetting,
- Patch 41 adds DT support to the SH-Mobile DRM driver.

To reduce strain on the audience, I have CCed the DT and media people
only on the cover letter and the DT resp. media patches. If interested,
the full series should be available through lore.kernel.org.

Some comments and questions can be found in the individual patches.

Changes compared to v1[1]:
- New patches
- "[PATCH v2 01/41] MAINTAINER: Create entry for Renesas SH-Mobile
DRM drivers",
- "[PATCH v2 18/41] drm: renesas: shmobile: Remove custom plane
destroy callback",
- Add myself as co-maintainer,
- Make fck clock required,
- Drop ports description referring to obsolete graph.txt,
- Condition ports to compatible strings,
- Drop label and status from example,
- Add Reviewed-by,
- Drop unused MEDIA_BUS_FMT_RGB666_2X9_LE, as requested by Laurent,
- Move explicit clock handling to Runtime PM callbacks,
- Move devm_pm_runtime_enable() after shmob_drm_setup_clocks(),
- Depend on PM,
- Split off removal of call to drm_plane_force_disable(),
- Select VIDEOMODE_HELPERS,
- Keep table instead of replacing it by a switch() statement,
- Fix shmob_drm_interface_data.bus_fmt comment,
- Drop superfluous blank lines,
- Keep initialization of info fields together,
- Use shmob_drm_bus_fmts[],
- Keep bus format validation at probe time,
- Pass plane type to shmob_drm_plane_create() to avoid having to shift
all overlay plane indices by one,
- Rename primary_plane_funcs to shmob_drm_primary_plane_funcs,
- Rename shmob_drm_plane_funcs to shmob_drm_overlay_plane_funcs,
- Move shmob_drm_crtc_finish_page_flip() further up,
- Inline shmob_drm_crtc_st{art,op}(),
- Use devm_drm_of_get_bridge(),
- Don't print bridge->of_node on failure, as this field depends on
CONFIG_OF.

This has been tested on the R-Mobile A1-based Atmark Techno
Armadillo-800-EVA development board, using both legacy[2] and
DT-based[3] instantiation, with the fbdev-emulated text console and
modetest, a.o.

modetest -M shmob-drm -s 43:800x480@RG16 -P 33@41:640x320+80+80@RG16
modetest -M shmob-drm -s 43:800x480@RG16

The output of "modetest -M shmob-drm" can be found below[4].

Thanks for your comments!

[1] "[PATCH 00/39] drm: renesas: shmobile: Atomic conversion + DT
support"
https://lore.kernel.org/r/[email protected]/

[2] "[PATCH/RFC] staging: board: armadillo800eva: Add DRM support"
https://lore.kernel.org/r/f7874a9da4bcb20fbc9cd133147b67862ebcf0b9.1687418281.git.geert+renesas@glider.be

[3] "[PATCH 0/2] ARM: dts: r8a7740/armadillo800eva: Add LCD support"
https://lore.kernel.org/r/[email protected]

[4] Encoders:
id crtc type possible crtcs possible clones
42 41 DPI 0x00000001 0x00000001

Connectors:
id encoder status name size (mm) modes encoders
43 42 connected DPI-1 111x67 1 42
modes:
index name refresh (Hz) hdisp hss hse htot vdisp vss vse vtot
#0 800x480 59.99 800 840 968 1056 480 515 517 525 33260 flags: nhsync, nvsync; type: preferred, driver
props:
1 EDID:
flags: immutable blob
blobs:

value:
2 DPMS:
flags: enum
enums: On=0 Standby=1 Suspend=2 Off=3
value: 0
5 link-status:
flags: enum
enums: Good=0 Bad=1
value: 0
6 non-desktop:
flags: immutable range
values: 0 1
value: 0
4 TILE:
flags: immutable blob
blobs:

value:

CRTCs:
id fb pos size
41 44 (0,0) (800x480)
#0 800x480 59.99 800 840 968 1056 480 515 517 525 33260 flags: nhsync, nvsync; type: preferred, driver
props:
24 VRR_ENABLED:
flags: range
values: 0 1
value: 0

Planes:
id crtc fb CRTC x,y x,y gamma size possible crtcs
31 41 44 0,0 0,0 0 0x00000001
formats: RG16 RG24 AR24 XR24 NV12 NV21 NV16 NV61 NV24 NV42
props:
8 type:
flags: immutable enum
enums: Overlay=0 Primary=1 Cursor=2
value: 1
30 IN_FORMATS:
flags: immutable blob
blobs:

value:
01000000000000000a00000018000000
01000000400000005247313652473234
41523234585232344e5631324e563231
4e5631364e5636314e5632344e563432
ff030000000000000000000000000000
0000000000000000
in_formats blob decoded:
RG16: LINEAR
RG24: LINEAR
AR24: LINEAR
XR24: LINEAR
NV12: LINEAR
NV21: LINEAR
NV16: LINEAR
NV61: LINEAR
NV24: LINEAR
NV42: LINEAR
33 0 0 0,0 0,0 0 0x00000001
formats: RG16 RG24 AR24 XR24 NV12 NV21 NV16 NV61 NV24 NV42
props:
8 type:
flags: immutable enum
enums: Overlay=0 Primary=1 Cursor=2
value: 0
30 IN_FORMATS:
flags: immutable blob
blobs:

value:
01000000000000000a00000018000000
01000000400000005247313652473234
41523234585232344e5631324e563231
4e5631364e5636314e5632344e563432
ff030000000000000000000000000000
0000000000000000
in_formats blob decoded:
RG16: LINEAR
RG24: LINEAR
AR24: LINEAR
XR24: LINEAR
NV12: LINEAR
NV21: LINEAR
NV16: LINEAR
NV61: LINEAR
NV24: LINEAR
NV42: LINEAR
35 0 0 0,0 0,0 0 0x00000001
formats: RG16 RG24 AR24 XR24 NV12 NV21 NV16 NV61 NV24 NV42
props:
8 type:
flags: immutable enum
enums: Overlay=0 Primary=1 Cursor=2
value: 0
30 IN_FORMATS:
flags: immutable blob
blobs:

value:
01000000000000000a00000018000000
01000000400000005247313652473234
41523234585232344e5631324e563231
4e5631364e5636314e5632344e563432
ff030000000000000000000000000000
0000000000000000
in_formats blob decoded:
RG16: LINEAR
RG24: LINEAR
AR24: LINEAR
XR24: LINEAR
NV12: LINEAR
NV21: LINEAR
NV16: LINEAR
NV61: LINEAR
NV24: LINEAR
NV42: LINEAR
37 0 0 0,0 0,0 0 0x00000001
formats: RG16 RG24 AR24 XR24 NV12 NV21 NV16 NV61 NV24 NV42
props:
8 type:
flags: immutable enum
enums: Overlay=0 Primary=1 Cursor=2
value: 0
30 IN_FORMATS:
flags: immutable blob
blobs:

value:
01000000000000000a00000018000000
01000000400000005247313652473234
41523234585232344e5631324e563231
4e5631364e5636314e5632344e563432
ff030000000000000000000000000000
0000000000000000
in_formats blob decoded:
RG16: LINEAR
RG24: LINEAR
AR24: LINEAR
XR24: LINEAR
NV12: LINEAR
NV21: LINEAR
NV16: LINEAR
NV61: LINEAR
NV24: LINEAR
NV42: LINEAR
39 0 0 0,0 0,0 0 0x00000001
formats: RG16 RG24 AR24 XR24 NV12 NV21 NV16 NV61 NV24 NV42
props:
8 type:
flags: immutable enum
enums: Overlay=0 Primary=1 Cursor=2
value: 0
30 IN_FORMATS:
flags: immutable blob
blobs:

value:
01000000000000000a00000018000000
01000000400000005247313652473234
41523234585232344e5631324e563231
4e5631364e5636314e5632344e563432
ff030000000000000000000000000000
0000000000000000
in_formats blob decoded:
RG16: LINEAR
RG24: LINEAR
AR24: LINEAR
XR24: LINEAR
NV12: LINEAR
NV21: LINEAR
NV16: LINEAR
NV61: LINEAR
NV24: LINEAR
NV42: LINEAR

Frame buffers:
id size pitch

Geert Uytterhoeven (36):
MAINTAINER: Create entry for Renesas SH-Mobile DRM drivers
dt-bindings: display: Add Renesas SH-Mobile LCDC bindings
media: uapi: Add MEDIA_BUS_FMT_RGB666_2X9_BE format
drm: renesas: shmobile: Fix overlay plane disable
drm: renesas: shmobile: Fix ARGB32 overlay format typo
drm: renesas: shmobile: Correct encoder/connector types
drm: renesas: shmobile: Add support for Runtime PM
drm: renesas: shmobile: Restore indentation of shmob_drm_setup_clocks()
drm: renesas: shmobile: Use %p4cc to print fourcc code
drm: renesas: shmobile: Add missing YCbCr formats
drm: renesas: shmobile: Improve shmob_drm_format_info table
drm: renesas: shmobile: Improve error handling
drm: renesas: shmobile: Convert to use devm_request_irq()
drm: renesas: shmobile: Remove custom plane destroy callback
drm: renesas: shmobile: Use drmm_universal_plane_alloc()
drm: renesas: shmobile: Embed drm_device in shmob_drm_device
drm: renesas: shmobile: Convert container helpers to static inline functions
drm: renesas: shmobile: Replace .dev_private with container_of()
drm: renesas: shmobile: Use media bus formats in platform data
drm: renesas: shmobile: Move interface handling to connector setup
drm: renesas: shmobile: Unify plane allocation
drm: renesas: shmobile: Rename shmob_drm_crtc.crtc
drm: renesas: shmobile: Rename shmob_drm_connector.connector
drm: renesas: shmobile: Rename shmob_drm_plane.plane
drm: renesas: shmobile: Use drm_crtc_handle_vblank()
drm: renesas: shmobile: Move shmob_drm_crtc_finish_page_flip()
drm: renesas: shmobile: Wait for page flip when turning CRTC off
drm: renesas: shmobile: Turn vblank on/off when enabling/disabling CRTC
drm: renesas: shmobile: Shutdown the display on remove
drm: renesas: shmobile: Cleanup encoder
drm: renesas: shmobile: Atomic conversion part 1
drm: renesas: shmobile: Atomic conversion part 2
drm: renesas: shmobile: Use suspend/resume helpers
drm: renesas: shmobile: Remove internal CRTC state tracking
drm: renesas: shmobile: Atomic conversion part 3
drm: renesas: shmobile: Add DT support

Laurent Pinchart (5):
drm: renesas: shmobile: Remove backlight support
drm: renesas: shmobile: Don't set display info width and height twice
drm: renesas: shmobile: Rename input clocks
drm: renesas: shmobile: Remove support for SYS panels
drm: renesas: shmobile: Use struct videomode in platform data

.../display/renesas,shmobile-lcdc.yaml | 130 ++++
.../media/v4l/subdev-formats.rst | 72 ++
MAINTAINERS | 13 +-
drivers/gpu/drm/renesas/shmobile/Kconfig | 3 +-
drivers/gpu/drm/renesas/shmobile/Makefile | 3 +-
.../renesas/shmobile/shmob_drm_backlight.c | 82 ---
.../renesas/shmobile/shmob_drm_backlight.h | 19 -
.../gpu/drm/renesas/shmobile/shmob_drm_crtc.c | 650 ++++++++----------
.../gpu/drm/renesas/shmobile/shmob_drm_crtc.h | 27 +-
.../gpu/drm/renesas/shmobile/shmob_drm_drv.c | 180 +++--
.../gpu/drm/renesas/shmobile/shmob_drm_drv.h | 18 +-
.../gpu/drm/renesas/shmobile/shmob_drm_kms.c | 77 ++-
.../gpu/drm/renesas/shmobile/shmob_drm_kms.h | 9 +-
.../drm/renesas/shmobile/shmob_drm_plane.c | 326 +++++----
.../drm/renesas/shmobile/shmob_drm_plane.h | 5 +-
include/linux/platform_data/shmob_drm.h | 57 +-
include/uapi/linux/media-bus-format.h | 3 +-
17 files changed, 860 insertions(+), 814 deletions(-)
create mode 100644 Documentation/devicetree/bindings/display/renesas,shmobile-lcdc.yaml
delete mode 100644 drivers/gpu/drm/renesas/shmobile/shmob_drm_backlight.c
delete mode 100644 drivers/gpu/drm/renesas/shmobile/shmob_drm_backlight.h

Cc: Rob Herring <[email protected]>
Cc: Krzysztof Kozlowski <[email protected]>
Cc: Conor Dooley <[email protected]>
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: Hans Verkuil <[email protected]>
Cc: [email protected]
Cc: [email protected]
--
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


2023-07-18 17:41:46

by Geert Uytterhoeven

[permalink] [raw]
Subject: [PATCH v2 26/41] drm: renesas: shmobile: Unify plane allocation

Unify primary and overlay plane allocation:
- Enhance shmob_drm_plane_create() so it can be used to create the
primary plane, too,
- Move overlay plane creation next to primary plane creation.

Signed-off-by: Geert Uytterhoeven <[email protected]>
---
v2:
- Pass plane type to shmob_drm_plane_create() to avoid having to shift
all overlay plane indices by one,
- Rename primary_plane_funcs to shmob_drm_primary_plane_funcs,
- Rename shmob_drm_plane_funcs to shmob_drm_overlay_plane_funcs.
---
.../gpu/drm/renesas/shmobile/shmob_drm_crtc.c | 39 +++++--------------
.../gpu/drm/renesas/shmobile/shmob_drm_drv.c | 9 -----
.../drm/renesas/shmobile/shmob_drm_plane.c | 31 +++++++++++----
.../drm/renesas/shmobile/shmob_drm_plane.h | 4 +-
4 files changed, 36 insertions(+), 47 deletions(-)

diff --git a/drivers/gpu/drm/renesas/shmobile/shmob_drm_crtc.c b/drivers/gpu/drm/renesas/shmobile/shmob_drm_crtc.c
index caafd04acd3d46d0..564051b505ed4ac5 100644
--- a/drivers/gpu/drm/renesas/shmobile/shmob_drm_crtc.c
+++ b/drivers/gpu/drm/renesas/shmobile/shmob_drm_crtc.c
@@ -19,7 +19,6 @@
#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>
@@ -453,47 +452,29 @@ 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,
- DRM_FORMAT_NV12,
- DRM_FORMAT_NV21,
- DRM_FORMAT_NV16,
- DRM_FORMAT_NV61,
- DRM_FORMAT_NV24,
- DRM_FORMAT_NV42,
-};
-
-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;
+ struct drm_plane *primary, *plane;
+ unsigned int i;
int ret;

sdev->crtc.dpms = DRM_MODE_DPMS_OFF;

- 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);
+ primary = shmob_drm_plane_create(sdev, DRM_PLANE_TYPE_PRIMARY, 0);
if (IS_ERR(primary))
return PTR_ERR(primary);

+ for (i = 1; i < 5; ++i) {
+ plane = shmob_drm_plane_create(sdev, DRM_PLANE_TYPE_OVERLAY, i);
+ if (IS_ERR(plane))
+ return PTR_ERR(plane);
+ }
+
ret = drm_crtc_init_with_planes(&sdev->ddev, crtc, primary, NULL,
&crtc_funcs, NULL);
- if (ret < 0) {
- drm_plane_cleanup(primary);
- kfree(primary);
+ if (ret < 0)
return ret;
- }

drm_crtc_helper_add(crtc, &crtc_helper_funcs);

diff --git a/drivers/gpu/drm/renesas/shmobile/shmob_drm_drv.c b/drivers/gpu/drm/renesas/shmobile/shmob_drm_drv.c
index 8da3054f26b2d235..6bc05a9e9661915e 100644
--- a/drivers/gpu/drm/renesas/shmobile/shmob_drm_drv.c
+++ b/drivers/gpu/drm/renesas/shmobile/shmob_drm_drv.c
@@ -181,7 +181,6 @@ static int shmob_drm_probe(struct platform_device *pdev)
struct shmob_drm_platform_data *pdata = pdev->dev.platform_data;
struct shmob_drm_device *sdev;
struct drm_device *ddev;
- unsigned int i;
int ret;

if (pdata == NULL) {
@@ -222,14 +221,6 @@ static int shmob_drm_probe(struct platform_device *pdev)
return dev_err_probe(&pdev->dev, ret,
"failed to initialize mode setting\n");

- for (i = 0; i < 4; ++i) {
- ret = shmob_drm_plane_create(sdev, i);
- if (ret < 0) {
- dev_err(&pdev->dev, "failed to create plane %u\n", i);
- goto err_modeset_cleanup;
- }
- }
-
ret = drm_vblank_init(ddev, 1);
if (ret < 0) {
dev_err(&pdev->dev, "failed to initialize vblank\n");
diff --git a/drivers/gpu/drm/renesas/shmobile/shmob_drm_plane.c b/drivers/gpu/drm/renesas/shmobile/shmob_drm_plane.c
index c58b9dca34736342..3518f8900c0d1f9e 100644
--- a/drivers/gpu/drm/renesas/shmobile/shmob_drm_plane.c
+++ b/drivers/gpu/drm/renesas/shmobile/shmob_drm_plane.c
@@ -12,6 +12,7 @@
#include <drm/drm_fourcc.h>
#include <drm/drm_framebuffer.h>
#include <drm/drm_gem_dma_helper.h>
+#include <drm/drm_plane_helper.h>

#include "shmob_drm_drv.h"
#include "shmob_drm_kms.h"
@@ -179,7 +180,12 @@ static int shmob_drm_plane_disable(struct drm_plane *plane,
return 0;
}

-static const struct drm_plane_funcs shmob_drm_plane_funcs = {
+static const struct drm_plane_funcs shmob_drm_primary_plane_funcs = {
+ .update_plane = drm_plane_helper_update_primary,
+ .disable_plane = drm_plane_helper_disable_primary,
+};
+
+static const struct drm_plane_funcs shmob_drm_overlay_plane_funcs = {
.update_plane = shmob_drm_plane_update,
.disable_plane = shmob_drm_plane_disable,
};
@@ -197,19 +203,28 @@ static const uint32_t formats[] = {
DRM_FORMAT_NV42,
};

-int shmob_drm_plane_create(struct shmob_drm_device *sdev, unsigned int index)
+struct drm_plane *shmob_drm_plane_create(struct shmob_drm_device *sdev,
+ enum drm_plane_type type,
+ unsigned int index)
{
+ const struct drm_plane_funcs *funcs;
struct shmob_drm_plane *splane;

- splane = drmm_universal_plane_alloc(&sdev->ddev, struct shmob_drm_plane,
- plane, 1, &shmob_drm_plane_funcs,
- formats, ARRAY_SIZE(formats), NULL,
- DRM_PLANE_TYPE_OVERLAY, NULL);
+ if (type == DRM_PLANE_TYPE_PRIMARY)
+ funcs = &shmob_drm_primary_plane_funcs;
+ else
+ funcs = &shmob_drm_overlay_plane_funcs;
+
+ splane = drmm_universal_plane_alloc(&sdev->ddev,
+ struct shmob_drm_plane, plane, 1,
+ funcs, formats,
+ ARRAY_SIZE(formats), NULL, type,
+ NULL);
if (IS_ERR(splane))
- return PTR_ERR(splane);
+ return ERR_CAST(splane);

splane->index = index;
splane->alpha = 255;

- return 0;
+ return &splane->plane;
}
diff --git a/drivers/gpu/drm/renesas/shmobile/shmob_drm_plane.h b/drivers/gpu/drm/renesas/shmobile/shmob_drm_plane.h
index e72b21a4288fc23f..8ad12129014016fa 100644
--- a/drivers/gpu/drm/renesas/shmobile/shmob_drm_plane.h
+++ b/drivers/gpu/drm/renesas/shmobile/shmob_drm_plane.h
@@ -13,7 +13,9 @@
struct drm_plane;
struct shmob_drm_device;

-int shmob_drm_plane_create(struct shmob_drm_device *sdev, unsigned int index);
+struct drm_plane *shmob_drm_plane_create(struct shmob_drm_device *sdev,
+ enum drm_plane_type type,
+ unsigned int index);
void shmob_drm_plane_setup(struct drm_plane *plane);

#endif /* __SHMOB_DRM_PLANE_H__ */
--
2.34.1


2023-07-18 17:43:06

by Geert Uytterhoeven

[permalink] [raw]
Subject: [PATCH v2 04/41] drm: renesas: shmobile: Fix overlay plane disable

Merely writing zero to the CHn Source Image Format Register is not
sufficient to disable a plane, as the programmed register value is not
propagated immediately to the current side. This can be seen when using
the -P option of modetest: the extra plane is displayed correctly, but
does not disappear after exit.

Fix this by doing the full update dance using the Blend Control
Register, like is done when enabling the plane.

Signed-off-by: Geert Uytterhoeven <[email protected]>
Reviewed-by: Laurent Pinchart <[email protected]>
---
v2:
- Add Reviewed-by.
---
drivers/gpu/drm/renesas/shmobile/shmob_drm_plane.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/renesas/shmobile/shmob_drm_plane.c b/drivers/gpu/drm/renesas/shmobile/shmob_drm_plane.c
index 850986cee848226a..0e34573c3cb3d032 100644
--- a/drivers/gpu/drm/renesas/shmobile/shmob_drm_plane.c
+++ b/drivers/gpu/drm/renesas/shmobile/shmob_drm_plane.c
@@ -215,7 +215,10 @@ static int shmob_drm_plane_disable(struct drm_plane *plane,

splane->format = NULL;

+ lcdc_write(sdev, LDBCR, LDBCR_UPC(splane->index));
lcdc_write(sdev, LDBnBSIFR(splane->index), 0);
+ lcdc_write(sdev, LDBCR,
+ LDBCR_UPF(splane->index) | LDBCR_UPD(splane->index));
return 0;
}

--
2.34.1


2023-07-18 17:43:44

by Geert Uytterhoeven

[permalink] [raw]
Subject: [PATCH v2 40/41] drm: renesas: shmobile: Atomic conversion part 3

Complete the conversion to atomic mode setting by converting the
connector, and setting the DRIVER_ATOMIC flag.

Signed-off-by: Geert Uytterhoeven <[email protected]>
Reviewed-by: Laurent Pinchart <[email protected]>
---
v2:
- Add Reviewed-by.
---
drivers/gpu/drm/renesas/shmobile/shmob_drm_crtc.c | 5 +----
drivers/gpu/drm/renesas/shmobile/shmob_drm_drv.c | 2 +-
2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/renesas/shmobile/shmob_drm_crtc.c b/drivers/gpu/drm/renesas/shmobile/shmob_drm_crtc.c
index e4d176b1f47654a8..729028a15efae00c 100644
--- a/drivers/gpu/drm/renesas/shmobile/shmob_drm_crtc.c
+++ b/drivers/gpu/drm/renesas/shmobile/shmob_drm_crtc.c
@@ -501,7 +501,6 @@ static void shmob_drm_connector_destroy(struct drm_connector *connector)
}

static const struct drm_connector_funcs connector_funcs = {
- .dpms = drm_helper_connector_dpms,
.reset = drm_atomic_helper_connector_reset,
.fill_modes = drm_helper_probe_single_connector_modes,
.destroy = shmob_drm_connector_destroy,
@@ -581,9 +580,7 @@ int shmob_drm_connector_create(struct shmob_drm_device *sdev,
if (ret < 0)
goto error;

- drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF);
- drm_object_property_set_value(&connector->base,
- sdev->ddev.mode_config.dpms_property, DRM_MODE_DPMS_OFF);
+ connector->dpms = DRM_MODE_DPMS_OFF;

sdev->connector = connector;

diff --git a/drivers/gpu/drm/renesas/shmobile/shmob_drm_drv.c b/drivers/gpu/drm/renesas/shmobile/shmob_drm_drv.c
index b7643884b49f0bc8..58a16efde4e3cb4f 100644
--- a/drivers/gpu/drm/renesas/shmobile/shmob_drm_drv.c
+++ b/drivers/gpu/drm/renesas/shmobile/shmob_drm_drv.c
@@ -98,7 +98,7 @@ static irqreturn_t shmob_drm_irq(int irq, void *arg)
DEFINE_DRM_GEM_DMA_FOPS(shmob_drm_fops);

static const struct drm_driver shmob_drm_driver = {
- .driver_features = DRIVER_GEM | DRIVER_MODESET,
+ .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC,
DRM_GEM_DMA_DRIVER_OPS,
.fops = &shmob_drm_fops,
.name = "shmob-drm",
--
2.34.1


2023-07-18 17:44:06

by Geert Uytterhoeven

[permalink] [raw]
Subject: [PATCH v2 21/41] drm: renesas: shmobile: Convert container helpers to static inline functions

Replace to conversion helper macros using container_of() by static
inline functions, to improve type-safety.

Signed-off-by: Geert Uytterhoeven <[email protected]>
Reviewed-by: Laurent Pinchart <[email protected]>
---
v2:
- Add Reviewed-by.
---
drivers/gpu/drm/renesas/shmobile/shmob_drm_crtc.c | 11 ++++++++---
drivers/gpu/drm/renesas/shmobile/shmob_drm_plane.c | 5 ++++-
2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/renesas/shmobile/shmob_drm_crtc.c b/drivers/gpu/drm/renesas/shmobile/shmob_drm_crtc.c
index 9c66e00ed70ea582..207fa98fe76d6f88 100644
--- a/drivers/gpu/drm/renesas/shmobile/shmob_drm_crtc.c
+++ b/drivers/gpu/drm/renesas/shmobile/shmob_drm_crtc.c
@@ -258,7 +258,10 @@ static void shmob_drm_crtc_update_base(struct shmob_drm_crtc *scrtc)
lcdc_write(sdev, LDRCNTR, lcdc_read(sdev, LDRCNTR) ^ LDRCNTR_MRS);
}

-#define to_shmob_crtc(c) container_of(c, struct shmob_drm_crtc, crtc)
+static inline struct shmob_drm_crtc *to_shmob_crtc(struct drm_crtc *crtc)
+{
+ return container_of(crtc, struct shmob_drm_crtc, crtc);
+}

static void shmob_drm_crtc_dpms(struct drm_crtc *crtc, int mode)
{
@@ -538,8 +541,10 @@ int shmob_drm_encoder_create(struct shmob_drm_device *sdev)
* Connector
*/

-#define to_shmob_connector(c) \
- container_of(c, struct shmob_drm_connector, connector)
+static inline struct shmob_drm_connector *to_shmob_connector(struct drm_connector *connector)
+{
+ return container_of(connector, struct shmob_drm_connector, connector);
+}

static int shmob_drm_connector_get_modes(struct drm_connector *connector)
{
diff --git a/drivers/gpu/drm/renesas/shmobile/shmob_drm_plane.c b/drivers/gpu/drm/renesas/shmobile/shmob_drm_plane.c
index 17e66a018689f648..258288c80756bf16 100644
--- a/drivers/gpu/drm/renesas/shmobile/shmob_drm_plane.c
+++ b/drivers/gpu/drm/renesas/shmobile/shmob_drm_plane.c
@@ -34,7 +34,10 @@ struct shmob_drm_plane {
unsigned int crtc_h;
};

-#define to_shmob_plane(p) container_of(p, struct shmob_drm_plane, plane)
+static inline struct shmob_drm_plane *to_shmob_plane(struct drm_plane *plane)
+{
+ return container_of(plane, struct shmob_drm_plane, plane);
+}

static void shmob_drm_plane_compute_base(struct shmob_drm_plane *splane,
struct drm_framebuffer *fb,
--
2.34.1


2023-07-18 17:46:51

by Geert Uytterhoeven

[permalink] [raw]
Subject: [PATCH v2 22/41] drm: renesas: shmobile: Replace .dev_private with container_of()

Now that drm_device is embedded in shmob_drm_device, we can use
a container_of()-based helper to get the shmob_drm_device pointer from
the drm_device, instead of using the deprecated drm_device.dev_private
field.

While at it, restore reverse Xmas tree ordering of local variable
declarations.

Signed-off-by: Geert Uytterhoeven <[email protected]>
Reviewed-by: Laurent Pinchart <[email protected]>
Reviewed-by: Sui Jingfeng <[email protected]>
---
v2:
- Add Reviewed-by.
---
.../gpu/drm/renesas/shmobile/shmob_drm_crtc.c | 20 +++++++++----------
.../gpu/drm/renesas/shmobile/shmob_drm_drv.c | 4 +---
.../gpu/drm/renesas/shmobile/shmob_drm_drv.h | 5 +++++
.../drm/renesas/shmobile/shmob_drm_plane.c | 6 +++---
4 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/renesas/shmobile/shmob_drm_crtc.c b/drivers/gpu/drm/renesas/shmobile/shmob_drm_crtc.c
index 207fa98fe76d6f88..f62ae047a48f615b 100644
--- a/drivers/gpu/drm/renesas/shmobile/shmob_drm_crtc.c
+++ b/drivers/gpu/drm/renesas/shmobile/shmob_drm_crtc.c
@@ -40,7 +40,7 @@
static void shmob_drm_crtc_setup_geometry(struct shmob_drm_crtc *scrtc)
{
struct drm_crtc *crtc = &scrtc->crtc;
- struct shmob_drm_device *sdev = crtc->dev->dev_private;
+ struct shmob_drm_device *sdev = to_shmob_device(crtc->dev);
const struct shmob_drm_interface_data *idata = &sdev->pdata->iface;
const struct drm_display_mode *mode = &crtc->mode;
u32 value;
@@ -79,7 +79,7 @@ static void shmob_drm_crtc_setup_geometry(struct shmob_drm_crtc *scrtc)

static void shmob_drm_crtc_start_stop(struct shmob_drm_crtc *scrtc, bool start)
{
- struct shmob_drm_device *sdev = scrtc->crtc.dev->dev_private;
+ struct shmob_drm_device *sdev = to_shmob_device(scrtc->crtc.dev);
u32 value;

value = lcdc_read(sdev, LDCNT2R);
@@ -113,7 +113,7 @@ static void shmob_drm_crtc_start_stop(struct shmob_drm_crtc *scrtc, bool start)
static void shmob_drm_crtc_start(struct shmob_drm_crtc *scrtc)
{
struct drm_crtc *crtc = &scrtc->crtc;
- struct shmob_drm_device *sdev = crtc->dev->dev_private;
+ struct shmob_drm_device *sdev = to_shmob_device(crtc->dev);
const struct shmob_drm_interface_data *idata = &sdev->pdata->iface;
const struct shmob_drm_format_info *format;
struct drm_device *dev = &sdev->ddev;
@@ -193,7 +193,7 @@ static void shmob_drm_crtc_start(struct shmob_drm_crtc *scrtc)
static void shmob_drm_crtc_stop(struct shmob_drm_crtc *scrtc)
{
struct drm_crtc *crtc = &scrtc->crtc;
- struct shmob_drm_device *sdev = crtc->dev->dev_private;
+ struct shmob_drm_device *sdev = to_shmob_device(crtc->dev);

if (!scrtc->started)
return;
@@ -247,7 +247,7 @@ static void shmob_drm_crtc_compute_base(struct shmob_drm_crtc *scrtc,
static void shmob_drm_crtc_update_base(struct shmob_drm_crtc *scrtc)
{
struct drm_crtc *crtc = &scrtc->crtc;
- struct shmob_drm_device *sdev = crtc->dev->dev_private;
+ struct shmob_drm_device *sdev = to_shmob_device(crtc->dev);

shmob_drm_crtc_compute_base(scrtc, crtc->x, crtc->y);

@@ -289,8 +289,8 @@ static int shmob_drm_crtc_mode_set(struct drm_crtc *crtc,
int x, int y,
struct drm_framebuffer *old_fb)
{
+ struct shmob_drm_device *sdev = to_shmob_device(crtc->dev);
struct shmob_drm_crtc *scrtc = to_shmob_crtc(crtc);
- struct shmob_drm_device *sdev = crtc->dev->dev_private;
const struct shmob_drm_format_info *format;

format = shmob_drm_format_info(crtc->primary->fb->format->format);
@@ -395,7 +395,7 @@ static void shmob_drm_crtc_enable_vblank(struct shmob_drm_device *sdev,

static int shmob_drm_enable_vblank(struct drm_crtc *crtc)
{
- struct shmob_drm_device *sdev = crtc->dev->dev_private;
+ struct shmob_drm_device *sdev = to_shmob_device(crtc->dev);

shmob_drm_crtc_enable_vblank(sdev, true);

@@ -404,7 +404,7 @@ static int shmob_drm_enable_vblank(struct drm_crtc *crtc)

static void shmob_drm_disable_vblank(struct drm_crtc *crtc)
{
- struct shmob_drm_device *sdev = crtc->dev->dev_private;
+ struct shmob_drm_device *sdev = to_shmob_device(crtc->dev);

shmob_drm_crtc_enable_vblank(sdev, false);
}
@@ -478,7 +478,7 @@ static bool shmob_drm_encoder_mode_fixup(struct drm_encoder *encoder,
struct drm_display_mode *adjusted_mode)
{
struct drm_device *dev = encoder->dev;
- struct shmob_drm_device *sdev = dev->dev_private;
+ struct shmob_drm_device *sdev = to_shmob_device(dev);
struct drm_connector *connector = &sdev->connector.connector;
const struct drm_display_mode *panel_mode;

@@ -548,7 +548,7 @@ static inline struct shmob_drm_connector *to_shmob_connector(struct drm_connecto

static int shmob_drm_connector_get_modes(struct drm_connector *connector)
{
- struct shmob_drm_device *sdev = connector->dev->dev_private;
+ struct shmob_drm_device *sdev = to_shmob_device(connector->dev);
struct drm_display_mode *mode;

mode = drm_mode_create(connector->dev);
diff --git a/drivers/gpu/drm/renesas/shmobile/shmob_drm_drv.c b/drivers/gpu/drm/renesas/shmobile/shmob_drm_drv.c
index 3f40ebb96747d1e7..c9ac8a86a7c39097 100644
--- a/drivers/gpu/drm/renesas/shmobile/shmob_drm_drv.c
+++ b/drivers/gpu/drm/renesas/shmobile/shmob_drm_drv.c
@@ -95,7 +95,7 @@ static int shmob_drm_setup_clocks(struct shmob_drm_device *sdev,
static irqreturn_t shmob_drm_irq(int irq, void *arg)
{
struct drm_device *dev = arg;
- struct shmob_drm_device *sdev = dev->dev_private;
+ struct shmob_drm_device *sdev = to_shmob_device(dev);
unsigned long flags;
u32 status;

@@ -244,8 +244,6 @@ static int shmob_drm_probe(struct platform_device *pdev)
if (ret < 0)
return ret;

- ddev->dev_private = sdev;
-
ret = shmob_drm_modeset_init(sdev);
if (ret < 0)
return dev_err_probe(&pdev->dev, ret,
diff --git a/drivers/gpu/drm/renesas/shmobile/shmob_drm_drv.h b/drivers/gpu/drm/renesas/shmobile/shmob_drm_drv.h
index 77bb0da48f37ace8..5e55ba7a207865bd 100644
--- a/drivers/gpu/drm/renesas/shmobile/shmob_drm_drv.h
+++ b/drivers/gpu/drm/renesas/shmobile/shmob_drm_drv.h
@@ -39,4 +39,9 @@ struct shmob_drm_device {
struct shmob_drm_connector connector;
};

+static inline struct shmob_drm_device *to_shmob_device(struct drm_device *dev)
+{
+ return container_of(dev, struct shmob_drm_device, ddev);
+}
+
#endif /* __SHMOB_DRM_DRV_H__ */
diff --git a/drivers/gpu/drm/renesas/shmobile/shmob_drm_plane.c b/drivers/gpu/drm/renesas/shmobile/shmob_drm_plane.c
index 258288c80756bf16..c58b9dca34736342 100644
--- a/drivers/gpu/drm/renesas/shmobile/shmob_drm_plane.c
+++ b/drivers/gpu/drm/renesas/shmobile/shmob_drm_plane.c
@@ -63,7 +63,7 @@ static void shmob_drm_plane_compute_base(struct shmob_drm_plane *splane,
static void __shmob_drm_plane_setup(struct shmob_drm_plane *splane,
struct drm_framebuffer *fb)
{
- struct shmob_drm_device *sdev = splane->plane.dev->dev_private;
+ struct shmob_drm_device *sdev = to_shmob_device(splane->plane.dev);
u32 format;

/* TODO: Support ROP3 mode */
@@ -135,8 +135,8 @@ shmob_drm_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,
uint32_t src_w, uint32_t src_h,
struct drm_modeset_acquire_ctx *ctx)
{
+ struct shmob_drm_device *sdev = to_shmob_device(plane->dev);
struct shmob_drm_plane *splane = to_shmob_plane(plane);
- struct shmob_drm_device *sdev = plane->dev->dev_private;
const struct shmob_drm_format_info *format;

format = shmob_drm_format_info(fb->format->format);
@@ -167,8 +167,8 @@ shmob_drm_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,
static int shmob_drm_plane_disable(struct drm_plane *plane,
struct drm_modeset_acquire_ctx *ctx)
{
+ struct shmob_drm_device *sdev = to_shmob_device(plane->dev);
struct shmob_drm_plane *splane = to_shmob_plane(plane);
- struct shmob_drm_device *sdev = plane->dev->dev_private;

splane->format = NULL;

--
2.34.1


2023-07-18 17:47:56

by Geert Uytterhoeven

[permalink] [raw]
Subject: [PATCH v2 10/41] drm: renesas: shmobile: Add missing YCbCr formats

The primary plane supports various YCbCr formats, and the CRTC code
already knows how to handle them. Enable support for the missing
formats by adding them to the table of supported modes.

Signed-off-by: Geert Uytterhoeven <[email protected]>
Reviewed-by: Laurent Pinchart <[email protected]>
---
v2:
- Add Reviewed-by.
---
drivers/gpu/drm/renesas/shmobile/shmob_drm_crtc.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/renesas/shmobile/shmob_drm_crtc.c b/drivers/gpu/drm/renesas/shmobile/shmob_drm_crtc.c
index 2d9ae0c6ab7b18a8..a0e1a49c84d5691a 100644
--- a/drivers/gpu/drm/renesas/shmobile/shmob_drm_crtc.c
+++ b/drivers/gpu/drm/renesas/shmobile/shmob_drm_crtc.c
@@ -460,6 +460,12 @@ static const uint32_t modeset_formats[] = {
DRM_FORMAT_RGB888,
DRM_FORMAT_ARGB8888,
DRM_FORMAT_XRGB8888,
+ DRM_FORMAT_NV12,
+ DRM_FORMAT_NV21,
+ DRM_FORMAT_NV16,
+ DRM_FORMAT_NV61,
+ DRM_FORMAT_NV24,
+ DRM_FORMAT_NV42,
};

static const struct drm_plane_funcs primary_plane_funcs = {
--
2.34.1