main.c (66834) | main.c (70991) |
---|---|
1/*- 2 * Copyright (c) 1991-1997 S�ren Schmidt 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 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * | 1/*- 2 * Copyright (c) 1991-1997 S�ren Schmidt 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 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * |
28 * $FreeBSD: head/lib/libvgl/main.c 66834 2000-10-08 21:34:00Z phk $ | 28 * $FreeBSD: head/lib/libvgl/main.c 70991 2001-01-13 11:30:17Z nsouch $ |
29 */ 30 31#include <stdio.h> 32#include <sys/types.h> 33#include <sys/signal.h> 34#include <sys/file.h> 35#include <sys/ioctl.h> 36#include <sys/mman.h> 37#include <sys/fbio.h> 38#include <sys/kbio.h> 39#include <sys/consio.h> 40#include "vgl.h" 41 | 29 */ 30 31#include <stdio.h> 32#include <sys/types.h> 33#include <sys/signal.h> 34#include <sys/file.h> 35#include <sys/ioctl.h> 36#include <sys/mman.h> 37#include <sys/fbio.h> 38#include <sys/kbio.h> 39#include <sys/consio.h> 40#include "vgl.h" 41 |
42/* XXX Direct Color 24bits modes unsupported */ 43 |
|
42#define min(x, y) (((x) < (y)) ? (x) : (y)) 43#define max(x, y) (((x) > (y)) ? (x) : (y)) 44 45VGLBitmap *VGLDisplay; 46video_info_t VGLModeInfo; 47video_adapter_info_t VGLAdpInfo; 48byte *VGLBuf; 49 --- 123 unchanged lines hidden (view full) --- 173 VGLEnd(); 174 return -4; 175 } 176 VGLDisplay->Type = VIDBUF8; 177 break; 178 case V_INFO_MM_VGAX: 179 VGLDisplay->Type = VIDBUF8X; 180 break; | 44#define min(x, y) (((x) < (y)) ? (x) : (y)) 45#define max(x, y) (((x) > (y)) ? (x) : (y)) 46 47VGLBitmap *VGLDisplay; 48video_info_t VGLModeInfo; 49video_adapter_info_t VGLAdpInfo; 50byte *VGLBuf; 51 --- 123 unchanged lines hidden (view full) --- 175 VGLEnd(); 176 return -4; 177 } 178 VGLDisplay->Type = VIDBUF8; 179 break; 180 case V_INFO_MM_VGAX: 181 VGLDisplay->Type = VIDBUF8X; 182 break; |
183 case V_INFO_MM_DIRECT: 184 VGLDisplay->PixelBytes = VGLModeInfo.vi_pixel_size; 185 switch (VGLDisplay->PixelBytes) { 186 case 2: 187 VGLDisplay->Type = VIDBUF16; 188 break; 189#if notyet 190 case 3: 191 VGLDisplay->Type = VIDBUF24; 192 break; 193#endif 194 case 4: 195 VGLDisplay->Type = VIDBUF32; 196 break; 197 default: 198 VGLEnd(); 199 return -4; 200 } 201 break; |
|
181 default: 182 VGLEnd(); 183 return -4; 184 } 185 186 ioctl(0, VT_WAITACTIVE, 0); 187 ioctl(0, KDSETMODE, KD_GRAPHICS); 188 if (ioctl(0, mode, 0)) { --- 30 unchanged lines hidden (view full) --- 219 } 220 221#ifdef LIBVGL_DEBUG 222 fprintf(stderr, "VGLBufSize:0x%x\n", VGLBufSize); 223#endif 224 225 /* see if we are in the windowed buffer mode or in the linear buffer mode */ 226 if (VGLBufSize/VGLModeInfo.vi_planes > VGLAdpInfo.va_window_size) { | 202 default: 203 VGLEnd(); 204 return -4; 205 } 206 207 ioctl(0, VT_WAITACTIVE, 0); 208 ioctl(0, KDSETMODE, KD_GRAPHICS); 209 if (ioctl(0, mode, 0)) { --- 30 unchanged lines hidden (view full) --- 240 } 241 242#ifdef LIBVGL_DEBUG 243 fprintf(stderr, "VGLBufSize:0x%x\n", VGLBufSize); 244#endif 245 246 /* see if we are in the windowed buffer mode or in the linear buffer mode */ 247 if (VGLBufSize/VGLModeInfo.vi_planes > VGLAdpInfo.va_window_size) { |
227 if (VGLDisplay->Type == VIDBUF4) | 248 switch (VGLDisplay->Type) { 249 case VIDBUF4: |
228 VGLDisplay->Type = VIDBUF4S; | 250 VGLDisplay->Type = VIDBUF4S; |
229 else if (VGLDisplay->Type == VIDBUF8) | 251 break; 252 case VIDBUF8: |
230 VGLDisplay->Type = VIDBUF8S; | 253 VGLDisplay->Type = VIDBUF8S; |
254 break; 255 case VIDBUF16: 256 VGLDisplay->Type = VIDBUF16S; 257 break; 258 case VIDBUF24: 259 VGLDisplay->Type = VIDBUF24S; 260 break; 261 case VIDBUF32: 262 VGLDisplay->Type = VIDBUF32S; 263 break; 264 default: 265 VGLEnd(); 266 return -8; 267 } |
|
231 } 232 233 VGLMode = mode; 234 VGLCurWindow = 0; 235 236 VGLDisplay->Xsize = VGLModeInfo.vi_width; 237 VGLDisplay->Ysize = VGLModeInfo.vi_height; 238 VGLDisplay->VXsize = VGLAdpInfo.va_line_width --- 64 unchanged lines hidden (view full) --- 303 } 304 break; 305 case V_INFO_MM_PACKED: 306 if (VGLModeInfo.vi_depth == 8) { 307 if (VGLBufSize/VGLModeInfo.vi_planes > VGLAdpInfo.va_window_size) 308 VGLDisplay->Type = VIDBUF8S; 309 else 310 VGLDisplay->Type = VIDBUF8; | 268 } 269 270 VGLMode = mode; 271 VGLCurWindow = 0; 272 273 VGLDisplay->Xsize = VGLModeInfo.vi_width; 274 VGLDisplay->Ysize = VGLModeInfo.vi_height; 275 VGLDisplay->VXsize = VGLAdpInfo.va_line_width --- 64 unchanged lines hidden (view full) --- 340 } 341 break; 342 case V_INFO_MM_PACKED: 343 if (VGLModeInfo.vi_depth == 8) { 344 if (VGLBufSize/VGLModeInfo.vi_planes > VGLAdpInfo.va_window_size) 345 VGLDisplay->Type = VIDBUF8S; 346 else 347 VGLDisplay->Type = VIDBUF8; |
311 } else { 312 /* shouldn't be happening */ | |
313 } 314 break; 315 case V_INFO_MM_VGAX: 316 VGLDisplay->Type = VIDBUF8X; 317 break; | 348 } 349 break; 350 case V_INFO_MM_VGAX: 351 VGLDisplay->Type = VIDBUF8X; 352 break; |
353 case V_INFO_MM_DIRECT: 354 switch (VGLModeInfo.vi_pixel_size) { 355 case 2: 356 if (VGLBufSize/VGLModeInfo.vi_planes > VGLAdpInfo.va_window_size) 357 VGLDisplay->Type = VIDBUF16S; 358 else 359 VGLDisplay->Type = VIDBUF16; 360 break; 361 case 3: 362 if (VGLBufSize/VGLModeInfo.vi_planes > VGLAdpInfo.va_window_size) 363 VGLDisplay->Type = VIDBUF24S; 364 else 365 VGLDisplay->Type = VIDBUF24; 366 break; 367 case 4: 368 if (VGLBufSize/VGLModeInfo.vi_planes > VGLAdpInfo.va_window_size) 369 VGLDisplay->Type = VIDBUF32S; 370 else 371 VGLDisplay->Type = VIDBUF32; 372 break; 373 default: 374 /* shouldn't be happening */ 375 break; 376 } |
|
318 default: 319 /* shouldn't be happening */ 320 break; 321 } 322 323 VGLDisplay->Bitmap = VGLMem; 324 VGLDisplay->Xsize = VGLModeInfo.vi_width; 325 VGLDisplay->Ysize = VGLModeInfo.vi_height; --- 26 unchanged lines hidden (view full) --- 352 outb(0x3c4, 0x02); 353 outb(0x3c5, 0x01<<i); 354 bcopy(&VGLBuf[i*VGLAdpInfo.va_window_size], VGLMem, 355 VGLAdpInfo.va_window_size); 356 } 357 break; 358 case VIDBUF8: 359 case VIDBUF8S: | 377 default: 378 /* shouldn't be happening */ 379 break; 380 } 381 382 VGLDisplay->Bitmap = VGLMem; 383 VGLDisplay->Xsize = VGLModeInfo.vi_width; 384 VGLDisplay->Ysize = VGLModeInfo.vi_height; --- 26 unchanged lines hidden (view full) --- 411 outb(0x3c4, 0x02); 412 outb(0x3c5, 0x01<<i); 413 bcopy(&VGLBuf[i*VGLAdpInfo.va_window_size], VGLMem, 414 VGLAdpInfo.va_window_size); 415 } 416 break; 417 case VIDBUF8: 418 case VIDBUF8S: |
419 case VIDBUF16: 420 case VIDBUF16S: 421 case VIDBUF24: 422 case VIDBUF24S: 423 case VIDBUF32: 424 case VIDBUF32S: |
|
360 for (offset = 0; offset < VGLBufSize; offset += len) { 361 VGLSetSegment(offset); 362 len = min(VGLBufSize - offset, VGLAdpInfo.va_window_size); 363 bcopy(&VGLBuf[offset], VGLMem, len); 364 } 365 break; 366 } 367 VGLRestorePalette(); --- 25 unchanged lines hidden (view full) --- 393 outb(0x3ce, 0x04); 394 outb(0x3cf, i); 395 bcopy(VGLMem, &VGLBuf[i*VGLAdpInfo.va_window_size], 396 VGLAdpInfo.va_window_size); 397 } 398 break; 399 case VIDBUF8: 400 case VIDBUF8S: | 425 for (offset = 0; offset < VGLBufSize; offset += len) { 426 VGLSetSegment(offset); 427 len = min(VGLBufSize - offset, VGLAdpInfo.va_window_size); 428 bcopy(&VGLBuf[offset], VGLMem, len); 429 } 430 break; 431 } 432 VGLRestorePalette(); --- 25 unchanged lines hidden (view full) --- 458 outb(0x3ce, 0x04); 459 outb(0x3cf, i); 460 bcopy(VGLMem, &VGLBuf[i*VGLAdpInfo.va_window_size], 461 VGLAdpInfo.va_window_size); 462 } 463 break; 464 case VIDBUF8: 465 case VIDBUF8S: |
466 case VIDBUF16: 467 case VIDBUF16S: 468 case VIDBUF24: 469 case VIDBUF24S: 470 case VIDBUF32: 471 case VIDBUF32S: |
|
401 for (offset = 0; offset < VGLBufSize; offset += len) { 402 VGLSetSegment(offset); 403 len = min(VGLBufSize - offset, VGLAdpInfo.va_window_size); 404 bcopy(VGLMem, &VGLBuf[offset], len); 405 } 406 break; 407 } 408 VGLMem = MAP_FAILED; --- 71 unchanged lines hidden --- | 472 for (offset = 0; offset < VGLBufSize; offset += len) { 473 VGLSetSegment(offset); 474 len = min(VGLBufSize - offset, VGLAdpInfo.va_window_size); 475 bcopy(VGLMem, &VGLBuf[offset], len); 476 } 477 break; 478 } 479 VGLMem = MAP_FAILED; --- 71 unchanged lines hidden --- |