| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: gftfb.c,v 1.13 2024/04/01 09:48:58 macallan Exp $ */ | | 1 | /* $NetBSD: gftfb.c,v 1.14 2024/04/18 04:52:43 macallan Exp $ */ |
2 | | | 2 | |
3 | /* $OpenBSD: sti_pci.c,v 1.7 2009/02/06 22:51:04 miod Exp $ */ | | 3 | /* $OpenBSD: sti_pci.c,v 1.7 2009/02/06 22:51:04 miod Exp $ */ |
4 | | | 4 | |
5 | /* | | 5 | /* |
6 | * Copyright (c) 2006, 2007 Miodrag Vallat. | | 6 | * Copyright (c) 2006, 2007 Miodrag Vallat. |
7 | ^ 2024 Michael Lorenz | | 7 | ^ 2024 Michael Lorenz |
8 | * | | 8 | * |
9 | * Permission to use, copy, modify, and distribute this software for any | | 9 | * Permission to use, copy, modify, and distribute this software for any |
10 | * purpose with or without fee is hereby granted, provided that the above | | 10 | * purpose with or without fee is hereby granted, provided that the above |
11 | * copyright notice, this permission notice, and the disclaimer below | | 11 | * copyright notice, this permission notice, and the disclaimer below |
12 | * appear in all copies. | | 12 | * appear in all copies. |
13 | * | | 13 | * |
14 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | | 14 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| @@ -227,27 +227,28 @@ gftfb_attach(device_t parent, device_t s | | | @@ -227,27 +227,28 @@ gftfb_attach(device_t parent, device_t s |
227 | | | 227 | |
228 | aprint_normal("\n"); | | 228 | aprint_normal("\n"); |
229 | | | 229 | |
230 | if (gftfb_check_rom(sc, paa) != 0) | | 230 | if (gftfb_check_rom(sc, paa) != 0) |
231 | return; | | 231 | return; |
232 | | | 232 | |
233 | ret = sti_pci_is_console(paa, sc->sc_base. bases); | | 233 | ret = sti_pci_is_console(paa, sc->sc_base. bases); |
234 | if (ret != 0) { | | 234 | if (ret != 0) { |
235 | sc->sc_base.sc_flags |= STI_CONSOLE; | | 235 | sc->sc_base.sc_flags |= STI_CONSOLE; |
236 | is_console = 1; | | 236 | is_console = 1; |
237 | } | | 237 | } |
238 | rom = (struct sti_rom *)kmem_zalloc(sizeof(*rom), KM_SLEEP); | | 238 | rom = (struct sti_rom *)kmem_zalloc(sizeof(*rom), KM_SLEEP); |
239 | rom->rom_softc = &sc->sc_base; | | 239 | rom->rom_softc = &sc->sc_base; |
240 | ret = sti_rom_setup(rom, paa->pa_iot, paa->pa_memt, sc->sc_romh, sc->sc_base.bases, STI_CODEBASE_MAIN); | | 240 | ret = sti_rom_setup(rom, paa->pa_iot, paa->pa_memt, sc->sc_romh, |
| | | 241 | sc->sc_base.bases, STI_CODEBASE_MAIN); |
241 | if (ret != 0) { | | 242 | if (ret != 0) { |
242 | kmem_free(rom, sizeof(*rom)); | | 243 | kmem_free(rom, sizeof(*rom)); |
243 | return; | | 244 | return; |
244 | } | | 245 | } |
245 | | | 246 | |
246 | sc->sc_base.sc_rom = rom; | | 247 | sc->sc_base.sc_rom = rom; |
247 | | | 248 | |
248 | sc->sc_scr.scr_rom = sc->sc_base.sc_rom; | | 249 | sc->sc_scr.scr_rom = sc->sc_base.sc_rom; |
249 | ret = sti_screen_setup(&sc->sc_scr, STI_FBMODE); | | 250 | ret = sti_screen_setup(&sc->sc_scr, STI_FBMODE); |
250 | | | 251 | |
251 | sc->sc_width = sc->sc_scr.scr_cfg.scr_width; | | 252 | sc->sc_width = sc->sc_scr.scr_cfg.scr_width; |
252 | sc->sc_height = sc->sc_scr.scr_cfg.scr_height; | | 253 | sc->sc_height = sc->sc_scr.scr_cfg.scr_height; |
253 | sc->sc_rect_colour = 0xf0000000; | | 254 | sc->sc_rect_colour = 0xf0000000; |
| @@ -879,36 +880,42 @@ gftfb_ioctl(void *v, void *vs, u_long cm | | | @@ -879,36 +880,42 @@ gftfb_ioctl(void *v, void *vs, u_long cm |
879 | case WSDISPLAYIO_GVIDEO: | | 880 | case WSDISPLAYIO_GVIDEO: |
880 | return sc->sc_video_on ? | | 881 | return sc->sc_video_on ? |
881 | WSDISPLAYIO_VIDEO_ON : WSDISPLAYIO_VIDEO_OFF; | | 882 | WSDISPLAYIO_VIDEO_ON : WSDISPLAYIO_VIDEO_OFF; |
882 | } | | 883 | } |
883 | return EPASSTHROUGH; | | 884 | return EPASSTHROUGH; |
884 | } | | 885 | } |
885 | | | 886 | |
886 | static paddr_t | | 887 | static paddr_t |
887 | gftfb_mmap(void *v, void *vs, off_t offset, int prot) | | 888 | gftfb_mmap(void *v, void *vs, off_t offset, int prot) |
888 | { | | 889 | { |
889 | struct vcons_data *vd = v; | | 890 | struct vcons_data *vd = v; |
890 | struct gftfb_softc *sc = vd->cookie; | | 891 | struct gftfb_softc *sc = vd->cookie; |
891 | struct sti_rom *rom = sc->sc_base.sc_rom; | | 892 | struct sti_rom *rom = sc->sc_base.sc_rom; |
892 | paddr_t pa; | | 893 | paddr_t pa = -1; |
893 | | | 894 | |
894 | if (offset < 0 || offset >= sc->sc_scr.fblen) | | | |
895 | return -1; | | | |
896 | | | 895 | |
897 | if (sc->sc_mode != WSDISPLAYIO_MODE_DUMBFB) | | 896 | if (sc->sc_mode == WSDISPLAYIO_MODE_EMUL) |
898 | return -1; | | 897 | return -1; |
899 | | | 898 | |
900 | pa = bus_space_mmap(rom->memt, sc->sc_scr.fbaddr, offset, prot, | | 899 | if (offset >= 0 || offset < sc->sc_scr.fblen) { |
901 | BUS_SPACE_MAP_LINEAR); | | 900 | /* framebuffer */ |
| | | 901 | pa = bus_space_mmap(rom->memt, sc->sc_scr.fbaddr, offset, |
| | | 902 | prot, BUS_SPACE_MAP_LINEAR); |
| | | 903 | } else if (offset >= 0x80000000 && offset < 0x8040000) { |
| | | 904 | /* blitter registers etc. */ |
| | | 905 | pa = bus_space_mmap(rom->memt, rom->regh[2], |
| | | 906 | offset - 0x80000000, prot, BUS_SPACE_MAP_LINEAR); |
| | | 907 | } |
| | | 908 | |
902 | return pa; | | 909 | return pa; |
903 | } | | 910 | } |
904 | | | 911 | |
905 | static void | | 912 | static void |
906 | gftfb_init_screen(void *cookie, struct vcons_screen *scr, | | 913 | gftfb_init_screen(void *cookie, struct vcons_screen *scr, |
907 | int existing, long *defattr) | | 914 | int existing, long *defattr) |
908 | { | | 915 | { |
909 | struct gftfb_softc *sc = cookie; | | 916 | struct gftfb_softc *sc = cookie; |
910 | struct rasops_info *ri = &scr->scr_ri; | | 917 | struct rasops_info *ri = &scr->scr_ri; |
911 | | | 918 | |
912 | ri->ri_depth = 8; | | 919 | ri->ri_depth = 8; |
913 | ri->ri_width = sc->sc_width; | | 920 | ri->ri_width = sc->sc_width; |
914 | ri->ri_height = sc->sc_height; | | 921 | ri->ri_height = sc->sc_height; |