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