Line data Source code
1 1 : /*
2 : * Copyright (c) 2022-2023 Jamie McCrae
3 : *
4 : * SPDX-License-Identifier: Apache-2.0
5 : */
6 :
7 : /**
8 : * @file
9 : * @ingroup auxdisplay_interface
10 : * @brief Main header file for auxiliary (textual/non-graphical) display driver API.
11 : */
12 :
13 : #ifndef ZEPHYR_INCLUDE_DRIVERS_AUXDISPLAY_H_
14 : #define ZEPHYR_INCLUDE_DRIVERS_AUXDISPLAY_H_
15 :
16 : /**
17 : * @brief Interfaces for auxiliary (textual/non-graphical) displays.
18 : * @defgroup auxdisplay_interface Auxiliary (Text) Display
19 : * @since 3.4
20 : * @version 0.1.0
21 : * @ingroup io_interfaces
22 : * @{
23 : */
24 :
25 : #include <stdint.h>
26 : #include <stddef.h>
27 : #include <zephyr/kernel.h>
28 : #include <zephyr/device.h>
29 :
30 : #ifdef __cplusplus
31 : extern "C" {
32 : #endif
33 :
34 : /** @brief Used for minimum and maximum brightness/backlight values if not supported */
35 1 : #define AUXDISPLAY_LIGHT_NOT_SUPPORTED 0
36 :
37 : /** @brief Used to describe the mode of an auxiliary (text) display */
38 1 : typedef uint32_t auxdisplay_mode_t;
39 :
40 : /** @brief Used for moving the cursor or display position */
41 0 : enum auxdisplay_position {
42 : /** Moves to specified X,Y position */
43 : AUXDISPLAY_POSITION_ABSOLUTE = 0,
44 :
45 : /** Shifts current position by +/- X,Y position, does not take display direction into
46 : * consideration
47 : */
48 : AUXDISPLAY_POSITION_RELATIVE,
49 :
50 : /** Shifts current position by +/- X,Y position, takes display direction into
51 : * consideration
52 : */
53 : AUXDISPLAY_POSITION_RELATIVE_DIRECTION,
54 :
55 : AUXDISPLAY_POSITION_COUNT,
56 : };
57 :
58 : /** @brief Used for setting character append position */
59 0 : enum auxdisplay_direction {
60 : /** Each character will be placed to the right of existing characters */
61 : AUXDISPLAY_DIRECTION_RIGHT = 0,
62 :
63 : /** Each character will be placed to the left of existing characters */
64 : AUXDISPLAY_DIRECTION_LEFT,
65 :
66 : AUXDISPLAY_DIRECTION_COUNT,
67 : };
68 :
69 : /** @brief Light levels for brightness and/or backlight. If not supported by a
70 : * display/driver, both minimum and maximum will be AUXDISPLAY_LIGHT_NOT_SUPPORTED.
71 : */
72 1 : struct auxdisplay_light {
73 : /** Minimum light level supported */
74 1 : uint8_t minimum;
75 :
76 : /** Maximum light level supported */
77 1 : uint8_t maximum;
78 : };
79 :
80 : /** @brief Structure holding display capabilities. */
81 1 : struct auxdisplay_capabilities {
82 : /** Number of character columns */
83 1 : uint16_t columns;
84 :
85 : /** Number of character rows */
86 1 : uint16_t rows;
87 :
88 : /** Display-specific data (e.g. 4-bit or 8-bit mode for HD44780-based displays) */
89 1 : auxdisplay_mode_t mode;
90 :
91 : /** Brightness details for display (if supported) */
92 1 : struct auxdisplay_light brightness;
93 :
94 : /** Backlight details for display (if supported) */
95 1 : struct auxdisplay_light backlight;
96 :
97 : /** Number of custom characters supported by display (0 if unsupported) */
98 1 : uint8_t custom_characters;
99 :
100 : /** Width (in pixels) of a custom character, supplied custom characters should match. */
101 1 : uint8_t custom_character_width;
102 :
103 : /** Height (in pixels) of a custom character, supplied custom characters should match. */
104 1 : uint8_t custom_character_height;
105 : };
106 :
107 : /** @brief Structure for a custom command. This may be extended by specific drivers. */
108 1 : struct auxdisplay_custom_data {
109 : /** Raw command data to be sent */
110 1 : uint8_t *data;
111 :
112 : /** Length of supplied data */
113 1 : uint16_t len;
114 :
115 : /** Display-driver specific options for command */
116 1 : uint32_t options;
117 : };
118 :
119 : /** @brief Structure for a custom character. */
120 1 : struct auxdisplay_character {
121 : /** Custom character index on the display */
122 1 : uint8_t index;
123 :
124 : /** Custom character pixel data, a character must be valid for a display consisting
125 : * of a uint8 array of size character width by character height, values should be
126 : * 0x00 for pixel off or 0xff for pixel on, if a display supports shades then values
127 : * between 0x00 and 0xff may be used (display driver dependent).
128 : */
129 1 : uint8_t *data;
130 :
131 : /** Will be updated with custom character index to use in the display write function to
132 : * disaplay this custom character
133 : */
134 1 : uint8_t character_code;
135 : };
136 :
137 : /**
138 : * @cond INTERNAL_HIDDEN
139 : *
140 : * For internal use only, skip these in public documentation.
141 : */
142 :
143 : /**
144 : * @typedef auxdisplay_display_on_t
145 : * @brief Callback API to turn display on
146 : * See auxdisplay_display_on() for argument description
147 : */
148 : typedef int (*auxdisplay_display_on_t)(const struct device *dev);
149 :
150 : /**
151 : * @typedef auxdisplay_display_off_t
152 : * @brief Callback API to turn display off
153 : * See auxdisplay_display_off() for argument description
154 : */
155 : typedef int (*auxdisplay_display_off_t)(const struct device *dev);
156 :
157 : /**
158 : * @typedef auxdisplay_cursor_set_enabled_t
159 : * @brief Callback API to turn display cursor visibility on or off
160 : * See auxdisplay_cursor_set_enabled() for argument description
161 : */
162 : typedef int (*auxdisplay_cursor_set_enabled_t)(const struct device *dev, bool enabled);
163 :
164 : /**
165 : * @typedef auxdisplay_position_blinking_set_enabled_t
166 : * @brief Callback API to turn the current position blinking on or off
167 : * See auxdisplay_position_blinking_set_enabled() for argument description
168 : */
169 : typedef int (*auxdisplay_position_blinking_set_enabled_t)(const struct device *dev,
170 : bool enabled);
171 :
172 : /**
173 : * @typedef auxdisplay_cursor_shift_set_t
174 : * @brief Callback API to set how the cursor shifts after a character is written
175 : * See auxdisplay_cursor_shift_set() for argument description
176 : */
177 : typedef int (*auxdisplay_cursor_shift_set_t)(const struct device *dev, uint8_t direction,
178 : bool display_shift);
179 :
180 : /**
181 : * @typedef auxdisplay_cursor_position_set_t
182 : * @brief Callback API to set the cursor position
183 : * See auxdisplay_cursor_position_set() for argument description
184 : */
185 : typedef int (*auxdisplay_cursor_position_set_t)(const struct device *dev,
186 : enum auxdisplay_position type,
187 : int16_t x, int16_t y);
188 :
189 : /**
190 : * @typedef auxdisplay_cursor_position_get_t
191 : * @brief Callback API to get the cursor position
192 : * See auxdisplay_cursor_position_get() for argument description
193 : */
194 : typedef int (*auxdisplay_cursor_position_get_t)(const struct device *dev, int16_t *x,
195 : int16_t *y);
196 :
197 : /**
198 : * @typedef auxdisplay_display_position_set_t
199 : * @brief Callback API to set the current position of the display
200 : * See auxdisplay_display_position_set() for argument description
201 : */
202 : typedef int (*auxdisplay_display_position_set_t)(const struct device *dev,
203 : enum auxdisplay_position type,
204 : int16_t x, int16_t y);
205 :
206 : /**
207 : * @typedef auxdisplay_display_position_get_t
208 : * @brief Callback API to get the current position of the display
209 : * See auxdisplay_display_position_get() for argument description
210 : */
211 : typedef int (*auxdisplay_display_position_get_t)(const struct device *dev, int16_t *x,
212 : int16_t *y);
213 :
214 : /**
215 : * @typedef auxdisplay_capabilities_get_t
216 : * @brief Callback API to get details on the display
217 : * See auxdisplay_capabilities_get() for argument description
218 : */
219 : typedef int (*auxdisplay_capabilities_get_t)(const struct device *dev,
220 : struct auxdisplay_capabilities *capabilities);
221 :
222 : /**
223 : * @typedef auxdisplay_clear_t
224 : * @brief Callback API to clear the contents of the display
225 : * See auxdisplay_clear() for argument description
226 : */
227 : typedef int (*auxdisplay_clear_t)(const struct device *dev);
228 :
229 : /**
230 : * @typedef auxdisplay_brightness_get_t
231 : * @brief Callback API to get the current and minimum/maximum supported
232 : * brightness settings of the display
233 : * See auxdisplay_brightness_get_api() for argument description
234 : */
235 : typedef int (*auxdisplay_brightness_get_t)(const struct device *dev, uint8_t *brightness);
236 :
237 : /**
238 : * @typedef auxdisplay_brightness_set_t
239 : * @brief Callback API to set the brightness of the display
240 : * See auxdisplay_brightness_set_api() for argument description
241 : */
242 : typedef int (*auxdisplay_brightness_set_t)(const struct device *dev, uint8_t brightness);
243 :
244 : /**
245 : * @typedef auxdisplay_backlight_get_t
246 : * @brief Callback API to get the current and minimum/maximum supported
247 : * backlight settings of the display
248 : * See auxdisplay_backlight_set() for argument description
249 : */
250 : typedef int (*auxdisplay_backlight_get_t)(const struct device *dev, uint8_t *backlight);
251 :
252 : /**
253 : * @typedef auxdisplay_backlight_set_t
254 : * @brief Callback API to set the backlight status
255 : * See auxdisplay_backlight_set() for argument description
256 : */
257 : typedef int (*auxdisplay_backlight_set_t)(const struct device *dev, uint8_t backlight);
258 :
259 : /**
260 : * @typedef auxdisplay_is_busy_t
261 : * @brief Callback API to check if the display is busy with an operation
262 : * See auxdisplay_is_busy() for argument description
263 : */
264 : typedef int (*auxdisplay_is_busy_t)(const struct device *dev);
265 :
266 : /**
267 : * @typedef auxdisplay_custom_character_set_t
268 : * @brief Callback API to set a customer character on the display for usage
269 : * See auxdisplay_custom_character_set() for argument description
270 : */
271 : typedef int (*auxdisplay_custom_character_set_t)(const struct device *dev,
272 : struct auxdisplay_character *character);
273 :
274 : /**
275 : * @typedef auxdisplay_write_t
276 : * @brief Callback API to write text to the display
277 : * See auxdisplay_write() for argument description
278 : */
279 : typedef int (*auxdisplay_write_t)(const struct device *dev, const uint8_t *data, uint16_t len);
280 :
281 : /**
282 : * @typedef auxdisplay_custom_command_t
283 : * @brief Callback API to send a custom command to the display
284 : * See auxdisplay_custom_command() for argument description
285 : */
286 : typedef int (*auxdisplay_custom_command_t)(const struct device *dev,
287 : struct auxdisplay_custom_data *command);
288 :
289 : __subsystem struct auxdisplay_driver_api {
290 : auxdisplay_display_on_t display_on;
291 : auxdisplay_display_off_t display_off;
292 : auxdisplay_cursor_set_enabled_t cursor_set_enabled;
293 : auxdisplay_position_blinking_set_enabled_t position_blinking_set_enabled;
294 : auxdisplay_cursor_shift_set_t cursor_shift_set;
295 : auxdisplay_cursor_position_set_t cursor_position_set;
296 : auxdisplay_cursor_position_get_t cursor_position_get;
297 : auxdisplay_display_position_set_t display_position_set;
298 : auxdisplay_display_position_get_t display_position_get;
299 : auxdisplay_capabilities_get_t capabilities_get;
300 : auxdisplay_clear_t clear;
301 : auxdisplay_brightness_get_t brightness_get;
302 : auxdisplay_brightness_set_t brightness_set;
303 : auxdisplay_backlight_get_t backlight_get;
304 : auxdisplay_backlight_set_t backlight_set;
305 : auxdisplay_is_busy_t is_busy;
306 : auxdisplay_custom_character_set_t custom_character_set;
307 : auxdisplay_write_t write;
308 : auxdisplay_custom_command_t custom_command;
309 : };
310 :
311 : /**
312 : * @endcond
313 : */
314 :
315 : /**
316 : * @brief Turn display on.
317 : *
318 : * @param dev Auxiliary display device instance
319 : *
320 : * @retval 0 on success.
321 : * @retval -ENOSYS if not supported/implemented.
322 : * @retval -errno Negative errno code on other failure.
323 : */
324 1 : __syscall int auxdisplay_display_on(const struct device *dev);
325 :
326 : static inline int z_impl_auxdisplay_display_on(const struct device *dev)
327 : {
328 : struct auxdisplay_driver_api *api = (struct auxdisplay_driver_api *)dev->api;
329 :
330 : if (!api->display_on) {
331 : return -ENOSYS;
332 : }
333 :
334 : return api->display_on(dev);
335 : }
336 :
337 : /**
338 : * @brief Turn display off.
339 : *
340 : * @param dev Auxiliary display device instance
341 : *
342 : * @retval 0 on success.
343 : * @retval -ENOSYS if not supported/implemented.
344 : * @retval -errno Negative errno code on other failure.
345 : */
346 1 : __syscall int auxdisplay_display_off(const struct device *dev);
347 :
348 : static inline int z_impl_auxdisplay_display_off(const struct device *dev)
349 : {
350 : struct auxdisplay_driver_api *api = (struct auxdisplay_driver_api *)dev->api;
351 :
352 : if (!api->display_off) {
353 : return -ENOSYS;
354 : }
355 :
356 : return api->display_off(dev);
357 : }
358 :
359 : /**
360 : * @brief Set cursor enabled status on an auxiliary display
361 : *
362 : * @param dev Auxiliary display device instance
363 : * @param enabled True to enable cursor, false to disable
364 : *
365 : * @retval 0 on success.
366 : * @retval -ENOSYS if not supported/implemented.
367 : * @retval -errno Negative errno code on other failure.
368 : */
369 1 : __syscall int auxdisplay_cursor_set_enabled(const struct device *dev,
370 : bool enabled);
371 :
372 : static inline int z_impl_auxdisplay_cursor_set_enabled(const struct device *dev,
373 : bool enabled)
374 : {
375 : struct auxdisplay_driver_api *api = (struct auxdisplay_driver_api *)dev->api;
376 :
377 : if (!api->cursor_set_enabled) {
378 : return -ENOSYS;
379 : }
380 :
381 : return api->cursor_set_enabled(dev, enabled);
382 : }
383 :
384 : /**
385 : * @brief Set cursor blinking status on an auxiliary display
386 : *
387 : * @param dev Auxiliary display device instance
388 : * @param enabled Set to true to enable blinking position, false to disable
389 : *
390 : * @retval 0 on success.
391 : * @retval -ENOSYS if not supported/implemented.
392 : * @retval -errno Negative errno code on other failure.
393 : */
394 1 : __syscall int auxdisplay_position_blinking_set_enabled(const struct device *dev,
395 : bool enabled);
396 :
397 : static inline int z_impl_auxdisplay_position_blinking_set_enabled(const struct device *dev,
398 : bool enabled)
399 : {
400 : struct auxdisplay_driver_api *api = (struct auxdisplay_driver_api *)dev->api;
401 :
402 : if (!api->position_blinking_set_enabled) {
403 : return -ENOSYS;
404 : }
405 :
406 : return api->position_blinking_set_enabled(dev, enabled);
407 : }
408 :
409 : /**
410 : * @brief Set cursor shift after character write and display shift
411 : *
412 : * @param dev Auxiliary display device instance
413 : * @param direction Sets the direction of the display when characters are written
414 : * @param display_shift If true, will shift the display when characters are written
415 : * (which makes it look like the display is moving, not the cursor)
416 : *
417 : * @retval 0 on success.
418 : * @retval -ENOSYS if not supported/implemented.
419 : * @retval -EINVAL if provided argument is invalid.
420 : * @retval -errno Negative errno code on other failure.
421 : */
422 1 : __syscall int auxdisplay_cursor_shift_set(const struct device *dev,
423 : uint8_t direction, bool display_shift);
424 :
425 : static inline int z_impl_auxdisplay_cursor_shift_set(const struct device *dev,
426 : uint8_t direction,
427 : bool display_shift)
428 : {
429 : struct auxdisplay_driver_api *api = (struct auxdisplay_driver_api *)dev->api;
430 :
431 : if (!api->cursor_shift_set) {
432 : return -ENOSYS;
433 : }
434 :
435 : if (direction >= AUXDISPLAY_DIRECTION_COUNT) {
436 : return -EINVAL;
437 : }
438 :
439 : return api->cursor_shift_set(dev, direction, display_shift);
440 : }
441 :
442 : /**
443 : * @brief Set cursor (and write position) on an auxiliary display
444 : *
445 : * @param dev Auxiliary display device instance
446 : * @param type Type of move, absolute or offset
447 : * @param x Exact or offset X position
448 : * @param y Exact or offset Y position
449 : *
450 : * @retval 0 on success.
451 : * @retval -ENOSYS if not supported/implemented.
452 : * @retval -EINVAL if provided argument is invalid.
453 : * @retval -errno Negative errno code on other failure.
454 : */
455 1 : __syscall int auxdisplay_cursor_position_set(const struct device *dev,
456 : enum auxdisplay_position type,
457 : int16_t x, int16_t y);
458 :
459 : static inline int z_impl_auxdisplay_cursor_position_set(const struct device *dev,
460 : enum auxdisplay_position type,
461 : int16_t x, int16_t y)
462 : {
463 : struct auxdisplay_driver_api *api = (struct auxdisplay_driver_api *)dev->api;
464 :
465 : if (!api->cursor_position_set) {
466 : return -ENOSYS;
467 : } else if (type >= AUXDISPLAY_POSITION_COUNT) {
468 : return -EINVAL;
469 : } else if (type == AUXDISPLAY_POSITION_ABSOLUTE && (x < 0 || y < 0)) {
470 : return -EINVAL;
471 : }
472 :
473 : return api->cursor_position_set(dev, type, x, y);
474 : }
475 :
476 : /**
477 : * @brief Get current cursor on an auxiliary display
478 : *
479 : * @param dev Auxiliary display device instance
480 : * @param x Will be updated with the exact X position
481 : * @param y Will be updated with the exact Y position
482 : *
483 : * @retval 0 on success.
484 : * @retval -ENOSYS if not supported/implemented.
485 : * @retval -EINVAL if provided argument is invalid.
486 : * @retval -errno Negative errno code on other failure.
487 : */
488 1 : __syscall int auxdisplay_cursor_position_get(const struct device *dev,
489 : int16_t *x, int16_t *y);
490 :
491 : static inline int z_impl_auxdisplay_cursor_position_get(const struct device *dev,
492 : int16_t *x, int16_t *y)
493 : {
494 : struct auxdisplay_driver_api *api = (struct auxdisplay_driver_api *)dev->api;
495 :
496 : if (!api->cursor_position_get) {
497 : return -ENOSYS;
498 : }
499 :
500 : return api->cursor_position_get(dev, x, y);
501 : }
502 :
503 : /**
504 : * @brief Set display position on an auxiliary display
505 : *
506 : * @param dev Auxiliary display device instance
507 : * @param type Type of move, absolute or offset
508 : * @param x Exact or offset X position
509 : * @param y Exact or offset Y position
510 : *
511 : * @retval 0 on success.
512 : * @retval -ENOSYS if not supported/implemented.
513 : * @retval -EINVAL if provided argument is invalid.
514 : * @retval -errno Negative errno code on other failure.
515 : */
516 1 : __syscall int auxdisplay_display_position_set(const struct device *dev,
517 : enum auxdisplay_position type,
518 : int16_t x, int16_t y);
519 :
520 : static inline int z_impl_auxdisplay_display_position_set(const struct device *dev,
521 : enum auxdisplay_position type,
522 : int16_t x, int16_t y)
523 : {
524 : struct auxdisplay_driver_api *api = (struct auxdisplay_driver_api *)dev->api;
525 :
526 : if (!api->display_position_set) {
527 : return -ENOSYS;
528 : } else if (type >= AUXDISPLAY_POSITION_COUNT) {
529 : return -EINVAL;
530 : } else if (type == AUXDISPLAY_POSITION_ABSOLUTE && (x < 0 || y < 0)) {
531 : return -EINVAL;
532 : }
533 :
534 : return api->display_position_set(dev, type, x, y);
535 : }
536 :
537 : /**
538 : * @brief Get current display position on an auxiliary display
539 : *
540 : * @param dev Auxiliary display device instance
541 : * @param x Will be updated with the exact X position
542 : * @param y Will be updated with the exact Y position
543 : *
544 : * @retval 0 on success.
545 : * @retval -ENOSYS if not supported/implemented.
546 : * @retval -EINVAL if provided argument is invalid.
547 : * @retval -errno Negative errno code on other failure.
548 : */
549 1 : __syscall int auxdisplay_display_position_get(const struct device *dev,
550 : int16_t *x, int16_t *y);
551 :
552 : static inline int z_impl_auxdisplay_display_position_get(const struct device *dev,
553 : int16_t *x, int16_t *y)
554 : {
555 : struct auxdisplay_driver_api *api = (struct auxdisplay_driver_api *)dev->api;
556 :
557 : if (!api->display_position_get) {
558 : return -ENOSYS;
559 : }
560 :
561 : return api->display_position_get(dev, x, y);
562 : }
563 :
564 : /**
565 : * @brief Fetch capabilities (and details) of auxiliary display
566 : *
567 : * @param dev Auxiliary display device instance
568 : * @param capabilities Will be updated with the details of the auxiliary display
569 : *
570 : * @retval 0 on success.
571 : * @retval -errno Negative errno code on other failure.
572 : */
573 1 : __syscall int auxdisplay_capabilities_get(const struct device *dev,
574 : struct auxdisplay_capabilities *capabilities);
575 :
576 : static inline int z_impl_auxdisplay_capabilities_get(const struct device *dev,
577 : struct auxdisplay_capabilities *capabilities)
578 : {
579 : struct auxdisplay_driver_api *api = (struct auxdisplay_driver_api *)dev->api;
580 :
581 : return api->capabilities_get(dev, capabilities);
582 : }
583 :
584 : /**
585 : * @brief Clear display of auxiliary display and return to home position (note that
586 : * this does not reset the display configuration, e.g. custom characters and
587 : * display mode will persist).
588 : *
589 : * @param dev Auxiliary display device instance
590 : *
591 : * @retval 0 on success.
592 : * @retval -errno Negative errno code on other failure.
593 : */
594 1 : __syscall int auxdisplay_clear(const struct device *dev);
595 :
596 : static inline int z_impl_auxdisplay_clear(const struct device *dev)
597 : {
598 : struct auxdisplay_driver_api *api = (struct auxdisplay_driver_api *)dev->api;
599 :
600 : return api->clear(dev);
601 : }
602 :
603 : /**
604 : * @brief Get the current brightness level of an auxiliary display
605 : *
606 : * @param dev Auxiliary display device instance
607 : * @param brightness Will be updated with the current brightness
608 : *
609 : * @retval 0 on success.
610 : * @retval -ENOSYS if not supported/implemented.
611 : * @retval -errno Negative errno code on other failure.
612 : */
613 1 : __syscall int auxdisplay_brightness_get(const struct device *dev,
614 : uint8_t *brightness);
615 :
616 : static inline int z_impl_auxdisplay_brightness_get(const struct device *dev,
617 : uint8_t *brightness)
618 : {
619 : struct auxdisplay_driver_api *api = (struct auxdisplay_driver_api *)dev->api;
620 :
621 : if (!api->brightness_get) {
622 : return -ENOSYS;
623 : }
624 :
625 : return api->brightness_get(dev, brightness);
626 : }
627 :
628 : /**
629 : * @brief Update the brightness level of an auxiliary display
630 : *
631 : * @param dev Auxiliary display device instance
632 : * @param brightness The brightness level to set
633 : *
634 : * @retval 0 on success.
635 : * @retval -ENOSYS if not supported/implemented.
636 : * @retval -EINVAL if provided argument is invalid.
637 : * @retval -errno Negative errno code on other failure.
638 : */
639 1 : __syscall int auxdisplay_brightness_set(const struct device *dev,
640 : uint8_t brightness);
641 :
642 : static inline int z_impl_auxdisplay_brightness_set(const struct device *dev,
643 : uint8_t brightness)
644 : {
645 : struct auxdisplay_driver_api *api = (struct auxdisplay_driver_api *)dev->api;
646 :
647 : if (!api->brightness_set) {
648 : return -ENOSYS;
649 : }
650 :
651 : return api->brightness_set(dev, brightness);
652 : }
653 :
654 : /**
655 : * @brief Get the backlight level details of an auxiliary display
656 : *
657 : * @param dev Auxiliary display device instance
658 : * @param backlight Will be updated with the current backlight level
659 : *
660 : * @retval 0 on success.
661 : * @retval -ENOSYS if not supported/implemented.
662 : * @retval -errno Negative errno code on other failure.
663 : */
664 1 : __syscall int auxdisplay_backlight_get(const struct device *dev,
665 : uint8_t *backlight);
666 :
667 : static inline int z_impl_auxdisplay_backlight_get(const struct device *dev,
668 : uint8_t *backlight)
669 : {
670 : struct auxdisplay_driver_api *api = (struct auxdisplay_driver_api *)dev->api;
671 :
672 : if (!api->backlight_get) {
673 : return -ENOSYS;
674 : }
675 :
676 : return api->backlight_get(dev, backlight);
677 : }
678 :
679 : /**
680 : * @brief Update the backlight level of an auxiliary display
681 : *
682 : * @param dev Auxiliary display device instance
683 : * @param backlight The backlight level to set
684 : *
685 : * @retval 0 on success.
686 : * @retval -ENOSYS if not supported/implemented.
687 : * @retval -EINVAL if provided argument is invalid.
688 : * @retval -errno Negative errno code on other failure.
689 : */
690 1 : __syscall int auxdisplay_backlight_set(const struct device *dev,
691 : uint8_t backlight);
692 :
693 : static inline int z_impl_auxdisplay_backlight_set(const struct device *dev,
694 : uint8_t backlight)
695 : {
696 : struct auxdisplay_driver_api *api = (struct auxdisplay_driver_api *)dev->api;
697 :
698 : if (!api->backlight_set) {
699 : return -ENOSYS;
700 : }
701 :
702 : return api->backlight_set(dev, backlight);
703 : }
704 :
705 : /**
706 : * @brief Check if an auxiliary display driver is busy
707 : *
708 : * @param dev Auxiliary display device instance
709 : *
710 : * @retval 1 on success and display busy.
711 : * @retval 0 on success and display not busy.
712 : * @retval -ENOSYS if not supported/implemented.
713 : * @retval -errno Negative errno code on other failure.
714 : */
715 1 : __syscall int auxdisplay_is_busy(const struct device *dev);
716 :
717 : static inline int z_impl_auxdisplay_is_busy(const struct device *dev)
718 : {
719 : struct auxdisplay_driver_api *api = (struct auxdisplay_driver_api *)dev->api;
720 :
721 : if (!api->is_busy) {
722 : return -ENOSYS;
723 : }
724 :
725 : return api->is_busy(dev);
726 : }
727 :
728 : /**
729 : * @brief Sets a custom character in the display, the custom character struct
730 : * must contain the pixel data for the custom character to add and valid
731 : * custom character index, if successful then the character_code variable
732 : * in the struct will be set to the character code that can be used with
733 : * the auxdisplay_write() function to show it.
734 : *
735 : * A character must be valid for a display consisting of a uint8 array of
736 : * size character width by character height, values should be 0x00 for
737 : * pixel off or 0xff for pixel on, if a display supports shades then
738 : * values between 0x00 and 0xff may be used (display driver dependent).
739 : *
740 : * @param dev Auxiliary display device instance
741 : * @param character Pointer to custom character structure
742 : *
743 : * @retval 0 on success.
744 : * @retval -ENOSYS if not supported/implemented.
745 : * @retval -EINVAL if provided argument is invalid.
746 : * @retval -errno Negative errno code on other failure.
747 : */
748 1 : __syscall int auxdisplay_custom_character_set(const struct device *dev,
749 : struct auxdisplay_character *character);
750 :
751 : static inline int z_impl_auxdisplay_custom_character_set(const struct device *dev,
752 : struct auxdisplay_character *character)
753 : {
754 : struct auxdisplay_driver_api *api = (struct auxdisplay_driver_api *)dev->api;
755 :
756 : if (!api->custom_character_set) {
757 : return -ENOSYS;
758 : }
759 :
760 : return api->custom_character_set(dev, character);
761 : }
762 :
763 : /**
764 : * @brief Write data to auxiliary display screen at current position
765 : *
766 : * @param dev Auxiliary display device instance
767 : * @param data Text data to write
768 : * @param len Length of text data to write
769 : *
770 : * @retval 0 on success.
771 : * @retval -EINVAL if provided argument is invalid.
772 : * @retval -errno Negative errno code on other failure.
773 : */
774 1 : __syscall int auxdisplay_write(const struct device *dev, const uint8_t *data,
775 : uint16_t len);
776 :
777 : static inline int z_impl_auxdisplay_write(const struct device *dev,
778 : const uint8_t *data, uint16_t len)
779 : {
780 : struct auxdisplay_driver_api *api = (struct auxdisplay_driver_api *)dev->api;
781 :
782 : return api->write(dev, data, len);
783 : }
784 :
785 : /**
786 : * @brief Send a custom command to the display (if supported by driver)
787 : *
788 : * @param dev Auxiliary display device instance
789 : * @param data Custom command structure (this may be extended by specific drivers)
790 : *
791 : * @retval 0 on success.
792 : * @retval -ENOSYS if not supported/implemented.
793 : * @retval -EINVAL if provided argument is invalid.
794 : * @retval -errno Negative errno code on other failure.
795 : */
796 1 : __syscall int auxdisplay_custom_command(const struct device *dev,
797 : struct auxdisplay_custom_data *data);
798 :
799 : static inline int z_impl_auxdisplay_custom_command(const struct device *dev,
800 : struct auxdisplay_custom_data *data)
801 : {
802 : struct auxdisplay_driver_api *api = (struct auxdisplay_driver_api *)dev->api;
803 :
804 : if (!api->custom_command) {
805 : return -ENOSYS;
806 : }
807 :
808 : return api->custom_command(dev, data);
809 : }
810 :
811 : #ifdef __cplusplus
812 : }
813 : #endif
814 :
815 : /**
816 : * @}
817 : */
818 :
819 : #include <zephyr/syscalls/auxdisplay.h>
820 :
821 : #endif /* ZEPHYR_INCLUDE_DRIVERS_AUXDISPLAY_H_ */
|