annotate drivers/mga_vid.c @ 9989:98791b90215a

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