annotate drivers/radeon/radeon_vid.c @ 3607:f5cc15e11d6e

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