From: Albert H. <he...@us...> - 2006-03-24 22:20:46
|
Update of /cvsroot/gc-linux/linux/drivers/video In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22880/drivers/video Modified Files: Kconfig gcnfb.c gcngx.c gcngx.h Log Message: Rewrote the framebuffer driver. Made the GX stuff optional (also saves GX reserved mem if not compiled in). Index: gcngx.h =================================================================== RCS file: /cvsroot/gc-linux/linux/drivers/video/gcngx.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- gcngx.h 24 Mar 2006 21:45:18 -0000 1.2 +++ gcngx.h 24 Mar 2006 22:20:15 -0000 1.3 @@ -1,12 +1,17 @@ #ifndef __GCGX__ #define __GCGX__ +#ifdef CONFIG_FB_GAMECUBE_GX + int gcngx_mmap(struct fb_info *info, struct vm_area_struct *vma); int gcngx_ioctl(struct fb_info *info, unsigned int cmd,unsigned long arg); int gcngx_init(struct fb_info *info); void gcngx_exit(struct fb_info *info); -void gcngx_vtrace(void); +struct vi_ctl; +void gcngx_vtrace(struct vi_ctl *ctl); + +#endif #endif Index: gcnfb.c =================================================================== RCS file: /cvsroot/gc-linux/linux/drivers/video/gcnfb.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- gcnfb.c 24 Mar 2006 21:45:18 -0000 1.13 +++ gcnfb.c 24 Mar 2006 22:20:15 -0000 1.14 @@ -2,9 +2,10 @@ * drivers/video/gcnfb.c * * Nintendo GameCube "Flipper" chipset frame buffer driver - * Copyright (C) 2004-2005 The GameCube Linux Team + * Copyright (C) 2004-2006 The GameCube Linux Team * Copyright (C) 2004 Michael Steil <mi...@c6...> * Copyright (C) 2004,2005 Todd Jeffreys <to...@vo...> + * Copyright (C) 2006 Albert Herranz * * Based on vesafb (c) 1998 Gerd Knorr <kr...@go...> * [...1316 lines suppressed...] + } + return ret; +} + +/* + * + */ +static void __exit gcnfb_exit_module(void) +{ + platform_device_unregister(&gcnfb_device); + platform_driver_unregister(&gcnfb_driver); +} + +module_init(gcnfb_init_module); +module_exit(gcnfb_exit_module); + +MODULE_DESCRIPTION(DRV_DESCRIPTION); +MODULE_AUTHOR(DRV_AUTHOR); +MODULE_LICENSE("GPL"); + Index: gcngx.c =================================================================== RCS file: /cvsroot/gc-linux/linux/drivers/video/gcngx.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- gcngx.c 24 Mar 2006 21:45:18 -0000 1.8 +++ gcngx.c 24 Mar 2006 22:20:15 -0000 1.9 @@ -14,6 +14,9 @@ * of the License, or (at your option) any later version. * */ + +#ifdef CONFIG_FB_GAMECUBE_GX + #include <linux/module.h> #include <linux/kernel.h> #include <linux/errno.h> @@ -36,8 +39,9 @@ static void gcngx_free_munmap(struct vm_area_struct *vma); static void gcngx_destroy_fifo(void); static void gcngx_init_fifo(void); + +extern void vi_set_framebuffer(struct vi_ctl *ctl, u32 addr); extern int gcnfb_restorefb(struct fb_info *info); -extern void gcnfb_set_framebuffer(u32 addr); extern struct fb_ops gcnfb_ops; @@ -155,7 +159,7 @@ return IRQ_NONE; } -void gcngx_vtrace(void) +void gcngx_vtrace(struct vi_ctl *ctl) { struct siginfo sig; /* ok flip the image if we have a flip request. @@ -168,7 +172,7 @@ currentFB = currentFB ? 0 : 1; sig.si_errno = xfb[currentFB]; /* inform the hardware */ - gcnfb_set_framebuffer(xfb[currentFB]); + vi_set_framebuffer(ctl, xfb[currentFB]); /* notify the process */ sig.si_signo = SIG_VTRACE_COMPLETE; sig.si_code = 0; @@ -213,13 +217,61 @@ return IRQ_HANDLED; } +/** + * + */ +static u32 gcngx_uvirt_to_phys(u32 virt) +{ + pgd_t *dir; + pmd_t *pmd; + pte_t *pte; + u32 ret = 0; + struct mm_struct *mm = get_task_mm(current); + u32 offset = virt & (PAGE_SIZE - 1); + virt &= PAGE_MASK; + + if (!mm) { + return 0; + } + down_read(&mm->mmap_sem); + /* convert to kernel address */ + if ((dir = pgd_offset(mm, virt)) && pgd_present(*dir)) { + if ((pmd = pmd_offset(dir, virt)) && pmd_present(*pmd)) { + pte = pte_offset_kernel(pmd, virt); + if (pte && pte_present(*pte)) { + ret = + (u32) page_address(pte_page(*pte)) + offset; + /* ok now we have the kern addr, map to phys */ + ret = virt_to_phys((void *)ret); + } + } + } + + up_read(&mm->mmap_sem); + mmput(mm); + return ret; +} + int gcngx_ioctl(struct fb_info *info, - unsigned int cmd, unsigned long arg) + unsigned int cmd, unsigned long arg) { + u32 phys; + void __user *argp; + if (cmd == FBIOFLIP) { flipRequest = 1; return 0; + } else if (cmd == FBIOVIRTTOPHYS) { + argp = (void __user *)arg; + if (copy_from_user(&phys, argp, sizeof(void *))) + return -EFAULT; + + phys = gcngx_uvirt_to_phys(phys); + + if (copy_to_user(argp, &phys, sizeof(void *))) + return -EFAULT; + return 0; } return -EINVAL; } @@ -289,10 +341,11 @@ { struct file *file = vma->vm_file; int ret; - static spinlock_t lock = SPIN_LOCK_UNLOCKED; +// static spinlock_t lock = SPIN_LOCK_UNLOCKED; u32 phys; u32 len; + len = vma->vm_end - vma->vm_start; if (vma->vm_pgoff == (VIDEO_MMAP_BASE >> PAGE_SHIFT) && @@ -349,13 +402,13 @@ * This seems to be broken. * fb_mmap might sleep and we're getting a lock here. */ - spin_lock(&lock); +// spin_lock(&lock); /* reset our mmap since the fb driver will call it */ gcnfb_ops.fb_mmap = NULL; ret = file->f_op->mmap(file,vma); /* reset our mmap */ gcnfb_ops.fb_mmap = gcngx_mmap; - spin_unlock(&lock); +// spin_unlock(&lock); return ret; } return -EINVAL; @@ -624,3 +677,6 @@ iounmap(mmap_fifo_base); release_mem_region((u32)phys_fifo_base,fifo_len); } + +#endif /* CONFIG_FB_GAMECUBE_GX */ + Index: Kconfig =================================================================== RCS file: /cvsroot/gc-linux/linux/drivers/video/Kconfig,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- Kconfig 24 Mar 2006 21:45:18 -0000 1.17 +++ Kconfig 24 Mar 2006 22:20:15 -0000 1.18 @@ -1209,6 +1209,12 @@ help This is the frame buffer device driver for the Nintendo GameCube. +config FB_GAMECUBE_GX + bool "Nintendo GameCube hardware accelerated graphics support" + depends on FB_GAMECUBE + help + Say Y here to support the 3D hardware found in the Nintendo GameCube. + config FB_AU1100 bool "Au1100 LCD Driver" depends on (FB = y) && EXPERIMENTAL && PCI && MIPS && MIPS_PB1100=y |