Dima Zavin | d5b0b6a | 2009-01-15 18:09:25 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2008, Google Inc. |
| 3 | * All rights reserved. |
| 4 | * |
Monika Singh | b879e49 | 2019-09-16 16:00:15 +0530 | [diff] [blame] | 5 | * Copyright (c) 2009-2015, 2018, 2019 The Linux Foundation. All rights reserved. |
Shashank Mittal | 4f99a88 | 2010-02-01 13:58:50 -0800 | [diff] [blame] | 6 | * |
Dima Zavin | d5b0b6a | 2009-01-15 18:09:25 -0800 | [diff] [blame] | 7 | * 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 |
lijuang | 7cfbfe3 | 2018-02-06 17:09:13 +0800 | [diff] [blame] | 24 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
Dima Zavin | d5b0b6a | 2009-01-15 18:09:25 -0800 | [diff] [blame] | 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 Uddaraju | 40b227d | 2010-08-03 19:25:41 -0700 | [diff] [blame] | 35 | #include <splash.h> |
Greg Grisco | d625055 | 2011-06-29 14:40:23 -0700 | [diff] [blame] | 36 | #include <platform.h> |
| 37 | #include <string.h> |
Channagoud Kadabi | 7af9fbc | 2015-02-13 20:09:55 -0800 | [diff] [blame] | 38 | #include <arch/ops.h> |
Channagoud Kadabi | 875a2a7 | 2015-04-24 17:26:38 -0700 | [diff] [blame] | 39 | #if ENABLE_WBC |
Umang Chheda | 4c140de | 2019-12-19 14:30:38 +0530 | [diff] [blame] | 40 | #include <pm_smbchg_common.h> |
Channagoud Kadabi | 875a2a7 | 2015-04-24 17:26:38 -0700 | [diff] [blame] | 41 | #endif |
Dima Zavin | d5b0b6a | 2009-01-15 18:09:25 -0800 | [diff] [blame] | 42 | |
| 43 | #include "font5x12.h" |
| 44 | |
| 45 | struct pos { |
| 46 | int x; |
| 47 | int y; |
| 48 | }; |
| 49 | |
lijuang | dd73d65 | 2015-06-05 21:29:37 +0800 | [diff] [blame] | 50 | struct fb_color { |
| 51 | uint32_t fg; |
| 52 | uint32_t bg; |
| 53 | }; |
| 54 | |
Dima Zavin | d5b0b6a | 2009-01-15 18:09:25 -0800 | [diff] [blame] | 55 | static struct fbcon_config *config = NULL; |
| 56 | |
Chandan Uddaraju | 2943fd6 | 2010-06-21 10:56:39 -0700 | [diff] [blame] | 57 | #define RGB565_BLACK 0x0000 |
Dima Zavin | d5b0b6a | 2009-01-15 18:09:25 -0800 | [diff] [blame] | 58 | #define RGB565_WHITE 0xffff |
lijuang | dd73d65 | 2015-06-05 21:29:37 +0800 | [diff] [blame] | 59 | #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 |
lijuang | 4304fce | 2015-08-14 20:52:47 +0800 | [diff] [blame] | 65 | #define RGB565_GREEN 0x3666 |
Dima Zavin | d5b0b6a | 2009-01-15 18:09:25 -0800 | [diff] [blame] | 66 | |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 67 | #define RGB888_BLACK 0x000000 |
| 68 | #define RGB888_WHITE 0xffffff |
lijuang | dd73d65 | 2015-06-05 21:29:37 +0800 | [diff] [blame] | 69 | #define RGB888_CYAN 0x00ffff |
| 70 | #define RGB888_BLUE 0x0000FF |
| 71 | #define RGB888_SILVER 0xc0c0c0 |
| 72 | #define RGB888_YELLOW 0xffff00 |
| 73 | #define RGB888_ORANGE 0xffa500 |
| 74 | #define RGB888_RED 0xff0000 |
lijuang | 4304fce | 2015-08-14 20:52:47 +0800 | [diff] [blame] | 75 | #define RGB888_GREEN 0x00ff00 |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 76 | |
Dima Zavin | d5b0b6a | 2009-01-15 18:09:25 -0800 | [diff] [blame] | 77 | #define FONT_WIDTH 5 |
| 78 | #define FONT_HEIGHT 12 |
| 79 | |
Sandeep Panda | df39f75 | 2015-05-08 14:01:16 +0530 | [diff] [blame] | 80 | #define SCALE_FACTOR 2 |
| 81 | |
| 82 | static uint32_t BGCOLOR; |
| 83 | static uint32_t FGCOLOR; |
lijuang | dd73d65 | 2015-06-05 21:29:37 +0800 | [diff] [blame] | 84 | static uint32_t SELECT_BGCOLOR; |
Dima Zavin | d5b0b6a | 2009-01-15 18:09:25 -0800 | [diff] [blame] | 85 | |
| 86 | static struct pos cur_pos; |
| 87 | static struct pos max_pos; |
lijuang | dd73d65 | 2015-06-05 21:29:37 +0800 | [diff] [blame] | 88 | static struct fb_color *fb_color_formats; |
| 89 | static struct fb_color fb_color_formats_555[] = { |
| 90 | [FBCON_COMMON_MSG] = {RGB565_WHITE, RGB565_BLACK}, |
lijuang | f3d7fc5 | 2018-04-23 16:34:29 +0800 | [diff] [blame] | 91 | [FBCON_UNLOCK_TITLE_MSG] = {RGB565_RED, RGB565_BLACK}, |
lijuang | dd73d65 | 2015-06-05 21:29:37 +0800 | [diff] [blame] | 92 | [FBCON_TITLE_MSG] = {RGB565_WHITE, RGB565_BLACK}, |
| 93 | [FBCON_SUBTITLE_MSG] = {RGB565_SILVER, RGB565_BLACK}, |
| 94 | [FBCON_YELLOW_MSG] = {RGB565_YELLOW, RGB565_BLACK}, |
| 95 | [FBCON_ORANGE_MSG] = {RGB565_ORANGE, RGB565_BLACK}, |
| 96 | [FBCON_RED_MSG] = {RGB565_RED, RGB565_BLACK}, |
lijuang | 4304fce | 2015-08-14 20:52:47 +0800 | [diff] [blame] | 97 | [FBCON_GREEN_MSG] = {RGB565_GREEN, RGB565_BLACK}, |
lijuang | dd73d65 | 2015-06-05 21:29:37 +0800 | [diff] [blame] | 98 | [FBCON_SELECT_MSG_BG_COLOR] = {RGB565_WHITE, RGB565_BLUE}}; |
| 99 | |
| 100 | static struct fb_color fb_color_formats_888[] = { |
| 101 | [FBCON_COMMON_MSG] = {RGB888_WHITE, RGB888_BLACK}, |
lijuang | f3d7fc5 | 2018-04-23 16:34:29 +0800 | [diff] [blame] | 102 | [FBCON_UNLOCK_TITLE_MSG] = {RGB888_RED, RGB888_BLACK}, |
lijuang | dd73d65 | 2015-06-05 21:29:37 +0800 | [diff] [blame] | 103 | [FBCON_TITLE_MSG] = {RGB888_WHITE, RGB888_BLACK}, |
| 104 | [FBCON_SUBTITLE_MSG] = {RGB888_SILVER, RGB888_BLACK}, |
| 105 | [FBCON_YELLOW_MSG] = {RGB888_YELLOW, RGB888_BLACK}, |
| 106 | [FBCON_ORANGE_MSG] = {RGB888_ORANGE, RGB888_BLACK}, |
| 107 | [FBCON_RED_MSG] = {RGB888_RED, RGB888_BLACK}, |
lijuang | 4304fce | 2015-08-14 20:52:47 +0800 | [diff] [blame] | 108 | [FBCON_GREEN_MSG] = {RGB888_GREEN, RGB888_BLACK}, |
lijuang | dd73d65 | 2015-06-05 21:29:37 +0800 | [diff] [blame] | 109 | [FBCON_SELECT_MSG_BG_COLOR] = {RGB888_WHITE, RGB888_BLUE}}; |
| 110 | |
Dima Zavin | d5b0b6a | 2009-01-15 18:09:25 -0800 | [diff] [blame] | 111 | |
lijuang | b3812fb | 2015-12-16 15:42:02 +0800 | [diff] [blame] | 112 | static void fbcon_flush(void); |
| 113 | |
Sandeep Panda | df39f75 | 2015-05-08 14:01:16 +0530 | [diff] [blame] | 114 | static void fbcon_drawglyph(char *pixels, uint32_t paint, unsigned stride, |
lijuang | dd73d65 | 2015-06-05 21:29:37 +0800 | [diff] [blame] | 115 | unsigned bpp, unsigned *glyph, unsigned scale_factor) |
Dima Zavin | d5b0b6a | 2009-01-15 18:09:25 -0800 | [diff] [blame] | 116 | { |
Sandeep Panda | df39f75 | 2015-05-08 14:01:16 +0530 | [diff] [blame] | 117 | unsigned x, y, i, j, k; |
| 118 | unsigned data, temp; |
| 119 | uint32_t fg_color = paint; |
lijuang | dd73d65 | 2015-06-05 21:29:37 +0800 | [diff] [blame] | 120 | stride -= FONT_WIDTH * scale_factor; |
Dima Zavin | d5b0b6a | 2009-01-15 18:09:25 -0800 | [diff] [blame] | 121 | |
| 122 | data = glyph[0]; |
Sandeep Panda | df39f75 | 2015-05-08 14:01:16 +0530 | [diff] [blame] | 123 | for (y = 0; y < FONT_HEIGHT / 2; ++y) { |
| 124 | temp = data; |
lijuang | dd73d65 | 2015-06-05 21:29:37 +0800 | [diff] [blame] | 125 | for (i = 0; i < scale_factor; i++) { |
Sandeep Panda | df39f75 | 2015-05-08 14:01:16 +0530 | [diff] [blame] | 126 | data = temp; |
| 127 | for (x = 0; x < FONT_WIDTH; ++x) { |
| 128 | if (data & 1) { |
lijuang | dd73d65 | 2015-06-05 21:29:37 +0800 | [diff] [blame] | 129 | for (j = 0; j < scale_factor; j++) { |
Sandeep Panda | df39f75 | 2015-05-08 14:01:16 +0530 | [diff] [blame] | 130 | fg_color = paint; |
| 131 | for (k = 0; k < bpp; k++) { |
| 132 | *pixels = (unsigned char) fg_color; |
| 133 | fg_color = fg_color >> 8; |
| 134 | pixels++; |
| 135 | } |
| 136 | } |
| 137 | } |
| 138 | else |
| 139 | { |
lijuang | dd73d65 | 2015-06-05 21:29:37 +0800 | [diff] [blame] | 140 | for (j = 0; j < scale_factor; j++) { |
Sandeep Panda | df39f75 | 2015-05-08 14:01:16 +0530 | [diff] [blame] | 141 | pixels = pixels + bpp; |
| 142 | } |
| 143 | } |
| 144 | data >>= 1; |
| 145 | } |
| 146 | pixels += (stride * bpp); |
Dima Zavin | d5b0b6a | 2009-01-15 18:09:25 -0800 | [diff] [blame] | 147 | } |
Dima Zavin | d5b0b6a | 2009-01-15 18:09:25 -0800 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | data = glyph[1]; |
Sandeep Panda | df39f75 | 2015-05-08 14:01:16 +0530 | [diff] [blame] | 151 | for (y = 0; y < FONT_HEIGHT / 2; ++y) { |
| 152 | temp = data; |
lijuang | dd73d65 | 2015-06-05 21:29:37 +0800 | [diff] [blame] | 153 | for (i = 0; i < scale_factor; i++) { |
Sandeep Panda | df39f75 | 2015-05-08 14:01:16 +0530 | [diff] [blame] | 154 | data = temp; |
| 155 | for (x = 0; x < FONT_WIDTH; ++x) { |
| 156 | if (data & 1) { |
lijuang | dd73d65 | 2015-06-05 21:29:37 +0800 | [diff] [blame] | 157 | for (j = 0; j < scale_factor; j++) { |
Sandeep Panda | df39f75 | 2015-05-08 14:01:16 +0530 | [diff] [blame] | 158 | fg_color = paint; |
| 159 | for (k = 0; k < bpp; k++) { |
| 160 | *pixels = (unsigned char) fg_color; |
| 161 | fg_color = fg_color >> 8; |
| 162 | pixels++; |
| 163 | } |
| 164 | } |
| 165 | } |
| 166 | else |
| 167 | { |
lijuang | dd73d65 | 2015-06-05 21:29:37 +0800 | [diff] [blame] | 168 | for (j = 0; j < scale_factor; j++) { |
Sandeep Panda | df39f75 | 2015-05-08 14:01:16 +0530 | [diff] [blame] | 169 | pixels = pixels + bpp; |
| 170 | } |
| 171 | } |
| 172 | data >>= 1; |
| 173 | } |
| 174 | pixels += (stride * bpp); |
Dima Zavin | d5b0b6a | 2009-01-15 18:09:25 -0800 | [diff] [blame] | 175 | } |
Dima Zavin | d5b0b6a | 2009-01-15 18:09:25 -0800 | [diff] [blame] | 176 | } |
Sandeep Panda | df39f75 | 2015-05-08 14:01:16 +0530 | [diff] [blame] | 177 | |
Dima Zavin | d5b0b6a | 2009-01-15 18:09:25 -0800 | [diff] [blame] | 178 | } |
| 179 | |
lijuang | dd73d65 | 2015-06-05 21:29:37 +0800 | [diff] [blame] | 180 | void fbcon_draw_msg_background(unsigned y_start, unsigned y_end, |
| 181 | uint32_t old_paint, int update) |
| 182 | { |
| 183 | unsigned i, j; |
| 184 | uint32_t bg_color, check_color, tmp_color, tmp1_color; |
| 185 | char *pixels; |
lijuang | 7cfbfe3 | 2018-02-06 17:09:13 +0800 | [diff] [blame] | 186 | unsigned count; |
lijuang | dd73d65 | 2015-06-05 21:29:37 +0800 | [diff] [blame] | 187 | |
lijuang | 7cfbfe3 | 2018-02-06 17:09:13 +0800 | [diff] [blame] | 188 | /* ignore anything that happens before fbcon is initialized */ |
| 189 | if (!config) |
| 190 | return; |
| 191 | |
| 192 | count = config->width * (FONT_HEIGHT * (y_end - y_start) - 1); |
lijuang | dd73d65 | 2015-06-05 21:29:37 +0800 | [diff] [blame] | 193 | pixels = config->base; |
| 194 | pixels += y_start * ((config->bpp / 8) * FONT_HEIGHT * config->width); |
| 195 | |
| 196 | if (update) { |
| 197 | bg_color = SELECT_BGCOLOR; |
| 198 | check_color = old_paint; |
| 199 | } else { |
| 200 | bg_color = old_paint; |
| 201 | check_color = SELECT_BGCOLOR; |
| 202 | } |
| 203 | |
| 204 | for (i = 0; i < count; i++) { |
| 205 | tmp1_color = bg_color; |
| 206 | tmp_color = 0; |
| 207 | for (j = 0; j < (config->bpp / 8); j++) { |
| 208 | tmp_color |= *(pixels+j) << j*8; |
| 209 | } |
| 210 | |
| 211 | if (tmp_color == check_color) { |
| 212 | for (j = 0; j < (config->bpp / 8); j++) { |
| 213 | *pixels = (unsigned char) tmp1_color; |
| 214 | tmp1_color = tmp1_color >> 8; |
| 215 | pixels++; |
| 216 | } |
| 217 | } else { |
| 218 | pixels += config->bpp / 8; |
| 219 | } |
| 220 | } |
lijuang | b3812fb | 2015-12-16 15:42:02 +0800 | [diff] [blame] | 221 | fbcon_flush(); |
lijuang | dd73d65 | 2015-06-05 21:29:37 +0800 | [diff] [blame] | 222 | } |
| 223 | |
Dima Zavin | 25ed994 | 2009-01-28 17:04:19 -0800 | [diff] [blame] | 224 | static void fbcon_flush(void) |
| 225 | { |
Mao Flynn | 7b379f3 | 2015-04-20 00:28:30 +0800 | [diff] [blame] | 226 | unsigned total_x, total_y; |
| 227 | unsigned bytes_per_bpp; |
| 228 | |
lijuang | 7cfbfe3 | 2018-02-06 17:09:13 +0800 | [diff] [blame] | 229 | /* ignore anything that happens before fbcon is initialized */ |
| 230 | if (!config) |
| 231 | return; |
| 232 | |
Dima Zavin | 25ed994 | 2009-01-28 17:04:19 -0800 | [diff] [blame] | 233 | if (config->update_start) |
| 234 | config->update_start(); |
| 235 | if (config->update_done) |
| 236 | while (!config->update_done()); |
Mao Flynn | 7b379f3 | 2015-04-20 00:28:30 +0800 | [diff] [blame] | 237 | |
| 238 | total_x = config->width; |
| 239 | total_y = config->height; |
| 240 | bytes_per_bpp = ((config->bpp) / 8); |
| 241 | arch_clean_invalidate_cache_range((addr_t) config->base, (total_x * total_y * bytes_per_bpp)); |
Dima Zavin | 25ed994 | 2009-01-28 17:04:19 -0800 | [diff] [blame] | 242 | } |
| 243 | |
Dima Zavin | d5b0b6a | 2009-01-15 18:09:25 -0800 | [diff] [blame] | 244 | /* TODO: Take stride into account */ |
| 245 | static void fbcon_scroll_up(void) |
| 246 | { |
lijuang | 7cfbfe3 | 2018-02-06 17:09:13 +0800 | [diff] [blame] | 247 | unsigned short *dst = NULL; |
| 248 | unsigned short *src = NULL; |
| 249 | unsigned count = 0; |
| 250 | |
| 251 | /* ignore anything that happens before fbcon is initialized */ |
| 252 | if (!config) |
| 253 | return; |
| 254 | |
| 255 | dst = config->base; |
| 256 | src = dst + (config->width * FONT_HEIGHT); |
| 257 | count = config->width * (config->height - FONT_HEIGHT); |
Dima Zavin | d5b0b6a | 2009-01-15 18:09:25 -0800 | [diff] [blame] | 258 | |
| 259 | while(count--) { |
| 260 | *dst++ = *src++; |
| 261 | } |
| 262 | |
| 263 | count = config->width * FONT_HEIGHT; |
| 264 | while(count--) { |
| 265 | *dst++ = BGCOLOR; |
| 266 | } |
Dima Zavin | 25ed994 | 2009-01-28 17:04:19 -0800 | [diff] [blame] | 267 | |
| 268 | fbcon_flush(); |
Dima Zavin | d5b0b6a | 2009-01-15 18:09:25 -0800 | [diff] [blame] | 269 | } |
| 270 | |
lijuang | 4304fce | 2015-08-14 20:52:47 +0800 | [diff] [blame] | 271 | void fbcon_draw_line(uint32_t type) |
lijuang | dd73d65 | 2015-06-05 21:29:37 +0800 | [diff] [blame] | 272 | { |
| 273 | char *pixels; |
lijuang | 4304fce | 2015-08-14 20:52:47 +0800 | [diff] [blame] | 274 | uint32_t line_color, tmp_color; |
lijuang | dd73d65 | 2015-06-05 21:29:37 +0800 | [diff] [blame] | 275 | int i, j; |
| 276 | |
lijuang | 7cfbfe3 | 2018-02-06 17:09:13 +0800 | [diff] [blame] | 277 | /* ignore anything that happens before fbcon is initialized */ |
| 278 | if (!config) |
| 279 | return; |
| 280 | |
lijuang | 4304fce | 2015-08-14 20:52:47 +0800 | [diff] [blame] | 281 | /* set line's color via diffrent type */ |
| 282 | line_color = fb_color_formats[type].fg; |
lijuang | dd73d65 | 2015-06-05 21:29:37 +0800 | [diff] [blame] | 283 | |
| 284 | pixels = config->base; |
| 285 | pixels += cur_pos.y * ((config->bpp / 8) * FONT_HEIGHT * config->width); |
| 286 | pixels += cur_pos.x * ((config->bpp / 8) * (FONT_WIDTH + 1)); |
| 287 | |
| 288 | for (i = 0; i < (int)config->width; i++) { |
lijuang | 4304fce | 2015-08-14 20:52:47 +0800 | [diff] [blame] | 289 | tmp_color = line_color; |
lijuang | dd73d65 | 2015-06-05 21:29:37 +0800 | [diff] [blame] | 290 | for (j = 0; j < (int)(config->bpp / 8); j++) { |
| 291 | *pixels = (unsigned char) tmp_color; |
| 292 | tmp_color = tmp_color >> 8; |
| 293 | pixels++; |
| 294 | } |
| 295 | } |
| 296 | |
| 297 | cur_pos.y += 1; |
| 298 | cur_pos.x = 0; |
| 299 | if(cur_pos.y >= max_pos.y) { |
| 300 | cur_pos.y = max_pos.y - 1; |
| 301 | fbcon_scroll_up(); |
| 302 | } else |
| 303 | fbcon_flush(); |
| 304 | } |
| 305 | |
| 306 | static void fbcon_set_colors(int type) |
| 307 | { |
| 308 | BGCOLOR = fb_color_formats[type].bg; |
| 309 | FGCOLOR = fb_color_formats[type].fg; |
| 310 | } |
| 311 | |
Shashank Mittal | 4f99a88 | 2010-02-01 13:58:50 -0800 | [diff] [blame] | 312 | void fbcon_clear(void) |
Dima Zavin | d5b0b6a | 2009-01-15 18:09:25 -0800 | [diff] [blame] | 313 | { |
Sandeep Panda | df39f75 | 2015-05-08 14:01:16 +0530 | [diff] [blame] | 314 | unsigned long i = 0, j = 0; |
lijuang | 7cfbfe3 | 2018-02-06 17:09:13 +0800 | [diff] [blame] | 315 | unsigned char *pixels = NULL; |
| 316 | unsigned count; |
Sandeep Panda | df39f75 | 2015-05-08 14:01:16 +0530 | [diff] [blame] | 317 | uint32_t bg_color; |
lijuang | dd73d65 | 2015-06-05 21:29:37 +0800 | [diff] [blame] | 318 | |
lijuang | 7cfbfe3 | 2018-02-06 17:09:13 +0800 | [diff] [blame] | 319 | /* ignore anything that happens before fbcon is initialized */ |
| 320 | if (!config) |
| 321 | return; |
| 322 | |
| 323 | pixels = config->base; |
| 324 | count = config->width * config->height; |
| 325 | |
lijuang | dd73d65 | 2015-06-05 21:29:37 +0800 | [diff] [blame] | 326 | fbcon_set_colors(FBCON_COMMON_MSG); |
Sandeep Panda | df39f75 | 2015-05-08 14:01:16 +0530 | [diff] [blame] | 327 | for (i = 0; i < count; i++) { |
| 328 | bg_color = BGCOLOR; |
| 329 | for (j = 0; j < (config->bpp / 8); j++) { |
| 330 | *pixels = (unsigned char) bg_color; |
| 331 | bg_color = bg_color >> 8; |
| 332 | pixels++; |
| 333 | } |
| 334 | } |
lijuang | dd73d65 | 2015-06-05 21:29:37 +0800 | [diff] [blame] | 335 | cur_pos.x = 0; |
| 336 | cur_pos.y = 0; |
Dima Zavin | d5b0b6a | 2009-01-15 18:09:25 -0800 | [diff] [blame] | 337 | } |
| 338 | |
Monika Singh | b879e49 | 2019-09-16 16:00:15 +0530 | [diff] [blame] | 339 | void fbcon_clear_msg(unsigned y_start, unsigned y_end) |
| 340 | { |
| 341 | unsigned i, j; |
| 342 | uint32_t bg_color; |
| 343 | char *pixels; |
| 344 | unsigned count; |
| 345 | |
| 346 | /* ignore anything that happens before fbcon is initialized */ |
| 347 | if (!config) |
| 348 | return; |
| 349 | |
| 350 | count = config->width * (FONT_HEIGHT * (y_end - y_start) - 1); |
| 351 | pixels = config->base; |
| 352 | pixels += y_start * ((config->bpp / 8) * FONT_HEIGHT * config->width); |
| 353 | |
| 354 | fbcon_set_colors(FBCON_COMMON_MSG); |
| 355 | for (i = 0; i < count; i++) { |
| 356 | bg_color = BGCOLOR; |
| 357 | for (j = 0; j < (config->bpp / 8); j++) { |
| 358 | *pixels = (unsigned char) bg_color; |
| 359 | bg_color = bg_color >> 8; |
| 360 | pixels++; |
| 361 | } |
| 362 | } |
| 363 | } |
| 364 | |
| 365 | void fbcon_putc_factor(char c, int type, unsigned scale_factor, int y_start) |
Dima Zavin | d5b0b6a | 2009-01-15 18:09:25 -0800 | [diff] [blame] | 366 | { |
Sandeep Panda | df39f75 | 2015-05-08 14:01:16 +0530 | [diff] [blame] | 367 | char *pixels; |
Dima Zavin | d5b0b6a | 2009-01-15 18:09:25 -0800 | [diff] [blame] | 368 | |
| 369 | /* ignore anything that happens before fbcon is initialized */ |
| 370 | if (!config) |
| 371 | return; |
| 372 | |
| 373 | if((unsigned char)c > 127) |
| 374 | return; |
Sandeep Panda | df39f75 | 2015-05-08 14:01:16 +0530 | [diff] [blame] | 375 | |
Dima Zavin | d5b0b6a | 2009-01-15 18:09:25 -0800 | [diff] [blame] | 376 | if((unsigned char)c < 32) { |
| 377 | if(c == '\n') |
| 378 | goto newline; |
Sandeep Panda | df39f75 | 2015-05-08 14:01:16 +0530 | [diff] [blame] | 379 | else if (c == '\r') { |
Dima Zavin | d5b0b6a | 2009-01-15 18:09:25 -0800 | [diff] [blame] | 380 | cur_pos.x = 0; |
Sandeep Panda | df39f75 | 2015-05-08 14:01:16 +0530 | [diff] [blame] | 381 | return; |
| 382 | } |
| 383 | else |
| 384 | return; |
Dima Zavin | d5b0b6a | 2009-01-15 18:09:25 -0800 | [diff] [blame] | 385 | } |
| 386 | |
lijuang | dd73d65 | 2015-06-05 21:29:37 +0800 | [diff] [blame] | 387 | if (cur_pos.x == 0 && (unsigned char)c == ' ' && |
| 388 | type != FBCON_SUBTITLE_MSG && |
| 389 | type != FBCON_TITLE_MSG) |
Dima Zavin | d5b0b6a | 2009-01-15 18:09:25 -0800 | [diff] [blame] | 390 | return; |
| 391 | |
lijuang | dd73d65 | 2015-06-05 21:29:37 +0800 | [diff] [blame] | 392 | fbcon_set_colors(type); |
| 393 | |
| 394 | pixels = config->base; |
Monika Singh | b879e49 | 2019-09-16 16:00:15 +0530 | [diff] [blame] | 395 | /* if y_start is null, it will start from current y loaction */ |
| 396 | if (y_start) { |
| 397 | cur_pos.x = 0; |
| 398 | cur_pos.y = y_start; |
| 399 | } |
lijuang | dd73d65 | 2015-06-05 21:29:37 +0800 | [diff] [blame] | 400 | pixels += cur_pos.y * ((config->bpp / 8) * FONT_HEIGHT * config->width); |
| 401 | pixels += cur_pos.x * scale_factor * ((config->bpp / 8) * (FONT_WIDTH + 1)); |
| 402 | |
| 403 | fbcon_drawglyph(pixels, FGCOLOR, config->stride, (config->bpp / 8), |
| 404 | font5x12 + (c - 32) * 2, scale_factor); |
| 405 | |
| 406 | cur_pos.x++; |
| 407 | if (cur_pos.x >= (int)(max_pos.x / scale_factor)) |
| 408 | goto newline; |
| 409 | |
| 410 | return; |
| 411 | |
Dima Zavin | d5b0b6a | 2009-01-15 18:09:25 -0800 | [diff] [blame] | 412 | newline: |
lijuang | dd73d65 | 2015-06-05 21:29:37 +0800 | [diff] [blame] | 413 | cur_pos.y += scale_factor; |
Dima Zavin | d5b0b6a | 2009-01-15 18:09:25 -0800 | [diff] [blame] | 414 | cur_pos.x = 0; |
| 415 | if(cur_pos.y >= max_pos.y) { |
| 416 | cur_pos.y = max_pos.y - 1; |
| 417 | fbcon_scroll_up(); |
Dima Zavin | 25ed994 | 2009-01-28 17:04:19 -0800 | [diff] [blame] | 418 | } else |
| 419 | fbcon_flush(); |
Dima Zavin | d5b0b6a | 2009-01-15 18:09:25 -0800 | [diff] [blame] | 420 | } |
| 421 | |
Monika Singh | b879e49 | 2019-09-16 16:00:15 +0530 | [diff] [blame] | 422 | void fbcon_putc(char c, int y_start) |
lijuang | dd73d65 | 2015-06-05 21:29:37 +0800 | [diff] [blame] | 423 | { |
Monika Singh | b879e49 | 2019-09-16 16:00:15 +0530 | [diff] [blame] | 424 | fbcon_putc_factor(c, FBCON_COMMON_MSG, SCALE_FACTOR, y_start); |
lijuang | dd73d65 | 2015-06-05 21:29:37 +0800 | [diff] [blame] | 425 | } |
| 426 | |
| 427 | uint32_t fbcon_get_current_line(void) |
| 428 | { |
| 429 | return cur_pos.y; |
| 430 | } |
| 431 | |
| 432 | uint32_t fbcon_get_max_x(void) |
| 433 | { |
| 434 | return max_pos.x; |
| 435 | } |
| 436 | |
lijuang | f3d7fc5 | 2018-04-23 16:34:29 +0800 | [diff] [blame] | 437 | uint32_t fbcon_get_width(void) |
| 438 | { |
| 439 | if (config) |
| 440 | return config->width; |
| 441 | else |
| 442 | return 0; |
| 443 | } |
| 444 | |
| 445 | uint32_t fbcon_get_height(void) |
| 446 | { |
| 447 | if (config) |
| 448 | return config->height; |
| 449 | else |
| 450 | return 0; |
| 451 | } |
| 452 | |
lijuang | dd73d65 | 2015-06-05 21:29:37 +0800 | [diff] [blame] | 453 | uint32_t fbcon_get_current_bg(void) |
| 454 | { |
| 455 | return BGCOLOR; |
| 456 | } |
| 457 | |
Dima Zavin | d5b0b6a | 2009-01-15 18:09:25 -0800 | [diff] [blame] | 458 | void fbcon_setup(struct fbcon_config *_config) |
| 459 | { |
Dima Zavin | d5b0b6a | 2009-01-15 18:09:25 -0800 | [diff] [blame] | 460 | ASSERT(_config); |
| 461 | |
| 462 | config = _config; |
| 463 | |
| 464 | switch (config->format) { |
| 465 | case FB_FORMAT_RGB565: |
lijuang | dd73d65 | 2015-06-05 21:29:37 +0800 | [diff] [blame] | 466 | fb_color_formats = fb_color_formats_555; |
Dima Zavin | d5b0b6a | 2009-01-15 18:09:25 -0800 | [diff] [blame] | 467 | break; |
lijuang | dd73d65 | 2015-06-05 21:29:37 +0800 | [diff] [blame] | 468 | case FB_FORMAT_RGB888: |
| 469 | fb_color_formats = fb_color_formats_888; |
| 470 | break; |
Dima Zavin | d5b0b6a | 2009-01-15 18:09:25 -0800 | [diff] [blame] | 471 | default: |
| 472 | dprintf(CRITICAL, "unknown framebuffer pixel format\n"); |
| 473 | ASSERT(0); |
| 474 | break; |
| 475 | } |
| 476 | |
lijuang | dd73d65 | 2015-06-05 21:29:37 +0800 | [diff] [blame] | 477 | SELECT_BGCOLOR = fb_color_formats[FBCON_SELECT_MSG_BG_COLOR].bg; |
| 478 | fbcon_set_colors(FBCON_COMMON_MSG); |
Dima Zavin | d5b0b6a | 2009-01-15 18:09:25 -0800 | [diff] [blame] | 479 | |
Dima Zavin | d5b0b6a | 2009-01-15 18:09:25 -0800 | [diff] [blame] | 480 | cur_pos.x = 0; |
| 481 | cur_pos.y = 0; |
lijuang | dd73d65 | 2015-06-05 21:29:37 +0800 | [diff] [blame] | 482 | max_pos.x = config->width / (FONT_WIDTH+1); |
Dima Zavin | d5b0b6a | 2009-01-15 18:09:25 -0800 | [diff] [blame] | 483 | max_pos.y = (config->height - 1) / FONT_HEIGHT; |
lijuang | dd73d65 | 2015-06-05 21:29:37 +0800 | [diff] [blame] | 484 | |
Shashank Mittal | 3704083 | 2010-08-24 15:57:57 -0700 | [diff] [blame] | 485 | #if !DISPLAY_SPLASH_SCREEN |
| 486 | fbcon_clear(); |
| 487 | #endif |
lijuang | dd73d65 | 2015-06-05 21:29:37 +0800 | [diff] [blame] | 488 | |
Dima Zavin | d5b0b6a | 2009-01-15 18:09:25 -0800 | [diff] [blame] | 489 | } |
Shashank Mittal | 4f99a88 | 2010-02-01 13:58:50 -0800 | [diff] [blame] | 490 | |
| 491 | struct fbcon_config* fbcon_display(void) |
| 492 | { |
Mao Flynn | 7b379f3 | 2015-04-20 00:28:30 +0800 | [diff] [blame] | 493 | return config; |
Shashank Mittal | 4f99a88 | 2010-02-01 13:58:50 -0800 | [diff] [blame] | 494 | } |
Chandan Uddaraju | 40b227d | 2010-08-03 19:25:41 -0700 | [diff] [blame] | 495 | |
Mao Flynn | 7b379f3 | 2015-04-20 00:28:30 +0800 | [diff] [blame] | 496 | void fbcon_extract_to_screen(logo_img_header *header, void* address) |
Aparna Mallavarapu | ce06a01 | 2013-09-06 23:03:24 +0530 | [diff] [blame] | 497 | { |
Mao Flynn | 7b379f3 | 2015-04-20 00:28:30 +0800 | [diff] [blame] | 498 | const uint8_t *imagestart = (const uint8_t *)address; |
| 499 | uint pos = 0, offset; |
| 500 | uint count = 0; |
| 501 | uint x = 0, y = 0; |
| 502 | uint8_t *base, *p; |
Aparna Mallavarapu | ce06a01 | 2013-09-06 23:03:24 +0530 | [diff] [blame] | 503 | |
Mao Flynn | 7b379f3 | 2015-04-20 00:28:30 +0800 | [diff] [blame] | 504 | if (!config || header->width > config->width |
| 505 | || header->height > config->height) { |
| 506 | dprintf(INFO, "the logo img is too large\n"); |
| 507 | return; |
Aparna Mallavarapu | ce06a01 | 2013-09-06 23:03:24 +0530 | [diff] [blame] | 508 | } |
| 509 | |
Mao Flynn | 7b379f3 | 2015-04-20 00:28:30 +0800 | [diff] [blame] | 510 | base = (uint8_t *) config->base; |
| 511 | |
| 512 | /* put the logo to be center */ |
| 513 | offset = (config->height - header->height) / 2; |
| 514 | if (offset) |
| 515 | base += (offset * config->width) * 3; |
| 516 | offset = (config->width - header->width ) / 2; |
| 517 | |
| 518 | x = offset; |
| 519 | while (count < (uint)header->height * (uint)header->width) { |
| 520 | uint8_t run = *(imagestart + pos); |
| 521 | bool repeat_run = (run & 0x80); |
| 522 | uint runlen = (run & 0x7f) + 1; |
| 523 | uint runpos; |
| 524 | |
| 525 | /* consume the run byte */ |
| 526 | pos++; |
| 527 | |
| 528 | p = base + (y * config->width + x) * 3; |
| 529 | |
| 530 | /* start of a run */ |
| 531 | for (runpos = 0; runpos < runlen; runpos++) { |
| 532 | *p++ = *(imagestart + pos); |
| 533 | *p++ = *(imagestart + pos + 1); |
| 534 | *p++ = *(imagestart + pos + 2); |
| 535 | count++; |
| 536 | |
| 537 | x++; |
| 538 | |
| 539 | /* if a run of raw pixels, consume an input pixel */ |
| 540 | if (!repeat_run) |
| 541 | pos += 3; |
| 542 | } |
| 543 | |
| 544 | /* if this was a run of repeated pixels, consume the one input pixel we repeated */ |
| 545 | if (repeat_run) |
| 546 | pos += 3; |
| 547 | |
| 548 | /* the generator will keep compressing data line by line */ |
| 549 | /* don't cross the lines */ |
| 550 | if (x == header->width + offset) { |
| 551 | y++; |
| 552 | x = offset; |
| 553 | } |
| 554 | } |
| 555 | |
Aparna Mallavarapu | ce06a01 | 2013-09-06 23:03:24 +0530 | [diff] [blame] | 556 | } |
| 557 | |
Mao Flynn | 7b379f3 | 2015-04-20 00:28:30 +0800 | [diff] [blame] | 558 | void display_default_image_on_screen(void) |
Chandan Uddaraju | 40b227d | 2010-08-03 19:25:41 -0700 | [diff] [blame] | 559 | { |
Mao Flynn | 7b379f3 | 2015-04-20 00:28:30 +0800 | [diff] [blame] | 560 | unsigned i = 0; |
| 561 | unsigned total_x; |
| 562 | unsigned total_y; |
| 563 | unsigned bytes_per_bpp; |
| 564 | unsigned image_base; |
Channagoud Kadabi | 875a2a7 | 2015-04-24 17:26:38 -0700 | [diff] [blame] | 565 | #if DISPLAY_TYPE_MIPI |
| 566 | char *image = NULL; |
| 567 | #endif |
Channagoud Kadabi | 956cf50 | 2012-03-08 03:49:50 +0530 | [diff] [blame] | 568 | |
Aparna Mallavarapu | ce06a01 | 2013-09-06 23:03:24 +0530 | [diff] [blame] | 569 | if (!config) { |
| 570 | dprintf(CRITICAL,"NULL configuration, image cannot be displayed\n"); |
| 571 | return; |
| 572 | } |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 573 | |
Mao Flynn | 7b379f3 | 2015-04-20 00:28:30 +0800 | [diff] [blame] | 574 | fbcon_clear(); // clear screen with Black color |
Aparna Mallavarapu | ce06a01 | 2013-09-06 23:03:24 +0530 | [diff] [blame] | 575 | |
| 576 | total_x = config->width; |
| 577 | total_y = config->height; |
| 578 | bytes_per_bpp = ((config->bpp) / 8); |
jialongjhan | 1efba00 | 2020-05-22 18:25:56 +0800 | [diff] [blame] | 579 | |
Mao Flynn | 7b379f3 | 2015-04-20 00:28:30 +0800 | [diff] [blame] | 580 | image_base = ((((total_y/2) - (SPLASH_IMAGE_HEIGHT / 2) - 1) * |
| 581 | (config->width)) + (total_x/2 - (SPLASH_IMAGE_WIDTH / 2))); |
Channagoud Kadabi | 956cf50 | 2012-03-08 03:49:50 +0530 | [diff] [blame] | 582 | |
jialongjhan | 1efba00 | 2020-05-22 18:25:56 +0800 | [diff] [blame] | 583 | |
Channagoud Kadabi | 875a2a7 | 2015-04-24 17:26:38 -0700 | [diff] [blame] | 584 | #if ENABLE_WBC |
| 585 | image = (pm_appsbl_charging_in_progress() ? image_batt888 : imageBuffer_rgb888); |
| 586 | #else |
| 587 | image = imageBuffer_rgb888; |
| 588 | #endif |
| 589 | |
jialongjhan | 1efba00 | 2020-05-22 18:25:56 +0800 | [diff] [blame] | 590 | //[Arima][8901][JialongJhan]modify Boot logo 20190418 Start |
| 591 | |
| 592 | #if 0 //ignore default |
Mao Flynn | 7b379f3 | 2015-04-20 00:28:30 +0800 | [diff] [blame] | 593 | if (bytes_per_bpp == 3) { |
| 594 | for (i = 0; i < SPLASH_IMAGE_HEIGHT; i++) { |
Aparna Mallavarapu | ce06a01 | 2013-09-06 23:03:24 +0530 | [diff] [blame] | 595 | memcpy (config->base + ((image_base + (i * (config->width))) * bytes_per_bpp), |
Channagoud Kadabi | 875a2a7 | 2015-04-24 17:26:38 -0700 | [diff] [blame] | 596 | image + (i * SPLASH_IMAGE_WIDTH * bytes_per_bpp), |
Mao Flynn | 7b379f3 | 2015-04-20 00:28:30 +0800 | [diff] [blame] | 597 | SPLASH_IMAGE_WIDTH * bytes_per_bpp); |
Aparna Mallavarapu | ce06a01 | 2013-09-06 23:03:24 +0530 | [diff] [blame] | 598 | } |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 599 | } |
jialongjhan | 1efba00 | 2020-05-22 18:25:56 +0800 | [diff] [blame] | 600 | #endif |
Zohaib Alam | 0370875 | 2014-10-23 17:51:57 -0400 | [diff] [blame] | 601 | |
Mao Flynn | 7b379f3 | 2015-04-20 00:28:30 +0800 | [diff] [blame] | 602 | if (bytes_per_bpp == 2) { |
| 603 | for (i = 0; i < SPLASH_IMAGE_HEIGHT; i++) { |
| 604 | memcpy (config->base + ((image_base + (i * (config->width))) * bytes_per_bpp), |
| 605 | imageBuffer + (i * SPLASH_IMAGE_WIDTH * bytes_per_bpp), |
| 606 | SPLASH_IMAGE_WIDTH * bytes_per_bpp); |
Zohaib Alam | 0370875 | 2014-10-23 17:51:57 -0400 | [diff] [blame] | 607 | } |
| 608 | } |
Wenjun Zhang | 4e63ce4 | 2017-11-28 05:11:34 -0500 | [diff] [blame] | 609 | |
jialongjhan | 1efba00 | 2020-05-22 18:25:56 +0800 | [diff] [blame] | 610 | /*[Jialong]Description: |
| 611 | image_base is picture's placemark which we want wirte. |
| 612 | The formula is (Row * Total_Column)+Column, so we can obtain placemark of first pixel of picture. |
| 613 | |
| 614 | image is array of picture. |
| 615 | |
| 616 | We use memcpy function display all pixels of line, |
| 617 | and use "for loop" function display all lines of picture.*/ |
| 618 | |
| 619 | //Show logo's top parts. |
| 620 | image_base=(913*1080)+208; |
| 621 | image = logo_top; |
| 622 | |
| 623 | if (bytes_per_bpp == 3) { |
| 624 | for (i = 0; i < FAIRPHONE_SPLASH_IMAGE_TOP_HEIGHT; i++) { |
| 625 | memcpy (config->base + ((image_base + (i * (config->width))) * bytes_per_bpp), |
| 626 | image + (i * FAIRPHONE_SPLASH_IMAGE_TOP_WIDTH * bytes_per_bpp), |
| 627 | FAIRPHONE_SPLASH_IMAGE_TOP_WIDTH * bytes_per_bpp); |
| 628 | } |
| 629 | } |
| 630 | //Show logo's top parts end. |
| 631 | |
| 632 | //Show logo's bottom parts. |
| 633 | image_base=(1884*1080)+403; |
| 634 | image = logo_bottom; |
| 635 | |
| 636 | if (bytes_per_bpp == 3) { |
| 637 | for (i = 0; i < FAIRPHONE_SPLASH_IMAGE_BOTTOM_HEIGHT; i++) { |
| 638 | memcpy (config->base + ((image_base + (i * (config->width))) * bytes_per_bpp), |
| 639 | image + (i * FAIRPHONE_SPLASH_IMAGE_BOTTOM_WIDTH * bytes_per_bpp), |
| 640 | FAIRPHONE_SPLASH_IMAGE_BOTTOM_WIDTH * bytes_per_bpp); |
| 641 | } |
| 642 | } |
| 643 | //Show logo's bottom parts end. |
| 644 | |
| 645 | //[Arima][8901][JialongJhan]modify Boot logo 20190418 End |
| 646 | |
Zohaib Alam | 0370875 | 2014-10-23 17:51:57 -0400 | [diff] [blame] | 647 | fbcon_flush(); |
Wenjun Zhang | 4e63ce4 | 2017-11-28 05:11:34 -0500 | [diff] [blame] | 648 | |
| 649 | #if DISPLAY_MIPI_PANEL_NOVATEK_BLUE |
| 650 | if(is_cmd_mode_enabled()) |
| 651 | mipi_dsi_cmd_mode_trigger(); |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 652 | #endif |
Chandan Uddaraju | 40b227d | 2010-08-03 19:25:41 -0700 | [diff] [blame] | 653 | } |
Mao Flynn | 7b379f3 | 2015-04-20 00:28:30 +0800 | [diff] [blame] | 654 | |
jialongjhan | 1efba00 | 2020-05-22 18:25:56 +0800 | [diff] [blame] | 655 | //[Arima][8901][JialongJhan]Show Fastboot logo 20190418 Start |
| 656 | void display_fastboot_image_on_screen(void) |
| 657 | { |
| 658 | unsigned i = 0; |
| 659 | unsigned bytes_per_bpp; |
| 660 | unsigned image_base; |
| 661 | #if DISPLAY_TYPE_MIPI |
| 662 | char *image = NULL; |
| 663 | #endif |
| 664 | |
| 665 | if (!config) { |
| 666 | dprintf(CRITICAL,"NULL configuration, image cannot be displayed\n"); |
| 667 | return; |
| 668 | } |
| 669 | fbcon_clear(); // clear screen with Black color |
| 670 | bytes_per_bpp = ((config->bpp) / 8); |
| 671 | |
| 672 | //Show fastboot image 1 |
| 673 | image_base=(702*1080)+319; |
| 674 | image = fastboot_logo1; |
| 675 | |
| 676 | if (bytes_per_bpp == 3) { |
| 677 | for (i = 0; i < FAIRPHONE_FASTBOOT_IMAGE_1_HEIGHT; i++) { |
| 678 | memcpy (config->base + ((image_base + (i * (config->width))) * bytes_per_bpp), |
| 679 | image + (i * FAIRPHONE_FASTBOOT_IMAGE_1_WIDTH * bytes_per_bpp), |
| 680 | FAIRPHONE_FASTBOOT_IMAGE_1_WIDTH * bytes_per_bpp); |
| 681 | } |
| 682 | } |
| 683 | |
| 684 | //Show fastboot image 2 |
| 685 | image_base=(905*1080)+475; |
| 686 | image = fastboot_logo2; |
| 687 | |
| 688 | if (bytes_per_bpp == 3) { |
| 689 | for (i = 0; i < FAIRPHONE_FASTBOOT_IMAGE_2_HEIGHT; i++) { |
| 690 | memcpy (config->base + ((image_base + (i * (config->width))) * bytes_per_bpp), |
| 691 | image + (i * FAIRPHONE_FASTBOOT_IMAGE_2_WIDTH * bytes_per_bpp), |
| 692 | FAIRPHONE_FASTBOOT_IMAGE_2_WIDTH * bytes_per_bpp); |
| 693 | } |
| 694 | } |
| 695 | |
| 696 | //Show fastboot image 3 |
| 697 | image_base=(1191*1080)+502; |
| 698 | image = fastboot_logo3; |
| 699 | |
| 700 | if (bytes_per_bpp == 3) { |
| 701 | for (i = 0; i < FAIRPHONE_FASTBOOT_IMAGE_3_HEIGHT; i++) { |
| 702 | memcpy (config->base + ((image_base + (i * (config->width))) * bytes_per_bpp), |
| 703 | image + (i * FAIRPHONE_FASTBOOT_IMAGE_3_WIDTH * bytes_per_bpp), |
| 704 | FAIRPHONE_FASTBOOT_IMAGE_3_WIDTH * bytes_per_bpp); |
| 705 | } |
| 706 | } |
| 707 | |
| 708 | //Show fastboot image 4 |
| 709 | image_base=(1720*1080)+450; |
| 710 | image = fastboot_logo4; |
| 711 | |
| 712 | if (bytes_per_bpp == 3) { |
| 713 | for (i = 0; i < FAIRPHONE_FASTBOOT_IMAGE_4_HEIGHT; i++) { |
| 714 | memcpy (config->base + ((image_base + (i * (config->width))) * bytes_per_bpp), |
| 715 | image + (i * FAIRPHONE_FASTBOOT_IMAGE_4_WIDTH * bytes_per_bpp), |
| 716 | FAIRPHONE_FASTBOOT_IMAGE_4_WIDTH * bytes_per_bpp); |
| 717 | } |
| 718 | } |
| 719 | |
| 720 | fbcon_flush(); |
| 721 | } |
| 722 | |
| 723 | //[Arima][8901][JialongJhan]Show Fastboot logo 20190418 End |
| 724 | |
| 725 | //[Arima][8901][JialongJhan]Show Low battery logo 20190418 Start |
| 726 | void display_lowbattery_image_on_screen(void) |
| 727 | { |
| 728 | unsigned i = 0; |
| 729 | unsigned bytes_per_bpp; |
| 730 | unsigned image_base; |
| 731 | #if DISPLAY_TYPE_MIPI |
| 732 | char *image = NULL; |
| 733 | #endif |
| 734 | |
| 735 | if (!config) { |
| 736 | dprintf(CRITICAL,"NULL configuration, image cannot be displayed\n"); |
| 737 | return; |
| 738 | } |
| 739 | fbcon_clear(); // clear screen with Black color |
| 740 | bytes_per_bpp = ((config->bpp) / 8); |
| 741 | |
| 742 | //Show lowb battery image 1 |
| 743 | image_base=(758*1080)+421; |
| 744 | image = lowbattery_logo1; |
| 745 | |
| 746 | if (bytes_per_bpp == 3) { |
| 747 | for (i = 0; i < FAIRPHONE_LOWBATTERY_IMAGE_1_HEIGHT; i++) { |
| 748 | memcpy (config->base + ((image_base + (i * (config->width))) * bytes_per_bpp), |
| 749 | image + (i * FAIRPHONE_LOWBATTERY_IMAGE_1_WIDTH * bytes_per_bpp), |
| 750 | FAIRPHONE_LOWBATTERY_IMAGE_1_WIDTH * bytes_per_bpp); |
| 751 | } |
| 752 | } |
| 753 | |
| 754 | //Show lowb battery image 2 |
| 755 | image_base=(1246*1080)+502; |
| 756 | image = lowbattery_logo2; |
| 757 | |
| 758 | if (bytes_per_bpp == 3) { |
| 759 | for (i = 0; i < FAIRPHONE_LOWBATTERY_IMAGE_2_HEIGHT; i++) { |
| 760 | memcpy (config->base + ((image_base + (i * (config->width))) * bytes_per_bpp), |
| 761 | image + (i * FAIRPHONE_LOWBATTERY_IMAGE_2_WIDTH * bytes_per_bpp), |
| 762 | FAIRPHONE_LOWBATTERY_IMAGE_2_WIDTH * bytes_per_bpp); |
| 763 | } |
| 764 | } |
| 765 | |
| 766 | //Show lowb battery image 3 |
| 767 | image_base=(1452*1080)+488; |
| 768 | image = lowbattery_logo3; |
| 769 | |
| 770 | if (bytes_per_bpp == 3) { |
| 771 | for (i = 0; i < FAIRPHONE_LOWBATTERY_IMAGE_3_HEIGHT; i++) { |
| 772 | memcpy (config->base + ((image_base + (i * (config->width))) * bytes_per_bpp), |
| 773 | image + (i * FAIRPHONE_LOWBATTERY_IMAGE_3_WIDTH * bytes_per_bpp), |
| 774 | FAIRPHONE_LOWBATTERY_IMAGE_3_WIDTH * bytes_per_bpp); |
| 775 | } |
| 776 | } |
| 777 | |
| 778 | //Show lowb battery image 4 |
| 779 | image_base=(1623*1080)+530; |
| 780 | image = lowbattery_logo4; |
| 781 | |
| 782 | if (bytes_per_bpp == 3) { |
| 783 | for (i = 0; i < FAIRPHONE_LOWBATTERY_IMAGE_4_HEIGHT; i++) { |
| 784 | memcpy (config->base + ((image_base + (i * (config->width))) * bytes_per_bpp), |
| 785 | image + (i * FAIRPHONE_LOWBATTERY_IMAGE_4_WIDTH * bytes_per_bpp), |
| 786 | FAIRPHONE_LOWBATTERY_IMAGE_4_WIDTH * bytes_per_bpp); |
| 787 | } |
| 788 | } |
| 789 | |
| 790 | |
| 791 | |
| 792 | fbcon_flush(); |
| 793 | } |
| 794 | |
| 795 | //[Arima][8901][JialongJhan]Show Low battery logo 20190418 End |
| 796 | |
Mao Flynn | 7b379f3 | 2015-04-20 00:28:30 +0800 | [diff] [blame] | 797 | |
| 798 | void display_image_on_screen(void) |
| 799 | { |
| 800 | #if DISPLAY_TYPE_MIPI |
| 801 | int fetch_image_from_partition(); |
| 802 | |
| 803 | if (fetch_image_from_partition() < 0) { |
| 804 | display_default_image_on_screen(); |
| 805 | } else { |
| 806 | /* data has been put into the right place */ |
| 807 | fbcon_flush(); |
| 808 | } |
| 809 | #else |
| 810 | display_default_image_on_screen(); |
| 811 | #endif |
| 812 | } |