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