diff -Nur matroxdriver-1.4.1/kernel/src/mtx_agp.c matroxdriver-1.4.2/kernel/src/mtx_agp.c --- matroxdriver-1.4.1/kernel/src/mtx_agp.c 2005-03-22 17:04:41.000000000 +0100 +++ matroxdriver-1.4.2/kernel/src/mtx_agp.c 2005-06-23 11:56:14.082206139 +0200 @@ -7,6 +7,7 @@ References: None. Author: Karl Lessard +2.6.x Updates: Alexander Griesser Copyright (c) 2001, Matrox Graphics Inc. All Rights Reserved. @@ -23,6 +24,11 @@ const drm_agp_t *agp_backend = NULL; #endif +/* Support multiple agp bridges in newer kernels */ +#ifdef AGPGART_HAS_BRIDGES + struct agp_bridge_data *bridge; +#endif + void mtx_agp_chipset_info_print( AGP_KernInfo* poAGPInfo ); /*************************************************************************************** @@ -64,8 +70,12 @@ #endif /* Copy AGP information */ - MTX_AGPGART_COPY_INFO( agp_backend, &agp_drv->kern_info); - +#ifdef AGPGART_HAS_BRIDGES + MTX_AGPGART_COPY_INFO(bridge, &agp_drv->kern_info); +#else + MTX_AGPGART_COPY_INFO(agp_backend, &agp_drv->kern_info); +#endif + agp_drv->aperture_base = agp_drv->kern_info.aper_base; agp_drv->aperture_size = agp_drv->kern_info.aper_size * 1024L * 1024L; @@ -136,10 +146,15 @@ if (!agp_drv || (agp_drv->dev != NULL)) return -EINVAL; +#ifdef AGPGART_HAS_BRIDGES + /* acquire control of AGP backend */ + if(!(bridge = MTX_AGPGART_BACKEND_ACQUIRE(&agp_drv->dev))) + return -ENODEV; +#else /* acquire control of AGP backend */ if ((ret = MTX_AGPGART_BACKEND_ACQUIRE(agp_backend)) < 0) return ret; - +#endif agp_drv->dev = dev; return 0; @@ -164,7 +179,11 @@ return; /* release control of AGP backend */ +#ifdef AGPGART_HAS_BRIDGES + MTX_AGPGART_BACKEND_RELEASE(bridge); +#else MTX_AGPGART_BACKEND_RELEASE(agp_backend); +#endif agp_drv->dev = NULL; }; @@ -234,7 +253,11 @@ agp_drv->rate; /* enable AGP controller */ - MTX_AGPGART_BACKEND_ENABLE(agp_backend,agp_command); +#ifdef AGPGART_HAS_BRIDGES + MTX_AGPGART_BACKEND_ENABLE(bridge, agp_command); +#else + MTX_AGPGART_BACKEND_ENABLE(agp_backend, agp_command); +#endif agp_drv->enabled = 1; diff -Nur matroxdriver-1.4.1/kernel/src/mtx_drv.h matroxdriver-1.4.2/kernel/src/mtx_drv.h --- matroxdriver-1.4.1/kernel/src/mtx_drv.h 2005-03-22 17:04:41.000000000 +0100 +++ matroxdriver-1.4.2/kernel/src/mtx_drv.h 2005-06-23 12:21:45.313930003 +0200 @@ -7,6 +7,7 @@ References: None. Author: Karl Lessard +2.6.x Updates: Alexander Griesser Copyright (c) 2001, Matrox Graphics Inc. All Rights Reserved. @@ -95,22 +96,41 @@ #endif -/* Special macros for linux kernel 2.6.10 and upwards */ -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10)) +/* Special macros for linux kernel 2.6.12 and upwards + * because agp_backend.h has been changed again to support + * multiple agp_bridges, yeah */ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,12)) + + #define AGPGART_HAS_BRIDGES + + #define MTX_AGPGART_BACKEND_ACQUIRE(o) agp_backend_acquire(o) + #define MTX_AGPGART_ALLOCATE_MEMORY(o,count,type) agp_allocate_memory(o,count,type) + #define MTX_AGPGART_COPY_INFO(o,p) agp_copy_info(o,p) + #define MTX_AGPGART_BACKEND_ENABLE(o,mode) agp_enable(o,mode) + #define MTX_AGPGART_BACKEND_RELEASE(o) agp_backend_release(o) + #define MTX_AGPGART_FREE_MEMORY(o) agp_free_memory(o) + #define MTX_AGPGART_BIND_MEMORY(o,offset) agp_bind_memory(o,offset) + #define MTX_AGPGART_UNBIND_MEMORY(o) agp_unbind_memory(o) +#endif + +/* Special macros for linux kernel >= 2.6.10 to < 2.6.12 */ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10) && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12)) #define MTX_AGPGART_BACKEND_ACQUIRE(o) agp_backend_acquire() + #define MTX_AGPGART_ALLOCATE_MEMORY(o,count,type) agp_allocate_memory(count,type) + #define MTX_AGPGART_COPY_INFO(o,p) agp_copy_info(p) #define MTX_AGPGART_BACKEND_ENABLE(o,mode) agp_enable(mode) #define MTX_AGPGART_BACKEND_RELEASE(o) agp_backend_release() - #define MTX_AGPGART_COPY_INFO(o,p) agp_copy_info(p) - #define MTX_AGPGART_ALLOCATE_MEMORY(o,count,type) agp_allocate_memory(count,type) #define MTX_AGPGART_FREE_MEMORY(o,p) agp_free_memory(p) #define MTX_AGPGART_BIND_MEMORY(o,p,offset) agp_bind_memory(p,offset) #define MTX_AGPGART_UNBIND_MEMORY(o,p) agp_unbind_memory(p) +#endif -#else +/* For kernels < 2.6.10 (including all 2.4 kernels) */ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10)) #define AGPBACKEND - + #define MTX_AGPGART_BACKEND_ACQUIRE(o) (o)->acquire() #define MTX_AGPGART_BACKEND_ENABLE(o,mode) (o)->enable(mode) #define MTX_AGPGART_BACKEND_RELEASE(o) (o) ->release() diff -Nur matroxdriver-1.4.1/kernel/src/mtx_mem.c matroxdriver-1.4.2/kernel/src/mtx_mem.c --- matroxdriver-1.4.1/kernel/src/mtx_mem.c 2005-03-22 17:04:41.000000000 +0100 +++ matroxdriver-1.4.2/kernel/src/mtx_mem.c 2005-06-23 11:51:37.199681184 +0200 @@ -7,6 +7,7 @@ References: None. Author: Karl Lessard +2.6.x Updates: Alexander Griesser Copyright (c) 2001, Matrox Graphics Inc. All Rights Reserved. @@ -27,6 +28,11 @@ extern drm_agp_t *agp_backend; #endif +/* Support multiple agp bridges in newer kernels */ +#ifdef AGPGART_HAS_BRIDGES + extern struct agp_bridge_data *bridge; +#endif + /* list of agp memory blocks (first item use as sentinel) */ static AGP_Memory agp_blocks = { 0, NULL, NULL, 0, 0, NULL, 0, 0, 0, 0, 0 }; @@ -192,7 +198,11 @@ return 0; /* Alloc AGP memory block */ +#ifdef AGPGART_HAS_BRIDGES + info_block = MTX_AGPGART_ALLOCATE_MEMORY(bridge, pg_count, AGP_NORMAL_MEMORY); +#else info_block = MTX_AGPGART_ALLOCATE_MEMORY(agp_backend, pg_count, AGP_NORMAL_MEMORY); +#endif if (!info_block) { MTX_ERROR("Failed to allocate AGP memory block\n"); @@ -234,8 +244,12 @@ } /* Bind memory block to GATT */ +#ifdef AGPGART_HAS_BRIDGES + ret = MTX_AGPGART_BIND_MEMORY(info_block, pg_offset); +#else ret = MTX_AGPGART_BIND_MEMORY(agp_backend, info_block, pg_offset); - +#endif + if (ret < 0) { MTX_ERROR("Failed to bind physical memory to AGP memory block\n"); return 0; @@ -313,7 +327,11 @@ } /* Unbind memory from AGP driver */ +#ifdef AGPGART_HAS_BRIDGES + ret = MTX_AGPGART_UNBIND_MEMORY(ptr_block); +#else ret = MTX_AGPGART_UNBIND_MEMORY(agp_backend, ptr_block); +#endif if (ret < 0) { MTX_ERROR("Failed to unbind memory block (returned %d)\n", ret); @@ -321,8 +339,12 @@ } /* Free memory block */ +#ifdef AGPGART_HAS_BRIDGES + MTX_AGPGART_FREE_MEMORY(ptr_block); +#else MTX_AGPGART_FREE_MEMORY(agp_backend, ptr_block); - +#endif + #if MEMORY_STATS --alloc_agp_count; alloc_agp_mem -= size; diff -Nur matroxdriver-1.4.1/kernel/src/mtx_vm.c matroxdriver-1.4.2/kernel/src/mtx_vm.c --- matroxdriver-1.4.1/kernel/src/mtx_vm.c 2005-03-22 17:04:41.000000000 +0100 +++ matroxdriver-1.4.2/kernel/src/mtx_vm.c 2005-04-28 08:30:31.896350350 +0200 @@ -160,7 +160,7 @@ spin_lock(&init_mm.page_table_lock); pgd = pgd_offset_k(kaddr); if (pgd_none(*pgd)) return NULL; - pmd = pmd_offset(pgd, kaddr); if (pmd_none(*pmd)) return NULL; + pmd = pmd_offset( (pud_t*) pgd, kaddr); if (pmd_none(*pmd)) return NULL; #ifdef pte_offset_map pte = pte_offset_map(pmd, kaddr); if (!pte_present(*pte)) return NULL; page = pte_page(*pte); if (!page) return NOPAGE_SIGBUS;