drivers/ipmi/ocp: Add missing include
[coreboot.git] / src / drivers / mipi / panel.c
blob7279d17b9a222a38962ea8b6f12dc2990578685e
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <console/console.h>
4 #include <delay.h>
5 #include <mipi/panel.h>
6 #include <types.h>
8 enum cb_err mipi_panel_parse_init_commands(const void *buf, mipi_cmd_func_t cmd_func)
10 const struct panel_init_command *init = buf;
11 enum mipi_dsi_transaction type;
14 * The given commands should be in a buffer containing a packed array of
15 * panel_init_command and each element may be in variable size so we have
16 * to parse and scan.
19 for (; init->cmd != PANEL_CMD_END; init = (const void *)buf) {
21 * For some commands like DELAY, the init->len should not be
22 * counted for buf.
24 buf += sizeof(*init);
26 u32 cmd = init->cmd, len = init->len;
28 if (cmd == PANEL_CMD_DELAY) {
29 mdelay(len);
30 continue;
33 switch (cmd) {
34 case PANEL_CMD_DCS:
35 switch (len) {
36 case 0:
37 printk(BIOS_ERR, "%s: DCS command length 0?\n", __func__);
38 return CB_ERR;
39 case 1:
40 type = MIPI_DSI_DCS_SHORT_WRITE;
41 break;
42 case 2:
43 type = MIPI_DSI_DCS_SHORT_WRITE_PARAM;
44 break;
45 default:
46 type = MIPI_DSI_DCS_LONG_WRITE;
47 break;
49 break;
50 case PANEL_CMD_GENERIC:
51 switch (len) {
52 case 0:
53 type = MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM;
54 break;
55 case 1:
56 type = MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM;
57 break;
58 case 2:
59 type = MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM;
60 break;
61 default:
62 type = MIPI_DSI_GENERIC_LONG_WRITE;
63 break;
65 break;
66 default:
67 printk(BIOS_ERR, "%s: Unknown command code: %d, "
68 "abort panel initialization.\n", __func__, cmd);
69 return CB_ERR;
72 enum cb_err ret = cmd_func(type, init->data, len);
73 if (ret != CB_SUCCESS)
74 return ret;
75 buf += len;
78 return CB_SUCCESS;