xref: /aosp_15_r20/external/coreboot/src/include/mipi/panel.h (revision b9411a12aaaa7e1e6a6fb7c5e057f44ee179a49c)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #ifndef __MIPI_PANEL_H__
4 #define __MIPI_PANEL_H__
5 
6 #include <edid.h>
7 #include <mipi/dsi.h>
8 #include <types.h>
9 
10 /* Definitions for cmd in panel_init_command */
11 enum panel_init_cmd {
12 	PANEL_CMD_END = 0,
13 	PANEL_CMD_DELAY = 1,
14 	PANEL_CMD_GENERIC = 2,
15 	PANEL_CMD_DCS = 3,
16 };
17 
18 struct panel_init_command {
19 	u8 cmd;
20 	u8 len;
21 	u8 data[];
22 };
23 
24 /*
25  * The data to be serialized and put into CBFS.
26  * Note some fields, for example edid.mode.name, were actually pointers and
27  * cannot be really serialized.
28  */
29 struct panel_serializable_data {
30 	struct edid edid;  /* edid info of this panel */
31 	u8 init[]; /* A packed array of panel_init_command */
32 };
33 
34 typedef enum cb_err (*mipi_cmd_func_t)(enum mipi_dsi_transaction type, const u8 *data, u8 len);
35 
36 /* Parse a command array and call cmd_func() for each entry. Delays get handled internally. */
37 enum cb_err mipi_panel_parse_init_commands(const void *buf, mipi_cmd_func_t cmd_func);
38 
39 #define PANEL_DCS(...) \
40 	PANEL_CMD_DCS, \
41 	sizeof((u8[]){__VA_ARGS__}), \
42 	__VA_ARGS__
43 
44 #define PANEL_GENERIC(...) \
45 	PANEL_CMD_GENERIC, \
46 	sizeof((u8[]){__VA_ARGS__}), \
47 	__VA_ARGS__
48 
49 #define PANEL_DELAY(delay) \
50 	PANEL_CMD_DELAY, \
51 	delay
52 
53 #define PANEL_END \
54 	PANEL_CMD_END
55 
56 #endif /* __MIPI_PANEL_H__ */
57