Linux-libre 5.3.12-gnu
[librecmc/linux-libre.git] / include / drm / tinydrm / tinydrm-helpers.h
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * Copyright (C) 2016 Noralf Trønnes
4  */
5
6 #ifndef __LINUX_TINYDRM_HELPERS_H
7 #define __LINUX_TINYDRM_HELPERS_H
8
9 struct backlight_device;
10 struct drm_device;
11 struct drm_display_mode;
12 struct drm_framebuffer;
13 struct drm_rect;
14 struct drm_simple_display_pipe;
15 struct drm_simple_display_pipe_funcs;
16 struct spi_transfer;
17 struct spi_message;
18 struct spi_device;
19 struct device;
20
21 /**
22  * tinydrm_machine_little_endian - Machine is little endian
23  *
24  * Returns:
25  * true if *defined(__LITTLE_ENDIAN)*, false otherwise
26  */
27 static inline bool tinydrm_machine_little_endian(void)
28 {
29 #if defined(__LITTLE_ENDIAN)
30         return true;
31 #else
32         return false;
33 #endif
34 }
35
36 int tinydrm_display_pipe_init(struct drm_device *drm,
37                               struct drm_simple_display_pipe *pipe,
38                               const struct drm_simple_display_pipe_funcs *funcs,
39                               int connector_type,
40                               const uint32_t *formats,
41                               unsigned int format_count,
42                               const struct drm_display_mode *mode,
43                               unsigned int rotation);
44
45 size_t tinydrm_spi_max_transfer_size(struct spi_device *spi, size_t max_len);
46 bool tinydrm_spi_bpw_supported(struct spi_device *spi, u8 bpw);
47 int tinydrm_spi_transfer(struct spi_device *spi, u32 speed_hz,
48                          struct spi_transfer *header, u8 bpw, const void *buf,
49                          size_t len);
50 void _tinydrm_dbg_spi_message(struct spi_device *spi, struct spi_message *m);
51
52 #ifdef DEBUG
53 /**
54  * tinydrm_dbg_spi_message - Dump SPI message
55  * @spi: SPI device
56  * @m: SPI message
57  *
58  * Dumps info about the transfers in a SPI message including buffer content.
59  * DEBUG has to be defined for this function to be enabled alongside setting
60  * the DRM_UT_DRIVER bit of &drm_debug.
61  */
62 static inline void tinydrm_dbg_spi_message(struct spi_device *spi,
63                                            struct spi_message *m)
64 {
65         if (drm_debug & DRM_UT_DRIVER)
66                 _tinydrm_dbg_spi_message(spi, m);
67 }
68 #else
69 static inline void tinydrm_dbg_spi_message(struct spi_device *spi,
70                                            struct spi_message *m)
71 {
72 }
73 #endif /* DEBUG */
74
75 #endif /* __LINUX_TINYDRM_HELPERS_H */