| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: r128fb.c,v 1.25 2012/01/04 08:38:20 macallan Exp $ */ | | 1 | /* $NetBSD: r128fb.c,v 1.26 2012/01/04 15:56:18 macallan Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2007 Michael Lorenz | | 4 | * Copyright (c) 2007 Michael Lorenz |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -21,27 +21,27 @@ | | | @@ -21,27 +21,27 @@ |
21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | | 21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | | 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | | 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | | 26 | */ |
27 | | | 27 | |
28 | /* | | 28 | /* |
29 | * A console driver for ATI Rage 128 graphics controllers | | 29 | * A console driver for ATI Rage 128 graphics controllers |
30 | * tested on macppc only so far | | 30 | * tested on macppc only so far |
31 | */ | | 31 | */ |
32 | | | 32 | |
33 | #include <sys/cdefs.h> | | 33 | #include <sys/cdefs.h> |
34 | __KERNEL_RCSID(0, "$NetBSD: r128fb.c,v 1.25 2012/01/04 08:38:20 macallan Exp $"); | | 34 | __KERNEL_RCSID(0, "$NetBSD: r128fb.c,v 1.26 2012/01/04 15:56:18 macallan Exp $"); |
35 | | | 35 | |
36 | #include <sys/param.h> | | 36 | #include <sys/param.h> |
37 | #include <sys/systm.h> | | 37 | #include <sys/systm.h> |
38 | #include <sys/kernel.h> | | 38 | #include <sys/kernel.h> |
39 | #include <sys/device.h> | | 39 | #include <sys/device.h> |
40 | #include <sys/malloc.h> | | 40 | #include <sys/malloc.h> |
41 | #include <sys/lwp.h> | | 41 | #include <sys/lwp.h> |
42 | #include <sys/kauth.h> | | 42 | #include <sys/kauth.h> |
43 | | | 43 | |
44 | #include <dev/videomode/videomode.h> | | 44 | #include <dev/videomode/videomode.h> |
45 | | | 45 | |
46 | #include <dev/pci/pcivar.h> | | 46 | #include <dev/pci/pcivar.h> |
47 | #include <dev/pci/pcireg.h> | | 47 | #include <dev/pci/pcireg.h> |
| @@ -815,50 +815,48 @@ r128fb_cursor(void *cookie, int on, int | | | @@ -815,50 +815,48 @@ r128fb_cursor(void *cookie, int on, int |
815 | } | | 815 | } |
816 | | | 816 | |
817 | } | | 817 | } |
818 | | | 818 | |
819 | static void | | 819 | static void |
820 | r128fb_putchar(void *cookie, int row, int col, u_int c, long attr) | | 820 | r128fb_putchar(void *cookie, int row, int col, u_int c, long attr) |
821 | { | | 821 | { |
822 | struct rasops_info *ri = cookie; | | 822 | struct rasops_info *ri = cookie; |
823 | struct wsdisplay_font *font = PICK_FONT(ri, c); | | 823 | struct wsdisplay_font *font = PICK_FONT(ri, c); |
824 | struct vcons_screen *scr = ri->ri_hw; | | 824 | struct vcons_screen *scr = ri->ri_hw; |
825 | struct r128fb_softc *sc = scr->scr_cookie; | | 825 | struct r128fb_softc *sc = scr->scr_cookie; |
826 | void *data; | | 826 | void *data; |
827 | uint32_t fg, bg; | | 827 | uint32_t fg, bg; |
828 | int uc, i; | | 828 | int i, x, y, wi, he, offset; |
829 | int x, y, wi, he, offset; | | | |
830 | | | 829 | |
831 | if (sc->sc_mode != WSDISPLAYIO_MODE_EMUL) | | 830 | if (sc->sc_mode != WSDISPLAYIO_MODE_EMUL) |
832 | return; | | 831 | return; |
833 | | | 832 | |
834 | if (!CHAR_IN_FONT(c, font)) | | 833 | if (!CHAR_IN_FONT(c, font)) |
835 | return; | | 834 | return; |
836 | | | 835 | |
837 | wi = font->fontwidth; | | 836 | wi = font->fontwidth; |
838 | he = font->fontheight; | | 837 | he = font->fontheight; |
839 | | | 838 | |
840 | bg = ri->ri_devcmap[(attr >> 16) & 0xf]; | | 839 | bg = ri->ri_devcmap[(attr >> 16) & 0xf]; |
841 | fg = ri->ri_devcmap[(attr >> 24) & 0xf]; | | 840 | fg = ri->ri_devcmap[(attr >> 24) & 0xf]; |
842 | x = ri->ri_xorigin + col * wi; | | 841 | x = ri->ri_xorigin + col * wi; |
843 | y = ri->ri_yorigin + row * he; | | 842 | y = ri->ri_yorigin + row * he; |
844 | | | 843 | |
845 | if (c == 0x20) { | | 844 | if (c == 0x20) { |
846 | r128fb_rectfill(sc, x, y, wi, he, bg); | | 845 | r128fb_rectfill(sc, x, y, wi, he, bg); |
847 | return; | | 846 | return; |
848 | } | | 847 | } |
849 | | | 848 | |
850 | uc = c - font->firstchar; | | 849 | data = WSFONT_GLYPH(c, font); |
851 | data = (uint8_t *)font->data + uc * ri->ri_fontscale; | | | |
852 | | | 850 | |
853 | r128fb_wait(sc, 8); | | 851 | r128fb_wait(sc, 8); |
854 | | | 852 | |
855 | bus_space_write_4(sc->sc_memt, sc->sc_regh, | | 853 | bus_space_write_4(sc->sc_memt, sc->sc_regh, |
856 | R128_DP_GUI_MASTER_CNTL, | | 854 | R128_DP_GUI_MASTER_CNTL, |
857 | R128_GMC_BRUSH_SOLID_COLOR | | | 855 | R128_GMC_BRUSH_SOLID_COLOR | |
858 | R128_GMC_SRC_DATATYPE_MONO_FG_BG | | | 856 | R128_GMC_SRC_DATATYPE_MONO_FG_BG | |
859 | R128_ROP3_S | | | 857 | R128_ROP3_S | |
860 | R128_DP_SRC_SOURCE_HOST_DATA | | | 858 | R128_DP_SRC_SOURCE_HOST_DATA | |
861 | R128_GMC_DST_CLIPPING | | | 859 | R128_GMC_DST_CLIPPING | |
862 | sc->sc_master_cntl); | | 860 | sc->sc_master_cntl); |
863 | | | 861 | |
864 | bus_space_write_4(sc->sc_memt, sc->sc_regh, | | 862 | bus_space_write_4(sc->sc_memt, sc->sc_regh, |
| @@ -916,49 +914,48 @@ r128fb_putchar(void *cookie, int row, in | | | @@ -916,49 +914,48 @@ r128fb_putchar(void *cookie, int row, in |
916 | break; | | 914 | break; |
917 | } | | 915 | } |
918 | } | | 916 | } |
919 | } | | 917 | } |
920 | | | 918 | |
921 | static void | | 919 | static void |
922 | r128fb_putchar_aa(void *cookie, int row, int col, u_int c, long attr) | | 920 | r128fb_putchar_aa(void *cookie, int row, int col, u_int c, long attr) |
923 | { | | 921 | { |
924 | struct rasops_info *ri = cookie; | | 922 | struct rasops_info *ri = cookie; |
925 | struct wsdisplay_font *font = PICK_FONT(ri, c); | | 923 | struct wsdisplay_font *font = PICK_FONT(ri, c); |
926 | struct vcons_screen *scr = ri->ri_hw; | | 924 | struct vcons_screen *scr = ri->ri_hw; |
927 | struct r128fb_softc *sc = scr->scr_cookie; | | 925 | struct r128fb_softc *sc = scr->scr_cookie; |
928 | uint32_t bg, latch = 0, bg8, fg8, pixel; | | 926 | uint32_t bg, latch = 0, bg8, fg8, pixel; |
929 | int uc, i, x, y, wi, he, r, g, b, aval; | | 927 | int i, x, y, wi, he, r, g, b, aval; |
930 | int r1, g1, b1, r0, g0, b0, fgo, bgo; | | 928 | int r1, g1, b1, r0, g0, b0, fgo, bgo; |
931 | uint8_t *data8; | | 929 | uint8_t *data8; |
932 | | | 930 | |
933 | if (sc->sc_mode != WSDISPLAYIO_MODE_EMUL) | | 931 | if (sc->sc_mode != WSDISPLAYIO_MODE_EMUL) |
934 | return; | | 932 | return; |
935 | | | 933 | |
936 | if (!CHAR_IN_FONT(c, font)) | | 934 | if (!CHAR_IN_FONT(c, font)) |
937 | return; | | 935 | return; |
938 | | | 936 | |
939 | wi = font->fontwidth; | | 937 | wi = font->fontwidth; |
940 | he = font->fontheight; | | 938 | he = font->fontheight; |
941 | | | 939 | |
942 | bg = ri->ri_devcmap[(attr >> 16) & 0xf]; | | 940 | bg = ri->ri_devcmap[(attr >> 16) & 0xf]; |
943 | x = ri->ri_xorigin + col * wi; | | 941 | x = ri->ri_xorigin + col * wi; |
944 | y = ri->ri_yorigin + row * he; | | 942 | y = ri->ri_yorigin + row * he; |
945 | if (c == 0x20) { | | 943 | if (c == 0x20) { |
946 | r128fb_rectfill(sc, x, y, wi, he, bg); | | 944 | r128fb_rectfill(sc, x, y, wi, he, bg); |
947 | return; | | 945 | return; |
948 | } | | 946 | } |
949 | | | 947 | |
950 | uc = c - font->firstchar; | | 948 | data8 = WSFONT_GLYPH(c, font); |
951 | data8 = (uint8_t *)font->data + uc * ri->ri_fontscale; | | | |
952 | | | 949 | |
953 | r128fb_wait(sc, 5); | | 950 | r128fb_wait(sc, 5); |
954 | bus_space_write_4(sc->sc_memt, sc->sc_regh, | | 951 | bus_space_write_4(sc->sc_memt, sc->sc_regh, |
955 | R128_DP_GUI_MASTER_CNTL, | | 952 | R128_DP_GUI_MASTER_CNTL, |
956 | R128_GMC_BRUSH_SOLID_COLOR | | | 953 | R128_GMC_BRUSH_SOLID_COLOR | |
957 | R128_GMC_SRC_DATATYPE_COLOR | | | 954 | R128_GMC_SRC_DATATYPE_COLOR | |
958 | R128_ROP3_S | | | 955 | R128_ROP3_S | |
959 | R128_DP_SRC_SOURCE_HOST_DATA | | | 956 | R128_DP_SRC_SOURCE_HOST_DATA | |
960 | sc->sc_master_cntl); | | 957 | sc->sc_master_cntl); |
961 | | | 958 | |
962 | bus_space_write_4(sc->sc_memt, sc->sc_regh, | | 959 | bus_space_write_4(sc->sc_memt, sc->sc_regh, |
963 | R128_DP_CNTL, | | 960 | R128_DP_CNTL, |
964 | R128_DST_Y_TOP_TO_BOTTOM | | | 961 | R128_DST_Y_TOP_TO_BOTTOM | |