Mercurial > mplayer.hg
annotate drivers/mga_vid.c @ 6662:f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
author | albeu |
---|---|
date | Sun, 07 Jul 2002 03:59:58 +0000 |
parents | df10f81f1bfc |
children | 7935d85facff |
rev | line source |
---|---|
2345 | 1 //#define CRTC2 |
2 | |
1 | 3 // YUY2 support (see config.format) added by A'rpi/ESP-team |
57 | 4 // double buffering added by A'rpi/ESP-team |
5623 | 5 // brightness/contrast introduced by eyck |
57 | 6 |
7 // Set this value, if autodetection fails! (video ram size in megabytes) | |
91 | 8 // #define MGA_MEMORY_SIZE 16 |
1 | 9 |
68 | 10 //#define MGA_ALLOW_IRQ |
11 | |
12 #define MGA_VSYNC_POS 2 | |
13 | |
1 | 14 /* |
15 * | |
16 * mga_vid.c | |
17 * | |
18 * Copyright (C) 1999 Aaron Holtzman | |
19 * | |
20 * Module skeleton based on gutted agpgart module by Jeff Hartmann | |
21 * <slicer@ionet.net> | |
22 * | |
23 * Matrox MGA G200/G400 YUV Video Interface module Version 0.1.0 | |
24 * | |
25 * BES == Back End Scaler | |
26 * | |
27 * This software has been released under the terms of the GNU Public | |
28 * license. See http://www.gnu.org/copyleft/gpl.html for details. | |
29 */ | |
30 | |
31 //It's entirely possible this major conflicts with something else | |
32 /* mknod /dev/mga_vid c 178 0 */ | |
33 | |
34 #include <linux/config.h> | |
35 #include <linux/version.h> | |
36 #include <linux/module.h> | |
37 #include <linux/types.h> | |
38 #include <linux/kernel.h> | |
39 #include <linux/sched.h> | |
40 #include <linux/mm.h> | |
41 #include <linux/string.h> | |
42 #include <linux/errno.h> | |
3125
d62aa0b7fd68
use <linux/slab.h> instead of <linux/malloc.h> for kernels 2.4.9+
szabi
parents:
2345
diff
changeset
|
43 |
d62aa0b7fd68
use <linux/slab.h> instead of <linux/malloc.h> for kernels 2.4.9+
szabi
parents:
2345
diff
changeset
|
44 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,10) |
1 | 45 #include <linux/malloc.h> |
3125
d62aa0b7fd68
use <linux/slab.h> instead of <linux/malloc.h> for kernels 2.4.9+
szabi
parents:
2345
diff
changeset
|
46 #else |
d62aa0b7fd68
use <linux/slab.h> instead of <linux/malloc.h> for kernels 2.4.9+
szabi
parents:
2345
diff
changeset
|
47 #include <linux/slab.h> |
d62aa0b7fd68
use <linux/slab.h> instead of <linux/malloc.h> for kernels 2.4.9+
szabi
parents:
2345
diff
changeset
|
48 #endif |
d62aa0b7fd68
use <linux/slab.h> instead of <linux/malloc.h> for kernels 2.4.9+
szabi
parents:
2345
diff
changeset
|
49 |
1 | 50 #include <linux/pci.h> |
63 | 51 #include <linux/ioport.h> |
1 | 52 #include <linux/init.h> |
53 | |
54 #include "mga_vid.h" | |
55 | |
56 #ifdef CONFIG_MTRR | |
57 #include <asm/mtrr.h> | |
58 #endif | |
59 | |
5653
39115273d236
Mark Schreiber sent link to Marcus Sundburg patch to mga_vid, which enables
eyck
parents:
5623
diff
changeset
|
60 #ifdef CONFIG_DEVFS_FS |
39115273d236
Mark Schreiber sent link to Marcus Sundburg patch to mga_vid, which enables
eyck
parents:
5623
diff
changeset
|
61 #include <linux/devfs_fs_kernel.h> |
39115273d236
Mark Schreiber sent link to Marcus Sundburg patch to mga_vid, which enables
eyck
parents:
5623
diff
changeset
|
62 #endif |
39115273d236
Mark Schreiber sent link to Marcus Sundburg patch to mga_vid, which enables
eyck
parents:
5623
diff
changeset
|
63 |
1 | 64 #include <asm/uaccess.h> |
65 #include <asm/system.h> | |
66 #include <asm/io.h> | |
67 | |
68 #define TRUE 1 | |
69 #define FALSE 0 | |
70 | |
71 #define MGA_VID_MAJOR 178 | |
72 | |
57 | 73 //#define MGA_VIDMEM_SIZE mga_ram_size |
1 | 74 |
75 #ifndef PCI_DEVICE_ID_MATROX_G200_PCI | |
76 #define PCI_DEVICE_ID_MATROX_G200_PCI 0x0520 | |
77 #endif | |
78 | |
79 #ifndef PCI_DEVICE_ID_MATROX_G200_AGP | |
80 #define PCI_DEVICE_ID_MATROX_G200_AGP 0x0521 | |
81 #endif | |
82 | |
83 #ifndef PCI_DEVICE_ID_MATROX_G400 | |
84 #define PCI_DEVICE_ID_MATROX_G400 0x0525 | |
85 #endif | |
86 | |
1989 | 87 #ifndef PCI_DEVICE_ID_MATROX_G550 |
88 #define PCI_DEVICE_ID_MATROX_G550 0x2527 | |
89 #endif | |
90 | |
1 | 91 MODULE_AUTHOR("Aaron Holtzman <aholtzma@engr.uvic.ca>"); |
2262 | 92 #ifdef MODULE_LICENSE |
93 MODULE_LICENSE("GPL"); | |
94 #endif | |
1 | 95 |
4483
fb4b914eab8a
framework for settings modifications like in radeon_vid ( /dev/mga_vid can
eyck
parents:
3959
diff
changeset
|
96 #define PARAM_BRIGHTNESS "brightness=" |
4487
e642ff2d5c6d
Attila's Linux 2.2 patch, and contrast control applied
eyck
parents:
4484
diff
changeset
|
97 #define PARAM_CONTRAST "contrast=" |
4483
fb4b914eab8a
framework for settings modifications like in radeon_vid ( /dev/mga_vid can
eyck
parents:
3959
diff
changeset
|
98 #define PARAM_BLACKIE "blackie=" |
4484 | 99 |
100 #define PARAM_BUFF_SIZE 4096 | |
101 static uint8_t *mga_param_buff = NULL; | |
102 static uint32_t mga_param_buff_size=0; | |
103 static uint32_t mga_param_buff_len=0; | |
104 | |
5764 | 105 #ifndef min |
5013
52c008dd6e93
min() moved out of #if, applied brightness/contrast patch by Brian J. Murrell
arpi
parents:
4728
diff
changeset
|
106 #define min(x,y) (((x)<(y))?(x):(y)) |
5764 | 107 #endif |
5013
52c008dd6e93
min() moved out of #if, applied brightness/contrast patch by Brian J. Murrell
arpi
parents:
4728
diff
changeset
|
108 |
4487
e642ff2d5c6d
Attila's Linux 2.2 patch, and contrast control applied
eyck
parents:
4484
diff
changeset
|
109 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0) |
e642ff2d5c6d
Attila's Linux 2.2 patch, and contrast control applied
eyck
parents:
4484
diff
changeset
|
110 #include <linux/ctype.h> |
e642ff2d5c6d
Attila's Linux 2.2 patch, and contrast control applied
eyck
parents:
4484
diff
changeset
|
111 |
5884 | 112 static unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base) |
4487
e642ff2d5c6d
Attila's Linux 2.2 patch, and contrast control applied
eyck
parents:
4484
diff
changeset
|
113 { |
e642ff2d5c6d
Attila's Linux 2.2 patch, and contrast control applied
eyck
parents:
4484
diff
changeset
|
114 unsigned long result = 0,value; |
e642ff2d5c6d
Attila's Linux 2.2 patch, and contrast control applied
eyck
parents:
4484
diff
changeset
|
115 |
e642ff2d5c6d
Attila's Linux 2.2 patch, and contrast control applied
eyck
parents:
4484
diff
changeset
|
116 if (!base) { |
e642ff2d5c6d
Attila's Linux 2.2 patch, and contrast control applied
eyck
parents:
4484
diff
changeset
|
117 base = 10; |
e642ff2d5c6d
Attila's Linux 2.2 patch, and contrast control applied
eyck
parents:
4484
diff
changeset
|
118 if (*cp == '0') { |
e642ff2d5c6d
Attila's Linux 2.2 patch, and contrast control applied
eyck
parents:
4484
diff
changeset
|
119 base = 8; |
e642ff2d5c6d
Attila's Linux 2.2 patch, and contrast control applied
eyck
parents:
4484
diff
changeset
|
120 cp++; |
e642ff2d5c6d
Attila's Linux 2.2 patch, and contrast control applied
eyck
parents:
4484
diff
changeset
|
121 if ((*cp == 'x') && isxdigit(cp[1])) { |
e642ff2d5c6d
Attila's Linux 2.2 patch, and contrast control applied
eyck
parents:
4484
diff
changeset
|
122 cp++; |
e642ff2d5c6d
Attila's Linux 2.2 patch, and contrast control applied
eyck
parents:
4484
diff
changeset
|
123 base = 16; |
e642ff2d5c6d
Attila's Linux 2.2 patch, and contrast control applied
eyck
parents:
4484
diff
changeset
|
124 } |
e642ff2d5c6d
Attila's Linux 2.2 patch, and contrast control applied
eyck
parents:
4484
diff
changeset
|
125 } |
e642ff2d5c6d
Attila's Linux 2.2 patch, and contrast control applied
eyck
parents:
4484
diff
changeset
|
126 } |
e642ff2d5c6d
Attila's Linux 2.2 patch, and contrast control applied
eyck
parents:
4484
diff
changeset
|
127 while (isxdigit(*cp) && (value = isdigit(*cp) ? *cp-'0' : (islower(*cp) |
e642ff2d5c6d
Attila's Linux 2.2 patch, and contrast control applied
eyck
parents:
4484
diff
changeset
|
128 ? toupper(*cp) : *cp)-'A'+10) < base) { |
e642ff2d5c6d
Attila's Linux 2.2 patch, and contrast control applied
eyck
parents:
4484
diff
changeset
|
129 result = result*base + value; |
e642ff2d5c6d
Attila's Linux 2.2 patch, and contrast control applied
eyck
parents:
4484
diff
changeset
|
130 cp++; |
e642ff2d5c6d
Attila's Linux 2.2 patch, and contrast control applied
eyck
parents:
4484
diff
changeset
|
131 } |
e642ff2d5c6d
Attila's Linux 2.2 patch, and contrast control applied
eyck
parents:
4484
diff
changeset
|
132 if (endp) |
e642ff2d5c6d
Attila's Linux 2.2 patch, and contrast control applied
eyck
parents:
4484
diff
changeset
|
133 *endp = (char *)cp; |
e642ff2d5c6d
Attila's Linux 2.2 patch, and contrast control applied
eyck
parents:
4484
diff
changeset
|
134 return result; |
e642ff2d5c6d
Attila's Linux 2.2 patch, and contrast control applied
eyck
parents:
4484
diff
changeset
|
135 } |
6586
df10f81f1bfc
linux-2.5.x support patch by Sytse Wielinga <s.b.wieling at student.utwente.nl>
alex
parents:
6086
diff
changeset
|
136 #endif |
4487
e642ff2d5c6d
Attila's Linux 2.2 patch, and contrast control applied
eyck
parents:
4484
diff
changeset
|
137 |
6586
df10f81f1bfc
linux-2.5.x support patch by Sytse Wielinga <s.b.wieling at student.utwente.nl>
alex
parents:
6086
diff
changeset
|
138 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0) || LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,5) |
5884 | 139 static long simple_strtol(const char *cp,char **endp,unsigned int base) |
4487
e642ff2d5c6d
Attila's Linux 2.2 patch, and contrast control applied
eyck
parents:
4484
diff
changeset
|
140 { |
e642ff2d5c6d
Attila's Linux 2.2 patch, and contrast control applied
eyck
parents:
4484
diff
changeset
|
141 if(*cp=='-') |
e642ff2d5c6d
Attila's Linux 2.2 patch, and contrast control applied
eyck
parents:
4484
diff
changeset
|
142 return -simple_strtoul(cp+1,endp,base); |
e642ff2d5c6d
Attila's Linux 2.2 patch, and contrast control applied
eyck
parents:
4484
diff
changeset
|
143 return simple_strtoul(cp,endp,base); |
e642ff2d5c6d
Attila's Linux 2.2 patch, and contrast control applied
eyck
parents:
4484
diff
changeset
|
144 } |
e642ff2d5c6d
Attila's Linux 2.2 patch, and contrast control applied
eyck
parents:
4484
diff
changeset
|
145 #endif |
e642ff2d5c6d
Attila's Linux 2.2 patch, and contrast control applied
eyck
parents:
4484
diff
changeset
|
146 |
4483
fb4b914eab8a
framework for settings modifications like in radeon_vid ( /dev/mga_vid can
eyck
parents:
3959
diff
changeset
|
147 |
1 | 148 typedef struct bes_registers_s |
149 { | |
150 //BES Control | |
151 uint32_t besctl; | |
152 //BES Global control | |
153 uint32_t besglobctl; | |
154 //Luma control (brightness and contrast) | |
155 uint32_t beslumactl; | |
156 //Line pitch | |
157 uint32_t bespitch; | |
158 | |
159 //Buffer A-1 Chroma 3 plane org | |
160 uint32_t besa1c3org; | |
161 //Buffer A-1 Chroma org | |
162 uint32_t besa1corg; | |
163 //Buffer A-1 Luma org | |
164 uint32_t besa1org; | |
165 | |
166 //Buffer A-2 Chroma 3 plane org | |
167 uint32_t besa2c3org; | |
168 //Buffer A-2 Chroma org | |
169 uint32_t besa2corg; | |
170 //Buffer A-2 Luma org | |
171 uint32_t besa2org; | |
172 | |
173 //Buffer B-1 Chroma 3 plane org | |
174 uint32_t besb1c3org; | |
175 //Buffer B-1 Chroma org | |
176 uint32_t besb1corg; | |
177 //Buffer B-1 Luma org | |
178 uint32_t besb1org; | |
179 | |
180 //Buffer B-2 Chroma 3 plane org | |
181 uint32_t besb2c3org; | |
182 //Buffer B-2 Chroma org | |
183 uint32_t besb2corg; | |
184 //Buffer B-2 Luma org | |
185 uint32_t besb2org; | |
186 | |
187 //BES Horizontal coord | |
188 uint32_t beshcoord; | |
189 //BES Horizontal inverse scaling [5.14] | |
190 uint32_t beshiscal; | |
191 //BES Horizontal source start [10.14] (for scaling) | |
192 uint32_t beshsrcst; | |
193 //BES Horizontal source ending [10.14] (for scaling) | |
194 uint32_t beshsrcend; | |
195 //BES Horizontal source last | |
196 uint32_t beshsrclst; | |
197 | |
198 | |
199 //BES Vertical coord | |
200 uint32_t besvcoord; | |
201 //BES Vertical inverse scaling [5.14] | |
202 uint32_t besviscal; | |
203 //BES Field 1 vertical source last position | |
204 uint32_t besv1srclst; | |
205 //BES Field 1 weight start | |
206 uint32_t besv1wght; | |
207 //BES Field 2 vertical source last position | |
208 uint32_t besv2srclst; | |
209 //BES Field 2 weight start | |
210 uint32_t besv2wght; | |
211 | |
4483
fb4b914eab8a
framework for settings modifications like in radeon_vid ( /dev/mga_vid can
eyck
parents:
3959
diff
changeset
|
212 |
fb4b914eab8a
framework for settings modifications like in radeon_vid ( /dev/mga_vid can
eyck
parents:
3959
diff
changeset
|
213 //configurable stuff |
fb4b914eab8a
framework for settings modifications like in radeon_vid ( /dev/mga_vid can
eyck
parents:
3959
diff
changeset
|
214 int blackie; |
fb4b914eab8a
framework for settings modifications like in radeon_vid ( /dev/mga_vid can
eyck
parents:
3959
diff
changeset
|
215 |
1 | 216 } bes_registers_t; |
217 | |
218 static bes_registers_t regs; | |
2344 | 219 #ifdef CRTC2 |
220 typedef struct crtc2_registers_s | |
221 { | |
222 uint32_t c2ctl; | |
223 uint32_t c2datactl; | |
224 uint32_t c2misc; | |
225 uint32_t c2hparam; | |
226 uint32_t c2hsync; | |
227 uint32_t c2offset; | |
228 uint32_t c2pl2startadd0; | |
229 uint32_t c2pl2startadd1; | |
230 uint32_t c2pl3startadd0; | |
231 uint32_t c2pl3startadd1; | |
232 uint32_t c2preload; | |
233 uint32_t c2spicstartadd0; | |
234 uint32_t c2spicstartadd1; | |
235 uint32_t c2startadd0; | |
236 uint32_t c2startadd1; | |
237 uint32_t c2subpiclut; | |
238 uint32_t c2vcount; | |
239 uint32_t c2vparam; | |
240 uint32_t c2vsync; | |
241 } crtc2_registers_t; | |
242 static crtc2_registers_t cregs; | |
243 #endif | |
1 | 244 static uint32_t mga_vid_in_use = 0; |
245 static uint32_t is_g400 = 0; | |
246 static uint32_t vid_src_ready = 0; | |
247 static uint32_t vid_overlay_on = 0; | |
248 | |
249 static uint8_t *mga_mmio_base = 0; | |
250 static uint32_t mga_mem_base = 0; | |
251 | |
57 | 252 static int mga_src_base = 0; // YUV buffer position in video memory |
253 | |
254 static uint32_t mga_ram_size = 0; // how much megabytes videoram we have | |
1 | 255 |
4559
5dc383bb1c82
added mga_top_reserved module parameter to skip a configurable amount
rfelker
parents:
4527
diff
changeset
|
256 static uint32_t mga_top_reserved = 0; // reserved space for console font (matroxfb + fastfont) |
5dc383bb1c82
added mga_top_reserved module parameter to skip a configurable amount
rfelker
parents:
4527
diff
changeset
|
257 |
4728
dab19bd91cde
Add module parameters: contrast and brightness, so when you need those permanently
eyck
parents:
4594
diff
changeset
|
258 static int mga_brightness = 0; // initial brightness |
dab19bd91cde
Add module parameters: contrast and brightness, so when you need those permanently
eyck
parents:
4594
diff
changeset
|
259 static int mga_contrast = 0; // initial contrast |
dab19bd91cde
Add module parameters: contrast and brightness, so when you need those permanently
eyck
parents:
4594
diff
changeset
|
260 |
95 | 261 //static int mga_force_memsize = 0; |
90 | 262 |
95 | 263 MODULE_PARM(mga_ram_size, "i"); |
4559
5dc383bb1c82
added mga_top_reserved module parameter to skip a configurable amount
rfelker
parents:
4527
diff
changeset
|
264 MODULE_PARM(mga_top_reserved, "i"); |
4728
dab19bd91cde
Add module parameters: contrast and brightness, so when you need those permanently
eyck
parents:
4594
diff
changeset
|
265 MODULE_PARM(mga_brightness, "i"); |
dab19bd91cde
Add module parameters: contrast and brightness, so when you need those permanently
eyck
parents:
4594
diff
changeset
|
266 MODULE_PARM(mga_contrast, "i"); |
90 | 267 |
1 | 268 static struct pci_dev *pci_dev; |
269 | |
270 static mga_vid_config_t mga_config; | |
271 | |
5653
39115273d236
Mark Schreiber sent link to Marcus Sundburg patch to mga_vid, which enables
eyck
parents:
5623
diff
changeset
|
272 #ifdef CONFIG_DEVFS_FS |
39115273d236
Mark Schreiber sent link to Marcus Sundburg patch to mga_vid, which enables
eyck
parents:
5623
diff
changeset
|
273 static devfs_handle_t dev_handle = NULL; |
39115273d236
Mark Schreiber sent link to Marcus Sundburg patch to mga_vid, which enables
eyck
parents:
5623
diff
changeset
|
274 #endif |
39115273d236
Mark Schreiber sent link to Marcus Sundburg patch to mga_vid, which enables
eyck
parents:
5623
diff
changeset
|
275 |
2086 | 276 static int colkey_saved=0; |
277 static int colkey_on=0; | |
278 static unsigned char colkey_color[4]; | |
279 static unsigned char colkey_mask[4]; | |
280 | |
48 | 281 static int mga_irq = -1; |
1 | 282 |
283 //All register offsets are converted to word aligned offsets (32 bit) | |
284 //because we want all our register accesses to be 32 bits | |
285 #define VCOUNT 0x1e20 | |
286 | |
287 #define PALWTADD 0x3c00 // Index register for X_DATAREG port | |
288 #define X_DATAREG 0x3c0a | |
289 | |
290 #define XMULCTRL 0x19 | |
291 #define BPP_8 0x00 | |
292 #define BPP_15 0x01 | |
293 #define BPP_16 0x02 | |
294 #define BPP_24 0x03 | |
295 #define BPP_32_DIR 0x04 | |
296 #define BPP_32_PAL 0x07 | |
297 | |
298 #define XCOLMSK 0x40 | |
299 #define X_COLKEY 0x42 | |
300 #define XKEYOPMODE 0x51 | |
301 #define XCOLMSK0RED 0x52 | |
302 #define XCOLMSK0GREEN 0x53 | |
303 #define XCOLMSK0BLUE 0x54 | |
304 #define XCOLKEY0RED 0x55 | |
305 #define XCOLKEY0GREEN 0x56 | |
306 #define XCOLKEY0BLUE 0x57 | |
307 | |
2344 | 308 #ifdef CRTC2 |
309 | |
310 /*CRTC2 registers*/ | |
311 #define XMISCCTRL 0x1e | |
312 #define C2CTL 0x3c10 | |
313 #define C2DATACTL 0x3c4c | |
314 #define C2MISC 0x3c44 | |
315 #define C2HPARAM 0x3c14 | |
316 #define C2HSYNC 0x3c18 | |
317 #define C2OFFSET 0x3c40 | |
318 #define C2PL2STARTADD0 0x3c30 // like BESA1CORG | |
319 #define C2PL2STARTADD1 0x3c34 // like BESA2CORG | |
320 #define C2PL3STARTADD0 0x3c38 // like BESA1C3ORG | |
321 #define C2PL3STARTADD1 0x3c3c // like BESA2C3ORG | |
322 #define C2PRELOAD 0x3c24 | |
323 #define C2SPICSTARTADD0 0x3c54 | |
324 #define C2SPICSTARTADD1 0x3c58 | |
325 #define C2STARTADD0 0x3c28 // like BESA1ORG | |
326 #define C2STARTADD1 0x3c2c // like BESA2ORG | |
327 #define C2SUBPICLUT 0x3c50 | |
328 #define C2VCOUNT 0x3c48 | |
329 #define C2VPARAM 0x3c1c | |
330 #define C2VSYNC 0x3c20 | |
331 | |
332 #endif | |
333 | |
1 | 334 // Backend Scaler registers |
335 #define BESCTL 0x3d20 | |
336 #define BESGLOBCTL 0x3dc0 | |
337 #define BESLUMACTL 0x3d40 | |
338 #define BESPITCH 0x3d24 | |
48 | 339 |
1 | 340 #define BESA1C3ORG 0x3d60 |
341 #define BESA1CORG 0x3d10 | |
342 #define BESA1ORG 0x3d00 | |
48 | 343 |
1 | 344 #define BESA2C3ORG 0x3d64 |
345 #define BESA2CORG 0x3d14 | |
346 #define BESA2ORG 0x3d04 | |
48 | 347 |
1 | 348 #define BESB1C3ORG 0x3d68 |
349 #define BESB1CORG 0x3d18 | |
350 #define BESB1ORG 0x3d08 | |
48 | 351 |
1 | 352 #define BESB2C3ORG 0x3d6C |
353 #define BESB2CORG 0x3d1C | |
354 #define BESB2ORG 0x3d0C | |
48 | 355 |
1 | 356 #define BESHCOORD 0x3d28 |
357 #define BESHISCAL 0x3d30 | |
358 #define BESHSRCEND 0x3d3C | |
359 #define BESHSRCLST 0x3d50 | |
360 #define BESHSRCST 0x3d38 | |
361 #define BESV1WGHT 0x3d48 | |
362 #define BESV2WGHT 0x3d4c | |
363 #define BESV1SRCLST 0x3d54 | |
364 #define BESV2SRCLST 0x3d58 | |
365 #define BESVISCAL 0x3d34 | |
366 #define BESVCOORD 0x3d2c | |
367 #define BESSTATUS 0x3dc4 | |
368 | |
48 | 369 #define CRTCX 0x1fd4 |
370 #define CRTCD 0x1fd5 | |
371 #define IEN 0x1e1c | |
372 #define ICLEAR 0x1e18 | |
373 #define STATUS 0x1e14 | |
374 | |
375 static int mga_next_frame=0; | |
1 | 376 |
2344 | 377 #ifdef CRTC2 |
378 static void crtc2_frame_sel(int frame) | |
379 { | |
380 switch(frame) { | |
381 case 0: | |
382 cregs.c2pl2startadd0=regs.besa1corg; | |
383 cregs.c2pl3startadd0=regs.besa1c3org; | |
384 cregs.c2startadd0=regs.besa1org; | |
385 break; | |
386 case 1: | |
387 cregs.c2pl2startadd0=regs.besa2corg; | |
388 cregs.c2pl3startadd0=regs.besa2c3org; | |
389 cregs.c2startadd0=regs.besa2org; | |
390 break; | |
391 case 2: | |
392 cregs.c2pl2startadd0=regs.besb1corg; | |
393 cregs.c2pl3startadd0=regs.besb1c3org; | |
394 cregs.c2startadd0=regs.besb1org; | |
395 break; | |
396 case 3: | |
397 cregs.c2pl2startadd0=regs.besb2corg; | |
398 cregs.c2pl3startadd0=regs.besb2c3org; | |
399 cregs.c2startadd0=regs.besb2org; | |
400 break; | |
401 } | |
402 writel(cregs.c2startadd0, mga_mmio_base + C2STARTADD0); | |
403 writel(cregs.c2pl2startadd0, mga_mmio_base + C2PL2STARTADD0); | |
404 writel(cregs.c2pl3startadd0, mga_mmio_base + C2PL3STARTADD0); | |
405 } | |
406 #endif | |
407 | |
1 | 408 static void mga_vid_frame_sel(int frame) |
409 { | |
48 | 410 if ( mga_irq != -1 ) { |
411 mga_next_frame=frame; | |
412 } else { | |
413 | |
1 | 414 //we don't need the vcount protection as we're only hitting |
415 //one register (and it doesn't seem to be double buffered) | |
416 regs.besctl = (regs.besctl & ~0x07000000) + (frame << 25); | |
417 writel( regs.besctl, mga_mmio_base + BESCTL ); | |
68 | 418 |
419 // writel( regs.besglobctl + ((readl(mga_mmio_base + VCOUNT)+2)<<16), | |
420 writel( regs.besglobctl + (MGA_VSYNC_POS<<16), | |
421 mga_mmio_base + BESGLOBCTL); | |
2344 | 422 #ifdef CRTC2 |
423 crtc2_frame_sel(frame); | |
424 #endif | |
68 | 425 |
48 | 426 } |
1 | 427 } |
428 | |
429 | |
2086 | 430 static void mga_vid_write_regs(int restore) |
1 | 431 { |
432 //Make sure internal registers don't get updated until we're done | |
433 writel( (readl(mga_mmio_base + VCOUNT)-1)<<16, | |
434 mga_mmio_base + BESGLOBCTL); | |
435 | |
436 // color or coordinate keying | |
2086 | 437 |
438 if(restore && colkey_saved){ | |
439 // restore it | |
440 colkey_saved=0; | |
441 | |
5623 | 442 #ifdef MP_DEBUG |
2086 | 443 printk("mga_vid: Restoring colorkey (ON: %d %02X:%02X:%02X)\n", |
444 colkey_on,colkey_color[0],colkey_color[1],colkey_color[2]); | |
5623 | 445 #endif |
2086 | 446 |
447 // Set color key registers: | |
448 writeb( XKEYOPMODE, mga_mmio_base + PALWTADD); | |
449 writeb( colkey_on, mga_mmio_base + X_DATAREG); | |
450 | |
451 writeb( XCOLKEY0RED, mga_mmio_base + PALWTADD); | |
452 writeb( colkey_color[0], mga_mmio_base + X_DATAREG); | |
453 writeb( XCOLKEY0GREEN, mga_mmio_base + PALWTADD); | |
454 writeb( colkey_color[1], mga_mmio_base + X_DATAREG); | |
455 writeb( XCOLKEY0BLUE, mga_mmio_base + PALWTADD); | |
456 writeb( colkey_color[2], mga_mmio_base + X_DATAREG); | |
457 writeb( X_COLKEY, mga_mmio_base + PALWTADD); | |
458 writeb( colkey_color[3], mga_mmio_base + X_DATAREG); | |
459 | |
460 writeb( XCOLMSK0RED, mga_mmio_base + PALWTADD); | |
461 writeb( colkey_mask[0], mga_mmio_base + X_DATAREG); | |
462 writeb( XCOLMSK0GREEN, mga_mmio_base + PALWTADD); | |
463 writeb( colkey_mask[1], mga_mmio_base + X_DATAREG); | |
464 writeb( XCOLMSK0BLUE, mga_mmio_base + PALWTADD); | |
465 writeb( colkey_mask[2], mga_mmio_base + X_DATAREG); | |
466 writeb( XCOLMSK, mga_mmio_base + PALWTADD); | |
467 writeb( colkey_mask[3], mga_mmio_base + X_DATAREG); | |
468 | |
469 } else if(!colkey_saved){ | |
470 // save it | |
471 colkey_saved=1; | |
472 // Get color key registers: | |
473 writeb( XKEYOPMODE, mga_mmio_base + PALWTADD); | |
474 colkey_on=(unsigned char)readb(mga_mmio_base + X_DATAREG) & 1; | |
475 | |
476 writeb( XCOLKEY0RED, mga_mmio_base + PALWTADD); | |
477 colkey_color[0]=(unsigned char)readb(mga_mmio_base + X_DATAREG); | |
478 writeb( XCOLKEY0GREEN, mga_mmio_base + PALWTADD); | |
479 colkey_color[1]=(unsigned char)readb(mga_mmio_base + X_DATAREG); | |
480 writeb( XCOLKEY0BLUE, mga_mmio_base + PALWTADD); | |
481 colkey_color[2]=(unsigned char)readb(mga_mmio_base + X_DATAREG); | |
482 writeb( X_COLKEY, mga_mmio_base + PALWTADD); | |
483 colkey_color[3]=(unsigned char)readb(mga_mmio_base + X_DATAREG); | |
484 | |
485 writeb( XCOLMSK0RED, mga_mmio_base + PALWTADD); | |
486 colkey_mask[0]=(unsigned char)readb(mga_mmio_base + X_DATAREG); | |
487 writeb( XCOLMSK0GREEN, mga_mmio_base + PALWTADD); | |
488 colkey_mask[1]=(unsigned char)readb(mga_mmio_base + X_DATAREG); | |
489 writeb( XCOLMSK0BLUE, mga_mmio_base + PALWTADD); | |
490 colkey_mask[2]=(unsigned char)readb(mga_mmio_base + X_DATAREG); | |
491 writeb( XCOLMSK, mga_mmio_base + PALWTADD); | |
492 colkey_mask[3]=(unsigned char)readb(mga_mmio_base + X_DATAREG); | |
493 | |
5623 | 494 #ifdef MP_DEBUG |
2086 | 495 printk("mga_vid: Saved colorkey (ON: %d %02X:%02X:%02X)\n", |
496 colkey_on,colkey_color[0],colkey_color[1],colkey_color[2]); | |
5623 | 497 #endif |
2086 | 498 |
499 } | |
500 | |
501 if(!restore){ | |
1 | 502 writeb( XKEYOPMODE, mga_mmio_base + PALWTADD); |
503 writeb( mga_config.colkey_on, mga_mmio_base + X_DATAREG); | |
504 if ( mga_config.colkey_on ) | |
505 { | |
506 uint32_t r=0, g=0, b=0; | |
507 | |
508 writeb( XMULCTRL, mga_mmio_base + PALWTADD); | |
509 switch (readb (mga_mmio_base + X_DATAREG)) | |
510 { | |
511 case BPP_8: | |
512 /* Need to look up the color index, just using | |
513 color 0 for now. */ | |
514 break; | |
515 | |
516 case BPP_15: | |
517 r = mga_config.colkey_red >> 3; | |
518 g = mga_config.colkey_green >> 3; | |
519 b = mga_config.colkey_blue >> 3; | |
520 break; | |
521 | |
522 case BPP_16: | |
523 r = mga_config.colkey_red >> 3; | |
524 g = mga_config.colkey_green >> 2; | |
525 b = mga_config.colkey_blue >> 3; | |
526 break; | |
527 | |
528 case BPP_24: | |
529 case BPP_32_DIR: | |
530 case BPP_32_PAL: | |
531 r = mga_config.colkey_red; | |
532 g = mga_config.colkey_green; | |
533 b = mga_config.colkey_blue; | |
534 break; | |
535 } | |
536 | |
537 // Disable color keying on alpha channel | |
538 writeb( XCOLMSK, mga_mmio_base + PALWTADD); | |
539 writeb( 0x00, mga_mmio_base + X_DATAREG); | |
540 writeb( X_COLKEY, mga_mmio_base + PALWTADD); | |
541 writeb( 0x00, mga_mmio_base + X_DATAREG); | |
542 | |
2086 | 543 |
1 | 544 // Set up color key registers |
545 writeb( XCOLKEY0RED, mga_mmio_base + PALWTADD); | |
546 writeb( r, mga_mmio_base + X_DATAREG); | |
547 writeb( XCOLKEY0GREEN, mga_mmio_base + PALWTADD); | |
548 writeb( g, mga_mmio_base + X_DATAREG); | |
549 writeb( XCOLKEY0BLUE, mga_mmio_base + PALWTADD); | |
550 writeb( b, mga_mmio_base + X_DATAREG); | |
551 | |
552 // Set up color key mask registers | |
553 writeb( XCOLMSK0RED, mga_mmio_base + PALWTADD); | |
554 writeb( 0xff, mga_mmio_base + X_DATAREG); | |
555 writeb( XCOLMSK0GREEN, mga_mmio_base + PALWTADD); | |
556 writeb( 0xff, mga_mmio_base + X_DATAREG); | |
557 writeb( XCOLMSK0BLUE, mga_mmio_base + PALWTADD); | |
558 writeb( 0xff, mga_mmio_base + X_DATAREG); | |
559 } | |
560 | |
2086 | 561 } |
562 | |
1 | 563 // Backend Scaler |
564 writel( regs.besctl, mga_mmio_base + BESCTL); | |
565 if(is_g400) | |
566 writel( regs.beslumactl, mga_mmio_base + BESLUMACTL); | |
567 writel( regs.bespitch, mga_mmio_base + BESPITCH); | |
568 | |
569 writel( regs.besa1org, mga_mmio_base + BESA1ORG); | |
570 writel( regs.besa1corg, mga_mmio_base + BESA1CORG); | |
48 | 571 writel( regs.besa2org, mga_mmio_base + BESA2ORG); |
572 writel( regs.besa2corg, mga_mmio_base + BESA2CORG); | |
1 | 573 writel( regs.besb1org, mga_mmio_base + BESB1ORG); |
574 writel( regs.besb1corg, mga_mmio_base + BESB1CORG); | |
48 | 575 writel( regs.besb2org, mga_mmio_base + BESB2ORG); |
576 writel( regs.besb2corg, mga_mmio_base + BESB2CORG); | |
1 | 577 if(is_g400) |
578 { | |
579 writel( regs.besa1c3org, mga_mmio_base + BESA1C3ORG); | |
48 | 580 writel( regs.besa2c3org, mga_mmio_base + BESA2C3ORG); |
1 | 581 writel( regs.besb1c3org, mga_mmio_base + BESB1C3ORG); |
48 | 582 writel( regs.besb2c3org, mga_mmio_base + BESB2C3ORG); |
1 | 583 } |
584 | |
585 writel( regs.beshcoord, mga_mmio_base + BESHCOORD); | |
586 writel( regs.beshiscal, mga_mmio_base + BESHISCAL); | |
587 writel( regs.beshsrcst, mga_mmio_base + BESHSRCST); | |
588 writel( regs.beshsrcend, mga_mmio_base + BESHSRCEND); | |
589 writel( regs.beshsrclst, mga_mmio_base + BESHSRCLST); | |
590 | |
591 writel( regs.besvcoord, mga_mmio_base + BESVCOORD); | |
592 writel( regs.besviscal, mga_mmio_base + BESVISCAL); | |
48 | 593 |
1 | 594 writel( regs.besv1srclst, mga_mmio_base + BESV1SRCLST); |
595 writel( regs.besv1wght, mga_mmio_base + BESV1WGHT); | |
48 | 596 writel( regs.besv2srclst, mga_mmio_base + BESV2SRCLST); |
597 writel( regs.besv2wght, mga_mmio_base + BESV2WGHT); | |
1 | 598 |
599 //update the registers somewhere between 1 and 2 frames from now. | |
600 writel( regs.besglobctl + ((readl(mga_mmio_base + VCOUNT)+2)<<16), | |
601 mga_mmio_base + BESGLOBCTL); | |
602 | |
77 | 603 #if 0 |
61 | 604 printk(KERN_DEBUG "mga_vid: wrote BES registers\n"); |
605 printk(KERN_DEBUG "mga_vid: BESCTL = 0x%08x\n", | |
1 | 606 readl(mga_mmio_base + BESCTL)); |
61 | 607 printk(KERN_DEBUG "mga_vid: BESGLOBCTL = 0x%08x\n", |
1 | 608 readl(mga_mmio_base + BESGLOBCTL)); |
61 | 609 printk(KERN_DEBUG "mga_vid: BESSTATUS= 0x%08x\n", |
1 | 610 readl(mga_mmio_base + BESSTATUS)); |
77 | 611 #endif |
2344 | 612 #ifdef CRTC2 |
613 // printk("c2ctl:0x%08x c2datactl:0x%08x\n",readl(mga_mmio_base + C2CTL),readl(mga_mmio_base + C2DATACTL)); | |
614 // printk("c2misc:0x%08x\n",readl(mga_mmio_base + C2MISC)); | |
615 // printk("c2ctl:0x%08x c2datactl:0x%08x\n",cregs.c2ctl,cregs.c2datactl); | |
616 | |
617 // writel(cregs.c2ctl, mga_mmio_base + C2CTL); | |
618 | |
619 writel(((readl(mga_mmio_base + C2CTL) & ~0x03e00000) + (cregs.c2ctl & 0x03e00000)), mga_mmio_base + C2CTL); | |
620 writel(((readl(mga_mmio_base + C2DATACTL) & ~0x000000ff) + (cregs.c2datactl & 0x000000ff)), mga_mmio_base + C2DATACTL); | |
621 // ctrc2 | |
622 // disable CRTC2 acording to specs | |
623 // writel(cregs.c2ctl & 0xfffffff0, mga_mmio_base + C2CTL); | |
624 // je to treba ??? | |
625 // writeb((readb(mga_mmio_base + XMISCCTRL) & 0x19) | 0xa2, mga_mmio_base + XMISCCTRL); // MAFC - mfcsel & vdoutsel | |
626 // writeb((readb(mga_mmio_base + XMISCCTRL) & 0x19) | 0x92, mga_mmio_base + XMISCCTRL); | |
627 // writeb((readb(mga_mmio_base + XMISCCTRL) & ~0xe9) + 0xa2, mga_mmio_base + XMISCCTRL); | |
628 // writel(cregs.c2datactl, mga_mmio_base + C2DATACTL); | |
629 // writel(cregs.c2hparam, mga_mmio_base + C2HPARAM); | |
630 // writel(cregs.c2hsync, mga_mmio_base + C2HSYNC); | |
631 // writel(cregs.c2vparam, mga_mmio_base + C2VPARAM); | |
632 // writel(cregs.c2vsync, mga_mmio_base + C2VSYNC); | |
633 writel(cregs.c2misc, mga_mmio_base + C2MISC); | |
634 | |
5623 | 635 #ifdef MP_DEBUG |
2344 | 636 printk("c2offset = %d\n",cregs.c2offset); |
5623 | 637 #endif |
2344 | 638 |
639 writel(cregs.c2offset, mga_mmio_base + C2OFFSET); | |
640 writel(cregs.c2startadd0, mga_mmio_base + C2STARTADD0); | |
641 // writel(cregs.c2startadd1, mga_mmio_base + C2STARTADD1); | |
642 writel(cregs.c2pl2startadd0, mga_mmio_base + C2PL2STARTADD0); | |
643 // writel(cregs.c2pl2startadd1, mga_mmio_base + C2PL2STARTADD1); | |
644 writel(cregs.c2pl3startadd0, mga_mmio_base + C2PL3STARTADD0); | |
645 // writel(cregs.c2pl3startadd1, mga_mmio_base + C2PL3STARTADD1); | |
646 writel(cregs.c2spicstartadd0, mga_mmio_base + C2SPICSTARTADD0); | |
647 // writel(cregs.c2spicstartadd1, mga_mmio_base + C2SPICSTARTADD1); | |
648 // writel(cregs.c2subpiclut, mga_mmio_base + C2SUBPICLUT); | |
649 // writel(cregs.c2preload, mga_mmio_base + C2PRELOAD); | |
650 // finaly enable everything | |
651 // writel(cregs.c2ctl, mga_mmio_base + C2CTL); | |
652 // printk("c2ctl:0x%08x c2datactl:0x%08x\n",readl(mga_mmio_base + C2CTL),readl(mga_mmio_base + C2DATACTL)); | |
653 // printk("c2misc:0x%08x\n", readl(mga_mmio_base + C2MISC)); | |
654 #endif | |
1 | 655 } |
656 | |
657 static int mga_vid_set_config(mga_vid_config_t *config) | |
658 { | |
659 int x, y, sw, sh, dw, dh; | |
660 int besleft, bestop, ifactor, ofsleft, ofstop, baseadrofs, weight, weights; | |
57 | 661 int frame_size=config->frame_size; |
2344 | 662 #ifdef CRTC2 |
663 #define right_margin 0 | |
664 #define left_margin 18 | |
665 #define hsync_len 46 | |
666 #define lower_margin 10 | |
667 #define vsync_len 4 | |
668 #define upper_margin 39 | |
669 | |
670 unsigned int hdispend = (config->src_width + 31) & ~31; | |
671 unsigned int hsyncstart = hdispend + (right_margin & ~7); | |
672 unsigned int hsyncend = hsyncstart + (hsync_len & ~7); | |
673 unsigned int htotal = hsyncend + (left_margin & ~7); | |
674 unsigned int vdispend = config->src_height; | |
675 unsigned int vsyncstart = vdispend + lower_margin; | |
676 unsigned int vsyncend = vsyncstart + vsync_len; | |
677 unsigned int vtotal = vsyncend + upper_margin; | |
678 #endif | |
1 | 679 x = config->x_org; |
680 y = config->y_org; | |
681 sw = config->src_width; | |
682 sh = config->src_height; | |
683 dw = config->dest_width; | |
684 dh = config->dest_height; | |
685 | |
5623 | 686 #ifdef MP_DEBUG |
61 | 687 printk(KERN_DEBUG "mga_vid: Setting up a %dx%d+%d+%d video window (src %dx%d) format %X\n", |
1 | 688 dw, dh, x, y, sw, sh, config->format); |
5623 | 689 #endif |
1 | 690 |
3959 | 691 if(sw<4 || sh<4 || dw<4 || dh<4){ |
692 printk(KERN_ERR "mga_vid: Invalid src/dest dimenstions\n"); | |
693 return -1; | |
694 } | |
695 | |
1 | 696 //FIXME check that window is valid and inside desktop |
697 | |
698 //FIXME figure out a better way to allocate memory on card | |
699 //allocate 2 megs | |
700 //mga_src_base = mga_mem_base + (MGA_VIDMEM_SIZE-2) * 0x100000; | |
57 | 701 //mga_src_base = (MGA_VIDMEM_SIZE-3) * 0x100000; |
1 | 702 |
703 | |
704 //Setup the BES registers for a three plane 4:2:0 video source | |
705 | |
466 | 706 regs.besglobctl = 0; |
707 | |
1 | 708 switch(config->format){ |
709 case MGA_VID_FORMAT_YV12: | |
470 | 710 case MGA_VID_FORMAT_I420: |
711 case MGA_VID_FORMAT_IYUV: | |
1 | 712 regs.besctl = 1 // BES enabled |
713 + (0<<6) // even start polarity | |
714 + (1<<10) // x filtering enabled | |
715 + (1<<11) // y filtering enabled | |
716 + (1<<16) // chroma upsampling | |
717 + (1<<17) // 4:2:0 mode | |
718 + (1<<18); // dither enabled | |
466 | 719 #if 0 |
1 | 720 if(is_g400) |
721 { | |
722 //zoom disabled, zoom filter disabled, 420 3 plane format, proc amp | |
723 //disabled, rgb mode disabled | |
724 regs.besglobctl = (1<<5); | |
725 } | |
726 else | |
727 { | |
728 //zoom disabled, zoom filter disabled, Cb samples in 0246, Cr | |
729 //in 1357, BES register update on besvcnt | |
466 | 730 regs.besglobctl = 0; |
1 | 731 } |
466 | 732 #endif |
1 | 733 break; |
734 | |
735 case MGA_VID_FORMAT_YUY2: | |
736 regs.besctl = 1 // BES enabled | |
737 + (0<<6) // even start polarity | |
738 + (1<<10) // x filtering enabled | |
739 + (1<<11) // y filtering enabled | |
740 + (1<<16) // chroma upsampling | |
741 + (0<<17) // 4:2:2 mode | |
742 + (1<<18); // dither enabled | |
743 | |
744 regs.besglobctl = 0; // YUY2 format selected | |
745 break; | |
466 | 746 |
747 case MGA_VID_FORMAT_UYVY: | |
748 regs.besctl = 1 // BES enabled | |
749 + (0<<6) // even start polarity | |
750 + (1<<10) // x filtering enabled | |
751 + (1<<11) // y filtering enabled | |
752 + (1<<16) // chroma upsampling | |
753 + (0<<17) // 4:2:2 mode | |
754 + (1<<18); // dither enabled | |
755 | |
756 regs.besglobctl = 1<<6; // UYVY format selected | |
757 break; | |
758 | |
1 | 759 default: |
61 | 760 printk(KERN_ERR "mga_vid: Unsupported pixel format: 0x%X\n",config->format); |
1 | 761 return -1; |
762 } | |
763 | |
4483
fb4b914eab8a
framework for settings modifications like in radeon_vid ( /dev/mga_vid can
eyck
parents:
3959
diff
changeset
|
764 // setting black&white mode |
4484 | 765 regs.besctl|=(regs.blackie<<20); |
1 | 766 |
4483
fb4b914eab8a
framework for settings modifications like in radeon_vid ( /dev/mga_vid can
eyck
parents:
3959
diff
changeset
|
767 //Enable contrast and brightness control |
466 | 768 regs.besglobctl |= (1<<5) + (1<<7); |
4483
fb4b914eab8a
framework for settings modifications like in radeon_vid ( /dev/mga_vid can
eyck
parents:
3959
diff
changeset
|
769 |
fb4b914eab8a
framework for settings modifications like in radeon_vid ( /dev/mga_vid can
eyck
parents:
3959
diff
changeset
|
770 // brightness ; default is 0x7f; |
4728
dab19bd91cde
Add module parameters: contrast and brightness, so when you need those permanently
eyck
parents:
4594
diff
changeset
|
771 regs.beslumactl = (mga_brightness << 16); |
4483
fb4b914eab8a
framework for settings modifications like in radeon_vid ( /dev/mga_vid can
eyck
parents:
3959
diff
changeset
|
772 // contrast: |
4728
dab19bd91cde
Add module parameters: contrast and brightness, so when you need those permanently
eyck
parents:
4594
diff
changeset
|
773 regs.beslumactl|= ((mga_contrast+0x80)<<0); |
1 | 774 |
775 //Setup destination window boundaries | |
776 besleft = x > 0 ? x : 0; | |
777 bestop = y > 0 ? y : 0; | |
778 regs.beshcoord = (besleft<<16) + (x + dw-1); | |
779 regs.besvcoord = (bestop<<16) + (y + dh-1); | |
780 | |
781 //Setup source dimensions | |
782 regs.beshsrclst = (sw - 1) << 16; | |
783 regs.bespitch = (sw + 31) & ~31 ; | |
784 | |
785 //Setup horizontal scaling | |
786 ifactor = ((sw-1)<<14)/(dw-1); | |
787 ofsleft = besleft - x; | |
788 | |
789 regs.beshiscal = ifactor<<2; | |
790 regs.beshsrcst = (ofsleft*ifactor)<<2; | |
791 regs.beshsrcend = regs.beshsrcst + (((dw - ofsleft - 1) * ifactor) << 2); | |
792 | |
793 //Setup vertical scaling | |
794 ifactor = ((sh-1)<<14)/(dh-1); | |
795 ofstop = bestop - y; | |
796 | |
797 regs.besviscal = ifactor<<2; | |
798 | |
799 baseadrofs = ((ofstop*regs.besviscal)>>16)*regs.bespitch; | |
57 | 800 //frame_size = ((sw + 31) & ~31) * sh + (((sw + 31) & ~31) * sh) / 2; |
1 | 801 regs.besa1org = (uint32_t) mga_src_base + baseadrofs; |
48 | 802 regs.besa2org = (uint32_t) mga_src_base + baseadrofs + 1*frame_size; |
803 regs.besb1org = (uint32_t) mga_src_base + baseadrofs + 2*frame_size; | |
804 regs.besb2org = (uint32_t) mga_src_base + baseadrofs + 3*frame_size; | |
1 | 805 |
470 | 806 if(config->format==MGA_VID_FORMAT_YV12 |
807 ||config->format==MGA_VID_FORMAT_IYUV | |
808 ||config->format==MGA_VID_FORMAT_I420 | |
809 ){ | |
57 | 810 // planar YUV frames: |
1 | 811 if (is_g400) |
812 baseadrofs = (((ofstop*regs.besviscal)/4)>>16)*regs.bespitch; | |
813 else | |
814 baseadrofs = (((ofstop*regs.besviscal)/2)>>16)*regs.bespitch; | |
815 | |
5336 | 816 if(config->format==MGA_VID_FORMAT_YV12 || !is_g400){ |
1 | 817 regs.besa1corg = (uint32_t) mga_src_base + baseadrofs + regs.bespitch * sh ; |
48 | 818 regs.besa2corg = (uint32_t) mga_src_base + baseadrofs + 1*frame_size + regs.bespitch * sh; |
819 regs.besb1corg = (uint32_t) mga_src_base + baseadrofs + 2*frame_size + regs.bespitch * sh; | |
820 regs.besb2corg = (uint32_t) mga_src_base + baseadrofs + 3*frame_size + regs.bespitch * sh; | |
1 | 821 regs.besa1c3org = regs.besa1corg + ((regs.bespitch * sh) / 4); |
48 | 822 regs.besa2c3org = regs.besa2corg + ((regs.bespitch * sh) / 4); |
1 | 823 regs.besb1c3org = regs.besb1corg + ((regs.bespitch * sh) / 4); |
48 | 824 regs.besb2c3org = regs.besb2corg + ((regs.bespitch * sh) / 4); |
470 | 825 } else { |
826 regs.besa1c3org = (uint32_t) mga_src_base + baseadrofs + regs.bespitch * sh ; | |
827 regs.besa2c3org = (uint32_t) mga_src_base + baseadrofs + 1*frame_size + regs.bespitch * sh; | |
828 regs.besb1c3org = (uint32_t) mga_src_base + baseadrofs + 2*frame_size + regs.bespitch * sh; | |
829 regs.besb2c3org = (uint32_t) mga_src_base + baseadrofs + 3*frame_size + regs.bespitch * sh; | |
830 regs.besa1corg = regs.besa1c3org + ((regs.bespitch * sh) / 4); | |
831 regs.besa2corg = regs.besa2c3org + ((regs.bespitch * sh) / 4); | |
832 regs.besb1corg = regs.besb1c3org + ((regs.bespitch * sh) / 4); | |
833 regs.besb2corg = regs.besb2c3org + ((regs.bespitch * sh) / 4); | |
834 } | |
835 | |
57 | 836 } |
1 | 837 |
838 weight = ofstop * (regs.besviscal >> 2); | |
839 weights = weight < 0 ? 1 : 0; | |
48 | 840 regs.besv2wght = regs.besv1wght = (weights << 16) + ((weight & 0x3FFF) << 2); |
841 regs.besv2srclst = regs.besv1srclst = sh - 1 - (((ofstop * regs.besviscal) >> 16) & 0x03FF); | |
1 | 842 |
2344 | 843 #ifdef CRTC2 |
844 // pridat hlavni registry - tj. casovani ... | |
845 | |
846 | |
847 switch(config->format){ | |
848 case MGA_VID_FORMAT_YV12: | |
849 case MGA_VID_FORMAT_I420: | |
850 case MGA_VID_FORMAT_IYUV: | |
851 cregs.c2ctl = 1 // CRTC2 enabled | |
852 + (1<<1) // external clock | |
853 + (0<<2) // external clock | |
854 + (1<<3) // pixel clock enable - not needed ??? | |
855 + (0<<4) // high prioryty req | |
856 + (1<<5) // high prioryty req | |
857 + (0<<6) // high prioryty req | |
858 + (1<<8) // high prioryty req max | |
859 + (0<<9) // high prioryty req max | |
860 + (0<<10) // high prioryty req max | |
861 + (0<<20) // CRTC1 to DAC | |
862 + (1<<21) // 420 mode | |
863 + (1<<22) // 420 mode | |
864 + (1<<23) // 420 mode | |
865 + (0<<24) // single chroma line for 420 mode - need to be corrected | |
866 + (0<<25) /*/ interlace mode - need to be corrected*/ | |
867 + (0<<26) // field legth polariry | |
868 + (0<<27) // field identification polariry | |
869 + (1<<28) // VIDRST detection mode | |
870 + (0<<29) // VIDRST detection mode | |
871 + (1<<30) // Horizontal counter preload | |
872 + (1<<31) // Vertical counter preload | |
873 ; | |
874 cregs.c2datactl = 1 // disable dither - propably not needed, we are already in YUV mode | |
875 + (1<<1) // Y filter enable | |
876 + (1<<2) // CbCr filter enable | |
877 + (0<<3) // subpicture enable (disabled) | |
878 + (0<<4) // NTSC enable (disabled - PAL) | |
879 + (0<<5) // C2 static subpicture enable (disabled) | |
880 + (0<<6) // C2 subpicture offset division (disabled) | |
881 + (0<<7) // 422 subformat selection ! | |
882 /* + (0<<8) // 15 bpp high alpha | |
883 + (0<<9) // 15 bpp high alpha | |
884 + (0<<10) // 15 bpp high alpha | |
885 + (0<<11) // 15 bpp high alpha | |
886 + (0<<12) // 15 bpp high alpha | |
887 + (0<<13) // 15 bpp high alpha | |
888 + (0<<14) // 15 bpp high alpha | |
889 + (0<<15) // 15 bpp high alpha | |
890 + (0<<16) // 15 bpp low alpha | |
891 + (0<<17) // 15 bpp low alpha | |
892 + (0<<18) // 15 bpp low alpha | |
893 + (0<<19) // 15 bpp low alpha | |
894 + (0<<20) // 15 bpp low alpha | |
895 + (0<<21) // 15 bpp low alpha | |
896 + (0<<22) // 15 bpp low alpha | |
897 + (0<<23) // 15 bpp low alpha | |
898 + (0<<24) // static subpicture key | |
899 + (0<<25) // static subpicture key | |
900 + (0<<26) // static subpicture key | |
901 + (0<<27) // static subpicture key | |
902 + (0<<28) // static subpicture key | |
903 */ ; | |
904 break; | |
905 | |
906 case MGA_VID_FORMAT_YUY2: | |
907 cregs.c2ctl = 1 // CRTC2 enabled | |
908 + (1<<1) // external clock | |
909 + (0<<2) // external clock | |
910 + (1<<3) // pixel clock enable - not needed ??? | |
911 + (0<<4) // high prioryty req - acc to spec | |
912 + (1<<5) // high prioryty req | |
913 + (0<<6) // high prioryty req | |
914 // 7 reserved | |
915 + (1<<8) // high prioryty req max | |
916 + (0<<9) // high prioryty req max | |
917 + (0<<10) // high prioryty req max | |
918 // 11-19 reserved | |
919 + (0<<20) // CRTC1 to DAC | |
920 + (1<<21) // 422 mode | |
921 + (0<<22) // 422 mode | |
922 + (1<<23) // 422 mode | |
923 + (0<<24) // single chroma line for 420 mode - need to be corrected | |
924 + (0<<25) /*/ interlace mode - need to be corrected*/ | |
925 + (0<<26) // field legth polariry | |
926 + (0<<27) // field identification polariry | |
927 + (1<<28) // VIDRST detection mode | |
928 + (0<<29) // VIDRST detection mode | |
929 + (1<<30) // Horizontal counter preload | |
930 + (1<<31) // Vertical counter preload | |
931 ; | |
932 cregs.c2datactl = 1 // disable dither - propably not needed, we are already in YUV mode | |
933 + (1<<1) // Y filter enable | |
934 + (1<<2) // CbCr filter enable | |
935 + (0<<3) // subpicture enable (disabled) | |
936 + (0<<4) // NTSC enable (disabled - PAL) | |
937 + (0<<5) // C2 static subpicture enable (disabled) | |
938 + (0<<6) // C2 subpicture offset division (disabled) | |
939 + (0<<7) // 422 subformat selection ! | |
940 /* + (0<<8) // 15 bpp high alpha | |
941 + (0<<9) // 15 bpp high alpha | |
942 + (0<<10) // 15 bpp high alpha | |
943 + (0<<11) // 15 bpp high alpha | |
944 + (0<<12) // 15 bpp high alpha | |
945 + (0<<13) // 15 bpp high alpha | |
946 + (0<<14) // 15 bpp high alpha | |
947 + (0<<15) // 15 bpp high alpha | |
948 + (0<<16) // 15 bpp low alpha | |
949 + (0<<17) // 15 bpp low alpha | |
950 + (0<<18) // 15 bpp low alpha | |
951 + (0<<19) // 15 bpp low alpha | |
952 + (0<<20) // 15 bpp low alpha | |
953 + (0<<21) // 15 bpp low alpha | |
954 + (0<<22) // 15 bpp low alpha | |
955 + (0<<23) // 15 bpp low alpha | |
956 + (0<<24) // static subpicture key | |
957 + (0<<25) // static subpicture key | |
958 + (0<<26) // static subpicture key | |
959 + (0<<27) // static subpicture key | |
960 + (0<<28) // static subpicture key | |
961 */ ; | |
962 break; | |
963 | |
964 case MGA_VID_FORMAT_UYVY: | |
965 cregs.c2ctl = 1 // CRTC2 enabled | |
966 + (1<<1) // external clock | |
967 + (0<<2) // external clock | |
968 + (1<<3) // pixel clock enable - not needed ??? | |
969 + (0<<4) // high prioryty req | |
970 + (1<<5) // high prioryty req | |
971 + (0<<6) // high prioryty req | |
972 + (1<<8) // high prioryty req max | |
973 + (0<<9) // high prioryty req max | |
974 + (0<<10) // high prioryty req max | |
975 + (0<<20) // CRTC1 to DAC | |
976 + (1<<21) // 422 mode | |
977 + (0<<22) // 422 mode | |
978 + (1<<23) // 422 mode | |
979 + (1<<24) // single chroma line for 420 mode - need to be corrected | |
980 + (1<<25) /*/ interlace mode - need to be corrected*/ | |
981 + (0<<26) // field legth polariry | |
982 + (0<<27) // field identification polariry | |
983 + (1<<28) // VIDRST detection mode | |
984 + (0<<29) // VIDRST detection mode | |
985 + (1<<30) // Horizontal counter preload | |
986 + (1<<31) // Vertical counter preload | |
987 ; | |
988 cregs.c2datactl = 0 // enable dither - propably not needed, we are already in YUV mode | |
989 + (1<<1) // Y filter enable | |
990 + (1<<2) // CbCr filter enable | |
991 + (0<<3) // subpicture enable (disabled) | |
992 + (0<<4) // NTSC enable (disabled - PAL) | |
993 + (0<<5) // C2 static subpicture enable (disabled) | |
994 + (0<<6) // C2 subpicture offset division (disabled) | |
995 + (1<<7) // 422 subformat selection ! | |
996 /* + (0<<8) // 15 bpp high alpha | |
997 + (0<<9) // 15 bpp high alpha | |
998 + (0<<10) // 15 bpp high alpha | |
999 + (0<<11) // 15 bpp high alpha | |
1000 + (0<<12) // 15 bpp high alpha | |
1001 + (0<<13) // 15 bpp high alpha | |
1002 + (0<<14) // 15 bpp high alpha | |
1003 + (0<<15) // 15 bpp high alpha | |
1004 + (0<<16) // 15 bpp low alpha | |
1005 + (0<<17) // 15 bpp low alpha | |
1006 + (0<<18) // 15 bpp low alpha | |
1007 + (0<<19) // 15 bpp low alpha | |
1008 + (0<<20) // 15 bpp low alpha | |
1009 + (0<<21) // 15 bpp low alpha | |
1010 + (0<<22) // 15 bpp low alpha | |
1011 + (0<<23) // 15 bpp low alpha | |
1012 + (0<<24) // static subpicture key | |
1013 + (0<<25) // static subpicture key | |
1014 + (0<<26) // static subpicture key | |
1015 + (0<<27) // static subpicture key | |
1016 + (0<<28) // static subpicture key | |
1017 */ ; | |
1018 break; | |
1019 | |
1020 default: | |
1021 printk(KERN_ERR "mga_vid: Unsupported pixel format: 0x%X\n",config->format); | |
1022 return -1; | |
1023 } | |
1024 | |
1025 cregs.c2hparam=((hdispend - 8) << 16) | (htotal - 8); | |
1026 cregs.c2hsync=((hsyncend - 8) << 16) | (hsyncstart - 8); | |
1027 | |
1028 cregs.c2misc=0 // CRTCV2 656 togg f0 | |
1029 +(0<<1) // CRTCV2 656 togg f0 | |
1030 +(0<<2) // CRTCV2 656 togg f0 | |
1031 +(0<<4) // CRTCV2 656 togg f1 | |
1032 +(0<<5) // CRTCV2 656 togg f1 | |
1033 +(0<<6) // CRTCV2 656 togg f1 | |
1034 +(0<<8) // Hsync active high | |
1035 +(0<<9) // Vsync active high | |
1036 // 16-27 c2vlinecomp - nevim co tam dat | |
1037 ; | |
1038 cregs.c2offset=(regs.bespitch << 1); | |
1039 | |
1040 cregs.c2pl2startadd0=regs.besa1corg; | |
1041 // cregs.c2pl2startadd1=regs.besa2corg; | |
1042 cregs.c2pl3startadd0=regs.besa1c3org; | |
1043 // cregs.c2pl3startadd1=regs.besa2c3org; | |
1044 | |
1045 cregs.c2preload=(vsyncstart << 16) | (hsyncstart); // from | |
1046 | |
1047 cregs.c2spicstartadd0=0; // not used | |
1048 // cregs.c2spicstartadd1=0; // not used | |
1049 | |
1050 cregs.c2startadd0=regs.besa1org; | |
1051 // cregs.c2startadd1=regs.besa2org; | |
1052 | |
1053 cregs.c2subpiclut=0; //not used | |
1054 | |
1055 cregs.c2vparam=((vdispend - 1) << 16) | (vtotal - 1); | |
1056 cregs.c2vsync=((vsyncend - 1) << 16) | (vsyncstart - 1); | |
1057 | |
1058 | |
1059 #endif | |
1060 | |
2086 | 1061 mga_vid_write_regs(0); |
1 | 1062 return 0; |
1063 } | |
1064 | |
68 | 1065 #ifdef MGA_ALLOW_IRQ |
1066 | |
48 | 1067 static void enable_irq(){ |
1068 long int cc; | |
1069 | |
1070 cc = readl(mga_mmio_base + IEN); | |
63 | 1071 // printk(KERN_ALERT "*** !!! IRQREG = %d\n", (int)(cc&0xff)); |
48 | 1072 |
1073 writeb( 0x11, mga_mmio_base + CRTCX); | |
1074 | |
1075 writeb(0x20, mga_mmio_base + CRTCD ); /* clear 0, enable off */ | |
1076 writeb(0x00, mga_mmio_base + CRTCD ); /* enable on */ | |
1077 writeb(0x10, mga_mmio_base + CRTCD ); /* clear = 1 */ | |
1078 | |
1079 writel( regs.besglobctl , mga_mmio_base + BESGLOBCTL); | |
1080 | |
1081 } | |
1082 | |
1083 static void disable_irq(){ | |
1084 | |
1085 writeb( 0x11, mga_mmio_base + CRTCX); | |
1086 writeb(0x20, mga_mmio_base + CRTCD ); /* clear 0, enable off */ | |
1087 | |
1088 } | |
1089 | |
5884 | 1090 static void mga_handle_irq(int irq, void *dev_id, struct pt_regs *pregs) { |
48 | 1091 // static int frame=0; |
854
76ca00724e12
gcc warnings fixed - patch by Aelius aelius@wish.net
arpi_esp
parents:
662
diff
changeset
|
1092 // static int counter=0; |
48 | 1093 long int cc; |
1094 // if ( ! mga_enabled_flag ) return; | |
1095 | |
68 | 1096 // printk(KERN_DEBUG "vcount = %d\n",readl(mga_mmio_base + VCOUNT)); |
1097 | |
48 | 1098 //printk("mga_interrupt #%d\n", irq); |
1099 | |
1100 if ( irq != -1 ) { | |
1101 | |
1102 cc = readl(mga_mmio_base + STATUS); | |
1103 if ( ! (cc & 0x10) ) return; /* vsyncpen */ | |
1104 // debug_irqcnt++; | |
1105 } | |
1106 | |
1107 // if ( debug_irqignore ) { | |
1108 // debug_irqignore = 0; | |
1109 | |
1110 | |
1111 /* | |
1112 if ( mga_conf_deinterlace ) { | |
1113 if ( mga_first_field ) { | |
1114 // printk("mga_interrupt first field\n"); | |
1115 if ( syncfb_interrupt() ) | |
1116 mga_first_field = 0; | |
1117 } else { | |
1118 // printk("mga_interrupt second field\n"); | |
1119 mga_select_buffer( mga_current_field | 2 ); | |
1120 mga_first_field = 1; | |
1121 } | |
1122 } else { | |
1123 syncfb_interrupt(); | |
1124 } | |
1125 */ | |
1126 | |
1127 // frame=(frame+1)&1; | |
1128 regs.besctl = (regs.besctl & ~0x07000000) + (mga_next_frame << 25); | |
1129 writel( regs.besctl, mga_mmio_base + BESCTL ); | |
2344 | 1130 |
1131 #ifdef CRTC2 | |
1132 // sem pridat vyber obrazku !!!! | |
1133 crtc2_frame_sel(mga_next_frame); | |
1134 #endif | |
48 | 1135 |
1136 #if 0 | |
1137 ++counter; | |
1138 if(!(counter&63)){ | |
1139 printk("mga irq counter = %d\n",counter); | |
1140 } | |
1141 #endif | |
1142 | |
1143 // } else { | |
1144 // debug_irqignore = 1; | |
1145 // } | |
1146 | |
1147 if ( irq != -1 ) { | |
1148 writeb( 0x11, mga_mmio_base + CRTCX); | |
1149 writeb( 0, mga_mmio_base + CRTCD ); | |
1150 writeb( 0x10, mga_mmio_base + CRTCD ); | |
1151 } | |
1152 | |
1153 // writel( regs.besglobctl, mga_mmio_base + BESGLOBCTL); | |
1154 | |
1155 | |
1156 return; | |
1157 | |
1158 } | |
1159 | |
68 | 1160 #endif |
1 | 1161 |
1162 static int mga_vid_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) | |
1163 { | |
1164 int frame; | |
5013
52c008dd6e93
min() moved out of #if, applied brightness/contrast patch by Brian J. Murrell
arpi
parents:
4728
diff
changeset
|
1165 uint32_t tmp; |
52c008dd6e93
min() moved out of #if, applied brightness/contrast patch by Brian J. Murrell
arpi
parents:
4728
diff
changeset
|
1166 |
1 | 1167 |
1168 switch(cmd) | |
1169 { | |
1170 case MGA_VID_CONFIG: | |
1171 //FIXME remove | |
68 | 1172 // printk(KERN_DEBUG "vcount = %d\n",readl(mga_mmio_base + VCOUNT)); |
5623 | 1173 #ifdef MP_DEBUG |
61 | 1174 printk(KERN_DEBUG "mga_mmio_base = %p\n",mga_mmio_base); |
854
76ca00724e12
gcc warnings fixed - patch by Aelius aelius@wish.net
arpi_esp
parents:
662
diff
changeset
|
1175 printk(KERN_DEBUG "mga_mem_base = %08x\n",mga_mem_base); |
1 | 1176 //FIXME remove |
1177 | |
61 | 1178 printk(KERN_DEBUG "mga_vid: Received configuration\n"); |
5623 | 1179 #endif |
1 | 1180 |
1181 if(copy_from_user(&mga_config,(mga_vid_config_t*) arg,sizeof(mga_vid_config_t))) | |
1182 { | |
61 | 1183 printk(KERN_ERR "mga_vid: failed copy from userspace\n"); |
1 | 1184 return(-EFAULT); |
1185 } | |
57 | 1186 if(mga_config.version != MGA_VID_VERSION){ |
61 | 1187 printk(KERN_ERR "mga_vid: incompatible version! driver: %X requested: %X\n",MGA_VID_VERSION,mga_config.version); |
57 | 1188 return(-EFAULT); |
1189 } | |
1190 | |
1191 if(mga_config.frame_size==0 || mga_config.frame_size>1024*768*2){ | |
61 | 1192 printk(KERN_ERR "mga_vid: illegal frame_size: %d\n",mga_config.frame_size); |
57 | 1193 return(-EFAULT); |
1194 } | |
1195 | |
1196 if(mga_config.num_frames<1 || mga_config.num_frames>4){ | |
61 | 1197 printk(KERN_ERR "mga_vid: illegal num_frames: %d\n",mga_config.num_frames); |
57 | 1198 return(-EFAULT); |
1199 } | |
1200 | |
4559
5dc383bb1c82
added mga_top_reserved module parameter to skip a configurable amount
rfelker
parents:
4527
diff
changeset
|
1201 mga_src_base = (mga_ram_size*0x100000-mga_config.num_frames*mga_config.frame_size-mga_top_reserved); |
57 | 1202 if(mga_src_base<0){ |
61 | 1203 printk(KERN_ERR "mga_vid: not enough memory for frames!\n"); |
57 | 1204 return(-EFAULT); |
1205 } | |
1206 mga_src_base &= (~0xFFFF); // 64k boundary | |
5623 | 1207 #ifdef MP_DEBUG |
61 | 1208 printk(KERN_DEBUG "mga YUV buffer base: 0x%X\n", mga_src_base); |
5623 | 1209 #endif |
57 | 1210 |
1 | 1211 if (is_g400) |
1212 mga_config.card_type = MGA_G400; | |
1213 else | |
1214 mga_config.card_type = MGA_G200; | |
1215 | |
1216 mga_config.ram_size = mga_ram_size; | |
1217 | |
1218 if (copy_to_user((mga_vid_config_t *) arg, &mga_config, sizeof(mga_vid_config_t))) | |
1219 { | |
61 | 1220 printk(KERN_ERR "mga_vid: failed copy to userspace\n"); |
1 | 1221 return(-EFAULT); |
1222 } | |
1223 return mga_vid_set_config(&mga_config); | |
1224 break; | |
1225 | |
1226 case MGA_VID_ON: | |
5623 | 1227 #ifdef MP_DEBUG |
61 | 1228 printk(KERN_DEBUG "mga_vid: Video ON\n"); |
5623 | 1229 #endif |
1 | 1230 vid_src_ready = 1; |
1231 if(vid_overlay_on) | |
1232 { | |
1233 regs.besctl |= 1; | |
2086 | 1234 mga_vid_write_regs(0); |
1 | 1235 } |
68 | 1236 #ifdef MGA_ALLOW_IRQ |
48 | 1237 if ( mga_irq != -1 ) enable_irq(); |
68 | 1238 #endif |
48 | 1239 mga_next_frame=0; |
1 | 1240 break; |
1241 | |
1242 case MGA_VID_OFF: | |
5623 | 1243 #ifdef MP_DEBUG |
94
fbd99740af99
printk() message for video off when releasing mga without ioctl()
lgb
parents:
93
diff
changeset
|
1244 printk(KERN_DEBUG "mga_vid: Video OFF (ioctl)\n"); |
5623 | 1245 #endif |
1 | 1246 vid_src_ready = 0; |
68 | 1247 #ifdef MGA_ALLOW_IRQ |
48 | 1248 if ( mga_irq != -1 ) disable_irq(); |
68 | 1249 #endif |
1 | 1250 regs.besctl &= ~1; |
466 | 1251 regs.besglobctl &= ~(1<<6); // UYVY format selected |
2086 | 1252 mga_vid_write_regs(0); |
1 | 1253 break; |
1254 | |
1255 case MGA_VID_FSEL: | |
1256 if(copy_from_user(&frame,(int *) arg,sizeof(int))) | |
1257 { | |
61 | 1258 printk(KERN_ERR "mga_vid: FSEL failed copy from userspace\n"); |
1 | 1259 return(-EFAULT); |
1260 } | |
1261 | |
1262 mga_vid_frame_sel(frame); | |
1263 break; | |
1264 | |
5013
52c008dd6e93
min() moved out of #if, applied brightness/contrast patch by Brian J. Murrell
arpi
parents:
4728
diff
changeset
|
1265 case MGA_VID_GET_LUMA: |
52c008dd6e93
min() moved out of #if, applied brightness/contrast patch by Brian J. Murrell
arpi
parents:
4728
diff
changeset
|
1266 tmp = regs.beslumactl - 0x80; |
52c008dd6e93
min() moved out of #if, applied brightness/contrast patch by Brian J. Murrell
arpi
parents:
4728
diff
changeset
|
1267 if (copy_to_user((uint32_t *) arg, &tmp, sizeof(uint32_t))) |
52c008dd6e93
min() moved out of #if, applied brightness/contrast patch by Brian J. Murrell
arpi
parents:
4728
diff
changeset
|
1268 { |
52c008dd6e93
min() moved out of #if, applied brightness/contrast patch by Brian J. Murrell
arpi
parents:
4728
diff
changeset
|
1269 printk(KERN_ERR "mga_vid: failed copy %p to userspace %p\n", |
52c008dd6e93
min() moved out of #if, applied brightness/contrast patch by Brian J. Murrell
arpi
parents:
4728
diff
changeset
|
1270 &tmp, (uint32_t *) arg); |
52c008dd6e93
min() moved out of #if, applied brightness/contrast patch by Brian J. Murrell
arpi
parents:
4728
diff
changeset
|
1271 return(-EFAULT); |
52c008dd6e93
min() moved out of #if, applied brightness/contrast patch by Brian J. Murrell
arpi
parents:
4728
diff
changeset
|
1272 } |
52c008dd6e93
min() moved out of #if, applied brightness/contrast patch by Brian J. Murrell
arpi
parents:
4728
diff
changeset
|
1273 break; |
52c008dd6e93
min() moved out of #if, applied brightness/contrast patch by Brian J. Murrell
arpi
parents:
4728
diff
changeset
|
1274 |
52c008dd6e93
min() moved out of #if, applied brightness/contrast patch by Brian J. Murrell
arpi
parents:
4728
diff
changeset
|
1275 case MGA_VID_SET_LUMA: |
52c008dd6e93
min() moved out of #if, applied brightness/contrast patch by Brian J. Murrell
arpi
parents:
4728
diff
changeset
|
1276 tmp = arg; |
52c008dd6e93
min() moved out of #if, applied brightness/contrast patch by Brian J. Murrell
arpi
parents:
4728
diff
changeset
|
1277 regs.beslumactl = tmp + 0x80; |
52c008dd6e93
min() moved out of #if, applied brightness/contrast patch by Brian J. Murrell
arpi
parents:
4728
diff
changeset
|
1278 mga_vid_write_regs(0); |
52c008dd6e93
min() moved out of #if, applied brightness/contrast patch by Brian J. Murrell
arpi
parents:
4728
diff
changeset
|
1279 break; |
52c008dd6e93
min() moved out of #if, applied brightness/contrast patch by Brian J. Murrell
arpi
parents:
4728
diff
changeset
|
1280 |
1 | 1281 default: |
61 | 1282 printk(KERN_ERR "mga_vid: Invalid ioctl\n"); |
1 | 1283 return (-EINVAL); |
1284 } | |
1285 | |
1286 return 0; | |
1287 } | |
1288 | |
1289 | |
1290 static int mga_vid_find_card(void) | |
1291 { | |
1292 struct pci_dev *dev = NULL; | |
854
76ca00724e12
gcc warnings fixed - patch by Aelius aelius@wish.net
arpi_esp
parents:
662
diff
changeset
|
1293 unsigned int card_option; |
1 | 1294 |
1989 | 1295 if((dev = pci_find_device(PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_G550, NULL))) |
1296 { | |
1297 is_g400 = 1; | |
1298 printk(KERN_INFO "mga_vid: Found MGA G550\n"); | |
1299 } | |
1300 else if((dev = pci_find_device(PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_G400, NULL))) | |
1 | 1301 { |
1302 is_g400 = 1; | |
77 | 1303 printk(KERN_INFO "mga_vid: Found MGA G400/G450\n"); |
1 | 1304 } |
1305 else if((dev = pci_find_device(PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_G200_AGP, NULL))) | |
1306 { | |
1307 is_g400 = 0; | |
63 | 1308 printk(KERN_INFO "mga_vid: Found MGA G200 AGP\n"); |
1 | 1309 } |
1310 else if((dev = pci_find_device(PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_G200_PCI, NULL))) | |
1311 { | |
1312 is_g400 = 0; | |
63 | 1313 printk(KERN_INFO "mga_vid: Found MGA G200 PCI\n"); |
1 | 1314 } |
1315 else | |
1316 { | |
61 | 1317 printk(KERN_ERR "mga_vid: No supported cards found\n"); |
1 | 1318 return FALSE; |
1319 } | |
1320 | |
1321 pci_dev = dev; | |
48 | 1322 |
1323 mga_irq = pci_dev->irq; | |
1 | 1324 |
1325 #if LINUX_VERSION_CODE >= 0x020300 | |
1326 mga_mmio_base = ioremap_nocache(dev->resource[1].start,0x4000); | |
1327 mga_mem_base = dev->resource[0].start; | |
1328 #else | |
1329 mga_mmio_base = ioremap_nocache(dev->base_address[1] & PCI_BASE_ADDRESS_MEM_MASK,0x4000); | |
1330 mga_mem_base = dev->base_address[0] & PCI_BASE_ADDRESS_MEM_MASK; | |
1331 #endif | |
854
76ca00724e12
gcc warnings fixed - patch by Aelius aelius@wish.net
arpi_esp
parents:
662
diff
changeset
|
1332 printk(KERN_INFO "mga_vid: MMIO at 0x%p IRQ: %d framebuffer: 0x%08X\n", mga_mmio_base, mga_irq, mga_mem_base); |
1 | 1333 |
1334 pci_read_config_dword(dev, 0x40, &card_option); | |
77 | 1335 printk(KERN_INFO "mga_vid: OPTION word: 0x%08X mem: 0x%02X %s\n", card_option, |
1336 (card_option>>10)&0x17, ((card_option>>14)&1)?"SGRAM":"SDRAM"); | |
1 | 1337 |
57 | 1338 // temp = (card_option >> 10) & 0x17; |
1339 | |
95 | 1340 if (mga_ram_size) { |
1341 printk(KERN_INFO "mga_vid: RAMSIZE forced to %d MB\n", mga_ram_size); | |
91 | 1342 } else { |
90 | 1343 |
101
7fe6855f19cd
mga_ram_size=x works with hard-coded ramsize too (szabi)
arpi_esp
parents:
95
diff
changeset
|
1344 #ifdef MGA_MEMORY_SIZE |
7fe6855f19cd
mga_ram_size=x works with hard-coded ramsize too (szabi)
arpi_esp
parents:
95
diff
changeset
|
1345 mga_ram_size = MGA_MEMORY_SIZE; |
7fe6855f19cd
mga_ram_size=x works with hard-coded ramsize too (szabi)
arpi_esp
parents:
95
diff
changeset
|
1346 printk(KERN_INFO "mga_vid: hard-coded RAMSIZE is %d MB\n", (unsigned int) mga_ram_size); |
7fe6855f19cd
mga_ram_size=x works with hard-coded ramsize too (szabi)
arpi_esp
parents:
95
diff
changeset
|
1347 |
7fe6855f19cd
mga_ram_size=x works with hard-coded ramsize too (szabi)
arpi_esp
parents:
95
diff
changeset
|
1348 #else |
7fe6855f19cd
mga_ram_size=x works with hard-coded ramsize too (szabi)
arpi_esp
parents:
95
diff
changeset
|
1349 |
95 | 1350 if (is_g400){ |
75 | 1351 switch((card_option>>10)&0x17){ |
1352 // SDRAM: | |
1353 case 0x00: | |
1354 case 0x04: mga_ram_size = 16; break; | |
4594
ca6d74f72734
g550 memdetect fix - patch by Diego Biurrun <diego@biurrun.de>
arpi
parents:
4559
diff
changeset
|
1355 case 0x03: |
ca6d74f72734
g550 memdetect fix - patch by Diego Biurrun <diego@biurrun.de>
arpi
parents:
4559
diff
changeset
|
1356 case 0x05: mga_ram_size = 32; break; |
75 | 1357 // SGRAM: |
1358 case 0x10: | |
1359 case 0x14: mga_ram_size = 32; break; | |
1360 case 0x11: | |
1361 case 0x12: mga_ram_size = 16; break; | |
1362 default: | |
1363 mga_ram_size = 16; | |
1364 printk(KERN_INFO "mga_vid: Couldn't detect RAMSIZE, assuming 16MB!"); | |
1365 } | |
95 | 1366 }else{ |
662
4a959b73d51e
G200 ramsize detection disabled, using 8M by default
arpi_esp
parents:
470
diff
changeset
|
1367 switch((card_option>>10)&0x17){ |
4a959b73d51e
G200 ramsize detection disabled, using 8M by default
arpi_esp
parents:
470
diff
changeset
|
1368 // case 0x10: |
4a959b73d51e
G200 ramsize detection disabled, using 8M by default
arpi_esp
parents:
470
diff
changeset
|
1369 // case 0x13: mga_ram_size = 8; break; |
4a959b73d51e
G200 ramsize detection disabled, using 8M by default
arpi_esp
parents:
470
diff
changeset
|
1370 default: mga_ram_size = 8; |
64 | 1371 } |
95 | 1372 } |
64 | 1373 #if 0 |
95 | 1374 // printk("List resources -----------\n"); |
1375 for(temp=0;temp<DEVICE_COUNT_RESOURCE;temp++){ | |
1376 struct resource *res=&pci_dev->resource[temp]; | |
1377 if(res->flags){ | |
1378 int size=(1+res->end-res->start)>>20; | |
1379 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); | |
1380 if(res->flags&(IORESOURCE_MEM|IORESOURCE_PREFETCH)){ | |
1381 if(size>mga_ram_size && size<=64) mga_ram_size=size; | |
1382 } | |
1383 } | |
57 | 1384 } |
64 | 1385 #endif |
95 | 1386 printk(KERN_INFO "mga_vid: detected RAMSIZE is %d MB\n", (unsigned int) mga_ram_size); |
101
7fe6855f19cd
mga_ram_size=x works with hard-coded ramsize too (szabi)
arpi_esp
parents:
95
diff
changeset
|
1387 #endif |
95 | 1388 } |
57 | 1389 |
48 | 1390 |
68 | 1391 #ifdef MGA_ALLOW_IRQ |
48 | 1392 if ( mga_irq != -1 ) { |
1393 int tmp = request_irq(mga_irq, mga_handle_irq, SA_INTERRUPT | SA_SHIRQ, "Syncfb Time Base", &mga_irq); | |
1394 if ( tmp ) { | |
61 | 1395 printk(KERN_INFO "syncfb (mga): cannot register irq %d (Err: %d)\n", mga_irq, tmp); |
48 | 1396 mga_irq=-1; |
1397 } else { | |
61 | 1398 printk(KERN_DEBUG "syncfb (mga): registered irq %d\n", mga_irq); |
48 | 1399 } |
1400 } else { | |
61 | 1401 printk(KERN_INFO "syncfb (mga): No valid irq was found\n"); |
48 | 1402 mga_irq=-1; |
1403 } | |
68 | 1404 #else |
1405 printk(KERN_INFO "syncfb (mga): IRQ disabled in mga_vid.c\n"); | |
1406 mga_irq=-1; | |
1407 #endif | |
48 | 1408 |
1 | 1409 return TRUE; |
1410 } | |
1411 | |
4484 | 1412 static void mga_param_buff_fill( void ) |
1413 { | |
1414 unsigned len; | |
1415 len = 0; | |
1416 len += sprintf(&mga_param_buff[len],"Interface version: %04X\n",MGA_VID_VERSION); | |
4527 | 1417 len += sprintf(&mga_param_buff[len],"Memory: %x:%dM\n",mga_mem_base,(unsigned int) mga_ram_size); |
4484 | 1418 len += sprintf(&mga_param_buff[len],"MMIO: %p\n",mga_mmio_base); |
1419 len += sprintf(&mga_param_buff[len],"Configurable stuff:\n"); | |
1420 len += sprintf(&mga_param_buff[len],"~~~~~~~~~~~~~~~~~~~\n"); | |
4728
dab19bd91cde
Add module parameters: contrast and brightness, so when you need those permanently
eyck
parents:
4594
diff
changeset
|
1421 len += sprintf(&mga_param_buff[len],PARAM_BRIGHTNESS"%d\n",mga_brightness); |
dab19bd91cde
Add module parameters: contrast and brightness, so when you need those permanently
eyck
parents:
4594
diff
changeset
|
1422 len += sprintf(&mga_param_buff[len],PARAM_CONTRAST"%d\n",mga_contrast); |
4484 | 1423 len += sprintf(&mga_param_buff[len],PARAM_BLACKIE"%s\n",regs.blackie?"on":"off"); |
1424 mga_param_buff_len = len; | |
4527 | 1425 // check boundaries of mga_param_buff before writing to it!!! |
4484 | 1426 } |
1427 | |
1 | 1428 |
1429 static ssize_t mga_vid_read(struct file *file, char *buf, size_t count, loff_t *ppos) | |
1430 { | |
4484 | 1431 uint32_t size; |
1432 if(!mga_param_buff) return -ESPIPE; | |
1433 if(!(*ppos)) mga_param_buff_fill(); | |
1434 if(*ppos >= mga_param_buff_len) return 0; | |
1435 size = min(count,mga_param_buff_len-(uint32_t)(*ppos)); | |
1436 memcpy(buf,mga_param_buff,size); | |
1437 *ppos += size; | |
1438 return size; | |
1 | 1439 } |
1440 | |
1441 static ssize_t mga_vid_write(struct file *file, const char *buf, size_t count, loff_t *ppos) | |
1442 { | |
4483
fb4b914eab8a
framework for settings modifications like in radeon_vid ( /dev/mga_vid can
eyck
parents:
3959
diff
changeset
|
1443 if(memcmp(buf,PARAM_BRIGHTNESS,min(count,strlen(PARAM_BRIGHTNESS))) == 0) |
fb4b914eab8a
framework for settings modifications like in radeon_vid ( /dev/mga_vid can
eyck
parents:
3959
diff
changeset
|
1444 { |
fb4b914eab8a
framework for settings modifications like in radeon_vid ( /dev/mga_vid can
eyck
parents:
3959
diff
changeset
|
1445 short brightness; |
fb4b914eab8a
framework for settings modifications like in radeon_vid ( /dev/mga_vid can
eyck
parents:
3959
diff
changeset
|
1446 brightness=simple_strtol(&buf[strlen(PARAM_BRIGHTNESS)],NULL,10); |
fb4b914eab8a
framework for settings modifications like in radeon_vid ( /dev/mga_vid can
eyck
parents:
3959
diff
changeset
|
1447 if (brightness>127 || brightness<-128) { brightness=0;} |
fb4b914eab8a
framework for settings modifications like in radeon_vid ( /dev/mga_vid can
eyck
parents:
3959
diff
changeset
|
1448 // printk(KERN_DEBUG "mga_vid: brightness modified ( %d ) \n",brightness); |
4728
dab19bd91cde
Add module parameters: contrast and brightness, so when you need those permanently
eyck
parents:
4594
diff
changeset
|
1449 mga_brightness=brightness; |
4483
fb4b914eab8a
framework for settings modifications like in radeon_vid ( /dev/mga_vid can
eyck
parents:
3959
diff
changeset
|
1450 } else |
4487
e642ff2d5c6d
Attila's Linux 2.2 patch, and contrast control applied
eyck
parents:
4484
diff
changeset
|
1451 if(memcmp(buf,PARAM_CONTRAST,min(count,strlen(PARAM_CONTRAST))) == 0) |
e642ff2d5c6d
Attila's Linux 2.2 patch, and contrast control applied
eyck
parents:
4484
diff
changeset
|
1452 { |
e642ff2d5c6d
Attila's Linux 2.2 patch, and contrast control applied
eyck
parents:
4484
diff
changeset
|
1453 short contrast; |
e642ff2d5c6d
Attila's Linux 2.2 patch, and contrast control applied
eyck
parents:
4484
diff
changeset
|
1454 contrast=simple_strtol(&buf[strlen(PARAM_CONTRAST)],NULL,10); |
e642ff2d5c6d
Attila's Linux 2.2 patch, and contrast control applied
eyck
parents:
4484
diff
changeset
|
1455 if (contrast>127 || contrast<-128) { contrast=0;} |
e642ff2d5c6d
Attila's Linux 2.2 patch, and contrast control applied
eyck
parents:
4484
diff
changeset
|
1456 // printk(KERN_DEBUG "mga_vid: contrast modified ( %d ) \n",contrast); |
4728
dab19bd91cde
Add module parameters: contrast and brightness, so when you need those permanently
eyck
parents:
4594
diff
changeset
|
1457 mga_contrast=contrast; |
4487
e642ff2d5c6d
Attila's Linux 2.2 patch, and contrast control applied
eyck
parents:
4484
diff
changeset
|
1458 } else |
e642ff2d5c6d
Attila's Linux 2.2 patch, and contrast control applied
eyck
parents:
4484
diff
changeset
|
1459 |
4483
fb4b914eab8a
framework for settings modifications like in radeon_vid ( /dev/mga_vid can
eyck
parents:
3959
diff
changeset
|
1460 if(memcmp(buf,PARAM_BLACKIE,min(count,strlen(PARAM_BLACKIE))) == 0) |
fb4b914eab8a
framework for settings modifications like in radeon_vid ( /dev/mga_vid can
eyck
parents:
3959
diff
changeset
|
1461 { |
fb4b914eab8a
framework for settings modifications like in radeon_vid ( /dev/mga_vid can
eyck
parents:
3959
diff
changeset
|
1462 short blackie; |
fb4b914eab8a
framework for settings modifications like in radeon_vid ( /dev/mga_vid can
eyck
parents:
3959
diff
changeset
|
1463 blackie=simple_strtol(&buf[strlen(PARAM_BLACKIE)],NULL,10); |
fb4b914eab8a
framework for settings modifications like in radeon_vid ( /dev/mga_vid can
eyck
parents:
3959
diff
changeset
|
1464 // printk(KERN_DEBUG "mga_vid: shadow mode: ( %d ) \n",blackie); |
fb4b914eab8a
framework for settings modifications like in radeon_vid ( /dev/mga_vid can
eyck
parents:
3959
diff
changeset
|
1465 regs.blackie=(blackie>0)?1:0; |
fb4b914eab8a
framework for settings modifications like in radeon_vid ( /dev/mga_vid can
eyck
parents:
3959
diff
changeset
|
1466 } else count = -EIO; |
fb4b914eab8a
framework for settings modifications like in radeon_vid ( /dev/mga_vid can
eyck
parents:
3959
diff
changeset
|
1467 // TODO: reset settings |
fb4b914eab8a
framework for settings modifications like in radeon_vid ( /dev/mga_vid can
eyck
parents:
3959
diff
changeset
|
1468 return count; |
1 | 1469 } |
1470 | |
1471 static int mga_vid_mmap(struct file *file, struct vm_area_struct *vma) | |
1472 { | |
1473 | |
5623 | 1474 #ifdef MP_DEBUG |
61 | 1475 printk(KERN_DEBUG "mga_vid: mapping video memory into userspace\n"); |
5623 | 1476 #endif |
6586
df10f81f1bfc
linux-2.5.x support patch by Sytse Wielinga <s.b.wieling at student.utwente.nl>
alex
parents:
6086
diff
changeset
|
1477 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,3) |
df10f81f1bfc
linux-2.5.x support patch by Sytse Wielinga <s.b.wieling at student.utwente.nl>
alex
parents:
6086
diff
changeset
|
1478 if(remap_page_range(vma, vma->vm_start, mga_mem_base + mga_src_base, |
df10f81f1bfc
linux-2.5.x support patch by Sytse Wielinga <s.b.wieling at student.utwente.nl>
alex
parents:
6086
diff
changeset
|
1479 vma->vm_end - vma->vm_start, vma->vm_page_prot)) |
df10f81f1bfc
linux-2.5.x support patch by Sytse Wielinga <s.b.wieling at student.utwente.nl>
alex
parents:
6086
diff
changeset
|
1480 #else |
57 | 1481 if(remap_page_range(vma->vm_start, mga_mem_base + mga_src_base, |
1 | 1482 vma->vm_end - vma->vm_start, vma->vm_page_prot)) |
6586
df10f81f1bfc
linux-2.5.x support patch by Sytse Wielinga <s.b.wieling at student.utwente.nl>
alex
parents:
6086
diff
changeset
|
1483 #endif |
1 | 1484 { |
63 | 1485 printk(KERN_ERR "mga_vid: error mapping video memory\n"); |
1 | 1486 return(-EAGAIN); |
1487 } | |
1488 | |
1489 return(0); | |
1490 } | |
1491 | |
1492 static int mga_vid_release(struct inode *inode, struct file *file) | |
1493 { | |
1494 //Close the window just in case | |
5623 | 1495 #ifdef MP_DEBUG |
94
fbd99740af99
printk() message for video off when releasing mga without ioctl()
lgb
parents:
93
diff
changeset
|
1496 printk(KERN_DEBUG "mga_vid: Video OFF (release)\n"); |
5623 | 1497 #endif |
94
fbd99740af99
printk() message for video off when releasing mga without ioctl()
lgb
parents:
93
diff
changeset
|
1498 |
1 | 1499 vid_src_ready = 0; |
1500 regs.besctl &= ~1; | |
466 | 1501 regs.besglobctl &= ~(1<<6); // UYVY format selected |
2086 | 1502 // mga_config.colkey_on=0; //!!! |
1503 mga_vid_write_regs(1); | |
1 | 1504 mga_vid_in_use = 0; |
1505 | |
93 | 1506 MOD_DEC_USE_COUNT; |
1 | 1507 return 0; |
1508 } | |
1509 | |
1510 static long long mga_vid_lseek(struct file *file, long long offset, int origin) | |
1511 { | |
1512 return -ESPIPE; | |
1513 } | |
1514 | |
1515 static int mga_vid_open(struct inode *inode, struct file *file) | |
1516 { | |
6586
df10f81f1bfc
linux-2.5.x support patch by Sytse Wielinga <s.b.wieling at student.utwente.nl>
alex
parents:
6086
diff
changeset
|
1517 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,2) |
df10f81f1bfc
linux-2.5.x support patch by Sytse Wielinga <s.b.wieling at student.utwente.nl>
alex
parents:
6086
diff
changeset
|
1518 int minor = MINOR(inode->i_rdev.value); |
df10f81f1bfc
linux-2.5.x support patch by Sytse Wielinga <s.b.wieling at student.utwente.nl>
alex
parents:
6086
diff
changeset
|
1519 #else |
1 | 1520 int minor = MINOR(inode->i_rdev); |
6586
df10f81f1bfc
linux-2.5.x support patch by Sytse Wielinga <s.b.wieling at student.utwente.nl>
alex
parents:
6086
diff
changeset
|
1521 #endif |
1 | 1522 |
1523 if(minor != 0) | |
1524 return(-ENXIO); | |
1525 | |
1526 if(mga_vid_in_use == 1) | |
1527 return(-EBUSY); | |
1528 | |
1529 mga_vid_in_use = 1; | |
93 | 1530 MOD_INC_USE_COUNT; |
1 | 1531 return(0); |
1532 } | |
1533 | |
1534 #if LINUX_VERSION_CODE >= 0x020400 | |
1535 static struct file_operations mga_vid_fops = | |
1536 { | |
1537 llseek: mga_vid_lseek, | |
1538 read: mga_vid_read, | |
1539 write: mga_vid_write, | |
1540 ioctl: mga_vid_ioctl, | |
1541 mmap: mga_vid_mmap, | |
1542 open: mga_vid_open, | |
1543 release: mga_vid_release | |
1544 }; | |
1545 #else | |
1546 static struct file_operations mga_vid_fops = | |
1547 { | |
1548 mga_vid_lseek, | |
1549 mga_vid_read, | |
1550 mga_vid_write, | |
1551 NULL, | |
1552 NULL, | |
1553 mga_vid_ioctl, | |
1554 mga_vid_mmap, | |
1555 mga_vid_open, | |
1556 NULL, | |
1557 mga_vid_release | |
1558 }; | |
1559 #endif | |
1560 | |
1561 | |
1562 /* | |
1563 * Main Initialization Function | |
1564 */ | |
1565 | |
1566 static int mga_vid_initialize(void) | |
1567 { | |
1568 mga_vid_in_use = 0; | |
1569 | |
77 | 1570 // printk(KERN_INFO "Matrox MGA G200/G400 YUV Video interface v0.01 (c) Aaron Holtzman \n"); |
4594
ca6d74f72734
g550 memdetect fix - patch by Diego Biurrun <diego@biurrun.de>
arpi
parents:
4559
diff
changeset
|
1571 printk(KERN_INFO "Matrox MGA G200/G400/G450/G550 YUV Video interface v2.01 (c) Aaron Holtzman & A'rpi\n"); |
90 | 1572 |
95 | 1573 if (mga_ram_size) { |
1574 if (mga_ram_size<4 || mga_ram_size>64) { | |
1575 printk(KERN_ERR "mga_vid: invalid RAMSIZE: %d MB\n", mga_ram_size); | |
90 | 1576 return -EINVAL; |
1577 } | |
1578 } | |
5653
39115273d236
Mark Schreiber sent link to Marcus Sundburg patch to mga_vid, which enables
eyck
parents:
5623
diff
changeset
|
1579 #ifdef CONFIG_DEVFS_FS |
5682 | 1580 /* |
1581 from 2.4.17/2.4.18 linux/devfs_fs_kernel.h: | |
1582 extern devfs_handle_t devfs_register (devfs_handle_t dir, const char *name, | |
1583 unsigned int flags, | |
1584 unsigned int major, unsigned int minor, | |
1585 umode_t mode, void *ops, void *info); | |
1586 */ | |
5653
39115273d236
Mark Schreiber sent link to Marcus Sundburg patch to mga_vid, which enables
eyck
parents:
5623
diff
changeset
|
1587 if ((dev_handle = devfs_register( |
39115273d236
Mark Schreiber sent link to Marcus Sundburg patch to mga_vid, which enables
eyck
parents:
5623
diff
changeset
|
1588 NULL, |
5682 | 1589 "mga_vid", DEVFS_FL_NONE, |
5653
39115273d236
Mark Schreiber sent link to Marcus Sundburg patch to mga_vid, which enables
eyck
parents:
5623
diff
changeset
|
1590 MGA_VID_MAJOR, 0, |
39115273d236
Mark Schreiber sent link to Marcus Sundburg patch to mga_vid, which enables
eyck
parents:
5623
diff
changeset
|
1591 S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IFCHR, |
39115273d236
Mark Schreiber sent link to Marcus Sundburg patch to mga_vid, which enables
eyck
parents:
5623
diff
changeset
|
1592 &mga_vid_fops, NULL)) == NULL) |
5764 | 1593 { |
6086 | 1594 printk(KERN_ERR "mga_vid: unable to get major: %d (devfs) => fallback to non-devfs mode\n", MGA_VID_MAJOR); |
1595 // return -EIO; | |
5764 | 1596 } |
1597 #endif | |
1 | 1598 if(register_chrdev(MGA_VID_MAJOR, "mga_vid", &mga_vid_fops)) |
1599 { | |
61 | 1600 printk(KERN_ERR "mga_vid: unable to get major: %d\n", MGA_VID_MAJOR); |
1 | 1601 return -EIO; |
1602 } | |
1603 | |
1604 if (!mga_vid_find_card()) | |
1605 { | |
61 | 1606 printk(KERN_ERR "mga_vid: no supported devices found\n"); |
5653
39115273d236
Mark Schreiber sent link to Marcus Sundburg patch to mga_vid, which enables
eyck
parents:
5623
diff
changeset
|
1607 #ifdef CONFIG_DEVFS_FS |
6086 | 1608 if(dev_handle) devfs_unregister(dev_handle); |
5764 | 1609 #endif |
1 | 1610 unregister_chrdev(MGA_VID_MAJOR, "mga_vid"); |
1611 return -EINVAL; | |
1612 } | |
4484 | 1613 mga_param_buff = kmalloc(PARAM_BUFF_SIZE,GFP_KERNEL); |
1614 if(mga_param_buff) mga_param_buff_size = PARAM_BUFF_SIZE; | |
1 | 1615 |
1616 return(0); | |
1617 } | |
1618 | |
1619 int init_module(void) | |
1620 { | |
1621 return mga_vid_initialize(); | |
1622 } | |
1623 | |
1624 void cleanup_module(void) | |
1625 { | |
48 | 1626 |
68 | 1627 #ifdef MGA_ALLOW_IRQ |
48 | 1628 if ( mga_irq != -1) |
1629 free_irq(mga_irq, &mga_irq); | |
68 | 1630 #endif |
48 | 1631 |
1 | 1632 if(mga_mmio_base) |
1633 iounmap(mga_mmio_base); | |
4520 | 1634 if(mga_param_buff) |
1635 kfree(mga_param_buff); | |
1 | 1636 |
1637 //FIXME turn off BES | |
63 | 1638 printk(KERN_INFO "mga_vid: Cleaning up module\n"); |
5653
39115273d236
Mark Schreiber sent link to Marcus Sundburg patch to mga_vid, which enables
eyck
parents:
5623
diff
changeset
|
1639 #ifdef CONFIG_DEVFS_FS |
6086 | 1640 if(dev_handle) devfs_unregister(dev_handle); |
5764 | 1641 #endif |
1 | 1642 unregister_chrdev(MGA_VID_MAJOR, "mga_vid"); |
1643 } | |
1644 |