annotate drivers/tdfx_vid.c @ 25285:b2f710272c75

Do not PostQuitMessage when destroying a child window.
author zuxy
date Thu, 06 Dec 2007 02:52:59 +0000
parents 3932d831fd02
children a506a6ab14e1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9545
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
1
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
2 #include <linux/config.h>
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
3 #include <linux/version.h>
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
4 #include <linux/module.h>
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
5 #include <linux/types.h>
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
6 #include <linux/kernel.h>
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
7 #include <linux/sched.h>
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
8 #include <linux/mm.h>
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
9 #include <linux/string.h>
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
10 #include <linux/errno.h>
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
11
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
12 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,10)
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
13 #include <linux/malloc.h>
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
14 #else
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
15 #include <linux/slab.h>
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
16 #endif
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
17
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
18 #include <linux/pci.h>
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
19 #include <linux/ioport.h>
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
20 #include <linux/init.h>
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
21 #include <linux/agp_backend.h>
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
22
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
23 #include <asm/uaccess.h>
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
24 #include <asm/system.h>
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
25 #include <asm/io.h>
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
26
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
27 #include "tdfx_vid.h"
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
28 #include "3dfx.h"
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
29
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
30
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
31 #define TDFX_VID_MAJOR 178
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
32
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
33 MODULE_AUTHOR("Albeu");
9566
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
34 MODULE_DESCRIPTION("A driver for Banshee targeted for video app");
9545
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
35
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
36 #ifdef MODULE_LICENSE
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
37 MODULE_LICENSE("GPL");
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
38 #endif
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
39
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
40 #ifndef min
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
41 #define min(x,y) (((x)<(y))?(x):(y))
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
42 #endif
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
43
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
44 static struct pci_dev *pci_dev;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
45
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
46 static uint8_t *tdfx_mmio_base = 0;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
47 static uint32_t tdfx_mem_base = 0;
9558
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
48 static uint32_t tdfx_io_base = 0;
9545
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
49
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
50 static int tdfx_ram_size = 0;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
51
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
52 static int tdfx_vid_in_use = 0;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
53
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
54 static drm_agp_t *drm_agp = NULL;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
55 static agp_kern_info agp_info;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
56 static agp_memory *agp_mem = NULL;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
57
9558
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
58 static __initdata int tdfx_map_io = 1;
9566
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
59 static __initdata unsigned long map_start = 0; //0x7300000;
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
60 static __initdata unsigned long map_max = (10*1024*1024);
9545
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
61
9558
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
62 MODULE_PARM(tdfx_map_io,"i");
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
63 MODULE_PARM_DESC(tdfx_map_io, "Set to 0 to use the page fault handler (you need to patch agpgart_be.c to allow the mapping in user space)\n");
9566
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
64 MODULE_PARM(map_start,"l");
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
65 MODULE_PARM_DESC(map_start,"Use a block of physical mem instead of the agp arerture.");
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
66 MODULE_PARM(map_max,"l");
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
67 MODULE_PARM_DESC(map_max, "Maximum amout of physical memory (in bytes) that can be used\n");
9545
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
68
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
69 static inline u32 tdfx_inl(unsigned int reg) {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
70 return readl(tdfx_mmio_base + reg);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
71 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
72
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
73 static inline void tdfx_outl(unsigned int reg, u32 val) {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
74 writel(val,tdfx_mmio_base + reg);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
75 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
76
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
77 static inline void banshee_make_room(int size) {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
78 while((tdfx_inl(STATUS) & 0x1f) < size);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
79 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
80
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
81 static inline void banshee_wait_idle(void) {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
82 int i = 0;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
83
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
84 banshee_make_room(1);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
85 tdfx_outl(COMMAND_3D, COMMAND_3D_NOP);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
86
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
87 while(1) {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
88 i = (tdfx_inl(STATUS) & STATUS_BUSY) ? 0 : i + 1;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
89 if(i == 3) break;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
90 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
91 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
92
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
93 static unsigned long get_lfb_size(void) {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
94 u32 draminit0 = 0;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
95 u32 draminit1 = 0;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
96 // u32 miscinit1 = 0;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
97 u32 lfbsize = 0;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
98 int sgram_p = 0;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
99
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
100 draminit0 = tdfx_inl(DRAMINIT0);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
101 draminit1 = tdfx_inl(DRAMINIT1);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
102
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
103 if ((pci_dev->device == PCI_DEVICE_ID_3DFX_BANSHEE) ||
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
104 (pci_dev->device == PCI_DEVICE_ID_3DFX_VOODOO3)) {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
105 sgram_p = (draminit1 & DRAMINIT1_MEM_SDRAM) ? 0 : 1;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
106
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
107 lfbsize = sgram_p ?
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
108 (((draminit0 & DRAMINIT0_SGRAM_NUM) ? 2 : 1) *
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
109 ((draminit0 & DRAMINIT0_SGRAM_TYPE) ? 8 : 4) * 1024 * 1024) :
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
110 16 * 1024 * 1024;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
111 } else {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
112 /* Voodoo4/5 */
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
113 u32 chips, psize, banks;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
114
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
115 chips = ((draminit0 & (1 << 26)) == 0) ? 4 : 8;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
116 psize = 1 << ((draminit0 & 0x38000000) >> 28);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
117 banks = ((draminit0 & (1 << 30)) == 0) ? 2 : 4;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
118 lfbsize = chips * psize * banks;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
119 lfbsize <<= 20;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
120 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
121
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
122 #if 0
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
123 /* disable block writes for SDRAM (why?) */
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
124 miscinit1 = tdfx_inl(MISCINIT1);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
125 miscinit1 |= sgram_p ? 0 : MISCINIT1_2DBLOCK_DIS;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
126 miscinit1 |= MISCINIT1_CLUT_INV;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
127
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
128 banshee_make_room(1);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
129 tdfx_outl(MISCINIT1, miscinit1);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
130 #endif
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
131
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
132 return lfbsize;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
133 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
134
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
135 static int tdfx_vid_find_card(void)
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
136 {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
137 struct pci_dev *dev = NULL;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
138 // unsigned int card_option;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
139
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
140 if((dev = pci_find_device(PCI_VENDOR_ID_3DFX, PCI_DEVICE_ID_3DFX_BANSHEE, NULL)))
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
141 printk(KERN_INFO "tdfx_vid: Found VOODOO BANSHEE\n");
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
142 else if((dev = pci_find_device(PCI_VENDOR_ID_3DFX, PCI_DEVICE_ID_3DFX_VOODOO3, NULL)))
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
143 printk(KERN_INFO "tdfx_vid: Found VOODOO 3 \n");
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
144 else
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
145 return 0;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
146
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
147
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
148 pci_dev = dev;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
149
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
150 #if LINUX_VERSION_CODE >= 0x020300
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
151 tdfx_mmio_base = ioremap_nocache(dev->resource[0].start,1 << 24);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
152 tdfx_mem_base = dev->resource[1].start;
9558
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
153 tdfx_io_base = dev->resource[2].start;
9545
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
154 #else
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
155 tdfx_mmio_base = ioremap_nocache(dev->base_address[1] & PCI_BASE_ADDRESS_MEM_MASK,0x4000);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
156 tdfx_mem_base = dev->base_address[1] & PCI_BASE_ADDRESS_MEM_MASK;
9558
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
157 tdfx_io_base = dev->base_address[2] & PCI_BASE_ADDRESS_MEM_MASK;
9545
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
158 #endif
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
159 printk(KERN_INFO "tdfx_vid: MMIO at 0x%p\n", tdfx_mmio_base);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
160 tdfx_ram_size = get_lfb_size();
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
161
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
162 printk(KERN_INFO "tdfx_vid: Found %d MB (%d bytes) of memory\n",
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
163 tdfx_ram_size / 1024 / 1024,tdfx_ram_size);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
164
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
165
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
166 #if 0
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
167 {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
168 int temp;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
169 printk("List resources -----------\n");
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
170 for(temp=0;temp<DEVICE_COUNT_RESOURCE;temp++){
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
171 struct resource *res=&pci_dev->resource[temp];
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
172 if(res->flags){
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
173 int size=(1+res->end-res->start)>>20;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
174 printk(KERN_DEBUG "res %d: start: 0x%X end: 0x%X (%d MB) flags=0x%X\n",temp,res->start,res->end,size,res->flags);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
175 if(res->flags&(IORESOURCE_MEM|IORESOURCE_PREFETCH)){
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
176 if(size>tdfx_ram_size && size<=64) tdfx_ram_size=size;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
177 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
178 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
179 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
180 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
181 #endif
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
182
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
183
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
184 return 1;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
185 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
186
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
187 static int agp_init(void) {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
188
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
189 drm_agp = (drm_agp_t*)inter_module_get("drm_agp");
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
190
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
191 if(!drm_agp) {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
192 printk(KERN_ERR "tdfx_vid: Unable to get drm_agp pointer\n");
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
193 return 0;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
194 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
195
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
196 if(drm_agp->acquire()) {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
197 printk(KERN_ERR "tdfx_vid: Unable to acquire the agp backend\n");
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
198 drm_agp = NULL;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
199 return 0;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
200 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
201
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
202 drm_agp->copy_info(&agp_info);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
203 #if 0
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
204 printk(KERN_DEBUG "AGP Version : %d %d\n"
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
205 "AGP Mode: %#X\nAperture Base: %p\nAperture Size: %d\n"
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
206 "Max memory = %d\nCurrent mem = %d\nCan use perture : %s\n"
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
207 "Page mask = %#X\n",
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
208 agp_info.version.major,agp_info.version.minor,
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
209 agp_info.mode,agp_info.aper_base,agp_info.aper_size,
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
210 agp_info.max_memory,agp_info.current_memory,
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
211 agp_info.cant_use_aperture ? "no" : "yes",
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
212 agp_info.page_mask);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
213 #endif
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
214 drm_agp->enable(agp_info.mode);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
215
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
216
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
217 printk(KERN_INFO "AGP Enabled\n");
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
218
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
219 return 1;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
220 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
221
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
222 static void agp_close(void) {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
223
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
224 if(!drm_agp) return;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
225
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
226 if(agp_mem) {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
227 drm_agp->unbind_memory(agp_mem);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
228 drm_agp->free_memory(agp_mem);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
229 agp_mem = NULL;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
230 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
231
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
232
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
233 drm_agp->release();
9566
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
234 inter_module_put("drm_agp");
9545
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
235 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
236
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
237 static int agp_move(tdfx_vid_agp_move_t* m) {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
238 u32 src = 0;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
239 u32 src_h,src_l;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
240
9566
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
241 if(!(agp_mem||map_start))
9545
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
242 return (-EAGAIN);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
243
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
244 if(m->move2 > 3) {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
245 printk(KERN_DEBUG "tdfx_vid: AGP move invalid destination %d\n",
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
246 m->move2);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
247 return (-EAGAIN);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
248 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
249
9566
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
250 if(map_start)
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
251 src = map_start + m->src;
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
252 else
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
253 src = agp_info.aper_base + m->src;
9545
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
254
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
255 src_l = (u32)src;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
256 src_h = (m->width | (m->src_stride << 14)) & 0x0FFFFFFF;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
257
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
258 // banshee_wait_idle();
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
259 banshee_make_room(6);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
260 tdfx_outl(AGPHOSTADDRESSHIGH,src_h);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
261 tdfx_outl(AGPHOSTADDRESSLOW,src_l);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
262
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
263 tdfx_outl(AGPGRAPHICSADDRESS, m->dst);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
264 tdfx_outl(AGPGRAPHICSSTRIDE, m->dst_stride);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
265 tdfx_outl(AGPREQSIZE,m->src_stride*m->height);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
266
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
267 tdfx_outl(AGPMOVECMD,m->move2 << 3);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
268 banshee_wait_idle();
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
269
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
270 return 0;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
271 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
272
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
273 static void setup_fifo(u32 offset,ssize_t pages) {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
274 long addr = agp_info.aper_base + offset;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
275 u32 size = pages | 0x700; // fifo on, in agp mem, disable hole cnt
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
276
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
277 banshee_wait_idle();
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
278
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
279 tdfx_outl(CMDBASEADDR0,addr >> 4);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
280 tdfx_outl(CMDRDPTRL0, addr << 4);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
281 tdfx_outl(CMDRDPTRH0, addr >> 28);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
282 tdfx_outl(CMDAMIN0, (addr - 4) & 0xFFFFFF);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
283 tdfx_outl(CMDAMAX0, (addr - 4) & 0xFFFFFF);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
284 tdfx_outl(CMDFIFODEPTH0, 0);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
285 tdfx_outl(CMDHOLECNT0, 0);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
286 tdfx_outl(CMDBASESIZE0,size);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
287
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
288 banshee_wait_idle();
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
289
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
290 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
291
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
292 static int bump_fifo(u16 size) {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
293
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
294 banshee_wait_idle();
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
295 tdfx_outl(CMDBUMP0 , size);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
296 banshee_wait_idle();
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
297
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
298 return 0;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
299 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
300
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
301 static void tdfx_vid_get_config(tdfx_vid_config_t* cfg) {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
302 u32 in;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
303
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
304 cfg->version = TDFX_VID_VERSION;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
305 cfg->ram_size = tdfx_ram_size;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
306
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
307 in = tdfx_inl(VIDSCREENSIZE);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
308 cfg->screen_width = in & 0xFFF;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
309 cfg->screen_height = (in >> 12) & 0xFFF;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
310 in = (tdfx_inl(VIDPROCCFG)>> 18)& 0x7;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
311 switch(in) {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
312 case 0:
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
313 cfg->screen_format = TDFX_VID_FORMAT_BGR8;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
314 break;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
315 case 1:
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
316 cfg->screen_format = TDFX_VID_FORMAT_BGR16;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
317 break;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
318 case 2:
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
319 cfg->screen_format = TDFX_VID_FORMAT_BGR24;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
320 break;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
321 case 3:
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
322 cfg->screen_format = TDFX_VID_FORMAT_BGR32;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
323 break;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
324 default:
10397
6180d7558f75 output typo fixes: unknow --> unknown
diego
parents: 10339
diff changeset
325 printk(KERN_INFO "tdfx_vid: unknown screen format %d\n",in);
9545
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
326 cfg->screen_format = 0;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
327 break;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
328 }
9566
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
329 cfg->screen_stride = tdfx_inl(VIDDESKSTRIDE) & 0x7FFF;
9545
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
330 cfg->screen_start = tdfx_inl(VIDDESKSTART);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
331 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
332
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
333 inline static u32 tdfx_vid_make_format(int src,u16 stride,u32 fmt) {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
334 u32 r = stride & 0xFFF3;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
335 u32 tdfx_fmt = 0;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
336
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
337 // src and dest formats
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
338 switch(fmt) {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
339 case TDFX_VID_FORMAT_BGR8:
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
340 tdfx_fmt = 1;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
341 break;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
342 case TDFX_VID_FORMAT_BGR16:
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
343 tdfx_fmt = 3;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
344 break;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
345 case TDFX_VID_FORMAT_BGR24:
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
346 tdfx_fmt = 4;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
347 break;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
348 case TDFX_VID_FORMAT_BGR32:
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
349 tdfx_fmt = 5;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
350 break;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
351 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
352
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
353 if(!src && !tdfx_fmt) {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
354 printk(KERN_INFO "tdfx_vid: Invalid destination format %#X\n",fmt);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
355 return 0;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
356 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
357
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
358 if(src && !tdfx_fmt) {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
359 // src only format
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
360 switch(fmt){
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
361 case TDFX_VID_FORMAT_BGR1:
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
362 tdfx_fmt = 0;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
363 break;
9558
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
364 case TDFX_VID_FORMAT_BGR15: // To check
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
365 tdfx_fmt = 2;
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
366 break;
9545
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
367 case TDFX_VID_FORMAT_YUY2:
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
368 tdfx_fmt = 8;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
369 break;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
370 case TDFX_VID_FORMAT_UYVY:
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
371 tdfx_fmt = 9;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
372 break;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
373 default:
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
374 printk(KERN_INFO "tdfx_vid: Invalid source format %#X\n",fmt);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
375 return 0;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
376 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
377 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
378
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
379 r |= tdfx_fmt << 16;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
380
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
381 return r;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
382 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
383
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
384 static int tdfx_vid_blit(tdfx_vid_blit_t* blit) {
9566
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
385 u32 src_fmt,dst_fmt,cmd = 2;
9545
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
386 u32 cmin,cmax,srcbase,srcxy,srcfmt,srcsize;
9566
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
387 u32 dstbase,dstxy,dstfmt,dstsize = 0;
9558
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
388 u32 cmd_extra = 0,src_ck[2],dst_ck[2],rop123=0;
9545
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
389
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
390 //printk(KERN_INFO "tdfx_vid: Make src fmt 0x%x\n",blit->src_format);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
391 src_fmt = tdfx_vid_make_format(1,blit->src_stride,blit->src_format);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
392 if(!src_fmt)
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
393 return 0;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
394 //printk(KERN_INFO "tdfx_vid: Make dst fmt 0x%x\n", blit->dst_format);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
395 dst_fmt = tdfx_vid_make_format(0,blit->dst_stride,blit->dst_format);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
396 if(!dst_fmt)
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
397 return 0;
9558
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
398 blit->colorkey &= 0x3;
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
399 // Be nice if user just want a simple blit
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
400 if((!blit->colorkey) && (!blit->rop[0]))
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
401 blit->rop[0] = TDFX_VID_ROP_COPY;
9566
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
402 // No stretch : fix me the cmd should be 1 but it
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
403 // doesn't work. Maybe some other regs need to be set
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
404 // as non-stretch blit have more options
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
405 if(((!blit->dst_w) && (!blit->dst_h)) ||
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
406 ((blit->dst_w == blit->src_w) && (blit->dst_h == blit->src_h)))
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
407 cmd = 2;
9558
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
408
9545
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
409 // Save the regs otherwise fb get crazy
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
410 // we can perhaps avoid some ...
9558
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
411 banshee_wait_idle();
9545
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
412 cmin = tdfx_inl(CLIP0MIN);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
413 cmax = tdfx_inl(CLIP0MAX);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
414 srcbase = tdfx_inl(SRCBASE);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
415 srcxy = tdfx_inl(SRCXY);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
416 srcfmt = tdfx_inl(SRCFORMAT);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
417 srcsize = tdfx_inl(SRCSIZE);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
418 dstbase = tdfx_inl(DSTBASE);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
419 dstxy = tdfx_inl(DSTXY);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
420 dstfmt = tdfx_inl(DSTFORMAT);
9566
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
421 if(cmd == 2)
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
422 dstsize = tdfx_inl(DSTSIZE);
9558
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
423 if(blit->colorkey & TDFX_VID_SRC_COLORKEY) {
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
424 src_ck[0] = tdfx_inl(SRCCOLORKEYMIN);
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
425 src_ck[1] = tdfx_inl(SRCCOLORKEYMAX);
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
426 tdfx_outl(SRCCOLORKEYMIN,blit->src_colorkey[0]);
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
427 tdfx_outl(SRCCOLORKEYMAX,blit->src_colorkey[1]);
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
428 }
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
429 if(blit->colorkey & TDFX_VID_DST_COLORKEY) {
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
430 dst_ck[0] = tdfx_inl(DSTCOLORKEYMIN);
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
431 dst_ck[1] = tdfx_inl(DSTCOLORKEYMAX);
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
432 tdfx_outl(SRCCOLORKEYMIN,blit->dst_colorkey[0]);
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
433 tdfx_outl(SRCCOLORKEYMAX,blit->dst_colorkey[1]);
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
434 }
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
435 if(blit->colorkey) {
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
436 cmd_extra = tdfx_inl(COMMANDEXTRA_2D);
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
437 rop123 = tdfx_inl(ROP123);
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
438 tdfx_outl(COMMANDEXTRA_2D, blit->colorkey);
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
439 tdfx_outl(ROP123,(blit->rop[1] | (blit->rop[2] << 8) | blit->rop[3] << 16));
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
440
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
441 }
9545
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
442 // Get rid of the clipping at the moment
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
443 tdfx_outl(CLIP0MIN,0);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
444 tdfx_outl(CLIP0MAX,0x0fff0fff);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
445
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
446 // Setup the src
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
447 tdfx_outl(SRCBASE,blit->src & 0x00FFFFFF);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
448 tdfx_outl(SRCXY,XYREG(blit->src_x,blit->src_y));
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
449 tdfx_outl(SRCFORMAT,src_fmt);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
450 tdfx_outl(SRCSIZE,XYREG(blit->src_w,blit->src_h));
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
451
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
452 // Setup the dst
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
453 tdfx_outl(DSTBASE,blit->dst & 0x00FFFFFF);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
454 tdfx_outl(DSTXY,XYREG(blit->dst_x,blit->dst_y));
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
455 tdfx_outl(DSTFORMAT,dst_fmt);
9566
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
456 if(cmd == 2)
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
457 tdfx_outl(DSTSIZE,XYREG(blit->dst_w,blit->dst_h));
9545
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
458
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
459 // Send the command
9566
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
460 tdfx_outl(COMMAND_2D,cmd | 0x100 | (blit->rop[0] << 24));
9545
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
461 banshee_wait_idle();
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
462
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
463 // Now restore the regs to make fb happy
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
464 tdfx_outl(CLIP0MIN, cmin);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
465 tdfx_outl(CLIP0MAX, cmax);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
466 tdfx_outl(SRCBASE, srcbase);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
467 tdfx_outl(SRCXY, srcxy);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
468 tdfx_outl(SRCFORMAT, srcfmt);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
469 tdfx_outl(SRCSIZE, srcsize);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
470 tdfx_outl(DSTBASE, dstbase);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
471 tdfx_outl(DSTXY, dstxy);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
472 tdfx_outl(DSTFORMAT, dstfmt);
9566
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
473 if(cmd == 2)
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
474 tdfx_outl(DSTSIZE, dstsize);
9558
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
475 if(blit->colorkey & TDFX_VID_SRC_COLORKEY) {
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
476 tdfx_outl(SRCCOLORKEYMIN,src_ck[0]);
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
477 tdfx_outl(SRCCOLORKEYMAX,src_ck[1]);
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
478 }
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
479 if(blit->colorkey & TDFX_VID_DST_COLORKEY) {
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
480 tdfx_outl(SRCCOLORKEYMIN,dst_ck[0]);
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
481 tdfx_outl(SRCCOLORKEYMAX,dst_ck[1]);
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
482 }
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
483 if(blit->colorkey) {
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
484 tdfx_outl(COMMANDEXTRA_2D,cmd_extra);
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
485 tdfx_outl(ROP123,rop123);
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
486 }
9545
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
487 return 1;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
488 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
489
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
490 static int tdfx_vid_set_yuv(unsigned long arg) {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
491 tdfx_vid_yuv_t yuv;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
492
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
493 if(copy_from_user(&yuv,(tdfx_vid_yuv_t*)arg,sizeof(tdfx_vid_yuv_t))) {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
494 printk(KERN_DEBUG "tdfx_vid:failed copy from userspace\n");
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
495 return(-EFAULT);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
496 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
497 banshee_make_room(2);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
498 tdfx_outl(YUVBASEADDRESS,yuv.base & 0x01FFFFFF);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
499 tdfx_outl(YUVSTRIDE, yuv.stride & 0x3FFF);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
500
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
501 banshee_wait_idle();
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
502
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
503 return 0;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
504 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
505
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
506 static int tdfx_vid_get_yuv(unsigned long arg) {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
507 tdfx_vid_yuv_t yuv;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
508
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
509 yuv.base = tdfx_inl(YUVBASEADDRESS) & 0x01FFFFFF;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
510 yuv.stride = tdfx_inl(YUVSTRIDE) & 0x3FFF;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
511
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
512 if(copy_to_user((tdfx_vid_yuv_t*)arg,&yuv,sizeof(tdfx_vid_yuv_t))) {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
513 printk(KERN_INFO "tdfx_vid:failed copy to userspace\n");
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
514 return(-EFAULT);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
515 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
516
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
517 return 0;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
518 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
519
9566
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
520 static int tdfx_vid_set_overlay(unsigned long arg) {
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
521 tdfx_vid_overlay_t ov;
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
522 uint32_t screen_w,screen_h;
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
523 uint32_t vidcfg,stride,vidbuf;
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
524 int disp_w,disp_h;
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
525
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
526 if(copy_from_user(&ov,(tdfx_vid_overlay_t*)arg,sizeof(tdfx_vid_overlay_t))) {
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
527 printk(KERN_DEBUG "tdfx_vid:failed copy from userspace\n");
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
528 return(-EFAULT);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
529 }
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
530
10339
7074d8b6f585 Allow negative x,y for the overlay.
albeu
parents: 9706
diff changeset
531 if(ov.dst_y < 0) {
7074d8b6f585 Allow negative x,y for the overlay.
albeu
parents: 9706
diff changeset
532 int shift;
7074d8b6f585 Allow negative x,y for the overlay.
albeu
parents: 9706
diff changeset
533 if(-ov.dst_y >= ov.src_height) {
7074d8b6f585 Allow negative x,y for the overlay.
albeu
parents: 9706
diff changeset
534 printk(KERN_DEBUG "tdfx_vid: Overlay outside of the screen ????\n");
7074d8b6f585 Allow negative x,y for the overlay.
albeu
parents: 9706
diff changeset
535 return(-EFAULT);
7074d8b6f585 Allow negative x,y for the overlay.
albeu
parents: 9706
diff changeset
536 }
7074d8b6f585 Allow negative x,y for the overlay.
albeu
parents: 9706
diff changeset
537 shift = (-ov.dst_y)/(double)ov.dst_height*ov.src_height;
7074d8b6f585 Allow negative x,y for the overlay.
albeu
parents: 9706
diff changeset
538 ov.src[0] += shift*ov.src_stride;
7074d8b6f585 Allow negative x,y for the overlay.
albeu
parents: 9706
diff changeset
539 ov.src_height -= shift;
7074d8b6f585 Allow negative x,y for the overlay.
albeu
parents: 9706
diff changeset
540 ov.dst_height += ov.dst_y;
7074d8b6f585 Allow negative x,y for the overlay.
albeu
parents: 9706
diff changeset
541 ov.dst_y = 0;
7074d8b6f585 Allow negative x,y for the overlay.
albeu
parents: 9706
diff changeset
542 }
7074d8b6f585 Allow negative x,y for the overlay.
albeu
parents: 9706
diff changeset
543
7074d8b6f585 Allow negative x,y for the overlay.
albeu
parents: 9706
diff changeset
544 if(ov.dst_x < 0) {
7074d8b6f585 Allow negative x,y for the overlay.
albeu
parents: 9706
diff changeset
545 int shift;
7074d8b6f585 Allow negative x,y for the overlay.
albeu
parents: 9706
diff changeset
546 if(-ov.dst_x >= ov.src_width) {
7074d8b6f585 Allow negative x,y for the overlay.
albeu
parents: 9706
diff changeset
547 printk(KERN_DEBUG "tdfx_vid: Overlay outside of the screen ????\n");
7074d8b6f585 Allow negative x,y for the overlay.
albeu
parents: 9706
diff changeset
548 return(-EFAULT);
7074d8b6f585 Allow negative x,y for the overlay.
albeu
parents: 9706
diff changeset
549 }
7074d8b6f585 Allow negative x,y for the overlay.
albeu
parents: 9706
diff changeset
550 shift = (-ov.dst_x)/(double)ov.dst_width*ov.src_width;
7074d8b6f585 Allow negative x,y for the overlay.
albeu
parents: 9706
diff changeset
551 shift = ((shift+3)/2)*2;
7074d8b6f585 Allow negative x,y for the overlay.
albeu
parents: 9706
diff changeset
552 ov.src[0] += shift*2;
7074d8b6f585 Allow negative x,y for the overlay.
albeu
parents: 9706
diff changeset
553 ov.src_width -= shift;
7074d8b6f585 Allow negative x,y for the overlay.
albeu
parents: 9706
diff changeset
554 ov.dst_width += ov.dst_x;
7074d8b6f585 Allow negative x,y for the overlay.
albeu
parents: 9706
diff changeset
555 ov.dst_x = 0;
9566
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
556 }
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
557
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
558 vidcfg = tdfx_inl(VIDPROCCFG);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
559 // clear the overlay fmt
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
560 vidcfg &= ~(7 << 21);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
561 switch(ov.format) {
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
562 case TDFX_VID_FORMAT_BGR15:
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
563 vidcfg |= (1 << 21);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
564 break;
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
565 case TDFX_VID_FORMAT_BGR16:
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
566 vidcfg |= (7 << 21);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
567 break;
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
568 case TDFX_VID_FORMAT_YUY2:
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
569 vidcfg |= (5 << 21);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
570 break;
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
571 case TDFX_VID_FORMAT_UYVY:
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
572 vidcfg |= (6 << 21);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
573 break;
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
574 default:
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
575 printk(KERN_DEBUG "tdfx_vid: Invalid overlay fmt 0x%x\n",ov.format);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
576 return (-EFAULT);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
577 }
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
578
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
579 // YUV422 need 4 bytes aligned stride and address
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
580 if((ov.format == TDFX_VID_FORMAT_YUY2 ||
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
581 ov.format == TDFX_VID_FORMAT_UYVY)) {
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
582 if((ov.src_stride & ~0x3) != ov.src_stride) {
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
583 printk(KERN_DEBUG "tdfx_vid: YUV need a 4 bytes aligned stride %d\n",ov.src_stride);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
584 return(-EFAULT);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
585 }
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
586 if((ov.src[0] & ~0x3) != ov.src[0] || (ov.src[1] & ~0x3) != ov.src[1]){
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
587 printk(KERN_DEBUG "tdfx_vid: YUV need a 4 bytes aligned address 0x%x 0x%x\n",ov.src[0],ov.src[1]);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
588 return(-EFAULT);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
589 }
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
590 }
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
591
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
592 // Now we have a good input format
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
593 // but first get the screen size to check a bit
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
594 // if the size/position is valid
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
595 screen_w = tdfx_inl(VIDSCREENSIZE);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
596 screen_h = (screen_w >> 12) & 0xFFF;
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
597 screen_w &= 0xFFF;
10339
7074d8b6f585 Allow negative x,y for the overlay.
albeu
parents: 9706
diff changeset
598 disp_w = ov.dst_x + ov.dst_width >= screen_w ?
9566
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
599 screen_w - ov.dst_x : ov.dst_width;
10339
7074d8b6f585 Allow negative x,y for the overlay.
albeu
parents: 9706
diff changeset
600 disp_h = ov.dst_y + ov.dst_height >= screen_h ?
9566
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
601 screen_h - ov.dst_y : ov.dst_height;
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
602
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
603 if(ov.dst_x >= screen_w || ov.dst_y >= screen_h ||
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
604 disp_h <= 0 || disp_h > screen_h || disp_w <= 0 || disp_w > screen_w) {
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
605 printk(KERN_DEBUG "tdfx_vid: Invalid overlay dimension and/or position\n");
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
606 return (-EFAULT);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
607 }
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
608 // Setup the vidproc
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
609 // H scaling
9706
8ae20fe919c9 The overlay can't downscale
albeu
parents: 9568
diff changeset
610 if(ov.src_width < ov.dst_width)
9566
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
611 vidcfg |= (1<<14);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
612 else
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
613 vidcfg &= ~(1<<14);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
614 // V scaling
9706
8ae20fe919c9 The overlay can't downscale
albeu
parents: 9568
diff changeset
615 if(ov.src_height < ov.dst_height)
9566
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
616 vidcfg |= (1<<15);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
617 else
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
618 vidcfg &= ~(1<<15);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
619 // Filtering can only be used in 1x mode
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
620 if(!(vidcfg | (1<<26)))
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
621 vidcfg |= (3<<16);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
622 else
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
623 vidcfg &= ~(3<<16);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
624 // disable overlay stereo mode
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
625 vidcfg &= ~(1<<2);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
626 // Colorkey on/off
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
627 if(ov.use_colorkey) {
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
628 // Colorkey inversion
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
629 if(ov.invert_colorkey)
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
630 vidcfg |= (1<<6);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
631 else
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
632 vidcfg &= ~(1<<6);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
633 vidcfg |= (1<<5);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
634 } else
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
635 vidcfg &= ~(1<<5);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
636 // Overlay isn't VidIn
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
637 vidcfg &= ~(1<<9);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
638 // vidcfg |= (1<<8);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
639 tdfx_outl(VIDPROCCFG,vidcfg);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
640
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
641 // Start coord
9568
ed8827c95386 Shut up some debug messages
albeu
parents: 9566
diff changeset
642 //printk(KERN_DEBUG "tdfx_vid: start %dx%d\n",ov.dst_x & 0xFFF,ov.dst_y & 0xFFF);
9566
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
643 tdfx_outl(VIDOVRSTARTCRD,(ov.dst_x & 0xFFF)|((ov.dst_y & 0xFFF)<<12));
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
644 // End coord
10339
7074d8b6f585 Allow negative x,y for the overlay.
albeu
parents: 9706
diff changeset
645 tdfx_outl(VIDOVRENDCRD, ((ov.dst_x + disp_w-1) & 0xFFF)|
7074d8b6f585 Allow negative x,y for the overlay.
albeu
parents: 9706
diff changeset
646 (((ov.dst_y + disp_h-1) & 0xFFF)<<12));
9566
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
647 // H Scaling
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
648 tdfx_outl(VIDOVRDUDX,( ((u32)ov.src_width) << 20) / ov.dst_width);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
649 // Src offset and width (in bytes)
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
650 tdfx_outl(VIDOVRDUDXOFF,((ov.src_width<<1) & 0xFFF) << 19);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
651 // V Scaling
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
652 tdfx_outl(VIDOVRDVDY, ( ((u32)ov.src_height) << 20) / ov.dst_height);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
653 //else
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
654 // tdfx_outl(VIDOVRDVDY,0);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
655 // V Offset
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
656 tdfx_outl(VIDOVRDVDYOFF,0);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
657 // Overlay stride
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
658 stride = tdfx_inl(VIDDESKSTRIDE) & 0xFFFF;
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
659 tdfx_outl(VIDDESKSTRIDE,stride | (((u32)ov.src_stride) << 16));
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
660 // Buffers address
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
661 tdfx_outl(LEFTOVBUF, ov.src[0]);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
662 tdfx_outl(RIGHTOVBUF, ov.src[1]);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
663
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
664 // Send a swap buffer cmd if we are not on one of the 2 buffers
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
665 vidbuf = tdfx_inl(VIDCUROVRSTART);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
666 if(vidbuf != ov.src[0] && vidbuf != ov.src[1]) {
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
667 tdfx_outl(SWAPPENDING,0);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
668 tdfx_outl(SWAPBUFCMD, 1);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
669 }
9568
ed8827c95386 Shut up some debug messages
albeu
parents: 9566
diff changeset
670 //printk(KERN_DEBUG "tdfx_vid: Buf0=0x%x Buf1=0x%x Current=0x%x\n",
ed8827c95386 Shut up some debug messages
albeu
parents: 9566
diff changeset
671 // ov.src[0],ov.src[1],tdfx_inl(VIDCUROVRSTART));
9566
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
672 // Colorkey
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
673 if(ov.use_colorkey) {
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
674 tdfx_outl(VIDCHRMIN,ov.colorkey[0]);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
675 tdfx_outl(VIDCHRMAX,ov.colorkey[1]);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
676 }
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
677
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
678 return 0;
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
679 }
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
680
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
681 static int tdfx_vid_overlay_on(void) {
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
682 uint32_t vidcfg = tdfx_inl(VIDPROCCFG);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
683 //return 0;
23873
49a433e2e78f cosmetics: misc typo fixes
diego
parents: 10397
diff changeset
684 if(vidcfg & (1<<8)) { // Overlay is already on
49a433e2e78f cosmetics: misc typo fixes
diego
parents: 10397
diff changeset
685 //printk(KERN_DEBUG "tdfx_vid: Overlay is already on.\n");
9566
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
686 return (-EFAULT);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
687 }
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
688 vidcfg |= (1<<8);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
689 tdfx_outl(VIDPROCCFG,vidcfg);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
690 return 0;
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
691 }
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
692
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
693 static int tdfx_vid_overlay_off(void) {
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
694 uint32_t vidcfg = tdfx_inl(VIDPROCCFG);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
695
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
696 if(vidcfg & (1<<8)) {
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
697 vidcfg &= ~(1<<8);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
698 tdfx_outl(VIDPROCCFG,vidcfg);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
699 return 0;
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
700 }
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
701
23873
49a433e2e78f cosmetics: misc typo fixes
diego
parents: 10397
diff changeset
702 printk(KERN_DEBUG "tdfx_vid: Overlay is already off.\n");
9566
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
703 return (-EFAULT);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
704 }
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
705
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
706
9545
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
707 static int tdfx_vid_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
708 {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
709 tdfx_vid_agp_move_t move;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
710 tdfx_vid_config_t cfg;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
711 tdfx_vid_blit_t blit;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
712 u16 int16;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
713
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
714 switch(cmd) {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
715 case TDFX_VID_AGP_MOVE:
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
716 if(copy_from_user(&move,(tdfx_vid_agp_move_t*)arg,sizeof(tdfx_vid_agp_move_t))) {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
717 printk(KERN_INFO "tdfx_vid:failed copy from userspace\n");
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
718 return(-EFAULT);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
719 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
720 return agp_move(&move);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
721 case TDFX_VID_BUMP0:
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
722 if(copy_from_user(&int16,(u16*)arg,sizeof(u16))) {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
723 printk(KERN_INFO "tdfx_vid:failed copy from userspace\n");
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
724 return(-EFAULT);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
725 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
726 return bump_fifo(int16);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
727 case TDFX_VID_BLIT:
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
728 if(copy_from_user(&blit,(tdfx_vid_blit_t*)arg,sizeof(tdfx_vid_blit_t))) {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
729 printk(KERN_INFO "tdfx_vid:failed copy from userspace\n");
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
730 return(-EFAULT);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
731 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
732 if(!tdfx_vid_blit(&blit)) {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
733 printk(KERN_INFO "tdfx_vid: Blit failed\n");
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
734 return(-EFAULT);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
735 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
736 return 0;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
737 case TDFX_VID_GET_CONFIG:
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
738 if(copy_from_user(&cfg,(tdfx_vid_config_t*)arg,sizeof(tdfx_vid_config_t))) {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
739 printk(KERN_INFO "tdfx_vid:failed copy from userspace\n");
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
740 return(-EFAULT);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
741 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
742 tdfx_vid_get_config(&cfg);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
743 if(copy_to_user((tdfx_vid_config_t*)arg,&cfg,sizeof(tdfx_vid_config_t))) {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
744 printk(KERN_INFO "tdfx_vid:failed copy to userspace\n");
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
745 return(-EFAULT);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
746 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
747 return 0;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
748 case TDFX_VID_SET_YUV:
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
749 return tdfx_vid_set_yuv(arg);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
750 case TDFX_VID_GET_YUV:
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
751 return tdfx_vid_get_yuv(arg);
9566
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
752 case TDFX_VID_SET_OVERLAY:
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
753 return tdfx_vid_set_overlay(arg);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
754 case TDFX_VID_OVERLAY_ON:
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
755 return tdfx_vid_overlay_on();
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
756 case TDFX_VID_OVERLAY_OFF:
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
757 return tdfx_vid_overlay_off();
9545
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
758 default:
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
759 printk(KERN_ERR "tdfx_vid: Invalid ioctl %d\n",cmd);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
760 return (-EINVAL);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
761 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
762 return 0;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
763 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
764
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
765
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
766
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
767 static ssize_t tdfx_vid_read(struct file *file, char *buf, size_t count, loff_t *ppos)
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
768 {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
769 return 0;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
770 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
771
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
772 static ssize_t tdfx_vid_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
773 {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
774
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
775 return 0;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
776 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
777
9558
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
778 static void tdfx_vid_mopen(struct vm_area_struct *vma) {
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
779 int i;
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
780 struct page *page;
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
781 unsigned long phys;
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
782
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
783 printk(KERN_DEBUG "tdfx_vid: mopen\n");
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
784
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
785 for(i = 0 ; i < agp_mem->page_count ; i++) {
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
786 phys = agp_mem->memory[i] & ~(0x00000fff);
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
787 page = virt_to_page(phys_to_virt(phys));
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
788 if(!page) {
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
789 printk(KERN_DEBUG "tdfx_vid: Can't get the page %d\%d\n",i,agp_mem->page_count);
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
790 return;
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
791 }
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
792 get_page(page);
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
793 }
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
794 MOD_INC_USE_COUNT;
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
795 }
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
796
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
797 static void tdfx_vid_mclose(struct vm_area_struct *vma) {
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
798 int i;
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
799 struct page *page;
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
800 unsigned long phys;
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
801
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
802 printk(KERN_DEBUG "tdfx_vid: mclose\n");
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
803
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
804 for(i = 0 ; i < agp_mem->page_count ; i++) {
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
805 phys = agp_mem->memory[i] & ~(0x00000fff);
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
806 page = virt_to_page(phys_to_virt(phys));
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
807 if(!page) {
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
808 printk(KERN_DEBUG "tdfx_vid: Can't get the page %d\%d\n",i,agp_mem->page_count);
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
809 return;
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
810 }
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
811 put_page(page);
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
812 }
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
813
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
814 MOD_DEC_USE_COUNT;
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
815 }
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
816
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
817 static struct page *tdfx_vid_nopage(struct vm_area_struct *vma,
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
818 unsigned long address,
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
819 int write_access) {
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
820 unsigned long off;
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
821 uint32_t n;
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
822 struct page *page;
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
823 unsigned long phys;
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
824
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
825 off = address - vma->vm_start + (vma->vm_pgoff<<PAGE_SHIFT);
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
826 n = off / PAGE_SIZE;
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
827
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
828 if(n >= agp_mem->page_count) {
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
829 printk(KERN_DEBUG "tdfx_vid: Too far away\n");
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
830 return ((struct page *)0UL);
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
831 }
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
832 phys = agp_mem->memory[n] & ~(0x00000fff);
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
833 page = virt_to_page(phys_to_virt(phys));
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
834 if(!page) {
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
835 printk(KERN_DEBUG "tdfx_vid: Can't get the page\n");
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
836 return ((struct page *)0UL);
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
837 }
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
838 return page;
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
839 }
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
840
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
841 /* memory handler functions */
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
842 static struct vm_operations_struct tdfx_vid_vm_ops = {
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
843 open: tdfx_vid_mopen, /* mmap-open */
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
844 close: tdfx_vid_mclose,/* mmap-close */
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
845 nopage: tdfx_vid_nopage, /* no-page fault handler */
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
846 };
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
847
9545
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
848
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
849 static int tdfx_vid_mmap(struct file *file, struct vm_area_struct *vma)
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
850 {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
851 size_t size;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
852 #ifdef MP_DEBUG
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
853 printk(KERN_DEBUG "tdfx_vid: mapping agp memory into userspace\n");
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
854 #endif
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
855
9566
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
856 size = (vma->vm_end-vma->vm_start + PAGE_SIZE - 1) / PAGE_SIZE;
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
857
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
858 if(map_start) { // Ok we map directly in the physcal ram
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
859 if(size*PAGE_SIZE > map_max) {
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
860 printk(KERN_ERR "tdfx_vid: Not enouth mem\n");
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
861 return(-EAGAIN);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
862 }
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
863 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,3)
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
864 if(remap_page_range(vma, vma->vm_start,map_start,
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
865 vma->vm_end - vma->vm_start, vma->vm_page_prot))
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
866 #else
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
867 if(remap_page_range(vma->vm_start, (unsigned long)map_start,
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
868 vma->vm_end - vma->vm_start, vma->vm_page_prot))
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
869 #endif
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
870 {
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
871 printk(KERN_ERR "tdfx_vid: error mapping video memory\n");
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
872 return(-EAGAIN);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
873 }
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
874 printk(KERN_INFO "Physical mem 0x%lx mapped in userspace\n",map_start);
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
875 return 0;
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
876 }
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
877
9545
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
878 if(agp_mem)
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
879 return(-EAGAIN);
9566
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
880
9545
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
881 agp_mem = drm_agp->allocate_memory(size,AGP_NORMAL_MEMORY);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
882 if(!agp_mem) {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
883 printk(KERN_ERR "Failed to allocate AGP memory\n");
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
884 return(-ENOMEM);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
885 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
886
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
887 if(drm_agp->bind_memory(agp_mem,0)) {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
888 printk(KERN_ERR "Failed to bind the AGP memory\n");
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
889 drm_agp->free_memory(agp_mem);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
890 agp_mem = NULL;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
891 return(-ENOMEM);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
892 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
893
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
894 printk(KERN_INFO "%d pages of AGP mem allocated (%ld/%ld bytes) :)))\n",
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
895 size,vma->vm_end-vma->vm_start,size*PAGE_SIZE);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
896
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
897
9558
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
898 if(tdfx_map_io) {
9545
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
899 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,3)
9558
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
900 if(remap_page_range(vma, vma->vm_start,agp_info.aper_base,
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
901 vma->vm_end - vma->vm_start, vma->vm_page_prot))
9545
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
902 #else
9558
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
903 if(remap_page_range(vma->vm_start, (unsigned long)agp_info.aper_base,
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
904 vma->vm_end - vma->vm_start, vma->vm_page_prot))
9545
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
905 #endif
9558
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
906 {
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
907 printk(KERN_ERR "tdfx_vid: error mapping video memory\n");
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
908 return(-EAGAIN);
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
909 }
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
910 } else {
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
911 // Never swap it out
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
912 vma->vm_flags |= VM_LOCKED | VM_IO;
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
913 vma->vm_ops = &tdfx_vid_vm_ops;
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
914 vma->vm_ops->open(vma);
9566
015b404023f5 Overlay support (now vo_xtdfx is possible :) and yet another way to
albeu
parents: 9558
diff changeset
915 printk(KERN_INFO "Page fault handler ready !!!!!\n");
9558
29aa61268e54 Update, new page fault handler to access the agp mem. Doesn't really work
albeu
parents: 9545
diff changeset
916 }
9545
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
917
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
918 return 0;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
919 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
920
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
921
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
922 static int tdfx_vid_release(struct inode *inode, struct file *file)
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
923 {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
924 #ifdef MP_DEBUG
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
925 printk(KERN_DEBUG "tdfx_vid: Video OFF (release)\n");
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
926 #endif
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
927
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
928 // Release the agp mem
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
929 if(agp_mem) {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
930 drm_agp->unbind_memory(agp_mem);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
931 drm_agp->free_memory(agp_mem);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
932 agp_mem = NULL;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
933 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
934
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
935 tdfx_vid_in_use = 0;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
936
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
937 MOD_DEC_USE_COUNT;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
938 return 0;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
939 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
940
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
941 static long long tdfx_vid_lseek(struct file *file, long long offset, int origin)
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
942 {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
943 return -ESPIPE;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
944 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
945
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
946 static int tdfx_vid_open(struct inode *inode, struct file *file)
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
947 {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
948 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,2)
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
949 int minor = MINOR(inode->i_rdev.value);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
950 #else
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
951 int minor = MINOR(inode->i_rdev);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
952 #endif
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
953
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
954 if(minor != 0)
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
955 return(-ENXIO);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
956
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
957 if(tdfx_vid_in_use == 1)
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
958 return(-EBUSY);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
959
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
960 tdfx_vid_in_use = 1;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
961 MOD_INC_USE_COUNT;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
962 return(0);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
963 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
964
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
965 #if LINUX_VERSION_CODE >= 0x020400
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
966 static struct file_operations tdfx_vid_fops =
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
967 {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
968 llseek: tdfx_vid_lseek,
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
969 read: tdfx_vid_read,
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
970 write: tdfx_vid_write,
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
971 ioctl: tdfx_vid_ioctl,
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
972 mmap: tdfx_vid_mmap,
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
973 open: tdfx_vid_open,
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
974 release: tdfx_vid_release
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
975 };
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
976 #else
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
977 static struct file_operations tdfx_vid_fops =
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
978 {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
979 tdfx_vid_lseek,
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
980 tdfx_vid_read,
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
981 tdfx_vid_write,
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
982 NULL,
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
983 NULL,
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
984 tdfx_vid_ioctl,
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
985 tdfx_vid_mmap,
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
986 tdfx_vid_open,
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
987 NULL,
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
988 tdfx_vid_release
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
989 };
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
990 #endif
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
991
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
992
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
993 int init_module(void)
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
994 {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
995 tdfx_vid_in_use = 0;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
996
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
997 if(register_chrdev(TDFX_VID_MAJOR, "tdfx_vid", &tdfx_vid_fops)) {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
998 printk(KERN_ERR "tdfx_vid: unable to get major: %d\n", TDFX_VID_MAJOR);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
999 return -EIO;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
1000 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
1001
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
1002 if(!agp_init()) {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
1003 printk(KERN_ERR "tdfx_vid: AGP init failed\n");
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
1004 unregister_chrdev(TDFX_VID_MAJOR, "tdfx_vid");
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
1005 return -EINVAL;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
1006 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
1007
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
1008 if (!tdfx_vid_find_card()) {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
1009 printk(KERN_ERR "tdfx_vid: no supported devices found\n");
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
1010 agp_close();
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
1011 unregister_chrdev(TDFX_VID_MAJOR, "tdfx_vid");
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
1012 return -EINVAL;
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
1013 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
1014
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
1015
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
1016
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
1017 return (0);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
1018
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
1019 }
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
1020
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
1021 void cleanup_module(void)
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
1022 {
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
1023 if(tdfx_mmio_base)
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
1024 iounmap(tdfx_mmio_base);
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
1025 agp_close();
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
1026 printk(KERN_INFO "tdfx_vid: Cleaning up module\n");
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
1027 unregister_chrdev(TDFX_VID_MAJOR, "tdfx_vid");
d1bbeae9f46a tdfx_vid a new kernel driver for tdfx wich let use agp move :)
albeu
parents:
diff changeset
1028 }