Kernel clients

This library provides support for clients running in the kernel like fbdev and bootsplash. Currently it’s only partially implemented, just enough to support fbdev.

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
unregister

Called when drm_device is unregistered. The client should respond by releasing it’s resources using drm_client_release().

This callback is optional.

restore

Called on drm_lastclose(). The first client instance in the list that returns zero gets the privilege to restore and no more clients are called. This callback is not called after unregister has been called.

This callback is optional.

hotplug

Called on drm_kms_helper_hotplug_event(). This callback is not called after unregister 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;
};

Members

dev
DRM device
name
Name of the client.
list
List of all clients of a DRM device, linked into drm_device.clientlist. Protected by drm_device.clientlist_mutex.
funcs
DRM client functions (optional)
file
DRM file
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
int drm_client_init(struct drm_device * dev, struct drm_client_dev * client, const char * name, const struct drm_client_funcs * funcs)

Initialise a DRM client

Parameters

struct drm_device * dev
DRM device
struct drm_client_dev * client
DRM client
const char * name
Client name
const struct drm_client_funcs * funcs
DRM client functions (optional)

Description

This initialises the client and opens a drm_file. Use drm_client_add() to complete the process. The caller needs to hold a reference on dev before calling this function. The client is freed when the drm_device is unregistered. See drm_client_release().

Return

Zero on success or negative error code on failure.

void drm_client_add(struct drm_client_dev * client)

Add client to the device list

Parameters

struct drm_client_dev * client
DRM client

Description

Add the client to the drm_device client list to activate its callbacks. client must be initialized by a call to drm_client_init(). After drm_client_add() it is no longer permissible to call drm_client_release() directly (outside the unregister callback), instead cleanup will happen automatically on driver unload.

void drm_client_release(struct drm_client_dev * client)

Release DRM client resources

Parameters

struct drm_client_dev * client
DRM client

Description

Releases resources by closing the drm_file that was opened by drm_client_init(). It is called automatically if the drm_client_funcs.unregister callback is _not_ set.

This function should only be called from the unregister callback. An exception is 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(struct drm_device * dev)

Send hotplug event to clients

Parameters

struct drm_device * dev
DRM device

Description

This function calls the drm_client_funcs.hotplug callback on the attached clients.

drm_kms_helper_hotplug_event() calls this function, so drivers that use it don’t need to call this function themselves.

struct drm_client_buffer * drm_client_framebuffer_create(struct drm_client_dev * client, u32 width, u32 height, u32 format)

Create a client framebuffer

Parameters

struct drm_client_dev * client
DRM client
u32 width
Framebuffer width
u32 height
Framebuffer height
u32 format
Buffer format

Description

This function creates a drm_client_buffer which consists of a drm_framebuffer backed by a dumb buffer. Call drm_client_framebuffer_delete() to free the buffer.

Return

Pointer to a client buffer or an error pointer on failure.

void drm_client_framebuffer_delete(struct drm_client_buffer * buffer)

Delete a client framebuffer

Parameters

struct drm_client_buffer * buffer
DRM client buffer (can be NULL)