annotate drivers/mga_vid.c @ 49:727b1337f951

updated to libmpeg2-0.2.1-CVS
author arpi_esp
date Wed, 07 Mar 2001 01:15:02 +0000
parents 66ae768fe0ea
children baa0a12438eb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1 // YUY2 support (see config.format) added by A'rpi/ESP-team
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
2
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
3 /*
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
4 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
5 * mga_vid.c
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
6 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
7 * Copyright (C) 1999 Aaron Holtzman
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
8 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
9 * Module skeleton based on gutted agpgart module by Jeff Hartmann
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
10 * <slicer@ionet.net>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
11 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
12 * Matrox MGA G200/G400 YUV Video Interface module Version 0.1.0
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
13 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
14 * BES == Back End Scaler
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
15 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
16 * This software has been released under the terms of the GNU Public
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
17 * license. See http://www.gnu.org/copyleft/gpl.html for details.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
18 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
19
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
20 //It's entirely possible this major conflicts with something else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
21 /* mknod /dev/mga_vid c 178 0 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
22
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
23 #include <linux/config.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
24 #include <linux/version.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
25 #include <linux/module.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
26 #include <linux/types.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
27 #include <linux/kernel.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
28 #include <linux/sched.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
29 #include <linux/mm.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
30 #include <linux/string.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
31 #include <linux/errno.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
32 #include <linux/malloc.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
33 #include <linux/pci.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
34 #include <linux/init.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
35
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
36 #include "mga_vid.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
37
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
38 #ifdef CONFIG_MTRR
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
39 #include <asm/mtrr.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
40 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
41
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
42 #include <asm/uaccess.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
43 #include <asm/system.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
44 #include <asm/io.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
45
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
46 #define TRUE 1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
47 #define FALSE 0
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
48
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
49 #define MGA_VID_MAJOR 178
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
50
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
51 #define MGA_VIDMEM_SIZE mga_ram_size
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
52
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
53 #ifndef PCI_DEVICE_ID_MATROX_G200_PCI
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
54 #define PCI_DEVICE_ID_MATROX_G200_PCI 0x0520
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
55 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
56
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
57 #ifndef PCI_DEVICE_ID_MATROX_G200_AGP
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
58 #define PCI_DEVICE_ID_MATROX_G200_AGP 0x0521
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
59 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
60
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
61 #ifndef PCI_DEVICE_ID_MATROX_G400
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
62 #define PCI_DEVICE_ID_MATROX_G400 0x0525
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
63 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
64
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
65 MODULE_AUTHOR("Aaron Holtzman <aholtzma@engr.uvic.ca>");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
66
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
67
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
68 typedef struct bes_registers_s
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
69 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
70 //BES Control
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
71 uint32_t besctl;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
72 //BES Global control
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
73 uint32_t besglobctl;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
74 //Luma control (brightness and contrast)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
75 uint32_t beslumactl;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
76 //Line pitch
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
77 uint32_t bespitch;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
78
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
79 //Buffer A-1 Chroma 3 plane org
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
80 uint32_t besa1c3org;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
81 //Buffer A-1 Chroma org
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
82 uint32_t besa1corg;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
83 //Buffer A-1 Luma org
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
84 uint32_t besa1org;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
85
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
86 //Buffer A-2 Chroma 3 plane org
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
87 uint32_t besa2c3org;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
88 //Buffer A-2 Chroma org
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
89 uint32_t besa2corg;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
90 //Buffer A-2 Luma org
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
91 uint32_t besa2org;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
92
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
93 //Buffer B-1 Chroma 3 plane org
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
94 uint32_t besb1c3org;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
95 //Buffer B-1 Chroma org
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
96 uint32_t besb1corg;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
97 //Buffer B-1 Luma org
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
98 uint32_t besb1org;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
99
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
100 //Buffer B-2 Chroma 3 plane org
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
101 uint32_t besb2c3org;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
102 //Buffer B-2 Chroma org
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
103 uint32_t besb2corg;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
104 //Buffer B-2 Luma org
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
105 uint32_t besb2org;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
106
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
107 //BES Horizontal coord
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
108 uint32_t beshcoord;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
109 //BES Horizontal inverse scaling [5.14]
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
110 uint32_t beshiscal;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
111 //BES Horizontal source start [10.14] (for scaling)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
112 uint32_t beshsrcst;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
113 //BES Horizontal source ending [10.14] (for scaling)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
114 uint32_t beshsrcend;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
115 //BES Horizontal source last
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
116 uint32_t beshsrclst;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
117
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
118
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
119 //BES Vertical coord
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
120 uint32_t besvcoord;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
121 //BES Vertical inverse scaling [5.14]
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
122 uint32_t besviscal;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
123 //BES Field 1 vertical source last position
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
124 uint32_t besv1srclst;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
125 //BES Field 1 weight start
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
126 uint32_t besv1wght;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
127 //BES Field 2 vertical source last position
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
128 uint32_t besv2srclst;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
129 //BES Field 2 weight start
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
130 uint32_t besv2wght;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
131
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
132 } bes_registers_t;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
133
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
134 static bes_registers_t regs;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
135 static uint32_t mga_vid_in_use = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
136 static uint32_t is_g400 = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
137 static uint32_t vid_src_ready = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
138 static uint32_t vid_overlay_on = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
139
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
140 static uint8_t *mga_mmio_base = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
141 static uint32_t mga_mem_base = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
142 static uint32_t mga_src_base = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
143
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
144 static uint32_t mga_ram_size = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
145
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
146 static struct pci_dev *pci_dev;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
147
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
148 static mga_vid_config_t mga_config;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
149
48
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
150 static int mga_irq = -1;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
151
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
152 //All register offsets are converted to word aligned offsets (32 bit)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
153 //because we want all our register accesses to be 32 bits
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
154 #define VCOUNT 0x1e20
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
155
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
156 #define PALWTADD 0x3c00 // Index register for X_DATAREG port
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
157 #define X_DATAREG 0x3c0a
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
158
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
159 #define XMULCTRL 0x19
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
160 #define BPP_8 0x00
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
161 #define BPP_15 0x01
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
162 #define BPP_16 0x02
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
163 #define BPP_24 0x03
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
164 #define BPP_32_DIR 0x04
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
165 #define BPP_32_PAL 0x07
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
166
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
167 #define XCOLMSK 0x40
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
168 #define X_COLKEY 0x42
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
169 #define XKEYOPMODE 0x51
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
170 #define XCOLMSK0RED 0x52
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
171 #define XCOLMSK0GREEN 0x53
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
172 #define XCOLMSK0BLUE 0x54
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
173 #define XCOLKEY0RED 0x55
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
174 #define XCOLKEY0GREEN 0x56
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
175 #define XCOLKEY0BLUE 0x57
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
176
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
177 // Backend Scaler registers
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
178 #define BESCTL 0x3d20
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
179 #define BESGLOBCTL 0x3dc0
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
180 #define BESLUMACTL 0x3d40
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
181 #define BESPITCH 0x3d24
48
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
182
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
183 #define BESA1C3ORG 0x3d60
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
184 #define BESA1CORG 0x3d10
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
185 #define BESA1ORG 0x3d00
48
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
186
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
187 #define BESA2C3ORG 0x3d64
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
188 #define BESA2CORG 0x3d14
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
189 #define BESA2ORG 0x3d04
48
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
190
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
191 #define BESB1C3ORG 0x3d68
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
192 #define BESB1CORG 0x3d18
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
193 #define BESB1ORG 0x3d08
48
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
194
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
195 #define BESB2C3ORG 0x3d6C
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
196 #define BESB2CORG 0x3d1C
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
197 #define BESB2ORG 0x3d0C
48
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
198
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
199 #define BESHCOORD 0x3d28
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
200 #define BESHISCAL 0x3d30
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
201 #define BESHSRCEND 0x3d3C
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
202 #define BESHSRCLST 0x3d50
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
203 #define BESHSRCST 0x3d38
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
204 #define BESV1WGHT 0x3d48
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
205 #define BESV2WGHT 0x3d4c
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
206 #define BESV1SRCLST 0x3d54
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
207 #define BESV2SRCLST 0x3d58
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
208 #define BESVISCAL 0x3d34
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
209 #define BESVCOORD 0x3d2c
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
210 #define BESSTATUS 0x3dc4
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
211
48
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
212 #define CRTCX 0x1fd4
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
213 #define CRTCD 0x1fd5
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
214 #define IEN 0x1e1c
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
215 #define ICLEAR 0x1e18
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
216 #define STATUS 0x1e14
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
217
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
218 static int mga_next_frame=0;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
219
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
220 static void mga_vid_frame_sel(int frame)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
221 {
48
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
222 if ( mga_irq != -1 ) {
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
223 mga_next_frame=frame;
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
224 } else {
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
225
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
226 //we don't need the vcount protection as we're only hitting
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
227 //one register (and it doesn't seem to be double buffered)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
228 regs.besctl = (regs.besctl & ~0x07000000) + (frame << 25);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
229 writel( regs.besctl, mga_mmio_base + BESCTL );
48
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
230 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
231 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
232
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
233
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
234 static void mga_vid_write_regs(void)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
235 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
236 //Make sure internal registers don't get updated until we're done
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
237 writel( (readl(mga_mmio_base + VCOUNT)-1)<<16,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
238 mga_mmio_base + BESGLOBCTL);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
239
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
240 // color or coordinate keying
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
241 writeb( XKEYOPMODE, mga_mmio_base + PALWTADD);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
242 writeb( mga_config.colkey_on, mga_mmio_base + X_DATAREG);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
243 if ( mga_config.colkey_on )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
244 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
245 uint32_t r=0, g=0, b=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
246
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
247 writeb( XMULCTRL, mga_mmio_base + PALWTADD);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
248 switch (readb (mga_mmio_base + X_DATAREG))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
249 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
250 case BPP_8:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
251 /* Need to look up the color index, just using
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
252 color 0 for now. */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
253 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
254
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
255 case BPP_15:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
256 r = mga_config.colkey_red >> 3;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
257 g = mga_config.colkey_green >> 3;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
258 b = mga_config.colkey_blue >> 3;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
259 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
260
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
261 case BPP_16:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
262 r = mga_config.colkey_red >> 3;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
263 g = mga_config.colkey_green >> 2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
264 b = mga_config.colkey_blue >> 3;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
265 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
266
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
267 case BPP_24:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
268 case BPP_32_DIR:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
269 case BPP_32_PAL:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
270 r = mga_config.colkey_red;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
271 g = mga_config.colkey_green;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
272 b = mga_config.colkey_blue;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
273 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
274 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
275
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
276 // Disable color keying on alpha channel
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
277 writeb( XCOLMSK, mga_mmio_base + PALWTADD);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
278 writeb( 0x00, mga_mmio_base + X_DATAREG);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
279 writeb( X_COLKEY, mga_mmio_base + PALWTADD);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
280 writeb( 0x00, mga_mmio_base + X_DATAREG);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
281
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
282 // Set up color key registers
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
283 writeb( XCOLKEY0RED, mga_mmio_base + PALWTADD);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
284 writeb( r, mga_mmio_base + X_DATAREG);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
285 writeb( XCOLKEY0GREEN, mga_mmio_base + PALWTADD);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
286 writeb( g, mga_mmio_base + X_DATAREG);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
287 writeb( XCOLKEY0BLUE, mga_mmio_base + PALWTADD);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
288 writeb( b, mga_mmio_base + X_DATAREG);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
289
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
290 // Set up color key mask registers
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
291 writeb( XCOLMSK0RED, mga_mmio_base + PALWTADD);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
292 writeb( 0xff, mga_mmio_base + X_DATAREG);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
293 writeb( XCOLMSK0GREEN, mga_mmio_base + PALWTADD);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
294 writeb( 0xff, mga_mmio_base + X_DATAREG);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
295 writeb( XCOLMSK0BLUE, mga_mmio_base + PALWTADD);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
296 writeb( 0xff, mga_mmio_base + X_DATAREG);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
297 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
298
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
299 // Backend Scaler
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
300 writel( regs.besctl, mga_mmio_base + BESCTL);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
301 if(is_g400)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
302 writel( regs.beslumactl, mga_mmio_base + BESLUMACTL);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
303 writel( regs.bespitch, mga_mmio_base + BESPITCH);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
304
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
305 writel( regs.besa1org, mga_mmio_base + BESA1ORG);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
306 writel( regs.besa1corg, mga_mmio_base + BESA1CORG);
48
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
307 writel( regs.besa2org, mga_mmio_base + BESA2ORG);
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
308 writel( regs.besa2corg, mga_mmio_base + BESA2CORG);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
309 writel( regs.besb1org, mga_mmio_base + BESB1ORG);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
310 writel( regs.besb1corg, mga_mmio_base + BESB1CORG);
48
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
311 writel( regs.besb2org, mga_mmio_base + BESB2ORG);
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
312 writel( regs.besb2corg, mga_mmio_base + BESB2CORG);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
313 if(is_g400)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
314 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
315 writel( regs.besa1c3org, mga_mmio_base + BESA1C3ORG);
48
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
316 writel( regs.besa2c3org, mga_mmio_base + BESA2C3ORG);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
317 writel( regs.besb1c3org, mga_mmio_base + BESB1C3ORG);
48
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
318 writel( regs.besb2c3org, mga_mmio_base + BESB2C3ORG);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
319 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
320
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
321 writel( regs.beshcoord, mga_mmio_base + BESHCOORD);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
322 writel( regs.beshiscal, mga_mmio_base + BESHISCAL);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
323 writel( regs.beshsrcst, mga_mmio_base + BESHSRCST);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
324 writel( regs.beshsrcend, mga_mmio_base + BESHSRCEND);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
325 writel( regs.beshsrclst, mga_mmio_base + BESHSRCLST);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
326
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
327 writel( regs.besvcoord, mga_mmio_base + BESVCOORD);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
328 writel( regs.besviscal, mga_mmio_base + BESVISCAL);
48
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
329
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
330 writel( regs.besv1srclst, mga_mmio_base + BESV1SRCLST);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
331 writel( regs.besv1wght, mga_mmio_base + BESV1WGHT);
48
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
332 writel( regs.besv2srclst, mga_mmio_base + BESV2SRCLST);
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
333 writel( regs.besv2wght, mga_mmio_base + BESV2WGHT);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
334
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
335 //update the registers somewhere between 1 and 2 frames from now.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
336 writel( regs.besglobctl + ((readl(mga_mmio_base + VCOUNT)+2)<<16),
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
337 mga_mmio_base + BESGLOBCTL);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
338
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
339 printk("mga_vid: wrote BES registers\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
340 printk("mga_vid: BESCTL = 0x%08x\n",
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
341 readl(mga_mmio_base + BESCTL));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
342 printk("mga_vid: BESGLOBCTL = 0x%08x\n",
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
343 readl(mga_mmio_base + BESGLOBCTL));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
344 printk("mga_vid: BESSTATUS= 0x%08x\n",
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
345 readl(mga_mmio_base + BESSTATUS));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
346 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
347
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
348 static int mga_vid_set_config(mga_vid_config_t *config)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
349 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
350 int x, y, sw, sh, dw, dh;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
351 int besleft, bestop, ifactor, ofsleft, ofstop, baseadrofs, weight, weights;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
352 int frame_size;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
353 x = config->x_org;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
354 y = config->y_org;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
355 sw = config->src_width;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
356 sh = config->src_height;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
357 dw = config->dest_width;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
358 dh = config->dest_height;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
359
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
360 printk("mga_vid: Setting up a %dx%d+%d+%d video window (src %dx%d) format %X\n",
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
361 dw, dh, x, y, sw, sh, config->format);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
362
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
363 //FIXME check that window is valid and inside desktop
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
364
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
365 //FIXME figure out a better way to allocate memory on card
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
366 //allocate 2 megs
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
367 //mga_src_base = mga_mem_base + (MGA_VIDMEM_SIZE-2) * 0x100000;
48
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
368 mga_src_base = (MGA_VIDMEM_SIZE-3) * 0x100000;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
369
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
370
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
371 //Setup the BES registers for a three plane 4:2:0 video source
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
372
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
373 switch(config->format){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
374 case MGA_VID_FORMAT_YV12:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
375 regs.besctl = 1 // BES enabled
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
376 + (0<<6) // even start polarity
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
377 + (1<<10) // x filtering enabled
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
378 + (1<<11) // y filtering enabled
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
379 + (1<<16) // chroma upsampling
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
380 + (1<<17) // 4:2:0 mode
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
381 + (1<<18); // dither enabled
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
382
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
383 if(is_g400)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
384 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
385 //zoom disabled, zoom filter disabled, 420 3 plane format, proc amp
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
386 //disabled, rgb mode disabled
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
387 regs.besglobctl = (1<<5);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
388 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
389 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
390 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
391 //zoom disabled, zoom filter disabled, Cb samples in 0246, Cr
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
392 //in 1357, BES register update on besvcnt
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
393 regs.besglobctl = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
394 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
395 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
396
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
397 case MGA_VID_FORMAT_YUY2:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
398 regs.besctl = 1 // BES enabled
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
399 + (0<<6) // even start polarity
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
400 + (1<<10) // x filtering enabled
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
401 + (1<<11) // y filtering enabled
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
402 + (1<<16) // chroma upsampling
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
403 + (0<<17) // 4:2:2 mode
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
404 + (1<<18); // dither enabled
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
405
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
406 regs.besglobctl = 0; // YUY2 format selected
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
407 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
408 default:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
409 return -1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
410 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
411
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
412
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
413 //Disable contrast and brightness control
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
414 regs.besglobctl = (1<<5) + (1<<7);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
415 regs.beslumactl = (0x7f << 16) + (0x80<<0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
416 regs.beslumactl = 0x80<<0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
417
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
418 //Setup destination window boundaries
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
419 besleft = x > 0 ? x : 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
420 bestop = y > 0 ? y : 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
421 regs.beshcoord = (besleft<<16) + (x + dw-1);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
422 regs.besvcoord = (bestop<<16) + (y + dh-1);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
423
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
424 //Setup source dimensions
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
425 regs.beshsrclst = (sw - 1) << 16;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
426 regs.bespitch = (sw + 31) & ~31 ;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
427
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
428 //Setup horizontal scaling
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
429 ifactor = ((sw-1)<<14)/(dw-1);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
430 ofsleft = besleft - x;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
431
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
432 regs.beshiscal = ifactor<<2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
433 regs.beshsrcst = (ofsleft*ifactor)<<2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
434 regs.beshsrcend = regs.beshsrcst + (((dw - ofsleft - 1) * ifactor) << 2);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
435
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
436 //Setup vertical scaling
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
437 ifactor = ((sh-1)<<14)/(dh-1);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
438 ofstop = bestop - y;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
439
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
440 regs.besviscal = ifactor<<2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
441
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
442 baseadrofs = ((ofstop*regs.besviscal)>>16)*regs.bespitch;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
443 frame_size = ((sw + 31) & ~31) * sh + (((sw + 31) & ~31) * sh) / 2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
444 regs.besa1org = (uint32_t) mga_src_base + baseadrofs;
48
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
445 regs.besa2org = (uint32_t) mga_src_base + baseadrofs + 1*frame_size;
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
446 regs.besb1org = (uint32_t) mga_src_base + baseadrofs + 2*frame_size;
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
447 regs.besb2org = (uint32_t) mga_src_base + baseadrofs + 3*frame_size;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
448
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
449 if (is_g400)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
450 baseadrofs = (((ofstop*regs.besviscal)/4)>>16)*regs.bespitch;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
451 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
452 baseadrofs = (((ofstop*regs.besviscal)/2)>>16)*regs.bespitch;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
453
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
454 regs.besa1corg = (uint32_t) mga_src_base + baseadrofs + regs.bespitch * sh ;
48
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
455 regs.besa2corg = (uint32_t) mga_src_base + baseadrofs + 1*frame_size + regs.bespitch * sh;
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
456 regs.besb1corg = (uint32_t) mga_src_base + baseadrofs + 2*frame_size + regs.bespitch * sh;
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
457 regs.besb2corg = (uint32_t) mga_src_base + baseadrofs + 3*frame_size + regs.bespitch * sh;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
458 regs.besa1c3org = regs.besa1corg + ((regs.bespitch * sh) / 4);
48
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
459 regs.besa2c3org = regs.besa2corg + ((regs.bespitch * sh) / 4);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
460 regs.besb1c3org = regs.besb1corg + ((regs.bespitch * sh) / 4);
48
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
461 regs.besb2c3org = regs.besb2corg + ((regs.bespitch * sh) / 4);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
462
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
463 weight = ofstop * (regs.besviscal >> 2);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
464 weights = weight < 0 ? 1 : 0;
48
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
465 regs.besv2wght = regs.besv1wght = (weights << 16) + ((weight & 0x3FFF) << 2);
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
466 regs.besv2srclst = regs.besv1srclst = sh - 1 - (((ofstop * regs.besviscal) >> 16) & 0x03FF);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
467
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
468 mga_vid_write_regs();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
469 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
470 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
471
48
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
472 static void enable_irq(){
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
473 long int cc;
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
474
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
475 cc = readl(mga_mmio_base + IEN);
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
476 printk("<1>*** !!! IRQREG = %d\n", (int)(cc&0xff));
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
477
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
478 writeb( 0x11, mga_mmio_base + CRTCX);
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
479
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
480 writeb(0x20, mga_mmio_base + CRTCD ); /* clear 0, enable off */
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
481 writeb(0x00, mga_mmio_base + CRTCD ); /* enable on */
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
482 writeb(0x10, mga_mmio_base + CRTCD ); /* clear = 1 */
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
483
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
484 writel( regs.besglobctl , mga_mmio_base + BESGLOBCTL);
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
485
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
486 }
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
487
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
488 static void disable_irq(){
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
489
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
490 writeb( 0x11, mga_mmio_base + CRTCX);
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
491 writeb(0x20, mga_mmio_base + CRTCD ); /* clear 0, enable off */
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
492
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
493 }
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
494
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
495 void mga_handle_irq(int irq, void *dev_id, struct pt_regs *pregs) {
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
496 // static int frame=0;
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
497 static int counter=0;
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
498 long int cc;
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
499 // if ( ! mga_enabled_flag ) return;
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
500
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
501 //printk("mga_interrupt #%d\n", irq);
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
502
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
503 if ( irq != -1 ) {
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
504
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
505 cc = readl(mga_mmio_base + STATUS);
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
506 if ( ! (cc & 0x10) ) return; /* vsyncpen */
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
507 // debug_irqcnt++;
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
508 }
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
509
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
510 // if ( debug_irqignore ) {
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
511 // debug_irqignore = 0;
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
512
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
513
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
514 /*
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
515 if ( mga_conf_deinterlace ) {
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
516 if ( mga_first_field ) {
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
517 // printk("mga_interrupt first field\n");
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
518 if ( syncfb_interrupt() )
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
519 mga_first_field = 0;
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
520 } else {
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
521 // printk("mga_interrupt second field\n");
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
522 mga_select_buffer( mga_current_field | 2 );
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
523 mga_first_field = 1;
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
524 }
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
525 } else {
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
526 syncfb_interrupt();
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
527 }
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
528 */
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
529
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
530 // frame=(frame+1)&1;
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
531 regs.besctl = (regs.besctl & ~0x07000000) + (mga_next_frame << 25);
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
532 writel( regs.besctl, mga_mmio_base + BESCTL );
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
533
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
534 #if 0
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
535 ++counter;
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
536 if(!(counter&63)){
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
537 printk("mga irq counter = %d\n",counter);
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
538 }
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
539 #endif
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
540
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
541 // } else {
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
542 // debug_irqignore = 1;
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
543 // }
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
544
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
545 if ( irq != -1 ) {
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
546 writeb( 0x11, mga_mmio_base + CRTCX);
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
547 writeb( 0, mga_mmio_base + CRTCD );
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
548 writeb( 0x10, mga_mmio_base + CRTCD );
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
549 }
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
550
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
551 // writel( regs.besglobctl, mga_mmio_base + BESGLOBCTL);
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
552
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
553
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
554 return;
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
555
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
556 }
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
557
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
558
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
559
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
560 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
561 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
562 int frame;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
563
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
564 switch(cmd)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
565 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
566 case MGA_VID_CONFIG:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
567 //FIXME remove
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
568 printk("vcount = %d\n",readl(mga_mmio_base + VCOUNT));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
569 printk("mga_mmio_base = %p\n",mga_mmio_base);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
570 printk("mga_mem_base = %08lx\n",mga_mem_base);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
571 //FIXME remove
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
572
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
573 printk("mga_vid: Received configuration\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
574
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
575 if(copy_from_user(&mga_config,(mga_vid_config_t*) arg,sizeof(mga_vid_config_t)))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
576 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
577 printk("mga_vid: failed copy from userspace\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
578 return(-EFAULT);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
579 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
580 if (is_g400)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
581 mga_config.card_type = MGA_G400;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
582 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
583 mga_config.card_type = MGA_G200;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
584
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
585 mga_config.ram_size = mga_ram_size;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
586
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
587 if (copy_to_user((mga_vid_config_t *) arg, &mga_config, sizeof(mga_vid_config_t)))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
588 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
589 printk("mga_vid: failed copy to userspace\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
590 return(-EFAULT);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
591 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
592 return mga_vid_set_config(&mga_config);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
593 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
594
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
595 case MGA_VID_ON:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
596 printk("mga_vid: Video ON\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
597 vid_src_ready = 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
598 if(vid_overlay_on)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
599 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
600 regs.besctl |= 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
601 mga_vid_write_regs();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
602 }
48
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
603 if ( mga_irq != -1 ) enable_irq();
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
604 mga_next_frame=0;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
605 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
606
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
607 case MGA_VID_OFF:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
608 printk("mga_vid: Video OFF\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
609 vid_src_ready = 0;
48
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
610 if ( mga_irq != -1 ) disable_irq();
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
611 regs.besctl &= ~1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
612 mga_vid_write_regs();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
613 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
614
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
615 case MGA_VID_FSEL:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
616 if(copy_from_user(&frame,(int *) arg,sizeof(int)))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
617 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
618 printk("mga_vid: FSEL failed copy from userspace\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
619 return(-EFAULT);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
620 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
621
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
622 mga_vid_frame_sel(frame);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
623 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
624
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
625 default:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
626 printk("mga_vid: Invalid ioctl\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
627 return (-EINVAL);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
628 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
629
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
630 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
631 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
632
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
633
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
634 static int mga_vid_find_card(void)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
635 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
636 struct pci_dev *dev = NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
637 unsigned int card_option, temp;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
638
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
639 if((dev = pci_find_device(PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_G400, NULL)))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
640 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
641 is_g400 = 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
642 printk("mga_vid: Found MGA G400\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
643 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
644 else if((dev = pci_find_device(PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_G200_AGP, NULL)))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
645 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
646 is_g400 = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
647 printk("mga_vid: Found MGA G200 AGP\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
648 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
649 else if((dev = pci_find_device(PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_G200_PCI, NULL)))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
650 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
651 is_g400 = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
652 printk("mga_vid: Found MGA G200 PCI\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
653 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
654 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
655 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
656 printk("mga_vid: No supported cards found\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
657 return FALSE;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
658 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
659
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
660 pci_dev = dev;
48
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
661
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
662 mga_irq = pci_dev->irq;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
663
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
664 #if LINUX_VERSION_CODE >= 0x020300
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
665 mga_mmio_base = ioremap_nocache(dev->resource[1].start,0x4000);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
666 mga_mem_base = dev->resource[0].start;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
667 #else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
668 mga_mmio_base = ioremap_nocache(dev->base_address[1] & PCI_BASE_ADDRESS_MEM_MASK,0x4000);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
669 mga_mem_base = dev->base_address[0] & PCI_BASE_ADDRESS_MEM_MASK;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
670 #endif
48
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
671 // printk("mga_vid: MMIO at 0x%p\n", mga_mmio_base);
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
672 printk("syncfb (mga): MMIO at 0x%p IRQ: %d\n", mga_mmio_base, mga_irq);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
673 printk("mga_vid: Frame Buffer at 0x%08lX\n", mga_mem_base);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
674
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
675 pci_read_config_dword(dev, 0x40, &card_option);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
676 printk("OPTION word: 0x%08x\n", card_option);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
677
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
678 temp = (card_option >> 10) & 0x17;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
679
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
680 if (is_g400)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
681 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
682 switch(temp)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
683 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
684 default:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
685 mga_ram_size = 16;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
686 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
687 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
688 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
689 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
690 // a g200
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
691 switch(temp)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
692 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
693 default:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
694 mga_ram_size = 8;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
695 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
696 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
697
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
698 printk("mga_vid: RAMSIZE seems to be %d MB\n", (unsigned int) mga_ram_size);
48
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
699
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
700 if ( mga_irq != -1 ) {
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
701 int tmp = request_irq(mga_irq, mga_handle_irq, SA_INTERRUPT | SA_SHIRQ, "Syncfb Time Base", &mga_irq);
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
702 if ( tmp ) {
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
703 printk("syncfb (mga): cannot register irq %d (Err: %d)\n", mga_irq, tmp);
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
704 mga_irq=-1;
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
705 } else {
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
706 printk("syncfb (mga): registered irq %d\n", mga_irq);
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
707 }
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
708 } else {
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
709 printk("syncfb (mga): No valid irq was found\n");
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
710 mga_irq=-1;
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
711 }
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
712
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
713
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
714 return TRUE;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
715 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
716
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
717
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
718 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
719 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
720 return -EINVAL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
721 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
722
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
723 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
724 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
725 return -EINVAL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
726 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
727
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
728 static int mga_vid_mmap(struct file *file, struct vm_area_struct *vma)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
729 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
730
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
731 printk("mga_vid: mapping video memory into userspace\n");
48
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
732 if(remap_page_range(vma->vm_start, mga_mem_base + (MGA_VIDMEM_SIZE-3) * 0x100000,
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
733 vma->vm_end - vma->vm_start, vma->vm_page_prot))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
734 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
735 printk("mga_vid: error mapping video memory\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
736 return(-EAGAIN);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
737 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
738
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
739 return(0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
740 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
741
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
742 static int mga_vid_release(struct inode *inode, struct file *file)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
743 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
744 //Close the window just in case
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
745 vid_src_ready = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
746 regs.besctl &= ~1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
747 mga_vid_write_regs();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
748 mga_vid_in_use = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
749
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
750 //FIXME put back in!
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
751 //MOD_DEC_USE_COUNT;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
752 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
753 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
754
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
755 static long long mga_vid_lseek(struct file *file, long long offset, int origin)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
756 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
757 return -ESPIPE;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
758 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
759
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
760 static int mga_vid_open(struct inode *inode, struct file *file)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
761 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
762 int minor = MINOR(inode->i_rdev);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
763
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
764 if(minor != 0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
765 return(-ENXIO);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
766
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
767 if(mga_vid_in_use == 1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
768 return(-EBUSY);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
769
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
770 mga_vid_in_use = 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
771 //FIXME turn me back on!
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
772 //MOD_INC_USE_COUNT;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
773 return(0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
774 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
775
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
776 #if LINUX_VERSION_CODE >= 0x020400
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
777 static struct file_operations mga_vid_fops =
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
778 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
779 llseek: mga_vid_lseek,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
780 read: mga_vid_read,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
781 write: mga_vid_write,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
782 ioctl: mga_vid_ioctl,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
783 mmap: mga_vid_mmap,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
784 open: mga_vid_open,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
785 release: mga_vid_release
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
786 };
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
787 #else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
788 static struct file_operations mga_vid_fops =
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
789 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
790 mga_vid_lseek,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
791 mga_vid_read,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
792 mga_vid_write,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
793 NULL,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
794 NULL,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
795 mga_vid_ioctl,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
796 mga_vid_mmap,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
797 mga_vid_open,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
798 NULL,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
799 mga_vid_release
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
800 };
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
801 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
802
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
803
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
804 /*
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
805 * Main Initialization Function
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
806 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
807
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
808
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
809 static int mga_vid_initialize(void)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
810 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
811 mga_vid_in_use = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
812
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
813 printk( "Matrox MGA G200/G400 YUV Video interface v0.01 (c) Aaron Holtzman \n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
814 if(register_chrdev(MGA_VID_MAJOR, "mga_vid", &mga_vid_fops))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
815 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
816 printk("mga_vid: unable to get major: %d\n", MGA_VID_MAJOR);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
817 return -EIO;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
818 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
819
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
820 if (!mga_vid_find_card())
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
821 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
822 printk("mga_vid: no supported devices found\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
823 unregister_chrdev(MGA_VID_MAJOR, "mga_vid");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
824 return -EINVAL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
825 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
826
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
827 return(0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
828 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
829
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
830 int init_module(void)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
831 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
832 return mga_vid_initialize();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
833 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
834
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
835 void cleanup_module(void)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
836 {
48
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
837
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
838 if ( mga_irq != -1)
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
839 free_irq(mga_irq, &mga_irq);
66ae768fe0ea vsync (4 buffers) implemented
arpi_esp
parents: 42
diff changeset
840
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
841 if(mga_mmio_base)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
842 iounmap(mga_mmio_base);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
843
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
844 //FIXME turn off BES
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
845 printk("mga_vid: Cleaning up module\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
846 unregister_chrdev(MGA_VID_MAJOR, "mga_vid");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
847 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
848