blob: 2fc878be8a73e1b086824ab728cba085fd0adecd [file] [log] [blame]
York Sunb7145172007-10-29 13:58:39 -05001/*
2 * Copyright 2007 Freescale Semiconductor, Inc.
3 * York Sun <yorksun@freescale.com>
4 *
5 * FSL DIU Framebuffer driver
6 *
7 * See file CREDITS for list of people who contributed to this
8 * project.
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of
13 * the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
23 * MA 02111-1307 USA
24 */
25
York Sunb7145172007-10-29 13:58:39 -050026#include <common.h>
27#include <i2c.h>
28#include <malloc.h>
29
York Sunb7145172007-10-29 13:58:39 -050030#include "fsl_diu_fb.h"
31
York Sunb7145172007-10-29 13:58:39 -050032struct fb_videomode {
33 const char *name; /* optional */
34 unsigned int refresh; /* optional */
35 unsigned int xres;
36 unsigned int yres;
37 unsigned int pixclock;
38 unsigned int left_margin;
39 unsigned int right_margin;
40 unsigned int upper_margin;
41 unsigned int lower_margin;
42 unsigned int hsync_len;
43 unsigned int vsync_len;
44 unsigned int sync;
45 unsigned int vmode;
46 unsigned int flag;
47};
48
49#define FB_SYNC_VERT_HIGH_ACT 2 /* vertical sync high active */
50#define FB_SYNC_COMP_HIGH_ACT 8 /* composite sync high active */
51#define FB_VMODE_NONINTERLACED 0 /* non interlaced */
52
53/*
54 * These parameters give default parameters
55 * for video output 1024x768,
56 * FIXME - change timing to proper amounts
57 * hsync 31.5kHz, vsync 60Hz
58 */
59static struct fb_videomode fsl_diu_mode_1024 = {
60 .refresh = 60,
61 .xres = 1024,
62 .yres = 768,
63 .pixclock = 15385,
64 .left_margin = 160,
65 .right_margin = 24,
66 .upper_margin = 29,
67 .lower_margin = 3,
68 .hsync_len = 136,
69 .vsync_len = 6,
70 .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
71 .vmode = FB_VMODE_NONINTERLACED
72};
73
74static struct fb_videomode fsl_diu_mode_1280 = {
75 .name = "1280x1024-60",
76 .refresh = 60,
77 .xres = 1280,
78 .yres = 1024,
79 .pixclock = 9375,
80 .left_margin = 38,
81 .right_margin = 128,
82 .upper_margin = 2,
83 .lower_margin = 7,
84 .hsync_len = 216,
85 .vsync_len = 37,
86 .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
87 .vmode = FB_VMODE_NONINTERLACED
88};
89
90/*
91 * These are the fields of area descriptor(in DDR memory) for every plane
92 */
93struct diu_ad {
94 /* Word 0(32-bit) in DDR memory */
95 unsigned int pix_fmt; /* hard coding pixel format */
96 /* Word 1(32-bit) in DDR memory */
97 unsigned int addr;
98 /* Word 2(32-bit) in DDR memory */
99 unsigned int src_size_g_alpha;
100 /* Word 3(32-bit) in DDR memory */
101 unsigned int aoi_size;
102 /* Word 4(32-bit) in DDR memory */
103 unsigned int offset_xyi;
104 /* Word 5(32-bit) in DDR memory */
105 unsigned int offset_xyd;
106 /* Word 6(32-bit) in DDR memory */
107 unsigned int ckmax_r:8;
108 unsigned int ckmax_g:8;
109 unsigned int ckmax_b:8;
110 unsigned int res9:8;
111 /* Word 7(32-bit) in DDR memory */
112 unsigned int ckmin_r:8;
113 unsigned int ckmin_g:8;
114 unsigned int ckmin_b:8;
115 unsigned int res10:8;
116 /* Word 8(32-bit) in DDR memory */
117 unsigned int next_ad;
118 /* Word 9(32-bit) in DDR memory, just for 64-bit aligned */
119 unsigned int res1;
120 unsigned int res2;
121 unsigned int res3;
122}__attribute__ ((packed));
123
124/*
125 * DIU register map
126 */
127struct diu {
128 unsigned int desc[3];
129 unsigned int gamma;
130 unsigned int pallete;
131 unsigned int cursor;
132 unsigned int curs_pos;
133 unsigned int diu_mode;
134 unsigned int bgnd;
135 unsigned int bgnd_wb;
136 unsigned int disp_size;
137 unsigned int wb_size;
138 unsigned int wb_mem_addr;
139 unsigned int hsyn_para;
140 unsigned int vsyn_para;
141 unsigned int syn_pol;
142 unsigned int thresholds;
143 unsigned int int_status;
144 unsigned int int_mask;
145 unsigned int colorbar[8];
146 unsigned int filling;
147 unsigned int plut;
148} __attribute__ ((packed));
149
150struct diu_hw {
151 struct diu *diu_reg;
152 volatile unsigned int mode; /* DIU operation mode */
153};
154
155struct diu_addr {
156 unsigned char * paddr; /* Virtual address */
Wolfgang Denka1be4762008-05-20 16:00:29 +0200157 unsigned int offset;
York Sunb7145172007-10-29 13:58:39 -0500158};
159
York Sunb7145172007-10-29 13:58:39 -0500160/*
161 * Modes of operation of DIU
162 */
163#define MFB_MODE0 0 /* DIU off */
164#define MFB_MODE1 1 /* All three planes output to display */
165#define MFB_MODE2 2 /* Plane 1 to display,
166 * planes 2+3 written back to memory */
167#define MFB_MODE3 3 /* All three planes written back to memory */
168#define MFB_MODE4 4 /* Color bar generation */
169
170#define MAX_CURS 32
171
York Sunb7145172007-10-29 13:58:39 -0500172static struct fb_info fsl_fb_info;
173static struct diu_addr gamma, cursor;
174static struct diu_ad fsl_diu_fb_ad __attribute__ ((aligned(32)));
175static struct diu_ad dummy_ad __attribute__ ((aligned(32)));
176static unsigned char *dummy_fb;
177static struct diu_hw dr = {
178 .mode = MFB_MODE1,
179};
180
181int fb_enabled = 0;
182int fb_initialized = 0;
183const int default_xres = 1280;
184const int default_pixel_format = 0x88882317;
185
186static int map_video_memory(struct fb_info *info, unsigned long bytes_align);
187static void enable_lcdc(void);
188static void disable_lcdc(void);
189static int fsl_diu_enable_panel(struct fb_info *info);
190static int fsl_diu_disable_panel(struct fb_info *info);
191static int allocate_buf(struct diu_addr *buf, u32 size, u32 bytes_align);
York Sunc4964382008-05-05 10:19:59 -0500192void diu_set_pixel_clock(unsigned int pixclock);
York Sunb7145172007-10-29 13:58:39 -0500193
York Sunb7145172007-10-29 13:58:39 -0500194int fsl_diu_init(int xres,
195 unsigned int pixel_format,
196 int gamma_fix,
197 unsigned char *splash_bmp)
198{
199 struct fb_videomode *fsl_diu_mode_db;
200 struct diu_ad *ad = &fsl_diu_fb_ad;
201 struct diu *hw;
202 struct fb_info *info = &fsl_fb_info;
203 struct fb_var_screeninfo *var = &info->var;
York Sunb7145172007-10-29 13:58:39 -0500204 unsigned char *gamma_table_base;
205 unsigned int i, j;
York Sunb7145172007-10-29 13:58:39 -0500206
York Sun94cbda92008-05-05 10:20:00 -0500207 debug("Enter fsl_diu_init\n");
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200208 dr.diu_reg = (struct diu *) (CONFIG_SYS_DIU_ADDR);
York Sunb7145172007-10-29 13:58:39 -0500209 hw = (struct diu *) dr.diu_reg;
210
211 disable_lcdc();
212
213 if (xres == 1280) {
214 fsl_diu_mode_db = &fsl_diu_mode_1280;
215 } else {
216 fsl_diu_mode_db = &fsl_diu_mode_1024;
217 }
218
219 if (0 == fb_initialized) {
220 allocate_buf(&gamma, 768, 32);
York Sun94cbda92008-05-05 10:20:00 -0500221 debug("gamma is allocated @ 0x%x\n",
York Sunb7145172007-10-29 13:58:39 -0500222 (unsigned int)gamma.paddr);
223 allocate_buf(&cursor, MAX_CURS * MAX_CURS * 2, 32);
York Sun94cbda92008-05-05 10:20:00 -0500224 debug("curosr is allocated @ 0x%x\n",
York Sunb7145172007-10-29 13:58:39 -0500225 (unsigned int)cursor.paddr);
226
227 /* create a dummy fb and dummy ad */
228 dummy_fb = malloc(64);
229 if (NULL == dummy_fb) {
230 printf("Cannot allocate dummy fb\n");
231 return -1;
232 }
233 dummy_ad.addr = cpu_to_le32((unsigned int)dummy_fb);
234 dummy_ad.pix_fmt = 0x88882317;
235 dummy_ad.src_size_g_alpha = 0x04400000; /* alpha = 0 */
236 dummy_ad.aoi_size = 0x02000400;
237 dummy_ad.offset_xyi = 0;
238 dummy_ad.offset_xyd = 0;
239 dummy_ad.next_ad = 0;
240 /* Memory allocation for framebuffer */
241 if (map_video_memory(info, 32)) {
242 printf("Unable to allocate fb memory 1\n");
243 return -1;
244 }
York Sunb7145172007-10-29 13:58:39 -0500245 }
246
Nikita V. Youshchenko7e6647e2008-10-03 00:03:55 +0400247 memset(info->screen_base, 0, info->smem_len);
248
York Sunb7145172007-10-29 13:58:39 -0500249 dr.diu_reg->desc[0] = (unsigned int) &dummy_ad;
250 dr.diu_reg->desc[1] = (unsigned int) &dummy_ad;
251 dr.diu_reg->desc[2] = (unsigned int) &dummy_ad;
York Sun94cbda92008-05-05 10:20:00 -0500252 debug("dummy dr.diu_reg->desc[0] = 0x%x\n", dr.diu_reg->desc[0]);
253 debug("dummy desc[0] = 0x%x\n", hw->desc[0]);
York Sunb7145172007-10-29 13:58:39 -0500254
255 /* read mode info */
256 var->xres = fsl_diu_mode_db->xres;
257 var->yres = fsl_diu_mode_db->yres;
258 var->bits_per_pixel = 32;
259 var->pixclock = fsl_diu_mode_db->pixclock;
260 var->left_margin = fsl_diu_mode_db->left_margin;
261 var->right_margin = fsl_diu_mode_db->right_margin;
262 var->upper_margin = fsl_diu_mode_db->upper_margin;
263 var->lower_margin = fsl_diu_mode_db->lower_margin;
264 var->hsync_len = fsl_diu_mode_db->hsync_len;
265 var->vsync_len = fsl_diu_mode_db->vsync_len;
266 var->sync = fsl_diu_mode_db->sync;
267 var->vmode = fsl_diu_mode_db->vmode;
268 info->line_length = var->xres * var->bits_per_pixel / 8;
269 info->logo_size = 0;
270 info->logo_height = 0;
271
272 ad->pix_fmt = pixel_format;
273 ad->addr = cpu_to_le32((unsigned int)info->screen_base);
274 ad->src_size_g_alpha
275 = cpu_to_le32((var->yres << 12) | var->xres);
276 /* fix me. AOI should not be greater than display size */
Wolfgang Denka1be4762008-05-20 16:00:29 +0200277 ad->aoi_size = cpu_to_le32(( var->yres << 16) | var->xres);
York Sunb7145172007-10-29 13:58:39 -0500278 ad->offset_xyi = 0;
279 ad->offset_xyd = 0;
280
281 /* Disable chroma keying function */
282 ad->ckmax_r = 0;
283 ad->ckmax_g = 0;
284 ad->ckmax_b = 0;
285
286 ad->ckmin_r = 255;
287 ad->ckmin_g = 255;
288 ad->ckmin_b = 255;
289
290 gamma_table_base = gamma.paddr;
York Sun94cbda92008-05-05 10:20:00 -0500291 debug("gamma_table_base is allocated @ 0x%x\n",
York Sunb7145172007-10-29 13:58:39 -0500292 (unsigned int)gamma_table_base);
293
294 /* Prep for DIU init - gamma table */
295
296 for (i = 0; i <= 2; i++)
297 for (j = 0; j <= 255; j++)
298 *gamma_table_base++ = j;
299
300 if (gamma_fix == 1) { /* fix the gamma */
York Sun94cbda92008-05-05 10:20:00 -0500301 debug("Fix gamma table\n");
York Sunb7145172007-10-29 13:58:39 -0500302 gamma_table_base = gamma.paddr;
303 for (i = 0; i < 256*3; i++) {
304 gamma_table_base[i] = (gamma_table_base[i] << 2)
305 | ((gamma_table_base[i] >> 6) & 0x03);
306 }
307 }
308
York Sun94cbda92008-05-05 10:20:00 -0500309 debug("update-lcdc: HW - %p\n Disabling DIU\n", hw);
York Sunb7145172007-10-29 13:58:39 -0500310
311 /* Program DIU registers */
312
313 hw->gamma = (unsigned int) gamma.paddr;
314 hw->cursor= (unsigned int) cursor.paddr;
315 hw->bgnd = 0x007F7F7F; /* BGND */
Wolfgang Denka1be4762008-05-20 16:00:29 +0200316 hw->bgnd_wb = 0; /* BGND_WB */
York Sunb7145172007-10-29 13:58:39 -0500317 hw->disp_size = var->yres << 16 | var->xres; /* DISP SIZE */
318 hw->wb_size = 0; /* WB SIZE */
319 hw->wb_mem_addr = 0; /* WB MEM ADDR */
320 hw->hsyn_para = var->left_margin << 22 | /* BP_H */
321 var->hsync_len << 11 | /* PW_H */
322 var->right_margin; /* FP_H */
323 hw->vsyn_para = var->upper_margin << 22 | /* BP_V */
324 var->vsync_len << 11 | /* PW_V */
325 var->lower_margin; /* FP_V */
326
York Sunb7145172007-10-29 13:58:39 -0500327 hw->syn_pol = 0; /* SYNC SIGNALS POLARITY */
328 hw->thresholds = 0x00037800; /* The Thresholds */
329 hw->int_status = 0; /* INTERRUPT STATUS */
330 hw->int_mask = 0; /* INT MASK */
331 hw->plut = 0x01F5F666;
332
York Sunc4964382008-05-05 10:19:59 -0500333 /* Pixel Clock configuration */
York Sun94cbda92008-05-05 10:20:00 -0500334 debug("DIU pixclock in ps - %d\n", var->pixclock);
York Sunc4964382008-05-05 10:19:59 -0500335 diu_set_pixel_clock(var->pixclock);
York Sunb7145172007-10-29 13:58:39 -0500336
337 fb_initialized = 1;
338
339 if (splash_bmp) {
340 info->logo_height = fsl_diu_display_bmp(splash_bmp, 0, 0, 0);
341 info->logo_size = info->logo_height * info->line_length;
York Sun94cbda92008-05-05 10:20:00 -0500342 debug("logo height %d, logo_size 0x%x\n",
York Sunb7145172007-10-29 13:58:39 -0500343 info->logo_height,info->logo_size);
344 }
345
346 /* Enable the DIU */
347 fsl_diu_enable_panel(info);
348 enable_lcdc();
349
350 return 0;
351}
352
353char *fsl_fb_open(struct fb_info **info)
354{
355 *info = &fsl_fb_info;
356 return (char *) ((unsigned int)(*info)->screen_base
357 + (*info)->logo_size);
358}
359
360void fsl_diu_close(void)
361{
362 struct fb_info *info = &fsl_fb_info;
363 fsl_diu_disable_panel(info);
364}
365
366static int fsl_diu_enable_panel(struct fb_info *info)
367{
368 struct diu *hw = dr.diu_reg;
369 struct diu_ad *ad = &fsl_diu_fb_ad;
370
York Sun94cbda92008-05-05 10:20:00 -0500371 debug("Entered: enable_panel\n");
York Sunb7145172007-10-29 13:58:39 -0500372 if (hw->desc[0] != (unsigned int)ad)
373 hw->desc[0] = (unsigned int)ad;
York Sun94cbda92008-05-05 10:20:00 -0500374 debug("desc[0] = 0x%x\n", hw->desc[0]);
York Sunb7145172007-10-29 13:58:39 -0500375 return 0;
376}
377
378static int fsl_diu_disable_panel(struct fb_info *info)
379{
380 struct diu *hw = dr.diu_reg;
381
York Sun94cbda92008-05-05 10:20:00 -0500382 debug("Entered: disable_panel\n");
York Sunb7145172007-10-29 13:58:39 -0500383 if (hw->desc[0] != (unsigned int)&dummy_ad)
384 hw->desc[0] = (unsigned int)&dummy_ad;
385 return 0;
386}
387
388static int map_video_memory(struct fb_info *info, unsigned long bytes_align)
389{
390 unsigned long offset;
391 unsigned long mask;
392
York Sun94cbda92008-05-05 10:20:00 -0500393 debug("Entered: map_video_memory\n");
York Sunb7145172007-10-29 13:58:39 -0500394 /* allocate maximum 1280*1024 with 32bpp */
395 info->smem_len = 1280 * 4 *1024 + bytes_align;
York Sun94cbda92008-05-05 10:20:00 -0500396 debug("MAP_VIDEO_MEMORY: smem_len = %d\n", info->smem_len);
York Sunb7145172007-10-29 13:58:39 -0500397 info->screen_base = malloc(info->smem_len);
398 if (info->screen_base == NULL) {
399 printf("Unable to allocate fb memory\n");
400 return -1;
401 }
402 info->smem_start = (unsigned int) info->screen_base;
403 mask = bytes_align - 1;
404 offset = (unsigned long)info->screen_base & mask;
405 if (offset) {
Nikita V. Youshchenko7e6647e2008-10-03 00:03:55 +0400406 info->screen_base += (bytes_align - offset);
York Sunb7145172007-10-29 13:58:39 -0500407 info->smem_len = info->smem_len - (bytes_align - offset);
408 } else
409 info->smem_len = info->smem_len - bytes_align;
410
411 info->screen_size = info->smem_len;
412
York Sun94cbda92008-05-05 10:20:00 -0500413 debug("Allocated fb @ 0x%08lx, size=%d.\n",
York Sunb7145172007-10-29 13:58:39 -0500414 info->smem_start, info->smem_len);
415
416 return 0;
417}
418
419static void enable_lcdc(void)
420{
421 struct diu *hw = dr.diu_reg;
422
York Sun94cbda92008-05-05 10:20:00 -0500423 debug("Entered: enable_lcdc, fb_enabled = %d\n", fb_enabled);
York Sunb7145172007-10-29 13:58:39 -0500424 if (!fb_enabled) {
425 hw->diu_mode = dr.mode;
426 fb_enabled++;
427 }
York Sun94cbda92008-05-05 10:20:00 -0500428 debug("diu_mode = %d\n", hw->diu_mode);
York Sunb7145172007-10-29 13:58:39 -0500429}
430
431static void disable_lcdc(void)
432{
433 struct diu *hw = dr.diu_reg;
434
York Sun94cbda92008-05-05 10:20:00 -0500435 debug("Entered: disable_lcdc, fb_enabled = %d\n", fb_enabled);
York Sunb7145172007-10-29 13:58:39 -0500436 if (fb_enabled) {
437 hw->diu_mode = 0;
438 fb_enabled = 0;
439 }
440}
441
York Sunb7145172007-10-29 13:58:39 -0500442/*
443 * Align to 64-bit(8-byte), 32-byte, etc.
444 */
445static int allocate_buf(struct diu_addr *buf, u32 size, u32 bytes_align)
446{
447 u32 offset, ssize;
448 u32 mask;
449
York Sun94cbda92008-05-05 10:20:00 -0500450 debug("Entered: allocate_buf\n");
York Sunb7145172007-10-29 13:58:39 -0500451 ssize = size + bytes_align;
452 buf->paddr = malloc(ssize);
453 if (!buf->paddr)
454 return -1;
455
456 memset(buf->paddr, 0, ssize);
457 mask = bytes_align - 1;
458 offset = (u32)buf->paddr & mask;
459 if (offset) {
460 buf->offset = bytes_align - offset;
461 buf->paddr = (unsigned char *) ((u32)buf->paddr + offset);
462 } else
463 buf->offset = 0;
464 return 0;
465}
466
467int fsl_diu_display_bmp(unsigned char *bmp,
468 int xoffset,
469 int yoffset,
470 int transpar)
471{
472 struct fb_info *info = &fsl_fb_info;
473 unsigned char r, g, b;
474 unsigned int *fb_t, val;
475 unsigned char *bitmap;
476 unsigned int palette[256];
477 int width, height, bpp, ncolors, raster, offset, x, y, i, k, cpp;
478
479 if (!bmp) {
480 printf("Must supply a bitmap address\n");
481 return 0;
482 }
483
484 raster = bmp[10] + (bmp[11] << 8) + (bmp[12] << 16) + (bmp[13] << 24);
485 width = (bmp[21] << 24) | (bmp[20] << 16) | (bmp[19] << 8) | bmp[18];
486 height = (bmp[25] << 24) | (bmp[24] << 16) | (bmp[23] << 8) | bmp[22];
487 bpp = (bmp[29] << 8) | (bmp[28]);
488 ncolors = bmp[46] + (bmp[47] << 8) + (bmp[48] << 16) + (bmp[49] << 24);
489 bitmap = bmp + raster;
490 cpp = info->var.bits_per_pixel / 8;
491
York Sun94cbda92008-05-05 10:20:00 -0500492 debug("bmp = 0x%08x\n", (unsigned int)bmp);
493 debug("bitmap = 0x%08x\n", (unsigned int)bitmap);
494 debug("width = %d\n", width);
495 debug("height = %d\n", height);
496 debug("bpp = %d\n", bpp);
497 debug("ncolors = %d\n", ncolors);
York Sunb7145172007-10-29 13:58:39 -0500498
York Sun94cbda92008-05-05 10:20:00 -0500499 debug("xres = %d\n", info->var.xres);
500 debug("yres = %d\n", info->var.yres);
501 debug("Screen_base = 0x%x\n", (unsigned int)info->screen_base);
York Sunb7145172007-10-29 13:58:39 -0500502
503 if (((width+xoffset) > info->var.xres) ||
504 ((height+yoffset) > info->var.yres)) {
505 printf("bitmap is out of range, image too large or too much offset\n");
506 return 0;
507 }
508 if (bpp < 24) {
509 for (i = 0, offset = 54; i < ncolors; i++, offset += 4)
510 palette[i] = (bmp[offset+2] << 16)
511 + (bmp[offset+1] << 8) + bmp[offset];
512 }
513
514 switch (bpp) {
515 case 1:
516 for (y = height - 1; y >= 0; y--) {
517 fb_t = (unsigned int *) ((unsigned int)info->screen_base + (((y+yoffset) * info->var.xres) + xoffset)*cpp);
518 for (x = 0; x < width; x += 8) {
519 b = *bitmap++;
520 for (k = 0; k < 8; k++) {
521 if (b & 0x80)
522 *fb_t = palette[1];
523 else
524 *fb_t = palette[0];
525 b = b << 1;
526 }
527 }
528 for (i = (width / 2) % 4; i > 0; i--)
529 bitmap++;
530 }
531 break;
532 case 4:
533 for (y = height - 1; y >= 0; y--) {
534 fb_t = (unsigned int *) ((unsigned int)info->screen_base + (((y+yoffset) * info->var.xres) + xoffset)*cpp);
535 for (x = 0; x < width; x += 2) {
536 b = *bitmap++;
537 r = (b >> 4) & 0x0F;
538 g = b & 0x0F;
539 *fb_t++ = palette[r];
540 *fb_t++ = palette[g];
541 }
542 for (i = (width / 2) % 4; i > 0; i--)
543 bitmap++;
544 }
545 break;
546 case 8:
547 for (y = height - 1; y >= 0; y--) {
548 fb_t = (unsigned int *) ((unsigned int)info->screen_base + (((y+yoffset) * info->var.xres) + xoffset)*cpp);
549 for (x = 0; x < width; x++) {
550 *fb_t++ = palette[ *bitmap++ ];
551 }
552 for (i = (width / 2) % 4; i > 0; i--)
553 bitmap++;
554 }
555 break;
556 case 24:
557 for (y = height - 1; y >= 0; y--) {
558 fb_t = (unsigned int *) ((unsigned int)info->screen_base + (((y+yoffset) * info->var.xres) + xoffset)*cpp);
559 for (x = 0; x < width; x++) {
560 b = *bitmap++;
561 g = *bitmap++;
562 r = *bitmap++;
563 val = (r << 16) + (g << 8) + b;
564 *fb_t++ = val;
565 }
566 for (; (x % 4) != 0; x++) /* 4-byte alignment */
567 bitmap++;
568 }
569 break;
570 }
571
572 return height;
573}
574
575void fsl_diu_clear_screen(void)
576{
577 struct fb_info *info = &fsl_fb_info;
578
579 memset(info->screen_base, 0, info->smem_len);
580}