| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: igsfb.c,v 1.54 2017/01/25 15:51:07 jakllsch Exp $ */ | | 1 | /* $NetBSD: igsfb.c,v 1.55 2017/01/25 16:11:54 jakllsch Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2002, 2003 Valeriy E. Ushakov | | 4 | * Copyright (c) 2002, 2003 Valeriy E. Ushakov |
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 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | | 21 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | | 22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | | 23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | | 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | | 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | | 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | 27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
28 | */ | | 28 | */ |
29 | | | 29 | |
30 | /* | | 30 | /* |
31 | * Integraphics Systems IGA 168x and CyberPro series. | | 31 | * Integraphics Systems IGA 168x and CyberPro series. |
32 | */ | | 32 | */ |
33 | #include <sys/cdefs.h> | | 33 | #include <sys/cdefs.h> |
34 | __KERNEL_RCSID(0, "$NetBSD: igsfb.c,v 1.54 2017/01/25 15:51:07 jakllsch Exp $"); | | 34 | __KERNEL_RCSID(0, "$NetBSD: igsfb.c,v 1.55 2017/01/25 16:11:54 jakllsch 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/ioctl.h> | | 41 | #include <sys/ioctl.h> |
42 | | | 42 | |
43 | #include <sys/bus.h> | | 43 | #include <sys/bus.h> |
44 | | | 44 | |
45 | #include <dev/wscons/wsdisplayvar.h> | | 45 | #include <dev/wscons/wsdisplayvar.h> |
46 | #include <dev/wscons/wsconsio.h> | | 46 | #include <dev/wscons/wsconsio.h> |
47 | #include <dev/wsfont/wsfont.h> | | 47 | #include <dev/wsfont/wsfont.h> |
| @@ -269,52 +269,72 @@ igsfb_init_video(struct igsfb_devconfig | | | @@ -269,52 +269,72 @@ igsfb_init_video(struct igsfb_devconfig |
269 | | | 269 | |
270 | /* | | 270 | /* |
271 | * On CyberPro we can use magic bswap bit in linear address. | | 271 | * On CyberPro we can use magic bswap bit in linear address. |
272 | */ | | 272 | */ |
273 | fbaddr = dc->dc_memaddr; | | 273 | fbaddr = dc->dc_memaddr; |
274 | if (need_bswap) { | | 274 | if (need_bswap) { |
275 | dc->dc_hwflags |= IGSFB_HW_BSWAP; | | 275 | dc->dc_hwflags |= IGSFB_HW_BSWAP; |
276 | if (dc->dc_id >= 0x2000) { | | 276 | if (dc->dc_id >= 0x2000) { |
277 | dc->dc_hwflags |= IGSFB_HW_BE_SELECT; | | 277 | dc->dc_hwflags |= IGSFB_HW_BE_SELECT; |
278 | fbaddr |= IGS_MEM_BE_SELECT; | | 278 | fbaddr |= IGS_MEM_BE_SELECT; |
279 | } | | 279 | } |
280 | } | | 280 | } |
281 | | | 281 | |
| | | 282 | /* |
| | | 283 | * Map graphic coprocessor for mode setting and accelerated rasops. |
| | | 284 | */ |
| | | 285 | if (dc->dc_id >= 0x2000) { /* XXX */ |
| | | 286 | if (bus_space_map(dc->dc_iot, |
| | | 287 | dc->dc_iobase + IGS_COP_BASE_B, IGS_COP_SIZE, |
| | | 288 | dc->dc_ioflags, |
| | | 289 | &dc->dc_coph) != 0) |
| | | 290 | { |
| | | 291 | printf("unable to map COP registers\n"); |
| | | 292 | return 1; |
| | | 293 | } |
| | | 294 | } |
| | | 295 | |
282 | igsfb_hw_setup(dc); | | 296 | igsfb_hw_setup(dc); |
283 | | | 297 | |
284 | /* | | 298 | /* |
285 | * Don't map in all N megs, just the amount we need for the wsscreen. | | 299 | * Don't map in all N megs, just the amount we need for the wsscreen. |
286 | */ | | 300 | */ |
287 | dc->dc_fbsz = dc->dc_stride * dc->dc_height; | | 301 | dc->dc_fbsz = dc->dc_stride * dc->dc_height; |
288 | if (bus_space_map(dc->dc_memt, fbaddr, dc->dc_fbsz, | | 302 | if (bus_space_map(dc->dc_memt, fbaddr, dc->dc_fbsz, |
289 | dc->dc_memflags | BUS_SPACE_MAP_LINEAR, | | 303 | dc->dc_memflags | BUS_SPACE_MAP_LINEAR, |
290 | &dc->dc_fbh) != 0) | | 304 | &dc->dc_fbh) != 0) |
291 | { | | 305 | { |
| | | 306 | if (dc->dc_id >= 0x2000) { /* XXX */ |
| | | 307 | bus_space_unmap(dc->dc_iot, dc->dc_coph, IGS_COP_SIZE); |
| | | 308 | } |
292 | bus_space_unmap(dc->dc_iot, dc->dc_ioh, IGS_REG_SIZE); | | 309 | bus_space_unmap(dc->dc_iot, dc->dc_ioh, IGS_REG_SIZE); |
293 | printf("unable to map framebuffer\n"); | | 310 | printf("unable to map framebuffer\n"); |
294 | return 1; | | 311 | return 1; |
295 | } | | 312 | } |
296 | | | 313 | |
297 | igsfb_init_cmap(dc); | | 314 | igsfb_init_cmap(dc); |
298 | | | 315 | |
299 | /* | | 316 | /* |
300 | * 1KB for cursor sprite data at the very end of the video memory. | | 317 | * 1KB for cursor sprite data at the very end of the video memory. |
301 | */ | | 318 | */ |
302 | croffset = dc->dc_vmemsz - IGS_CURSOR_DATA_SIZE; | | 319 | croffset = dc->dc_vmemsz - IGS_CURSOR_DATA_SIZE; |
303 | craddr = fbaddr + croffset; | | 320 | craddr = fbaddr + croffset; |
304 | if (bus_space_map(dc->dc_memt, craddr, IGS_CURSOR_DATA_SIZE, | | 321 | if (bus_space_map(dc->dc_memt, craddr, IGS_CURSOR_DATA_SIZE, |
305 | dc->dc_memflags | BUS_SPACE_MAP_LINEAR, | | 322 | dc->dc_memflags | BUS_SPACE_MAP_LINEAR, |
306 | &dc->dc_crh) != 0) | | 323 | &dc->dc_crh) != 0) |
307 | { | | 324 | { |
| | | 325 | if (dc->dc_id >= 0x2000) { /* XXX */ |
| | | 326 | bus_space_unmap(dc->dc_iot, dc->dc_coph, IGS_COP_SIZE); |
| | | 327 | } |
308 | bus_space_unmap(dc->dc_iot, dc->dc_ioh, IGS_REG_SIZE); | | 328 | bus_space_unmap(dc->dc_iot, dc->dc_ioh, IGS_REG_SIZE); |
309 | bus_space_unmap(dc->dc_memt, dc->dc_fbh, dc->dc_fbsz); | | 329 | bus_space_unmap(dc->dc_memt, dc->dc_fbh, dc->dc_fbsz); |
310 | printf("unable to map cursor sprite region\n"); | | 330 | printf("unable to map cursor sprite region\n"); |
311 | return 1; | | 331 | return 1; |
312 | } | | 332 | } |
313 | | | 333 | |
314 | /* | | 334 | /* |
315 | * Tell the device where cursor sprite data are located in the | | 335 | * Tell the device where cursor sprite data are located in the |
316 | * linear space (it takes data offset in 1KB units). | | 336 | * linear space (it takes data offset in 1KB units). |
317 | */ | | 337 | */ |
318 | croffset >>= 10; /* bytes -> kilobytes */ | | 338 | croffset >>= 10; /* bytes -> kilobytes */ |
319 | igs_ext_write(dc->dc_iot, dc->dc_ioh, | | 339 | igs_ext_write(dc->dc_iot, dc->dc_ioh, |
320 | IGS_EXT_SPRITE_DATA_LO, croffset & 0xff); | | 340 | IGS_EXT_SPRITE_DATA_LO, croffset & 0xff); |
| @@ -326,38 +346,29 @@ igsfb_init_video(struct igsfb_devconfig | | | @@ -326,38 +346,29 @@ igsfb_init_video(struct igsfb_devconfig |
326 | | | 346 | |
327 | /* XXX: fill dc_cursor and use igsfb_update_cursor() instead? */ | | 347 | /* XXX: fill dc_cursor and use igsfb_update_cursor() instead? */ |
328 | memset(&dc->dc_cursor, 0, sizeof(struct igs_hwcursor)); | | 348 | memset(&dc->dc_cursor, 0, sizeof(struct igs_hwcursor)); |
329 | va = bus_space_vaddr(dc->dc_memt, dc->dc_crh); | | 349 | va = bus_space_vaddr(dc->dc_memt, dc->dc_crh); |
330 | memset(va, /* transparent */ 0xaa, IGS_CURSOR_DATA_SIZE); | | 350 | memset(va, /* transparent */ 0xaa, IGS_CURSOR_DATA_SIZE); |
331 | | | 351 | |
332 | curctl = igs_ext_read(dc->dc_iot, dc->dc_ioh, IGS_EXT_SPRITE_CTL); | | 352 | curctl = igs_ext_read(dc->dc_iot, dc->dc_ioh, IGS_EXT_SPRITE_CTL); |
333 | curctl |= IGS_EXT_SPRITE_64x64; | | 353 | curctl |= IGS_EXT_SPRITE_64x64; |
334 | curctl &= ~IGS_EXT_SPRITE_VISIBLE; | | 354 | curctl &= ~IGS_EXT_SPRITE_VISIBLE; |
335 | igs_ext_write(dc->dc_iot, dc->dc_ioh, IGS_EXT_SPRITE_CTL, curctl); | | 355 | igs_ext_write(dc->dc_iot, dc->dc_ioh, IGS_EXT_SPRITE_CTL, curctl); |
336 | dc->dc_curenb = 0; | | 356 | dc->dc_curenb = 0; |
337 | | | 357 | |
338 | /* | | 358 | /* |
339 | * Map and init graphic coprocessor for accelerated rasops. | | 359 | * Init graphic coprocessor for accelerated rasops. |
340 | */ | | 360 | */ |
341 | if (dc->dc_id >= 0x2000) { /* XXX */ | | 361 | if (dc->dc_id >= 0x2000) { /* XXX */ |
342 | if (bus_space_map(dc->dc_iot, | | | |
343 | dc->dc_iobase + IGS_COP_BASE_B, IGS_COP_SIZE, | | | |
344 | dc->dc_ioflags, | | | |
345 | &dc->dc_coph) != 0) | | | |
346 | { | | | |
347 | printf("unable to map COP registers\n"); | | | |
348 | return 1; | | | |
349 | } | | | |
350 | | | | |
351 | /* XXX: hardcoded 8bpp */ | | 362 | /* XXX: hardcoded 8bpp */ |
352 | bus_space_write_2(dc->dc_iot, dc->dc_coph, | | 363 | bus_space_write_2(dc->dc_iot, dc->dc_coph, |
353 | IGS_COP_SRC_MAP_WIDTH_REG, | | 364 | IGS_COP_SRC_MAP_WIDTH_REG, |
354 | dc->dc_width - 1); | | 365 | dc->dc_width - 1); |
355 | bus_space_write_2(dc->dc_iot, dc->dc_coph, | | 366 | bus_space_write_2(dc->dc_iot, dc->dc_coph, |
356 | IGS_COP_DST_MAP_WIDTH_REG, | | 367 | IGS_COP_DST_MAP_WIDTH_REG, |
357 | dc->dc_width - 1); | | 368 | dc->dc_width - 1); |
358 | | | 369 | |
359 | bus_space_write_1(dc->dc_iot, dc->dc_coph, | | 370 | bus_space_write_1(dc->dc_iot, dc->dc_coph, |
360 | IGS_COP_MAP_FMT_REG, | | 371 | IGS_COP_MAP_FMT_REG, |
361 | IGS_COP_MAP_8BPP); | | 372 | IGS_COP_MAP_8BPP); |
362 | } | | 373 | } |
363 | | | 374 | |