hd64461video.c revision 1.12 1 /* $NetBSD: hd64461video.c,v 1.12 2002/09/06 13:18:43 gehenna 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_hpcsh.h"
40 // #define HD64461VIDEO_HWACCEL
41
42 #include <sys/param.h>
43 #include <sys/systm.h>
44 #include <sys/device.h>
45 #include <sys/malloc.h>
46
47 #include <sys/conf.h> /* cdev_decl */
48 #include <dev/cons.h> /* consdev */
49
50 /* ioctl */
51 #include <sys/ioctl.h>
52 #include <sys/buf.h>
53 #include <uvm/uvm_extern.h>
54
55 #include <machine/bus.h>
56 #include <machine/intr.h>
57
58 #include <hpcsh/dev/hd64461/hd64461var.h>
59 #include <hpcsh/dev/hd64461/hd64461reg.h>
60 #include <hpcsh/dev/hd64461/hd64461videoreg.h>
61
62 #include <dev/wscons/wsdisplayvar.h>
63 #include <dev/rasops/rasops.h>
64
65 #include <dev/wscons/wsconsio.h>
66 #include <dev/hpc/hpcfbvar.h>
67 #include <dev/hpc/hpcfbio.h>
68 #include <dev/hpc/video_subr.h>
69
70 #include <machine/bootinfo.h>
71
72 #ifdef HD64461VIDEO_DEBUG
73 #define DPRINTF_ENABLE
74 #define DPRINTF_DEBUG hd64461video_debug
75 #endif
76 #include <machine/debug.h>
77
78 struct hd64461video_chip;
79 struct hd64461video_font {
80 struct wsdisplay_font wsfont;
81 int c, cw, cstep;
82 int loaded;
83 };
84
85 struct hd64461video_softc {
86 struct device sc_dev;
87 enum hd64461_module_id sc_module_id;
88 struct hd64461video_chip *sc_vc;
89
90 struct hd64461video_font sc_font;
91 };
92
93 STATIC struct hd64461video_chip {
94 struct video_chip vc;
95 enum hd64461video_display_mode {
96 LCD256_C,
97 LCD64K_C,
98 LCD64_MONO,
99 LCD16_MONO,
100 LCD4_MONO,
101 LCD2_MONO,
102 CRT256_C,
103 LCDCRT
104 };
105 enum hd64461video_display_mode mode;
106 struct hpcfb_dspconf hd;
107 struct hpcfb_fbconf hf;
108 u_int8_t *off_screen_addr;
109 size_t off_screen_size;
110
111 int console;
112 } hd64461video_chip;
113
114 void hd64461video_cnprobe(struct consdev *);
115 void hd64461video_cninit(struct consdev *);
116
117 STATIC int hd64461video_match(struct device *, struct cfdata *, void *);
118 STATIC void hd64461video_attach(struct device *, struct device *, void *);
119
120 STATIC void hd64461video_setup_hpcfbif(struct hd64461video_chip *);
121 STATIC void hd64461video_update_videochip_status(struct hd64461video_chip *);
122 STATIC size_t hd64461video_frame_buffer_size(struct hd64461video_chip *);
123 STATIC void hd64461video_hwaccel_init(struct hd64461video_chip *);
124
125 STATIC void hd64461video_set_clut(struct hd64461video_chip *, int, int,
126 u_int8_t *, u_int8_t *, u_int8_t *);
127 STATIC void hd64461video_get_clut(struct hd64461video_chip *, int, int,
128 u_int8_t *, u_int8_t *, u_int8_t *);
129 #if notyet
130 STATIC void hd64461video_set_display_mode(struct hd64461video_chip *);
131 STATIC void hd64461video_set_display_mode_lcdc(struct hd64461video_chip *);
132 STATIC void hd64461video_set_display_mode_crtc(struct hd64461video_chip *);
133 #endif
134
135 #ifdef HD64461VIDEO_DEBUG
136 STATIC void hd64461video_info(struct hd64461video_softc *);
137 STATIC void hd64461video_dump(void) __attribute__((__unused__));
138 #endif
139
140 struct cfattach hd64461video_ca = {
141 sizeof(struct hd64461video_softc), hd64461video_match,
142 hd64461video_attach
143 };
144
145 int hd64461video_ioctl(void *, u_long, caddr_t, int, struct proc *);
146 paddr_t hd64461video_mmap(void *, off_t, int);
147 void hd64461video_cursor(void *, int, int, int, int, int);
148 void hd64461video_bitblit(void *, int, int, int, int, int, int);
149 void hd64461video_erase(void *, int, int, int, int, int);
150 void hd64461video_putchar(void *, int, int, struct wsdisplay_font *, int, int,
151 u_int, int);
152 void hd64461video_setclut(void *, struct rasops_info *);
153 void hd64461video_font(void *, struct wsdisplay_font *);
154 void hd64461video_iodone(void *);
155
156 struct hpcfb_accessops hd64461video_ha = {
157 .ioctl = hd64461video_ioctl,
158 .mmap = hd64461video_mmap,
159 #ifdef HD64461VIDEO_HWACCEL
160 .cursor = hd64461video_cursor,
161 .bitblit= hd64461video_bitblit,
162 .erase = hd64461video_erase,
163 .putchar= hd64461video_putchar,
164 .setclut= hd64461video_setclut,
165 .font = hd64461video_font,
166 .iodone = hd64461video_iodone
167 #endif /* HD64461VIDEO_HWACCEL */
168 };
169
170 /* font */
171 STATIC void hd64461video_font_load_16bpp(u_int16_t *, u_int8_t *, int, int, int);
172 STATIC void hd64461video_font_load_8bpp(u_int8_t *, u_int8_t *, int, int, int);
173 STATIC void hd64461video_font_set_attr(struct hd64461video_softc *,
174 struct wsdisplay_font *);
175 STATIC void hd64461video_font_load(struct hd64461video_softc *);
176 STATIC vaddr_t hd64461video_font_start_addr(struct hd64461video_softc *, int);
177
178 int
179 hd64461video_match(struct device *parent, struct cfdata *cf, void *aux)
180 {
181 struct hd64461_attach_args *ha = aux;
182
183 return (ha->ha_module_id == HD64461_MODULE_VIDEO);
184 }
185
186 void
187 hd64461video_attach(struct device *parent, struct device *self, void *aux)
188 {
189 struct hd64461_attach_args *ha = aux;
190 struct hd64461video_softc *sc = (struct hd64461video_softc *)self;
191 struct hpcfb_attach_args hfa;
192 struct video_chip *vc = &hd64461video_chip.vc;
193 char pbuf[9];
194 size_t fbsize, on_screen_size;
195
196 sc->sc_module_id = ha->ha_module_id;
197 sc->sc_vc = &hd64461video_chip;
198 printf(": ");
199
200 /* detect frame buffer size */
201 fbsize = hd64461video_frame_buffer_size(&hd64461video_chip);
202 format_bytes(pbuf, sizeof(pbuf), fbsize);
203 printf("frame buffer = %s ", pbuf);
204
205 /* update chip status */
206 hd64461video_update_videochip_status(&hd64461video_chip);
207 // hd64461video_set_display_mode(&hd64461video_chip);
208
209 if (hd64461video_chip.console)
210 printf(", console");
211
212 printf("\n");
213 #ifdef HD64461VIDEO_DEBUG
214 hd64461video_info(sc);
215 hd64461video_dump();
216 #endif
217
218
219 /* setup hpcfb interface */
220 hd64461video_setup_hpcfbif(&hd64461video_chip);
221
222 /* setup off-screen buffer */
223 on_screen_size = (vc->vc_fbwidth * vc->vc_fbheight * vc->vc_fbdepth) /
224 NBBY;
225 hd64461video_chip.off_screen_addr = (u_int8_t *)vc->vc_fbvaddr +
226 on_screen_size;
227 hd64461video_chip.off_screen_size = fbsize - on_screen_size;
228 /* clean up off-screen area */
229 {
230 u_int8_t *p = hd64461video_chip.off_screen_addr;
231 u_int8_t *end = p + hd64461video_chip.off_screen_size;
232 while (p < end)
233 *p++ = 0xff;
234 }
235
236 /* initialize hardware acceralation */
237 hd64461video_hwaccel_init(&hd64461video_chip);
238
239 /* register interface to hpcfb */
240 hfa.ha_console = hd64461video_chip.console;
241 hfa.ha_accessops = &hd64461video_ha;
242 hfa.ha_accessctx = sc;
243 hfa.ha_curfbconf = 0;
244 hfa.ha_nfbconf = 1;
245 hfa.ha_fbconflist = &hd64461video_chip.hf;
246 hfa.ha_curdspconf = 0;
247 hfa.ha_ndspconf = 1;
248 hfa.ha_dspconflist = &hd64461video_chip.hd;
249
250 config_found(self, &hfa, hpcfbprint);
251 }
252
253 /* console support */
254 void
255 hd64461video_cninit(struct consdev *cndev)
256 {
257 hd64461video_chip.console = 1;
258 hd64461video_chip.vc.vc_reverse = video_reverse_color();
259
260 hd64461video_update_videochip_status(&hd64461video_chip);
261 hd64461video_setup_hpcfbif(&hd64461video_chip);
262 hpcfb_cnattach(&hd64461video_chip.hf);
263
264 cn_tab->cn_pri = CN_INTERNAL;
265 }
266
267 void
268 hd64461video_cnprobe(struct consdev *cndev)
269 {
270 #if NWSDISPLAY > 0
271 extern const struct cdevsw wsdisplay_cdevsw;
272 int maj, unit;
273 #endif
274 cndev->cn_dev = NODEV;
275 cndev->cn_pri = CN_NORMAL;
276
277 #if NWSDISPLAY > 0
278 unit = 0;
279 maj = cdevsw_lookup_major(&wsdisplay_cdevsw);
280
281 if (maj != -1) {
282 cndev->cn_pri = CN_INTERNAL;
283 cndev->cn_dev = makedev(maj, unit);
284 }
285 #endif /* NWSDISPLAY > 0 */
286 }
287
288 /* hpcfb support */
289 void
290 hd64461video_setup_hpcfbif(struct hd64461video_chip *hvc)
291 {
292 struct video_chip *vc = &hvc->vc;
293 struct hpcfb_fbconf *fb = &hvc->hf;
294 vaddr_t fbvaddr = vc->vc_fbvaddr;
295 int height = vc->vc_fbheight;
296 int width = vc->vc_fbwidth;
297 int depth = vc->vc_fbdepth;
298
299 memset(fb, 0, sizeof(struct hpcfb_fbconf));
300
301 fb->hf_conf_index = 0; /* configuration index */
302 fb->hf_nconfs = 1; /* how many configurations */
303 strncpy(fb->hf_name, "HD64461 video module", HPCFB_MAXNAMELEN);
304
305 /* frame buffer name */
306 strncpy(fb->hf_conf_name, "LCD", HPCFB_MAXNAMELEN);
307
308 /* configuration name */
309 fb->hf_height = height;
310 fb->hf_width = width;
311 fb->hf_baseaddr = (u_long)fbvaddr;
312 fb->hf_offset = (u_long)fbvaddr -
313 sh3_ptob(sh3_btop(fbvaddr));
314
315 /* frame buffer start offset */
316 fb->hf_bytes_per_line = (width * depth) / NBBY;
317 fb->hf_nplanes = 1;
318 fb->hf_bytes_per_plane = height * fb->hf_bytes_per_line;
319
320 fb->hf_access_flags |= HPCFB_ACCESS_BYTE;
321 fb->hf_access_flags |= HPCFB_ACCESS_WORD;
322 fb->hf_access_flags |= HPCFB_ACCESS_DWORD;
323 if (vc->vc_reverse)
324 fb->hf_access_flags |= HPCFB_ACCESS_REVERSE;
325
326 switch (depth) {
327 default:
328 panic("%s: not supported color depth\n", __FUNCTION__);
329 /* NOTREACHED */
330 case 16:
331 fb->hf_class = HPCFB_CLASS_RGBCOLOR;
332 fb->hf_access_flags |= HPCFB_ACCESS_STATIC;
333 fb->hf_pack_width = 16;
334 fb->hf_pixels_per_pack = 1;
335 fb->hf_pixel_width = 16;
336
337 fb->hf_class_data_length = sizeof(struct hf_rgb_tag);
338 /* reserved for future use */
339 fb->hf_u.hf_rgb.hf_flags = 0;
340
341 fb->hf_u.hf_rgb.hf_red_width = 5;
342 fb->hf_u.hf_rgb.hf_red_shift = 11;
343 fb->hf_u.hf_rgb.hf_green_width = 6;
344 fb->hf_u.hf_rgb.hf_green_shift = 5;
345 fb->hf_u.hf_rgb.hf_blue_width = 5;
346 fb->hf_u.hf_rgb.hf_blue_shift = 0;
347 fb->hf_u.hf_rgb.hf_alpha_width = 0;
348 fb->hf_u.hf_rgb.hf_alpha_shift = 0;
349 break;
350
351 case 8:
352 fb->hf_class = HPCFB_CLASS_INDEXCOLOR;
353 fb->hf_access_flags |= HPCFB_ACCESS_STATIC;
354 fb->hf_pack_width = 8;
355 fb->hf_pixels_per_pack = 1;
356 fb->hf_pixel_width = 8;
357 fb->hf_class_data_length = sizeof(struct hf_indexed_tag);
358 /* reserved for future use */
359 fb->hf_u.hf_indexed.hf_flags = 0;
360 break;
361 }
362 }
363
364 void
365 hd64461video_hwaccel_init(struct hd64461video_chip *hvc)
366 {
367 u_int16_t r;
368
369 r = HD64461_LCDGRCFGR_ACCRESET;
370 switch (hvc->vc.vc_fbdepth) {
371 default:
372 panic("no bitblit acceralation.");
373 case 16:
374 break;
375 case 8:
376 r |= HD64461_LCDGRCFGR_COLORDEPTH_8BPP;
377 break;
378 }
379 hd64461_reg_write_2(HD64461_LCDGRCFGR_REG16, r);
380
381 while ((hd64461_reg_read_2(HD64461_LCDGRCFGR_REG16) &
382 HD64461_LCDGRCFGR_ACCSTATUS) != 0)
383 /* busy loop */;
384 r &= ~HD64461_LCDGRCFGR_ACCRESET;
385 hd64461_reg_write_2(HD64461_LCDGRCFGR_REG16, r);
386
387 while ((hd64461_reg_read_2(HD64461_LCDGRCFGR_REG16) &
388 HD64461_LCDGRCFGR_ACCSTATUS) != 0)
389 /* busy loop */;
390
391 hd64461_reg_write_2(HD64461_LCDGRDOR_REG16,
392 (hvc->vc.vc_fbwidth - 1) & HD64461_LCDGRDOR_MASK);
393 }
394
395 /* hpcfb ops */
396 int
397 hd64461video_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p)
398 {
399 struct hd64461video_softc *sc = (struct hd64461video_softc *)v;
400 struct hpcfb_fbconf *hf = &sc->sc_vc->hf;
401 struct hpcfb_fbconf *fbconf;
402 struct hpcfb_dspconf *dspconf;
403 struct wsdisplay_cmap *cmap;
404 u_int8_t *r, *g, *b;
405 int error;
406 size_t idx, cnt;
407
408 switch (cmd) {
409 case WSDISPLAYIO_GETCMAP:
410 cmap = (struct wsdisplay_cmap*)data;
411 cnt = cmap->count;
412 idx = cmap->index;
413
414 if (hf->hf_class != HPCFB_CLASS_INDEXCOLOR ||
415 hf->hf_pack_width != 8 ||
416 !LEGAL_CLUT_INDEX(idx) ||
417 !LEGAL_CLUT_INDEX(idx + cnt -1)) {
418 return (EINVAL);
419 }
420
421 if (!uvm_useracc(cmap->red, cnt, B_WRITE) ||
422 !uvm_useracc(cmap->green, cnt, B_WRITE) ||
423 !uvm_useracc(cmap->blue, cnt, B_WRITE)) {
424 return (EFAULT);
425 }
426
427 error = cmap_work_alloc(&r, &g, &b, 0, cnt);
428 if (error != 0) {
429 cmap_work_free(r, g, b, 0);
430 return (ENOMEM);
431 }
432
433 hd64461video_get_clut(sc->sc_vc, idx, cnt, r, g, b);
434 copyout(r, cmap->red, cnt);
435 copyout(g, cmap->green,cnt);
436 copyout(b, cmap->blue, cnt);
437 cmap_work_free(r, g, b, 0);
438
439 return (0);
440
441 case WSDISPLAYIO_PUTCMAP:
442 cmap = (struct wsdisplay_cmap *)data;
443 cnt = cmap->count;
444 idx = cmap->index;
445
446 if (hf->hf_class != HPCFB_CLASS_INDEXCOLOR ||
447 hf->hf_pack_width != 8 ||
448 !LEGAL_CLUT_INDEX(idx) ||
449 !LEGAL_CLUT_INDEX(idx + cnt -1)) {
450 return (EINVAL);
451 }
452
453 if (!uvm_useracc(cmap->red, cnt, B_WRITE) ||
454 !uvm_useracc(cmap->green, cnt, B_WRITE) ||
455 !uvm_useracc(cmap->blue, cnt, B_WRITE)) {
456 return (EFAULT);
457 }
458
459 error = cmap_work_alloc(&r, &g, &b, 0, cnt);
460 if (error != 0) {
461 cmap_work_free(r, g, b, 0);
462 return (ENOMEM);
463 }
464
465 copyin(cmap->red, r, cnt);
466 copyin(cmap->green,g, cnt);
467 copyin(cmap->blue, b, cnt);
468 hd64461video_set_clut(sc->sc_vc, idx, cnt, r, g, b);
469 cmap_work_free(r, g, b, 0);
470
471 return (0);
472
473 case HPCFBIO_GCONF:
474 fbconf = (struct hpcfb_fbconf *)data;
475 if (fbconf->hf_conf_index != 0 &&
476 fbconf->hf_conf_index != HPCFB_CURRENT_CONFIG) {
477 return (EINVAL);
478 }
479 *fbconf = *hf; /* structure assignment */
480 return (0);
481
482 case HPCFBIO_SCONF:
483 fbconf = (struct hpcfb_fbconf *)data;
484 if (fbconf->hf_conf_index != 0 &&
485 fbconf->hf_conf_index != HPCFB_CURRENT_CONFIG) {
486 return (EINVAL);
487 }
488 /*
489 * nothing to do because we have only one configration
490 */
491 return (0);
492
493 case HPCFBIO_GDSPCONF:
494 dspconf = (struct hpcfb_dspconf *)data;
495 if ((dspconf->hd_unit_index != 0 &&
496 dspconf->hd_unit_index != HPCFB_CURRENT_UNIT) ||
497 (dspconf->hd_conf_index != 0 &&
498 dspconf->hd_conf_index != HPCFB_CURRENT_CONFIG)) {
499 return (EINVAL);
500 }
501 *dspconf = sc->sc_vc->hd; /* structure assignment */
502 return (0);
503
504 case HPCFBIO_SDSPCONF:
505 dspconf = (struct hpcfb_dspconf *)data;
506 if ((dspconf->hd_unit_index != 0 &&
507 dspconf->hd_unit_index != HPCFB_CURRENT_UNIT) ||
508 (dspconf->hd_conf_index != 0 &&
509 dspconf->hd_conf_index != HPCFB_CURRENT_CONFIG)) {
510 return (EINVAL);
511 }
512 /*
513 * nothing to do
514 * because we have only one unit and one configration
515 */
516 return (0);
517
518 case HPCFBIO_GOP:
519 case HPCFBIO_SOP:
520 /* XXX not implemented yet */
521 return (EINVAL);
522 }
523
524 return (EPASSTHROUGH);
525 }
526
527 paddr_t
528 hd64461video_mmap(void *ctx, off_t offset, int prot)
529 {
530 struct hd64461video_softc *sc = (struct hd64461video_softc *)ctx;
531 struct hpcfb_fbconf *hf = &sc->sc_vc->hf;
532
533 if (offset < 0 || (hf->hf_bytes_per_plane + hf->hf_offset) < offset)
534 return (-1);
535
536 return (sh3_btop(HD64461_FBBASE + offset));
537 }
538
539 void
540 hd64461video_cursor(void *ctx, int on, int xd, int yd, int w, int h)
541 {
542 struct hd64461video_softc *sc = (struct hd64461video_softc *)ctx;
543 int xw, yh, width, bpp, adr;
544 u_int16_t r;
545
546 width = sc->sc_vc->vc.vc_fbwidth;
547 bpp = sc->sc_vc->vc.vc_fbdepth;
548 xw = w - 1;
549 yh = h - 1;
550
551 /* Wait until previous command done. */
552 hd64461video_iodone(ctx);
553
554 /* Destination addr */
555 adr = width * yd + xd;
556 if (bpp == 16)
557 adr *= 2;
558 hd64461_reg_write_2(HD64461_LCDBBTDSARH_REG16,
559 HD64461_LCDBBTDSARH(adr));
560 hd64461_reg_write_2(HD64461_LCDBBTDSARL_REG16,
561 HD64461_LCDBBTDSARL(adr));
562
563 // Width
564 hd64461_reg_write_2(HD64461_LCDBBTDWR_REG16,
565 xw & HD64461_LCDBBTDWR_MASK);
566
567 // Height
568 hd64461_reg_write_2(HD64461_LCDBBTDHR_REG16,
569 yh & HD64461_LCDBBTDHR_MASK);
570
571 // Operation (Destination Invert)
572 hd64461_reg_write_2(HD64461_LCDBBTROPR_REG16,
573 HD64461_LCDC_BITBLT_DSTINVERT);
574
575 // BitBLT mode (Destination Invert)
576 hd64461_reg_write_2(HD64461_LCDBBTMDR_REG16, 0);
577
578 // Kick.
579 r = hd64461_reg_read_2(HD64461_LCDGRCFGR_REG16);
580 r &= ~HD64461_LCDGRCFGR_ACCSTART_MASK;
581 r |= HD64461_LCDGRCFGR_ACCSTART_BITBLT;
582 hd64461_reg_write_2(HD64461_LCDGRCFGR_REG16, r);
583 }
584
585 void
586 hd64461video_bitblit(void *ctx, int xs, int ys, int xd, int yd, int h, int w)
587 {
588 struct hd64461video_softc *sc = (struct hd64461video_softc *)ctx;
589 int xw, yh, width, bpp, condition_a, adr;
590 u_int16_t r;
591
592 xw = w - 1;
593 yh = h - 1;
594 width = sc->sc_vc->vc.vc_fbwidth;
595 bpp = sc->sc_vc->vc.vc_fbdepth;
596 condition_a = ((ys == yd) && (xs <= xd)) || (ys < yd);
597
598 hd64461video_iodone(ctx);
599
600 // Source addr
601 if (condition_a)
602 adr = (width * (ys + yh)) + (xs + xw);
603 else
604 adr = width * ys + xs;
605 if (bpp == 16)
606 adr *= 2;
607
608 hd64461_reg_write_2(HD64461_LCDBBTSSARH_REG16,
609 HD64461_LCDBBTSSARH(adr));
610 hd64461_reg_write_2(HD64461_LCDBBTSSARL_REG16,
611 HD64461_LCDBBTSSARL(adr));
612
613 // Destination addr
614 if (condition_a)
615 adr = (width * (yd + yh)) + (xd + xw);
616 else
617 adr = width * yd + xd;
618 if (bpp == 16)
619 adr *= 2;
620
621 hd64461_reg_write_2(HD64461_LCDBBTDSARH_REG16,
622 HD64461_LCDBBTDSARH(adr));
623 hd64461_reg_write_2(HD64461_LCDBBTDSARL_REG16,
624 HD64461_LCDBBTDSARL(adr));
625
626 // Width
627 hd64461_reg_write_2(HD64461_LCDBBTDWR_REG16,
628 xw & HD64461_LCDBBTDWR_MASK);
629
630 // Height
631 hd64461_reg_write_2(HD64461_LCDBBTDHR_REG16,
632 yh & HD64461_LCDBBTDHR_MASK);
633
634 // Operation (source copy)
635 hd64461_reg_write_2(HD64461_LCDBBTROPR_REG16,
636 HD64461_LCDC_BITBLT_SRCCOPY);
637
638 // BitBLT mode (on screen to on screen)
639 r = HD64461_LCDBBTMDR_SET(0,
640 HD64461_LCDBBTMDR_ON_SCREEN_TO_ON_SCREEN);
641 hd64461_reg_write_2(HD64461_LCDBBTMDR_REG16, r);
642
643 // Kick.
644 r = hd64461_reg_read_2(HD64461_LCDGRCFGR_REG16);
645 r &= ~HD64461_LCDGRCFGR_ACCSTART_MASK;
646 r |= HD64461_LCDGRCFGR_ACCSTART_BITBLT;
647 hd64461_reg_write_2(HD64461_LCDGRCFGR_REG16, r);
648 }
649
650 void
651 hd64461video_erase(void *ctx, int xd, int yd, int h, int w, int attr)
652 {
653 struct hd64461video_softc *sc = (struct hd64461video_softc *)ctx;
654 int xw, yh, width, bpp, adr;
655 u_int16_t r;
656
657 width = sc->sc_vc->vc.vc_fbwidth;
658 bpp = sc->sc_vc->vc.vc_fbdepth;
659 xw = w - 1;
660 yh = h - 1;
661
662 /* Wait until previous command done. */
663 hd64461video_iodone(ctx);
664
665 /* Destination addr */
666 adr = width * yd + xd;
667 if (bpp == 16)
668 adr *= 2;
669 hd64461_reg_write_2(HD64461_LCDBBTDSARH_REG16,
670 HD64461_LCDBBTDSARH(adr));
671 hd64461_reg_write_2(HD64461_LCDBBTDSARL_REG16,
672 HD64461_LCDBBTDSARL(adr));
673
674 // Width
675 hd64461_reg_write_2(HD64461_LCDBBTDWR_REG16,
676 xw & HD64461_LCDBBTDWR_MASK);
677
678 // Height
679 hd64461_reg_write_2(HD64461_LCDBBTDHR_REG16,
680 yh & HD64461_LCDBBTDHR_MASK);
681
682 // Color
683 hd64461_reg_write_2(HD64461_LCDGRSCR_REG16, 0); //XXX black only
684
685 // Operation (Solid Color Fill)
686 hd64461_reg_write_2(HD64461_LCDBBTROPR_REG16,
687 HD64461_LCDC_BITBLT_PATCOPY);
688
689 // BitBLT mode (Solid Color)
690 hd64461_reg_write_2(HD64461_LCDBBTMDR_REG16,
691 HD64461_LCDBBTMDR_PATSELECT_SOLIDCOLOR);
692
693 // Kick.
694 r = hd64461_reg_read_2(HD64461_LCDGRCFGR_REG16);
695 r &= ~HD64461_LCDGRCFGR_ACCSTART_MASK;
696 r |= HD64461_LCDGRCFGR_ACCSTART_BITBLT;
697 hd64461_reg_write_2(HD64461_LCDGRCFGR_REG16, r);
698 }
699
700 void
701 hd64461video_putchar(void *ctx, int row, int col, struct wsdisplay_font *font,
702 int fclr, int uclr, u_int uc, int attr)
703 {
704 struct hd64461video_softc *sc = (struct hd64461video_softc *)ctx;
705 int w, h, cw;
706
707 w = font->fontwidth;
708 h = font->fontheight;
709 cw = sc->sc_font.cw;
710 hd64461video_bitblit(ctx, (uc % cw) * w,
711 sc->sc_vc->vc.vc_fbheight + (uc / cw) * h, row, col, h, w);
712 }
713
714 void
715 hd64461video_setclut(void *ctx, struct rasops_info *info)
716 {
717 struct hd64461video_softc *sc = (struct hd64461video_softc *)ctx;
718
719 if (sc->sc_vc->vc.vc_fbdepth != 8)
720 return;
721 }
722
723 void
724 hd64461video_font(void *ctx, struct wsdisplay_font *font)
725 {
726 struct hd64461video_softc *sc = (struct hd64461video_softc *)ctx;
727
728 hd64461video_font_set_attr(sc, font);
729 hd64461video_font_load(sc);
730 }
731
732 void
733 hd64461video_iodone(void *ctx)
734 {
735 while ((hd64461_reg_read_2(HD64461_LCDGRCFGR_REG16) &
736 HD64461_LCDGRCFGR_ACCSTATUS) != 0)
737 /* busy loop */;
738 }
739
740 /* internal */
741 void
742 hd64461video_font_load_16bpp(u_int16_t *d, u_int8_t *s, int w, int h, int step)
743 {
744 int i, j, n;
745 n = step / sizeof(u_int16_t);
746
747 for (i = 0; i < h; i++, d += n) {
748 for (j = 0; j < w; j++) {
749 d[j] = *s & (1 << (w - j - 1)) ? 0xffff : 0x0000;
750 }
751 s++;
752 }
753 }
754
755 void
756 hd64461video_font_load_8bpp(u_int8_t *d, u_int8_t *s, int w, int h, int step)
757 {
758 int i, j, n;
759 n = step / sizeof(u_int8_t);
760
761 for (i = 0; i < h; i++, d += n) {
762 for (j = 0; j < w; j++) {
763 d[j] = *s & (1 << (w - j - 1)) ? 0xff : 0x00;
764 }
765 s++;
766 }
767 }
768
769 void
770 hd64461video_font_set_attr(struct hd64461video_softc *sc,
771 struct wsdisplay_font *f)
772 {
773 struct hd64461video_chip *hvc = sc->sc_vc;
774 struct wsdisplay_font *font = (struct wsdisplay_font *)&sc->sc_font;
775 int w, h, bpp;
776
777 w = f->fontwidth;
778 h = f->fontheight;
779 bpp = hvc->vc.vc_fbdepth;
780
781 *font = *f;
782 sc->sc_font.c = (w * bpp) / NBBY;
783 sc->sc_font.cw = hvc->hf.hf_width / w;
784 sc->sc_font.cstep = ((w * h * bpp) / NBBY) * sc->sc_font.cw;
785
786 DPRINTF("c = %d cw = %d cstep = %d\n", sc->sc_font.c,
787 sc->sc_font.cw, sc->sc_font.cstep);
788
789 }
790
791 /* return frame buffer virtual address of charcter #n */
792 vaddr_t
793 hd64461video_font_start_addr(struct hd64461video_softc *sc, int n)
794 {
795 struct hd64461video_chip *hvc = sc->sc_vc;
796 struct hd64461video_font *font = &sc->sc_font;
797 vaddr_t base;
798
799 base = (vaddr_t)hvc->off_screen_addr;
800 base += (n / font->cw) * font->cstep + font->c * (n % font->cw);
801
802 return base;
803 }
804
805 void
806 hd64461video_font_load(struct hd64461video_softc *sc)
807 {
808 struct hd64461video_chip *hvc = sc->sc_vc;
809 struct wsdisplay_font *font = (struct wsdisplay_font *)&sc->sc_font;
810 u_int8_t *q;
811 int w, h, step, i, n;
812
813 if (sc->sc_font.loaded) {
814 printf("reload font\n");
815 }
816
817 w = font->fontwidth;
818 h = font->fontheight;
819 step = sc->sc_font.cw * sc->sc_font.c;
820 n = (w * h) / NBBY;
821 q = font->data;
822
823 DPRINTF("%s (%dx%d) %d+%d\n", font->name, w, h, font->firstchar,
824 font->numchars);
825 DPRINTF("bitorder %d byteorder %d stride %d\n", font->bitorder,
826 font->byteorder, font->stride);
827
828 switch (hvc->vc.vc_fbdepth) {
829 case 8:
830 for (i = font->firstchar; i < font->numchars; i++) {
831 hd64461video_font_load_8bpp
832 ((u_int8_t *)hd64461video_font_start_addr(sc, i),
833 q, w, h, step);
834 q += n;
835 }
836 break;
837 case 16:
838 for (i = font->firstchar; i < font->numchars; i++) {
839 hd64461video_font_load_16bpp
840 ((u_int16_t *)hd64461video_font_start_addr(sc, i),
841 q, w, h, step);
842 q += n;
843 }
844 break;
845 }
846
847 sc->sc_font.loaded = TRUE;
848 }
849
850 void
851 hd64461video_update_videochip_status(struct hd64461video_chip *hvc)
852 {
853 struct video_chip *vc = &hvc->vc;
854 u_int16_t r;
855 int i;
856 int depth, width, height;
857
858 /* display mode */
859 r = hd64461_reg_read_2(HD64461_LCDLDR3_REG16);
860 i = HD64461_LCDLDR3_CG(r);
861 switch (i) {
862 case HD64461_LCDLDR3_CG_COLOR16:
863 depth = 16;
864 hvc->mode = LCD64K_C;
865 break;
866 case HD64461_LCDLDR3_CG_COLOR8:
867 depth = 8;
868 hvc->mode = LCD256_C;
869 break;
870 case HD64461_LCDLDR3_CG_GRAY6:
871 depth = 6;
872 hvc->mode = LCD64_MONO;
873 break;
874 case HD64461_LCDLDR3_CG_GRAY4:
875 depth = 4;
876 hvc->mode = LCD16_MONO;
877 break;
878 case HD64461_LCDLDR3_CG_GRAY2:
879 depth = 2;
880 hvc->mode = LCD4_MONO;
881 break;
882 case HD64461_LCDLDR3_CG_GRAY1:
883 depth = 1;
884 hvc->mode = LCD2_MONO;
885 break;
886 }
887
888 r = hd64461_reg_read_2(HD64461_LCDCCR_REG16);
889 i = HD64461_LCDCCR_DSPSEL(i);
890 switch (i) {
891 case HD64461_LCDCCR_DSPSEL_LCD_CRT:
892 depth = 8;
893 hvc->mode = LCDCRT;
894 break;
895 case HD64461_LCDCCR_DSPSEL_CRT:
896 depth = 8;
897 hvc->mode = CRT256_C;
898 break;
899 case HD64461_LCDCCR_DSPSEL_LCD:
900 /* nothing to do */
901 break;
902 }
903
904 width = bootinfo->fb_width;
905 height = bootinfo->fb_height;
906
907 vc->vc_fbvaddr = HD64461_FBBASE;
908 vc->vc_fbpaddr = HD64461_FBBASE;
909 vc->vc_fbdepth = depth;
910 vc->vc_fbsize = (width * height * depth) / NBBY;
911 vc->vc_fbwidth = width;
912 vc->vc_fbheight = height;
913 }
914
915 #if notyet
916 void
917 hd64461video_set_display_mode(struct hd64461video_chip *hvc)
918 {
919
920 if (hvc->mode == LCDCRT || hvc->mode == CRT256_C)
921 hd64461video_set_display_mode_crtc(hvc);
922
923 hd64461video_set_display_mode_lcdc(hvc);
924 }
925
926 void
927 hd64461video_set_display_mode_lcdc(struct hd64461video_chip *hvc)
928 {
929 struct {
930 u_int16_t clor; /* display size 640 x 240 */
931 u_int16_t ldr3;
932 const char *name;
933 } disp_conf[] = {
934 [LCD256_C] = { 0x280 , HD64461_LCDLDR3_CG_COLOR8 ,
935 "8bit color" },
936 [LCD64K_C] = { 0x500 , HD64461_LCDLDR3_CG_COLOR16 ,
937 "16bit color" },
938 [LCD64_MONO] = { 0x280 , HD64461_LCDLDR3_CG_GRAY6 ,
939 "6bit gray scale" },
940 [LCD16_MONO] = { 0x140 , HD64461_LCDLDR3_CG_GRAY4 ,
941 "4bit gray scale" },
942 [LCD4_MONO] = { 0x0a0 , HD64461_LCDLDR3_CG_GRAY2 ,
943 "2bit gray scale" },
944 [LCD2_MONO] = { 0x050 , HD64461_LCDLDR3_CG_GRAY1 ,
945 "mono chrome" },
946 }, *conf;
947 u_int16_t r;
948 int omode;
949
950 conf = &disp_conf[hvc->mode];
951
952 hd64461_reg_write_2(HD64461_LCDCLOR_REG16, conf->clor);
953 r = hd64461_reg_read_2(HD64461_LCDLDR3_REG16);
954 omode = HD64461_LCDLDR3_CG(r);
955 r = HD64461_LCDLDR3_CG_CLR(r);
956 r = HD64461_LCDLDR3_CG_SET(r, conf->ldr3);
957 hd64461_reg_write_2(HD64461_LCDLDR3_REG16, r);
958
959 printf("%s ", conf->name);
960 }
961
962 void
963 hd64461video_set_display_mode_crtc(struct hd64461video_chip *hvc)
964 {
965 /* not yet */
966 }
967 #endif /* notyet */
968
969 size_t
970 hd64461video_frame_buffer_size(struct hd64461video_chip *hvc)
971 {
972 vaddr_t page, startaddr, endaddr;
973 int x;
974
975 startaddr = HD64461_FBBASE;
976 endaddr = startaddr + HD64461_FBSIZE - 1;
977
978 page = startaddr;
979
980 x = random();
981 *(volatile int *)(page + 0) = x;
982 *(volatile int *)(page + 4) = ~x;
983
984 if (*(volatile int *)(page + 0) != x ||
985 *(volatile int *)(page + 4) != ~x)
986 return (0);
987
988 for (page += HD64461_FBPAGESIZE; page < endaddr;
989 page += HD64461_FBPAGESIZE) {
990 if (*(volatile int *)(page + 0) == x &&
991 *(volatile int *)(page + 4) == ~x)
992 goto fbend_found;
993 }
994
995 page -= HD64461_FBPAGESIZE;
996 *(volatile int *)(page + 0) = x;
997 *(volatile int *)(page + 4) = ~x;
998
999 if (*(volatile int *)(page + 0) != x ||
1000 *(volatile int *)(page + 4) != ~x)
1001 return (0);
1002
1003 fbend_found:
1004 return (page - startaddr);
1005 }
1006
1007 void
1008 hd64461video_set_clut(struct hd64461video_chip *vc, int idx, int cnt,
1009 u_int8_t *r, u_int8_t *g, u_int8_t *b)
1010 {
1011 KASSERT(r && g && b);
1012
1013 /* index pallete */
1014 hd64461_reg_write_2(HD64461_LCDCPTWAR_REG16,
1015 HD64461_LCDCPTWAR_SET(0, idx));
1016 /* set data */
1017 while (cnt && LEGAL_CLUT_INDEX(idx)) {
1018 u_int16_t v;
1019 #define HD64461VIDEO_SET_CLUT(x) \
1020 v = (x >> 2) & 0x3f; \
1021 hd64461_reg_write_2(HD64461_LCDCPTWDR_REG16, v)
1022 HD64461VIDEO_SET_CLUT(*r);
1023 HD64461VIDEO_SET_CLUT(*g);
1024 HD64461VIDEO_SET_CLUT(*b);
1025 #undef HD64461VIDEO_SET_CLUT
1026 r++, g++, b++;
1027 idx++, cnt--;
1028 }
1029 }
1030
1031 void
1032 hd64461video_get_clut(struct hd64461video_chip *vc, int idx, int cnt,
1033 u_int8_t *r, u_int8_t *g, u_int8_t *b)
1034 {
1035 KASSERT(r && g && b);
1036
1037 /* index pallete */
1038 hd64461_reg_write_2(HD64461_LCDCPTRAR_REG16,
1039 HD64461_LCDCPTRAR_SET(0, idx));
1040
1041 /* get data */
1042 while (cnt && LEGAL_CLUT_INDEX(idx)) {
1043 u_int16_t v;
1044 #define HD64461VIDEO_GET_CLUT(x) \
1045 v = hd64461_reg_read_2(HD64461_LCDCPTWDR_REG16); \
1046 x = HD64461_LCDCPTRDR(v); \
1047 x <<= 2
1048 HD64461VIDEO_GET_CLUT(*r);
1049 HD64461VIDEO_GET_CLUT(*g);
1050 HD64461VIDEO_GET_CLUT(*b);
1051 #undef HD64461VIDEO_GET_CLUT
1052 r++, g++, b++;
1053 idx++, cnt--;
1054 }
1055 }
1056
1057 #ifdef HD64461VIDEO_DEBUG
1058 void
1059 hd64461video_info(struct hd64461video_softc *sc)
1060 {
1061 u_int16_t r;
1062 int color;
1063 int i;
1064
1065 dbg_banner_function();
1066 printf("---[LCD]---\n");
1067 /* Base Address Register */
1068 r = hd64461_reg_read_2(HD64461_LCDCBAR_REG16);
1069 printf("LCDCBAR Frame buffer base address (4k Byte align): 0x%08x\n",
1070 HD64461_LCDCBAR_BASEADDR(r));
1071
1072 /* Line Address Offset Register */
1073 r = hd64461_reg_read_2(HD64461_LCDCLOR_REG16);
1074 printf("LCDCLOR Line address offset: %d\n", HD64461_LCDCLOR(r));
1075
1076 /* LCDC Control Register */
1077 r = hd64461_reg_read_2(HD64461_LCDCCR_REG16);
1078 i = HD64461_LCDCCR_DSPSEL(r);
1079 #define DBG_BITMASK_PRINT(r, m) dbg_bitmask_print(r, HD64461_LCDCCR_##m, #m)
1080 printf("LCDCCR (LCD Control Register)\n");
1081 DBG_BITMASK_PRINT(r, STBAK);
1082 DBG_BITMASK_PRINT(r, STREQ);
1083 DBG_BITMASK_PRINT(r, MOFF);
1084 DBG_BITMASK_PRINT(r, REFSEL);
1085 DBG_BITMASK_PRINT(r, EPON);
1086 DBG_BITMASK_PRINT(r, SPON);
1087 printf("\n");
1088 #undef DBG_BITMASK_PRINT
1089 printf("LCDCCR Display selct LCD[%c] CRT[%c]\n",
1090 i == HD64461_LCDCCR_DSPSEL_LCD_CRT ||
1091 i == HD64461_LCDCCR_DSPSEL_LCD ? 'x' : '_',
1092 i == HD64461_LCDCCR_DSPSEL_LCD_CRT ||
1093 i == HD64461_LCDCCR_DSPSEL_CRT ? 'x' : '_');
1094
1095 /* LCD Display Register */
1096 /* 1 */
1097 r = hd64461_reg_read_2(HD64461_LCDLDR1_REG16);
1098 printf("(LCD Display Register)\n");
1099 #define DBG_BITMASK_PRINT(r, m) dbg_bitmask_print(r, HD64461_LCDLDR1_##m, #m)
1100 printf("LCDLDR1: ");
1101 DBG_BITMASK_PRINT(r, DINV);
1102 DBG_BITMASK_PRINT(r, DON);
1103 printf("\n");
1104 #undef DBG_BITMASK_PRINT
1105 /* 2 */
1106 r = hd64461_reg_read_2(HD64461_LCDLDR2_REG16);
1107 i = HD64461_LCDLDR2_LM(r);
1108 #define DBG_BITMASK_PRINT(r, m) dbg_bitmask_print(r, HD64461_LCDLDR2_##m, #m)
1109 printf("LCDLDR2: ");
1110 DBG_BITMASK_PRINT(r, CC1);
1111 DBG_BITMASK_PRINT(r, CC2);
1112 #undef DBG_BITMASK_PRINT
1113 color = 0;
1114 switch (i) {
1115 default:
1116 panic("unknown unknown LCD interface.");
1117 break;
1118 case HD64461_LCDLDR2_LM_COLOR:
1119 color = 1;
1120 printf("Color");
1121 break;
1122 case HD64461_LCDLDR2_LM_GRAY8:
1123 printf("8-bit grayscale");
1124 break;
1125 case HD64461_LCDLDR2_LM_GRAY4:
1126 printf("8-bit grayscale");
1127 break;
1128 }
1129 printf(" LCD interface\n");
1130 /* 3 */
1131 printf("LCDLDR3: ");
1132 r = hd64461_reg_read_2(HD64461_LCDLDR3_REG16);
1133 i = HD64461_LCDLDR3_CS(r);
1134 printf("CS ");
1135 switch (i) {
1136 case 0:
1137 printf("15");
1138 break;
1139 case 1:
1140 printf("2.5");
1141 break;
1142 case 2:
1143 printf("3.75");
1144 break;
1145 case 4:
1146 printf("5");
1147 break;
1148 case 8:
1149 printf("7.5");
1150 break;
1151 case 16:
1152 printf("10");
1153 break;
1154 }
1155 printf("%s MHz ", color ? "" : "/2");
1156 i = HD64461_LCDLDR3_CG(r);
1157 switch (i) {
1158 case HD64461_LCDLDR3_CG_COLOR16:
1159 printf("Color 64K colors\n");
1160 break;
1161 case HD64461_LCDLDR3_CG_COLOR8:
1162 printf("Color 256 colors\n");
1163 break;
1164 case HD64461_LCDLDR3_CG_GRAY6:
1165 printf("6-bit Grayscale\n");
1166 break;
1167 case HD64461_LCDLDR3_CG_GRAY4:
1168 printf("4-bit Grayscale\n");
1169 break;
1170 case HD64461_LCDLDR3_CG_GRAY2:
1171 printf("2-bit Grayscale\n");
1172 break;
1173 case HD64461_LCDLDR3_CG_GRAY1:
1174 printf("1-bit Grayscale\n");
1175 break;
1176 }
1177
1178 /* LCD Number of Characters in Horizontal Register */
1179 r = hd64461_reg_read_2(HD64461_LCDLDHNCR_REG16);
1180 printf("LDHNCR: NHD %d NHT %d (# of horizontal characters)\n",
1181 HD64461_LCDLDHNCR_NHD(r), HD64461_LCDLDHNCR_NHT(r));
1182
1183 /* Start Position of Horizontal Register */
1184 r = hd64461_reg_read_2(HD64461_LCDLDHNSR_REG16);
1185 printf("LDHNSR: HSW %d HSP %d (start position of horizontal)\n",
1186 HD64461_LCDLDHNSR_HSW(r), HD64461_LCDLDHNSR_HSP(r));
1187
1188 /* Total Vertical Lines Register */
1189 r = hd64461_reg_read_2(HD64461_LCDLDVNTR_REG16);
1190 printf("LDVNTR: %d (total vertical lines)\n",
1191 HD64461_LCDLDVNTR_VTL(r));
1192
1193 /* Display Vertical Lines Register */
1194 r = hd64461_reg_read_2(HD64461_LCDLDVNDR_REG16);
1195 printf("LDVNDR: %d (display vertical lines)\n",
1196 HD64461_LCDLDVSPR_VSP(r));
1197
1198 /* Vertical Synchronization Position Register */
1199 r = hd64461_reg_read_2(HD64461_LCDLDVSPR_REG16);
1200 printf("LDVSPR: %d (vertical synchronization position)\n",
1201 HD64461_LCDLDVSPR_VSP(r));
1202
1203 /*
1204 * CRT Control Register
1205 */
1206 printf("---[CRT]---\n");
1207 r = hd64461_reg_read_2(HD64461_LCDCRTVTR_REG16);
1208 printf("CRTVTR: %d (CRTC total vertical lines)\n",
1209 HD64461_LCDCRTVTR(r));
1210 r = hd64461_reg_read_2(HD64461_LCDCRTVRSR_REG16);
1211 printf("CRTVRSR: %d (CRTC vertical retrace start line)\n",
1212 HD64461_LCDCRTVRSR(r));
1213 r = hd64461_reg_read_2(HD64461_LCDCRTVRER_REG16);
1214 printf("CRTVRER: %d (CRTC vertical retrace end line)\n",
1215 HD64461_LCDCRTVRER(r));
1216
1217 }
1218
1219 void
1220 hd64461video_dump()
1221 {
1222 u_int16_t r;
1223 printf("---[Display Mode Setting]---\n");
1224 #define DUMPREG(x) \
1225 r = hd64461_reg_read_2(HD64461_LCD ## x ## _REG16); \
1226 __dbg_bit_print(r, sizeof(u_int16_t), 0, 0, #x, DBG_BIT_PRINT_COUNT)
1227 DUMPREG(CBAR);
1228 DUMPREG(CLOR);
1229 DUMPREG(CCR);
1230 DUMPREG(LDR1);
1231 DUMPREG(LDR2);
1232 DUMPREG(LDHNCR);
1233 DUMPREG(LDHNSR);
1234 DUMPREG(LDVNTR);
1235 DUMPREG(LDVNDR);
1236 DUMPREG(LDVSPR);
1237 DUMPREG(LDR3);
1238 DUMPREG(CRTVTR);
1239 DUMPREG(CRTVRSR);
1240 DUMPREG(CRTVRER);
1241 #undef DUMPREG
1242 dbg_banner_line();
1243 }
1244
1245 #endif /* HD64461VIDEO_DEBUG */
1246