Zephyr API Documentation 4.0.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 <jan.van_winkel@dxplore.eu>
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
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
93
103
119
133
139typedef int (*display_blanking_on_api)(const struct device *dev);
140
146typedef int (*display_blanking_off_api)(const struct device *dev);
147
153typedef int (*display_write_api)(const struct device *dev, const uint16_t x,
154 const uint16_t y,
155 const struct display_buffer_descriptor *desc,
156 const void *buf);
157
163typedef int (*display_read_api)(const struct device *dev, const uint16_t x,
164 const uint16_t y,
165 const struct display_buffer_descriptor *desc,
166 void *buf);
167
173typedef void *(*display_get_framebuffer_api)(const struct device *dev);
174
180typedef int (*display_set_brightness_api)(const struct device *dev,
181 const uint8_t brightness);
182
188typedef int (*display_set_contrast_api)(const struct device *dev,
189 const uint8_t contrast);
190
196typedef void (*display_get_capabilities_api)(const struct device *dev,
197 struct display_capabilities *
198 capabilities);
199
205typedef int (*display_set_pixel_format_api)(const struct device *dev,
206 const enum display_pixel_format
207 pixel_format);
208
214typedef int (*display_set_orientation_api)(const struct device *dev,
215 const enum display_orientation
216 orientation);
217
234
246static inline int display_write(const struct device *dev, const uint16_t x,
247 const uint16_t y,
248 const struct display_buffer_descriptor *desc,
249 const void *buf)
250{
251 struct display_driver_api *api =
252 (struct display_driver_api *)dev->api;
253
254 return api->write(dev, x, y, desc, buf);
255}
256
269static inline int display_read(const struct device *dev, const uint16_t x,
270 const uint16_t y,
271 const struct display_buffer_descriptor *desc,
272 void *buf)
273{
274 struct display_driver_api *api =
275 (struct display_driver_api *)dev->api;
276
277 if (api->read == NULL) {
278 return -ENOSYS;
279 }
280
281 return api->read(dev, x, y, desc, buf);
282}
283
293static inline void *display_get_framebuffer(const struct device *dev)
294{
295 struct display_driver_api *api =
296 (struct display_driver_api *)dev->api;
297
298 if (api->get_framebuffer == NULL) {
299 return NULL;
300 }
301
302 return api->get_framebuffer(dev);
303}
304
324static inline int display_blanking_on(const struct device *dev)
325{
326 struct display_driver_api *api =
327 (struct display_driver_api *)dev->api;
328
329 if (api->blanking_on == NULL) {
330 return -ENOSYS;
331 }
332
333 return api->blanking_on(dev);
334}
335
348static inline int display_blanking_off(const struct device *dev)
349{
350 struct display_driver_api *api =
351 (struct display_driver_api *)dev->api;
352
353 if (api->blanking_off == NULL) {
354 return -ENOSYS;
355 }
356
357 return api->blanking_off(dev);
358}
359
372static inline int display_set_brightness(const struct device *dev,
373 uint8_t brightness)
374{
375 struct display_driver_api *api =
376 (struct display_driver_api *)dev->api;
377
378 if (api->set_brightness == NULL) {
379 return -ENOSYS;
380 }
381
382 return api->set_brightness(dev, brightness);
383}
384
397static inline int display_set_contrast(const struct device *dev, uint8_t contrast)
398{
399 struct display_driver_api *api =
400 (struct display_driver_api *)dev->api;
401
402 if (api->set_contrast == NULL) {
403 return -ENOSYS;
404 }
405
406 return api->set_contrast(dev, contrast);
407}
408
415static inline void display_get_capabilities(const struct device *dev,
416 struct display_capabilities *
417 capabilities)
418{
419 struct display_driver_api *api =
420 (struct display_driver_api *)dev->api;
421
422 api->get_capabilities(dev, capabilities);
423}
424
434static inline int
436 const enum display_pixel_format pixel_format)
437{
438 struct display_driver_api *api =
439 (struct display_driver_api *)dev->api;
440
441 if (api->set_pixel_format == NULL) {
442 return -ENOSYS;
443 }
444
445 return api->set_pixel_format(dev, pixel_format);
446}
447
457static inline int display_set_orientation(const struct device *dev,
458 const enum display_orientation
459 orientation)
460{
461 struct display_driver_api *api =
462 (struct display_driver_api *)dev->api;
463
464 if (api->set_orientation == NULL) {
465 return -ENOSYS;
466 }
467
468 return api->set_orientation(dev, orientation);
469}
470
471#ifdef __cplusplus
472}
473#endif
474
479#endif /* ZEPHYR_INCLUDE_DRIVERS_DISPLAY_H_ */
System error numbers.
display_screen_info
Display screen information.
Definition display.h:69
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:205
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:246
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:269
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:196
static void * display_get_framebuffer(const struct device *dev)
Get pointer to framebuffer for direct access.
Definition display.h:293
static int display_blanking_off(const struct device *dev)
Turn display blanking off.
Definition display.h:348
static int display_set_orientation(const struct device *dev, const enum display_orientation orientation)
Set display orientation.
Definition display.h:457
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:153
static void display_get_capabilities(const struct device *dev, struct display_capabilities *capabilities)
Get display capabilities.
Definition display.h:415
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:180
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:173
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:435
static int display_set_contrast(const struct device *dev, uint8_t contrast)
Set the contrast of the display.
Definition display.h:397
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:163
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:146
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:324
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:139
static int display_set_brightness(const struct device *dev, uint8_t brightness)
Set the brightness of the display.
Definition display.h:372
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:188
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:214
@ 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:82
__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:411
const void * api
Address of the API structure exposed by the device instance.
Definition device.h:417
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
bool frame_incomplete
Indicates that this is not the last write buffer of the frame.
Definition display.h:131
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:222
display_blanking_off_api blanking_off
Definition display.h:224
display_set_pixel_format_api set_pixel_format
Definition display.h:231
display_read_api read
Definition display.h:226
display_set_orientation_api set_orientation
Definition display.h:232
display_write_api write
Definition display.h:225
display_set_brightness_api set_brightness
Definition display.h:228
display_get_framebuffer_api get_framebuffer
Definition display.h:227
display_blanking_on_api blanking_on
Definition display.h:223
display_get_capabilities_api get_capabilities
Definition display.h:230
display_set_contrast_api set_contrast
Definition display.h:229