This library provides driver helpers for very simple display hardware.
It is based on drm_simple_display_pipe coupled with a drm_connector which has only one fixed drm_display_mode. The framebuffers are backed by the cma helper and have support for framebuffer flushing (dirty). fbdev support is also included.
The driver allocates tinydrm_device, initializes it using devm_tinydrm_init(), sets up the pipeline using tinydrm_display_pipe_init() and registers the DRM device using devm_tinydrm_register().
tinydrm device
Definition
struct tinydrm_device {
struct drm_device * drm;
struct drm_simple_display_pipe pipe;
struct mutex dirty_lock;
struct drm_fbdev_cma * fbdev_cma;
struct drm_atomic_state * suspend_state;
const struct drm_framebuffer_funcs * fb_funcs;
};
Members
default tinydrm gem operations
Parameters
Description
This macro provides a shortcut for setting the tinydrm GEM operations in the drm_driver structure.
tinydrm display mode
Parameters
Description
This macro creates a drm_display_mode for use with tinydrm.
DRM lastclose helper
Parameters
Description
This function ensures that fbdev is restored when drm_lastclose() is called on the last drm_release(). Drivers can use this as their drm_driver->lastclose callback.
Produce a CMA GEM object from another driver’s scatter/gather table of pinned pages
Parameters
Description
This function imports a scatter/gather table exported via DMA-BUF by another driver using drm_gem_cma_prime_import_sg_table(). It sets the kernel virtual address on the CMA object. Drivers should use this as their drm_driver->gem_prime_import_sg_table callback if they need the virtual address. tinydrm_gem_cma_free_object() should be used in combination with this function.
Return
A pointer to a newly created GEM object or an ERR_PTR-encoded negative error code on failure.
Free resources associated with a CMA GEM object
Parameters
Description
This function frees the backing memory of the CMA GEM object, cleans up the GEM object state and frees the memory used to store the object itself using drm_gem_cma_free_object(). It also handles PRIME buffers which has the kernel virtual address set by tinydrm_gem_cma_prime_import_sg_table(). Drivers can use this as their drm_driver->gem_free_object callback.
Initialize tinydrm device
Parameters
Description
This function initializes tdev, the underlying DRM device and it’s mode_config. Resources will be automatically freed on driver detach (devres) using drm_mode_config_cleanup() and drm_dev_unref().
Return
Zero on success, negative error code on failure.
Register tinydrm device
Parameters
Description
This function registers the underlying DRM device and fbdev. These resources will be automatically unregistered on driver detach (devres) and the display pipeline will be disabled.
Return
Zero on success, negative error code on failure.
Shutdown tinydrm
Parameters
Description
This function makes sure that the display pipeline is disabled. Used by drivers in their shutdown callback to turn off the display on machine shutdown and reboot.
Suspend tinydrm
Parameters
Description
Used in driver PM operations to suspend tinydrm. Suspends fbdev and DRM. Resume with tinydrm_resume().
Return
Zero on success, negative error code on failure.
Resume tinydrm
Parameters
Description
Used in driver PM operations to resume tinydrm. Suspend with tinydrm_suspend().
Return
Zero on success, negative error code on failure.
Display pipe update helper
Parameters
Description
This function does a full framebuffer flush if the plane framebuffer has changed. It also handles vblank events. Drivers can use this as their drm_simple_display_pipe_funcs->update callback.
Display pipe prepare_fb helper
Parameters
Description
This function uses drm_fb_cma_prepare_fb() to check if the plane FB has an dma-buf attached, extracts the exclusive fence and attaches it to plane state for the atomic helper to wait on. Drivers can use this as their drm_simple_display_pipe_funcs->prepare_fb callback.
Initialize display pipe
Parameters
Description
This function sets up a drm_simple_display_pipe with a drm_connector that has one fixed drm_display_mode which is rotated according to rotation.
Return
Zero on success, negative error code on failure.
Machine is little endian
Parameters
Return
true if defined(__LITTLE_ENDIAN), false otherwise
Dump SPI message
Parameters
Description
Dumps info about the transfers in a SPI message including buffer content. DEBUG has to be defined for this function to be enabled alongside setting the DRM_UT_DRIVER bit of drm_debug.
Merge clip rectangles
Parameters
Description
This function merges src clip rectangle(s) into dst. If src is NULL, max_width and min_width is used to set a full dst clip rectangle.
Return
true if it’s a full clip, false otherwise
Copy clip buffer
Parameters
Swap bytes into clip buffer
Parameters
Convert XRGB8888 to RGB565 clip buffer
Parameters
Description
Drivers can use this function for RGB565 devices that don’t natively support XRGB8888.
Find backlight device in device-tree
Parameters
Description
This function looks for a DT node pointed to by a property named ‘backlight’ and uses of_find_backlight_by_node() to get the backlight device. Additionally if the brightness property is zero, it is set to max_brightness.
Return
NULL if there’s no backlight property. Error pointer -EPROBE_DEFER if the DT node is found, but no backlight device is found. If the backlight device is found, a pointer to the structure is returned.
Enable backlight helper
Parameters
Return
Zero on success, negative error code on failure.
Disable backlight helper
Parameters
Return
Zero on success, negative error code on failure.
Determine max SPI transfer size
Parameters
Description
This function returns the maximum size to use for SPI transfers. It checks the SPI master, the optional max_len and the module parameter spi_max and returns the smallest.
Return
Maximum size for SPI transfers
Check if bits per word is supported
Parameters
Description
This function checks to see if the SPI master driver supports bpw.
Return
True if bpw is supported, false otherwise.
SPI transfer helper
Parameters
Description
This SPI transfer helper breaks up the transfer of buf into chunks which the SPI master driver can handle. If the machine is Little Endian and the SPI master driver doesn’t support 16 bits per word, it swaps the bytes and does a 8-bit transfer. If header is set, it is prepended to each SPI message.
Return
Zero on success, negative error code on failure.
This library provides helpers for MIPI Display Bus Interface (DBI) compatible display controllers.
Many controllers for tiny lcd displays are MIPI compliant and can use this library. If a controller uses registers 0x2A and 0x2B to set the area to update and uses register 0x2C to write to frame memory, it is most likely MIPI compliant.
Only MIPI Type 1 displays are supported since a full frame memory is needed.
There are 3 MIPI DBI implementation types:
Currently mipi_dbi only supports Type C options 1 and 3 with mipi_dbi_spi_init().
MIPI DBI controller
Definition
struct mipi_dbi {
struct tinydrm_device tinydrm;
struct spi_device * spi;
bool enabled;
struct mutex cmdlock;
int (* command) (struct mipi_dbi *mipi, u8 cmd, u8 *param, size_t num);
const u8 * read_commands;
struct gpio_desc * dc;
u16 * tx_buf;
void * tx_buf9;
size_t tx_buf9_len;
bool swap_bytes;
struct gpio_desc * reset;
unsigned int rotation;
struct backlight_device * backlight;
struct regulator * regulator;
};
Members
MIPI DCS command with optional parameter(s)
Parameters
Description
Send MIPI DCS command to the controller. Use mipi_dbi_command_read() for get/read.
Return
Zero on success, negative error code on failure.
Parameters
Description
Send MIPI DCS read command to the controller.
Return
Zero on success, negative error code on failure.
MIPI DCS command with parameter(s) in an array
Parameters
Return
Zero on success, negative error code on failure.
MIPI DBI pipe enable helper
Parameters
Description
This function enables backlight. Drivers can use this as their drm_simple_display_pipe_funcs->enable callback.
MIPI DBI pipe disable helper
Parameters
Description
This function disables backlight if present or if not the display memory is blanked. Drivers can use this as their drm_simple_display_pipe_funcs->disable callback.
MIPI DBI initialization
Parameters
Description
This function initializes a mipi_dbi structure and it’s underlying tinydrm_device. It also sets up the display pipeline.
Supported formats: Native RGB565 and emulated XRGB8888.
Objects created by this function will be automatically freed on driver detach (devres).
Return
Zero on success, negative error code on failure.
Parameters
Description
Reset controller if the mipi_dbi->reset gpio is set.
Parameters
Description
This function checks the Power Mode register (if readable) to see if display output is turned on. This can be used to see if the bootloader has already turned on the display avoiding flicker when the pipeline is enabled.
Return
true if the display can be verified to be on, false otherwise.
Initialize MIPI DBI SPI interfaced controller
Parameters
Description
This function sets mipi_dbi->command, enables mipi->read_commands for the usual read commands and initializes mipi using mipi_dbi_init().
If dc is set, a Type C Option 3 interface is assumed, if not Type C Option 1.
If the SPI master driver doesn’t support the necessary bits per word, the following transformation is used:
Return
Zero on success, negative error code on failure.
Parameters
Description
This function creates a ‘command’ debugfs file for sending commands to the controller or getting the read command values. Drivers can use this as their drm_driver->debugfs_init callback.
Return
Zero on success, negative error code on failure.