1 /* $NetBSD: debug_subr.c,v 1.4 2002/05/03 07:31:23 takemura Exp $ */ 2 3 /*- 4 * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by UCHIYAMA Yasushi. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 3. All advertising materials mentioning features or use of this software 19 * must display the following acknowledgement: 20 * This product includes software developed by the NetBSD 21 * Foundation, Inc. and its contributors. 22 * 4. Neither the name of The NetBSD Foundation nor the names of its 23 * contributors may be used to endorse or promote products derived 24 * from this software without specific prior written permission. 25 * 26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36 * POSSIBILITY OF SUCH DAMAGE. 37 */ 38 39 #include "debug_hpc.h" 40 41 #include <sys/param.h> 42 #include <sys/systm.h> 43 44 #include <machine/debug.h> 45 #include <machine/bootinfo.h> 46 47 #define BANNER_LENGTH 80 48 49 static const char onoff[2] = "_x"; 50 51 void 52 __dbg_bit_print(u_int32_t a, int len, int start, int end, char *title, 53 int flags) 54 { 55 u_int32_t j, j1; 56 int i, n; 57 char buf[64]; 58 59 n = len * NBBY - 1; 60 j1 = 1 << n; 61 end = end ? end : n; 62 63 if (!(flags & DBG_BIT_PRINT_QUIET)) 64 printf(" "); 65 if (title) { 66 printf("[%-16s] ", title); 67 } 68 69 for (j = j1, i = n; j > 0; j >>=1, i--) { 70 if (i > end || i < start) { 71 printf("%c", a & j ? '+' : '-'); /* out of range */ 72 } else { 73 printf("%c", a & j ? '|' : '.'); 74 } 75 } 76 77 if (!(flags & DBG_BIT_PRINT_QUIET)) { 78 snprintf(buf, sizeof buf, " [0x%%0%dx %%12d]", len << 1); 79 printf(buf, a, a); 80 } 81 82 if (flags & DBG_BIT_PRINT_COUNT) { 83 for (j = j1, i = n; j > 0; j >>=1, i--) { 84 if (!(i > end || i < start) && (a & j)) { 85 printf(" %d", i); 86 } 87 } 88 } 89 90 if (!(flags & DBG_BIT_PRINT_QUIET)) 91 printf("\n"); 92 } 93 94 void 95 dbg_bitmask_print(u_int32_t reg, u_int32_t mask, const char *name) 96 { 97 98 printf("%s[%c] ", name, onoff[reg & mask ? 1 : 0]); 99 } 100 101 void 102 dbg_banner_title(const char *name, size_t len) 103 { 104 int n = (BANNER_LENGTH - (len + 2)) >> 1; 105 106 dbg_draw_line(n); 107 printf("[%s]", name); 108 dbg_draw_line(n); 109 printf("\n"); 110 } 111 112 void 113 dbg_banner_line() 114 { 115 116 dbg_draw_line(BANNER_LENGTH); 117 printf("\n"); 118 } 119 120 void 121 dbg_draw_line(int n) 122 { 123 int i; 124 125 for (i = 0; i < n; i++) 126 printf("-"); 127 } 128 129 #ifdef HPC_DEBUG_LCD 130 /* 131 * LCD test routines for 8bpp, 16bpp LCD. 132 */ 133 static const u_int8_t img[1024] = { 134 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 135 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 136 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 137 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 138 0xff,0xd5,0xff,0xc3,0xff,0xd5,0xff,0xc3, 139 0xff,0xd5,0xff,0xc3,0xff,0xd5,0xff,0xc3, 140 0xff,0xd5,0xff,0xc3,0xff,0xd5,0xc3,0xd5, 141 0xff,0xc3,0xff,0xd5,0xff,0xc3,0xff,0xd5, 142 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 143 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 144 0xff,0xff,0xff,0xff,0xff,0xff,0x82,0x82, 145 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xc3, 146 0xff,0xc3,0xff,0xff,0xff,0xff,0xff,0xff, 147 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 148 0xff,0xff,0xff,0xff,0xff,0xff,0xb9,0x82, 149 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xb9, 150 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 151 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 152 0xff,0xff,0xff,0xff,0xff,0xff,0xd5,0x82, 153 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xd5, 154 0xff,0xb9,0xff,0xff,0xff,0xff,0xff,0xff, 155 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 156 0xff,0xff,0xff,0xff,0xff,0xff,0xc3,0x82, 157 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xc3, 158 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 159 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 160 0xff,0xff,0xff,0xff,0xff,0xff,0xd5,0x82, 161 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xd5, 162 0xff,0xd5,0xff,0xff,0xff,0xff,0xff,0xff, 163 0xff,0xff,0xff,0xff,0xb9,0xd5,0xc3,0xd5, 164 0xff,0xff,0xff,0xff,0xff,0xff,0x3d,0x82, 165 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xb9, 166 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 167 0xff,0xff,0xd5,0x82,0x82,0x82,0x82,0x82, 168 0x82,0x82,0xd5,0xff,0xff,0xff,0xd5,0x82, 169 0xff,0xff,0xd5,0xc3,0xff,0xff,0xff,0xc3, 170 0xff,0xc3,0xff,0xff,0xff,0xff,0xff,0xff, 171 0xff,0xff,0x82,0x82,0xff,0xff,0xff,0xff, 172 0xd5,0x3e,0x82,0x82,0x82,0xc3,0x82,0x3d, 173 0xff,0xc3,0x82,0x3d,0xff,0xff,0xff,0xd5, 174 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 175 0xff,0xd5,0x82,0xff,0xff,0xff,0xff,0xff, 176 0xff,0xff,0xff,0xff,0x82,0x82,0x82,0x3d, 177 0x82,0x82,0xd5,0xff,0xff,0xff,0xff,0xb9, 178 0xff,0xb9,0xff,0xff,0xff,0xff,0xff,0xff, 179 0xff,0x82,0x82,0xff,0xff,0xff,0xff,0xff, 180 0xff,0xff,0xff,0xff,0xd5,0x82,0x82,0x82, 181 0x82,0x82,0xb9,0xff,0xff,0xff,0xff,0xc3, 182 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 183 0xff,0x82,0xd5,0xff,0xff,0xff,0xff,0xff, 184 0xff,0xff,0xff,0xff,0xff,0x82,0x82,0x82, 185 0xd5,0xff,0x82,0xd5,0xff,0xff,0xff,0xd5, 186 0xff,0xd5,0xff,0xff,0xff,0xff,0xff,0xff, 187 0xd5,0x82,0xff,0xff,0xff,0xff,0xff,0xff, 188 0xff,0xff,0xff,0xff,0xff,0x82,0x82,0x3e, 189 0xff,0xff,0xc3,0x82,0xff,0xff,0xff,0xb9, 190 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 191 0x82,0x3e,0xff,0xff,0xff,0xff,0xff,0xff, 192 0xff,0xff,0xff,0xff,0xff,0xd5,0x82,0xc3, 193 0xff,0xff,0xff,0x82,0xf8,0xff,0xff,0xd5, 194 0xff,0xc3,0xff,0xff,0xff,0xff,0xff,0xff, 195 0x82,0xd5,0xff,0xff,0xff,0xff,0xff,0xff, 196 0xff,0xff,0xff,0xff,0x3e,0x82,0x82,0x82, 197 0x80,0x3d,0xff,0x3d,0x82,0xff,0xff,0xc3, 198 0xff,0xff,0xff,0xff,0xd5,0xc3,0xd5,0xb9, 199 0x82,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 200 0xff,0xff,0xff,0xff,0x82,0x82,0xd5,0xff, 201 0x82,0xd5,0xff,0xd5,0x82,0xff,0xff,0xb9, 202 0xff,0xb9,0xff,0x82,0x82,0x82,0x82,0x82, 203 0x82,0xc3,0xff,0xff,0xff,0xff,0xff,0xff, 204 0xff,0xff,0xff,0x82,0x82,0x82,0x82,0x3d, 205 0x82,0xb9,0xff,0xc3,0x82,0xff,0xff,0xd5, 206 0xff,0xff,0xd5,0x82,0xd5,0xff,0xff,0xff, 207 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 208 0xff,0xff,0xff,0x82,0x82,0xd5,0x3e,0x82, 209 0x82,0xc3,0xff,0xb9,0x82,0xff,0xff,0xc3, 210 0xff,0xc3,0x3e,0x82,0xff,0xff,0xff,0xff, 211 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 212 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 213 0xff,0xff,0xff,0xd5,0x82,0xff,0xff,0xb9, 214 0xff,0xff,0x82,0x3d,0xff,0xff,0x3e,0xd5, 215 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 216 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 217 0xff,0xff,0xff,0xc3,0x82,0xff,0xff,0xd5, 218 0xff,0xd5,0x82,0xd5,0xff,0xc3,0x82,0xff, 219 0xc3,0xd5,0xb9,0xd5,0xff,0xff,0xff,0xff, 220 0xff,0xff,0xff,0xff,0xff,0xff,0xc3,0xd5, 221 0xb9,0xff,0xff,0xb9,0x82,0xff,0xff,0xc3, 222 0xff,0xb9,0x82,0xb9,0xff,0x82,0x3d,0xff, 223 0x82,0x82,0x82,0x82,0xff,0xff,0xff,0xff, 224 0xff,0xff,0xff,0xff,0xff,0xd5,0x82,0x82, 225 0x82,0x82,0xff,0xd5,0x82,0xff,0xff,0xd5, 226 0xff,0x82,0x82,0x82,0x82,0x82,0x82,0x82, 227 0x82,0x82,0x82,0x82,0x82,0xc3,0xb9,0xd5, 228 0xc3,0xd5,0xff,0xff,0xc3,0x82,0x82,0x82, 229 0x82,0x82,0xb9,0xc3,0x82,0xff,0xff,0xb9, 230 0xff,0xd5,0xc3,0xd5,0xb9,0x82,0x3d,0xd5, 231 0x82,0x82,0x3e,0x82,0x82,0x82,0x82,0x82, 232 0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x3d, 233 0x82,0x82,0x82,0x82,0x3d,0xff,0xff,0xc3, 234 0xff,0xff,0xff,0xff,0xff,0xd5,0x82,0xc3, 235 0x82,0xd5,0xff,0x82,0xd5,0xff,0xff,0xff, 236 0xff,0xd5,0xb9,0xd5,0x82,0x82,0x82,0xd5, 237 0x82,0x82,0x82,0xff,0xd5,0xff,0xff,0xd5, 238 0xff,0xb9,0xff,0xff,0xff,0xff,0x82,0x82, 239 0x82,0xc3,0x82,0x82,0xff,0xff,0xff,0xff, 240 0xff,0xff,0xff,0xff,0xff,0x82,0x82,0x82, 241 0x82,0x82,0x82,0xff,0xff,0xff,0xff,0xb9, 242 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3d, 243 0x82,0x82,0x3d,0xff,0xff,0xff,0xff,0xff, 244 0xff,0xff,0xff,0xff,0xff,0xd5,0x82,0x82, 245 0x82,0x82,0xd5,0xff,0xff,0xff,0xff,0xc3, 246 0xff,0xc3,0xff,0xff,0xff,0xff,0xff,0xff, 247 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 248 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xc3, 249 0xd5,0xff,0xff,0xff,0xff,0xff,0xff,0xd5, 250 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 251 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 252 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 253 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xb9, 254 0xff,0xd5,0xff,0xff,0xff,0xff,0xff,0xff, 255 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 256 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 257 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xc3, 258 0xff,0x80,0x80,0x80,0x80,0x80,0x80,0x80, 259 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, 260 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, 261 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, 262 }; 263 264 static const u_int16_t rgb565_clut[256] = { 265 0x0000, 0x8000, 0x0400, 0x8400, 0x0080, 0x8080, 0x0480, 0x8480, 266 0xc6e0, 0xa6f0, 0x29ea, 0x29ff, 0x2ae0, 0x2af5, 0x2aea, 0x2aff, 267 0x2be0, 0x2bf5, 0x2bea, 0x2bff, 0x2ce0, 0x2cf5, 0x2cea, 0x2cff, 268 0x2de0, 0x2df5, 0x2dea, 0x2dff, 0x2ee0, 0x2ef5, 0x2eea, 0x2eff, 269 0x2fe0, 0x2ff5, 0x2fea, 0x2fff, 0x5000, 0x5055, 0x50aa, 0x50ff, 270 0x50e0, 0x50f5, 0x50ea, 0x50ff, 0x51e0, 0x51f5, 0x51ea, 0x51ff, 271 0x52e0, 0x52f5, 0x52ea, 0x52ff, 0x53e0, 0x53f5, 0x53ea, 0x53ff, 272 0x54e0, 0x54f5, 0x54ea, 0x54ff, 0x55e0, 0x55f5, 0x55ea, 0x55ff, 273 0x56e0, 0x56f5, 0x56ea, 0x56ff, 0x57e0, 0x57f5, 0x57ea, 0x57ff, 274 0x7800, 0x7855, 0x78aa, 0x78ff, 0x78e0, 0x78f5, 0x78ea, 0x78ff, 275 0x79e0, 0x79f5, 0x79ea, 0x79ff, 0x7ae0, 0x7af5, 0x7aea, 0x7aff, 276 0x7be0, 0x7bf5, 0x7bea, 0x7bff, 0x7ce0, 0x7cf5, 0x7cea, 0x7cff, 277 0x7de0, 0x7df5, 0x7dea, 0x7dff, 0x7ee0, 0x7ef5, 0x7eea, 0x7eff, 278 0x7fe0, 0x7ff5, 0x7fea, 0x7fff, 0xa800, 0xa855, 0xa8aa, 0xa8ff, 279 0xa8e0, 0xa8f5, 0xa8ea, 0xa8ff, 0xa9e0, 0xa9f5, 0xa9ea, 0xa9ff, 280 0xaae0, 0xaaf5, 0xaaea, 0xaaff, 0xabe0, 0xabf5, 0xabea, 0xabff, 281 0xace0, 0xacf5, 0xacea, 0xacff, 0xade0, 0xadf5, 0xadea, 0xadff, 282 0xaee0, 0xaef5, 0xaeea, 0xaeff, 0xafe0, 0xaff5, 0xafea, 0xafff, 283 0xd000, 0xd055, 0xd0aa, 0xd0ff, 0xd0e0, 0xd0f5, 0xd0ea, 0xd0ff, 284 0xd1e0, 0xd1f5, 0xd1ea, 0xd1ff, 0xd2e0, 0xd2f5, 0xd2ea, 0xd2ff, 285 0xd3e0, 0xd3f5, 0xd3ea, 0xd3ff, 0xd4e0, 0xd4f5, 0xd4ea, 0xd4ff, 286 0xd5e0, 0xd5f5, 0xd5ea, 0xd5ff, 0xd6e0, 0xd6f5, 0xd6ea, 0xd6ff, 287 0xd7e0, 0xd7f5, 0xd7ea, 0xd7ff, 0xf855, 0xf8aa, 0xf8e0, 0xf8f5, 288 0xf8ea, 0xf8ff, 0xf9e0, 0xf9f5, 0xf9ea, 0xf9ff, 0xfae0, 0xfaf5, 289 0xfaea, 0xfaff, 0xfbe0, 0xfbf5, 0xfbea, 0xfbff, 0xfce0, 0xfcf5, 290 0xfcea, 0xfcff, 0xfde0, 0xfdf5, 0xfdea, 0xfdff, 0xfee0, 0xfef5, 291 0xfeea, 0xfeff, 0xfff5, 0xffea, 0xceff, 0xfeff, 0x37ff, 0x67ff, 292 0x9fff, 0xcfff, 0x03e0, 0x03f5, 0x03ea, 0x03ff, 0x04e0, 0x04f5, 293 0x04ea, 0x04ff, 0x05e0, 0x05f5, 0x05ea, 0x05ff, 0x06e0, 0x06f5, 294 0x06ea, 0x06ff, 0x07f5, 0x07ea, 0x2800, 0x2855, 0x28aa, 0x28ff, 295 0x28e0, 0x28f5, 0x28ea, 0x28ff, 0x29e0, 0x29f5, 0xfff0, 0xa5a4, 296 0x8480, 0xf800, 0x07e0, 0xffe0, 0x00ff, 0xf8ff, 0x07ff, 0xffff 297 }; 298 299 static u_int16_t __color_tab16[] = { 300 RGB565_BLACK, 301 RGB565_RED, 302 RGB565_GREEN, 303 RGB565_YELLOW, 304 RGB565_BLUE, 305 RGB565_MAGENTA, 306 RGB565_CYAN, 307 RGB565_WHITE 308 }; 309 310 static int bootinfo_fb_depth(void); 311 static void __dbg_lcd_test8(vaddr_t, int, int); 312 static void __dbg_lcd_test16(vaddr_t, int, int); 313 314 void 315 dbg_lcd_test() 316 { 317 vaddr_t fbaddr; 318 int w, h; 319 320 if (bootinfo == NULL || bootinfo->fb_addr == NULL) 321 return; 322 323 fbaddr = (vaddr_t)bootinfo->fb_addr; 324 w = bootinfo->fb_width; 325 h = bootinfo->fb_height; 326 327 switch (bootinfo_fb_depth()) { 328 default: 329 break; 330 case 8: 331 __dbg_lcd_test8(fbaddr, w, h); 332 break; 333 case 16: 334 __dbg_lcd_test16(fbaddr, w, h); 335 break; 336 } 337 } 338 339 /* 340 * 8bpp LCD test routine. 341 * HP620LX, HPW50PAD are little-endian display. 342 */ 343 void 344 __dbg_lcd_test8(vaddr_t fbaddr, int w, int h) 345 { 346 u_int8_t *fb, *fb_start = (u_int8_t *)fbaddr; 347 int i, x, y, y_start, y_end, len, skip; 348 u_int16_t *fb16; 349 u_int32_t *fb32; 350 351 /* 352 * Clear screen (BLACK) 353 */ 354 for (fb = fb_start, i = 0; i < w * h; i++) 355 *fb++ = 0; 356 357 /* 358 * Color bar (I assume palette index is ANSI) 359 * BLACK|RED|GREEN|YELLOW|BLUE|MAGENTA|CYAN|WHITE 360 */ 361 len = w / 8; 362 y_start = 0; 363 y_end = h / 2; 364 skip = bootinfo->fb_line_bytes - w; 365 for (fb = fb_start, y = y_start; y < y_end; y++, fb += skip) { 366 for (i = 0; i < 8; i++) { 367 for (x = 0; x < len; x++) 368 *fb++ = i; 369 } 370 } 371 372 /* 373 * Byte order test. (display 32x32 bitmap) 374 */ 375 /* 376 * 8-bit access (reference) 377 */ 378 y_start = y_end; 379 y_end = y_start + 32; 380 i = 0; 381 fb += w / 2 - 16; /* center */ 382 skip = bootinfo->fb_line_bytes - 32; 383 for (y = y_start; y < y_end; y++, fb += skip) 384 for (x = 0; x < 32; x++) 385 *fb++ = img[i++]; 386 387 /* 388 * 16-bit access 389 */ 390 y_start = y_end; 391 y_end = y_start + 32; 392 i = 0; 393 fb16 = (u_int16_t *)fb; 394 skip /= 2; 395 for (y = y_start; y < y_end; y++, fb16 += skip) 396 for (x = 0; x < 16; x++, i += 2) 397 *fb16++ = 398 img[i + 1] << 8 | 399 img[i + 0]; 400 401 /* 402 * 32-bit access 403 */ 404 y_start = y_end; 405 y_end = y_start + 32; 406 i = 0; 407 fb32 = (u_int32_t *)(fb + 32 * w); 408 skip /= 2; 409 for (y = y_start; y < y_end; y++, fb32 += skip) 410 for (x = 0; x < 8; x++, i += 4) 411 *fb32++ = 412 img[i + 3] << 24 | 413 img[i + 2] << 16 | 414 img[i + 1] << 8 | 415 img[i + 0]; 416 } 417 418 /* 419 * 16bpp LCD test routine. 420 * Jornada6[89]0, HPW650PA are big-endian display. 421 */ 422 void 423 __dbg_lcd_test16(vaddr_t fbaddr, int w, int h) 424 { 425 u_int16_t *fb, *fb_start = (u_int16_t *)fbaddr; 426 u_int16_t pat; 427 int i, x, y, y_start, y_end, len, skip; 428 u_int32_t *fb32; 429 430 /* 431 * Clear screen (BLACK) 432 */ 433 pat = __color_tab16[0]; 434 for (fb = fb_start, i = 0; i < w * h; i++) 435 *fb++ = pat; 436 437 /* 438 * Color bar 439 * BLACK|RED|GREEN|YELLOW|BLUE|MAGENTA|CYAN|WHITE 440 */ 441 len = w / 8; 442 y_start = 0; 443 y_end = h / 2; 444 for (fb = fb_start, y = y_start; y < y_end; y++) { 445 for (i = 0; i < 8; i++) { 446 pat = __color_tab16[i]; 447 for (x = 0; x < len; x++) 448 *fb++ = pat; 449 } 450 } 451 y_start = y_end; 452 453 /* 454 * Byte order test. (display 32x32 bitmap) 455 */ 456 /* 457 * 16-bit access (reference) 458 */ 459 y_start = y_end; 460 y_end = y_start + 32; 461 i = 0; 462 fb += w / 2 - 16; /* center */ 463 skip = w - 32; 464 for (y = y_start; y < y_end; y++, fb += skip) 465 for (x = 0; x < 32; x++) 466 *fb++ = rgb565_clut[img[i++]]; 467 468 /* 469 * 32-bit access (test) 470 */ 471 y_start = y_end; 472 y_end = y_start + 32; 473 i = 0; 474 fb32 = (u_int32_t *)fb; 475 skip /= 2; 476 for (y = y_start; y < y_end; y++, fb32 += skip) 477 for (x = 0; x < 16; x++, i += 2) 478 *fb32++ = (rgb565_clut[img[i + 1]] << 16) | 479 rgb565_clut[img[i]]; 480 } 481 482 int 483 bootinfo_fb_depth() 484 { 485 486 switch (bootinfo->fb_type) { 487 case BIFB_D2_M2L_3: 488 /* FALLTHROUGH */ 489 case BIFB_D2_M2L_0: 490 return (2); 491 case BIFB_D4_M2L_F: 492 /* FALLTHROUGH */ 493 case BIFB_D4_M2L_0: 494 return (4); 495 case BIFB_D8_FF: 496 /* FALLTHROUGH */ 497 case BIFB_D8_00: 498 return (8); 499 case BIFB_D16_FFFF: 500 /* FALLTHROUGH */ 501 case BIFB_D16_0000: 502 return (16); 503 } 504 505 return (0); 506 } 507 508 #endif /* HPC_DEBUG_LCD */ 509