Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 9df628f

Browse files
Thomas ZimmermannCarlos Llamas
authored andcommitted
UPSTREAM: drm: Add client-agnostic setup helper
[ Upstream commit d07fdf9 ] DRM may support multiple in-kernel clients that run as soon as a DRM driver has been registered. To select the client(s) in a single place, introduce drm_client_setup(). Drivers that call the new helper automatically instantiate the kernel's configured default clients. Only fbdev emulation is currently supported. Later versions can add support for DRM-based logging, a boot logo or even a console. Some drivers handle the color mode for clients internally. Provide the helper drm_client_setup_with_color_mode() for them. Using the new interface requires the driver to select DRM_CLIENT_SELECTION in its Kconfig. For now this only enables the client-setup helpers if the fbdev client has been configured by the user. A future patchset will further modularize client support and rework DRM_CLIENT_SELECTION to select the correct dependencies for all its clients. v5: - add CONFIG_DRM_CLIENT_SELECTION und DRM_CLIENT_SETUP v4: - fix docs for drm_client_setup_with_fourcc() (Geert) v3: - fix build error v2: - add drm_client_setup_with_fourcc() (Laurent) - push default-format handling into actual clients Change-Id: I78a2e4fec8c831d13a16a66f57a91e2e7a6fc1c5 Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Link: https://patchwork.freedesktop.org/patch/msgid/20240924071734.98201-5-tzimmermann@suse.de Stable-dep-of: 6b481ab ("drm/nouveau: select FW caching") Signed-off-by: Sasha Levin <sashal@kernel.org> (cherry picked from commit 09d1157) Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
1 parent a387aeb commit 9df628f

File tree

4 files changed

+106
-0
lines changed

4 files changed

+106
-0
lines changed

drivers/gpu/drm/Kconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,18 @@ config DRM_DEBUG_MODESET_LOCK
211211

212212
If in doubt, say "N".
213213

214+
config DRM_CLIENT_SELECTION
215+
bool
216+
depends on DRM
217+
select DRM_CLIENT_SETUP if DRM_FBDEV_EMULATION
218+
help
219+
Drivers that support in-kernel DRM clients have to select this
220+
option.
221+
222+
config DRM_CLIENT_SETUP
223+
bool
224+
depends on DRM_CLIENT_SELECTION
225+
214226
config DRM_FBDEV_EMULATION
215227
bool "Enable legacy fbdev support for your modesetting driver"
216228
depends on DRM

drivers/gpu/drm/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ drm_kms_helper-y := \
144144
drm_rect.o \
145145
drm_self_refresh_helper.o \
146146
drm_simple_kms_helper.o
147+
drm_kms_helper-$(CONFIG_DRM_CLIENT_SETUP) += \
148+
drm_client_setup.o
147149
drm_kms_helper-$(CONFIG_DRM_PANEL_BRIDGE) += bridge/panel.o
148150
drm_kms_helper-$(CONFIG_DRM_FBDEV_EMULATION) += \
149151
drm_fbdev_client.o \

drivers/gpu/drm/drm_client_setup.c

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// SPDX-License-Identifier: MIT
2+
3+
#include <drm/drm_client_setup.h>
4+
#include <drm/drm_device.h>
5+
#include <drm/drm_fbdev_client.h>
6+
#include <drm/drm_fourcc.h>
7+
#include <drm/drm_print.h>
8+
9+
/**
10+
* drm_client_setup() - Setup in-kernel DRM clients
11+
* @dev: DRM device
12+
* @format: Preferred pixel format for the device. Use NULL, unless
13+
* there is clearly a driver-preferred format.
14+
*
15+
* This function sets up the in-kernel DRM clients. Restore, hotplug
16+
* events and teardown are all taken care of.
17+
*
18+
* Drivers should call drm_client_setup() after registering the new
19+
* DRM device with drm_dev_register(). This function is safe to call
20+
* even when there are no connectors present. Setup will be retried
21+
* on the next hotplug event.
22+
*
23+
* The clients are destroyed by drm_dev_unregister().
24+
*/
25+
void drm_client_setup(struct drm_device *dev, const struct drm_format_info *format)
26+
{
27+
int ret;
28+
29+
ret = drm_fbdev_client_setup(dev, format);
30+
if (ret)
31+
drm_warn(dev, "Failed to set up DRM client; error %d\n", ret);
32+
}
33+
EXPORT_SYMBOL(drm_client_setup);
34+
35+
/**
36+
* drm_client_setup_with_fourcc() - Setup in-kernel DRM clients for color mode
37+
* @dev: DRM device
38+
* @fourcc: Preferred pixel format as 4CC code for the device
39+
*
40+
* This function sets up the in-kernel DRM clients. It is equivalent
41+
* to drm_client_setup(), but expects a 4CC code as second argument.
42+
*/
43+
void drm_client_setup_with_fourcc(struct drm_device *dev, u32 fourcc)
44+
{
45+
drm_client_setup(dev, drm_format_info(fourcc));
46+
}
47+
EXPORT_SYMBOL(drm_client_setup_with_fourcc);
48+
49+
/**
50+
* drm_client_setup_with_color_mode() - Setup in-kernel DRM clients for color mode
51+
* @dev: DRM device
52+
* @color_mode: Preferred color mode for the device
53+
*
54+
* This function sets up the in-kernel DRM clients. It is equivalent
55+
* to drm_client_setup(), but expects a color mode as second argument.
56+
*
57+
* Do not use this function in new drivers. Prefer drm_client_setup() with a
58+
* format of NULL.
59+
*/
60+
void drm_client_setup_with_color_mode(struct drm_device *dev, unsigned int color_mode)
61+
{
62+
u32 fourcc = drm_driver_color_mode_format(dev, color_mode);
63+
64+
drm_client_setup_with_fourcc(dev, fourcc);
65+
}
66+
EXPORT_SYMBOL(drm_client_setup_with_color_mode);

include/drm/drm_client_setup.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/* SPDX-License-Identifier: MIT */
2+
3+
#ifndef DRM_CLIENT_SETUP_H
4+
#define DRM_CLIENT_SETUP_H
5+
6+
#include <linux/types.h>
7+
8+
struct drm_device;
9+
struct drm_format_info;
10+
11+
#if defined(CONFIG_DRM_CLIENT_SETUP)
12+
void drm_client_setup(struct drm_device *dev, const struct drm_format_info *format);
13+
void drm_client_setup_with_fourcc(struct drm_device *dev, u32 fourcc);
14+
void drm_client_setup_with_color_mode(struct drm_device *dev, unsigned int color_mode);
15+
#else
16+
static inline void drm_client_setup(struct drm_device *dev,
17+
const struct drm_format_info *format)
18+
{ }
19+
static inline void drm_client_setup_with_fourcc(struct drm_device *dev, u32 fourcc)
20+
{ }
21+
static inline void drm_client_setup_with_color_mode(struct drm_device *dev,
22+
unsigned int color_mode)
23+
{ }
24+
#endif
25+
26+
#endif

0 commit comments

Comments
 (0)