Mercurial > mplayer.hg
annotate drivers/radeon/radeon_vid.c @ 3915:8f71d01a22d7
ACEL.P fixed (avifile sync)
author | arpi |
---|---|
date | Mon, 31 Dec 2001 04:35:20 +0000 |
parents | 80d0864322b9 |
children | f6cd00725f6e |
rev | line source |
---|---|
2870 | 1 /* |
2 * | |
3 * radeon_vid.c | |
4 * | |
5 * Copyright (C) 2001 Nick Kurshev | |
6 * | |
3164 | 7 * BES YUV video overlay driver for Radeon/Rage128Pro/Rage128 cards |
2870 | 8 * |
9 * This software has been released under the terms of the GNU Public | |
10 * license. See http://www.gnu.org/copyleft/gpl.html for details. | |
11 * | |
12 * This file is partly based on mga_vid and sis_vid stuff from | |
13 * mplayer's package. | |
2917 | 14 * Also here was used code from CVS of GATOS project and X11 trees. |
3366 | 15 * |
16 * SPECIAL THANKS TO: Hans-Peter Raschke for active testing and hacking | |
17 * Rage128(pro) stuff of this driver. | |
2870 | 18 */ |
19 | |
3607
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
20 #define RADEON_VID_VERSION "1.1.2" |
2951 | 21 |
2870 | 22 /* |
23 It's entirely possible this major conflicts with something else | |
24 mknod /dev/radeon_vid c 178 0 | |
3164 | 25 or |
26 mknod /dev/rage128_vid c 178 0 | |
3380 | 27 for Rage128/Rage128Pro chips (although it doesn't matter) |
3164 | 28 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
29 TESTED and WORKING formats: YUY2, UYVY, IYUV, I420, YV12 | |
30 ----------------------------------------------------------- | |
2870 | 31 TODO: |
3164 | 32 Highest priority: fbvid.h compatibility |
3366 | 33 High priority: Fixing BUGS |
34 Middle priority: RGB/BGR 2-32, YVU9, IF09 support | |
35 Low priority: CLPL, IYU1, IYU2, UYNV, CYUV, YUNV, YVYU, Y41P, Y211, Y41T, | |
36 ^^^^ | |
37 Y42T, V422, V655, CLJR, YUVP, UYVP, Mpeg PES (mpeg-1,2) support | |
38 ........................................................... | |
39 BUGS and LACKS: | |
40 Color and video keys don't work | |
41 Contrast and brightness are unconfigurable on radeons | |
2870 | 42 */ |
43 | |
44 #include <linux/config.h> | |
45 #include <linux/version.h> | |
46 #include <linux/module.h> | |
47 #include <linux/types.h> | |
48 #include <linux/kernel.h> | |
49 #include <linux/sched.h> | |
50 #include <linux/mm.h> | |
51 #include <linux/string.h> | |
52 #include <linux/errno.h> | |
53 #include <linux/slab.h> | |
54 #include <linux/pci.h> | |
55 #include <linux/ioport.h> | |
56 #include <linux/init.h> | |
3265 | 57 #include <linux/byteorder/swab.h> |
2870 | 58 |
59 #include "radeon_vid.h" | |
60 #include "radeon.h" | |
61 | |
62 #ifdef CONFIG_MTRR | |
63 #include <asm/mtrr.h> | |
64 #endif | |
65 | |
66 #include <asm/uaccess.h> | |
67 #include <asm/system.h> | |
68 #include <asm/io.h> | |
69 | |
70 #define TRUE 1 | |
71 #define FALSE 0 | |
72 | |
73 #define RADEON_VID_MAJOR 178 | |
74 | |
75 | |
76 MODULE_AUTHOR("Nick Kurshev <nickols_k@mail.ru>"); | |
3198 | 77 #ifdef RAGE128 |
78 MODULE_DESCRIPTION("Accelerated YUV BES driver for Rage128. Version: "RADEON_VID_VERSION); | |
79 #else | |
80 MODULE_DESCRIPTION("Accelerated YUV BES driver for Radeons. Version: "RADEON_VID_VERSION); | |
81 #endif | |
2965 | 82 #ifdef MODULE_LICENSE |
2870 | 83 MODULE_LICENSE("GPL"); |
2965 | 84 #endif |
3265 | 85 #ifdef CONFIG_MTRR |
86 MODULE_PARM(mtrr, "i"); | |
87 MODULE_PARM_DESC(mtrr, "Tune MTRR (touch=1(default))"); | |
88 static int mtrr __initdata = 1; | |
89 static struct { int vram; int vram_valid; } smtrr; | |
90 #endif | |
91 MODULE_PARM(swap_fourcc, "i"); | |
92 MODULE_PARM_DESC(swap_fourcc, "Swap fourcc (dont't swap=0(default))"); | |
93 static int swap_fourcc __initdata = 0; | |
2870 | 94 |
3164 | 95 #ifdef RAGE128 |
96 #define RVID_MSG "rage128_vid: " | |
97 #define X_ADJUST 0 | |
98 #else | |
99 #define RVID_MSG "radeon_vid: " | |
100 #define X_ADJUST 8 | |
3198 | 101 #ifndef RADEON |
102 #define RADEON | |
103 #endif | |
3164 | 104 #endif |
105 | |
3348 | 106 #undef DEBUG |
107 #if DEBUG | |
108 #define RTRACE printk | |
109 #else | |
110 #define RTRACE(...) ((void)0) | |
111 #endif | |
112 | |
2870 | 113 typedef struct bes_registers_s |
114 { | |
115 /* base address of yuv framebuffer */ | |
116 uint32_t yuv_base; | |
117 uint32_t fourcc; | |
3278 | 118 uint32_t dest_bpp; |
2870 | 119 /* YUV BES registers */ |
120 uint32_t reg_load_cntl; | |
121 uint32_t h_inc; | |
122 uint32_t step_by; | |
123 uint32_t y_x_start; | |
124 uint32_t y_x_end; | |
125 uint32_t v_inc; | |
126 uint32_t p1_blank_lines_at_top; | |
3019 | 127 uint32_t p23_blank_lines_at_top; |
2870 | 128 uint32_t vid_buf_pitch0_value; |
2944 | 129 uint32_t vid_buf_pitch1_value; |
2870 | 130 uint32_t p1_x_start_end; |
131 uint32_t p2_x_start_end; | |
132 uint32_t p3_x_start_end; | |
3122 | 133 uint32_t base_addr; |
2870 | 134 uint32_t vid_buf0_base_adrs; |
135 /* These ones are for auto flip: maybe in the future */ | |
136 uint32_t vid_buf1_base_adrs; | |
137 uint32_t vid_buf2_base_adrs; | |
138 uint32_t vid_buf3_base_adrs; | |
139 uint32_t vid_buf4_base_adrs; | |
140 uint32_t vid_buf5_base_adrs; | |
141 | |
142 uint32_t p1_v_accum_init; | |
143 uint32_t p1_h_accum_init; | |
3019 | 144 uint32_t p23_v_accum_init; |
2870 | 145 uint32_t p23_h_accum_init; |
146 uint32_t scale_cntl; | |
147 uint32_t exclusive_horz; | |
148 uint32_t auto_flip_cntl; | |
149 uint32_t filter_cntl; | |
3250 | 150 uint32_t key_cntl; |
151 uint32_t test; | |
152 /* Configurable stuff */ | |
153 int double_buff; | |
3278 | 154 |
3247
7cec2396bde3
Tune up driver through reading and writing /dev/radeon_vid ;)
nick
parents:
3198
diff
changeset
|
155 int brightness; |
7cec2396bde3
Tune up driver through reading and writing /dev/radeon_vid ;)
nick
parents:
3198
diff
changeset
|
156 int saturation; |
3278 | 157 |
158 int ckey_on; | |
2870 | 159 uint32_t graphics_key_clr; |
3278 | 160 uint32_t graphics_key_msk; |
161 | |
3250 | 162 int deinterlace_on; |
163 uint32_t deinterlace_pattern; | |
3278 | 164 |
2870 | 165 } bes_registers_t; |
166 | |
167 typedef struct video_registers_s | |
168 { | |
3348 | 169 #ifdef DEBUG |
3305 | 170 const char * sname; |
3348 | 171 #endif |
2870 | 172 uint32_t name; |
173 uint32_t value; | |
174 }video_registers_t; | |
175 | |
176 static bes_registers_t besr; | |
3900
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
177 #ifndef RAGE128 |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
178 static int IsR200=0; |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
179 #endif |
3348 | 180 #ifdef DEBUG |
181 #define DECLARE_VREG(name) { #name, name, 0 } | |
182 #else | |
183 #define DECLARE_VREG(name) { name, 0 } | |
184 #endif | |
3607
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
185 #ifdef DEBUG |
2870 | 186 static video_registers_t vregs[] = |
187 { | |
3473 | 188 DECLARE_VREG(VIDEOMUX_CNTL), |
189 DECLARE_VREG(VIPPAD_MASK), | |
190 DECLARE_VREG(VIPPAD1_A), | |
191 DECLARE_VREG(VIPPAD1_EN), | |
192 DECLARE_VREG(VIPPAD1_Y), | |
3348 | 193 DECLARE_VREG(OV0_Y_X_START), |
194 DECLARE_VREG(OV0_Y_X_END), | |
195 DECLARE_VREG(OV0_PIPELINE_CNTL), | |
196 DECLARE_VREG(OV0_EXCLUSIVE_HORZ), | |
197 DECLARE_VREG(OV0_EXCLUSIVE_VERT), | |
198 DECLARE_VREG(OV0_REG_LOAD_CNTL), | |
199 DECLARE_VREG(OV0_SCALE_CNTL), | |
200 DECLARE_VREG(OV0_V_INC), | |
201 DECLARE_VREG(OV0_P1_V_ACCUM_INIT), | |
202 DECLARE_VREG(OV0_P23_V_ACCUM_INIT), | |
203 DECLARE_VREG(OV0_P1_BLANK_LINES_AT_TOP), | |
204 DECLARE_VREG(OV0_P23_BLANK_LINES_AT_TOP), | |
3487 | 205 #ifdef RADEON |
3348 | 206 DECLARE_VREG(OV0_BASE_ADDR), |
3487 | 207 #endif |
3348 | 208 DECLARE_VREG(OV0_VID_BUF0_BASE_ADRS), |
209 DECLARE_VREG(OV0_VID_BUF1_BASE_ADRS), | |
210 DECLARE_VREG(OV0_VID_BUF2_BASE_ADRS), | |
211 DECLARE_VREG(OV0_VID_BUF3_BASE_ADRS), | |
212 DECLARE_VREG(OV0_VID_BUF4_BASE_ADRS), | |
213 DECLARE_VREG(OV0_VID_BUF5_BASE_ADRS), | |
214 DECLARE_VREG(OV0_VID_BUF_PITCH0_VALUE), | |
215 DECLARE_VREG(OV0_VID_BUF_PITCH1_VALUE), | |
216 DECLARE_VREG(OV0_AUTO_FLIP_CNTL), | |
217 DECLARE_VREG(OV0_DEINTERLACE_PATTERN), | |
218 DECLARE_VREG(OV0_SUBMIT_HISTORY), | |
219 DECLARE_VREG(OV0_H_INC), | |
220 DECLARE_VREG(OV0_STEP_BY), | |
221 DECLARE_VREG(OV0_P1_H_ACCUM_INIT), | |
222 DECLARE_VREG(OV0_P23_H_ACCUM_INIT), | |
223 DECLARE_VREG(OV0_P1_X_START_END), | |
224 DECLARE_VREG(OV0_P2_X_START_END), | |
225 DECLARE_VREG(OV0_P3_X_START_END), | |
226 DECLARE_VREG(OV0_FILTER_CNTL), | |
227 DECLARE_VREG(OV0_FOUR_TAP_COEF_0), | |
228 DECLARE_VREG(OV0_FOUR_TAP_COEF_1), | |
229 DECLARE_VREG(OV0_FOUR_TAP_COEF_2), | |
230 DECLARE_VREG(OV0_FOUR_TAP_COEF_3), | |
231 DECLARE_VREG(OV0_FOUR_TAP_COEF_4), | |
232 DECLARE_VREG(OV0_FLAG_CNTL), | |
3470 | 233 #ifdef RAGE128 |
3348 | 234 DECLARE_VREG(OV0_COLOUR_CNTL), |
3470 | 235 #else |
236 DECLARE_VREG(OV0_SLICE_CNTL), | |
237 #endif | |
3348 | 238 DECLARE_VREG(OV0_VID_KEY_CLR), |
239 DECLARE_VREG(OV0_VID_KEY_MSK), | |
240 DECLARE_VREG(OV0_GRAPHICS_KEY_CLR), | |
241 DECLARE_VREG(OV0_GRAPHICS_KEY_MSK), | |
242 DECLARE_VREG(OV0_KEY_CNTL), | |
243 DECLARE_VREG(OV0_TEST), | |
244 DECLARE_VREG(OV0_LIN_TRANS_A), | |
245 DECLARE_VREG(OV0_LIN_TRANS_B), | |
246 DECLARE_VREG(OV0_LIN_TRANS_C), | |
247 DECLARE_VREG(OV0_LIN_TRANS_D), | |
248 DECLARE_VREG(OV0_LIN_TRANS_E), | |
249 DECLARE_VREG(OV0_LIN_TRANS_F), | |
250 DECLARE_VREG(OV0_GAMMA_0_F), | |
251 DECLARE_VREG(OV0_GAMMA_10_1F), | |
252 DECLARE_VREG(OV0_GAMMA_20_3F), | |
253 DECLARE_VREG(OV0_GAMMA_40_7F), | |
254 DECLARE_VREG(OV0_GAMMA_380_3BF), | |
3473 | 255 DECLARE_VREG(OV0_GAMMA_3C0_3FF), |
256 DECLARE_VREG(SUBPIC_CNTL), | |
257 DECLARE_VREG(SUBPIC_DEFCOLCON), | |
258 DECLARE_VREG(SUBPIC_Y_X_START), | |
259 DECLARE_VREG(SUBPIC_Y_X_END), | |
260 DECLARE_VREG(SUBPIC_V_INC), | |
261 DECLARE_VREG(SUBPIC_H_INC), | |
262 DECLARE_VREG(SUBPIC_BUF0_OFFSET), | |
263 DECLARE_VREG(SUBPIC_BUF1_OFFSET), | |
264 DECLARE_VREG(SUBPIC_LC0_OFFSET), | |
265 DECLARE_VREG(SUBPIC_LC1_OFFSET), | |
266 DECLARE_VREG(SUBPIC_PITCH), | |
267 DECLARE_VREG(SUBPIC_BTN_HLI_COLCON), | |
268 DECLARE_VREG(SUBPIC_BTN_HLI_Y_X_START), | |
269 DECLARE_VREG(SUBPIC_BTN_HLI_Y_X_END), | |
270 DECLARE_VREG(SUBPIC_PALETTE_INDEX), | |
271 DECLARE_VREG(SUBPIC_PALETTE_DATA), | |
272 DECLARE_VREG(SUBPIC_H_ACCUM_INIT), | |
273 DECLARE_VREG(SUBPIC_V_ACCUM_INIT), | |
274 DECLARE_VREG(IDCT_RUNS), | |
275 DECLARE_VREG(IDCT_LEVELS), | |
276 DECLARE_VREG(IDCT_AUTH_CONTROL), | |
277 DECLARE_VREG(IDCT_AUTH), | |
278 DECLARE_VREG(IDCT_CONTROL) | |
2870 | 279 }; |
3607
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
280 #endif |
2870 | 281 static uint32_t radeon_vid_in_use = 0; |
282 | |
283 static uint8_t *radeon_mmio_base = 0; | |
284 static uint32_t radeon_mem_base = 0; | |
3019 | 285 static int32_t radeon_overlay_off = 0; |
2870 | 286 static uint32_t radeon_ram_size = 0; |
3263 | 287 #define PARAM_BUFF_SIZE 4096 |
288 static uint8_t *radeon_param_buff = NULL; | |
289 static uint32_t radeon_param_buff_size=0; | |
290 static uint32_t radeon_param_buff_len=0; /* real length of buffer */ | |
2870 | 291 static mga_vid_config_t radeon_config; |
292 | |
3122 | 293 static char *fourcc_format_name(int format) |
294 { | |
295 switch(format) | |
296 { | |
297 case IMGFMT_RGB8: return("RGB 8-bit"); | |
298 case IMGFMT_RGB15: return("RGB 15-bit"); | |
299 case IMGFMT_RGB16: return("RGB 16-bit"); | |
300 case IMGFMT_RGB24: return("RGB 24-bit"); | |
301 case IMGFMT_RGB32: return("RGB 32-bit"); | |
302 case IMGFMT_BGR8: return("BGR 8-bit"); | |
303 case IMGFMT_BGR15: return("BGR 15-bit"); | |
304 case IMGFMT_BGR16: return("BGR 16-bit"); | |
305 case IMGFMT_BGR24: return("BGR 24-bit"); | |
306 case IMGFMT_BGR32: return("BGR 32-bit"); | |
307 case IMGFMT_YVU9: return("Planar YVU9"); | |
308 case IMGFMT_IF09: return("Planar IF09"); | |
309 case IMGFMT_YV12: return("Planar YV12"); | |
310 case IMGFMT_I420: return("Planar I420"); | |
311 case IMGFMT_IYUV: return("Planar IYUV"); | |
312 case IMGFMT_CLPL: return("Planar CLPL"); | |
3198 | 313 case IMGFMT_Y800: return("Planar Y800"); |
314 case IMGFMT_Y8: return("Planar Y8"); | |
315 case IMGFMT_IUYV: return("Packed IUYV"); | |
316 case IMGFMT_IY41: return("Packed IY41"); | |
3122 | 317 case IMGFMT_IYU1: return("Packed IYU1"); |
318 case IMGFMT_IYU2: return("Packed IYU2"); | |
319 case IMGFMT_UYVY: return("Packed UYVY"); | |
320 case IMGFMT_UYNV: return("Packed UYNV"); | |
321 case IMGFMT_cyuv: return("Packed CYUV"); | |
3198 | 322 case IMGFMT_Y422: return("Packed Y422"); |
3122 | 323 case IMGFMT_YUY2: return("Packed YUY2"); |
324 case IMGFMT_YUNV: return("Packed YUNV"); | |
325 case IMGFMT_YVYU: return("Packed YVYU"); | |
326 case IMGFMT_Y41P: return("Packed Y41P"); | |
327 case IMGFMT_Y211: return("Packed Y211"); | |
328 case IMGFMT_Y41T: return("Packed Y41T"); | |
329 case IMGFMT_Y42T: return("Packed Y42T"); | |
330 case IMGFMT_V422: return("Packed V422"); | |
331 case IMGFMT_V655: return("Packed V655"); | |
332 case IMGFMT_CLJR: return("Packed CLJR"); | |
333 case IMGFMT_YUVP: return("Packed YUVP"); | |
334 case IMGFMT_UYVP: return("Packed UYVP"); | |
3198 | 335 case IMGFMT_MPEGPES: return("Mpeg PES"); |
3122 | 336 } |
337 return("Unknown"); | |
338 } | |
339 | |
2870 | 340 |
341 /* | |
342 * IO macros | |
343 */ | |
344 | |
345 #define INREG8(addr) readb((radeon_mmio_base)+addr) | |
346 #define OUTREG8(addr,val) writeb(val, (radeon_mmio_base)+addr) | |
347 #define INREG(addr) readl((radeon_mmio_base)+addr) | |
348 #define OUTREG(addr,val) writel(val, (radeon_mmio_base)+addr) | |
3607
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
349 #define OUTREGP(addr,val,mask) \ |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
350 do { \ |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
351 unsigned int _tmp = INREG(addr); \ |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
352 _tmp &= (mask); \ |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
353 _tmp |= (val); \ |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
354 OUTREG(addr, _tmp); \ |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
355 } while (0) |
2870 | 356 |
3278 | 357 static uint32_t radeon_vid_get_dbpp( void ) |
358 { | |
359 uint32_t dbpp,retval; | |
360 dbpp = (INREG(CRTC_GEN_CNTL)>>8)& 0xF; | |
361 switch(dbpp) | |
362 { | |
363 case DST_8BPP: retval = 8; break; | |
364 case DST_15BPP: retval = 15; break; | |
365 case DST_16BPP: retval = 16; break; | |
366 case DST_24BPP: retval = 24; break; | |
367 default: retval=32; break; | |
368 } | |
369 return retval; | |
370 } | |
371 | |
3369 | 372 static int radeon_is_dbl_scan( void ) |
373 { | |
374 return (INREG(CRTC_GEN_CNTL))&CRTC_DBL_SCAN_EN; | |
375 } | |
376 | |
3380 | 377 static int radeon_is_interlace( void ) |
378 { | |
379 return (INREG(CRTC_GEN_CNTL))&CRTC_INTERLACE_EN; | |
380 } | |
3369 | 381 |
3607
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
382 static __inline__ void radeon_engine_flush ( void ) |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
383 { |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
384 int i; |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
385 |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
386 /* initiate flush */ |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
387 OUTREGP(RB2D_DSTCACHE_CTLSTAT, RB2D_DC_FLUSH_ALL, |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
388 ~RB2D_DC_FLUSH_ALL); |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
389 |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
390 for (i=0; i < 2000000; i++) { |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
391 if (!(INREG(RB2D_DSTCACHE_CTLSTAT) & RB2D_DC_BUSY)) |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
392 break; |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
393 } |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
394 } |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
395 |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
396 |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
397 static __inline__ void _radeon_fifo_wait (int entries) |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
398 { |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
399 int i; |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
400 |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
401 for (i=0; i<2000000; i++) |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
402 if ((INREG(RBBM_STATUS) & 0x7f) >= entries) |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
403 return; |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
404 } |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
405 |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
406 |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
407 static __inline__ void _radeon_engine_idle ( void ) |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
408 { |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
409 int i; |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
410 |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
411 /* ensure FIFO is empty before waiting for idle */ |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
412 _radeon_fifo_wait (64); |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
413 |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
414 for (i=0; i<2000000; i++) { |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
415 if (((INREG(RBBM_STATUS) & GUI_ACTIVE)) == 0) { |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
416 radeon_engine_flush (); |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
417 return; |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
418 } |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
419 } |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
420 } |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
421 |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
422 #define radeon_engine_idle() _radeon_engine_idle() |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
423 #define radeon_fifo_wait(entries) _radeon_fifo_wait(entries) |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
424 |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
425 #if 0 |
3265 | 426 static void __init radeon_vid_save_state( void ) |
2870 | 427 { |
428 size_t i; | |
429 for(i=0;i<sizeof(vregs)/sizeof(video_registers_t);i++) | |
430 vregs[i].value = INREG(vregs[i].name); | |
431 } | |
432 | |
3265 | 433 static void __exit radeon_vid_restore_state( void ) |
2870 | 434 { |
435 size_t i; | |
3607
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
436 radeon_fifo_wait(2); |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
437 OUTREG(OV0_REG_LOAD_CNTL, REG_LD_CTL_LOCK); |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
438 radeon_engine_idle(); |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
439 while(!(INREG(OV0_REG_LOAD_CNTL)®_LD_CTL_LOCK_READBACK)); |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
440 radeon_fifo_wait(15); |
2870 | 441 for(i=0;i<sizeof(vregs)/sizeof(video_registers_t);i++) |
3607
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
442 { |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
443 radeon_fifo_wait(1); |
2870 | 444 OUTREG(vregs[i].name,vregs[i].value); |
3607
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
445 } |
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
446 OUTREG(OV0_REG_LOAD_CNTL, 0); |
2870 | 447 } |
3607
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
448 #endif |
3305 | 449 #ifdef DEBUG |
450 static void radeon_vid_dump_regs( void ) | |
451 { | |
452 size_t i; | |
453 printk(RVID_MSG"*** Begin of OV0 registers dump ***\n"); | |
454 for(i=0;i<sizeof(vregs)/sizeof(video_registers_t);i++) | |
455 printk(RVID_MSG"%s = %08X\n",vregs[i].sname,INREG(vregs[i].name)); | |
456 printk(RVID_MSG"*** End of OV0 registers dump ***\n"); | |
457 } | |
458 #endif | |
459 | |
3900
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
460 #ifndef RAGE128 |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
461 /* Gamma curve definition */ |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
462 typedef struct |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
463 { |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
464 unsigned int gammaReg; |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
465 unsigned int gammaSlope; |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
466 unsigned int gammaOffset; |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
467 }GAMMA_SETTINGS; |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
468 |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
469 /* Recommended gamma curve parameters */ |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
470 GAMMA_SETTINGS r200_def_gamma[18] = |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
471 { |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
472 {OV0_GAMMA_0_F, 0x100, 0x0000}, |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
473 {OV0_GAMMA_10_1F, 0x100, 0x0020}, |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
474 {OV0_GAMMA_20_3F, 0x100, 0x0040}, |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
475 {OV0_GAMMA_40_7F, 0x100, 0x0080}, |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
476 {OV0_GAMMA_80_BF, 0x100, 0x0100}, |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
477 {OV0_GAMMA_C0_FF, 0x100, 0x0100}, |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
478 {OV0_GAMMA_100_13F, 0x100, 0x0200}, |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
479 {OV0_GAMMA_140_17F, 0x100, 0x0200}, |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
480 {OV0_GAMMA_180_1BF, 0x100, 0x0300}, |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
481 {OV0_GAMMA_1C0_1FF, 0x100, 0x0300}, |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
482 {OV0_GAMMA_200_23F, 0x100, 0x0400}, |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
483 {OV0_GAMMA_240_27F, 0x100, 0x0400}, |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
484 {OV0_GAMMA_280_2BF, 0x100, 0x0500}, |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
485 {OV0_GAMMA_2C0_2FF, 0x100, 0x0500}, |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
486 {OV0_GAMMA_300_33F, 0x100, 0x0600}, |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
487 {OV0_GAMMA_340_37F, 0x100, 0x0600}, |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
488 {OV0_GAMMA_380_3BF, 0x100, 0x0700}, |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
489 {OV0_GAMMA_3C0_3FF, 0x100, 0x0700} |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
490 }; |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
491 |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
492 GAMMA_SETTINGS r100_def_gamma[6] = |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
493 { |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
494 {OV0_GAMMA_0_F, 0x100, 0x0000}, |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
495 {OV0_GAMMA_10_1F, 0x100, 0x0020}, |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
496 {OV0_GAMMA_20_3F, 0x100, 0x0040}, |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
497 {OV0_GAMMA_40_7F, 0x100, 0x0080}, |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
498 {OV0_GAMMA_380_3BF, 0x100, 0x0100}, |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
499 {OV0_GAMMA_3C0_3FF, 0x100, 0x0100} |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
500 }; |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
501 |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
502 static void make_default_gamma_correction( void ) |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
503 { |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
504 size_t i; |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
505 if(!IsR200){ |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
506 OUTREG(OV0_LIN_TRANS_A, 0x12A00000); |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
507 OUTREG(OV0_LIN_TRANS_B, 0x199018FE); |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
508 OUTREG(OV0_LIN_TRANS_C, 0x12A0F9B0); |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
509 OUTREG(OV0_LIN_TRANS_D, 0xF2F0043B); |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
510 OUTREG(OV0_LIN_TRANS_E, 0x12A02050); |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
511 OUTREG(OV0_LIN_TRANS_F, 0x0000174E); |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
512 for(i=0; i<6; i++){ |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
513 OUTREG(r100_def_gamma[i].gammaReg, |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
514 (r100_def_gamma[i].gammaSlope<<16) | |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
515 r100_def_gamma[i].gammaOffset); |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
516 } |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
517 } |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
518 else{ |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
519 OUTREG(OV0_LIN_TRANS_A, 0x12a00000); |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
520 OUTREG(OV0_LIN_TRANS_B, 0x1990190e); |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
521 OUTREG(OV0_LIN_TRANS_C, 0x12a0f9c0); |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
522 OUTREG(OV0_LIN_TRANS_D, 0xf3000442); |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
523 OUTREG(OV0_LIN_TRANS_E, 0x12a02040); |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
524 OUTREG(OV0_LIN_TRANS_F, 0x175f); |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
525 |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
526 /* Default Gamma, |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
527 Of 18 segments for gamma cure, all segments in R200 are programmable, |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
528 while only lower 4 and upper 2 segments are programmable in Radeon*/ |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
529 for(i=0; i<18; i++){ |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
530 OUTREG(r200_def_gamma[i].gammaReg, |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
531 (r200_def_gamma[i].gammaSlope<<16) | |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
532 r200_def_gamma[i].gammaOffset); |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
533 } |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
534 } |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
535 } |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
536 #endif |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
537 |
2870 | 538 static void radeon_vid_stop_video( void ) |
539 { | |
3607
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
540 radeon_engine_idle(); |
2870 | 541 OUTREG(OV0_SCALE_CNTL, SCALER_SOFT_RESET); |
542 OUTREG(OV0_EXCLUSIVE_HORZ, 0); | |
543 OUTREG(OV0_AUTO_FLIP_CNTL, 0); /* maybe */ | |
3487 | 544 OUTREG(OV0_FILTER_CNTL, FILTER_HARDCODED_COEF); |
2870 | 545 OUTREG(OV0_KEY_CNTL, GRAPHIC_KEY_FN_NE); |
546 OUTREG(OV0_TEST, 0); | |
547 } | |
548 | |
549 static void radeon_vid_display_video( void ) | |
550 { | |
551 int bes_flags; | |
3607
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
552 radeon_fifo_wait(2); |
2870 | 553 OUTREG(OV0_REG_LOAD_CNTL, REG_LD_CTL_LOCK); |
3607
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
554 radeon_engine_idle(); |
2870 | 555 while(!(INREG(OV0_REG_LOAD_CNTL)®_LD_CTL_LOCK_READBACK)); |
3607
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
556 radeon_fifo_wait(15); |
2870 | 557 OUTREG(OV0_AUTO_FLIP_CNTL,OV0_AUTO_FLIP_CNTL_SOFT_BUF_ODD); |
3348 | 558 OUTREG(OV0_AUTO_FLIP_CNTL,(INREG(OV0_AUTO_FLIP_CNTL)^OV0_AUTO_FLIP_CNTL_SOFT_EOF_TOGGLE)); |
559 OUTREG(OV0_AUTO_FLIP_CNTL,(INREG(OV0_AUTO_FLIP_CNTL)^OV0_AUTO_FLIP_CNTL_SOFT_EOF_TOGGLE)); | |
2870 | 560 |
3250 | 561 OUTREG(OV0_DEINTERLACE_PATTERN,besr.deinterlace_pattern); |
3470 | 562 #ifdef RAGE128 |
3266
ff90589b635f
Fixed single buffering problems and -vo mga compatibility by number of buffers
nick
parents:
3265
diff
changeset
|
563 OUTREG(OV0_COLOUR_CNTL, (besr.brightness & 0x7f) | |
ff90589b635f
Fixed single buffering problems and -vo mga compatibility by number of buffers
nick
parents:
3265
diff
changeset
|
564 (besr.saturation << 8) | |
ff90589b635f
Fixed single buffering problems and -vo mga compatibility by number of buffers
nick
parents:
3265
diff
changeset
|
565 (besr.saturation << 16)); |
3470 | 566 #endif |
3607
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
567 radeon_fifo_wait(2); |
3278 | 568 if(besr.ckey_on) |
569 { | |
570 OUTREG(OV0_GRAPHICS_KEY_MSK, besr.graphics_key_msk); | |
571 OUTREG(OV0_GRAPHICS_KEY_CLR, besr.graphics_key_clr); | |
3347 | 572 OUTREG(OV0_KEY_CNTL,GRAPHIC_KEY_FN_EQ|VIDEO_KEY_FN_FALSE|CMP_MIX_OR); |
3278 | 573 } |
3366 | 574 else |
575 { | |
576 OUTREG(OV0_GRAPHICS_KEY_MSK, 0ULL); | |
577 OUTREG(OV0_GRAPHICS_KEY_CLR, 0ULL); | |
578 OUTREG(OV0_KEY_CNTL,GRAPHIC_KEY_FN_NE); | |
579 } | |
580 | |
2870 | 581 OUTREG(OV0_H_INC, besr.h_inc); |
582 OUTREG(OV0_STEP_BY, besr.step_by); | |
583 OUTREG(OV0_Y_X_START, besr.y_x_start); | |
584 OUTREG(OV0_Y_X_END, besr.y_x_end); | |
585 OUTREG(OV0_V_INC, besr.v_inc); | |
586 OUTREG(OV0_P1_BLANK_LINES_AT_TOP, besr.p1_blank_lines_at_top); | |
3164 | 587 OUTREG(OV0_P23_BLANK_LINES_AT_TOP, besr.p23_blank_lines_at_top); |
2870 | 588 OUTREG(OV0_VID_BUF_PITCH0_VALUE, besr.vid_buf_pitch0_value); |
2944 | 589 OUTREG(OV0_VID_BUF_PITCH1_VALUE, besr.vid_buf_pitch1_value); |
2870 | 590 OUTREG(OV0_P1_X_START_END, besr.p1_x_start_end); |
591 OUTREG(OV0_P2_X_START_END, besr.p2_x_start_end); | |
592 OUTREG(OV0_P3_X_START_END, besr.p3_x_start_end); | |
3487 | 593 #ifdef RADEON |
3122 | 594 OUTREG(OV0_BASE_ADDR, besr.base_addr); |
595 #endif | |
2870 | 596 OUTREG(OV0_VID_BUF0_BASE_ADRS, besr.vid_buf0_base_adrs); |
597 OUTREG(OV0_VID_BUF1_BASE_ADRS, besr.vid_buf1_base_adrs); | |
598 OUTREG(OV0_VID_BUF2_BASE_ADRS, besr.vid_buf2_base_adrs); | |
3607
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
599 radeon_fifo_wait(9); |
2870 | 600 OUTREG(OV0_VID_BUF3_BASE_ADRS, besr.vid_buf3_base_adrs); |
601 OUTREG(OV0_VID_BUF4_BASE_ADRS, besr.vid_buf4_base_adrs); | |
602 OUTREG(OV0_VID_BUF5_BASE_ADRS, besr.vid_buf5_base_adrs); | |
603 OUTREG(OV0_P1_V_ACCUM_INIT, besr.p1_v_accum_init); | |
604 OUTREG(OV0_P1_H_ACCUM_INIT, besr.p1_h_accum_init); | |
605 OUTREG(OV0_P23_H_ACCUM_INIT, besr.p23_h_accum_init); | |
3164 | 606 OUTREG(OV0_P23_V_ACCUM_INIT, besr.p23_v_accum_init); |
2870 | 607 |
608 bes_flags = SCALER_ENABLE | | |
609 SCALER_SMART_SWITCH | | |
3334 | 610 #ifdef RADEON |
3305 | 611 SCALER_HORZ_PICK_NEAREST; |
3334 | 612 #else |
613 SCALER_Y2R_TEMP | | |
614 SCALER_PIX_EXPAND; | |
615 #endif | |
3250 | 616 if(besr.double_buff) bes_flags |= SCALER_DOUBLE_BUFFER; |
617 if(besr.deinterlace_on) bes_flags |= SCALER_ADAPTIVE_DEINT; | |
3198 | 618 #ifdef RAGE128 |
619 bes_flags |= SCALER_BURST_PER_PLANE; | |
620 #endif | |
2870 | 621 switch(besr.fourcc) |
622 { | |
623 case IMGFMT_RGB15: | |
624 case IMGFMT_BGR15: bes_flags |= SCALER_SOURCE_15BPP; break; | |
625 case IMGFMT_RGB16: | |
626 case IMGFMT_BGR16: bes_flags |= SCALER_SOURCE_16BPP; break; | |
627 case IMGFMT_RGB24: | |
628 case IMGFMT_BGR24: bes_flags |= SCALER_SOURCE_24BPP; break; | |
629 case IMGFMT_RGB32: | |
630 case IMGFMT_BGR32: bes_flags |= SCALER_SOURCE_32BPP; break; | |
3164 | 631 /* 4:1:0*/ |
632 case IMGFMT_IF09: | |
2870 | 633 case IMGFMT_YVU9: bes_flags |= SCALER_SOURCE_YUV9; break; |
3164 | 634 /* 4:2:0 */ |
3122 | 635 case IMGFMT_IYUV: |
2870 | 636 case IMGFMT_I420: |
3305 | 637 case IMGFMT_YV12: bes_flags |= SCALER_SOURCE_YUV12; |
638 break; | |
3164 | 639 /* 4:2:2 */ |
640 case IMGFMT_UYVY: bes_flags |= SCALER_SOURCE_YVYU422; break; | |
2870 | 641 case IMGFMT_YUY2: |
642 default: bes_flags |= SCALER_SOURCE_VYUY422; break; | |
643 } | |
644 OUTREG(OV0_SCALE_CNTL, bes_flags); | |
645 OUTREG(OV0_REG_LOAD_CNTL, 0); | |
3305 | 646 #ifdef DEBUG |
647 radeon_vid_dump_regs(); | |
648 #endif | |
2870 | 649 } |
650 | |
3278 | 651 void radeon_vid_set_color_key(int ckey_on, uint8_t R, uint8_t G, uint8_t B) |
652 { | |
653 besr.ckey_on = ckey_on; | |
3347 | 654 besr.graphics_key_msk=(1ULL<<radeon_vid_get_dbpp()) - 1; |
3278 | 655 besr.graphics_key_clr=(R<<16)|(G<<8)|(B)|(0x00 << 24); |
656 } | |
657 | |
658 | |
2951 | 659 #define XXX_SRC_X 0 |
660 #define XXX_SRC_Y 0 | |
2870 | 661 |
662 static int radeon_vid_init_video( mga_vid_config_t *config ) | |
663 { | |
3047
ef3b9b104648
Minor speedup of YUY2 decoding. Radeon it's tricked chip
nick
parents:
3020
diff
changeset
|
664 uint32_t tmp,src_w,src_h,pitch,h_inc,step_by,left,leftUV,top; |
3019 | 665 int is_420; |
3164 | 666 RTRACE(RVID_MSG"usr_config: version = %x format=%x card=%x ram=%u src(%ux%u) dest(%u:%ux%u:%u) frame_size=%u num_frames=%u\n" |
2870 | 667 ,(uint32_t)config->version |
2951 | 668 ,(uint32_t)config->format |
2870 | 669 ,(uint32_t)config->card_type |
670 ,(uint32_t)config->ram_size | |
671 ,(uint32_t)config->src_width | |
672 ,(uint32_t)config->src_height | |
673 ,(uint32_t)config->x_org | |
674 ,(uint32_t)config->y_org | |
675 ,(uint32_t)config->dest_width | |
676 ,(uint32_t)config->dest_height | |
677 ,(uint32_t)config->frame_size | |
678 ,(uint32_t)config->num_frames); | |
2917 | 679 radeon_vid_stop_video(); |
3047
ef3b9b104648
Minor speedup of YUY2 decoding. Radeon it's tricked chip
nick
parents:
3020
diff
changeset
|
680 left = XXX_SRC_X << 16; |
ef3b9b104648
Minor speedup of YUY2 decoding. Radeon it's tricked chip
nick
parents:
3020
diff
changeset
|
681 top = XXX_SRC_Y << 16; |
ef3b9b104648
Minor speedup of YUY2 decoding. Radeon it's tricked chip
nick
parents:
3020
diff
changeset
|
682 src_h = config->src_height; |
ef3b9b104648
Minor speedup of YUY2 decoding. Radeon it's tricked chip
nick
parents:
3020
diff
changeset
|
683 src_w = config->src_width; |
2870 | 684 switch(config->format) |
685 { | |
686 case IMGFMT_RGB15: | |
687 case IMGFMT_BGR15: | |
688 case IMGFMT_RGB16: | |
689 case IMGFMT_BGR16: | |
690 case IMGFMT_RGB24: | |
691 case IMGFMT_BGR24: | |
692 case IMGFMT_RGB32: | |
693 case IMGFMT_BGR32: | |
3164 | 694 /* 4:1:0 */ |
695 case IMGFMT_IF09: | |
2870 | 696 case IMGFMT_YVU9: |
3164 | 697 /* 4:2:0 */ |
2870 | 698 case IMGFMT_IYUV: |
699 case IMGFMT_YV12: | |
700 case IMGFMT_I420: | |
3164 | 701 /* 4:2:2 */ |
702 case IMGFMT_UYVY: | |
2870 | 703 case IMGFMT_YUY2: |
704 break; | |
705 default: | |
3164 | 706 printk(RVID_MSG"Unsupported pixel format: 0x%X\n",config->format); |
2870 | 707 return -1; |
708 } | |
3019 | 709 is_420 = 0; |
3122 | 710 if(config->format == IMGFMT_YV12 || |
711 config->format == IMGFMT_I420 || | |
712 config->format == IMGFMT_IYUV) is_420 = 1; | |
2951 | 713 switch(config->format) |
714 { | |
3164 | 715 /* 4:1:0 */ |
2951 | 716 case IMGFMT_YVU9: |
3164 | 717 case IMGFMT_IF09: |
718 /* 4:2:0 */ | |
2951 | 719 case IMGFMT_IYUV: |
3164 | 720 case IMGFMT_YV12: |
721 case IMGFMT_I420: pitch = (src_w + 31) & ~31; break; | |
722 /* 4:2:2 */ | |
723 default: | |
2951 | 724 case IMGFMT_UYVY: |
725 case IMGFMT_YUY2: | |
726 case IMGFMT_RGB15: | |
727 case IMGFMT_BGR15: | |
728 case IMGFMT_RGB16: | |
3047
ef3b9b104648
Minor speedup of YUY2 decoding. Radeon it's tricked chip
nick
parents:
3020
diff
changeset
|
729 case IMGFMT_BGR16: pitch = ((src_w*2) + 15) & ~15; break; |
2951 | 730 case IMGFMT_RGB24: |
3047
ef3b9b104648
Minor speedup of YUY2 decoding. Radeon it's tricked chip
nick
parents:
3020
diff
changeset
|
731 case IMGFMT_BGR24: pitch = ((src_w*3) + 15) & ~15; break; |
2951 | 732 case IMGFMT_RGB32: |
3047
ef3b9b104648
Minor speedup of YUY2 decoding. Radeon it's tricked chip
nick
parents:
3020
diff
changeset
|
733 case IMGFMT_BGR32: pitch = ((src_w*4) + 15) & ~15; break; |
2951 | 734 } |
3380 | 735 if(radeon_is_dbl_scan()) config->dest_height *= 2; |
736 else | |
737 if(radeon_is_interlace()) config->dest_height /= 2; | |
3278 | 738 besr.dest_bpp = radeon_vid_get_dbpp(); |
2870 | 739 besr.fourcc = config->format; |
3369 | 740 besr.v_inc = (src_h << 20) / config->dest_height; |
741 h_inc = (src_w << 12) / config->dest_width; | |
2944 | 742 step_by = 1; |
2870 | 743 |
2944 | 744 while(h_inc >= (2 << 12)) { |
745 step_by++; | |
746 h_inc >>= 1; | |
2870 | 747 } |
748 | |
749 /* keep everything in 16.16 */ | |
3164 | 750 besr.base_addr = radeon_mem_base; |
3019 | 751 if(is_420) |
752 { | |
3164 | 753 uint32_t d1line,d2line,d3line; |
754 d1line = top*pitch; | |
755 d2line = src_h*pitch+(d1line>>1); | |
756 d3line = d2line+((src_h*pitch)>>2); | |
757 d1line += (left >> 16) & ~15; | |
758 d2line += (left >> 17) & ~15; | |
759 d3line += (left >> 17) & ~15; | |
760 besr.vid_buf0_base_adrs=((radeon_overlay_off+d1line)&VIF_BUF0_BASE_ADRS_MASK); | |
761 besr.vid_buf1_base_adrs=((radeon_overlay_off+d2line)&VIF_BUF1_BASE_ADRS_MASK)|VIF_BUF1_PITCH_SEL; | |
762 besr.vid_buf2_base_adrs=((radeon_overlay_off+d3line)&VIF_BUF2_BASE_ADRS_MASK)|VIF_BUF2_PITCH_SEL; | |
763 if(besr.fourcc == IMGFMT_I420 || besr.fourcc == IMGFMT_IYUV) | |
764 { | |
765 uint32_t tmp; | |
766 tmp = besr.vid_buf1_base_adrs; | |
767 besr.vid_buf1_base_adrs = besr.vid_buf2_base_adrs; | |
768 besr.vid_buf2_base_adrs = tmp; | |
769 } | |
3019 | 770 } |
771 else | |
772 { | |
773 besr.vid_buf0_base_adrs = radeon_overlay_off; | |
3198 | 774 besr.vid_buf0_base_adrs += ((left & ~7) << 1)&VIF_BUF0_BASE_ADRS_MASK; |
3047
ef3b9b104648
Minor speedup of YUY2 decoding. Radeon it's tricked chip
nick
parents:
3020
diff
changeset
|
775 besr.vid_buf1_base_adrs = besr.vid_buf0_base_adrs; |
3019 | 776 besr.vid_buf2_base_adrs = besr.vid_buf0_base_adrs; |
777 } | |
3047
ef3b9b104648
Minor speedup of YUY2 decoding. Radeon it's tricked chip
nick
parents:
3020
diff
changeset
|
778 besr.vid_buf3_base_adrs = besr.vid_buf0_base_adrs+config->frame_size; |
ef3b9b104648
Minor speedup of YUY2 decoding. Radeon it's tricked chip
nick
parents:
3020
diff
changeset
|
779 besr.vid_buf4_base_adrs = besr.vid_buf1_base_adrs+config->frame_size; |
ef3b9b104648
Minor speedup of YUY2 decoding. Radeon it's tricked chip
nick
parents:
3020
diff
changeset
|
780 besr.vid_buf5_base_adrs = besr.vid_buf2_base_adrs+config->frame_size; |
2870 | 781 |
2951 | 782 tmp = (left & 0x0003ffff) + 0x00028000 + (h_inc << 3); |
2870 | 783 besr.p1_h_accum_init = ((tmp << 4) & 0x000f8000) | |
2951 | 784 ((tmp << 12) & 0xf0000000); |
2870 | 785 |
2951 | 786 tmp = ((left >> 1) & 0x0001ffff) + 0x00028000 + (h_inc << 2); |
2870 | 787 besr.p23_h_accum_init = ((tmp << 4) & 0x000f8000) | |
2951 | 788 ((tmp << 12) & 0x70000000); |
789 tmp = (top & 0x0000ffff) + 0x00018000; | |
3122 | 790 besr.p1_v_accum_init = ((tmp << 4) & OV0_P1_V_ACCUM_INIT_MASK) |
791 |(OV0_P1_MAX_LN_IN_PER_LN_OUT & 1); | |
3019 | 792 |
793 tmp = ((top >> 1) & 0x0000ffff) + 0x00018000; | |
3122 | 794 besr.p23_v_accum_init = is_420 ? ((tmp << 4) & OV0_P23_V_ACCUM_INIT_MASK) |
795 |(OV0_P23_MAX_LN_IN_PER_LN_OUT & 1) : 0; | |
3019 | 796 |
3047
ef3b9b104648
Minor speedup of YUY2 decoding. Radeon it's tricked chip
nick
parents:
3020
diff
changeset
|
797 leftUV = (left >> 17) & 15; |
ef3b9b104648
Minor speedup of YUY2 decoding. Radeon it's tricked chip
nick
parents:
3020
diff
changeset
|
798 left = (left >> 16) & 15; |
2944 | 799 besr.h_inc = h_inc | ((h_inc >> 1) << 16); |
800 besr.step_by = step_by | (step_by << 8); | |
3164 | 801 besr.y_x_start = (config->x_org+X_ADJUST) | (config->y_org << 16); |
802 besr.y_x_end = (config->x_org + config->dest_width+X_ADJUST) | ((config->y_org + config->dest_height) << 16); | |
3047
ef3b9b104648
Minor speedup of YUY2 decoding. Radeon it's tricked chip
nick
parents:
3020
diff
changeset
|
803 besr.p1_blank_lines_at_top = P1_BLNK_LN_AT_TOP_M1_MASK|((src_h-1)<<16); |
3122 | 804 if(is_420) |
805 { | |
806 src_h = (src_h + 1) >> 1; | |
807 besr.p23_blank_lines_at_top = P23_BLNK_LN_AT_TOP_M1_MASK|((src_h-1)<<16); | |
808 } | |
809 else besr.p23_blank_lines_at_top = 0; | |
2870 | 810 besr.vid_buf_pitch0_value = pitch; |
3047
ef3b9b104648
Minor speedup of YUY2 decoding. Radeon it's tricked chip
nick
parents:
3020
diff
changeset
|
811 besr.vid_buf_pitch1_value = is_420 ? pitch>>1 : pitch; |
ef3b9b104648
Minor speedup of YUY2 decoding. Radeon it's tricked chip
nick
parents:
3020
diff
changeset
|
812 besr.p1_x_start_end = (src_w+left-1)|(left<<16); |
3164 | 813 src_w>>=1; |
814 besr.p2_x_start_end = (src_w+left-1)|(leftUV<<16); | |
815 besr.p3_x_start_end = besr.p2_x_start_end; | |
2870 | 816 return 0; |
817 } | |
818 | |
819 static void radeon_vid_frame_sel(int frame) | |
820 { | |
3066 | 821 uint32_t off0,off1,off2; |
3250 | 822 if(!besr.double_buff) return; |
3066 | 823 if(frame%2) |
824 { | |
825 off0 = besr.vid_buf3_base_adrs; | |
826 off1 = besr.vid_buf4_base_adrs; | |
827 off2 = besr.vid_buf5_base_adrs; | |
828 } | |
829 else | |
830 { | |
831 off0 = besr.vid_buf0_base_adrs; | |
832 off1 = besr.vid_buf1_base_adrs; | |
833 off2 = besr.vid_buf2_base_adrs; | |
834 } | |
2917 | 835 OUTREG(OV0_REG_LOAD_CNTL, REG_LD_CTL_LOCK); |
836 while(!(INREG(OV0_REG_LOAD_CNTL)®_LD_CTL_LOCK_READBACK)); | |
3066 | 837 OUTREG(OV0_VID_BUF0_BASE_ADRS, off0); |
838 OUTREG(OV0_VID_BUF1_BASE_ADRS, off1); | |
839 OUTREG(OV0_VID_BUF2_BASE_ADRS, off2); | |
2917 | 840 OUTREG(OV0_REG_LOAD_CNTL, 0); |
2870 | 841 } |
842 | |
3250 | 843 static void radeon_vid_make_default(void) |
844 { | |
3470 | 845 #ifdef RAGE128 |
3366 | 846 OUTREG(OV0_COLOUR_CNTL,0x00101000UL); /* Default brihgtness and saturation for Rage128 */ |
3900
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
847 #else |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
848 make_default_gamma_correction(); |
3470 | 849 #endif |
3250 | 850 besr.deinterlace_pattern = 0x900AAAAA; |
851 OUTREG(OV0_DEINTERLACE_PATTERN,besr.deinterlace_pattern); | |
852 besr.deinterlace_on=1; | |
853 besr.double_buff=1; | |
854 } | |
855 | |
856 | |
3247
7cec2396bde3
Tune up driver through reading and writing /dev/radeon_vid ;)
nick
parents:
3198
diff
changeset
|
857 static void radeon_vid_preset(void) |
7cec2396bde3
Tune up driver through reading and writing /dev/radeon_vid ;)
nick
parents:
3198
diff
changeset
|
858 { |
3470 | 859 #ifdef RAGE128 |
3247
7cec2396bde3
Tune up driver through reading and writing /dev/radeon_vid ;)
nick
parents:
3198
diff
changeset
|
860 unsigned tmp; |
7cec2396bde3
Tune up driver through reading and writing /dev/radeon_vid ;)
nick
parents:
3198
diff
changeset
|
861 tmp = INREG(OV0_COLOUR_CNTL); |
7cec2396bde3
Tune up driver through reading and writing /dev/radeon_vid ;)
nick
parents:
3198
diff
changeset
|
862 besr.saturation = (tmp>>8)&0x1f; |
7cec2396bde3
Tune up driver through reading and writing /dev/radeon_vid ;)
nick
parents:
3198
diff
changeset
|
863 besr.brightness = tmp & 0x7f; |
3470 | 864 #endif |
3250 | 865 besr.graphics_key_clr = INREG(OV0_GRAPHICS_KEY_CLR); |
866 besr.deinterlace_pattern = INREG(OV0_DEINTERLACE_PATTERN); | |
3247
7cec2396bde3
Tune up driver through reading and writing /dev/radeon_vid ;)
nick
parents:
3198
diff
changeset
|
867 } |
7cec2396bde3
Tune up driver through reading and writing /dev/radeon_vid ;)
nick
parents:
3198
diff
changeset
|
868 |
2951 | 869 static int video_on = 0; |
870 | |
2870 | 871 static int radeon_vid_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) |
872 { | |
873 int frame; | |
874 | |
875 switch(cmd) | |
876 { | |
877 case MGA_VID_CONFIG: | |
3305 | 878 RTRACE(RVID_MSG"radeon_mmio_base = %p\n",radeon_mmio_base); |
879 RTRACE(RVID_MSG"radeon_mem_base = %08x\n",radeon_mem_base); | |
3164 | 880 RTRACE(RVID_MSG"Received configuration\n"); |
2870 | 881 |
882 if(copy_from_user(&radeon_config,(mga_vid_config_t*) arg,sizeof(mga_vid_config_t))) | |
883 { | |
3164 | 884 printk(RVID_MSG"failed copy from userspace\n"); |
3019 | 885 return -EFAULT; |
2870 | 886 } |
887 if(radeon_config.version != MGA_VID_VERSION){ | |
3164 | 888 printk(RVID_MSG"incompatible version! driver: %X requested: %X\n",MGA_VID_VERSION,radeon_config.version); |
3019 | 889 return -EFAULT; |
2870 | 890 } |
891 | |
892 if(radeon_config.frame_size==0 || radeon_config.frame_size>1024*768*2){ | |
3164 | 893 printk(RVID_MSG"illegal frame_size: %d\n",radeon_config.frame_size); |
3019 | 894 return -EFAULT; |
2870 | 895 } |
896 | |
3266
ff90589b635f
Fixed single buffering problems and -vo mga compatibility by number of buffers
nick
parents:
3265
diff
changeset
|
897 if(radeon_config.num_frames<1){ |
3164 | 898 printk(RVID_MSG"illegal num_frames: %d\n",radeon_config.num_frames); |
3019 | 899 return -EFAULT; |
2870 | 900 } |
3266
ff90589b635f
Fixed single buffering problems and -vo mga compatibility by number of buffers
nick
parents:
3265
diff
changeset
|
901 if(radeon_config.num_frames==1) besr.double_buff=0; |
ff90589b635f
Fixed single buffering problems and -vo mga compatibility by number of buffers
nick
parents:
3265
diff
changeset
|
902 if(!besr.double_buff) radeon_config.num_frames=1; |
ff90589b635f
Fixed single buffering problems and -vo mga compatibility by number of buffers
nick
parents:
3265
diff
changeset
|
903 else radeon_config.num_frames=2; |
2870 | 904 radeon_config.card_type = 0; |
905 radeon_config.ram_size = radeon_ram_size; | |
3019 | 906 radeon_overlay_off = radeon_ram_size*0x100000 - radeon_config.frame_size*radeon_config.num_frames; |
907 radeon_overlay_off &= 0xffff0000; | |
908 if(radeon_overlay_off < 0){ | |
3164 | 909 printk(RVID_MSG"not enough video memory. Need: %u has: %u\n",radeon_config.frame_size*radeon_config.num_frames,radeon_ram_size*0x100000); |
3019 | 910 return -EFAULT; |
911 } | |
3305 | 912 RTRACE(RVID_MSG"using video overlay at offset %08X\n",radeon_overlay_off); |
2870 | 913 if (copy_to_user((mga_vid_config_t *) arg, &radeon_config, sizeof(mga_vid_config_t))) |
914 { | |
3164 | 915 printk(RVID_MSG"failed copy to userspace\n"); |
3019 | 916 return -EFAULT; |
2870 | 917 } |
3278 | 918 radeon_vid_set_color_key(radeon_config.colkey_on, |
919 radeon_config.colkey_red, | |
920 radeon_config.colkey_green, | |
921 radeon_config.colkey_blue); | |
3265 | 922 if(swap_fourcc) radeon_config.format = swab32(radeon_config.format); |
3164 | 923 printk(RVID_MSG"configuring for '%s' fourcc\n",fourcc_format_name(radeon_config.format)); |
2870 | 924 return radeon_vid_init_video(&radeon_config); |
925 break; | |
926 | |
927 case MGA_VID_ON: | |
3164 | 928 RTRACE(RVID_MSG"Video ON (ioctl)\n"); |
929 radeon_vid_display_video(); | |
2951 | 930 video_on = 1; |
2870 | 931 break; |
932 | |
933 case MGA_VID_OFF: | |
3164 | 934 RTRACE(RVID_MSG"Video OFF (ioctl)\n"); |
2951 | 935 if(video_on) radeon_vid_stop_video(); |
936 video_on = 0; | |
2870 | 937 break; |
938 | |
939 case MGA_VID_FSEL: | |
940 if(copy_from_user(&frame,(int *) arg,sizeof(int))) | |
941 { | |
3164 | 942 printk(RVID_MSG"FSEL failed copy from userspace\n"); |
2870 | 943 return(-EFAULT); |
944 } | |
945 radeon_vid_frame_sel(frame); | |
946 break; | |
947 | |
948 default: | |
3164 | 949 printk(RVID_MSG"Invalid ioctl\n"); |
2870 | 950 return (-EINVAL); |
951 } | |
952 | |
953 return 0; | |
954 } | |
955 | |
956 struct ati_card_id_s | |
957 { | |
3164 | 958 const int id; |
959 const char name[17]; | |
960 }; | |
961 | |
962 const struct ati_card_id_s ati_card_ids[]= | |
2870 | 963 { |
3164 | 964 #ifdef RAGE128 |
965 /* | |
966 This driver should be compatible with Rage128 (pro) chips. | |
967 (include adaptive deinterlacing!!!). | |
968 Moreover: the same logic can be used with Mach64 chips. | |
969 (I mean: mach64xx, 3d rage, 3d rage IIc, 3D rage pro, 3d rage mobility). | |
970 but they are incompatible by i/o ports. So if enthusiasts will want | |
971 then they can redefine OUTREG and INREG macros and redefine OV0_* | |
972 constants. Also it seems that mach64 chips supports only: YUY2, YV12, UYVY | |
973 fourccs (422 and 420 formats only). | |
974 */ | |
975 /* Rage128 Pro GL */ | |
976 { PCI_DEVICE_ID_ATI_Rage128_PA, "R128Pro PA" }, | |
977 { PCI_DEVICE_ID_ATI_Rage128_PB, "R128Pro PB" }, | |
978 { PCI_DEVICE_ID_ATI_Rage128_PC, "R128Pro PC" }, | |
979 { PCI_DEVICE_ID_ATI_Rage128_PD, "R128Pro PD" }, | |
980 { PCI_DEVICE_ID_ATI_Rage128_PE, "R128Pro PE" }, | |
981 { PCI_DEVICE_ID_ATI_RAGE128_PF, "R128Pro PF" }, | |
982 /* Rage128 Pro VR */ | |
983 { PCI_DEVICE_ID_ATI_RAGE128_PG, "R128Pro PG" }, | |
984 { PCI_DEVICE_ID_ATI_RAGE128_PH, "R128Pro PH" }, | |
985 { PCI_DEVICE_ID_ATI_RAGE128_PI, "R128Pro PI" }, | |
986 { PCI_DEVICE_ID_ATI_RAGE128_PJ, "R128Pro PJ" }, | |
987 { PCI_DEVICE_ID_ATI_RAGE128_PK, "R128Pro PK" }, | |
988 { PCI_DEVICE_ID_ATI_RAGE128_PL, "R128Pro PL" }, | |
989 { PCI_DEVICE_ID_ATI_RAGE128_PM, "R128Pro PM" }, | |
990 { PCI_DEVICE_ID_ATI_RAGE128_PN, "R128Pro PN" }, | |
991 { PCI_DEVICE_ID_ATI_RAGE128_PO, "R128Pro PO" }, | |
992 { PCI_DEVICE_ID_ATI_RAGE128_PP, "R128Pro PP" }, | |
993 { PCI_DEVICE_ID_ATI_RAGE128_PQ, "R128Pro PQ" }, | |
994 { PCI_DEVICE_ID_ATI_RAGE128_PR, "R128Pro PR" }, | |
995 { PCI_DEVICE_ID_ATI_RAGE128_TR, "R128Pro TR" }, | |
996 { PCI_DEVICE_ID_ATI_RAGE128_PS, "R128Pro PS" }, | |
997 { PCI_DEVICE_ID_ATI_RAGE128_PT, "R128Pro PT" }, | |
998 { PCI_DEVICE_ID_ATI_RAGE128_PU, "R128Pro PU" }, | |
999 { PCI_DEVICE_ID_ATI_RAGE128_PV, "R128Pro PV" }, | |
1000 { PCI_DEVICE_ID_ATI_RAGE128_PW, "R128Pro PW" }, | |
1001 { PCI_DEVICE_ID_ATI_RAGE128_PX, "R128Pro PX" }, | |
1002 /* Rage128 GL */ | |
1003 { PCI_DEVICE_ID_ATI_RAGE128_RE, "R128 RE" }, | |
1004 { PCI_DEVICE_ID_ATI_RAGE128_RF, "R128 RF" }, | |
1005 { PCI_DEVICE_ID_ATI_RAGE128_RG, "R128 RG" }, | |
1006 { PCI_DEVICE_ID_ATI_RAGE128_RH, "R128 RH" }, | |
1007 { PCI_DEVICE_ID_ATI_RAGE128_RI, "R128 RI" }, | |
1008 /* Rage128 VR */ | |
1009 { PCI_DEVICE_ID_ATI_RAGE128_RK, "R128 RK" }, | |
1010 { PCI_DEVICE_ID_ATI_RAGE128_RL, "R128 RL" }, | |
1011 { PCI_DEVICE_ID_ATI_RAGE128_RM, "R128 RM" }, | |
1012 { PCI_DEVICE_ID_ATI_RAGE128_RN, "R128 RN" }, | |
1013 { PCI_DEVICE_ID_ATI_RAGE128_RO, "R128 RO" }, | |
1014 /* Rage128 M3 */ | |
3198 | 1015 { PCI_DEVICE_ID_ATI_RAGE128_LE, "R128 M3 LE" }, |
1016 { PCI_DEVICE_ID_ATI_RAGE128_LF, "R128 M3 LF" }, | |
3164 | 1017 /* Rage128 Pro Ultra */ |
3198 | 1018 { PCI_DEVICE_ID_ATI_RAGE128_U1, "R128Pro U1" }, |
1019 { PCI_DEVICE_ID_ATI_RAGE128_U2, "R128Pro U2" }, | |
1020 { PCI_DEVICE_ID_ATI_RAGE128_U3, "R128Pro U3" } | |
3164 | 1021 #else |
1022 /* Radeons (indeed: Rage 256 Pro ;) */ | |
2870 | 1023 { PCI_DEVICE_ID_RADEON_QD, "Radeon QD " }, |
1024 { PCI_DEVICE_ID_RADEON_QE, "Radeon QE " }, | |
1025 { PCI_DEVICE_ID_RADEON_QF, "Radeon QF " }, | |
1026 { PCI_DEVICE_ID_RADEON_QG, "Radeon QG " }, | |
1027 { PCI_DEVICE_ID_RADEON_QY, "Radeon VE QY " }, | |
1028 { PCI_DEVICE_ID_RADEON_QZ, "Radeon VE QZ " }, | |
1029 { PCI_DEVICE_ID_RADEON_LY, "Radeon M6 LY " }, | |
1030 { PCI_DEVICE_ID_RADEON_LZ, "Radeon M6 LZ " }, | |
1031 { PCI_DEVICE_ID_RADEON_LW, "Radeon M7 LW " }, | |
1032 { PCI_DEVICE_ID_R200_QL, "Radeon2 8500 QL " }, | |
1033 { PCI_DEVICE_ID_RV200_QW, "Radeon2 7500 QW " } | |
3164 | 1034 #endif |
2870 | 1035 }; |
1036 | |
3247
7cec2396bde3
Tune up driver through reading and writing /dev/radeon_vid ;)
nick
parents:
3198
diff
changeset
|
1037 static int detected_chip; |
7cec2396bde3
Tune up driver through reading and writing /dev/radeon_vid ;)
nick
parents:
3198
diff
changeset
|
1038 |
3265 | 1039 static int __init radeon_vid_config_card(void) |
2870 | 1040 { |
1041 struct pci_dev *dev = NULL; | |
1042 size_t i; | |
1043 | |
1044 for(i=0;i<sizeof(ati_card_ids)/sizeof(struct ati_card_id_s);i++) | |
1045 if((dev=pci_find_device(PCI_VENDOR_ID_ATI, ati_card_ids[i].id, NULL))) | |
1046 break; | |
3122 | 1047 if(!dev) |
2870 | 1048 { |
3164 | 1049 printk(RVID_MSG"No supported cards found\n"); |
2870 | 1050 return FALSE; |
1051 } | |
1052 | |
1053 radeon_mmio_base = ioremap_nocache(pci_resource_start (dev, 2),RADEON_REGSIZE); | |
1054 radeon_mem_base = dev->resource[0].start; | |
1055 | |
3164 | 1056 RTRACE(RVID_MSG"MMIO at 0x%p\n", radeon_mmio_base); |
1057 RTRACE(RVID_MSG"Frame Buffer at 0x%08x\n", radeon_mem_base); | |
2870 | 1058 |
3122 | 1059 /* video memory size */ |
1060 radeon_ram_size = INREG(CONFIG_MEMSIZE); | |
1061 | |
3164 | 1062 /* mem size is bits [28:0], mask off the rest. Range: from 1Mb up to 512 Mb */ |
3122 | 1063 radeon_ram_size &= CONFIG_MEMSIZE_MASK; |
1064 radeon_ram_size /= 0x100000; | |
3247
7cec2396bde3
Tune up driver through reading and writing /dev/radeon_vid ;)
nick
parents:
3198
diff
changeset
|
1065 detected_chip = i; |
3164 | 1066 printk(RVID_MSG"Found %s (%uMb memory)\n",ati_card_ids[i].name,radeon_ram_size); |
3900
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
1067 #ifndef RAGE128 |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
1068 if(ati_card_ids[i].id == PCI_DEVICE_ID_R200_QL || |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
1069 ati_card_ids[i].id == PCI_DEVICE_ID_RV200_QW) IsR200 = 1; |
80d0864322b9
Radeon specific gamma correction initialization. (from gatos.sf.net)
nick
parents:
3607
diff
changeset
|
1070 #endif |
2870 | 1071 return TRUE; |
1072 } | |
1073 | |
3247
7cec2396bde3
Tune up driver through reading and writing /dev/radeon_vid ;)
nick
parents:
3198
diff
changeset
|
1074 #define PARAM_BRIGHTNESS "brightness=" |
7cec2396bde3
Tune up driver through reading and writing /dev/radeon_vid ;)
nick
parents:
3198
diff
changeset
|
1075 #define PARAM_SATURATION "saturation=" |
7cec2396bde3
Tune up driver through reading and writing /dev/radeon_vid ;)
nick
parents:
3198
diff
changeset
|
1076 #define PARAM_DOUBLE_BUFF "double_buff=" |
3250 | 1077 #define PARAM_DEINTERLACE "deinterlace=" |
1078 #define PARAM_DEINTERLACE_PATTERN "deinterlace_pattern=" | |
2870 | 1079 |
3263 | 1080 static void radeon_param_buff_fill( void ) |
2870 | 1081 { |
3247
7cec2396bde3
Tune up driver through reading and writing /dev/radeon_vid ;)
nick
parents:
3198
diff
changeset
|
1082 unsigned len,saturation; |
3366 | 1083 int8_t brightness; |
1084 brightness = besr.brightness & 0x7f; | |
1085 /* FIXME: It's probably x86 specific convertion. But it doesn't matter | |
1086 for general logic - only for printing value */ | |
1087 if(brightness > 63) brightness = (((~besr.brightness) & 0x3f)+1) * (-1); | |
3247
7cec2396bde3
Tune up driver through reading and writing /dev/radeon_vid ;)
nick
parents:
3198
diff
changeset
|
1088 saturation = besr.saturation; |
7cec2396bde3
Tune up driver through reading and writing /dev/radeon_vid ;)
nick
parents:
3198
diff
changeset
|
1089 len = 0; |
3263 | 1090 len += sprintf(&radeon_param_buff[len],"Interface version: %04X\nDriver version: %s\n",MGA_VID_VERSION,RADEON_VID_VERSION); |
1091 len += sprintf(&radeon_param_buff[len],"Chip: %s\n",ati_card_ids[detected_chip].name); | |
3334 | 1092 len += sprintf(&radeon_param_buff[len],"Memory: %x:%x\n",radeon_mem_base,radeon_ram_size*0x100000); |
3263 | 1093 len += sprintf(&radeon_param_buff[len],"MMIO: %p\n",radeon_mmio_base); |
3334 | 1094 len += sprintf(&radeon_param_buff[len],"Overlay offset: %x\n",radeon_overlay_off); |
3269 | 1095 #ifdef CONFIG_MTRR |
3265 | 1096 len += sprintf(&radeon_param_buff[len],"Tune MTRR: %s\n",mtrr?"on":"off"); |
3269 | 1097 #endif |
3278 | 1098 if(besr.ckey_on) len += sprintf(&radeon_param_buff[len],"Last used color_key=%X (mask=%X)\n",besr.graphics_key_clr,besr.graphics_key_msk); |
3265 | 1099 len += sprintf(&radeon_param_buff[len],"Swapped fourcc: %s\n",swap_fourcc?"on":"off"); |
3278 | 1100 len += sprintf(&radeon_param_buff[len],"Last BPP: %u\n",besr.dest_bpp); |
3263 | 1101 len += sprintf(&radeon_param_buff[len],"Last fourcc: %s\n\n",fourcc_format_name(besr.fourcc)); |
1102 len += sprintf(&radeon_param_buff[len],"Configurable stuff:\n"); | |
1103 len += sprintf(&radeon_param_buff[len],"~~~~~~~~~~~~~~~~~~~\n"); | |
1104 len += sprintf(&radeon_param_buff[len],PARAM_DOUBLE_BUFF"%s\n",besr.double_buff?"on":"off"); | |
3470 | 1105 #ifdef RAGE128 |
3366 | 1106 len += sprintf(&radeon_param_buff[len],PARAM_BRIGHTNESS"%i\n",(int)brightness); |
3263 | 1107 len += sprintf(&radeon_param_buff[len],PARAM_SATURATION"%u\n",saturation); |
3470 | 1108 #endif |
3263 | 1109 len += sprintf(&radeon_param_buff[len],PARAM_DEINTERLACE"%s\n",besr.deinterlace_on?"on":"off"); |
1110 len += sprintf(&radeon_param_buff[len],PARAM_DEINTERLACE_PATTERN"%X\n",besr.deinterlace_pattern); | |
1111 radeon_param_buff_len = len; | |
1112 } | |
1113 | |
1114 static ssize_t radeon_vid_read(struct file *file, char *buf, size_t count, loff_t *ppos) | |
1115 { | |
1116 uint32_t size; | |
1117 if(!radeon_param_buff) return -ESPIPE; | |
1118 if(!(*ppos)) radeon_param_buff_fill(); | |
1119 if(*ppos >= radeon_param_buff_len) return 0; | |
1120 size = min(count,radeon_param_buff_len-(uint32_t)(*ppos)); | |
1121 memcpy(buf,radeon_param_buff,size); | |
1122 *ppos += size; | |
1123 return size; | |
2870 | 1124 } |
1125 | |
1126 static ssize_t radeon_vid_write(struct file *file, const char *buf, size_t count, loff_t *ppos) | |
1127 { | |
3470 | 1128 #ifdef RAGE128 |
3247
7cec2396bde3
Tune up driver through reading and writing /dev/radeon_vid ;)
nick
parents:
3198
diff
changeset
|
1129 if(memcmp(buf,PARAM_BRIGHTNESS,min(count,strlen(PARAM_BRIGHTNESS))) == 0) |
7cec2396bde3
Tune up driver through reading and writing /dev/radeon_vid ;)
nick
parents:
3198
diff
changeset
|
1130 { |
7cec2396bde3
Tune up driver through reading and writing /dev/radeon_vid ;)
nick
parents:
3198
diff
changeset
|
1131 long brightness; |
7cec2396bde3
Tune up driver through reading and writing /dev/radeon_vid ;)
nick
parents:
3198
diff
changeset
|
1132 brightness=simple_strtol(&buf[strlen(PARAM_BRIGHTNESS)],NULL,10); |
3368 | 1133 if(brightness >= -64 && brightness <= 63) |
1134 { | |
1135 besr.brightness = brightness; | |
3247
7cec2396bde3
Tune up driver through reading and writing /dev/radeon_vid ;)
nick
parents:
3198
diff
changeset
|
1136 OUTREG(OV0_COLOUR_CNTL, (brightness & 0x7f) | |
3250 | 1137 (besr.saturation << 8) | |
1138 (besr.saturation << 16)); | |
3368 | 1139 } |
3247
7cec2396bde3
Tune up driver through reading and writing /dev/radeon_vid ;)
nick
parents:
3198
diff
changeset
|
1140 } |
7cec2396bde3
Tune up driver through reading and writing /dev/radeon_vid ;)
nick
parents:
3198
diff
changeset
|
1141 else |
7cec2396bde3
Tune up driver through reading and writing /dev/radeon_vid ;)
nick
parents:
3198
diff
changeset
|
1142 if(memcmp(buf,PARAM_SATURATION,min(count,strlen(PARAM_SATURATION))) == 0) |
7cec2396bde3
Tune up driver through reading and writing /dev/radeon_vid ;)
nick
parents:
3198
diff
changeset
|
1143 { |
7cec2396bde3
Tune up driver through reading and writing /dev/radeon_vid ;)
nick
parents:
3198
diff
changeset
|
1144 long saturation; |
7cec2396bde3
Tune up driver through reading and writing /dev/radeon_vid ;)
nick
parents:
3198
diff
changeset
|
1145 saturation=simple_strtol(&buf[strlen(PARAM_SATURATION)],NULL,10); |
7cec2396bde3
Tune up driver through reading and writing /dev/radeon_vid ;)
nick
parents:
3198
diff
changeset
|
1146 if(saturation >= 0 && saturation <= 31) |
7cec2396bde3
Tune up driver through reading and writing /dev/radeon_vid ;)
nick
parents:
3198
diff
changeset
|
1147 OUTREG(OV0_COLOUR_CNTL, (besr.brightness & 0x7f) | |
3250 | 1148 (saturation << 8) | |
1149 (saturation << 16)); | |
3247
7cec2396bde3
Tune up driver through reading and writing /dev/radeon_vid ;)
nick
parents:
3198
diff
changeset
|
1150 } |
7cec2396bde3
Tune up driver through reading and writing /dev/radeon_vid ;)
nick
parents:
3198
diff
changeset
|
1151 else |
3470 | 1152 #endif |
3247
7cec2396bde3
Tune up driver through reading and writing /dev/radeon_vid ;)
nick
parents:
3198
diff
changeset
|
1153 if(memcmp(buf,PARAM_DOUBLE_BUFF,min(count,strlen(PARAM_DOUBLE_BUFF))) == 0) |
7cec2396bde3
Tune up driver through reading and writing /dev/radeon_vid ;)
nick
parents:
3198
diff
changeset
|
1154 { |
3250 | 1155 if(memcmp(&buf[strlen(PARAM_DOUBLE_BUFF)],"on",2) == 0) besr.double_buff = 1; |
1156 else besr.double_buff = 0; | |
1157 } | |
1158 else | |
1159 if(memcmp(buf,PARAM_DEINTERLACE,min(count,strlen(PARAM_DEINTERLACE))) == 0) | |
1160 { | |
1161 if(memcmp(&buf[strlen(PARAM_DEINTERLACE)],"on",2) == 0) besr.deinterlace_on = 1; | |
1162 else besr.deinterlace_on = 0; | |
1163 } | |
1164 else | |
1165 if(memcmp(buf,PARAM_DEINTERLACE_PATTERN,min(count,strlen(PARAM_DEINTERLACE_PATTERN))) == 0) | |
1166 { | |
1167 long dpat; | |
1168 dpat=simple_strtol(&buf[strlen(PARAM_DEINTERLACE_PATTERN)],NULL,16); | |
1169 OUTREG(OV0_DEINTERLACE_PATTERN, dpat); | |
3247
7cec2396bde3
Tune up driver through reading and writing /dev/radeon_vid ;)
nick
parents:
3198
diff
changeset
|
1170 } |
3263 | 1171 else count = -EIO; |
3247
7cec2396bde3
Tune up driver through reading and writing /dev/radeon_vid ;)
nick
parents:
3198
diff
changeset
|
1172 radeon_vid_preset(); |
7cec2396bde3
Tune up driver through reading and writing /dev/radeon_vid ;)
nick
parents:
3198
diff
changeset
|
1173 return count; |
2870 | 1174 } |
1175 | |
1176 static int radeon_vid_mmap(struct file *file, struct vm_area_struct *vma) | |
1177 { | |
1178 | |
3164 | 1179 RTRACE(RVID_MSG"mapping video memory into userspace\n"); |
3019 | 1180 if(remap_page_range(vma->vm_start, radeon_mem_base + radeon_overlay_off, |
2870 | 1181 vma->vm_end - vma->vm_start, vma->vm_page_prot)) |
1182 { | |
3164 | 1183 printk(RVID_MSG"error mapping video memory\n"); |
2870 | 1184 return(-EAGAIN); |
1185 } | |
1186 | |
1187 return(0); | |
1188 } | |
1189 | |
1190 static int radeon_vid_release(struct inode *inode, struct file *file) | |
1191 { | |
1192 radeon_vid_in_use = 0; | |
1193 radeon_vid_stop_video(); | |
1194 | |
1195 MOD_DEC_USE_COUNT; | |
1196 return 0; | |
1197 } | |
1198 | |
1199 static long long radeon_vid_lseek(struct file *file, long long offset, int origin) | |
1200 { | |
1201 return -ESPIPE; | |
1202 } | |
1203 | |
1204 static int radeon_vid_open(struct inode *inode, struct file *file) | |
1205 { | |
1206 int minor = MINOR(inode->i_rdev); | |
1207 | |
1208 if(minor != 0) | |
1209 return(-ENXIO); | |
1210 | |
1211 if(radeon_vid_in_use == 1) | |
1212 return(-EBUSY); | |
1213 | |
1214 radeon_vid_in_use = 1; | |
1215 MOD_INC_USE_COUNT; | |
1216 return(0); | |
1217 } | |
1218 | |
1219 #if LINUX_VERSION_CODE >= 0x020400 | |
1220 static struct file_operations radeon_vid_fops = | |
1221 { | |
1222 llseek: radeon_vid_lseek, | |
3366 | 1223 read: radeon_vid_read, |
2870 | 1224 write: radeon_vid_write, |
3366 | 1225 /* |
1226 readdir: | |
1227 poll: | |
1228 */ | |
2870 | 1229 ioctl: radeon_vid_ioctl, |
3366 | 1230 mmap: radeon_vid_mmap, |
1231 open: radeon_vid_open, | |
1232 /* | |
1233 flush: | |
1234 */ | |
2870 | 1235 release: radeon_vid_release |
3366 | 1236 /* |
1237 fsync: | |
1238 fasync: | |
1239 lock: | |
1240 readv: | |
1241 writev: | |
1242 sendpage: | |
1243 get_unmapped_area: | |
1244 */ | |
2870 | 1245 }; |
1246 #else | |
1247 static struct file_operations radeon_vid_fops = | |
1248 { | |
1249 radeon_vid_lseek, | |
1250 radeon_vid_read, | |
1251 radeon_vid_write, | |
1252 NULL, | |
1253 NULL, | |
1254 radeon_vid_ioctl, | |
1255 radeon_vid_mmap, | |
1256 radeon_vid_open, | |
1257 NULL, | |
1258 radeon_vid_release | |
1259 }; | |
1260 #endif | |
1261 | |
1262 /* | |
1263 * Main Initialization Function | |
1264 */ | |
1265 | |
3265 | 1266 static int __init radeon_vid_initialize(void) |
2870 | 1267 { |
1268 radeon_vid_in_use = 0; | |
3164 | 1269 #ifdef RAGE128 |
1270 printk(RVID_MSG"Rage128/Rage128Pro video overlay driver v"RADEON_VID_VERSION" (C) Nick Kurshev\n"); | |
1271 #else | |
1272 printk(RVID_MSG"Radeon video overlay driver v"RADEON_VID_VERSION" (C) Nick Kurshev\n"); | |
1273 #endif | |
2870 | 1274 if(register_chrdev(RADEON_VID_MAJOR, "radeon_vid", &radeon_vid_fops)) |
1275 { | |
3164 | 1276 printk(RVID_MSG"unable to get major: %d\n", RADEON_VID_MAJOR); |
2870 | 1277 return -EIO; |
1278 } | |
1279 | |
1280 if (!radeon_vid_config_card()) | |
1281 { | |
3164 | 1282 printk(RVID_MSG"can't configure this card\n"); |
2870 | 1283 unregister_chrdev(RADEON_VID_MAJOR, "radeon_vid"); |
1284 return -EINVAL; | |
1285 } | |
3263 | 1286 radeon_param_buff = kmalloc(PARAM_BUFF_SIZE,GFP_KERNEL); |
1287 if(radeon_param_buff) radeon_param_buff_size = PARAM_BUFF_SIZE; | |
3607
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
1288 #if 0 |
2870 | 1289 radeon_vid_save_state(); |
3607
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
1290 #endif |
3250 | 1291 radeon_vid_make_default(); |
3247
7cec2396bde3
Tune up driver through reading and writing /dev/radeon_vid ;)
nick
parents:
3198
diff
changeset
|
1292 radeon_vid_preset(); |
3265 | 1293 #ifdef CONFIG_MTRR |
1294 if (mtrr) { | |
1295 smtrr.vram = mtrr_add(radeon_mem_base, | |
1296 radeon_ram_size*0x100000, MTRR_TYPE_WRCOMB, 1); | |
1297 smtrr.vram_valid = 1; | |
1298 /* let there be speed */ | |
1299 printk(RVID_MSG"MTRR set to ON\n"); | |
1300 } | |
1301 #endif /* CONFIG_MTRR */ | |
2870 | 1302 return(0); |
1303 } | |
1304 | |
3265 | 1305 int __init init_module(void) |
2870 | 1306 { |
1307 return radeon_vid_initialize(); | |
1308 } | |
1309 | |
3265 | 1310 void __exit cleanup_module(void) |
2870 | 1311 { |
3607
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
1312 #if 0 |
2870 | 1313 radeon_vid_restore_state(); |
3607
f5cc15e11d6e
+ Added support of FIFO engine (suggested by Vladimir Dergachev)
nick
parents:
3487
diff
changeset
|
1314 #endif |
2870 | 1315 if(radeon_mmio_base) |
1316 iounmap(radeon_mmio_base); | |
3263 | 1317 kfree(radeon_param_buff); |
3164 | 1318 RTRACE(RVID_MSG"Cleaning up module\n"); |
2870 | 1319 unregister_chrdev(RADEON_VID_MAJOR, "radeon_vid"); |
3265 | 1320 #ifdef CONFIG_MTRR |
1321 if (smtrr.vram_valid) | |
1322 mtrr_del(smtrr.vram, radeon_mem_base, | |
1323 radeon_ram_size*0x100000); | |
1324 #endif /* CONFIG_MTRR */ | |
2870 | 1325 } |
1326 |