blob: 532ec100988c09d1b6223187e947e3da1e1cd8df [file] [log] [blame]
Dima Zavind5b0b6a2009-01-15 18:09:25 -08001/*
2 * Copyright (c) 2008, Google Inc.
3 * All rights reserved.
4 *
Channagoud Kadabi7af9fbc2015-02-13 20:09:55 -08005 * Copyright (c) 2009-2015, The Linux Foundation. All rights reserved.
Shashank Mittal4f99a882010-02-01 13:58:50 -08006 *
Dima Zavind5b0b6a2009-01-15 18:09:25 -08007 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
24 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
25 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
27 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 */
30
31#include <debug.h>
32#include <err.h>
33#include <stdlib.h>
34#include <dev/fbcon.h>
Chandan Uddaraju40b227d2010-08-03 19:25:41 -070035#include <splash.h>
Greg Griscod6250552011-06-29 14:40:23 -070036#include <platform.h>
37#include <string.h>
Channagoud Kadabi7af9fbc2015-02-13 20:09:55 -080038#include <arch/ops.h>
Channagoud Kadabi875a2a72015-04-24 17:26:38 -070039#if ENABLE_WBC
40#include <pm_app_smbchg.h>
41#endif
Dima Zavind5b0b6a2009-01-15 18:09:25 -080042
43#include "font5x12.h"
44
45struct pos {
46 int x;
47 int y;
48};
49
lijuangdd73d652015-06-05 21:29:37 +080050struct fb_color {
51 uint32_t fg;
52 uint32_t bg;
53};
54
Dima Zavind5b0b6a2009-01-15 18:09:25 -080055static struct fbcon_config *config = NULL;
56
Chandan Uddaraju2943fd62010-06-21 10:56:39 -070057#define RGB565_BLACK 0x0000
Dima Zavind5b0b6a2009-01-15 18:09:25 -080058#define RGB565_WHITE 0xffff
lijuangdd73d652015-06-05 21:29:37 +080059#define RGB565_CYAN 0x07ff
60#define RGB565_BLUE 0x001f
61#define RGB565_SILVER 0xc618
62#define RGB565_YELLOW 0xffe0
63#define RGB565_ORANGE 0xfd20
64#define RGB565_RED 0xf800
Dima Zavind5b0b6a2009-01-15 18:09:25 -080065
Chandan Uddaraju78ae6752010-10-19 12:57:10 -070066#define RGB888_BLACK 0x000000
67#define RGB888_WHITE 0xffffff
lijuangdd73d652015-06-05 21:29:37 +080068#define RGB888_CYAN 0x00ffff
69#define RGB888_BLUE 0x0000FF
70#define RGB888_SILVER 0xc0c0c0
71#define RGB888_YELLOW 0xffff00
72#define RGB888_ORANGE 0xffa500
73#define RGB888_RED 0xff0000
Chandan Uddaraju78ae6752010-10-19 12:57:10 -070074
Dima Zavind5b0b6a2009-01-15 18:09:25 -080075#define FONT_WIDTH 5
76#define FONT_HEIGHT 12
77
Sandeep Pandadf39f752015-05-08 14:01:16 +053078#define SCALE_FACTOR 2
79
80static uint32_t BGCOLOR;
81static uint32_t FGCOLOR;
lijuangdd73d652015-06-05 21:29:37 +080082static uint32_t SELECT_BGCOLOR;
Dima Zavind5b0b6a2009-01-15 18:09:25 -080083
84static struct pos cur_pos;
85static struct pos max_pos;
lijuangdd73d652015-06-05 21:29:37 +080086static struct fb_color *fb_color_formats;
87static struct fb_color fb_color_formats_555[] = {
88 [FBCON_COMMON_MSG] = {RGB565_WHITE, RGB565_BLACK},
89 [FBCON_UNLOCK_TITLE_MSG] = {RGB565_CYAN, RGB565_BLACK},
90 [FBCON_TITLE_MSG] = {RGB565_WHITE, RGB565_BLACK},
91 [FBCON_SUBTITLE_MSG] = {RGB565_SILVER, RGB565_BLACK},
92 [FBCON_YELLOW_MSG] = {RGB565_YELLOW, RGB565_BLACK},
93 [FBCON_ORANGE_MSG] = {RGB565_ORANGE, RGB565_BLACK},
94 [FBCON_RED_MSG] = {RGB565_RED, RGB565_BLACK},
95 [FBCON_LINE_COLOR] = {RGB565_WHITE, RGB565_WHITE},
96 [FBCON_SELECT_MSG_BG_COLOR] = {RGB565_WHITE, RGB565_BLUE}};
97
98static struct fb_color fb_color_formats_888[] = {
99 [FBCON_COMMON_MSG] = {RGB888_WHITE, RGB888_BLACK},
100 [FBCON_UNLOCK_TITLE_MSG] = {RGB888_CYAN, RGB888_BLACK},
101 [FBCON_TITLE_MSG] = {RGB888_WHITE, RGB888_BLACK},
102 [FBCON_SUBTITLE_MSG] = {RGB888_SILVER, RGB888_BLACK},
103 [FBCON_YELLOW_MSG] = {RGB888_YELLOW, RGB888_BLACK},
104 [FBCON_ORANGE_MSG] = {RGB888_ORANGE, RGB888_BLACK},
105 [FBCON_RED_MSG] = {RGB888_RED, RGB888_BLACK},
106 [FBCON_LINE_COLOR] = {RGB888_WHITE, RGB888_WHITE},
107 [FBCON_SELECT_MSG_BG_COLOR] = {RGB888_WHITE, RGB888_BLUE}};
108
Dima Zavind5b0b6a2009-01-15 18:09:25 -0800109
Sandeep Pandadf39f752015-05-08 14:01:16 +0530110static void fbcon_drawglyph(char *pixels, uint32_t paint, unsigned stride,
lijuangdd73d652015-06-05 21:29:37 +0800111 unsigned bpp, unsigned *glyph, unsigned scale_factor)
Dima Zavind5b0b6a2009-01-15 18:09:25 -0800112{
Sandeep Pandadf39f752015-05-08 14:01:16 +0530113 unsigned x, y, i, j, k;
114 unsigned data, temp;
115 uint32_t fg_color = paint;
lijuangdd73d652015-06-05 21:29:37 +0800116 stride -= FONT_WIDTH * scale_factor;
Dima Zavind5b0b6a2009-01-15 18:09:25 -0800117
118 data = glyph[0];
Sandeep Pandadf39f752015-05-08 14:01:16 +0530119 for (y = 0; y < FONT_HEIGHT / 2; ++y) {
120 temp = data;
lijuangdd73d652015-06-05 21:29:37 +0800121 for (i = 0; i < scale_factor; i++) {
Sandeep Pandadf39f752015-05-08 14:01:16 +0530122 data = temp;
123 for (x = 0; x < FONT_WIDTH; ++x) {
124 if (data & 1) {
lijuangdd73d652015-06-05 21:29:37 +0800125 for (j = 0; j < scale_factor; j++) {
Sandeep Pandadf39f752015-05-08 14:01:16 +0530126 fg_color = paint;
127 for (k = 0; k < bpp; k++) {
128 *pixels = (unsigned char) fg_color;
129 fg_color = fg_color >> 8;
130 pixels++;
131 }
132 }
133 }
134 else
135 {
lijuangdd73d652015-06-05 21:29:37 +0800136 for (j = 0; j < scale_factor; j++) {
Sandeep Pandadf39f752015-05-08 14:01:16 +0530137 pixels = pixels + bpp;
138 }
139 }
140 data >>= 1;
141 }
142 pixels += (stride * bpp);
Dima Zavind5b0b6a2009-01-15 18:09:25 -0800143 }
Dima Zavind5b0b6a2009-01-15 18:09:25 -0800144 }
145
146 data = glyph[1];
Sandeep Pandadf39f752015-05-08 14:01:16 +0530147 for (y = 0; y < FONT_HEIGHT / 2; ++y) {
148 temp = data;
lijuangdd73d652015-06-05 21:29:37 +0800149 for (i = 0; i < scale_factor; i++) {
Sandeep Pandadf39f752015-05-08 14:01:16 +0530150 data = temp;
151 for (x = 0; x < FONT_WIDTH; ++x) {
152 if (data & 1) {
lijuangdd73d652015-06-05 21:29:37 +0800153 for (j = 0; j < scale_factor; j++) {
Sandeep Pandadf39f752015-05-08 14:01:16 +0530154 fg_color = paint;
155 for (k = 0; k < bpp; k++) {
156 *pixels = (unsigned char) fg_color;
157 fg_color = fg_color >> 8;
158 pixels++;
159 }
160 }
161 }
162 else
163 {
lijuangdd73d652015-06-05 21:29:37 +0800164 for (j = 0; j < scale_factor; j++) {
Sandeep Pandadf39f752015-05-08 14:01:16 +0530165 pixels = pixels + bpp;
166 }
167 }
168 data >>= 1;
169 }
170 pixels += (stride * bpp);
Dima Zavind5b0b6a2009-01-15 18:09:25 -0800171 }
Dima Zavind5b0b6a2009-01-15 18:09:25 -0800172 }
Sandeep Pandadf39f752015-05-08 14:01:16 +0530173
Dima Zavind5b0b6a2009-01-15 18:09:25 -0800174}
175
lijuangdd73d652015-06-05 21:29:37 +0800176void fbcon_draw_msg_background(unsigned y_start, unsigned y_end,
177 uint32_t old_paint, int update)
178{
179 unsigned i, j;
180 uint32_t bg_color, check_color, tmp_color, tmp1_color;
181 char *pixels;
182 unsigned count = config->width * (FONT_HEIGHT * (y_end - y_start) - 1);
183
184 pixels = config->base;
185 pixels += y_start * ((config->bpp / 8) * FONT_HEIGHT * config->width);
186
187 if (update) {
188 bg_color = SELECT_BGCOLOR;
189 check_color = old_paint;
190 } else {
191 bg_color = old_paint;
192 check_color = SELECT_BGCOLOR;
193 }
194
195 for (i = 0; i < count; i++) {
196 tmp1_color = bg_color;
197 tmp_color = 0;
198 for (j = 0; j < (config->bpp / 8); j++) {
199 tmp_color |= *(pixels+j) << j*8;
200 }
201
202 if (tmp_color == check_color) {
203 for (j = 0; j < (config->bpp / 8); j++) {
204 *pixels = (unsigned char) tmp1_color;
205 tmp1_color = tmp1_color >> 8;
206 pixels++;
207 }
208 } else {
209 pixels += config->bpp / 8;
210 }
211 }
212}
213
Dima Zavin25ed9942009-01-28 17:04:19 -0800214static void fbcon_flush(void)
215{
Mao Flynn7b379f32015-04-20 00:28:30 +0800216 unsigned total_x, total_y;
217 unsigned bytes_per_bpp;
218
Dima Zavin25ed9942009-01-28 17:04:19 -0800219 if (config->update_start)
220 config->update_start();
221 if (config->update_done)
222 while (!config->update_done());
Mao Flynn7b379f32015-04-20 00:28:30 +0800223
224 total_x = config->width;
225 total_y = config->height;
226 bytes_per_bpp = ((config->bpp) / 8);
227 arch_clean_invalidate_cache_range((addr_t) config->base, (total_x * total_y * bytes_per_bpp));
Dima Zavin25ed9942009-01-28 17:04:19 -0800228}
229
Dima Zavind5b0b6a2009-01-15 18:09:25 -0800230/* TODO: Take stride into account */
231static void fbcon_scroll_up(void)
232{
233 unsigned short *dst = config->base;
234 unsigned short *src = dst + (config->width * FONT_HEIGHT);
235 unsigned count = config->width * (config->height - FONT_HEIGHT);
236
237 while(count--) {
238 *dst++ = *src++;
239 }
240
241 count = config->width * FONT_HEIGHT;
242 while(count--) {
243 *dst++ = BGCOLOR;
244 }
Dima Zavin25ed9942009-01-28 17:04:19 -0800245
246 fbcon_flush();
Dima Zavind5b0b6a2009-01-15 18:09:25 -0800247}
248
lijuangdd73d652015-06-05 21:29:37 +0800249void fbcon_draw_line()
250{
251 char *pixels;
252 uint32_t bg_color, tmp_color;
253 int i, j;
254
255 bg_color = fb_color_formats[FBCON_LINE_COLOR].bg;
256
257 pixels = config->base;
258 pixels += cur_pos.y * ((config->bpp / 8) * FONT_HEIGHT * config->width);
259 pixels += cur_pos.x * ((config->bpp / 8) * (FONT_WIDTH + 1));
260
261 for (i = 0; i < (int)config->width; i++) {
262 tmp_color = bg_color;
263 for (j = 0; j < (int)(config->bpp / 8); j++) {
264 *pixels = (unsigned char) tmp_color;
265 tmp_color = tmp_color >> 8;
266 pixels++;
267 }
268 }
269
270 cur_pos.y += 1;
271 cur_pos.x = 0;
272 if(cur_pos.y >= max_pos.y) {
273 cur_pos.y = max_pos.y - 1;
274 fbcon_scroll_up();
275 } else
276 fbcon_flush();
277}
278
279static void fbcon_set_colors(int type)
280{
281 BGCOLOR = fb_color_formats[type].bg;
282 FGCOLOR = fb_color_formats[type].fg;
283}
284
Shashank Mittal4f99a882010-02-01 13:58:50 -0800285void fbcon_clear(void)
Dima Zavind5b0b6a2009-01-15 18:09:25 -0800286{
Sandeep Pandadf39f752015-05-08 14:01:16 +0530287 unsigned long i = 0, j = 0;
288 unsigned char *pixels = config->base;
Dima Zavind5b0b6a2009-01-15 18:09:25 -0800289 unsigned count = config->width * config->height;
Sandeep Pandadf39f752015-05-08 14:01:16 +0530290 uint32_t bg_color;
lijuangdd73d652015-06-05 21:29:37 +0800291
292 fbcon_set_colors(FBCON_COMMON_MSG);
Sandeep Pandadf39f752015-05-08 14:01:16 +0530293 for (i = 0; i < count; i++) {
294 bg_color = BGCOLOR;
295 for (j = 0; j < (config->bpp / 8); j++) {
296 *pixels = (unsigned char) bg_color;
297 bg_color = bg_color >> 8;
298 pixels++;
299 }
300 }
lijuangdd73d652015-06-05 21:29:37 +0800301 cur_pos.x = 0;
302 cur_pos.y = 0;
Dima Zavind5b0b6a2009-01-15 18:09:25 -0800303}
304
lijuangdd73d652015-06-05 21:29:37 +0800305void fbcon_putc_factor(char c, int type, unsigned scale_factor)
Dima Zavind5b0b6a2009-01-15 18:09:25 -0800306{
Sandeep Pandadf39f752015-05-08 14:01:16 +0530307 char *pixels;
Dima Zavind5b0b6a2009-01-15 18:09:25 -0800308
309 /* ignore anything that happens before fbcon is initialized */
310 if (!config)
311 return;
312
313 if((unsigned char)c > 127)
314 return;
Sandeep Pandadf39f752015-05-08 14:01:16 +0530315
Dima Zavind5b0b6a2009-01-15 18:09:25 -0800316 if((unsigned char)c < 32) {
317 if(c == '\n')
318 goto newline;
Sandeep Pandadf39f752015-05-08 14:01:16 +0530319 else if (c == '\r') {
Dima Zavind5b0b6a2009-01-15 18:09:25 -0800320 cur_pos.x = 0;
Sandeep Pandadf39f752015-05-08 14:01:16 +0530321 return;
322 }
323 else
324 return;
Dima Zavind5b0b6a2009-01-15 18:09:25 -0800325 }
326
lijuangdd73d652015-06-05 21:29:37 +0800327 if (cur_pos.x == 0 && (unsigned char)c == ' ' &&
328 type != FBCON_SUBTITLE_MSG &&
329 type != FBCON_TITLE_MSG)
Dima Zavind5b0b6a2009-01-15 18:09:25 -0800330 return;
331
lijuangdd73d652015-06-05 21:29:37 +0800332 fbcon_set_colors(type);
333
334 pixels = config->base;
335 pixels += cur_pos.y * ((config->bpp / 8) * FONT_HEIGHT * config->width);
336 pixels += cur_pos.x * scale_factor * ((config->bpp / 8) * (FONT_WIDTH + 1));
337
338 fbcon_drawglyph(pixels, FGCOLOR, config->stride, (config->bpp / 8),
339 font5x12 + (c - 32) * 2, scale_factor);
340
341 cur_pos.x++;
342 if (cur_pos.x >= (int)(max_pos.x / scale_factor))
343 goto newline;
344
345 return;
346
Dima Zavind5b0b6a2009-01-15 18:09:25 -0800347newline:
lijuangdd73d652015-06-05 21:29:37 +0800348 cur_pos.y += scale_factor;
Dima Zavind5b0b6a2009-01-15 18:09:25 -0800349 cur_pos.x = 0;
350 if(cur_pos.y >= max_pos.y) {
351 cur_pos.y = max_pos.y - 1;
352 fbcon_scroll_up();
Dima Zavin25ed9942009-01-28 17:04:19 -0800353 } else
354 fbcon_flush();
Dima Zavind5b0b6a2009-01-15 18:09:25 -0800355}
356
lijuangdd73d652015-06-05 21:29:37 +0800357void fbcon_putc(char c)
358{
359 fbcon_putc_factor(c, FBCON_COMMON_MSG, SCALE_FACTOR);
360}
361
362uint32_t fbcon_get_current_line(void)
363{
364 return cur_pos.y;
365}
366
367uint32_t fbcon_get_max_x(void)
368{
369 return max_pos.x;
370}
371
372uint32_t fbcon_get_current_bg(void)
373{
374 return BGCOLOR;
375}
376
Dima Zavind5b0b6a2009-01-15 18:09:25 -0800377void fbcon_setup(struct fbcon_config *_config)
378{
Dima Zavind5b0b6a2009-01-15 18:09:25 -0800379 ASSERT(_config);
380
381 config = _config;
382
383 switch (config->format) {
384 case FB_FORMAT_RGB565:
lijuangdd73d652015-06-05 21:29:37 +0800385 fb_color_formats = fb_color_formats_555;
Dima Zavind5b0b6a2009-01-15 18:09:25 -0800386 break;
lijuangdd73d652015-06-05 21:29:37 +0800387 case FB_FORMAT_RGB888:
388 fb_color_formats = fb_color_formats_888;
389 break;
Dima Zavind5b0b6a2009-01-15 18:09:25 -0800390 default:
391 dprintf(CRITICAL, "unknown framebuffer pixel format\n");
392 ASSERT(0);
393 break;
394 }
395
lijuangdd73d652015-06-05 21:29:37 +0800396 SELECT_BGCOLOR = fb_color_formats[FBCON_SELECT_MSG_BG_COLOR].bg;
397 fbcon_set_colors(FBCON_COMMON_MSG);
Dima Zavind5b0b6a2009-01-15 18:09:25 -0800398
Dima Zavind5b0b6a2009-01-15 18:09:25 -0800399 cur_pos.x = 0;
400 cur_pos.y = 0;
lijuangdd73d652015-06-05 21:29:37 +0800401 max_pos.x = config->width / (FONT_WIDTH+1);
Dima Zavind5b0b6a2009-01-15 18:09:25 -0800402 max_pos.y = (config->height - 1) / FONT_HEIGHT;
lijuangdd73d652015-06-05 21:29:37 +0800403
Shashank Mittal37040832010-08-24 15:57:57 -0700404#if !DISPLAY_SPLASH_SCREEN
405 fbcon_clear();
406#endif
lijuangdd73d652015-06-05 21:29:37 +0800407
Dima Zavind5b0b6a2009-01-15 18:09:25 -0800408}
Shashank Mittal4f99a882010-02-01 13:58:50 -0800409
410struct fbcon_config* fbcon_display(void)
411{
Mao Flynn7b379f32015-04-20 00:28:30 +0800412 return config;
Shashank Mittal4f99a882010-02-01 13:58:50 -0800413}
Chandan Uddaraju40b227d2010-08-03 19:25:41 -0700414
Mao Flynn7b379f32015-04-20 00:28:30 +0800415void fbcon_extract_to_screen(logo_img_header *header, void* address)
Aparna Mallavarapuce06a012013-09-06 23:03:24 +0530416{
Mao Flynn7b379f32015-04-20 00:28:30 +0800417 const uint8_t *imagestart = (const uint8_t *)address;
418 uint pos = 0, offset;
419 uint count = 0;
420 uint x = 0, y = 0;
421 uint8_t *base, *p;
Aparna Mallavarapuce06a012013-09-06 23:03:24 +0530422
Mao Flynn7b379f32015-04-20 00:28:30 +0800423 if (!config || header->width > config->width
424 || header->height > config->height) {
425 dprintf(INFO, "the logo img is too large\n");
426 return;
Aparna Mallavarapuce06a012013-09-06 23:03:24 +0530427 }
428
Mao Flynn7b379f32015-04-20 00:28:30 +0800429 base = (uint8_t *) config->base;
430
431 /* put the logo to be center */
432 offset = (config->height - header->height) / 2;
433 if (offset)
434 base += (offset * config->width) * 3;
435 offset = (config->width - header->width ) / 2;
436
437 x = offset;
438 while (count < (uint)header->height * (uint)header->width) {
439 uint8_t run = *(imagestart + pos);
440 bool repeat_run = (run & 0x80);
441 uint runlen = (run & 0x7f) + 1;
442 uint runpos;
443
444 /* consume the run byte */
445 pos++;
446
447 p = base + (y * config->width + x) * 3;
448
449 /* start of a run */
450 for (runpos = 0; runpos < runlen; runpos++) {
451 *p++ = *(imagestart + pos);
452 *p++ = *(imagestart + pos + 1);
453 *p++ = *(imagestart + pos + 2);
454 count++;
455
456 x++;
457
458 /* if a run of raw pixels, consume an input pixel */
459 if (!repeat_run)
460 pos += 3;
461 }
462
463 /* if this was a run of repeated pixels, consume the one input pixel we repeated */
464 if (repeat_run)
465 pos += 3;
466
467 /* the generator will keep compressing data line by line */
468 /* don't cross the lines */
469 if (x == header->width + offset) {
470 y++;
471 x = offset;
472 }
473 }
474
Aparna Mallavarapuce06a012013-09-06 23:03:24 +0530475}
476
Mao Flynn7b379f32015-04-20 00:28:30 +0800477void display_default_image_on_screen(void)
Chandan Uddaraju40b227d2010-08-03 19:25:41 -0700478{
Mao Flynn7b379f32015-04-20 00:28:30 +0800479 unsigned i = 0;
480 unsigned total_x;
481 unsigned total_y;
482 unsigned bytes_per_bpp;
483 unsigned image_base;
Channagoud Kadabi875a2a72015-04-24 17:26:38 -0700484#if DISPLAY_TYPE_MIPI
485 char *image = NULL;
486#endif
Channagoud Kadabi956cf502012-03-08 03:49:50 +0530487
Aparna Mallavarapuce06a012013-09-06 23:03:24 +0530488 if (!config) {
489 dprintf(CRITICAL,"NULL configuration, image cannot be displayed\n");
490 return;
491 }
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700492
Mao Flynn7b379f32015-04-20 00:28:30 +0800493 fbcon_clear(); // clear screen with Black color
Aparna Mallavarapuce06a012013-09-06 23:03:24 +0530494
495 total_x = config->width;
496 total_y = config->height;
497 bytes_per_bpp = ((config->bpp) / 8);
Mao Flynn7b379f32015-04-20 00:28:30 +0800498 image_base = ((((total_y/2) - (SPLASH_IMAGE_HEIGHT / 2) - 1) *
499 (config->width)) + (total_x/2 - (SPLASH_IMAGE_WIDTH / 2)));
Channagoud Kadabi956cf502012-03-08 03:49:50 +0530500
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700501#if DISPLAY_TYPE_MIPI
Channagoud Kadabi875a2a72015-04-24 17:26:38 -0700502#if ENABLE_WBC
503 image = (pm_appsbl_charging_in_progress() ? image_batt888 : imageBuffer_rgb888);
504#else
505 image = imageBuffer_rgb888;
506#endif
507
Mao Flynn7b379f32015-04-20 00:28:30 +0800508 if (bytes_per_bpp == 3) {
509 for (i = 0; i < SPLASH_IMAGE_HEIGHT; i++) {
Aparna Mallavarapuce06a012013-09-06 23:03:24 +0530510 memcpy (config->base + ((image_base + (i * (config->width))) * bytes_per_bpp),
Channagoud Kadabi875a2a72015-04-24 17:26:38 -0700511 image + (i * SPLASH_IMAGE_WIDTH * bytes_per_bpp),
Mao Flynn7b379f32015-04-20 00:28:30 +0800512 SPLASH_IMAGE_WIDTH * bytes_per_bpp);
Aparna Mallavarapuce06a012013-09-06 23:03:24 +0530513 }
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700514 }
Aparna Mallavarapuce06a012013-09-06 23:03:24 +0530515 fbcon_flush();
Kinson Chike5c93432011-06-17 09:10:29 -0700516#if DISPLAY_MIPI_PANEL_NOVATEK_BLUE
Aparna Mallavarapuce06a012013-09-06 23:03:24 +0530517 if(is_cmd_mode_enabled())
Mao Flynn7b379f32015-04-20 00:28:30 +0800518 mipi_dsi_cmd_mode_trigger();
Kinson Chike5c93432011-06-17 09:10:29 -0700519#endif
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800520
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700521#else
Zohaib Alam03708752014-10-23 17:51:57 -0400522
Mao Flynn7b379f32015-04-20 00:28:30 +0800523 if (bytes_per_bpp == 2) {
524 for (i = 0; i < SPLASH_IMAGE_HEIGHT; i++) {
525 memcpy (config->base + ((image_base + (i * (config->width))) * bytes_per_bpp),
526 imageBuffer + (i * SPLASH_IMAGE_WIDTH * bytes_per_bpp),
527 SPLASH_IMAGE_WIDTH * bytes_per_bpp);
Zohaib Alam03708752014-10-23 17:51:57 -0400528 }
529 }
530 fbcon_flush();
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800531#endif
Chandan Uddaraju40b227d2010-08-03 19:25:41 -0700532}
Mao Flynn7b379f32015-04-20 00:28:30 +0800533
534
535void display_image_on_screen(void)
536{
537#if DISPLAY_TYPE_MIPI
538 int fetch_image_from_partition();
539
540 if (fetch_image_from_partition() < 0) {
541 display_default_image_on_screen();
542 } else {
543 /* data has been put into the right place */
544 fbcon_flush();
545 }
546#else
547 display_default_image_on_screen();
548#endif
549}