Skip to content

Commit

Permalink
display: add display_finalize_frame
Browse files Browse the repository at this point in the history
Introduces support for double-buffered/latched displays.
Currently, every write has to be presented to the user immediately,
which negates the advantage of latched displays to negate frame tearing.

Signed-off-by: Martin Stumpf <martin.stumpf@vected.de>
  • Loading branch information
mstumpf-vected committed Oct 17, 2024
1 parent 8c705ca commit 1e6150d
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions include/zephyr/drivers/display.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,13 @@ typedef int (*display_read_api)(const struct device *dev, const uint16_t x,
const struct display_buffer_descriptor *desc,
void *buf);

/**
* @typedef display_flush_api
* @brief Callback API to indicate that all previous writes should be flushed to the display
* See display_flush() for argument description
*/
typedef int (*display_flush_api)(const struct device *dev);

/**
* @typedef display_get_framebuffer_api
* @brief Callback API to get framebuffer pointer
Expand Down Expand Up @@ -222,6 +229,7 @@ __subsystem struct display_driver_api {
display_blanking_off_api blanking_off;
display_write_api write;
display_read_api read;
display_flush_api flush;
display_get_framebuffer_api get_framebuffer;
display_set_brightness_api set_brightness;
display_set_contrast_api set_contrast;
Expand Down Expand Up @@ -279,6 +287,27 @@ static inline int display_read(const struct device *dev, const uint16_t x,
return api->read(dev, x, y, desc, buf);
}

/**
* @brief Indicates that all previous writes should be flushed to the display
*
* Can be used to present all previous writes simultaneously, for
* double buffered or latched displays.
*
* @param dev Pointer to device structure
*
* @retval 0 on success else negative errno code.
*/
static inline int display_flush(const struct device *dev)
{
struct display_driver_api *api = (struct display_driver_api *)dev->api;

if (api->flush == NULL) {
return -ENOSYS;
}

return api->flush(dev);
}

/**
* @brief Get pointer to framebuffer for direct access
*
Expand Down

0 comments on commit 1e6150d

Please sign in to comment.