summaryrefslogtreecommitdiff
path: root/src/soc/mediatek/common
diff options
context:
space:
mode:
authorHung-Te Lin <hungte@chromium.org>2019-08-07 08:44:30 +0800
committerJulius Werner <jwerner@chromium.org>2019-08-13 02:21:36 +0000
commit61e346624a2c8b7e3de5313f2f4bfa2d4359e660 (patch)
treeb6423901a5de995677bf700be8669d181fb80523 /src/soc/mediatek/common
parentc59fbf2bb80ed1e9cfca837cf9f35a08d6b4129c (diff)
soc/mediatek: dsi: Unify format to bpp conversion
The 'bpp' was referred to both 'bits per pixel' and 'bytes per pixel' in MTK DSI driver and should be corrected. By this change we now always consider 'bpp' as 'bits per pixel', and rename the variables for other cases. BUG=b:80501386,b:117254947 TEST=make -j # board = oak and boots Change-Id: Ibd405220b73859e5592c68f498af07eef8d7edbc Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/34770 Reviewed-by: Julius Werner <jwerner@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/soc/mediatek/common')
-rw-r--r--src/soc/mediatek/common/dsi.c37
-rw-r--r--src/soc/mediatek/common/include/soc/dsi_common.h3
2 files changed, 27 insertions, 13 deletions
diff --git a/src/soc/mediatek/common/dsi.c b/src/soc/mediatek/common/dsi.c
index 3d003ec94f..92a645682e 100644
--- a/src/soc/mediatek/common/dsi.c
+++ b/src/soc/mediatek/common/dsi.c
@@ -21,6 +21,22 @@
#include <soc/dsi.h>
#include <timer.h>
+static unsigned int mtk_dsi_get_bits_per_pixel(u32 format)
+{
+ switch (format) {
+ case MIPI_DSI_FMT_RGB565:
+ return 16;
+ case MIPI_DSI_FMT_RGB666:
+ case MIPI_DSI_FMT_RGB666_PACKED:
+ return 18;
+ case MIPI_DSI_FMT_RGB888:
+ return 24;
+ }
+ printk(BIOS_WARNING, "%s: WARN: Unknown format %d, assuming 24 bpp\n",
+ __func__, format);
+ return 24;
+}
+
static void mtk_dsi_phy_timconfig(u32 data_rate)
{
u32 timcon0, timcon1, timcon2, timcon3;
@@ -106,15 +122,11 @@ static void mtk_dsi_config_vdo_timing(u32 mode_flags, u32 format,
u32 hfp_byte;
u32 vbp_byte;
u32 vfp_byte;
- u32 bpp;
+ u32 bytes_per_pixel;
u32 packet_fmt;
u32 hactive;
- if (format == MIPI_DSI_FMT_RGB565)
- bpp = 2;
- else
- bpp = 3;
-
+ bytes_per_pixel = DIV_ROUND_UP(mtk_dsi_get_bits_per_pixel(format), 8);
vbp_byte = edid->mode.vbl - edid->mode.vso - edid->mode.vspw -
edid->mode.vborder;
vfp_byte = edid->mode.vso - edid->mode.vborder;
@@ -126,13 +138,13 @@ static void mtk_dsi_config_vdo_timing(u32 mode_flags, u32 format,
if (mode_flags & MIPI_DSI_MODE_VIDEO_SYNC_PULSE)
hbp_byte = (edid->mode.hbl - edid->mode.hso - edid->mode.hspw -
- edid->mode.hborder) * bpp - 10;
+ edid->mode.hborder) * bytes_per_pixel - 10;
else
hbp_byte = (edid->mode.hbl - edid->mode.hso -
- edid->mode.hborder) * bpp - 10;
+ edid->mode.hborder) * bytes_per_pixel - 10;
- hsync_active_byte = edid->mode.hspw * bpp - 10;
- hfp_byte = (edid->mode.hso - edid->mode.hborder) * bpp - 12;
+ hsync_active_byte = edid->mode.hspw * bytes_per_pixel - 10;
+ hfp_byte = (edid->mode.hso - edid->mode.hborder) * bytes_per_pixel - 12;
write32(&dsi0->dsi_hsa_wc, hsync_active_byte);
write32(&dsi0->dsi_hbp_wc, hbp_byte);
@@ -157,7 +169,7 @@ static void mtk_dsi_config_vdo_timing(u32 mode_flags, u32 format,
}
hactive = edid->mode.ha;
- packet_fmt |= (hactive * bpp) & DSI_PS_WC;
+ packet_fmt |= (hactive * bytes_per_pixel) & DSI_PS_WC;
write32(&dsi0->dsi_psctrl, packet_fmt);
}
@@ -172,8 +184,9 @@ static void mtk_dsi_start(void)
int mtk_dsi_init(u32 mode_flags, u32 format, u32 lanes, const struct edid *edid)
{
int data_rate;
+ u32 bits_per_pixel = mtk_dsi_get_bits_per_pixel(format);
- data_rate = mtk_dsi_phy_clk_setting(format, lanes, edid);
+ data_rate = mtk_dsi_phy_clk_setting(bits_per_pixel, lanes, edid);
if (data_rate < 0)
return -1;
diff --git a/src/soc/mediatek/common/include/soc/dsi_common.h b/src/soc/mediatek/common/include/soc/dsi_common.h
index cebf9af701..7a48d53507 100644
--- a/src/soc/mediatek/common/include/soc/dsi_common.h
+++ b/src/soc/mediatek/common/include/soc/dsi_common.h
@@ -303,7 +303,8 @@ enum {
/* Functions that each SOC should provide. */
void mtk_dsi_reset(void);
/* mtk_dsi_phy_clk_setting should return the data rate in Mbps. */
-int mtk_dsi_phy_clk_setting(u32 format, u32 lanes, const struct edid *edid);
+int mtk_dsi_phy_clk_setting(u32 bits_per_pixel, u32 lanes,
+ const struct edid *edid);
/* Public API provided in common/dsi.c */
int mtk_dsi_init(u32 mode_flags, u32 format, u32 lanes,