|
Zephyr API Documentation 4.4.99
A Scalable Open Source RTOS
|
RGB-to-palette dithering helpers for display drivers. More...
Files | |
| file | color_dither.h |
| Color dithering helpers for display drivers. | |
Data Structures | |
| struct | display_color_dither_state |
| Runtime state owned by the color dithering helper for one display device instance. More... | |
Macros | |
| #define | DISPLAY_COLOR_DITHER_DEFINE(inst) |
| Define color dithering backing storage for one display driver instance. | |
| #define | DISPLAY_COLOR_DITHER_INIT(inst) |
| Initialize a driver's display_color_dither_state member for one display driver instance. | |
Functions | |
| int | display_color_dither_prepare (const struct device *dev, struct display_color_dither_state *state, const struct display_buffer_descriptor **desc, const void **buf, struct display_buffer_descriptor *scratch) |
| Prepare a write buffer for a PIXEL_FORMAT_I_4 native path. | |
| void | display_color_dither_patch_caps (struct display_color_dither_state *state, struct display_capabilities *caps) |
| Add helper-managed RGB formats to display capabilities. | |
| int | display_color_dither_set_input_format (struct display_color_dither_state *state, enum display_pixel_format pf) |
| Select the helper input pixel format. | |
| bool | display_color_dither_is_active (const struct display_color_dither_state *state, enum display_pixel_format current_pixel_format) |
| Report whether the helper is actively converting input to native I_4. | |
RGB-to-palette dithering helpers for display drivers.
These helpers let a driver whose native write path consumes PIXEL_FORMAT_I_4 also accept configured RGB input formats. The helper converts each RGB write buffer to packed PIXEL_FORMAT_I_4 using the driver's color palette before the native write code runs.
A driver uses the helper at four points:
Typical integration:
When CONFIG_DISPLAY_COLOR_DITHER is disabled, the backing-storage macro is empty, display_color_dither_set_input_format() accepts only native PIXEL_FORMAT_I_4, and the other inline helpers leave driver behavior unchanged.
| #define DISPLAY_COLOR_DITHER_DEFINE | ( | inst | ) |
#include <zephyr/drivers/display/color_dither.h>
Define color dithering backing storage for one display driver instance.
Use once for each driver instance that can use the helper. This allocates the conversion buffer and optional error-diffusion rows. Buffer dimensions come from the instance's width and height devicetree properties.
CONFIG_DISPLAY_COLOR_DITHER.| inst | DT instance index. |
| #define DISPLAY_COLOR_DITHER_INIT | ( | inst | ) |
#include <zephyr/drivers/display/color_dither.h>
Initialize a driver's display_color_dither_state member for one display driver instance.
Use in the driver data initializer after DISPLAY_COLOR_DITHER_DEFINE has defined the backing storage for the same instance. When CONFIG_DISPLAY_COLOR_DITHER is disabled this expands to an empty initializer (the state member is then zero-sized), so it can be used unconditionally.
| inst | DT instance index. |
| bool display_color_dither_is_active | ( | const struct display_color_dither_state * | state, |
| enum display_pixel_format | current_pixel_format ) |
#include <zephyr/drivers/display/color_dither.h>
Report whether the helper is actively converting input to native I_4.
CONFIG_DISPLAY_COLOR_DITHER.| state | Color dithering state embedded in the driver data. |
| current_pixel_format | Pixel format the driver currently reports to callers. |
| true | The helper is converting current_pixel_format down to PIXEL_FORMAT_I_4. |
| false | The native I_4 write path is in effect (no helper conversion). |
| void display_color_dither_patch_caps | ( | struct display_color_dither_state * | state, |
| struct display_capabilities * | caps ) |
#include <zephyr/drivers/display/color_dither.h>
Add helper-managed RGB formats to display capabilities.
Call at the end of the driver's display_driver_api.get_capabilities() operation, after the driver has filled its native capabilities and color palette.
This adds the RGB formats enabled by Kconfig to the list of supported pixel formats in display_capabilities::supported_pixel_formats.
When the helper is actively converting, it also reports the helper-managed input format in display_capabilities::current_pixel_format.
CONFIG_DISPLAY_COLOR_DITHER.| state | Color dithering state embedded in the driver data. |
| caps | Capabilities to patch. |
| int display_color_dither_prepare | ( | const struct device * | dev, |
| struct display_color_dither_state * | state, | ||
| const struct display_buffer_descriptor ** | desc, | ||
| const void ** | buf, | ||
| struct display_buffer_descriptor * | scratch ) |
#include <zephyr/drivers/display/color_dither.h>
Prepare a write buffer for a PIXEL_FORMAT_I_4 native path.
Call at the start of the driver's display_driver_api.write() operation.
If state->input_format is an RGB input format, this converts buf to packed PIXEL_FORMAT_I_4 and updates desc and buf to point at the converted data.
If state->input_format is PIXEL_FORMAT_I_4, or when the state has no conversion buffer, the inputs are left unchanged.
CONFIG_DISPLAY_COLOR_DITHER.| dev | Display device. Used to read the driver's color palette. |
| state | Color dithering state embedded in the driver data. |
| desc | Address of the write callback's descriptor pointer. |
| buf | Address of the write callback's buffer pointer. |
| scratch | Scratch descriptor storage owned by the caller. |
| 0 | The write can continue. |
| -EINVAL | The input descriptor is invalid for the selected format. |
| -ENOMEM | The conversion buffer is too small. |
| -ENOTSUP | The selected format or palette cannot be converted. |
| int display_color_dither_set_input_format | ( | struct display_color_dither_state * | state, |
| enum display_pixel_format | pf ) |
#include <zephyr/drivers/display/color_dither.h>
Select the helper input pixel format.
Call from the driver's display_driver_api.set_pixel_format() operation.
A pf value of PIXEL_FORMAT_I_4 selects the driver's native I_4 write path without helper conversion.
A pf value of a configured RGB format instructs the helper to convert the input to packed PIXEL_FORMAT_I_4 before the driver's native write path runs.
CONFIG_DISPLAY_COLOR_DITHER.| state | Color dithering state embedded in the driver data. |
| pf | Pixel format requested by the caller. |
| 0 | Success, including native PIXEL_FORMAT_I_4 without helper conversion. |
| -ENOTSUP | The helper is disabled, state has no conversion buffer, or pf is unsupported for RGB-to-I_4 conversion. |