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.
- structdrm_client_funcs¶
DRM client callbacks
Definition:
struct drm_client_funcs { struct module *owner; void (*free)(struct drm_client_dev *client); void (*unregister)(struct drm_client_dev *client); int (*restore)(struct drm_client_dev *client, bool force); int (*hotplug)(struct drm_client_dev *client); int (*suspend)(struct drm_client_dev *client); int (*resume)(struct drm_client_dev *client);};Members
ownerThe module owner
freeCalled when the client gets unregistered. Implementations shouldrelease all client-specific data and free the memory.
This callback is optional.
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 byusingdrm_master_internal_acquire()anddrm_master_internal_release().If the caller passes force, the client should ignore any present DRMmaster and restore the display anyway.
This callback is optional.
hotplugCalled on
drm_kms_helper_hotplug_event().This callback is not called afterunregister has been called.This callback is optional.
suspendCalled when suspending the device.
This callback is optional.
resumeCalled when resuming the device from suspend.
This callback is optional.
- structdrm_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; bool suspended; bool hotplug_pending; bool hotplug_failed;};Members
devDRM device
nameName of the client.
listList of all clients of a DRM device, linked into
drm_device.clientlist. Protected bydrm_device.clientlist_mutex.funcsDRM client functions (optional)
fileDRM file
modeset_mutexProtectsmodesets.
modesetsCRTC configurations
suspendedThe client has been suspended.
hotplug_pendingA hotplug event has been received while the client was suspended.Try again on resume.
hotplug_failedSet by client hotplug helpers if the hotplugging failedbefore. It is usually not tried again.
- structdrm_client_buffer¶
DRM client buffer
Definition:
struct drm_client_buffer { struct drm_client_dev *client; struct drm_gem_object *gem; struct iosys_map map; struct drm_framebuffer *fb;};Members
clientDRM client
gemGEM object backing this buffer
FIXME: The DRM framebuffer holds a reference on its GEMbuffer objects. Do not use this field in new code andupdate existing users.
mapVirtual address for the buffer
fbDRM framebuffer
- drm_client_for_each_modeset¶
drm_client_for_each_modeset(modeset,client)
Iterate over client modesets
Parameters
modesetdrm_mode_setloop cursorclientDRM client
- drm_client_for_each_connector_iter¶
drm_client_for_each_connector_iter(connector,iter)
connector_list iterator macro
Parameters
connectorstructdrm_connectorpointer used as cursoriter
Description
This iterates the connectors that are useable for internal clients (excludeswriteback connectors).
For more info seedrm_for_each_connector_iter().
- intdrm_client_init(structdrm_device*dev,structdrm_client_dev*client,constchar*name,conststructdrm_client_funcs*funcs)¶
Initialise a DRM client
Parameters
structdrm_device*devDRM device
structdrm_client_dev*clientDRM client
constchar*nameClient name
conststructdrm_client_funcs*funcsDRM 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.
- voiddrm_client_register(structdrm_client_dev*client)¶
Register client
Parameters
structdrm_client_dev*clientDRM 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.
Registering a client generates a hotplug event that allows the clientto set up its display from pre-existing outputs. The client must haveinitialized its state to able to handle the hotplug event successfully.
- voiddrm_client_release(structdrm_client_dev*client)¶
Release DRM client resources
Parameters
structdrm_client_dev*clientDRM 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.
- voiddrm_client_buffer_delete(structdrm_client_buffer*buffer)¶
Delete a client buffer
Parameters
structdrm_client_buffer*bufferDRM client buffer
- intdrm_client_buffer_vmap_local(structdrm_client_buffer*buffer,structiosys_map*map_copy)¶
Map DRM client buffer into address space
Parameters
structdrm_client_buffer*bufferDRM client buffer
structiosys_map*map_copyReturns the mapped memory’s address
Description
This function maps a client buffer into kernel address space. If thebuffer is already mapped, it returns the existing mapping’s address.
Client buffer mappings are not ref’counted. Each call todrm_client_buffer_vmap_local() should be closely followed by a call todrm_client_buffer_vunmap_local(). Seedrm_client_buffer_vmap() forlong-term mappings.
The returned address is a copy of the internal value. In contrast toother vmap interfaces, you don’t need it for the client’s vunmapfunction. So you can modify it at will during blit and draw operations.
Return
0 on success, or a negative errno code otherwise.
- voiddrm_client_buffer_vunmap_local(structdrm_client_buffer*buffer)¶
Unmap DRM client buffer
Parameters
structdrm_client_buffer*bufferDRM client buffer
Description
This function removes a client buffer’s memory mapping establishedwithdrm_client_buffer_vunmap_local(). Calling this function is onlyrequired by clients that manage their buffer mappings by themselves.
- intdrm_client_buffer_vmap(structdrm_client_buffer*buffer,structiosys_map*map_copy)¶
Map DRM client buffer into address space
Parameters
structdrm_client_buffer*bufferDRM client buffer
structiosys_map*map_copyReturns the mapped memory’s address
Description
This function maps a client buffer into kernel address space. If thebuffer is already mapped, it returns the existing 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.
The returned address is a copy of the internal value. In contrast toother vmap interfaces, you don’t need it for the client’s vunmapfunction. So you can modify it at will during blit and draw operations.
Return
0 on success, or a negative errno code otherwise.
- voiddrm_client_buffer_vunmap(structdrm_client_buffer*buffer)¶
Unmap DRM client buffer
Parameters
structdrm_client_buffer*bufferDRM 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_buffer_create_dumb(structdrm_client_dev*client,u32width,u32height,u32format)¶
Create a client buffer backed by a dumb buffer
Parameters
structdrm_client_dev*clientDRM client
u32widthFramebuffer width
u32heightFramebuffer height
u32formatBuffer format
Description
This function creates adrm_client_buffer which consists of adrm_framebuffer backed by a dumb buffer.Calldrm_client_buffer_delete() to free the buffer.
Return
Pointer to a client buffer or an error pointer on failure.
- intdrm_client_buffer_flush(structdrm_client_buffer*buffer,structdrm_rect*rect)¶
Manually flush client buffer
Parameters
structdrm_client_buffer*bufferDRM client buffer
structdrm_rect*rectDamage 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.
- intdrm_client_modeset_probe(structdrm_client_dev*client,unsignedintwidth,unsignedintheight)¶
Probe for displays
Parameters
structdrm_client_dev*clientDRM client
unsignedintwidthMaximum display mode width (optional)
unsignedintheightMaximum 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.
- booldrm_client_rotation(structdrm_mode_set*modeset,unsignedint*rotation)¶
Check the initial rotation value
Parameters
structdrm_mode_set*modesetDRM modeset
unsignedint*rotationReturned 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.
- intdrm_client_modeset_check(structdrm_client_dev*client)¶
Check modeset configuration
Parameters
structdrm_client_dev*clientDRM client
Description
Check modeset configuration.
Return
Zero on success or negative error code on failure.
- intdrm_client_modeset_commit_locked(structdrm_client_dev*client)¶
Force commit CRTC configuration
Parameters
structdrm_client_dev*clientDRM 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 withdrm_master_internal_acquire().
Return
Zero on success or negative error code on failure.
- intdrm_client_modeset_commit(structdrm_client_dev*client)¶
Commit CRTC configuration
Parameters
structdrm_client_dev*clientDRM client
Description
Commit modeset configuration to crtcs.
Return
Zero on success or negative error code on failure.
- intdrm_client_modeset_dpms(structdrm_client_dev*client,intmode)¶
Set DPMS mode
Parameters
structdrm_client_dev*clientDRM client
intmodeDPMS mode
Note
For atomic driversmode is reduced to on/off.
Return
Zero on success or negative error code on failure.
- intdrm_client_modeset_wait_for_vblank(structdrm_client_dev*client,unsignedintcrtc_index)¶
Wait for the next VBLANK to occur
Parameters
structdrm_client_dev*clientDRM client
unsignedintcrtc_indexThe ndex of the CRTC to wait on
Description
Block the caller until the given CRTC has seen a VBLANK. Do nothingif the CRTC is disabled. If there’s another DRM master present, failwith -EBUSY.
Return
0 on success, or negative error code otherwise.
- voiddrm_client_dev_unregister(structdrm_device*dev)¶
Unregister clients
Parameters
structdrm_device*devDRM device
Description
This function releases all clients by calling each client’sdrm_client_funcs.unregister callback. The callback functionis responsibe for releaseing all resources including the clientitself.
The helperdrm_dev_unregister() calls this function. Driversthat use it don’t need to call this function themselves.
- voiddrm_client_dev_hotplug(structdrm_device*dev)¶
Send hotplug event to clients
Parameters
structdrm_device*devDRM 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.