drm/tinydrm: Use spi_is_bpw_supported()
[platform/kernel/linux-rpi.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 int tinydrm_spi_transfer(struct spi_device *spi, u32 speed_hz,
47                          struct spi_transfer *header, u8 bpw, const void *buf,
48                          size_t len);
49 void _tinydrm_dbg_spi_message(struct spi_device *spi, struct spi_message *m);
50
51 #ifdef DEBUG
52 /**
53  * tinydrm_dbg_spi_message - Dump SPI message
54  * @spi: SPI device
55  * @m: SPI message
56  *
57  * Dumps info about the transfers in a SPI message including buffer content.
58  * DEBUG has to be defined for this function to be enabled alongside setting
59  * the DRM_UT_DRIVER bit of &drm_debug.
60  */
61 static inline void tinydrm_dbg_spi_message(struct spi_device *spi,
62                                            struct spi_message *m)
63 {
64         if (drm_debug & DRM_UT_DRIVER)
65                 _tinydrm_dbg_spi_message(spi, m);
66 }
67 #else
68 static inline void tinydrm_dbg_spi_message(struct spi_device *spi,
69                                            struct spi_message *m)
70 {
71 }
72 #endif /* DEBUG */
73
74 #endif /* __LINUX_TINYDRM_HELPERS_H */