Zephyr API Documentation  3.6.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
display.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2017 Jan Van Winkel <[email protected]>
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
12#ifndef ZEPHYR_INCLUDE_DRIVERS_DISPLAY_H_
13#define ZEPHYR_INCLUDE_DRIVERS_DISPLAY_H_
14
24#include <zephyr/device.h>
25#include <errno.h>
26#include <stddef.h>
27#include <zephyr/types.h>
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
49};
50
58#define DISPLAY_BITS_PER_PIXEL(fmt) \
59 ((((fmt & PIXEL_FORMAT_RGB_888) >> 0) * 24U) + \
60 (((fmt & PIXEL_FORMAT_MONO01) >> 1) * 1U) + \
61 (((fmt & PIXEL_FORMAT_MONO10) >> 2) * 1U) + \
62 (((fmt & PIXEL_FORMAT_ARGB_8888) >> 3) * 32U) + \
63 (((fmt & PIXEL_FORMAT_RGB_565) >> 4) * 16U) + \
64 (((fmt & PIXEL_FORMAT_BGR_565) >> 5) * 16U))
65
92};
93
102};
103
118};
119
130};
131
137typedef int (*display_blanking_on_api)(const struct device *dev);
138
144typedef int (*display_blanking_off_api)(const struct device *dev);
145
151typedef int (*display_write_api)(const struct device *dev, const uint16_t x,
152 const uint16_t y,
153 const struct display_buffer_descriptor *desc,
154 const void *buf);
155
161typedef int (*display_read_api)(const struct device *dev, const uint16_t x,
162 const uint16_t y,
163 const struct display_buffer_descriptor *desc,
164 void *buf);
165
171typedef void *(*display_get_framebuffer_api)(const struct device *dev);
172
178typedef int (*display_set_brightness_api)(const struct device *dev,
179 const uint8_t brightness);
180
186typedef int (*display_set_contrast_api)(const struct device *dev,
187 const uint8_t contrast);
188
194typedef void (*display_get_capabilities_api)(const struct device *dev,
195 struct display_capabilities *
196 capabilities);
197
203typedef int (*display_set_pixel_format_api)(const struct device *dev,
204 const enum display_pixel_format
205 pixel_format);
206
212typedef int (*display_set_orientation_api)(const struct device *dev,
213 const enum display_orientation
214 orientation);
215
220__subsystem struct display_driver_api {
231};
232
244static inline int display_write(const struct device *dev, const uint16_t x,
245 const uint16_t y,
246 const struct display_buffer_descriptor *desc,
247 const void *buf)
248{
249 struct display_driver_api *api =
250 (struct display_driver_api *)dev->api;
251
252 return api->write(dev, x, y, desc, buf);
253}
254
267static inline int display_read(const struct device *dev, const uint16_t x,
268 const uint16_t y,
269 const struct display_buffer_descriptor *desc,
270 void *buf)
271{
272 struct display_driver_api *api =
273 (struct display_driver_api *)dev->api;
274
275 if (api->read == NULL) {
276 return -ENOSYS;
277 }
278
279 return api->read(dev, x, y, desc, buf);
280}
281
291static inline void *display_get_framebuffer(const struct device *dev)
292{
293 struct display_driver_api *api =
294 (struct display_driver_api *)dev->api;
295
296 if (api->get_framebuffer == NULL) {
297 return NULL;
298 }
299
300 return api->get_framebuffer(dev);
301}
302
322static inline int display_blanking_on(const struct device *dev)
323{
324 struct display_driver_api *api =
325 (struct display_driver_api *)dev->api;
326
327 if (api->blanking_on == NULL) {
328 return -ENOSYS;
329 }
330
331 return api->blanking_on(dev);
332}
333
346static inline int display_blanking_off(const struct device *dev)
347{
348 struct display_driver_api *api =
349 (struct display_driver_api *)dev->api;
350
351 if (api->blanking_off == NULL) {
352 return -ENOSYS;
353 }
354
355 return api->blanking_off(dev);
356}
357
370static inline int display_set_brightness(const struct device *dev,
371 uint8_t brightness)
372{
373 struct display_driver_api *api =
374 (struct display_driver_api *)dev->api;
375
376 if (api->set_brightness == NULL) {
377 return -ENOSYS;
378 }
379
380 return api->set_brightness(dev, brightness);
381}
382
395static inline int display_set_contrast(const struct device *dev, uint8_t contrast)
396{
397 struct display_driver_api *api =
398 (struct display_driver_api *)dev->api;
399
400 if (api->set_contrast == NULL) {
401 return -ENOSYS;
402 }
403
404 return api->set_contrast(dev, contrast);
405}
406
413static inline void display_get_capabilities(const struct device *dev,
414 struct display_capabilities *
415 capabilities)
416{
417 struct display_driver_api *api =
418 (struct display_driver_api *)dev->api;
419
420 api->get_capabilities(dev, capabilities);
421}
422
432static inline int
434 const enum display_pixel_format pixel_format)
435{
436 struct display_driver_api *api =
437 (struct display_driver_api *)dev->api;
438
439 if (api->set_pixel_format == NULL) {
440 return -ENOSYS;
441 }
442
443 return api->set_pixel_format(dev, pixel_format);
444}
445
455static inline int display_set_orientation(const struct device *dev,
456 const enum display_orientation
457 orientation)
458{
459 struct display_driver_api *api =
460 (struct display_driver_api *)dev->api;
461
462 if (api->set_orientation == NULL) {
463 return -ENOSYS;
464 }
465
466 return api->set_orientation(dev, orientation);
467}
468
469#ifdef __cplusplus
470}
471#endif
472
477#endif /* ZEPHYR_INCLUDE_DRIVERS_DISPLAY_H_ */
System error numbers.
int(* display_set_pixel_format_api)(const struct device *dev, const enum display_pixel_format pixel_format)
Callback API to set pixel format used by the display See display_set_pixel_format() for argument desc...
Definition: display.h:203
int(* display_blanking_off_api)(const struct device *dev)
Callback API to turn off display blanking See display_blanking_off() for argument description.
Definition: display.h:144
int(* display_set_contrast_api)(const struct device *dev, const uint8_t contrast)
Callback API to set display contrast See display_set_contrast() for argument description.
Definition: display.h:186
display_screen_info
Display screen information.
Definition: display.h:69
int(* display_set_orientation_api)(const struct device *dev, const enum display_orientation orientation)
Callback API to set orientation used by the display See display_set_orientation() for argument descri...
Definition: display.h:212
static int display_write(const struct device *dev, const uint16_t x, const uint16_t y, const struct display_buffer_descriptor *desc, const void *buf)
Write data to display.
Definition: display.h:244
static int display_read(const struct device *dev, const uint16_t x, const uint16_t y, const struct display_buffer_descriptor *desc, void *buf)
Read data from display.
Definition: display.h:267
static void * display_get_framebuffer(const struct device *dev)
Get pointer to framebuffer for direct access.
Definition: display.h:291
static int display_blanking_off(const struct device *dev)
Turn display blanking off.
Definition: display.h:346
static int display_set_orientation(const struct device *dev, const enum display_orientation orientation)
Set display orientation.
Definition: display.h:455
static void display_get_capabilities(const struct device *dev, struct display_capabilities *capabilities)
Get display capabilities.
Definition: display.h:413
static int display_set_pixel_format(const struct device *dev, const enum display_pixel_format pixel_format)
Set pixel format used by the display.
Definition: display.h:433
static int display_set_contrast(const struct device *dev, uint8_t contrast)
Set the contrast of the display.
Definition: display.h:395
int(* display_set_brightness_api)(const struct device *dev, const uint8_t brightness)
Callback API to set display brightness See display_set_brightness() for argument description.
Definition: display.h:178
int(* display_read_api)(const struct device *dev, const uint16_t x, const uint16_t y, const struct display_buffer_descriptor *desc, void *buf)
Callback API for reading data from the display See display_read() for argument description.
Definition: display.h:161
display_pixel_format
Display pixel formats.
Definition: display.h:42
display_orientation
Enumeration with possible display orientation.
Definition: display.h:97
static int display_blanking_on(const struct device *dev)
Turn display blanking on.
Definition: display.h:322
int(* display_blanking_on_api)(const struct device *dev)
Callback API to turn on display blanking See display_blanking_on() for argument description.
Definition: display.h:137
static int display_set_brightness(const struct device *dev, uint8_t brightness)
Set the brightness of the display.
Definition: display.h:370
void *(* display_get_framebuffer_api)(const struct device *dev)
Callback API to get framebuffer pointer See display_get_framebuffer() for argument description.
Definition: display.h:171
int(* display_write_api)(const struct device *dev, const uint16_t x, const uint16_t y, const struct display_buffer_descriptor *desc, const void *buf)
Callback API for writing data to the display See display_write() for argument description.
Definition: display.h:151
void(* display_get_capabilities_api)(const struct device *dev, struct display_capabilities *capabilities)
Callback API to get display capabilities See display_get_capabilities() for argument description.
Definition: display.h:194
@ SCREEN_INFO_X_ALIGNMENT_WIDTH
Screen has x alignment constrained to width.
Definition: display.h:91
@ SCREEN_INFO_EPD
Electrophoretic Display.
Definition: display.h:83
@ SCREEN_INFO_DOUBLE_BUFFER
Screen has two alternating ram buffers.
Definition: display.h:87
@ SCREEN_INFO_MONO_VTILED
If selected, one octet represents 8 pixels ordered vertically, otherwise ordered horizontally.
Definition: display.h:74
@ SCREEN_INFO_MONO_MSB_FIRST
If selected, the MSB represents the first pixel, otherwise MSB represents the last pixel.
Definition: display.h:79
@ PIXEL_FORMAT_MONO10
Monochrome (1=Black 0=White)
Definition: display.h:45
@ PIXEL_FORMAT_ARGB_8888
32-bit ARGB
Definition: display.h:46
@ PIXEL_FORMAT_MONO01
Monochrome (0=Black 1=White)
Definition: display.h:44
@ PIXEL_FORMAT_RGB_565
16-bit RGB
Definition: display.h:47
@ PIXEL_FORMAT_RGB_888
24-bit RGB
Definition: display.h:43
@ PIXEL_FORMAT_BGR_565
16-bit BGR
Definition: display.h:48
@ DISPLAY_ORIENTATION_ROTATED_90
Rotated 90 degrees clockwise.
Definition: display.h:99
@ DISPLAY_ORIENTATION_ROTATED_180
Rotated 180 degrees clockwise.
Definition: display.h:100
@ DISPLAY_ORIENTATION_NORMAL
No rotation.
Definition: display.h:98
@ DISPLAY_ORIENTATION_ROTATED_270
Rotated 270 degrees clockwise.
Definition: display.h:101
#define BIT(n)
Unsigned integer with bit position n set (signed in assembly language).
Definition: util_macro.h:44
#define ENOSYS
Function not implemented.
Definition: errno.h:83
__UINT32_TYPE__ uint32_t
Definition: stdint.h:90
__UINT8_TYPE__ uint8_t
Definition: stdint.h:88
__UINT16_TYPE__ uint16_t
Definition: stdint.h:89
Runtime device structure (in ROM) per driver instance.
Definition: device.h:399
const void * api
Address of the API structure exposed by the device instance.
Definition: device.h:405
Structure to describe display data buffer layout.
Definition: display.h:121
uint16_t pitch
Number of pixels between consecutive rows in the data buffer.
Definition: display.h:129
uint16_t height
Data buffer column height in pixels.
Definition: display.h:127
uint16_t width
Data buffer row width in pixels.
Definition: display.h:125
uint32_t buf_size
Data buffer size in bytes.
Definition: display.h:123
Structure holding display capabilities.
Definition: display.h:105
uint32_t supported_pixel_formats
Bitwise or of pixel formats supported by the display.
Definition: display.h:111
uint16_t x_resolution
Display resolution in the X direction.
Definition: display.h:107
enum display_orientation current_orientation
Current display orientation.
Definition: display.h:117
uint16_t y_resolution
Display resolution in the Y direction.
Definition: display.h:109
uint32_t screen_info
Information about display panel.
Definition: display.h:113
enum display_pixel_format current_pixel_format
Currently active pixel format for the display.
Definition: display.h:115
Display driver API API which a display driver should expose.
Definition: display.h:220
display_blanking_off_api blanking_off
Definition: display.h:222
display_set_pixel_format_api set_pixel_format
Definition: display.h:229
display_read_api read
Definition: display.h:224
display_set_orientation_api set_orientation
Definition: display.h:230
display_write_api write
Definition: display.h:223
display_set_brightness_api set_brightness
Definition: display.h:226
display_get_framebuffer_api get_framebuffer
Definition: display.h:225
display_blanking_on_api blanking_on
Definition: display.h:221
display_get_capabilities_api get_capabilities
Definition: display.h:228
display_set_contrast_api set_contrast
Definition: display.h:227