annotate drivers/mga_vid.c @ 27366:067da68b5b16

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