Julius Werner has submitted this change and it was merged. ( https://review.coreboot.org/c/coreboot/+/34778 )
Change subject: soc/mediatek: Change DSI init commands to take flexible length array ......................................................................
soc/mediatek: Change DSI init commands to take flexible length array
The fixed size of init command in lcm_init_table is wasting lots of space and we should change to packed array since the command buffer already provides length information.
With this change, BOE panel init commands have been reduced from 4848 bytes to 1309 bytes.
BUG=b:80501386,b:117254947 TEST=emerge-kukui coreboot chromeos-bootimage; Boots properly
Change-Id: I359dde8e6f2e1c0983f4677193bb47a7ae497ca6 Signed-off-by: Hung-Te Lin hungte@chromium.org Reviewed-on: https://review.coreboot.org/c/coreboot/+/34778 Reviewed-by: Julius Werner jwerner@chromium.org Tested-by: build bot (Jenkins) no-reply@coreboot.org --- M src/mainboard/google/kukui/panel.h M src/soc/mediatek/common/dsi.c M src/soc/mediatek/common/include/soc/dsi_common.h 3 files changed, 36 insertions(+), 22 deletions(-)
Approvals: build bot (Jenkins): Verified Julius Werner: Looks good to me, approved
diff --git a/src/mainboard/google/kukui/panel.h b/src/mainboard/google/kukui/panel.h index e68567d..321e366 100644 --- a/src/mainboard/google/kukui/panel.h +++ b/src/mainboard/google/kukui/panel.h @@ -23,27 +23,28 @@ struct edid edid; /* edid info of this panel */ enum lb_fb_orientation orientation; /* panel orientation */ void (*power_on)(void); /* Callback to turn on panel */ - struct lcm_init_command init[]; /* table of init commands */ + u8 init[]; /* a packed array of lcm_init_command */ };
/* Returns the panel description from given ID. */ extern struct panel_description *get_panel_description(int panel_id);
-#define INIT_DCS_CMD(...) { \ - .cmd = LCM_DCS_CMD, \ - .len = sizeof((u8[]){__VA_ARGS__}), \ - .data = {__VA_ARGS__} } +#define INIT_DCS_CMD(...) \ + LCM_DCS_CMD, \ + sizeof((u8[]){__VA_ARGS__}), \ + __VA_ARGS__
-#define INIT_GENERIC_CMD(...) { \ - .cmd = LCM_GENERIC_CMD, \ - .len = sizeof((u8[]){__VA_ARGS__}), \ - .data = {__VA_ARGS__} } +#define INIT_GENERIC_CMD(...) \ + LCM_GENERIC_CMD, \ + sizeof((u8[]){__VA_ARGS__}), \ + __VA_ARGS__
-#define INIT_DELAY_CMD(delay) { \ - .cmd = LCM_DELAY_CMD,\ - .len = delay, } +#define INIT_DELAY_CMD(delay) \ + LCM_DELAY_CMD, \ + delay
-#define INIT_END_CMD { .cmd = LCM_END_CMD, } +#define INIT_END_CMD \ + LCM_END_CMD
/* GPIO names */ #define GPIO_LCM_RST_1V8 GPIO(LCM_RST) /* 45 */ diff --git a/src/soc/mediatek/common/dsi.c b/src/soc/mediatek/common/dsi.c index 166bc17..679bec8 100644 --- a/src/soc/mediatek/common/dsi.c +++ b/src/soc/mediatek/common/dsi.c @@ -321,12 +321,25 @@ } }
-static void mtk_dsi_send_init_commands(const struct lcm_init_command *init) +static void mtk_dsi_send_init_commands(const u8 *buf) { - if (!init) + if (!buf) return; + const struct lcm_init_command *init = (const void *)buf;
- for (; init->cmd != LCM_END_CMD; init++) { + /* + * The given commands should be in a buffer containing a packed array of + * lcm_init_command and each element may be in variable size so we have + * to parse and scan. + */ + + for (; init->cmd != LCM_END_CMD; init = (const void *)buf) { + /* + * For some commands like DELAY, the init->len should not be + * counted for buf. + */ + buf += sizeof(*init); + u32 cmd = init->cmd, len = init->len; u32 type;
@@ -374,13 +387,13 @@ return;
} - assert(len <= sizeof(init->data)); + buf += len; mtk_dsi_cmdq(init->data, len, type); } }
int mtk_dsi_init(u32 mode_flags, u32 format, u32 lanes, const struct edid *edid, - const struct lcm_init_command *init_commands) + const u8 *init_commands) { int data_rate; u32 bits_per_pixel = mtk_dsi_get_bits_per_pixel(format); diff --git a/src/soc/mediatek/common/include/soc/dsi_common.h b/src/soc/mediatek/common/include/soc/dsi_common.h index c684aaf..9a00d1d 100644 --- a/src/soc/mediatek/common/include/soc/dsi_common.h +++ b/src/soc/mediatek/common/include/soc/dsi_common.h @@ -350,9 +350,9 @@ #define LCM_DCS_CMD 3
struct lcm_init_command { - u16 cmd; - u16 len; - u8 data[8]; + u8 cmd; + u8 len; + u8 data[]; };
/* Functions that each SOC should provide. */ @@ -365,6 +365,6 @@ /* Public API provided in common/dsi.c */ int mtk_dsi_bpp_from_format(u32 format); int mtk_dsi_init(u32 mode_flags, u32 format, u32 lanes, const struct edid *edid, - const struct lcm_init_command *init_commands); + const u8 *init_commands);
#endif /* SOC_MEDIATEK_DSI_COMMON_H */