[U-Boot] [PATCH] [v2] mpc8610: refactor DIU initialization code to use existing bitmap and logo features
Timur Tabi
timur at freescale.com
Tue Aug 31 21:58:23 CEST 2010
The Freescale MPC8610 DIU code had re-implement two features that already
existed in U-Boot: bitmap drawing and top-of-screen logo (CONFIG_VIDEO_LOGO).
So delete the 8610-specific code and use the built-in features instead.
Signed-off-by: Timur Tabi <timur at freescale.com>
---
This patch depends on the patch, "logos: add Freescale logo"
board/freescale/common/fsl_diu_fb.c | 132 +------------------------
board/freescale/common/fsl_diu_fb.h | 12 +--
board/freescale/mpc8610hpcd/mpc8610hpcd.c | 6 +-
board/freescale/mpc8610hpcd/mpc8610hpcd_diu.c | 44 +-------
include/configs/MPC8610HPCD.h | 7 +-
5 files changed, 15 insertions(+), 186 deletions(-)
diff --git a/board/freescale/common/fsl_diu_fb.c b/board/freescale/common/fsl_diu_fb.c
index e740ad8..394b71f 100644
--- a/board/freescale/common/fsl_diu_fb.c
+++ b/board/freescale/common/fsl_diu_fb.c
@@ -208,10 +208,7 @@ static int fsl_diu_disable_panel(struct fb_info *info);
static int allocate_buf(struct diu_addr *buf, u32 size, u32 bytes_align);
void diu_set_pixel_clock(unsigned int pixclock);
-int fsl_diu_init(int xres,
- unsigned int pixel_format,
- int gamma_fix,
- unsigned char *splash_bmp)
+int fsl_diu_init(int xres, unsigned int pixel_format, int gamma_fix)
{
struct fb_videomode *fsl_diu_mode_db;
struct diu_ad *ad = &fsl_diu_fb_ad;
@@ -288,8 +285,6 @@ int fsl_diu_init(int xres,
var->sync = fsl_diu_mode_db->sync;
var->vmode = fsl_diu_mode_db->vmode;
info->line_length = var->xres * var->bits_per_pixel / 8;
- info->logo_size = 0;
- info->logo_height = 0;
ad->pix_fmt = pixel_format;
ad->addr = cpu_to_le32((unsigned int)info->screen_base);
@@ -358,13 +353,6 @@ int fsl_diu_init(int xres,
fb_initialized = 1;
- if (splash_bmp) {
- info->logo_height = fsl_diu_display_bmp(splash_bmp, 0, 0, 0);
- info->logo_size = info->logo_height * info->line_length;
- debug("logo height %d, logo_size 0x%x\n",
- info->logo_height,info->logo_size);
- }
-
/* Enable the DIU */
fsl_diu_enable_panel(info);
enable_lcdc();
@@ -375,8 +363,7 @@ int fsl_diu_init(int xres,
char *fsl_fb_open(struct fb_info **info)
{
*info = &fsl_fb_info;
- return (char *) ((unsigned int)(*info)->screen_base
- + (*info)->logo_size);
+ return fsl_fb_info.screen_base;
}
void fsl_diu_close(void)
@@ -485,118 +472,3 @@ static int allocate_buf(struct diu_addr *buf, u32 size, u32 bytes_align)
buf->offset = 0;
return 0;
}
-
-int fsl_diu_display_bmp(unsigned char *bmp,
- int xoffset,
- int yoffset,
- int transpar)
-{
- struct fb_info *info = &fsl_fb_info;
- unsigned char r, g, b;
- unsigned int *fb_t, val;
- unsigned char *bitmap;
- unsigned int palette[256];
- int width, height, bpp, ncolors, raster, offset, x, y, i, k, cpp;
-
- if (!bmp) {
- printf("Must supply a bitmap address\n");
- return 0;
- }
-
- raster = bmp[10] + (bmp[11] << 8) + (bmp[12] << 16) + (bmp[13] << 24);
- width = (bmp[21] << 24) | (bmp[20] << 16) | (bmp[19] << 8) | bmp[18];
- height = (bmp[25] << 24) | (bmp[24] << 16) | (bmp[23] << 8) | bmp[22];
- bpp = (bmp[29] << 8) | (bmp[28]);
- ncolors = bmp[46] + (bmp[47] << 8) + (bmp[48] << 16) + (bmp[49] << 24);
- bitmap = bmp + raster;
- cpp = info->var.bits_per_pixel / 8;
-
- debug("bmp = 0x%08x\n", (unsigned int)bmp);
- debug("bitmap = 0x%08x\n", (unsigned int)bitmap);
- debug("width = %d\n", width);
- debug("height = %d\n", height);
- debug("bpp = %d\n", bpp);
- debug("ncolors = %d\n", ncolors);
-
- debug("xres = %d\n", info->var.xres);
- debug("yres = %d\n", info->var.yres);
- debug("Screen_base = 0x%x\n", (unsigned int)info->screen_base);
-
- if (((width+xoffset) > info->var.xres) ||
- ((height+yoffset) > info->var.yres)) {
- printf("bitmap is out of range, image too large or too much offset\n");
- return 0;
- }
- if (bpp < 24) {
- for (i = 0, offset = 54; i < ncolors; i++, offset += 4)
- palette[i] = (bmp[offset+2] << 16)
- + (bmp[offset+1] << 8) + bmp[offset];
- }
-
- switch (bpp) {
- case 1:
- for (y = height - 1; y >= 0; y--) {
- fb_t = (unsigned int *) ((unsigned int)info->screen_base + (((y+yoffset) * info->var.xres) + xoffset)*cpp);
- for (x = 0; x < width; x += 8) {
- b = *bitmap++;
- for (k = 0; k < 8; k++) {
- if (b & 0x80)
- *fb_t++ = palette[1];
- else
- *fb_t++ = palette[0];
- b = b << 1;
- }
- }
- for (i = (width / 2) % 4; i > 0; i--)
- bitmap++;
- }
- break;
- case 4:
- for (y = height - 1; y >= 0; y--) {
- fb_t = (unsigned int *) ((unsigned int)info->screen_base + (((y+yoffset) * info->var.xres) + xoffset)*cpp);
- for (x = 0; x < width; x += 2) {
- b = *bitmap++;
- r = (b >> 4) & 0x0F;
- g = b & 0x0F;
- *fb_t++ = palette[r];
- *fb_t++ = palette[g];
- }
- for (i = (width / 2) % 4; i > 0; i--)
- bitmap++;
- }
- break;
- case 8:
- for (y = height - 1; y >= 0; y--) {
- fb_t = (unsigned int *) ((unsigned int)info->screen_base + (((y+yoffset) * info->var.xres) + xoffset)*cpp);
- for (x = 0; x < width; x++) {
- *fb_t++ = palette[ *bitmap++ ];
- }
- for (i = (width / 2) % 4; i > 0; i--)
- bitmap++;
- }
- break;
- case 24:
- for (y = height - 1; y >= 0; y--) {
- fb_t = (unsigned int *) ((unsigned int)info->screen_base + (((y+yoffset) * info->var.xres) + xoffset)*cpp);
- for (x = 0; x < width; x++) {
- b = *bitmap++;
- g = *bitmap++;
- r = *bitmap++;
- val = (r << 16) + (g << 8) + b;
- *fb_t++ = val;
- }
- for (; (x % 4) != 0; x++) /* 4-byte alignment */
- bitmap++;
- }
- break;
- }
-
- return height;
-}
-
-void fsl_diu_clear_screen(void)
-{
- struct fb_info *info = &fsl_fb_info;
-
- memset(info->screen_base, 0, info->smem_len);
-}
diff --git a/board/freescale/common/fsl_diu_fb.h b/board/freescale/common/fsl_diu_fb.h
index 6deba32..3a5fc9f 100644
--- a/board/freescale/common/fsl_diu_fb.h
+++ b/board/freescale/common/fsl_diu_fb.h
@@ -52,18 +52,8 @@ struct fb_info {
char *screen_base;
unsigned long screen_size;
- int logo_height;
- unsigned int logo_size;
};
extern char *fsl_fb_open(struct fb_info **info);
-extern int fsl_diu_init(int xres,
- unsigned int pixel_format,
- int gamma_fix,
- unsigned char *splash_bmp);
-extern void fsl_diu_clear_screen(void);
-extern int fsl_diu_display_bmp(unsigned char *bmp,
- int xoffset,
- int yoffset,
- int transpar);
+int fsl_diu_init(int xres, unsigned int pixel_format, int gamma_fix);
diff --git a/board/freescale/mpc8610hpcd/mpc8610hpcd.c b/board/freescale/mpc8610hpcd/mpc8610hpcd.c
index 6578f58..f67f3e3 100644
--- a/board/freescale/mpc8610hpcd/mpc8610hpcd.c
+++ b/board/freescale/mpc8610hpcd/mpc8610hpcd.c
@@ -36,7 +36,7 @@
void sdram_init(void);
phys_size_t fixed_sdram(void);
-void mpc8610hpcd_diu_init(void);
+int mpc8610hpcd_diu_init(void);
/* called before any console output */
@@ -84,10 +84,6 @@ int misc_init_r(void)
i2c_read(0x38, 0x0A, 1, &tmp_val, sizeof(tmp_val));
debug("DVI Encoder Read: 0x%02lx\n",tmp_val);
-#ifdef CONFIG_FSL_DIU_FB
- mpc8610hpcd_diu_init();
-#endif
-
return 0;
}
diff --git a/board/freescale/mpc8610hpcd/mpc8610hpcd_diu.c b/board/freescale/mpc8610hpcd/mpc8610hpcd_diu.c
index 781a7c8..f919a18 100644
--- a/board/freescale/mpc8610hpcd/mpc8610hpcd_diu.c
+++ b/board/freescale/mpc8610hpcd/mpc8610hpcd_diu.c
@@ -61,7 +61,7 @@ void diu_set_pixel_clock(unsigned int pixclock)
debug("DIU: Modified value of CLKDVDR = 0x%08x\n", *guts_clkdvdr);
}
-void mpc8610hpcd_diu_init(void)
+int mpc8610hpcd_diu_init(void)
{
char *monitor_port;
int gamma_fix;
@@ -106,42 +106,9 @@ void mpc8610hpcd_diu_init(void)
out_8(pixis_base + PIXIS_BRDCFG0, tmp_val | 0x08);
}
- fsl_diu_init(xres, pixel_format, gamma_fix,
- (unsigned char *)FSL_Logo_BMP);
+ return fsl_diu_init(xres, pixel_format, gamma_fix);
}
-int mpc8610diu_init_show_bmp(cmd_tbl_t *cmdtp,
- int flag, int argc, char * const argv[])
-{
- unsigned int addr;
-
- if (argc < 2)
- return cmd_usage(cmdtp);
-
- if (!strncmp(argv[1],"init",4)) {
-#if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE)
- fsl_diu_clear_screen();
- drv_video_init();
-#else
- mpc8610hpcd_diu_init();
-#endif
- } else {
- addr = simple_strtoul(argv[1], NULL, 16);
- fsl_diu_clear_screen();
- fsl_diu_display_bmp((unsigned char *)addr, 0, 0, 0);
- }
-
- return 0;
-}
-
-U_BOOT_CMD(
- diufb, CONFIG_SYS_MAXARGS, 1, mpc8610diu_init_show_bmp,
- "Init or Display BMP file",
- "init\n - initialize DIU\n"
- "addr\n - display bmp at address 'addr'"
-);
-
-
#if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE)
/*
@@ -153,7 +120,8 @@ void *video_hw_init(void)
GraphicDevice *pGD = (GraphicDevice *) &ctfb;
struct fb_info *info;
- mpc8610hpcd_diu_init();
+ if (mpc8610hpcd_diu_init() < 0)
+ return NULL;
/* fill in Graphic device struct */
sprintf(pGD->modeIdent,
@@ -162,7 +130,7 @@ void *video_hw_init(void)
pGD->frameAdrs = (unsigned int)fsl_fb_open(&info);
pGD->winSizeX = xres;
- pGD->winSizeY = yres - info->logo_height;
+ pGD->winSizeY = yres;
pGD->plnSizeX = pGD->winSizeX;
pGD->plnSizeY = pGD->winSizeY;
@@ -171,7 +139,7 @@ void *video_hw_init(void)
pGD->isaBase = 0;
pGD->pciBase = 0;
- pGD->memSize = info->screen_size - info->logo_size;
+ pGD->memSize = info->screen_size;
/* Cursor Start Address */
pGD->dprBase = 0;
diff --git a/include/configs/MPC8610HPCD.h b/include/configs/MPC8610HPCD.h
index 4d9606e..b1905f2 100644
--- a/include/configs/MPC8610HPCD.h
+++ b/include/configs/MPC8610HPCD.h
@@ -22,11 +22,14 @@
#define CONFIG_FSL_DIU_FB 1 /* FSL DIU */
/* video */
-#undef CONFIG_VIDEO
+#define CONFIG_VIDEO
-#if defined(CONFIG_VIDEO)
+#ifdef CONFIG_VIDEO
+#define CONFIG_CMD_BMP
#define CONFIG_CFB_CONSOLE
#define CONFIG_VGA_AS_SINGLE_DEVICE
+#define CONFIG_VIDEO_LOGO
+#define CONFIG_VIDEO_BMP_LOGO
#endif
#ifdef RUN_DIAG
--
1.7.2.1
More information about the U-Boot
mailing list