| 1 |
|
| 2 |
|
| 3 |
#include <console/console.h> |
| 4 |
#include <delay.h> |
| 5 |
#include <mipi/panel.h> |
| 6 |
#include <types.h> |
| 7 |
|
| 8 |
enum cb_err mipi_panel_parse_init_commands(const void *buf, mipi_cmd_func_t cmd_func) |
| 9 |
{ |
| 10 |
const struct panel_init_command *init = buf; |
| 11 |
enum mipi_dsi_transaction type; |
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
for (; init->cmd != PANEL_CMD_END; init = (const void *)buf) { |
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
buf += sizeof(*init); |
| 25 |
|
| 26 |
u32 cmd = init->cmd, len = init->len; |
| 27 |
|
| 28 |
if (cmd == PANEL_CMD_DELAY) { |
| 29 |
mdelay(len); |
| 30 |
continue; |
| 31 |
} |
| 32 |
|
| 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; |
| 48 |
} |
| 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; |
| 64 |
} |
| 65 |
break; |
| 66 |
default: |
| 67 |
printk(BIOS_ERR, "%s: Unknown command code: %d, " |
| 68 |
"abort panel initialization.\n", __func__, cmd); |
| 69 |
return CB_ERR; |
| 70 |
} |
| 71 |
|
| 72 |
enum cb_err ret = cmd_func(type, init->data, len); |
| 73 |
if (ret != CB_SUCCESS) |
| 74 |
return ret; |
| 75 |
buf += len; |
| 76 |
} |
| 77 |
|
| 78 |
return CB_SUCCESS; |
| 79 |
} |