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