Kernel clients¶
This library provides support for clients running in the kernel like fbdev and bootsplash.
GEM drivers which provide a GEM based dumb buffer with a virtual address are supported.
- struct
drm_client_funcs¶ DRM client callbacks
Definition
struct drm_client_funcs { struct module *owner; void (*unregister)(struct drm_client_dev *client); int (*restore)(struct drm_client_dev *client); int (*hotplug)(struct drm_client_dev *client);};Members
owner- The module owner
unregisterCalled when
drm_deviceis unregistered. The client should respond byreleasing its resources usingdrm_client_release().This callback is optional.
restoreCalled on drm_lastclose(). The first client instance in the list thatreturns zero gets the privilege to restore and no more clients arecalled. This callback is not called afterunregister has been called.
Note that the core does not guarantee exclusion against concurrent
drm_open(). Clients need to ensure this themselves, for example byusing drm_master_internal_acquire() anddrm_master_internal_release().This callback is optional.
hotplugCalled on
drm_kms_helper_hotplug_event().This callback is not called afterunregister has been called.This callback is optional.
- struct
drm_client_dev¶ DRM client instance
Definition
struct drm_client_dev { struct drm_device *dev; const char *name; struct list_head list; const struct drm_client_funcs *funcs; struct drm_file *file; struct mutex modeset_mutex; struct drm_mode_set *modesets;};Members
dev- DRM device
name- Name of the client.
list- List of all clients of a DRM device, linked into
drm_device.clientlist. Protected bydrm_device.clientlist_mutex. funcs- DRM client functions (optional)
file- DRM file
modeset_mutex- Protectsmodesets.
modesets- CRTC configurations
- struct
drm_client_buffer¶ DRM client buffer
Definition
struct drm_client_buffer { struct drm_client_dev *client; u32 handle; u32 pitch; struct drm_gem_object *gem; void *vaddr; struct drm_framebuffer *fb;};Members
client- DRM client
handle- Buffer handle
pitch- Buffer pitch
gem- GEM object backing this buffer
vaddr- Virtual address for the buffer
fb- DRM framebuffer
drm_client_for_each_modeset(modeset,client)¶Iterate over client modesets
Parameters
modesetdrm_mode_setloop cursorclient- DRM client
drm_client_for_each_connector_iter(connector,iter)¶connector_list iterator macro
Parameters
connectorstructdrm_connectorpointer used as cursoriterstructdrm_connector_list_iter
Description
This iterates the connectors that are useable for internal clients (excludeswriteback connectors).
For more info seedrm_for_each_connector_iter().
- int
drm_client_init(structdrm_device * dev, structdrm_client_dev * client, const char * name, const structdrm_client_funcs * funcs)¶ Initialise a DRM client
Parameters
structdrm_device*dev- DRM device
structdrm_client_dev*client- DRM client
constchar*name- Client name
conststructdrm_client_funcs*funcs- DRM client functions (optional)
Description
This initialises the client and opens adrm_file.Usedrm_client_register() to complete the process.The caller needs to hold a reference ondev before calling this function.The client is freed when thedrm_device is unregistered. Seedrm_client_release().
Return
Zero on success or negative error code on failure.
- void
drm_client_register(structdrm_client_dev * client)¶ Register client
Parameters
structdrm_client_dev*client- DRM client
Description
Add the client to thedrm_device client list to activate its callbacks.client must be initialized by a call todrm_client_init(). Afterdrm_client_register() it is no longer permissible to calldrm_client_release()directly (outside the unregister callback), instead cleanup will happenautomatically on driver unload.
- void
drm_client_release(structdrm_client_dev * client)¶ Release DRM client resources
Parameters
structdrm_client_dev*client- DRM client
Description
Releases resources by closing thedrm_file that was opened bydrm_client_init().It is called automatically if thedrm_client_funcs.unregister callback is _not_ set.
This function should only be called from the unregister callback. An exceptionis fbdev which cannot free the buffer if userspace has open file descriptors.
Note
Clients cannot initiate a release by themselves. This is done to keep the code simple.The driver has to be unloaded before the client can be unloaded.
- void
drm_client_dev_hotplug(structdrm_device * dev)¶ Send hotplug event to clients
Parameters
structdrm_device*dev- DRM device
Description
This function calls thedrm_client_funcs.hotplug callback on the attached clients.
drm_kms_helper_hotplug_event() calls this function, so drivers that use itdon’t need to call this function themselves.
- void *
drm_client_buffer_vmap(structdrm_client_buffer * buffer)¶ Map DRM client buffer into address space
Parameters
structdrm_client_buffer*buffer- DRM client buffer
Description
This function maps a client buffer into kernel address space. If thebuffer is already mapped, it returns the mapping’s address.
Client buffer mappings are not ref’counted. Each call todrm_client_buffer_vmap() should be followed by a call todrm_client_buffer_vunmap(); or the client buffer should be mappedthroughout its lifetime.
Return
The mapped memory’s address
- void
drm_client_buffer_vunmap(structdrm_client_buffer * buffer)¶ Unmap DRM client buffer
Parameters
structdrm_client_buffer*buffer- DRM client buffer
Description
This function removes a client buffer’s memory mapping. Calling thisfunction is only required by clients that manage their buffer mappingsby themselves.
- structdrm_client_buffer *
drm_client_framebuffer_create(structdrm_client_dev * client, u32 width, u32 height, u32 format)¶ Create a client framebuffer
Parameters
structdrm_client_dev*client- DRM client
u32width- Framebuffer width
u32height- Framebuffer height
u32format- Buffer format
Description
This function creates adrm_client_buffer which consists of adrm_framebuffer backed by a dumb buffer.Calldrm_client_framebuffer_delete() to free the buffer.
Return
Pointer to a client buffer or an error pointer on failure.
- void
drm_client_framebuffer_delete(structdrm_client_buffer * buffer)¶ Delete a client framebuffer
Parameters
structdrm_client_buffer*buffer- DRM client buffer (can be NULL)
- int
drm_client_framebuffer_flush(structdrm_client_buffer * buffer, structdrm_rect * rect)¶ Manually flush client framebuffer
Parameters
structdrm_client_buffer*buffer- DRM client buffer (can be NULL)
structdrm_rect*rect- Damage rectangle (if NULL flushes all)
Description
This callsdrm_framebuffer_funcs->dirty (if present) to flush buffer changesfor drivers that need it.
Return
Zero on success or negative error code on failure.
- int
drm_client_modeset_probe(structdrm_client_dev * client, unsigned int width, unsigned int height)¶ Probe for displays
Parameters
structdrm_client_dev*client- DRM client
unsignedintwidth- Maximum display mode width (optional)
unsignedintheight- Maximum display mode height (optional)
Description
This function sets up display pipelines for enabled connectors and stores theconfig in the client’s modeset array.
Return
Zero on success or negative error code on failure.
- bool
drm_client_rotation(structdrm_mode_set * modeset, unsigned int * rotation)¶ Check the initial rotation value
Parameters
structdrm_mode_set*modeset- DRM modeset
unsignedint*rotation- Returned rotation value
Description
This function checks if the primary plane inmodeset can hw rotateto match the rotation needed on its connector.
Note
Currently only 0 and 180 degrees are supported.
Return
True if the plane can do the rotation, false otherwise.
- int
drm_client_modeset_check(structdrm_client_dev * client)¶ Check modeset configuration
Parameters
structdrm_client_dev*client- DRM client
Description
Check modeset configuration.
Return
Zero on success or negative error code on failure.
- int
drm_client_modeset_commit_locked(structdrm_client_dev * client)¶ Force commit CRTC configuration
Parameters
structdrm_client_dev*client- DRM client
Description
Commit modeset configuration to crtcs without checking if there is a DRMmaster. The assumption is that the caller already holds an internal DRMmaster reference acquired with drm_master_internal_acquire().
Return
Zero on success or negative error code on failure.
- int
drm_client_modeset_commit(structdrm_client_dev * client)¶ Commit CRTC configuration
Parameters
structdrm_client_dev*client- DRM client
Description
Commit modeset configuration to crtcs.
Return
Zero on success or negative error code on failure.
- int
drm_client_modeset_dpms(structdrm_client_dev * client, int mode)¶ Set DPMS mode
Parameters
structdrm_client_dev*client- DRM client
intmode- DPMS mode
Note
For atomic driversmode is reduced to on/off.
Return
Zero on success or negative error code on failure.