annotate drivers/mga_vid.c @ 8:5f9ece2d0621

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