Skip to content

RFC: Change/deprecation in display API #17508

@pabigot

Description

@pabigot

I propose that the display API functions named display_blanking_{on,off} be deprecated and replaced with these functions and clarified semantics:

/**
 * @brief Turn the display off.
 *
 * This function turns off the display.  The expected result for
 * e-paper displays is that the displayed content is unchanged.  The
 * expected result for other displays is that the display will appear
 * blank.
 *
 * Drivers that control backlighting should turn it off.
 *
 * Drivers that support power control may power down the display.
 *
 * Display content in frame buffers held by the driver or device may
 * be lost as a result of this operation, whether or not the content
 * remains displayed.
 *
 * Use display_on() prior to any further interaction with the display
 * device.  Attempts to update the display while it is off produce
 * undefined behavior.
 *
 * @return a non-negative value on success, or a negative error code.
 */
static inline int display_off(const struct device *dev);

/**
 * @brief Turn the display on.
 *
 * This function turns on the display.
 *
 * If display content is not preserved by display_off() the driver
 * should ensure that the display is set to consistent content
 * (cleared to black, a distinct "no data" pattern, etc.) when this
 * operation completes.
 *
 * If backlighting is controlled by the display driver, backlighting
 * should be turned on consistent with the last backlighting
 * configuration.  (Not all displays may support backlighting; not all
 * displays that support it may allow control of it.)
 *
 * On successful return from this function the application may use
 * display_write() to provide new content.
 *
 * @return a non-negative value on success, or a negative error code.
 */
static inline int display_on(const struct device *dev);

There are several motivations for this, the primary one being that the existing names are counter-intuitive:

  • display_blanking_on() is implemented in three drivers as turning the display off (ili9340, sdl, ssd1306). In one it is implemented to turn the display on (ssd16xx).
  • display_blanking_off() is implemented in three drivers as turning the display on. In one it is implemented to turn the display off.
  • Three drivers don't support the operation, perhaps because it was unclear what the functions were supposed to do (dummy, framebuf, mcux_elcdif).

A second is that some displays, particularly e-paper ones, should be powered down when not in use. The existing API does not address how that could be accomplished. Porting the whole power management API to display drivers is a bigger step that IMO is not yet justified, so the proposed documentation ties power control to display state.

The existing drivers are inconsistent whether the display is turned on or off by driver initialization. I am ambivalent on the desired behavior, but feel strongly that it must be specified. I'm leaning toward display is on (i.e. applications that care should turn it off or write to it ASAP), because that is the most convenient approach for e-paper displays and should be consistent with existing drivers except perhaps sdl which turns it off (sorta). Preferences?

Please provide design feedback here. Based on that I will prepare a PR that updates the API to go along with the IL03xx e-paper driver I'm working on now.

Metadata

Metadata

Labels

RFCRequest For Comments: want input from the communityarea: APIChanges to public APIsarea: Display

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions