comparison src/video/fbcon/SDL_fbvideo.c @ 1798:49b4b8413734

Date: Tue, 9 May 2006 23:01:49 -0400 From: Mike Frysinger Subject: [SDL] [patch] fall back to using MAP_PRIVATE with mmap() in fbcon dri trying to use MAP_SHARED with mmap() on uClinux (aka non-mmu) hosts nowadays will simply fail since the kernel disallows it ... falling back to using MAP_PRIVATE on these hosts is acceptable ... as such, ive attached a patch for the fbcon driver that will fall back to using MAP_PRIVATE if mmap() with MAP_SHARED failed going by a grep of MAP_SHARED, the only other drivers that utilize this flag are video/wscons, video/ps2gs, and sound/dmaaudio ... i dont think these would appear on a non-mmu host so the patch i wrote is restricted to just SDL_fbvideo.c ... -mike
author Sam Lantinga <slouken@libsdl.org>
date Wed, 10 May 2006 04:05:46 +0000
parents 7a36f01acf71
children 6987e947c77a
comparison
equal deleted inserted replaced
1797:783b9409baa0 1798:49b4b8413734
147 /* Internal palette functions */ 147 /* Internal palette functions */
148 static void FB_SavePalette(_THIS, struct fb_fix_screeninfo *finfo, 148 static void FB_SavePalette(_THIS, struct fb_fix_screeninfo *finfo,
149 struct fb_var_screeninfo *vinfo); 149 struct fb_var_screeninfo *vinfo);
150 static void FB_RestorePalette(_THIS); 150 static void FB_RestorePalette(_THIS);
151 151
152 /* Small wrapper for mmap() so we can play nicely with no-mmu hosts
153 * (non-mmu hosts disallow the MAP_SHARED flag) */
154
155 static void *do_mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset)
156 {
157 void *ret;
158 ret = mmap(start, length, prot, flags, fd, offset);
159 if ( ret == (char *)-1 && (flags & MAP_SHARED) ) {
160 ret = mmap(start, length, prot,
161 (flags & ~MAP_SHARED) | MAP_PRIVATE, fd, offset);
162 }
163 }
164
152 /* FB driver bootstrap functions */ 165 /* FB driver bootstrap functions */
153 166
154 static int FB_Available(void) 167 static int FB_Available(void)
155 { 168 {
156 int console; 169 int console;
533 546
534 /* Memory map the device, compensating for buggy PPC mmap() */ 547 /* Memory map the device, compensating for buggy PPC mmap() */
535 mapped_offset = (((long)finfo.smem_start) - 548 mapped_offset = (((long)finfo.smem_start) -
536 (((long)finfo.smem_start)&~(PAGE_SIZE-1))); 549 (((long)finfo.smem_start)&~(PAGE_SIZE-1)));
537 mapped_memlen = finfo.smem_len+mapped_offset; 550 mapped_memlen = finfo.smem_len+mapped_offset;
538 mapped_mem = mmap(NULL, mapped_memlen, 551 mapped_mem = do_mmap(NULL, mapped_memlen,
539 PROT_READ|PROT_WRITE, MAP_SHARED, console_fd, 0); 552 PROT_READ|PROT_WRITE, MAP_SHARED, console_fd, 0);
540 if ( mapped_mem == (char *)-1 ) { 553 if ( mapped_mem == (char *)-1 ) {
541 SDL_SetError("Unable to memory map the video hardware"); 554 SDL_SetError("Unable to memory map the video hardware");
542 mapped_mem = NULL; 555 mapped_mem = NULL;
543 FB_VideoQuit(this); 556 FB_VideoQuit(this);
577 */ 590 */
578 vinfo.accel_flags = 0; /* Temporarily reserve registers */ 591 vinfo.accel_flags = 0; /* Temporarily reserve registers */
579 ioctl(console_fd, FBIOPUT_VSCREENINFO, &vinfo); 592 ioctl(console_fd, FBIOPUT_VSCREENINFO, &vinfo);
580 if ( finfo.accel && finfo.mmio_len ) { 593 if ( finfo.accel && finfo.mmio_len ) {
581 mapped_iolen = finfo.mmio_len; 594 mapped_iolen = finfo.mmio_len;
582 mapped_io = mmap(NULL, mapped_iolen, PROT_READ|PROT_WRITE, 595 mapped_io = do_mmap(NULL, mapped_iolen, PROT_READ|PROT_WRITE,
583 MAP_SHARED, console_fd, mapped_memlen); 596 MAP_SHARED, console_fd, mapped_memlen);
584 if ( mapped_io == (char *)-1 ) { 597 if ( mapped_io == (char *)-1 ) {
585 /* Hmm, failed to memory map I/O registers */ 598 /* Hmm, failed to memory map I/O registers */
586 mapped_io = NULL; 599 mapped_io = NULL;
587 } 600 }