Deleted Added
full compact
bcm2835_fb.c (243687) bcm2835_fb.c (244762)
1/*-
2 * Copyright (c) 2012 Oleksandr Tymoshenko <gonzo@freebsd.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 */
27#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2012 Oleksandr Tymoshenko <gonzo@freebsd.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 */
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sys/arm/broadcom/bcm2835/bcm2835_fb.c 243687 2012-11-30 02:31:08Z gonzo $");
28__FBSDID("$FreeBSD: head/sys/arm/broadcom/bcm2835/bcm2835_fb.c 244762 2012-12-28 03:18:05Z gonzo $");
29
30#include <sys/param.h>
31#include <sys/systm.h>
32#include <sys/bio.h>
33#include <sys/bus.h>
34#include <sys/conf.h>
35#include <sys/endian.h>
36#include <sys/kernel.h>

--- 52 unchanged lines hidden (view full) ---

89 {0x00, 0x55, 0xff, 0x55},
90 {0x00, 0x55, 0xff, 0xff},
91 {0x00, 0xff, 0x55, 0x55},
92 {0x00, 0xff, 0x55, 0xff},
93 {0x00, 0xff, 0xff, 0x55},
94 {0x00, 0xff, 0xff, 0xff}
95};
96
29
30#include <sys/param.h>
31#include <sys/systm.h>
32#include <sys/bio.h>
33#include <sys/bus.h>
34#include <sys/conf.h>
35#include <sys/endian.h>
36#include <sys/kernel.h>

--- 52 unchanged lines hidden (view full) ---

89 {0x00, 0x55, 0xff, 0x55},
90 {0x00, 0x55, 0xff, 0xff},
91 {0x00, 0xff, 0x55, 0x55},
92 {0x00, 0xff, 0x55, 0xff},
93 {0x00, 0xff, 0xff, 0x55},
94 {0x00, 0xff, 0xff, 0xff}
95};
96
97/* mouse pointer from dev/syscons/scgfbrndr.c */
98static u_char mouse_pointer[16] = {
99 0x00, 0x40, 0x60, 0x70, 0x78, 0x7c, 0x7e, 0x68,
100 0x0c, 0x0c, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00
101};
102
97#define FB_WIDTH 640
98#define FB_HEIGHT 480
99#define FB_DEPTH 24
100
101struct bcm_fb_config {
102 uint32_t xres;
103 uint32_t yres;
104 uint32_t vxres;

--- 310 unchanged lines hidden (view full) ---

415 .putp = bcmfb_putp,
416 .putc = bcmfb_putc,
417 .puts = bcmfb_puts,
418 .putm = bcmfb_putm,
419};
420
421VIDEO_DRIVER(bcmfb, bcmfbvidsw, bcmfb_configure);
422
103#define FB_WIDTH 640
104#define FB_HEIGHT 480
105#define FB_DEPTH 24
106
107struct bcm_fb_config {
108 uint32_t xres;
109 uint32_t yres;
110 uint32_t vxres;

--- 310 unchanged lines hidden (view full) ---

421 .putp = bcmfb_putp,
422 .putc = bcmfb_putc,
423 .puts = bcmfb_puts,
424 .putm = bcmfb_putm,
425};
426
427VIDEO_DRIVER(bcmfb, bcmfbvidsw, bcmfb_configure);
428
423extern sc_rndr_sw_t txtrndrsw;
424RENDERER(bcmfb, 0, txtrndrsw, gfb_set);
429static vr_init_t bcmrend_init;
430static vr_clear_t bcmrend_clear;
431static vr_draw_border_t bcmrend_draw_border;
432static vr_draw_t bcmrend_draw;
433static vr_set_cursor_t bcmrend_set_cursor;
434static vr_draw_cursor_t bcmrend_draw_cursor;
435static vr_blink_cursor_t bcmrend_blink_cursor;
436static vr_set_mouse_t bcmrend_set_mouse;
437static vr_draw_mouse_t bcmrend_draw_mouse;
438
439/*
440 * We use our own renderer; this is because we must emulate a hardware
441 * cursor.
442 */
443static sc_rndr_sw_t bcmrend = {
444 bcmrend_init,
445 bcmrend_clear,
446 bcmrend_draw_border,
447 bcmrend_draw,
448 bcmrend_set_cursor,
449 bcmrend_draw_cursor,
450 bcmrend_blink_cursor,
451 bcmrend_set_mouse,
452 bcmrend_draw_mouse
453};
454
455RENDERER(bcmfb, 0, bcmrend, gfb_set);
425RENDERER_MODULE(bcmfb, gfb_set);
426
456RENDERER_MODULE(bcmfb, gfb_set);
457
458static void
459bcmrend_init(scr_stat* scp)
460{
461}
462
463static void
464bcmrend_clear(scr_stat* scp, int c, int attr)
465{
466}
467
468static void
469bcmrend_draw_border(scr_stat* scp, int color)
470{
471}
472
473static void
474bcmrend_draw(scr_stat* scp, int from, int count, int flip)
475{
476 video_adapter_t* adp = scp->sc->adp;
477 int i, c, a;
478
479 if (!flip) {
480 /* Normal printing */
481 vidd_puts(adp, from, (uint16_t*)sc_vtb_pointer(&scp->vtb, from), count);
482 } else {
483 /* This is for selections and such: invert the color attribute */
484 for (i = count; i-- > 0; ++from) {
485 c = sc_vtb_getc(&scp->vtb, from);
486 a = sc_vtb_geta(&scp->vtb, from) >> 8;
487 vidd_putc(adp, from, c, (a >> 4) | ((a & 0xf) << 4));
488 }
489 }
490}
491
492static void
493bcmrend_set_cursor(scr_stat* scp, int base, int height, int blink)
494{
495}
496
497static void
498bcmrend_draw_cursor(scr_stat* scp, int off, int blink, int on, int flip)
499{
500 video_adapter_t* adp = scp->sc->adp;
501 struct video_adapter_softc *sc;
502 int row, col;
503 uint8_t *addr;
504 int i, j, bytes;
505
506 sc = (struct video_adapter_softc *)adp;
507
508 if (scp->curs_attr.height <= 0)
509 return;
510
511 if (sc->fb_addr == 0)
512 return;
513
514 if (off >= adp->va_info.vi_width * adp->va_info.vi_height)
515 return;
516
517 /* calculate the coordinates in the video buffer */
518 row = (off / adp->va_info.vi_width) * adp->va_info.vi_cheight;
519 col = (off % adp->va_info.vi_width) * adp->va_info.vi_cwidth;
520
521 addr = (uint8_t *)sc->fb_addr
522 + (row + sc->ymargin)*(sc->stride)
523 + (sc->depth/8) * (col + sc->xmargin);
524
525 bytes = sc->depth/8;
526
527 /* our cursor consists of simply inverting the char under it */
528 for (i = 0; i < adp->va_info.vi_cheight; i++) {
529 for (j = 0; j < adp->va_info.vi_cwidth; j++) {
530 switch (sc->depth) {
531 case 32:
532 case 24:
533 addr[bytes*j + 2] ^= 0xff;
534 /* FALLTHROUGH */
535 case 16:
536 addr[bytes*j + 1] ^= 0xff;
537 addr[bytes*j] ^= 0xff;
538 break;
539 default:
540 break;
541 }
542 }
543
544 addr += sc->stride;
545 }
546}
547
548static void
549bcmrend_blink_cursor(scr_stat* scp, int at, int flip)
550{
551}
552
553static void
554bcmrend_set_mouse(scr_stat* scp)
555{
556}
557
558static void
559bcmrend_draw_mouse(scr_stat* scp, int x, int y, int on)
560{
561 vidd_putm(scp->sc->adp, x, y, mouse_pointer, 0xffffffff, 16, 8);
562}
563
427static uint16_t bcmfb_static_window[ROW*COL];
428extern u_char dflt_font_16[];
429
430/*
431 * Update videoadapter settings after changing resolution
432 */
433static void
434bcmfb_update_margins(video_adapter_t *adp)

--- 398 unchanged lines hidden ---
564static uint16_t bcmfb_static_window[ROW*COL];
565extern u_char dflt_font_16[];
566
567/*
568 * Update videoadapter settings after changing resolution
569 */
570static void
571bcmfb_update_margins(video_adapter_t *adp)

--- 398 unchanged lines hidden ---