1
2
3
4
5
6
7
8
9
10
11
12#ifndef __LINUX_MIPI_DBI_H
13#define __LINUX_MIPI_DBI_H
14
15#include <drm/tinydrm/tinydrm.h>
16
17struct drm_rect;
18struct spi_device;
19struct gpio_desc;
20struct regulator;
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41struct mipi_dbi {
42 struct tinydrm_device tinydrm;
43 struct spi_device *spi;
44 bool enabled;
45 struct mutex cmdlock;
46 int (*command)(struct mipi_dbi *mipi, u8 cmd, u8 *param, size_t num);
47 const u8 *read_commands;
48 struct gpio_desc *dc;
49 u16 *tx_buf;
50 void *tx_buf9;
51 size_t tx_buf9_len;
52 bool swap_bytes;
53 struct gpio_desc *reset;
54 unsigned int rotation;
55 struct backlight_device *backlight;
56 struct regulator *regulator;
57};
58
59static inline struct mipi_dbi *
60mipi_dbi_from_tinydrm(struct tinydrm_device *tdev)
61{
62 return container_of(tdev, struct mipi_dbi, tinydrm);
63}
64
65int mipi_dbi_spi_init(struct spi_device *spi, struct mipi_dbi *mipi,
66 struct gpio_desc *dc);
67int mipi_dbi_init(struct device *dev, struct mipi_dbi *mipi,
68 const struct drm_simple_display_pipe_funcs *pipe_funcs,
69 struct drm_driver *driver,
70 const struct drm_display_mode *mode, unsigned int rotation);
71void mipi_dbi_pipe_update(struct drm_simple_display_pipe *pipe,
72 struct drm_plane_state *old_state);
73void mipi_dbi_enable_flush(struct mipi_dbi *mipi,
74 struct drm_crtc_state *crtc_state,
75 struct drm_plane_state *plan_state);
76void mipi_dbi_pipe_disable(struct drm_simple_display_pipe *pipe);
77void mipi_dbi_hw_reset(struct mipi_dbi *mipi);
78bool mipi_dbi_display_is_on(struct mipi_dbi *mipi);
79int mipi_dbi_poweron_reset(struct mipi_dbi *mipi);
80int mipi_dbi_poweron_conditional_reset(struct mipi_dbi *mipi);
81u32 mipi_dbi_spi_cmd_max_speed(struct spi_device *spi, size_t len);
82
83int mipi_dbi_command_read(struct mipi_dbi *mipi, u8 cmd, u8 *val);
84int mipi_dbi_command_buf(struct mipi_dbi *mipi, u8 cmd, u8 *data, size_t len);
85int mipi_dbi_buf_copy(void *dst, struct drm_framebuffer *fb,
86 struct drm_rect *clip, bool swap);
87
88
89
90
91
92
93
94
95
96
97
98
99#define mipi_dbi_command(mipi, cmd, seq...) \
100({ \
101 u8 d[] = { seq }; \
102 mipi_dbi_command_buf(mipi, cmd, d, ARRAY_SIZE(d)); \
103})
104
105#ifdef CONFIG_DEBUG_FS
106int mipi_dbi_debugfs_init(struct drm_minor *minor);
107#else
108#define mipi_dbi_debugfs_init NULL
109#endif
110
111#endif
112