Mercurial > mplayer.hg
annotate vidix/mga_vid.c @ 22865:441582f3ed87
simplified function prototypes to avoid casts but keep external API compatibility
author | ben |
---|---|
date | Sun, 01 Apr 2007 12:39:06 +0000 |
parents | 6c57087c5a2d |
children | 9a8f6901e888 |
rev | line source |
---|---|
22850 | 1 /* |
2 Matrox MGA driver | |
3 | |
4 ported to VIDIX by Alex Beregszaszi | |
5 | |
6 YUY2 support (see config.format) added by A'rpi/ESP-team | |
7 double buffering added by A'rpi/ESP-team | |
8 | |
9 Brightness/contrast support by Nick Kurshev/Dariush Pietrzak (eyck) and me | |
10 | |
11 TODO: | |
12 * fix memory size detection (current reading pci userconfig isn't | |
13 working as requested - returns the max avail. ram on arch?) | |
14 * translate all non-english comments to english | |
15 */ | |
16 | |
17 /* | |
18 * Original copyright: | |
19 * | |
20 * mga_vid.c | |
21 * | |
22 * Copyright (C) 1999 Aaron Holtzman | |
23 * | |
24 * Module skeleton based on gutted agpgart module by Jeff Hartmann | |
25 * <slicer@ionet.net> | |
26 * | |
27 * Matrox MGA G200/G400 YUV Video Interface module Version 0.1.0 | |
28 * | |
29 * BES == Back End Scaler | |
30 * | |
31 * This software has been released under the terms of the GNU Public | |
32 * license. See http://www.gnu.org/copyleft/gpl.html for details. | |
33 */ | |
34 | |
35 //#define CRTC2 | |
36 | |
37 // Set this value, if autodetection fails! (video ram size in megabytes) | |
38 //#define MGA_MEMORY_SIZE 16 | |
39 | |
40 /* No irq support in userspace implemented yet, do not enable this! */ | |
41 /* disable irq */ | |
42 #undef MGA_ALLOW_IRQ | |
43 | |
44 #define MGA_VSYNC_POS 2 | |
45 | |
46 #undef MGA_PCICONFIG_MEMDETECT | |
47 | |
48 #define MGA_DEFAULT_FRAMES 4 | |
49 | |
50 #include <errno.h> | |
51 #include <stdio.h> | |
52 #include <stdlib.h> | |
53 #include <string.h> | |
54 #include <math.h> | |
55 #include <inttypes.h> | |
56 | |
57 #include "vidix.h" | |
22857
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
58 #include "vidixlib.h" |
22850 | 59 #include "fourcc.h" |
60 #include "../libdha/libdha.h" | |
61 #include "../libdha/pci_ids.h" | |
62 #include "../libdha/pci_names.h" | |
63 | |
64 #ifdef __MINGW32__ | |
65 #define ENOTSUP 134 | |
66 #endif | |
67 | |
68 #if !defined(ENOTSUP) && defined(EOPNOTSUPP) | |
69 #define ENOTSUP EOPNOTSUPP | |
70 #endif | |
71 | |
72 /* from radeon_vid */ | |
73 #define GETREG(TYPE,PTR,OFFZ) (*((volatile TYPE*)((PTR)+(OFFZ)))) | |
74 #define SETREG(TYPE,PTR,OFFZ,VAL) (*((volatile TYPE*)((PTR)+(OFFZ))))=VAL | |
75 | |
76 #define readb(addr) GETREG(uint8_t,(uint32_t)(addr),0) | |
77 #define writeb(val,addr) SETREG(uint8_t,(uint32_t)(addr),0,val) | |
78 #define readl(addr) GETREG(uint32_t,(uint32_t)(addr),0) | |
79 #define writel(val,addr) SETREG(uint32_t,(uint32_t)(addr),0,val) | |
80 | |
81 static int mga_verbose = 0; | |
82 | |
83 /* for device detection */ | |
84 static int probed = 0; | |
85 static pciinfo_t pci_info; | |
86 | |
87 /* internal booleans */ | |
88 static int mga_vid_in_use = 0; | |
89 static int is_g400 = 0; | |
90 static int vid_src_ready = 0; | |
91 static int vid_overlay_on = 0; | |
92 | |
93 /* mapped physical addresses */ | |
94 static uint8_t *mga_mmio_base = 0; | |
95 static uint8_t *mga_mem_base = 0; | |
96 | |
97 static int mga_src_base = 0; /* YUV buffer position in video memory */ | |
98 | |
99 static uint32_t mga_ram_size = 0; /* how much megabytes videoram we have */ | |
100 | |
101 /* Graphic keys */ | |
102 static vidix_grkey_t mga_grkey; | |
103 | |
104 static int colkey_saved = 0; | |
105 static int colkey_on = 0; | |
106 static unsigned char colkey_color[4]; | |
107 static unsigned char colkey_mask[4]; | |
108 | |
109 /* for IRQ */ | |
110 static int mga_irq = -1; | |
111 | |
112 static int mga_next_frame = 0; | |
113 | |
114 static vidix_capability_t mga_cap = | |
115 { | |
116 "Matrox MGA G200/G4x0/G5x0 YUV Video", | |
117 "Aaron Holtzman, Arpad Gereoffy, Alex Beregszaszi, Nick Kurshev", | |
118 TYPE_OUTPUT, | |
119 { 0, 0, 0, 0 }, | |
120 2048, | |
121 2048, | |
122 4, | |
123 4, | |
124 -1, | |
125 FLAG_UPSCALER | FLAG_DOWNSCALER | FLAG_EQUALIZER, | |
126 VENDOR_MATROX, | |
127 -1, /* will be set in vixProbe */ | |
128 { 0, 0, 0, 0} | |
129 }; | |
130 | |
131 /* MATROX BES registers */ | |
132 typedef struct bes_registers_s | |
133 { | |
134 //BES Control | |
135 uint32_t besctl; | |
136 //BES Global control | |
137 uint32_t besglobctl; | |
138 //Luma control (brightness and contrast) | |
139 uint32_t beslumactl; | |
140 //Line pitch | |
141 uint32_t bespitch; | |
142 | |
143 //Buffer A-1 Chroma 3 plane org | |
144 uint32_t besa1c3org; | |
145 //Buffer A-1 Chroma org | |
146 uint32_t besa1corg; | |
147 //Buffer A-1 Luma org | |
148 uint32_t besa1org; | |
149 | |
150 //Buffer A-2 Chroma 3 plane org | |
151 uint32_t besa2c3org; | |
152 //Buffer A-2 Chroma org | |
153 uint32_t besa2corg; | |
154 //Buffer A-2 Luma org | |
155 uint32_t besa2org; | |
156 | |
157 //Buffer B-1 Chroma 3 plane org | |
158 uint32_t besb1c3org; | |
159 //Buffer B-1 Chroma org | |
160 uint32_t besb1corg; | |
161 //Buffer B-1 Luma org | |
162 uint32_t besb1org; | |
163 | |
164 //Buffer B-2 Chroma 3 plane org | |
165 uint32_t besb2c3org; | |
166 //Buffer B-2 Chroma org | |
167 uint32_t besb2corg; | |
168 //Buffer B-2 Luma org | |
169 uint32_t besb2org; | |
170 | |
171 //BES Horizontal coord | |
172 uint32_t beshcoord; | |
173 //BES Horizontal inverse scaling [5.14] | |
174 uint32_t beshiscal; | |
175 //BES Horizontal source start [10.14] (for scaling) | |
176 uint32_t beshsrcst; | |
177 //BES Horizontal source ending [10.14] (for scaling) | |
178 uint32_t beshsrcend; | |
179 //BES Horizontal source last | |
180 uint32_t beshsrclst; | |
181 | |
182 | |
183 //BES Vertical coord | |
184 uint32_t besvcoord; | |
185 //BES Vertical inverse scaling [5.14] | |
186 uint32_t besviscal; | |
187 //BES Field 1 vertical source last position | |
188 uint32_t besv1srclst; | |
189 //BES Field 1 weight start | |
190 uint32_t besv1wght; | |
191 //BES Field 2 vertical source last position | |
192 uint32_t besv2srclst; | |
193 //BES Field 2 weight start | |
194 uint32_t besv2wght; | |
195 | |
196 } bes_registers_t; | |
197 static bes_registers_t regs; | |
198 | |
199 #ifdef CRTC2 | |
200 typedef struct crtc2_registers_s | |
201 { | |
202 uint32_t c2ctl; | |
203 uint32_t c2datactl; | |
204 uint32_t c2misc; | |
205 uint32_t c2hparam; | |
206 uint32_t c2hsync; | |
207 uint32_t c2offset; | |
208 uint32_t c2pl2startadd0; | |
209 uint32_t c2pl2startadd1; | |
210 uint32_t c2pl3startadd0; | |
211 uint32_t c2pl3startadd1; | |
212 uint32_t c2preload; | |
213 uint32_t c2spicstartadd0; | |
214 uint32_t c2spicstartadd1; | |
215 uint32_t c2startadd0; | |
216 uint32_t c2startadd1; | |
217 uint32_t c2subpiclut; | |
218 uint32_t c2vcount; | |
219 uint32_t c2vparam; | |
220 uint32_t c2vsync; | |
221 } crtc2_registers_t; | |
222 static crtc2_registers_t cregs; | |
223 #endif | |
224 | |
225 //All register offsets are converted to word aligned offsets (32 bit) | |
226 //because we want all our register accesses to be 32 bits | |
227 #define VCOUNT 0x1e20 | |
228 | |
229 #define PALWTADD 0x3c00 // Index register for X_DATAREG port | |
230 #define X_DATAREG 0x3c0a | |
231 | |
232 #define XMULCTRL 0x19 | |
233 #define BPP_8 0x00 | |
234 #define BPP_15 0x01 | |
235 #define BPP_16 0x02 | |
236 #define BPP_24 0x03 | |
237 #define BPP_32_DIR 0x04 | |
238 #define BPP_32_PAL 0x07 | |
239 | |
240 #define XCOLMSK 0x40 | |
241 #define X_COLKEY 0x42 | |
242 #define XKEYOPMODE 0x51 | |
243 #define XCOLMSK0RED 0x52 | |
244 #define XCOLMSK0GREEN 0x53 | |
245 #define XCOLMSK0BLUE 0x54 | |
246 #define XCOLKEY0RED 0x55 | |
247 #define XCOLKEY0GREEN 0x56 | |
248 #define XCOLKEY0BLUE 0x57 | |
249 | |
250 #ifdef CRTC2 | |
251 /*CRTC2 registers*/ | |
252 #define XMISCCTRL 0x1e | |
253 #define C2CTL 0x3c10 | |
254 #define C2DATACTL 0x3c4c | |
255 #define C2MISC 0x3c44 | |
256 #define C2HPARAM 0x3c14 | |
257 #define C2HSYNC 0x3c18 | |
258 #define C2OFFSET 0x3c40 | |
259 #define C2PL2STARTADD0 0x3c30 // like BESA1CORG | |
260 #define C2PL2STARTADD1 0x3c34 // like BESA2CORG | |
261 #define C2PL3STARTADD0 0x3c38 // like BESA1C3ORG | |
262 #define C2PL3STARTADD1 0x3c3c // like BESA2C3ORG | |
263 #define C2PRELOAD 0x3c24 | |
264 #define C2SPICSTARTADD0 0x3c54 | |
265 #define C2SPICSTARTADD1 0x3c58 | |
266 #define C2STARTADD0 0x3c28 // like BESA1ORG | |
267 #define C2STARTADD1 0x3c2c // like BESA2ORG | |
268 #define C2SUBPICLUT 0x3c50 | |
269 #define C2VCOUNT 0x3c48 | |
270 #define C2VPARAM 0x3c1c | |
271 #define C2VSYNC 0x3c20 | |
272 #endif /* CRTC2 */ | |
273 | |
274 // Backend Scaler registers | |
275 #define BESCTL 0x3d20 | |
276 #define BESGLOBCTL 0x3dc0 | |
277 #define BESLUMACTL 0x3d40 | |
278 #define BESPITCH 0x3d24 | |
279 | |
280 #define BESA1C3ORG 0x3d60 | |
281 #define BESA1CORG 0x3d10 | |
282 #define BESA1ORG 0x3d00 | |
283 | |
284 #define BESA2C3ORG 0x3d64 | |
285 #define BESA2CORG 0x3d14 | |
286 #define BESA2ORG 0x3d04 | |
287 | |
288 #define BESB1C3ORG 0x3d68 | |
289 #define BESB1CORG 0x3d18 | |
290 #define BESB1ORG 0x3d08 | |
291 | |
292 #define BESB2C3ORG 0x3d6C | |
293 #define BESB2CORG 0x3d1C | |
294 #define BESB2ORG 0x3d0C | |
295 | |
296 #define BESHCOORD 0x3d28 | |
297 #define BESHISCAL 0x3d30 | |
298 #define BESHSRCEND 0x3d3C | |
299 #define BESHSRCLST 0x3d50 | |
300 #define BESHSRCST 0x3d38 | |
301 #define BESV1WGHT 0x3d48 | |
302 #define BESV2WGHT 0x3d4c | |
303 #define BESV1SRCLST 0x3d54 | |
304 #define BESV2SRCLST 0x3d58 | |
305 #define BESVISCAL 0x3d34 | |
306 #define BESVCOORD 0x3d2c | |
307 #define BESSTATUS 0x3dc4 | |
308 | |
309 #define CRTCX 0x1fd4 | |
310 #define CRTCD 0x1fd5 | |
311 #define IEN 0x1e1c | |
312 #define ICLEAR 0x1e18 | |
313 #define STATUS 0x1e14 | |
314 | |
315 | |
316 #ifdef CRTC2 | |
317 static void crtc2_frame_sel(int frame) | |
318 { | |
319 switch(frame) { | |
320 case 0: | |
321 cregs.c2pl2startadd0=regs.besa1corg; | |
322 cregs.c2pl3startadd0=regs.besa1c3org; | |
323 cregs.c2startadd0=regs.besa1org; | |
324 break; | |
325 case 1: | |
326 cregs.c2pl2startadd0=regs.besa2corg; | |
327 cregs.c2pl3startadd0=regs.besa2c3org; | |
328 cregs.c2startadd0=regs.besa2org; | |
329 break; | |
330 case 2: | |
331 cregs.c2pl2startadd0=regs.besb1corg; | |
332 cregs.c2pl3startadd0=regs.besb1c3org; | |
333 cregs.c2startadd0=regs.besb1org; | |
334 break; | |
335 case 3: | |
336 cregs.c2pl2startadd0=regs.besb2corg; | |
337 cregs.c2pl3startadd0=regs.besb2c3org; | |
338 cregs.c2startadd0=regs.besb2org; | |
339 break; | |
340 } | |
341 writel(cregs.c2startadd0, mga_mmio_base + C2STARTADD0); | |
342 writel(cregs.c2pl2startadd0, mga_mmio_base + C2PL2STARTADD0); | |
343 writel(cregs.c2pl3startadd0, mga_mmio_base + C2PL3STARTADD0); | |
344 } | |
345 #endif | |
346 | |
22857
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
347 static int mga_frame_select(unsigned int frame) |
22850 | 348 { |
349 mga_next_frame = frame; | |
350 if (mga_verbose>1) printf("[mga] frameselect: %d\n", mga_next_frame); | |
351 #if MGA_ALLOW_IRQ | |
352 if (mga_irq == -1) | |
353 #endif | |
354 { | |
355 //we don't need the vcount protection as we're only hitting | |
356 //one register (and it doesn't seem to be double buffered) | |
357 regs.besctl = (regs.besctl & ~0x07000000) + (mga_next_frame << 25); | |
358 writel( regs.besctl, mga_mmio_base + BESCTL ); | |
359 | |
360 // writel( regs.besglobctl + ((readl(mga_mmio_base + VCOUNT)+2)<<16), | |
361 writel( regs.besglobctl + (MGA_VSYNC_POS<<16), | |
362 mga_mmio_base + BESGLOBCTL); | |
363 #ifdef CRTC2 | |
364 crtc2_frame_sel(mga_next_frame); | |
365 #endif | |
366 } | |
367 | |
368 return(0); | |
369 } | |
370 | |
371 | |
372 static void mga_vid_write_regs(int restore) | |
373 { | |
374 //Make sure internal registers don't get updated until we're done | |
375 writel( (readl(mga_mmio_base + VCOUNT)-1)<<16, | |
376 mga_mmio_base + BESGLOBCTL); | |
377 | |
378 // color or coordinate keying | |
379 | |
380 if(restore && colkey_saved){ | |
381 // restore it | |
382 colkey_saved=0; | |
383 | |
384 // printf("[mga] Restoring colorkey (ON: %d %02X:%02X:%02X)\n", | |
385 // colkey_on,colkey_color[0],colkey_color[1],colkey_color[2]); | |
386 | |
387 // Set color key registers: | |
388 writeb( XKEYOPMODE, mga_mmio_base + PALWTADD); | |
389 writeb( colkey_on, mga_mmio_base + X_DATAREG); | |
390 | |
391 writeb( XCOLKEY0RED, mga_mmio_base + PALWTADD); | |
392 writeb( colkey_color[0], mga_mmio_base + X_DATAREG); | |
393 writeb( XCOLKEY0GREEN, mga_mmio_base + PALWTADD); | |
394 writeb( colkey_color[1], mga_mmio_base + X_DATAREG); | |
395 writeb( XCOLKEY0BLUE, mga_mmio_base + PALWTADD); | |
396 writeb( colkey_color[2], mga_mmio_base + X_DATAREG); | |
397 writeb( X_COLKEY, mga_mmio_base + PALWTADD); | |
398 writeb( colkey_color[3], mga_mmio_base + X_DATAREG); | |
399 | |
400 writeb( XCOLMSK0RED, mga_mmio_base + PALWTADD); | |
401 writeb( colkey_mask[0], mga_mmio_base + X_DATAREG); | |
402 writeb( XCOLMSK0GREEN, mga_mmio_base + PALWTADD); | |
403 writeb( colkey_mask[1], mga_mmio_base + X_DATAREG); | |
404 writeb( XCOLMSK0BLUE, mga_mmio_base + PALWTADD); | |
405 writeb( colkey_mask[2], mga_mmio_base + X_DATAREG); | |
406 writeb( XCOLMSK, mga_mmio_base + PALWTADD); | |
407 writeb( colkey_mask[3], mga_mmio_base + X_DATAREG); | |
408 | |
409 } else if(!colkey_saved){ | |
410 // save it | |
411 colkey_saved=1; | |
412 // Get color key registers: | |
413 writeb( XKEYOPMODE, mga_mmio_base + PALWTADD); | |
414 colkey_on=(unsigned char)readb(mga_mmio_base + X_DATAREG) & 1; | |
415 | |
416 writeb( XCOLKEY0RED, mga_mmio_base + PALWTADD); | |
417 colkey_color[0]=(unsigned char)readb(mga_mmio_base + X_DATAREG); | |
418 writeb( XCOLKEY0GREEN, mga_mmio_base + PALWTADD); | |
419 colkey_color[1]=(unsigned char)readb(mga_mmio_base + X_DATAREG); | |
420 writeb( XCOLKEY0BLUE, mga_mmio_base + PALWTADD); | |
421 colkey_color[2]=(unsigned char)readb(mga_mmio_base + X_DATAREG); | |
422 writeb( X_COLKEY, mga_mmio_base + PALWTADD); | |
423 colkey_color[3]=(unsigned char)readb(mga_mmio_base + X_DATAREG); | |
424 | |
425 writeb( XCOLMSK0RED, mga_mmio_base + PALWTADD); | |
426 colkey_mask[0]=(unsigned char)readb(mga_mmio_base + X_DATAREG); | |
427 writeb( XCOLMSK0GREEN, mga_mmio_base + PALWTADD); | |
428 colkey_mask[1]=(unsigned char)readb(mga_mmio_base + X_DATAREG); | |
429 writeb( XCOLMSK0BLUE, mga_mmio_base + PALWTADD); | |
430 colkey_mask[2]=(unsigned char)readb(mga_mmio_base + X_DATAREG); | |
431 writeb( XCOLMSK, mga_mmio_base + PALWTADD); | |
432 colkey_mask[3]=(unsigned char)readb(mga_mmio_base + X_DATAREG); | |
433 | |
434 // printf("[mga] Saved colorkey (ON: %d %02X:%02X:%02X)\n", | |
435 // colkey_on,colkey_color[0],colkey_color[1],colkey_color[2]); | |
436 | |
437 } | |
438 | |
439 if(!restore){ | |
440 writeb( XKEYOPMODE, mga_mmio_base + PALWTADD); | |
441 writeb( mga_grkey.ckey.op == CKEY_TRUE, mga_mmio_base + X_DATAREG); | |
442 if ( mga_grkey.ckey.op == CKEY_TRUE ) | |
443 { | |
444 uint32_t r=0, g=0, b=0; | |
445 | |
446 writeb( XMULCTRL, mga_mmio_base + PALWTADD); | |
447 switch (readb (mga_mmio_base + X_DATAREG)) | |
448 { | |
449 case BPP_8: | |
450 /* Need to look up the color index, just using | |
451 color 0 for now. */ | |
452 break; | |
453 | |
454 case BPP_15: | |
455 r = mga_grkey.ckey.red >> 3; | |
456 g = mga_grkey.ckey.green >> 3; | |
457 b = mga_grkey.ckey.blue >> 3; | |
458 break; | |
459 | |
460 case BPP_16: | |
461 r = mga_grkey.ckey.red >> 3; | |
462 g = mga_grkey.ckey.green >> 2; | |
463 b = mga_grkey.ckey.blue >> 3; | |
464 break; | |
465 | |
466 case BPP_24: | |
467 case BPP_32_DIR: | |
468 case BPP_32_PAL: | |
469 r = mga_grkey.ckey.red; | |
470 g = mga_grkey.ckey.green; | |
471 b = mga_grkey.ckey.blue; | |
472 break; | |
473 } | |
474 | |
475 // Enable colorkeying | |
476 writeb( XKEYOPMODE, mga_mmio_base + PALWTADD); | |
477 writeb( 1, mga_mmio_base + X_DATAREG); | |
478 | |
479 // Disable color keying on alpha channel | |
480 writeb( XCOLMSK, mga_mmio_base + PALWTADD); | |
481 writeb( 0x00, mga_mmio_base + X_DATAREG); | |
482 writeb( X_COLKEY, mga_mmio_base + PALWTADD); | |
483 writeb( 0x00, mga_mmio_base + X_DATAREG); | |
484 | |
485 | |
486 // Set up color key registers | |
487 writeb( XCOLKEY0RED, mga_mmio_base + PALWTADD); | |
488 writeb( r, mga_mmio_base + X_DATAREG); | |
489 writeb( XCOLKEY0GREEN, mga_mmio_base + PALWTADD); | |
490 writeb( g, mga_mmio_base + X_DATAREG); | |
491 writeb( XCOLKEY0BLUE, mga_mmio_base + PALWTADD); | |
492 writeb( b, mga_mmio_base + X_DATAREG); | |
493 | |
494 // Set up color key mask registers | |
495 writeb( XCOLMSK0RED, mga_mmio_base + PALWTADD); | |
496 writeb( 0xff, mga_mmio_base + X_DATAREG); | |
497 writeb( XCOLMSK0GREEN, mga_mmio_base + PALWTADD); | |
498 writeb( 0xff, mga_mmio_base + X_DATAREG); | |
499 writeb( XCOLMSK0BLUE, mga_mmio_base + PALWTADD); | |
500 writeb( 0xff, mga_mmio_base + X_DATAREG); | |
501 } | |
502 else | |
503 { | |
504 // Disable colorkeying | |
505 writeb( XKEYOPMODE, mga_mmio_base + PALWTADD); | |
506 writeb( 0, mga_mmio_base + X_DATAREG); | |
507 } | |
508 } | |
509 | |
510 // Backend Scaler | |
511 writel( regs.besctl, mga_mmio_base + BESCTL); | |
512 if(is_g400) | |
513 writel( regs.beslumactl, mga_mmio_base + BESLUMACTL); | |
514 writel( regs.bespitch, mga_mmio_base + BESPITCH); | |
515 | |
516 writel( regs.besa1org, mga_mmio_base + BESA1ORG); | |
517 writel( regs.besa1corg, mga_mmio_base + BESA1CORG); | |
518 writel( regs.besa2org, mga_mmio_base + BESA2ORG); | |
519 writel( regs.besa2corg, mga_mmio_base + BESA2CORG); | |
520 writel( regs.besb1org, mga_mmio_base + BESB1ORG); | |
521 writel( regs.besb1corg, mga_mmio_base + BESB1CORG); | |
522 writel( regs.besb2org, mga_mmio_base + BESB2ORG); | |
523 writel( regs.besb2corg, mga_mmio_base + BESB2CORG); | |
524 if(is_g400) | |
525 { | |
526 writel( regs.besa1c3org, mga_mmio_base + BESA1C3ORG); | |
527 writel( regs.besa2c3org, mga_mmio_base + BESA2C3ORG); | |
528 writel( regs.besb1c3org, mga_mmio_base + BESB1C3ORG); | |
529 writel( regs.besb2c3org, mga_mmio_base + BESB2C3ORG); | |
530 } | |
531 | |
532 writel( regs.beshcoord, mga_mmio_base + BESHCOORD); | |
533 writel( regs.beshiscal, mga_mmio_base + BESHISCAL); | |
534 writel( regs.beshsrcst, mga_mmio_base + BESHSRCST); | |
535 writel( regs.beshsrcend, mga_mmio_base + BESHSRCEND); | |
536 writel( regs.beshsrclst, mga_mmio_base + BESHSRCLST); | |
537 | |
538 writel( regs.besvcoord, mga_mmio_base + BESVCOORD); | |
539 writel( regs.besviscal, mga_mmio_base + BESVISCAL); | |
540 | |
541 writel( regs.besv1srclst, mga_mmio_base + BESV1SRCLST); | |
542 writel( regs.besv1wght, mga_mmio_base + BESV1WGHT); | |
543 writel( regs.besv2srclst, mga_mmio_base + BESV2SRCLST); | |
544 writel( regs.besv2wght, mga_mmio_base + BESV2WGHT); | |
545 | |
546 //update the registers somewhere between 1 and 2 frames from now. | |
547 writel( regs.besglobctl + ((readl(mga_mmio_base + VCOUNT)+2)<<16), | |
548 mga_mmio_base + BESGLOBCTL); | |
549 | |
550 if (mga_verbose > 1) | |
551 { | |
552 printf("[mga] wrote BES registers\n"); | |
553 printf("[mga] BESCTL = 0x%08x\n", | |
554 readl(mga_mmio_base + BESCTL)); | |
555 printf("[mga] BESGLOBCTL = 0x%08x\n", | |
556 readl(mga_mmio_base + BESGLOBCTL)); | |
557 printf("[mga] BESSTATUS= 0x%08x\n", | |
558 readl(mga_mmio_base + BESSTATUS)); | |
559 } | |
560 #ifdef CRTC2 | |
561 // printf("c2ctl:0x%08x c2datactl:0x%08x\n",readl(mga_mmio_base + C2CTL),readl(mga_mmio_base + C2DATACTL)); | |
562 // printf("c2misc:0x%08x\n",readl(mga_mmio_base + C2MISC)); | |
563 // printf("c2ctl:0x%08x c2datactl:0x%08x\n",cregs.c2ctl,cregs.c2datactl); | |
564 | |
565 // writel(cregs.c2ctl, mga_mmio_base + C2CTL); | |
566 | |
567 writel(((readl(mga_mmio_base + C2CTL) & ~0x03e00000) + (cregs.c2ctl & 0x03e00000)), mga_mmio_base + C2CTL); | |
568 writel(((readl(mga_mmio_base + C2DATACTL) & ~0x000000ff) + (cregs.c2datactl & 0x000000ff)), mga_mmio_base + C2DATACTL); | |
569 // ctrc2 | |
570 // disable CRTC2 acording to specs | |
571 // writel(cregs.c2ctl & 0xfffffff0, mga_mmio_base + C2CTL); | |
572 // je to treba ??? | |
573 // writeb((readb(mga_mmio_base + XMISCCTRL) & 0x19) | 0xa2, mga_mmio_base + XMISCCTRL); // MAFC - mfcsel & vdoutsel | |
574 // writeb((readb(mga_mmio_base + XMISCCTRL) & 0x19) | 0x92, mga_mmio_base + XMISCCTRL); | |
575 // writeb((readb(mga_mmio_base + XMISCCTRL) & ~0xe9) + 0xa2, mga_mmio_base + XMISCCTRL); | |
576 // writel(cregs.c2datactl, mga_mmio_base + C2DATACTL); | |
577 // writel(cregs.c2hparam, mga_mmio_base + C2HPARAM); | |
578 // writel(cregs.c2hsync, mga_mmio_base + C2HSYNC); | |
579 // writel(cregs.c2vparam, mga_mmio_base + C2VPARAM); | |
580 // writel(cregs.c2vsync, mga_mmio_base + C2VSYNC); | |
581 writel(cregs.c2misc, mga_mmio_base + C2MISC); | |
582 | |
583 if (mga_verbose > 1) printf("[mga] c2offset = %d\n",cregs.c2offset); | |
584 | |
585 writel(cregs.c2offset, mga_mmio_base + C2OFFSET); | |
586 writel(cregs.c2startadd0, mga_mmio_base + C2STARTADD0); | |
587 // writel(cregs.c2startadd1, mga_mmio_base + C2STARTADD1); | |
588 writel(cregs.c2pl2startadd0, mga_mmio_base + C2PL2STARTADD0); | |
589 // writel(cregs.c2pl2startadd1, mga_mmio_base + C2PL2STARTADD1); | |
590 writel(cregs.c2pl3startadd0, mga_mmio_base + C2PL3STARTADD0); | |
591 // writel(cregs.c2pl3startadd1, mga_mmio_base + C2PL3STARTADD1); | |
592 writel(cregs.c2spicstartadd0, mga_mmio_base + C2SPICSTARTADD0); | |
593 // writel(cregs.c2spicstartadd1, mga_mmio_base + C2SPICSTARTADD1); | |
594 // writel(cregs.c2subpiclut, mga_mmio_base + C2SUBPICLUT); | |
595 // writel(cregs.c2preload, mga_mmio_base + C2PRELOAD); | |
596 // finaly enable everything | |
597 // writel(cregs.c2ctl, mga_mmio_base + C2CTL); | |
598 // printf("c2ctl:0x%08x c2datactl:0x%08x\n",readl(mga_mmio_base + C2CTL),readl(mga_mmio_base + C2DATACTL)); | |
599 // printf("c2misc:0x%08x\n", readl(mga_mmio_base + C2MISC)); | |
600 #endif | |
601 } | |
602 | |
603 #ifdef MGA_ALLOW_IRQ | |
604 static void enable_irq(){ | |
605 long int cc; | |
606 | |
607 cc = readl(mga_mmio_base + IEN); | |
608 // printf("*** !!! IRQREG = %d\n", (int)(cc&0xff)); | |
609 | |
610 writeb( 0x11, mga_mmio_base + CRTCX); | |
611 | |
612 writeb(0x20, mga_mmio_base + CRTCD ); /* clear 0, enable off */ | |
613 writeb(0x00, mga_mmio_base + CRTCD ); /* enable on */ | |
614 writeb(0x10, mga_mmio_base + CRTCD ); /* clear = 1 */ | |
615 | |
616 writel( regs.besglobctl , mga_mmio_base + BESGLOBCTL); | |
617 | |
618 return; | |
619 } | |
620 | |
621 static void disable_irq() | |
622 { | |
623 writeb( 0x11, mga_mmio_base + CRTCX); | |
624 writeb(0x20, mga_mmio_base + CRTCD ); /* clear 0, enable off */ | |
625 | |
626 return; | |
627 } | |
628 | |
629 void mga_handle_irq(int irq, void *dev_id/*, struct pt_regs *pregs*/) { | |
630 // static int frame=0; | |
631 // static int counter=0; | |
632 long int cc; | |
633 // if ( ! mga_enabled_flag ) return; | |
634 | |
635 // printf("vcount = %d\n",readl(mga_mmio_base + VCOUNT)); | |
636 | |
637 //printf("mga_interrupt #%d\n", irq); | |
638 | |
639 if ( irq != -1 ) { | |
640 | |
641 cc = readl(mga_mmio_base + STATUS); | |
642 if ( ! (cc & 0x10) ) return; /* vsyncpen */ | |
643 // debug_irqcnt++; | |
644 } | |
645 | |
646 // if ( debug_irqignore ) { | |
647 // debug_irqignore = 0; | |
648 | |
649 | |
650 /* | |
651 if ( mga_conf_deinterlace ) { | |
652 if ( mga_first_field ) { | |
653 // printf("mga_interrupt first field\n"); | |
654 if ( syncfb_interrupt() ) | |
655 mga_first_field = 0; | |
656 } else { | |
657 // printf("mga_interrupt second field\n"); | |
658 mga_select_buffer( mga_current_field | 2 ); | |
659 mga_first_field = 1; | |
660 } | |
661 } else { | |
662 syncfb_interrupt(); | |
663 } | |
664 */ | |
665 | |
666 // frame=(frame+1)&1; | |
667 regs.besctl = (regs.besctl & ~0x07000000) + (mga_next_frame << 25); | |
668 writel( regs.besctl, mga_mmio_base + BESCTL ); | |
669 | |
670 #ifdef CRTC2 | |
671 // sem pridat vyber obrazku !!!! | |
672 crtc2_frame_sel(mga_next_frame); | |
673 #endif | |
674 | |
675 #if 0 | |
676 ++counter; | |
677 if(!(counter&63)){ | |
678 printf("mga irq counter = %d\n",counter); | |
679 } | |
680 #endif | |
681 | |
682 // } else { | |
683 // debug_irqignore = 1; | |
684 // } | |
685 | |
686 if ( irq != -1 ) { | |
687 writeb( 0x11, mga_mmio_base + CRTCX); | |
688 writeb( 0, mga_mmio_base + CRTCD ); | |
689 writeb( 0x10, mga_mmio_base + CRTCD ); | |
690 } | |
691 | |
692 // writel( regs.besglobctl, mga_mmio_base + BESGLOBCTL); | |
693 | |
694 | |
695 return; | |
696 | |
697 } | |
698 #endif /* MGA_ALLOW_IRQ */ | |
699 | |
22857
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
700 static int mga_config_playback(vidix_playback_t *config) |
22850 | 701 { |
702 unsigned int i; | |
703 int x, y, sw, sh, dw, dh; | |
704 int besleft, bestop, ifactor, ofsleft, ofstop, baseadrofs, weight, weights; | |
705 #ifdef CRTC2 | |
706 #define right_margin 0 | |
707 #define left_margin 18 | |
708 #define hsync_len 46 | |
709 #define lower_margin 10 | |
710 #define vsync_len 4 | |
711 #define upper_margin 39 | |
712 | |
713 unsigned int hdispend = (config->src.w + 31) & ~31; | |
714 unsigned int hsyncstart = hdispend + (right_margin & ~7); | |
715 unsigned int hsyncend = hsyncstart + (hsync_len & ~7); | |
716 unsigned int htotal = hsyncend + (left_margin & ~7); | |
717 unsigned int vdispend = config->src.h; | |
718 unsigned int vsyncstart = vdispend + lower_margin; | |
719 unsigned int vsyncend = vsyncstart + vsync_len; | |
720 unsigned int vtotal = vsyncend + upper_margin; | |
721 #endif | |
722 | |
723 if ((config->num_frames < 1) || (config->num_frames > 4)) | |
724 { | |
725 printf("[mga] illegal num_frames: %d, setting to %d\n", | |
726 config->num_frames, MGA_DEFAULT_FRAMES); | |
727 config->num_frames = MGA_DEFAULT_FRAMES; | |
728 } | |
729 | |
730 x = config->dest.x; | |
731 y = config->dest.y; | |
732 sw = config->src.w; | |
733 sh = config->src.h; | |
734 dw = config->dest.w; | |
735 dh = config->dest.h; | |
736 | |
737 config->dest.pitch.y=32; | |
738 config->dest.pitch.u=config->dest.pitch.v=32; | |
739 | |
740 if (mga_verbose) printf("[mga] Setting up a %dx%d-%dx%d video window (src %dx%d) format %X\n", | |
741 dw, dh, x, y, sw, sh, config->fourcc); | |
742 | |
743 if ((sw < 4) || (sh < 4) || (dw < 4) || (dh < 4)) | |
744 { | |
745 printf("[mga] Invalid src/dest dimensions\n"); | |
746 return(EINVAL); | |
747 } | |
748 | |
749 //FIXME check that window is valid and inside desktop | |
750 | |
751 // printf("[mga] vcount = %d\n", readl(mga_mmio_base + VCOUNT)); | |
752 | |
753 sw+=sw&1; | |
754 switch(config->fourcc) | |
755 { | |
756 case IMGFMT_I420: | |
757 case IMGFMT_IYUV: | |
758 case IMGFMT_YV12: | |
759 sh+=sh&1; | |
760 config->frame_size = ((sw + 31) & ~31) * sh + (((sw + 31) & ~31) * sh) / 2; | |
761 break; | |
762 case IMGFMT_YUY2: | |
763 case IMGFMT_UYVY: | |
764 config->frame_size = ((sw + 31) & ~31) * sh * 2; | |
765 break; | |
766 default: | |
767 printf("[mga] Unsupported pixel format: %x\n", config->fourcc); | |
768 return(ENOTSUP); | |
769 } | |
770 | |
771 config->offsets[0] = 0; | |
772 // config->offsets[1] = config->frame_size; | |
773 // config->offsets[2] = 2*config->frame_size; | |
774 // config->offsets[3] = 3*config->frame_size; | |
775 for (i = 1; i < config->num_frames+1; i++) | |
776 config->offsets[i] = i*config->frame_size; | |
777 | |
778 config->offset.y=0; | |
779 if(config->fourcc == IMGFMT_I420 || config->fourcc == IMGFMT_IYUV) | |
780 { | |
781 config->offset.u=((sw + 31) & ~31) * sh; | |
782 config->offset.v=config->offset.u+((sw + 31) & ~31) * sh /4; | |
783 } | |
784 else { | |
785 config->offset.v=((sw + 31) & ~31) * sh; | |
786 config->offset.u=config->offset.v+((sw + 31) & ~31) * sh /4; | |
787 } | |
788 | |
789 //FIXME figure out a better way to allocate memory on card | |
790 //allocate 2 megs | |
791 //mga_src_base = mga_mem_base + (MGA_VIDMEM_SIZE-2) * 0x100000; | |
792 //mga_src_base = (MGA_VIDMEM_SIZE-3) * 0x100000; | |
793 | |
794 mga_src_base = (mga_ram_size*0x100000-config->num_frames*config->frame_size); | |
795 if (mga_src_base < 0) | |
796 { | |
797 printf("[mga] not enough memory for frames!\n"); | |
798 return(EFAULT); | |
799 } | |
800 mga_src_base &= (~0xFFFF); /* 64k boundary */ | |
801 if (mga_verbose > 1) printf("[mga] YUV buffer base: %#x\n", mga_src_base); | |
802 | |
803 config->dga_addr = mga_mem_base + mga_src_base; | |
804 | |
805 /* for G200 set Interleaved UV planes */ | |
806 if (!is_g400) | |
807 config->flags = VID_PLAY_INTERLEAVED_UV | INTERLEAVING_UV; | |
808 | |
809 //Setup the BES registers for a three plane 4:2:0 video source | |
810 | |
811 regs.besglobctl = 0; | |
812 | |
813 switch(config->fourcc) | |
814 { | |
815 case IMGFMT_YV12: | |
816 case IMGFMT_I420: | |
817 case IMGFMT_IYUV: | |
818 regs.besctl = 1 // BES enabled | |
819 + (0<<6) // even start polarity | |
820 + (1<<10) // x filtering enabled | |
821 + (1<<11) // y filtering enabled | |
822 + (1<<16) // chroma upsampling | |
823 + (1<<17) // 4:2:0 mode | |
824 + (1<<18); // dither enabled | |
825 #if 0 | |
826 if(is_g400) | |
827 { | |
828 //zoom disabled, zoom filter disabled, 420 3 plane format, proc amp | |
829 //disabled, rgb mode disabled | |
830 regs.besglobctl = (1<<5); | |
831 } | |
832 else | |
833 { | |
834 //zoom disabled, zoom filter disabled, Cb samples in 0246, Cr | |
835 //in 1357, BES register update on besvcnt | |
836 regs.besglobctl = 0; | |
837 } | |
838 #endif | |
839 break; | |
840 | |
841 case IMGFMT_YUY2: | |
842 regs.besctl = 1 // BES enabled | |
843 + (0<<6) // even start polarity | |
844 + (1<<10) // x filtering enabled | |
845 + (1<<11) // y filtering enabled | |
846 + (1<<16) // chroma upsampling | |
847 + (0<<17) // 4:2:2 mode | |
848 + (1<<18); // dither enabled | |
849 | |
850 regs.besglobctl = 0; // YUY2 format selected | |
851 break; | |
852 | |
853 case IMGFMT_UYVY: | |
854 regs.besctl = 1 // BES enabled | |
855 + (0<<6) // even start polarity | |
856 + (1<<10) // x filtering enabled | |
857 + (1<<11) // y filtering enabled | |
858 + (1<<16) // chroma upsampling | |
859 + (0<<17) // 4:2:2 mode | |
860 + (1<<18); // dither enabled | |
861 | |
862 regs.besglobctl = 1<<6; // UYVY format selected | |
863 break; | |
864 | |
865 } | |
866 | |
867 //Disable contrast and brightness control | |
868 regs.besglobctl |= (1<<5) + (1<<7); | |
869 regs.beslumactl = (0x7f << 16) + (0x80<<0); | |
870 regs.beslumactl = 0x80<<0; | |
871 | |
872 //Setup destination window boundaries | |
873 besleft = x > 0 ? x : 0; | |
874 bestop = y > 0 ? y : 0; | |
875 regs.beshcoord = (besleft<<16) + (x + dw-1); | |
876 regs.besvcoord = (bestop<<16) + (y + dh-1); | |
877 | |
878 //Setup source dimensions | |
879 regs.beshsrclst = (sw - 1) << 16; | |
880 regs.bespitch = (sw + 31) & ~31 ; | |
881 | |
882 //Setup horizontal scaling | |
883 ifactor = ((sw-1)<<14)/(dw-1); | |
884 ofsleft = besleft - x; | |
885 | |
886 regs.beshiscal = ifactor<<2; | |
887 regs.beshsrcst = (ofsleft*ifactor)<<2; | |
888 regs.beshsrcend = regs.beshsrcst + (((dw - ofsleft - 1) * ifactor) << 2); | |
889 | |
890 //Setup vertical scaling | |
891 ifactor = ((sh-1)<<14)/(dh-1); | |
892 ofstop = bestop - y; | |
893 | |
894 regs.besviscal = ifactor<<2; | |
895 | |
896 baseadrofs = ((ofstop*regs.besviscal)>>16)*regs.bespitch; | |
897 //frame_size = ((sw + 31) & ~31) * sh + (((sw + 31) & ~31) * sh) / 2; | |
898 regs.besa1org = (uint32_t) mga_src_base + baseadrofs; | |
899 regs.besa2org = (uint32_t) mga_src_base + baseadrofs + 1*config->frame_size; | |
900 regs.besb1org = (uint32_t) mga_src_base + baseadrofs + 2*config->frame_size; | |
901 regs.besb2org = (uint32_t) mga_src_base + baseadrofs + 3*config->frame_size; | |
902 | |
903 if(config->fourcc==IMGFMT_YV12 | |
904 ||config->fourcc==IMGFMT_IYUV | |
905 ||config->fourcc==IMGFMT_I420 | |
906 ){ | |
907 // planar YUV frames: | |
908 if (is_g400) | |
909 baseadrofs = (((ofstop*regs.besviscal)/4)>>16)*regs.bespitch; | |
910 else | |
911 baseadrofs = (((ofstop*regs.besviscal)/2)>>16)*regs.bespitch; | |
912 | |
913 if(config->fourcc==IMGFMT_YV12){ | |
914 regs.besa1corg = (uint32_t) mga_src_base + baseadrofs + regs.bespitch * sh ; | |
915 regs.besa2corg = (uint32_t) mga_src_base + baseadrofs + 1*config->frame_size + regs.bespitch * sh; | |
916 regs.besb1corg = (uint32_t) mga_src_base + baseadrofs + 2*config->frame_size + regs.bespitch * sh; | |
917 regs.besb2corg = (uint32_t) mga_src_base + baseadrofs + 3*config->frame_size + regs.bespitch * sh; | |
918 regs.besa1c3org = regs.besa1corg + ((regs.bespitch * sh) / 4); | |
919 regs.besa2c3org = regs.besa2corg + ((regs.bespitch * sh) / 4); | |
920 regs.besb1c3org = regs.besb1corg + ((regs.bespitch * sh) / 4); | |
921 regs.besb2c3org = regs.besb2corg + ((regs.bespitch * sh) / 4); | |
922 } else { | |
923 regs.besa1c3org = (uint32_t) mga_src_base + baseadrofs + regs.bespitch * sh ; | |
924 regs.besa2c3org = (uint32_t) mga_src_base + baseadrofs + 1*config->frame_size + regs.bespitch * sh; | |
925 regs.besb1c3org = (uint32_t) mga_src_base + baseadrofs + 2*config->frame_size + regs.bespitch * sh; | |
926 regs.besb2c3org = (uint32_t) mga_src_base + baseadrofs + 3*config->frame_size + regs.bespitch * sh; | |
927 regs.besa1corg = regs.besa1c3org + ((regs.bespitch * sh) / 4); | |
928 regs.besa2corg = regs.besa2c3org + ((regs.bespitch * sh) / 4); | |
929 regs.besb1corg = regs.besb1c3org + ((regs.bespitch * sh) / 4); | |
930 regs.besb2corg = regs.besb2c3org + ((regs.bespitch * sh) / 4); | |
931 } | |
932 | |
933 } | |
934 | |
935 weight = ofstop * (regs.besviscal >> 2); | |
936 weights = weight < 0 ? 1 : 0; | |
937 regs.besv2wght = regs.besv1wght = (weights << 16) + ((weight & 0x3FFF) << 2); | |
938 regs.besv2srclst = regs.besv1srclst = sh - 1 - (((ofstop * regs.besviscal) >> 16) & 0x03FF); | |
939 | |
940 #ifdef CRTC2 | |
941 // pridat hlavni registry - tj. casovani ... | |
942 | |
943 | |
944 switch(config->fourcc){ | |
945 case IMGFMT_YV12: | |
946 case IMGFMT_I420: | |
947 case IMGFMT_IYUV: | |
948 cregs.c2ctl = 1 // CRTC2 enabled | |
949 + (1<<1) // external clock | |
950 + (0<<2) // external clock | |
951 + (1<<3) // pixel clock enable - not needed ??? | |
952 + (0<<4) // high prioryty req | |
953 + (1<<5) // high prioryty req | |
954 + (0<<6) // high prioryty req | |
955 + (1<<8) // high prioryty req max | |
956 + (0<<9) // high prioryty req max | |
957 + (0<<10) // high prioryty req max | |
958 + (0<<20) // CRTC1 to DAC | |
959 + (1<<21) // 420 mode | |
960 + (1<<22) // 420 mode | |
961 + (1<<23) // 420 mode | |
962 + (0<<24) // single chroma line for 420 mode - need to be corrected | |
963 + (0<<25) /*/ interlace mode - need to be corrected*/ | |
964 + (0<<26) // field legth polariry | |
965 + (0<<27) // field identification polariry | |
966 + (1<<28) // VIDRST detection mode | |
967 + (0<<29) // VIDRST detection mode | |
968 + (1<<30) // Horizontal counter preload | |
969 + (1<<31) // Vertical counter preload | |
970 ; | |
971 cregs.c2datactl = 1 // disable dither - propably not needed, we are already in YUV mode | |
972 + (1<<1) // Y filter enable | |
973 + (1<<2) // CbCr filter enable | |
974 + (0<<3) // subpicture enable (disabled) | |
975 + (0<<4) // NTSC enable (disabled - PAL) | |
976 + (0<<5) // C2 static subpicture enable (disabled) | |
977 + (0<<6) // C2 subpicture offset division (disabled) | |
978 + (0<<7) // 422 subformat selection ! | |
979 /* + (0<<8) // 15 bpp high alpha | |
980 + (0<<9) // 15 bpp high alpha | |
981 + (0<<10) // 15 bpp high alpha | |
982 + (0<<11) // 15 bpp high alpha | |
983 + (0<<12) // 15 bpp high alpha | |
984 + (0<<13) // 15 bpp high alpha | |
985 + (0<<14) // 15 bpp high alpha | |
986 + (0<<15) // 15 bpp high alpha | |
987 + (0<<16) // 15 bpp low alpha | |
988 + (0<<17) // 15 bpp low alpha | |
989 + (0<<18) // 15 bpp low alpha | |
990 + (0<<19) // 15 bpp low alpha | |
991 + (0<<20) // 15 bpp low alpha | |
992 + (0<<21) // 15 bpp low alpha | |
993 + (0<<22) // 15 bpp low alpha | |
994 + (0<<23) // 15 bpp low alpha | |
995 + (0<<24) // static subpicture key | |
996 + (0<<25) // static subpicture key | |
997 + (0<<26) // static subpicture key | |
998 + (0<<27) // static subpicture key | |
999 + (0<<28) // static subpicture key | |
1000 */ ; | |
1001 break; | |
1002 | |
1003 case IMGFMT_YUY2: | |
1004 cregs.c2ctl = 1 // CRTC2 enabled | |
1005 + (1<<1) // external clock | |
1006 + (0<<2) // external clock | |
1007 + (1<<3) // pixel clock enable - not needed ??? | |
1008 + (0<<4) // high prioryty req - acc to spec | |
1009 + (1<<5) // high prioryty req | |
1010 + (0<<6) // high prioryty req | |
1011 // 7 reserved | |
1012 + (1<<8) // high prioryty req max | |
1013 + (0<<9) // high prioryty req max | |
1014 + (0<<10) // high prioryty req max | |
1015 // 11-19 reserved | |
1016 + (0<<20) // CRTC1 to DAC | |
1017 + (1<<21) // 422 mode | |
1018 + (0<<22) // 422 mode | |
1019 + (1<<23) // 422 mode | |
1020 + (0<<24) // single chroma line for 420 mode - need to be corrected | |
1021 + (0<<25) /*/ interlace mode - need to be corrected*/ | |
1022 + (0<<26) // field legth polariry | |
1023 + (0<<27) // field identification polariry | |
1024 + (1<<28) // VIDRST detection mode | |
1025 + (0<<29) // VIDRST detection mode | |
1026 + (1<<30) // Horizontal counter preload | |
1027 + (1<<31) // Vertical counter preload | |
1028 ; | |
1029 cregs.c2datactl = 1 // disable dither - propably not needed, we are already in YUV mode | |
1030 + (1<<1) // Y filter enable | |
1031 + (1<<2) // CbCr filter enable | |
1032 + (0<<3) // subpicture enable (disabled) | |
1033 + (0<<4) // NTSC enable (disabled - PAL) | |
1034 + (0<<5) // C2 static subpicture enable (disabled) | |
1035 + (0<<6) // C2 subpicture offset division (disabled) | |
1036 + (0<<7) // 422 subformat selection ! | |
1037 /* + (0<<8) // 15 bpp high alpha | |
1038 + (0<<9) // 15 bpp high alpha | |
1039 + (0<<10) // 15 bpp high alpha | |
1040 + (0<<11) // 15 bpp high alpha | |
1041 + (0<<12) // 15 bpp high alpha | |
1042 + (0<<13) // 15 bpp high alpha | |
1043 + (0<<14) // 15 bpp high alpha | |
1044 + (0<<15) // 15 bpp high alpha | |
1045 + (0<<16) // 15 bpp low alpha | |
1046 + (0<<17) // 15 bpp low alpha | |
1047 + (0<<18) // 15 bpp low alpha | |
1048 + (0<<19) // 15 bpp low alpha | |
1049 + (0<<20) // 15 bpp low alpha | |
1050 + (0<<21) // 15 bpp low alpha | |
1051 + (0<<22) // 15 bpp low alpha | |
1052 + (0<<23) // 15 bpp low alpha | |
1053 + (0<<24) // static subpicture key | |
1054 + (0<<25) // static subpicture key | |
1055 + (0<<26) // static subpicture key | |
1056 + (0<<27) // static subpicture key | |
1057 + (0<<28) // static subpicture key | |
1058 */ ; | |
1059 break; | |
1060 | |
1061 case IMGFMT_UYVY: | |
1062 cregs.c2ctl = 1 // CRTC2 enabled | |
1063 + (1<<1) // external clock | |
1064 + (0<<2) // external clock | |
1065 + (1<<3) // pixel clock enable - not needed ??? | |
1066 + (0<<4) // high prioryty req | |
1067 + (1<<5) // high prioryty req | |
1068 + (0<<6) // high prioryty req | |
1069 + (1<<8) // high prioryty req max | |
1070 + (0<<9) // high prioryty req max | |
1071 + (0<<10) // high prioryty req max | |
1072 + (0<<20) // CRTC1 to DAC | |
1073 + (1<<21) // 422 mode | |
1074 + (0<<22) // 422 mode | |
1075 + (1<<23) // 422 mode | |
1076 + (1<<24) // single chroma line for 420 mode - need to be corrected | |
1077 + (1<<25) /*/ interlace mode - need to be corrected*/ | |
1078 + (0<<26) // field legth polariry | |
1079 + (0<<27) // field identification polariry | |
1080 + (1<<28) // VIDRST detection mode | |
1081 + (0<<29) // VIDRST detection mode | |
1082 + (1<<30) // Horizontal counter preload | |
1083 + (1<<31) // Vertical counter preload | |
1084 ; | |
1085 cregs.c2datactl = 0 // enable dither - propably not needed, we are already in YUV mode | |
1086 + (1<<1) // Y filter enable | |
1087 + (1<<2) // CbCr filter enable | |
1088 + (0<<3) // subpicture enable (disabled) | |
1089 + (0<<4) // NTSC enable (disabled - PAL) | |
1090 + (0<<5) // C2 static subpicture enable (disabled) | |
1091 + (0<<6) // C2 subpicture offset division (disabled) | |
1092 + (1<<7) // 422 subformat selection ! | |
1093 /* + (0<<8) // 15 bpp high alpha | |
1094 + (0<<9) // 15 bpp high alpha | |
1095 + (0<<10) // 15 bpp high alpha | |
1096 + (0<<11) // 15 bpp high alpha | |
1097 + (0<<12) // 15 bpp high alpha | |
1098 + (0<<13) // 15 bpp high alpha | |
1099 + (0<<14) // 15 bpp high alpha | |
1100 + (0<<15) // 15 bpp high alpha | |
1101 + (0<<16) // 15 bpp low alpha | |
1102 + (0<<17) // 15 bpp low alpha | |
1103 + (0<<18) // 15 bpp low alpha | |
1104 + (0<<19) // 15 bpp low alpha | |
1105 + (0<<20) // 15 bpp low alpha | |
1106 + (0<<21) // 15 bpp low alpha | |
1107 + (0<<22) // 15 bpp low alpha | |
1108 + (0<<23) // 15 bpp low alpha | |
1109 + (0<<24) // static subpicture key | |
1110 + (0<<25) // static subpicture key | |
1111 + (0<<26) // static subpicture key | |
1112 + (0<<27) // static subpicture key | |
1113 + (0<<28) // static subpicture key | |
1114 */ ; | |
1115 break; | |
1116 } | |
1117 | |
1118 cregs.c2hparam=((hdispend - 8) << 16) | (htotal - 8); | |
1119 cregs.c2hsync=((hsyncend - 8) << 16) | (hsyncstart - 8); | |
1120 | |
1121 cregs.c2misc=0 // CRTCV2 656 togg f0 | |
1122 +(0<<1) // CRTCV2 656 togg f0 | |
1123 +(0<<2) // CRTCV2 656 togg f0 | |
1124 +(0<<4) // CRTCV2 656 togg f1 | |
1125 +(0<<5) // CRTCV2 656 togg f1 | |
1126 +(0<<6) // CRTCV2 656 togg f1 | |
1127 +(0<<8) // Hsync active high | |
1128 +(0<<9) // Vsync active high | |
1129 // 16-27 c2vlinecomp - nevim co tam dat | |
1130 ; | |
1131 cregs.c2offset=(regs.bespitch << 1); | |
1132 | |
1133 cregs.c2pl2startadd0=regs.besa1corg; | |
1134 // cregs.c2pl2startadd1=regs.besa2corg; | |
1135 cregs.c2pl3startadd0=regs.besa1c3org; | |
1136 // cregs.c2pl3startadd1=regs.besa2c3org; | |
1137 | |
1138 cregs.c2preload=(vsyncstart << 16) | (hsyncstart); // from | |
1139 | |
1140 cregs.c2spicstartadd0=0; // not used | |
1141 // cregs.c2spicstartadd1=0; // not used | |
1142 | |
1143 cregs.c2startadd0=regs.besa1org; | |
1144 // cregs.c2startadd1=regs.besa2org; | |
1145 | |
1146 cregs.c2subpiclut=0; //not used | |
1147 | |
1148 cregs.c2vparam=((vdispend - 1) << 16) | (vtotal - 1); | |
1149 cregs.c2vsync=((vsyncend - 1) << 16) | (vsyncstart - 1); | |
1150 #endif /* CRTC2 */ | |
1151 | |
1152 mga_vid_write_regs(0); | |
1153 return(0); | |
1154 } | |
1155 | |
22857
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
1156 static int mga_playback_on(void) |
22850 | 1157 { |
1158 if (mga_verbose) printf("[mga] playback on\n"); | |
1159 | |
1160 vid_src_ready = 1; | |
1161 if(vid_overlay_on) | |
1162 { | |
1163 regs.besctl |= 1; | |
1164 mga_vid_write_regs(0); | |
1165 } | |
1166 #ifdef MGA_ALLOW_IRQ | |
1167 if (mga_irq != -1) | |
1168 enable_irq(); | |
1169 #endif | |
1170 mga_next_frame=0; | |
1171 | |
1172 return(0); | |
1173 } | |
1174 | |
22857
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
1175 static int mga_playback_off(void) |
22850 | 1176 { |
1177 if (mga_verbose) printf("[mga] playback off\n"); | |
1178 | |
1179 vid_src_ready = 0; | |
1180 #ifdef MGA_ALLOW_IRQ | |
1181 if (mga_irq != -1) | |
1182 disable_irq(); | |
1183 #endif | |
1184 regs.besctl &= ~1; | |
1185 regs.besglobctl &= ~(1<<6); /* UYVY format selected */ | |
1186 mga_vid_write_regs(0); | |
1187 | |
1188 return(0); | |
1189 } | |
1190 | |
22857
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
1191 static int mga_probe(int verbose,int force) |
22850 | 1192 { |
1193 pciinfo_t lst[MAX_PCI_DEVICES]; | |
1194 unsigned int i, num_pci; | |
1195 int err; | |
1196 | |
1197 if (verbose) printf("[mga] probe\n"); | |
1198 | |
1199 mga_verbose = verbose; | |
1200 | |
1201 is_g400 = -1; | |
1202 | |
1203 err = pci_scan(lst, &num_pci); | |
1204 if (err) | |
1205 { | |
1206 printf("[mga] Error occurred during pci scan: %s\n", strerror(err)); | |
1207 return(err); | |
1208 } | |
1209 | |
1210 if (mga_verbose) | |
1211 printf("[mga] found %d pci devices\n", num_pci); | |
1212 | |
1213 for (i = 0; i < num_pci; i++) | |
1214 { | |
1215 if (mga_verbose > 1) | |
1216 printf("[mga] pci[%d] vendor: %d device: %d\n", | |
1217 i, lst[i].vendor, lst[i].device); | |
1218 if (lst[i].vendor == VENDOR_MATROX) | |
1219 { | |
1220 if ((lst[i].command & PCI_COMMAND_IO) == 0) | |
1221 { | |
1222 printf("[mga] Device is disabled, ignoring\n"); | |
1223 continue; | |
1224 } | |
1225 switch(lst[i].device) | |
1226 { | |
1227 case DEVICE_MATROX_MGA_G550_AGP: | |
1228 printf("[mga] Found MGA G550\n"); | |
1229 is_g400 = 1; | |
1230 goto card_found; | |
1231 case DEVICE_MATROX_MGA_G400_AGP: | |
1232 printf("[mga] Found MGA G400/G450\n"); | |
1233 is_g400 = 1; | |
1234 goto card_found; | |
1235 case DEVICE_MATROX_MGA_G200_AGP: | |
1236 printf("[mga] Found MGA G200 AGP\n"); | |
1237 is_g400 = 0; | |
1238 goto card_found; | |
1239 case DEVICE_MATROX_MGA_G200: | |
1240 printf("[mga] Found MGA G200 PCI\n"); | |
1241 is_g400 = 0; | |
1242 goto card_found; | |
1243 } | |
1244 } | |
1245 } | |
1246 | |
1247 if (is_g400 == -1) | |
1248 { | |
1249 if (verbose) printf("[mga] Can't find chip\n"); | |
1250 return(ENXIO); | |
1251 } | |
1252 | |
1253 card_found: | |
1254 probed = 1; | |
1255 memcpy(&pci_info, &lst[i], sizeof(pciinfo_t)); | |
1256 | |
1257 mga_cap.device_id = pci_info.device; /* set device id in capabilites */ | |
1258 | |
1259 return(0); | |
1260 } | |
1261 | |
22857
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
1262 static int mga_init(void) |
22850 | 1263 { |
1264 unsigned int card_option = 0; | |
1265 int err; | |
1266 | |
1267 if (mga_verbose) printf("[mga] init\n"); | |
1268 | |
1269 mga_vid_in_use = 0; | |
1270 | |
1271 printf("Matrox MGA G200/G400/G450 YUV Video interface v2.01 (c) Aaron Holtzman & A'rpi\n"); | |
1272 #ifdef CRCT2 | |
1273 printf("Driver compiled with TV-out (second-head) support\n"); | |
1274 #endif | |
1275 | |
1276 if (!probed) | |
1277 { | |
1278 printf("[mga] driver was not probed but is being initializing\n"); | |
1279 return(EINTR); | |
1280 } | |
1281 | |
1282 #ifdef MGA_PCICONFIG_MEMDETECT | |
1283 pci_config_read(pci_info.bus, pci_info.card, pci_info.func, | |
1284 0x40, 4, &card_option); | |
1285 if (mga_verbose > 1) printf("[mga] OPTION word: 0x%08X mem: 0x%02X %s\n", card_option, | |
1286 (card_option>>10)&0x17, ((card_option>>14)&1)?"SGRAM":"SDRAM"); | |
1287 #endif | |
1288 | |
1289 if (mga_ram_size) | |
1290 { | |
1291 printf("[mga] RAMSIZE forced to %d MB\n", mga_ram_size); | |
1292 } | |
1293 else | |
1294 { | |
1295 #ifdef MGA_MEMORY_SIZE | |
1296 mga_ram_size = MGA_MEMORY_SIZE; | |
1297 printf("[mga] hard-coded RAMSIZE is %d MB\n", (unsigned int) mga_ram_size); | |
1298 #else | |
1299 if (is_g400) | |
1300 { | |
1301 switch((card_option>>10)&0x17) | |
1302 { | |
1303 // SDRAM: | |
1304 case 0x00: | |
1305 case 0x04: mga_ram_size = 16; break; | |
1306 case 0x03: mga_ram_size = 32; break; | |
1307 // SGRAM: | |
1308 case 0x10: | |
1309 case 0x14: mga_ram_size = 32; break; | |
1310 case 0x11: | |
1311 case 0x12: mga_ram_size = 16; break; | |
1312 default: | |
1313 mga_ram_size = 16; | |
1314 printf("[mga] Couldn't detect RAMSIZE, assuming 16MB!\n"); | |
1315 } | |
1316 } | |
1317 else | |
1318 { | |
1319 switch((card_option>>10)&0x17) | |
1320 { | |
1321 // case 0x10: | |
1322 // case 0x13: mga_ram_size = 8; break; | |
1323 default: mga_ram_size = 8; | |
1324 } | |
1325 } | |
1326 | |
1327 #if 0 | |
1328 // printf("List resources -----------\n"); | |
1329 for(temp=0;temp<DEVICE_COUNT_RESOURCE;temp++){ | |
1330 struct resource *res=&pci_dev->resource[temp]; | |
1331 if(res->flags){ | |
1332 int size=(1+res->end-res->start)>>20; | |
1333 printf("res %d: start: 0x%X end: 0x%X (%d MB) flags=0x%X\n",temp,res->start,res->end,size,res->flags); | |
1334 if(res->flags&(IORESOURCE_MEM|IORESOURCE_PREFETCH)){ | |
1335 if(size>mga_ram_size && size<=64) mga_ram_size=size; | |
1336 } | |
1337 } | |
1338 } | |
1339 #endif | |
1340 | |
1341 printf("[mga] detected RAMSIZE is %d MB\n", (unsigned int) mga_ram_size); | |
1342 #endif | |
1343 } | |
1344 | |
1345 if (mga_ram_size) | |
1346 { | |
1347 if ((mga_ram_size < 4) || (mga_ram_size > 64)) | |
1348 { | |
1349 printf("[mga] invalid RAMSIZE: %d MB\n", mga_ram_size); | |
1350 return(EINVAL); | |
1351 } | |
1352 } | |
1353 | |
1354 if (mga_verbose > 1) printf("[mga] hardware addresses: mmio: %#x, framebuffer: %#x\n", | |
1355 pci_info.base1, pci_info.base0); | |
1356 | |
1357 mga_mmio_base = map_phys_mem(pci_info.base1,0x4000); | |
1358 mga_mem_base = map_phys_mem(pci_info.base0,mga_ram_size*1024*1024); | |
1359 | |
1360 if (mga_verbose > 1) printf("[mga] MMIO at %p, IRQ: %d, framebuffer: %p\n", | |
1361 mga_mmio_base, mga_irq, mga_mem_base); | |
1362 err = mtrr_set_type(pci_info.base0,mga_ram_size*1024*1024,MTRR_TYPE_WRCOMB); | |
1363 if(!err) printf("[mga] Set write-combining type of video memory\n"); | |
1364 #ifdef MGA_ALLOW_IRQ | |
1365 if (mga_irq != -1) | |
1366 { | |
1367 int tmp = request_irq(mga_irq, mga_handle_irq, SA_INTERRUPT | SA_SHIRQ, "Syncfb Time Base", &mga_irq); | |
1368 if (tmp) | |
1369 { | |
1370 printf("syncfb (mga): cannot register irq %d (Err: %d)\n", mga_irq, tmp); | |
1371 mga_irq=-1; | |
1372 } | |
1373 else | |
1374 { | |
1375 printf("syncfb (mga): registered irq %d\n", mga_irq); | |
1376 } | |
1377 } | |
1378 else | |
1379 { | |
1380 printf("syncfb (mga): No valid irq was found\n"); | |
1381 mga_irq=-1; | |
1382 } | |
1383 #else | |
1384 printf("syncfb (mga): IRQ disabled in mga_vid.c\n"); | |
1385 mga_irq=-1; | |
1386 #endif | |
1387 | |
1388 return(0); | |
1389 } | |
1390 | |
22857
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
1391 static void mga_destroy(void) |
22850 | 1392 { |
1393 if (mga_verbose) printf("[mga] destroy\n"); | |
1394 | |
1395 /* FIXME turn off BES */ | |
1396 vid_src_ready = 0; | |
1397 regs.besctl &= ~1; | |
1398 regs.besglobctl &= ~(1<<6); // UYVY format selected | |
1399 // mga_config.colkey_on=0; //!!! | |
1400 mga_vid_write_regs(1); | |
1401 mga_vid_in_use = 0; | |
1402 | |
1403 #ifdef MGA_ALLOW_IRQ | |
1404 if (mga_irq != -1) | |
1405 free_irq(mga_irq, &mga_irq); | |
1406 #endif | |
1407 | |
1408 if (mga_mmio_base) | |
1409 unmap_phys_mem(mga_mmio_base, 0x4000); | |
1410 if (mga_mem_base) | |
1411 unmap_phys_mem(mga_mem_base, mga_ram_size); | |
1412 return; | |
1413 } | |
1414 | |
22857
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
1415 static int mga_query_fourcc(vidix_fourcc_t *to) |
22850 | 1416 { |
1417 if (mga_verbose) printf("[mga] query fourcc (%x)\n", to->fourcc); | |
1418 | |
1419 switch(to->fourcc) | |
1420 { | |
1421 case IMGFMT_YV12: | |
1422 case IMGFMT_IYUV: | |
1423 case IMGFMT_I420: | |
1424 case IMGFMT_YUY2: | |
1425 case IMGFMT_UYVY: | |
1426 break; | |
1427 default: | |
1428 to->depth = to->flags = 0; | |
1429 return(ENOTSUP); | |
1430 } | |
1431 | |
1432 to->depth = VID_DEPTH_12BPP | | |
1433 VID_DEPTH_15BPP | VID_DEPTH_16BPP | | |
1434 VID_DEPTH_24BPP | VID_DEPTH_32BPP; | |
1435 to->flags = VID_CAP_EXPAND | VID_CAP_SHRINK | VID_CAP_COLORKEY; | |
1436 return(0); | |
1437 } | |
1438 | |
22857
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
1439 static int mga_get_caps(vidix_capability_t *to) |
22850 | 1440 { |
1441 memcpy(to, &mga_cap, sizeof(vidix_capability_t)); | |
1442 return(0); | |
1443 } | |
1444 | |
22857
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
1445 static int mga_get_gkeys(vidix_grkey_t *grkey) |
22850 | 1446 { |
1447 memcpy(grkey, &mga_grkey, sizeof(vidix_grkey_t)); | |
1448 return(0); | |
1449 } | |
1450 | |
22857
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
1451 static int mga_set_gkeys(const vidix_grkey_t *grkey) |
22850 | 1452 { |
1453 memcpy(&mga_grkey, grkey, sizeof(vidix_grkey_t)); | |
1454 mga_vid_write_regs(0); | |
1455 return(0); | |
1456 } | |
1457 | |
22857
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
1458 static int mga_set_eq( const vidix_video_eq_t * eq) |
22850 | 1459 { |
1460 /* contrast and brightness control isn't supported on G200 - alex */ | |
1461 if (!is_g400) | |
1462 { | |
1463 if (mga_verbose) printf("[mga] equalizer isn't supported with G200\n"); | |
1464 return(ENOTSUP); | |
1465 } | |
1466 | |
1467 // only brightness&contrast are supported: | |
1468 if(!(eq->cap & (VEQ_CAP_BRIGHTNESS|VEQ_CAP_CONTRAST))) | |
1469 return(ENOTSUP); | |
1470 | |
1471 //regs.beslumactl = readl(mga_mmio_base + BESLUMACTL); | |
1472 // printf("LUMA = %08X \n",regs.beslumactl); | |
1473 if (eq->cap & VEQ_CAP_BRIGHTNESS) { | |
1474 regs.beslumactl &= 0xFFFF; | |
1475 regs.beslumactl |= (eq->brightness*255/2000)<<16; | |
1476 } | |
1477 if (eq->cap & VEQ_CAP_CONTRAST) { | |
1478 regs.beslumactl &= 0xFFFF0000; | |
1479 regs.beslumactl |= (128+eq->contrast*255/2000)&0xFFFF; | |
1480 } | |
1481 writel(regs.beslumactl,mga_mmio_base + BESLUMACTL); | |
1482 | |
1483 return(0); | |
1484 } | |
1485 | |
22857
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
1486 static int mga_get_eq( vidix_video_eq_t * eq) |
22850 | 1487 { |
1488 /* contrast and brightness control isn't supported on G200 - alex */ | |
1489 if (!is_g400) | |
1490 { | |
1491 if (mga_verbose) printf("[mga] equalizer isn't supported with G200\n"); | |
1492 return(ENOTSUP); | |
1493 } | |
1494 | |
1495 // regs.beslumactl = readl(mga_mmio_base + BESLUMACTL); | |
1496 | |
1497 eq->brightness = (signed short int)(regs.beslumactl >> 16) * 1000 / 128; | |
1498 eq->contrast = (signed short int)(regs.beslumactl & 0xFFFF) * 1000 / 128 - 1000; | |
1499 eq->cap = VEQ_CAP_BRIGHTNESS | VEQ_CAP_CONTRAST; | |
1500 | |
1501 printf("MGA GET_EQ: br=%d c=%d \n",eq->brightness,eq->contrast); | |
1502 | |
1503 return(0); | |
1504 } | |
22857
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
1505 |
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
1506 #ifndef CRTC2 |
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
1507 VDXDriver mga_drv = { |
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
1508 "mga", |
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
1509 #else |
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
1510 VDXDriver mga_crtc2_drv = { |
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
1511 "mga_crtc2", |
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
1512 #endif |
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
1513 NULL, |
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
1514 |
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
1515 .probe = mga_probe, |
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
1516 .get_caps = mga_get_caps, |
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
1517 .query_fourcc = mga_query_fourcc, |
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
1518 .init = mga_init, |
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
1519 .destroy = mga_destroy, |
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
1520 .config_playback = mga_config_playback, |
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
1521 .playback_on = mga_playback_on, |
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
1522 .playback_off = mga_playback_off, |
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
1523 .frame_sel = mga_frame_select, |
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
1524 .get_eq = mga_get_eq, |
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
1525 .set_eq = mga_set_eq, |
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
1526 .get_gkey = mga_get_gkeys, |
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
1527 .set_gkey = mga_set_gkeys, |
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
1528 }; |