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