1 /*- 2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3 * 4 * Copyright (c) 2013 Oleksandr Tymoshenko <gonzo@freebsd.org> 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 */ 28 #include <sys/cdefs.h> 29 __FBSDID("$FreeBSD$"); 30 31 #include <sys/param.h> 32 #include <sys/systm.h> 33 #include <sys/bus.h> 34 #include <sys/conf.h> 35 #include <sys/endian.h> 36 #include <sys/kernel.h> 37 #include <sys/lock.h> 38 #include <sys/malloc.h> 39 #include <sys/module.h> 40 #include <sys/mutex.h> 41 #include <sys/resource.h> 42 #include <sys/rman.h> 43 #include <sys/fbio.h> 44 #include <sys/consio.h> 45 46 #include <sys/kdb.h> 47 48 #include <machine/bus.h> 49 #include <machine/resource.h> 50 #include <machine/intr.h> 51 52 #include <dev/ofw/ofw_bus.h> 53 #include <dev/ofw/ofw_bus_subr.h> 54 55 #include <dev/fb/fbreg.h> 56 #include <dev/syscons/syscons.h> 57 58 #include "am335x_lcd.h" 59 60 struct video_adapter_softc { 61 /* Videoadpater part */ 62 video_adapter_t va; 63 int console; 64 65 intptr_t fb_addr; 66 intptr_t fb_paddr; 67 unsigned int fb_size; 68 69 unsigned int height; 70 unsigned int width; 71 unsigned int depth; 72 unsigned int stride; 73 74 unsigned int xmargin; 75 unsigned int ymargin; 76 77 unsigned char *font; 78 int initialized; 79 }; 80 81 struct argb { 82 uint8_t a; 83 uint8_t r; 84 uint8_t g; 85 uint8_t b; 86 }; 87 88 static struct argb am335x_syscons_palette[16] = { 89 {0x00, 0x00, 0x00, 0x00}, 90 {0x00, 0x00, 0x00, 0xaa}, 91 {0x00, 0x00, 0xaa, 0x00}, 92 {0x00, 0x00, 0xaa, 0xaa}, 93 {0x00, 0xaa, 0x00, 0x00}, 94 {0x00, 0xaa, 0x00, 0xaa}, 95 {0x00, 0xaa, 0x55, 0x00}, 96 {0x00, 0xaa, 0xaa, 0xaa}, 97 {0x00, 0x55, 0x55, 0x55}, 98 {0x00, 0x55, 0x55, 0xff}, 99 {0x00, 0x55, 0xff, 0x55}, 100 {0x00, 0x55, 0xff, 0xff}, 101 {0x00, 0xff, 0x55, 0x55}, 102 {0x00, 0xff, 0x55, 0xff}, 103 {0x00, 0xff, 0xff, 0x55}, 104 {0x00, 0xff, 0xff, 0xff} 105 }; 106 107 /* mouse pointer from dev/syscons/scgfbrndr.c */ 108 static u_char mouse_pointer[16] = { 109 0x00, 0x40, 0x60, 0x70, 0x78, 0x7c, 0x7e, 0x68, 110 0x0c, 0x0c, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00 111 }; 112 113 #define AM335X_FONT_HEIGHT 16 114 115 #define FB_WIDTH 640 116 #define FB_HEIGHT 480 117 #define FB_DEPTH 24 118 119 static struct video_adapter_softc va_softc; 120 121 static int am335x_syscons_configure(int flags); 122 123 /* 124 * Video driver routines and glue. 125 */ 126 static vi_probe_t am335x_syscons_probe; 127 static vi_init_t am335x_syscons_init; 128 static vi_get_info_t am335x_syscons_get_info; 129 static vi_query_mode_t am335x_syscons_query_mode; 130 static vi_set_mode_t am335x_syscons_set_mode; 131 static vi_save_font_t am335x_syscons_save_font; 132 static vi_load_font_t am335x_syscons_load_font; 133 static vi_show_font_t am335x_syscons_show_font; 134 static vi_save_palette_t am335x_syscons_save_palette; 135 static vi_load_palette_t am335x_syscons_load_palette; 136 static vi_set_border_t am335x_syscons_set_border; 137 static vi_save_state_t am335x_syscons_save_state; 138 static vi_load_state_t am335x_syscons_load_state; 139 static vi_set_win_org_t am335x_syscons_set_win_org; 140 static vi_read_hw_cursor_t am335x_syscons_read_hw_cursor; 141 static vi_set_hw_cursor_t am335x_syscons_set_hw_cursor; 142 static vi_set_hw_cursor_shape_t am335x_syscons_set_hw_cursor_shape; 143 static vi_blank_display_t am335x_syscons_blank_display; 144 static vi_mmap_t am335x_syscons_mmap; 145 static vi_ioctl_t am335x_syscons_ioctl; 146 static vi_clear_t am335x_syscons_clear; 147 static vi_fill_rect_t am335x_syscons_fill_rect; 148 static vi_bitblt_t am335x_syscons_bitblt; 149 static vi_diag_t am335x_syscons_diag; 150 static vi_save_cursor_palette_t am335x_syscons_save_cursor_palette; 151 static vi_load_cursor_palette_t am335x_syscons_load_cursor_palette; 152 static vi_copy_t am335x_syscons_copy; 153 static vi_putp_t am335x_syscons_putp; 154 static vi_putc_t am335x_syscons_putc; 155 static vi_puts_t am335x_syscons_puts; 156 static vi_putm_t am335x_syscons_putm; 157 158 static video_switch_t am335x_sysconsvidsw = { 159 .probe = am335x_syscons_probe, 160 .init = am335x_syscons_init, 161 .get_info = am335x_syscons_get_info, 162 .query_mode = am335x_syscons_query_mode, 163 .set_mode = am335x_syscons_set_mode, 164 .save_font = am335x_syscons_save_font, 165 .load_font = am335x_syscons_load_font, 166 .show_font = am335x_syscons_show_font, 167 .save_palette = am335x_syscons_save_palette, 168 .load_palette = am335x_syscons_load_palette, 169 .set_border = am335x_syscons_set_border, 170 .save_state = am335x_syscons_save_state, 171 .load_state = am335x_syscons_load_state, 172 .set_win_org = am335x_syscons_set_win_org, 173 .read_hw_cursor = am335x_syscons_read_hw_cursor, 174 .set_hw_cursor = am335x_syscons_set_hw_cursor, 175 .set_hw_cursor_shape = am335x_syscons_set_hw_cursor_shape, 176 .blank_display = am335x_syscons_blank_display, 177 .mmap = am335x_syscons_mmap, 178 .ioctl = am335x_syscons_ioctl, 179 .clear = am335x_syscons_clear, 180 .fill_rect = am335x_syscons_fill_rect, 181 .bitblt = am335x_syscons_bitblt, 182 .diag = am335x_syscons_diag, 183 .save_cursor_palette = am335x_syscons_save_cursor_palette, 184 .load_cursor_palette = am335x_syscons_load_cursor_palette, 185 .copy = am335x_syscons_copy, 186 .putp = am335x_syscons_putp, 187 .putc = am335x_syscons_putc, 188 .puts = am335x_syscons_puts, 189 .putm = am335x_syscons_putm, 190 }; 191 192 VIDEO_DRIVER(am335x_syscons, am335x_sysconsvidsw, am335x_syscons_configure); 193 194 static vr_init_t am335x_rend_init; 195 static vr_clear_t am335x_rend_clear; 196 static vr_draw_border_t am335x_rend_draw_border; 197 static vr_draw_t am335x_rend_draw; 198 static vr_set_cursor_t am335x_rend_set_cursor; 199 static vr_draw_cursor_t am335x_rend_draw_cursor; 200 static vr_blink_cursor_t am335x_rend_blink_cursor; 201 static vr_set_mouse_t am335x_rend_set_mouse; 202 static vr_draw_mouse_t am335x_rend_draw_mouse; 203 204 /* 205 * We use our own renderer; this is because we must emulate a hardware 206 * cursor. 207 */ 208 static sc_rndr_sw_t am335x_rend = { 209 am335x_rend_init, 210 am335x_rend_clear, 211 am335x_rend_draw_border, 212 am335x_rend_draw, 213 am335x_rend_set_cursor, 214 am335x_rend_draw_cursor, 215 am335x_rend_blink_cursor, 216 am335x_rend_set_mouse, 217 am335x_rend_draw_mouse 218 }; 219 220 RENDERER(am335x_syscons, 0, am335x_rend, gfb_set); 221 RENDERER_MODULE(am335x_syscons, gfb_set); 222 223 static void 224 am335x_rend_init(scr_stat* scp) 225 { 226 } 227 228 static void 229 am335x_rend_clear(scr_stat* scp, int c, int attr) 230 { 231 } 232 233 static void 234 am335x_rend_draw_border(scr_stat* scp, int color) 235 { 236 } 237 238 static void 239 am335x_rend_draw(scr_stat* scp, int from, int count, int flip) 240 { 241 video_adapter_t* adp = scp->sc->adp; 242 int i, c, a; 243 244 if (!flip) { 245 /* Normal printing */ 246 vidd_puts(adp, from, (uint16_t*)sc_vtb_pointer(&scp->vtb, from), count); 247 } else { 248 /* This is for selections and such: invert the color attribute */ 249 for (i = count; i-- > 0; ++from) { 250 c = sc_vtb_getc(&scp->vtb, from); 251 a = sc_vtb_geta(&scp->vtb, from) >> 8; 252 vidd_putc(adp, from, c, (a >> 4) | ((a & 0xf) << 4)); 253 } 254 } 255 } 256 257 static void 258 am335x_rend_set_cursor(scr_stat* scp, int base, int height, int blink) 259 { 260 } 261 262 static void 263 am335x_rend_draw_cursor(scr_stat* scp, int off, int blink, int on, int flip) 264 { 265 video_adapter_t* adp = scp->sc->adp; 266 struct video_adapter_softc *sc; 267 int row, col; 268 uint8_t *addr; 269 int i, j, bytes; 270 271 sc = (struct video_adapter_softc *)adp; 272 273 if (scp->curs_attr.height <= 0) 274 return; 275 276 if (sc->fb_addr == 0) 277 return; 278 279 if (off >= adp->va_info.vi_width * adp->va_info.vi_height) 280 return; 281 282 /* calculate the coordinates in the video buffer */ 283 row = (off / adp->va_info.vi_width) * adp->va_info.vi_cheight; 284 col = (off % adp->va_info.vi_width) * adp->va_info.vi_cwidth; 285 286 addr = (uint8_t *)sc->fb_addr 287 + (row + sc->ymargin)*(sc->stride) 288 + (sc->depth/8) * (col + sc->xmargin); 289 290 bytes = sc->depth/8; 291 292 /* our cursor consists of simply inverting the char under it */ 293 for (i = 0; i < adp->va_info.vi_cheight; i++) { 294 for (j = 0; j < adp->va_info.vi_cwidth; j++) { 295 switch (sc->depth) { 296 case 32: 297 case 24: 298 addr[bytes*j + 2] ^= 0xff; 299 /* FALLTHROUGH */ 300 case 16: 301 addr[bytes*j + 1] ^= 0xff; 302 addr[bytes*j] ^= 0xff; 303 break; 304 default: 305 break; 306 } 307 } 308 309 addr += sc->stride; 310 } 311 } 312 313 static void 314 am335x_rend_blink_cursor(scr_stat* scp, int at, int flip) 315 { 316 } 317 318 static void 319 am335x_rend_set_mouse(scr_stat* scp) 320 { 321 } 322 323 static void 324 am335x_rend_draw_mouse(scr_stat* scp, int x, int y, int on) 325 { 326 vidd_putm(scp->sc->adp, x, y, mouse_pointer, 0xffffffff, 16, 8); 327 } 328 329 static uint16_t am335x_syscons_static_window[ROW*COL]; 330 extern u_char dflt_font_16[]; 331 332 /* 333 * Update videoadapter settings after changing resolution 334 */ 335 static void 336 am335x_syscons_update_margins(video_adapter_t *adp) 337 { 338 struct video_adapter_softc *sc; 339 video_info_t *vi; 340 341 sc = (struct video_adapter_softc *)adp; 342 vi = &adp->va_info; 343 344 sc->xmargin = (sc->width - (vi->vi_width * vi->vi_cwidth)) / 2; 345 sc->ymargin = (sc->height - (vi->vi_height * vi->vi_cheight))/2; 346 } 347 348 static phandle_t 349 am335x_syscons_find_panel_node(phandle_t start) 350 { 351 phandle_t child; 352 phandle_t result; 353 354 for (child = OF_child(start); child != 0; child = OF_peer(child)) { 355 if (ofw_bus_node_is_compatible(child, "ti,am335x-lcd")) 356 return (child); 357 if ((result = am335x_syscons_find_panel_node(child))) 358 return (result); 359 } 360 361 return (0); 362 } 363 364 static int 365 am335x_syscons_configure(int flags) 366 { 367 struct video_adapter_softc *va_sc; 368 369 va_sc = &va_softc; 370 phandle_t display, root; 371 pcell_t cell; 372 373 if (va_sc->initialized) 374 return (0); 375 376 va_sc->width = 0; 377 va_sc->height = 0; 378 379 /* 380 * It seems there is no way to let syscons framework know 381 * that framebuffer resolution has changed. So just try 382 * to fetch data from FDT and go with defaults if failed 383 */ 384 root = OF_finddevice("/"); 385 if ((root != 0) && 386 (display = am335x_syscons_find_panel_node(root))) { 387 if ((OF_getencprop(display, "panel_width", &cell, 388 sizeof(cell))) > 0) 389 va_sc->width = cell; 390 391 if ((OF_getencprop(display, "panel_height", &cell, 392 sizeof(cell))) > 0) 393 va_sc->height = cell; 394 } 395 396 if (va_sc->width == 0) 397 va_sc->width = FB_WIDTH; 398 if (va_sc->height == 0) 399 va_sc->height = FB_HEIGHT; 400 401 am335x_syscons_init(0, &va_sc->va, 0); 402 403 va_sc->initialized = 1; 404 405 return (0); 406 } 407 408 static int 409 am335x_syscons_probe(int unit, video_adapter_t **adp, void *arg, int flags) 410 { 411 412 return (0); 413 } 414 415 static int 416 am335x_syscons_init(int unit, video_adapter_t *adp, int flags) 417 { 418 struct video_adapter_softc *sc; 419 video_info_t *vi; 420 421 sc = (struct video_adapter_softc *)adp; 422 vi = &adp->va_info; 423 424 vid_init_struct(adp, "am335x_syscons", -1, unit); 425 426 sc->font = dflt_font_16; 427 vi->vi_cheight = AM335X_FONT_HEIGHT; 428 vi->vi_cwidth = 8; 429 430 vi->vi_width = sc->width/8; 431 vi->vi_height = sc->height/vi->vi_cheight; 432 433 /* 434 * Clamp width/height to syscons maximums 435 */ 436 if (vi->vi_width > COL) 437 vi->vi_width = COL; 438 if (vi->vi_height > ROW) 439 vi->vi_height = ROW; 440 441 sc->xmargin = (sc->width - (vi->vi_width * vi->vi_cwidth)) / 2; 442 sc->ymargin = (sc->height - (vi->vi_height * vi->vi_cheight))/2; 443 444 445 adp->va_window = (vm_offset_t) am335x_syscons_static_window; 446 adp->va_flags |= V_ADP_FONT /* | V_ADP_COLOR | V_ADP_MODECHANGE */; 447 448 vid_register(&sc->va); 449 450 return (0); 451 } 452 453 static int 454 am335x_syscons_get_info(video_adapter_t *adp, int mode, video_info_t *info) 455 { 456 bcopy(&adp->va_info, info, sizeof(*info)); 457 return (0); 458 } 459 460 static int 461 am335x_syscons_query_mode(video_adapter_t *adp, video_info_t *info) 462 { 463 return (0); 464 } 465 466 static int 467 am335x_syscons_set_mode(video_adapter_t *adp, int mode) 468 { 469 return (0); 470 } 471 472 static int 473 am335x_syscons_save_font(video_adapter_t *adp, int page, int size, int width, 474 u_char *data, int c, int count) 475 { 476 return (0); 477 } 478 479 static int 480 am335x_syscons_load_font(video_adapter_t *adp, int page, int size, int width, 481 u_char *data, int c, int count) 482 { 483 struct video_adapter_softc *sc = (struct video_adapter_softc *)adp; 484 485 sc->font = data; 486 487 return (0); 488 } 489 490 static int 491 am335x_syscons_show_font(video_adapter_t *adp, int page) 492 { 493 return (0); 494 } 495 496 static int 497 am335x_syscons_save_palette(video_adapter_t *adp, u_char *palette) 498 { 499 return (0); 500 } 501 502 static int 503 am335x_syscons_load_palette(video_adapter_t *adp, u_char *palette) 504 { 505 return (0); 506 } 507 508 static int 509 am335x_syscons_set_border(video_adapter_t *adp, int border) 510 { 511 return (am335x_syscons_blank_display(adp, border)); 512 } 513 514 static int 515 am335x_syscons_save_state(video_adapter_t *adp, void *p, size_t size) 516 { 517 return (0); 518 } 519 520 static int 521 am335x_syscons_load_state(video_adapter_t *adp, void *p) 522 { 523 return (0); 524 } 525 526 static int 527 am335x_syscons_set_win_org(video_adapter_t *adp, off_t offset) 528 { 529 return (0); 530 } 531 532 static int 533 am335x_syscons_read_hw_cursor(video_adapter_t *adp, int *col, int *row) 534 { 535 *col = *row = 0; 536 537 return (0); 538 } 539 540 static int 541 am335x_syscons_set_hw_cursor(video_adapter_t *adp, int col, int row) 542 { 543 return (0); 544 } 545 546 static int 547 am335x_syscons_set_hw_cursor_shape(video_adapter_t *adp, int base, int height, 548 int celsize, int blink) 549 { 550 return (0); 551 } 552 553 static int 554 am335x_syscons_blank_display(video_adapter_t *adp, int mode) 555 { 556 557 struct video_adapter_softc *sc; 558 559 sc = (struct video_adapter_softc *)adp; 560 if (sc && sc->fb_addr) 561 memset((void*)sc->fb_addr, 0, sc->fb_size); 562 563 return (0); 564 } 565 566 static int 567 am335x_syscons_mmap(video_adapter_t *adp, vm_ooffset_t offset, vm_paddr_t *paddr, 568 int prot, vm_memattr_t *memattr) 569 { 570 struct video_adapter_softc *sc; 571 572 sc = (struct video_adapter_softc *)adp; 573 574 /* 575 * This might be a legacy VGA mem request: if so, just point it at the 576 * framebuffer, since it shouldn't be touched 577 */ 578 if (offset < sc->stride*sc->height) { 579 *paddr = sc->fb_paddr + offset; 580 return (0); 581 } 582 583 return (EINVAL); 584 } 585 586 static int 587 am335x_syscons_ioctl(video_adapter_t *adp, u_long cmd, caddr_t data) 588 { 589 struct video_adapter_softc *sc; 590 struct fbtype *fb; 591 592 sc = (struct video_adapter_softc *)adp; 593 594 switch (cmd) { 595 case FBIOGTYPE: 596 fb = (struct fbtype *)data; 597 fb->fb_type = FBTYPE_PCIMISC; 598 fb->fb_height = sc->height; 599 fb->fb_width = sc->width; 600 fb->fb_depth = sc->depth; 601 if (sc->depth <= 1 || sc->depth > 8) 602 fb->fb_cmsize = 0; 603 else 604 fb->fb_cmsize = 1 << sc->depth; 605 fb->fb_size = sc->fb_size; 606 break; 607 default: 608 return (fb_commonioctl(adp, cmd, data)); 609 } 610 611 return (0); 612 } 613 614 static int 615 am335x_syscons_clear(video_adapter_t *adp) 616 { 617 618 return (am335x_syscons_blank_display(adp, 0)); 619 } 620 621 static int 622 am335x_syscons_fill_rect(video_adapter_t *adp, int val, int x, int y, int cx, int cy) 623 { 624 625 return (0); 626 } 627 628 static int 629 am335x_syscons_bitblt(video_adapter_t *adp, ...) 630 { 631 632 return (0); 633 } 634 635 static int 636 am335x_syscons_diag(video_adapter_t *adp, int level) 637 { 638 639 return (0); 640 } 641 642 static int 643 am335x_syscons_save_cursor_palette(video_adapter_t *adp, u_char *palette) 644 { 645 646 return (0); 647 } 648 649 static int 650 am335x_syscons_load_cursor_palette(video_adapter_t *adp, u_char *palette) 651 { 652 653 return (0); 654 } 655 656 static int 657 am335x_syscons_copy(video_adapter_t *adp, vm_offset_t src, vm_offset_t dst, int n) 658 { 659 660 return (0); 661 } 662 663 static int 664 am335x_syscons_putp(video_adapter_t *adp, vm_offset_t off, uint32_t p, uint32_t a, 665 int size, int bpp, int bit_ltor, int byte_ltor) 666 { 667 668 return (0); 669 } 670 671 static int 672 am335x_syscons_putc(video_adapter_t *adp, vm_offset_t off, uint8_t c, uint8_t a) 673 { 674 struct video_adapter_softc *sc; 675 int row; 676 int col; 677 int i, j, k; 678 uint8_t *addr; 679 u_char *p; 680 uint8_t fg, bg, color; 681 uint16_t rgb; 682 683 sc = (struct video_adapter_softc *)adp; 684 685 if (sc->fb_addr == 0) 686 return (0); 687 688 row = (off / adp->va_info.vi_width) * adp->va_info.vi_cheight; 689 col = (off % adp->va_info.vi_width) * adp->va_info.vi_cwidth; 690 p = sc->font + c*AM335X_FONT_HEIGHT; 691 addr = (uint8_t *)sc->fb_addr 692 + (row + sc->ymargin)*(sc->stride) 693 + (sc->depth/8) * (col + sc->xmargin); 694 695 fg = a & 0xf ; 696 bg = (a >> 4) & 0xf; 697 698 for (i = 0; i < AM335X_FONT_HEIGHT; i++) { 699 for (j = 0, k = 7; j < 8; j++, k--) { 700 if ((p[i] & (1 << k)) == 0) 701 color = bg; 702 else 703 color = fg; 704 705 switch (sc->depth) { 706 case 32: 707 addr[4*j+0] = am335x_syscons_palette[color].r; 708 addr[4*j+1] = am335x_syscons_palette[color].g; 709 addr[4*j+2] = am335x_syscons_palette[color].b; 710 addr[4*j+3] = am335x_syscons_palette[color].a; 711 break; 712 case 24: 713 addr[3*j] = am335x_syscons_palette[color].r; 714 addr[3*j+1] = am335x_syscons_palette[color].g; 715 addr[3*j+2] = am335x_syscons_palette[color].b; 716 break; 717 case 16: 718 rgb = (am335x_syscons_palette[color].r >> 3) << 11; 719 rgb |= (am335x_syscons_palette[color].g >> 2) << 5; 720 rgb |= (am335x_syscons_palette[color].b >> 3); 721 addr[2*j] = rgb & 0xff; 722 addr[2*j + 1] = (rgb >> 8) & 0xff; 723 default: 724 /* Not supported yet */ 725 break; 726 } 727 } 728 729 addr += (sc->stride); 730 } 731 732 return (0); 733 } 734 735 static int 736 am335x_syscons_puts(video_adapter_t *adp, vm_offset_t off, u_int16_t *s, int len) 737 { 738 int i; 739 740 for (i = 0; i < len; i++) 741 am335x_syscons_putc(adp, off + i, s[i] & 0xff, (s[i] & 0xff00) >> 8); 742 743 return (0); 744 } 745 746 static int 747 am335x_syscons_putm(video_adapter_t *adp, int x, int y, uint8_t *pixel_image, 748 uint32_t pixel_mask, int size, int width) 749 { 750 751 return (0); 752 } 753 754 /* Initialization function */ 755 int am335x_lcd_syscons_setup(vm_offset_t vaddr, vm_paddr_t paddr, 756 struct panel_info *panel) 757 { 758 struct video_adapter_softc *va_sc = &va_softc; 759 760 va_sc->fb_addr = vaddr; 761 va_sc->fb_paddr = paddr; 762 va_sc->depth = panel->bpp; 763 va_sc->stride = panel->bpp*panel->panel_width/8; 764 765 va_sc->width = panel->panel_width; 766 va_sc->height = panel->panel_height; 767 va_sc->fb_size = va_sc->width * va_sc->height 768 * va_sc->depth/8; 769 am335x_syscons_update_margins(&va_sc->va); 770 771 return (0); 772 } 773 774 /* 775 * Define a stub keyboard driver in case one hasn't been 776 * compiled into the kernel 777 */ 778 #include <sys/kbio.h> 779 #include <dev/kbd/kbdreg.h> 780 781 static int dummy_kbd_configure(int flags); 782 783 keyboard_switch_t am335x_dummysw; 784 785 static int 786 dummy_kbd_configure(int flags) 787 { 788 789 return (0); 790 } 791 KEYBOARD_DRIVER(am335x_dummy, am335x_dummysw, dummy_kbd_configure); 792