annotate drivers/radeon_vid.c @ 33484:4f940d7917f0

Provide a desktop icon of reasonable size (48x48) and quality. All three icon files (ico, png and xpm) derive from the same 48x48 graphic which itself derives from the svg at http://en.wikipedia.org/wiki/File:MPlayer.svg. GUI's icon has been renamed mplayer.xpm (from MPlayer_mini.xpm) and the format of the icon to be installed has been changed from xpm to png.
author ib
date Tue, 07 Jun 2011 15:16:22 +0000
parents 32725ca88fed
children 958431e2cde0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
22691
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1 /*
26003
a506a6ab14e1 Add standard license header and make copyright notices consistent.
diego
parents: 25862
diff changeset
2 * BES YUV video overlay driver for Radeon/Rage128Pro/Rage128 cards
22691
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
3 *
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
4 * Copyright (C) 2001 Nick Kurshev
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
5 *
26003
a506a6ab14e1 Add standard license header and make copyright notices consistent.
diego
parents: 25862
diff changeset
6 * This file is partly based on mga_vid and sis_vid from MPlayer.
a506a6ab14e1 Add standard license header and make copyright notices consistent.
diego
parents: 25862
diff changeset
7 * Code from CVS of GATOS project and X11 trees was also used.
22691
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
8 *
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
9 * SPECIAL THANKS TO: Hans-Peter Raschke for active testing and hacking
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
10 * Rage128(pro) stuff of this driver.
26003
a506a6ab14e1 Add standard license header and make copyright notices consistent.
diego
parents: 25862
diff changeset
11 *
a506a6ab14e1 Add standard license header and make copyright notices consistent.
diego
parents: 25862
diff changeset
12 * This file is part of MPlayer.
a506a6ab14e1 Add standard license header and make copyright notices consistent.
diego
parents: 25862
diff changeset
13 *
a506a6ab14e1 Add standard license header and make copyright notices consistent.
diego
parents: 25862
diff changeset
14 * MPlayer is free software; you can redistribute it and/or modify
a506a6ab14e1 Add standard license header and make copyright notices consistent.
diego
parents: 25862
diff changeset
15 * it under the terms of the GNU General Public License as published by
a506a6ab14e1 Add standard license header and make copyright notices consistent.
diego
parents: 25862
diff changeset
16 * the Free Software Foundation; either version 2 of the License, or
a506a6ab14e1 Add standard license header and make copyright notices consistent.
diego
parents: 25862
diff changeset
17 * (at your option) any later version.
a506a6ab14e1 Add standard license header and make copyright notices consistent.
diego
parents: 25862
diff changeset
18 *
a506a6ab14e1 Add standard license header and make copyright notices consistent.
diego
parents: 25862
diff changeset
19 * MPlayer is distributed in the hope that it will be useful,
a506a6ab14e1 Add standard license header and make copyright notices consistent.
diego
parents: 25862
diff changeset
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
a506a6ab14e1 Add standard license header and make copyright notices consistent.
diego
parents: 25862
diff changeset
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a506a6ab14e1 Add standard license header and make copyright notices consistent.
diego
parents: 25862
diff changeset
22 * GNU General Public License for more details.
a506a6ab14e1 Add standard license header and make copyright notices consistent.
diego
parents: 25862
diff changeset
23 *
a506a6ab14e1 Add standard license header and make copyright notices consistent.
diego
parents: 25862
diff changeset
24 * You should have received a copy of the GNU General Public License along
a506a6ab14e1 Add standard license header and make copyright notices consistent.
diego
parents: 25862
diff changeset
25 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
a506a6ab14e1 Add standard license header and make copyright notices consistent.
diego
parents: 25862
diff changeset
26 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22691
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
27 */
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
28
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
29 #define RADEON_VID_VERSION "1.2.1"
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
30
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
31 /*
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
32 It's entirely possible this major conflicts with something else
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
33 mknod /dev/radeon_vid c 178 0
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
34 or
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
35 mknod /dev/rage128_vid c 178 0
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
36 for Rage128/Rage128Pro chips (although it doesn't matter)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
37 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
38 TESTED and WORKING formats: YUY2, UYVY, IYUV, I420, YV12
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
39 -----------------------------------------------------------
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
40 TODO:
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
41 Highest priority: fbvid.h compatibility
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
42 High priority: Fixing BUGS
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
43 Middle priority: RGB/BGR 2-32, YVU9, IF09 support
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
44 Low priority: CLPL, IYU1, IYU2, UYNV, CYUV, YUNV, YVYU, Y41P, Y211, Y41T,
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
45 ^^^^
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
46 Y42T, V422, V655, CLJR, YUVP, UYVP, Mpeg PES (mpeg-1,2) support
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
47 ...........................................................
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
48 BUGS and LACKS:
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
49 Color and video keys don't work
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
50 */
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
51
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
52 #include <linux/config.h>
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
53 #include <linux/version.h>
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
54 #include <linux/module.h>
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
55 #include <linux/types.h>
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
56 #include <linux/kernel.h>
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
57 #include <linux/sched.h>
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
58 #include <linux/mm.h>
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
59 #include <linux/string.h>
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
60 #include <linux/errno.h>
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
61 #include <linux/slab.h>
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
62 #include <linux/pci.h>
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
63 #include <linux/ioport.h>
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
64 #include <linux/init.h>
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
65 #include <linux/byteorder/swab.h>
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
66
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
67 #include "radeon_vid.h"
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
68 #include "radeon.h"
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
69
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27757
diff changeset
70 #ifdef CONFIG_MTRR
22691
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
71 #include <asm/mtrr.h>
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
72 #endif
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
73
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
74 #include <asm/uaccess.h>
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
75 #include <asm/system.h>
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
76 #include <asm/io.h>
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
77
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
78 #define TRUE 1
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
79 #define FALSE 0
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
80
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
81 #define RADEON_VID_MAJOR 178
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
82
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
83
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
84 MODULE_AUTHOR("Nick Kurshev <nickols_k@mail.ru>");
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
85 #ifdef RAGE128
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
86 MODULE_DESCRIPTION("Accelerated YUV BES driver for Rage128. Version: "RADEON_VID_VERSION);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
87 #else
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
88 MODULE_DESCRIPTION("Accelerated YUV BES driver for Radeons. Version: "RADEON_VID_VERSION);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
89 #endif
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
90 #ifdef MODULE_LICENSE
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
91 MODULE_LICENSE("GPL");
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
92 #endif
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27757
diff changeset
93 #ifdef CONFIG_MTRR
22691
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
94 MODULE_PARM(mtrr, "i");
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
95 MODULE_PARM_DESC(mtrr, "Tune MTRR (touch=1(default))");
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
96 static int mtrr __initdata = 1;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
97 static struct { int vram; int vram_valid; } smtrr;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
98 #endif
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
99 MODULE_PARM(swap_fourcc, "i");
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
100 MODULE_PARM_DESC(swap_fourcc, "Swap fourcc (don't swap=0(default))");
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
101 static int swap_fourcc __initdata = 0;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
102
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
103 #ifdef RAGE128
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
104 #define RVID_MSG "rage128_vid: "
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
105 #define X_ADJUST 0
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
106 #else
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
107 #define RVID_MSG "radeon_vid: "
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
108 #define X_ADJUST 8
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
109 #ifndef RADEON
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
110 #define RADEON
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
111 #endif
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
112 #endif
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
113
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
114 #undef DEBUG
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
115 #if DEBUG
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
116 #define RTRACE printk
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
117 #else
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
118 #define RTRACE(...) ((void)0)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
119 #endif
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
120
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
121 #ifndef min
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
122 #define min(a,b) (a < b ? a : b)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
123 #endif
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
124
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
125 #ifndef RAGE128
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
126 #if defined(__i386__)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
127 /* Ugly but only way */
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
128 #undef AVOID_FPU
25862
4be9faee0360 Rename some identifiers to not use leading underscores.
diego
parents: 22691
diff changeset
129 static inline double FastSin(double x)
22691
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
130 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
131 register double res;
27757
b5a46071062a Replace all occurrences of '__volatile__' and '__volatile' by plain 'volatile'.
diego
parents: 27754
diff changeset
132 __asm__ volatile("fsin":"=t"(res):"0"(x));
22691
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
133 return res;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
134 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
135 #undef sin
25862
4be9faee0360 Rename some identifiers to not use leading underscores.
diego
parents: 22691
diff changeset
136 #define sin(x) FastSin(x)
22691
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
137
25862
4be9faee0360 Rename some identifiers to not use leading underscores.
diego
parents: 22691
diff changeset
138 static inline double FastCos(double x)
22691
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
139 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
140 register double res;
27757
b5a46071062a Replace all occurrences of '__volatile__' and '__volatile' by plain 'volatile'.
diego
parents: 27754
diff changeset
141 __asm__ volatile("fcos":"=t"(res):"0"(x));
22691
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
142 return res;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
143 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
144 #undef cos
25862
4be9faee0360 Rename some identifiers to not use leading underscores.
diego
parents: 22691
diff changeset
145 #define cos(x) FastCos(x)
22691
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
146 #else
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
147 #include "generic_math.h"
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
148 #endif /*__386__*/
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
149 #endif /*RAGE128*/
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
150
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
151 #if !defined( RAGE128 ) && !defined( AVOID_FPU )
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
152 #define RADEON_FPU 1
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
153 #endif
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
154
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
155 typedef struct bes_registers_s
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
156 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
157 /* base address of yuv framebuffer */
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
158 uint32_t yuv_base;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
159 uint32_t fourcc;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
160 uint32_t dest_bpp;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
161 /* YUV BES registers */
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
162 uint32_t reg_load_cntl;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
163 uint32_t h_inc;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
164 uint32_t step_by;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
165 uint32_t y_x_start;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
166 uint32_t y_x_end;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
167 uint32_t v_inc;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
168 uint32_t p1_blank_lines_at_top;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
169 uint32_t p23_blank_lines_at_top;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
170 uint32_t vid_buf_pitch0_value;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
171 uint32_t vid_buf_pitch1_value;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
172 uint32_t p1_x_start_end;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
173 uint32_t p2_x_start_end;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
174 uint32_t p3_x_start_end;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
175 uint32_t base_addr;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
176 uint32_t vid_buf0_base_adrs;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
177 /* These ones are for auto flip: maybe in the future */
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
178 uint32_t vid_buf1_base_adrs;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
179 uint32_t vid_buf2_base_adrs;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
180 uint32_t vid_buf3_base_adrs;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
181 uint32_t vid_buf4_base_adrs;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
182 uint32_t vid_buf5_base_adrs;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
183
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
184 uint32_t p1_v_accum_init;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
185 uint32_t p1_h_accum_init;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
186 uint32_t p23_v_accum_init;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
187 uint32_t p23_h_accum_init;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
188 uint32_t scale_cntl;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
189 uint32_t exclusive_horz;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
190 uint32_t auto_flip_cntl;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
191 uint32_t filter_cntl;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
192 uint32_t key_cntl;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
193 uint32_t test;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
194 /* Configurable stuff */
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
195 int double_buff;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27757
diff changeset
196
22691
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
197 int brightness;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
198 int saturation;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27757
diff changeset
199
22691
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
200 int ckey_on;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
201 uint32_t graphics_key_clr;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
202 uint32_t graphics_key_msk;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27757
diff changeset
203
22691
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
204 int deinterlace_on;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
205 uint32_t deinterlace_pattern;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27757
diff changeset
206
22691
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
207 } bes_registers_t;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
208
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
209 typedef struct video_registers_s
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
210 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
211 #ifdef DEBUG
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
212 const char * sname;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
213 #endif
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
214 uint32_t name;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
215 uint32_t value;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
216 }video_registers_t;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
217
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
218 static bes_registers_t besr;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
219 #ifndef RAGE128
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
220 static int IsR200=0;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
221 #endif
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
222 #ifdef DEBUG
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
223 #define DECLARE_VREG(name) { #name, name, 0 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
224 #else
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
225 #define DECLARE_VREG(name) { name, 0 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
226 #endif
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
227 #ifdef DEBUG
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27757
diff changeset
228 static video_registers_t vregs[] =
22691
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
229 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
230 DECLARE_VREG(VIDEOMUX_CNTL),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
231 DECLARE_VREG(VIPPAD_MASK),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
232 DECLARE_VREG(VIPPAD1_A),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
233 DECLARE_VREG(VIPPAD1_EN),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
234 DECLARE_VREG(VIPPAD1_Y),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
235 DECLARE_VREG(OV0_Y_X_START),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
236 DECLARE_VREG(OV0_Y_X_END),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
237 DECLARE_VREG(OV0_PIPELINE_CNTL),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
238 DECLARE_VREG(OV0_EXCLUSIVE_HORZ),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
239 DECLARE_VREG(OV0_EXCLUSIVE_VERT),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
240 DECLARE_VREG(OV0_REG_LOAD_CNTL),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
241 DECLARE_VREG(OV0_SCALE_CNTL),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
242 DECLARE_VREG(OV0_V_INC),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
243 DECLARE_VREG(OV0_P1_V_ACCUM_INIT),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
244 DECLARE_VREG(OV0_P23_V_ACCUM_INIT),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
245 DECLARE_VREG(OV0_P1_BLANK_LINES_AT_TOP),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
246 DECLARE_VREG(OV0_P23_BLANK_LINES_AT_TOP),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
247 #ifdef RADEON
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
248 DECLARE_VREG(OV0_BASE_ADDR),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
249 #endif
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
250 DECLARE_VREG(OV0_VID_BUF0_BASE_ADRS),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
251 DECLARE_VREG(OV0_VID_BUF1_BASE_ADRS),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
252 DECLARE_VREG(OV0_VID_BUF2_BASE_ADRS),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
253 DECLARE_VREG(OV0_VID_BUF3_BASE_ADRS),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
254 DECLARE_VREG(OV0_VID_BUF4_BASE_ADRS),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
255 DECLARE_VREG(OV0_VID_BUF5_BASE_ADRS),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
256 DECLARE_VREG(OV0_VID_BUF_PITCH0_VALUE),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
257 DECLARE_VREG(OV0_VID_BUF_PITCH1_VALUE),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
258 DECLARE_VREG(OV0_AUTO_FLIP_CNTL),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
259 DECLARE_VREG(OV0_DEINTERLACE_PATTERN),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
260 DECLARE_VREG(OV0_SUBMIT_HISTORY),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
261 DECLARE_VREG(OV0_H_INC),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
262 DECLARE_VREG(OV0_STEP_BY),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
263 DECLARE_VREG(OV0_P1_H_ACCUM_INIT),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
264 DECLARE_VREG(OV0_P23_H_ACCUM_INIT),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
265 DECLARE_VREG(OV0_P1_X_START_END),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
266 DECLARE_VREG(OV0_P2_X_START_END),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
267 DECLARE_VREG(OV0_P3_X_START_END),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
268 DECLARE_VREG(OV0_FILTER_CNTL),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
269 DECLARE_VREG(OV0_FOUR_TAP_COEF_0),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
270 DECLARE_VREG(OV0_FOUR_TAP_COEF_1),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
271 DECLARE_VREG(OV0_FOUR_TAP_COEF_2),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
272 DECLARE_VREG(OV0_FOUR_TAP_COEF_3),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
273 DECLARE_VREG(OV0_FOUR_TAP_COEF_4),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
274 DECLARE_VREG(OV0_FLAG_CNTL),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
275 #ifdef RAGE128
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
276 DECLARE_VREG(OV0_COLOUR_CNTL),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
277 #else
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
278 DECLARE_VREG(OV0_SLICE_CNTL),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
279 #endif
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
280 DECLARE_VREG(OV0_VID_KEY_CLR),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
281 DECLARE_VREG(OV0_VID_KEY_MSK),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
282 DECLARE_VREG(OV0_GRAPHICS_KEY_CLR),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
283 DECLARE_VREG(OV0_GRAPHICS_KEY_MSK),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
284 DECLARE_VREG(OV0_KEY_CNTL),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
285 DECLARE_VREG(OV0_TEST),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
286 DECLARE_VREG(OV0_LIN_TRANS_A),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
287 DECLARE_VREG(OV0_LIN_TRANS_B),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
288 DECLARE_VREG(OV0_LIN_TRANS_C),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
289 DECLARE_VREG(OV0_LIN_TRANS_D),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
290 DECLARE_VREG(OV0_LIN_TRANS_E),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
291 DECLARE_VREG(OV0_LIN_TRANS_F),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
292 DECLARE_VREG(OV0_GAMMA_0_F),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
293 DECLARE_VREG(OV0_GAMMA_10_1F),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
294 DECLARE_VREG(OV0_GAMMA_20_3F),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
295 DECLARE_VREG(OV0_GAMMA_40_7F),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
296 DECLARE_VREG(OV0_GAMMA_380_3BF),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
297 DECLARE_VREG(OV0_GAMMA_3C0_3FF),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
298 DECLARE_VREG(SUBPIC_CNTL),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
299 DECLARE_VREG(SUBPIC_DEFCOLCON),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
300 DECLARE_VREG(SUBPIC_Y_X_START),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
301 DECLARE_VREG(SUBPIC_Y_X_END),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
302 DECLARE_VREG(SUBPIC_V_INC),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
303 DECLARE_VREG(SUBPIC_H_INC),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
304 DECLARE_VREG(SUBPIC_BUF0_OFFSET),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
305 DECLARE_VREG(SUBPIC_BUF1_OFFSET),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
306 DECLARE_VREG(SUBPIC_LC0_OFFSET),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
307 DECLARE_VREG(SUBPIC_LC1_OFFSET),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
308 DECLARE_VREG(SUBPIC_PITCH),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
309 DECLARE_VREG(SUBPIC_BTN_HLI_COLCON),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
310 DECLARE_VREG(SUBPIC_BTN_HLI_Y_X_START),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
311 DECLARE_VREG(SUBPIC_BTN_HLI_Y_X_END),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
312 DECLARE_VREG(SUBPIC_PALETTE_INDEX),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
313 DECLARE_VREG(SUBPIC_PALETTE_DATA),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
314 DECLARE_VREG(SUBPIC_H_ACCUM_INIT),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
315 DECLARE_VREG(SUBPIC_V_ACCUM_INIT),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
316 DECLARE_VREG(IDCT_RUNS),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
317 DECLARE_VREG(IDCT_LEVELS),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
318 DECLARE_VREG(IDCT_AUTH_CONTROL),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
319 DECLARE_VREG(IDCT_AUTH),
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
320 DECLARE_VREG(IDCT_CONTROL)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
321 };
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
322 #endif
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
323 static uint32_t radeon_vid_in_use = 0;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
324
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
325 static uint8_t *radeon_mmio_base = 0;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27757
diff changeset
326 static uint32_t radeon_mem_base = 0;
22691
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
327 static int32_t radeon_overlay_off = 0;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
328 static uint32_t radeon_ram_size = 0;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
329 #define PARAM_BUFF_SIZE 4096
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
330 static uint8_t *radeon_param_buff = NULL;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
331 static uint32_t radeon_param_buff_size=0;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
332 static uint32_t radeon_param_buff_len=0; /* real length of buffer */
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27757
diff changeset
333 static mga_vid_config_t radeon_config;
22691
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
334
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
335 static char *fourcc_format_name(int format)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
336 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
337 switch(format)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
338 {
26759
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26003
diff changeset
339 case IMGFMT_RGB8: return "RGB 8-bit";
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26003
diff changeset
340 case IMGFMT_RGB15: return "RGB 15-bit";
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26003
diff changeset
341 case IMGFMT_RGB16: return "RGB 16-bit";
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26003
diff changeset
342 case IMGFMT_RGB24: return "RGB 24-bit";
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26003
diff changeset
343 case IMGFMT_RGB32: return "RGB 32-bit";
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26003
diff changeset
344 case IMGFMT_BGR8: return "BGR 8-bit";
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26003
diff changeset
345 case IMGFMT_BGR15: return "BGR 15-bit";
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26003
diff changeset
346 case IMGFMT_BGR16: return "BGR 16-bit";
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26003
diff changeset
347 case IMGFMT_BGR24: return "BGR 24-bit";
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26003
diff changeset
348 case IMGFMT_BGR32: return "BGR 32-bit";
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26003
diff changeset
349 case IMGFMT_YVU9: return "Planar YVU9";
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26003
diff changeset
350 case IMGFMT_IF09: return "Planar IF09";
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26003
diff changeset
351 case IMGFMT_YV12: return "Planar YV12";
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26003
diff changeset
352 case IMGFMT_I420: return "Planar I420";
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26003
diff changeset
353 case IMGFMT_IYUV: return "Planar IYUV";
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26003
diff changeset
354 case IMGFMT_CLPL: return "Planar CLPL";
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26003
diff changeset
355 case IMGFMT_Y800: return "Planar Y800";
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26003
diff changeset
356 case IMGFMT_Y8: return "Planar Y8";
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26003
diff changeset
357 case IMGFMT_IUYV: return "Packed IUYV";
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26003
diff changeset
358 case IMGFMT_IY41: return "Packed IY41";
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26003
diff changeset
359 case IMGFMT_IYU1: return "Packed IYU1";
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26003
diff changeset
360 case IMGFMT_IYU2: return "Packed IYU2";
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26003
diff changeset
361 case IMGFMT_UYNV: return "Packed UYNV";
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26003
diff changeset
362 case IMGFMT_cyuv: return "Packed CYUV";
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26003
diff changeset
363 case IMGFMT_Y422: return "Packed Y422";
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26003
diff changeset
364 case IMGFMT_YUY2: return "Packed YUY2";
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26003
diff changeset
365 case IMGFMT_YUNV: return "Packed YUNV";
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26003
diff changeset
366 case IMGFMT_UYVY: return "Packed UYVY";
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26003
diff changeset
367 // case IMGFMT_YVYU: return "Packed YVYU";
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26003
diff changeset
368 case IMGFMT_Y41P: return "Packed Y41P";
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26003
diff changeset
369 case IMGFMT_Y211: return "Packed Y211";
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26003
diff changeset
370 case IMGFMT_Y41T: return "Packed Y41T";
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26003
diff changeset
371 case IMGFMT_Y42T: return "Packed Y42T";
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26003
diff changeset
372 case IMGFMT_V422: return "Packed V422";
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26003
diff changeset
373 case IMGFMT_V655: return "Packed V655";
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26003
diff changeset
374 case IMGFMT_CLJR: return "Packed CLJR";
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26003
diff changeset
375 case IMGFMT_YUVP: return "Packed YUVP";
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26003
diff changeset
376 case IMGFMT_UYVP: return "Packed UYVP";
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26003
diff changeset
377 case IMGFMT_MPEGPES: return "Mpeg PES";
22691
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
378 }
26759
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26003
diff changeset
379 return "Unknown";
22691
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
380 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
381
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
382
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
383 /*
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
384 * IO macros
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
385 */
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
386
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
387 #define INREG8(addr) readb((radeon_mmio_base)+addr)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
388 #define OUTREG8(addr,val) writeb(val, (radeon_mmio_base)+addr)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
389 #define INREG(addr) readl((radeon_mmio_base)+addr)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
390 #define OUTREG(addr,val) writel(val, (radeon_mmio_base)+addr)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
391 #define OUTREGP(addr,val,mask) \
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
392 do { \
25862
4be9faee0360 Rename some identifiers to not use leading underscores.
diego
parents: 22691
diff changeset
393 unsigned int tmp = INREG(addr); \
4be9faee0360 Rename some identifiers to not use leading underscores.
diego
parents: 22691
diff changeset
394 tmp &= (mask); \
4be9faee0360 Rename some identifiers to not use leading underscores.
diego
parents: 22691
diff changeset
395 tmp |= (val); \
4be9faee0360 Rename some identifiers to not use leading underscores.
diego
parents: 22691
diff changeset
396 OUTREG(addr, tmp); \
22691
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
397 } while (0)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
398
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
399 static uint32_t radeon_vid_get_dbpp( void )
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
400 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
401 uint32_t dbpp,retval;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
402 dbpp = (INREG(CRTC_GEN_CNTL)>>8)& 0xF;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
403 switch(dbpp)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
404 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
405 case DST_8BPP: retval = 8; break;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
406 case DST_15BPP: retval = 15; break;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
407 case DST_16BPP: retval = 16; break;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
408 case DST_24BPP: retval = 24; break;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
409 default: retval=32; break;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
410 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
411 return retval;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
412 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
413
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
414 static int radeon_is_dbl_scan( void )
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
415 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
416 return (INREG(CRTC_GEN_CNTL))&CRTC_DBL_SCAN_EN;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
417 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
418
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
419 static int radeon_is_interlace( void )
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
420 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
421 return (INREG(CRTC_GEN_CNTL))&CRTC_INTERLACE_EN;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
422 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
423
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
424 static __inline__ void radeon_engine_flush ( void )
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
425 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
426 int i;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
427
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
428 /* initiate flush */
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
429 OUTREGP(RB2D_DSTCACHE_CTLSTAT, RB2D_DC_FLUSH_ALL,
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
430 ~RB2D_DC_FLUSH_ALL);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
431
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
432 for (i=0; i < 2000000; i++) {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
433 if (!(INREG(RB2D_DSTCACHE_CTLSTAT) & RB2D_DC_BUSY))
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
434 break;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
435 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
436 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
437
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
438
25862
4be9faee0360 Rename some identifiers to not use leading underscores.
diego
parents: 22691
diff changeset
439 static __inline__ void radeon_fifo_wait (int entries)
22691
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
440 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
441 int i;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
442
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
443 for (i=0; i<2000000; i++)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
444 if ((INREG(RBBM_STATUS) & 0x7f) >= entries)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
445 return;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
446 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
447
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
448
25862
4be9faee0360 Rename some identifiers to not use leading underscores.
diego
parents: 22691
diff changeset
449 static __inline__ void radeon_engine_idle ( void )
22691
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
450 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
451 int i;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
452
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
453 /* ensure FIFO is empty before waiting for idle */
25862
4be9faee0360 Rename some identifiers to not use leading underscores.
diego
parents: 22691
diff changeset
454 radeon_fifo_wait (64);
22691
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
455
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
456 for (i=0; i<2000000; i++) {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
457 if (((INREG(RBBM_STATUS) & GUI_ACTIVE)) == 0) {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
458 radeon_engine_flush ();
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
459 return;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
460 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
461 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
462 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
463
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
464 #if 0
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
465 static void __init radeon_vid_save_state( void )
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
466 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
467 size_t i;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
468 for(i=0;i<sizeof(vregs)/sizeof(video_registers_t);i++)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
469 vregs[i].value = INREG(vregs[i].name);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
470 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
471
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
472 static void __exit radeon_vid_restore_state( void )
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
473 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
474 size_t i;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
475 radeon_fifo_wait(2);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
476 OUTREG(OV0_REG_LOAD_CNTL, REG_LD_CTL_LOCK);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
477 radeon_engine_idle();
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
478 while(!(INREG(OV0_REG_LOAD_CNTL)&REG_LD_CTL_LOCK_READBACK));
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
479 radeon_fifo_wait(15);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
480 for(i=0;i<sizeof(vregs)/sizeof(video_registers_t);i++)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
481 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
482 radeon_fifo_wait(1);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
483 OUTREG(vregs[i].name,vregs[i].value);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
484 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
485 OUTREG(OV0_REG_LOAD_CNTL, 0);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
486 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
487 #endif
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
488 #ifdef DEBUG
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
489 static void radeon_vid_dump_regs( void )
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
490 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
491 size_t i;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
492 printk(RVID_MSG"*** Begin of OV0 registers dump ***\n");
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
493 for(i=0;i<sizeof(vregs)/sizeof(video_registers_t);i++)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
494 printk(RVID_MSG"%s = %08X\n",vregs[i].sname,INREG(vregs[i].name));
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
495 printk(RVID_MSG"*** End of OV0 registers dump ***\n");
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
496 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
497 #endif
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
498
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
499 #ifdef RADEON_FPU
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
500 /* Reference color space transform data */
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
501 typedef struct tagREF_TRANSFORM
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
502 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
503 float RefLuma;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
504 float RefRCb;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
505 float RefRCr;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
506 float RefGCb;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
507 float RefGCr;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
508 float RefBCb;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
509 float RefBCr;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
510 } REF_TRANSFORM;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
511
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
512 /* Parameters for ITU-R BT.601 and ITU-R BT.709 colour spaces */
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
513 REF_TRANSFORM trans[2] =
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
514 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
515 {1.1678, 0.0, 1.6007, -0.3929, -0.8154, 2.0232, 0.0}, /* BT.601 */
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
516 {1.1678, 0.0, 1.7980, -0.2139, -0.5345, 2.1186, 0.0} /* BT.709 */
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
517 };
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
518 /****************************************************************************
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
519 * SetTransform *
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
520 * Function: Calculates and sets color space transform from supplied *
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
521 * reference transform, gamma, brightness, contrast, hue and *
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
522 * saturation. *
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
523 * Inputs: bright - brightness *
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
524 * cont - contrast *
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
525 * sat - saturation *
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
526 * hue - hue *
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
527 * ref - index to the table of refernce transforms *
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
528 * Outputs: NONE *
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
529 ****************************************************************************/
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
530
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
531 static void radeon_set_transform(float bright, float cont, float sat,
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
532 float hue, unsigned ref)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
533 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
534 float OvHueSin, OvHueCos;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
535 float CAdjLuma, CAdjOff;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
536 float CAdjRCb, CAdjRCr;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
537 float CAdjGCb, CAdjGCr;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
538 float CAdjBCb, CAdjBCr;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
539 float OvLuma, OvROff, OvGOff, OvBOff;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
540 float OvRCb, OvRCr;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
541 float OvGCb, OvGCr;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
542 float OvBCb, OvBCr;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
543 float Loff = 64.0;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
544 float Coff = 512.0f;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
545
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
546 u32 dwOvLuma, dwOvROff, dwOvGOff, dwOvBOff;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
547 u32 dwOvRCb, dwOvRCr;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
548 u32 dwOvGCb, dwOvGCr;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
549 u32 dwOvBCb, dwOvBCr;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
550
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
551 if (ref >= 2) return;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
552
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
553 OvHueSin = sin((double)hue);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
554 OvHueCos = cos((double)hue);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
555
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
556 CAdjLuma = cont * trans[ref].RefLuma;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
557 CAdjOff = cont * trans[ref].RefLuma * bright * 1023.0;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
558
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
559 CAdjRCb = sat * -OvHueSin * trans[ref].RefRCr;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
560 CAdjRCr = sat * OvHueCos * trans[ref].RefRCr;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
561 CAdjGCb = sat * (OvHueCos * trans[ref].RefGCb - OvHueSin * trans[ref].RefGCr);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
562 CAdjGCr = sat * (OvHueSin * trans[ref].RefGCb + OvHueCos * trans[ref].RefGCr);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
563 CAdjBCb = sat * OvHueCos * trans[ref].RefBCb;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
564 CAdjBCr = sat * OvHueSin * trans[ref].RefBCb;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27757
diff changeset
565
22691
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
566 #if 0 /* default constants */
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
567 CAdjLuma = 1.16455078125;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
568
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
569 CAdjRCb = 0.0;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
570 CAdjRCr = 1.59619140625;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
571 CAdjGCb = -0.39111328125;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
572 CAdjGCr = -0.8125;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
573 CAdjBCb = 2.01708984375;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
574 CAdjBCr = 0;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
575 #endif
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
576 OvLuma = CAdjLuma;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
577 OvRCb = CAdjRCb;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
578 OvRCr = CAdjRCr;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
579 OvGCb = CAdjGCb;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
580 OvGCr = CAdjGCr;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
581 OvBCb = CAdjBCb;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
582 OvBCr = CAdjBCr;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
583 OvROff = CAdjOff -
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
584 OvLuma * Loff - (OvRCb + OvRCr) * Coff;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27757
diff changeset
585 OvGOff = CAdjOff -
22691
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
586 OvLuma * Loff - (OvGCb + OvGCr) * Coff;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27757
diff changeset
587 OvBOff = CAdjOff -
22691
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
588 OvLuma * Loff - (OvBCb + OvBCr) * Coff;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
589 #if 0 /* default constants */
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
590 OvROff = -888.5;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
591 OvGOff = 545;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
592 OvBOff = -1104;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27757
diff changeset
593 #endif
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27757
diff changeset
594
22691
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
595 dwOvROff = ((int)(OvROff * 2.0)) & 0x1fff;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
596 dwOvGOff = (int)(OvGOff * 2.0) & 0x1fff;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
597 dwOvBOff = (int)(OvBOff * 2.0) & 0x1fff;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
598 if(!IsR200)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
599 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
600 dwOvLuma =(((int)(OvLuma * 2048.0))&0x7fff)<<17;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
601 dwOvRCb = (((int)(OvRCb * 2048.0))&0x7fff)<<1;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
602 dwOvRCr = (((int)(OvRCr * 2048.0))&0x7fff)<<17;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
603 dwOvGCb = (((int)(OvGCb * 2048.0))&0x7fff)<<1;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
604 dwOvGCr = (((int)(OvGCr * 2048.0))&0x7fff)<<17;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
605 dwOvBCb = (((int)(OvBCb * 2048.0))&0x7fff)<<1;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
606 dwOvBCr = (((int)(OvBCr * 2048.0))&0x7fff)<<17;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
607 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
608 else
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
609 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
610 dwOvLuma = (((int)(OvLuma * 256.0))&0x7ff)<<20;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
611 dwOvRCb = (((int)(OvRCb * 256.0))&0x7ff)<<4;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
612 dwOvRCr = (((int)(OvRCr * 256.0))&0x7ff)<<20;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
613 dwOvGCb = (((int)(OvGCb * 256.0))&0x7ff)<<4;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
614 dwOvGCr = (((int)(OvGCr * 256.0))&0x7ff)<<20;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
615 dwOvBCb = (((int)(OvBCb * 256.0))&0x7ff)<<4;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
616 dwOvBCr = (((int)(OvBCr * 256.0))&0x7ff)<<20;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
617 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
618
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
619 OUTREG(OV0_LIN_TRANS_A, dwOvRCb | dwOvLuma);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
620 OUTREG(OV0_LIN_TRANS_B, dwOvROff | dwOvRCr);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
621 OUTREG(OV0_LIN_TRANS_C, dwOvGCb | dwOvLuma);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
622 OUTREG(OV0_LIN_TRANS_D, dwOvGOff | dwOvGCr);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
623 OUTREG(OV0_LIN_TRANS_E, dwOvBCb | dwOvLuma);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
624 OUTREG(OV0_LIN_TRANS_F, dwOvBOff | dwOvBCr);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
625 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
626 #endif
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
627
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
628 #ifndef RAGE128
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
629 /* Gamma curve definition */
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27757
diff changeset
630 typedef struct
22691
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
631 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
632 unsigned int gammaReg;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
633 unsigned int gammaSlope;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
634 unsigned int gammaOffset;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
635 }GAMMA_SETTINGS;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
636
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
637 /* Recommended gamma curve parameters */
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27757
diff changeset
638 GAMMA_SETTINGS r200_def_gamma[18] =
22691
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
639 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
640 {OV0_GAMMA_0_F, 0x100, 0x0000},
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
641 {OV0_GAMMA_10_1F, 0x100, 0x0020},
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
642 {OV0_GAMMA_20_3F, 0x100, 0x0040},
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
643 {OV0_GAMMA_40_7F, 0x100, 0x0080},
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
644 {OV0_GAMMA_80_BF, 0x100, 0x0100},
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
645 {OV0_GAMMA_C0_FF, 0x100, 0x0100},
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
646 {OV0_GAMMA_100_13F, 0x100, 0x0200},
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
647 {OV0_GAMMA_140_17F, 0x100, 0x0200},
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
648 {OV0_GAMMA_180_1BF, 0x100, 0x0300},
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
649 {OV0_GAMMA_1C0_1FF, 0x100, 0x0300},
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
650 {OV0_GAMMA_200_23F, 0x100, 0x0400},
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
651 {OV0_GAMMA_240_27F, 0x100, 0x0400},
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
652 {OV0_GAMMA_280_2BF, 0x100, 0x0500},
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
653 {OV0_GAMMA_2C0_2FF, 0x100, 0x0500},
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
654 {OV0_GAMMA_300_33F, 0x100, 0x0600},
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
655 {OV0_GAMMA_340_37F, 0x100, 0x0600},
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
656 {OV0_GAMMA_380_3BF, 0x100, 0x0700},
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
657 {OV0_GAMMA_3C0_3FF, 0x100, 0x0700}
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
658 };
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
659
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27757
diff changeset
660 GAMMA_SETTINGS r100_def_gamma[6] =
22691
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
661 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
662 {OV0_GAMMA_0_F, 0x100, 0x0000},
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
663 {OV0_GAMMA_10_1F, 0x100, 0x0020},
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
664 {OV0_GAMMA_20_3F, 0x100, 0x0040},
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
665 {OV0_GAMMA_40_7F, 0x100, 0x0080},
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
666 {OV0_GAMMA_380_3BF, 0x100, 0x0100},
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
667 {OV0_GAMMA_3C0_3FF, 0x100, 0x0100}
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
668 };
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
669
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
670 static void make_default_gamma_correction( void )
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
671 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
672 size_t i;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
673 if(!IsR200){
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
674 OUTREG(OV0_LIN_TRANS_A, 0x12A00000);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
675 OUTREG(OV0_LIN_TRANS_B, 0x199018FE);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
676 OUTREG(OV0_LIN_TRANS_C, 0x12A0F9B0);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
677 OUTREG(OV0_LIN_TRANS_D, 0xF2F0043B);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
678 OUTREG(OV0_LIN_TRANS_E, 0x12A02050);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
679 OUTREG(OV0_LIN_TRANS_F, 0x0000174E);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
680 for(i=0; i<6; i++){
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
681 OUTREG(r100_def_gamma[i].gammaReg,
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
682 (r100_def_gamma[i].gammaSlope<<16) |
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
683 r100_def_gamma[i].gammaOffset);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
684 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
685 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
686 else{
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
687 OUTREG(OV0_LIN_TRANS_A, 0x12a00000);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
688 OUTREG(OV0_LIN_TRANS_B, 0x1990190e);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
689 OUTREG(OV0_LIN_TRANS_C, 0x12a0f9c0);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
690 OUTREG(OV0_LIN_TRANS_D, 0xf3000442);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
691 OUTREG(OV0_LIN_TRANS_E, 0x12a02040);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
692 OUTREG(OV0_LIN_TRANS_F, 0x175f);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
693
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
694 /* Default Gamma,
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
695 Of 18 segments for gamma cure, all segments in R200 are programmable,
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
696 while only lower 4 and upper 2 segments are programmable in Radeon*/
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
697 for(i=0; i<18; i++){
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
698 OUTREG(r200_def_gamma[i].gammaReg,
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
699 (r200_def_gamma[i].gammaSlope<<16) |
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
700 r200_def_gamma[i].gammaOffset);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
701 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
702 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
703 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
704 #endif
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
705
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
706 static void radeon_vid_stop_video( void )
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
707 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
708 radeon_engine_idle();
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
709 OUTREG(OV0_SCALE_CNTL, SCALER_SOFT_RESET);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
710 OUTREG(OV0_EXCLUSIVE_HORZ, 0);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
711 OUTREG(OV0_AUTO_FLIP_CNTL, 0); /* maybe */
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
712 OUTREG(OV0_FILTER_CNTL, FILTER_HARDCODED_COEF);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
713 OUTREG(OV0_KEY_CNTL, GRAPHIC_KEY_FN_NE);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
714 OUTREG(OV0_TEST, 0);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
715 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
716
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
717 static void radeon_vid_display_video( void )
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
718 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
719 int bes_flags;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
720 radeon_fifo_wait(2);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
721 OUTREG(OV0_REG_LOAD_CNTL, REG_LD_CTL_LOCK);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
722 radeon_engine_idle();
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
723 while(!(INREG(OV0_REG_LOAD_CNTL)&REG_LD_CTL_LOCK_READBACK));
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
724 radeon_fifo_wait(15);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
725 OUTREG(OV0_AUTO_FLIP_CNTL,OV0_AUTO_FLIP_CNTL_SOFT_BUF_ODD);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
726 OUTREG(OV0_AUTO_FLIP_CNTL,(INREG(OV0_AUTO_FLIP_CNTL)^OV0_AUTO_FLIP_CNTL_SOFT_EOF_TOGGLE));
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
727 OUTREG(OV0_AUTO_FLIP_CNTL,(INREG(OV0_AUTO_FLIP_CNTL)^OV0_AUTO_FLIP_CNTL_SOFT_EOF_TOGGLE));
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
728
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
729 OUTREG(OV0_DEINTERLACE_PATTERN,besr.deinterlace_pattern);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
730 #ifdef RAGE128
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
731 OUTREG(OV0_COLOUR_CNTL, (besr.brightness & 0x7f) |
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
732 (besr.saturation << 8) |
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
733 (besr.saturation << 16));
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
734 #endif
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
735 radeon_fifo_wait(2);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
736 if(besr.ckey_on)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
737 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
738 OUTREG(OV0_GRAPHICS_KEY_MSK, besr.graphics_key_msk);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
739 OUTREG(OV0_GRAPHICS_KEY_CLR, besr.graphics_key_clr);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
740 OUTREG(OV0_KEY_CNTL,GRAPHIC_KEY_FN_EQ|VIDEO_KEY_FN_FALSE|CMP_MIX_OR);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
741 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
742 else
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
743 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
744 OUTREG(OV0_GRAPHICS_KEY_MSK, 0ULL);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
745 OUTREG(OV0_GRAPHICS_KEY_CLR, 0ULL);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
746 OUTREG(OV0_KEY_CNTL,GRAPHIC_KEY_FN_NE);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
747 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
748
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
749 OUTREG(OV0_H_INC, besr.h_inc);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
750 OUTREG(OV0_STEP_BY, besr.step_by);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
751 OUTREG(OV0_Y_X_START, besr.y_x_start);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
752 OUTREG(OV0_Y_X_END, besr.y_x_end);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
753 OUTREG(OV0_V_INC, besr.v_inc);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
754 OUTREG(OV0_P1_BLANK_LINES_AT_TOP, besr.p1_blank_lines_at_top);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
755 OUTREG(OV0_P23_BLANK_LINES_AT_TOP, besr.p23_blank_lines_at_top);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
756 OUTREG(OV0_VID_BUF_PITCH0_VALUE, besr.vid_buf_pitch0_value);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
757 OUTREG(OV0_VID_BUF_PITCH1_VALUE, besr.vid_buf_pitch1_value);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
758 OUTREG(OV0_P1_X_START_END, besr.p1_x_start_end);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
759 OUTREG(OV0_P2_X_START_END, besr.p2_x_start_end);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
760 OUTREG(OV0_P3_X_START_END, besr.p3_x_start_end);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
761 #ifdef RADEON
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
762 OUTREG(OV0_BASE_ADDR, besr.base_addr);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
763 #endif
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
764 OUTREG(OV0_VID_BUF0_BASE_ADRS, besr.vid_buf0_base_adrs);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
765 OUTREG(OV0_VID_BUF1_BASE_ADRS, besr.vid_buf1_base_adrs);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
766 OUTREG(OV0_VID_BUF2_BASE_ADRS, besr.vid_buf2_base_adrs);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
767 radeon_fifo_wait(9);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
768 OUTREG(OV0_VID_BUF3_BASE_ADRS, besr.vid_buf3_base_adrs);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
769 OUTREG(OV0_VID_BUF4_BASE_ADRS, besr.vid_buf4_base_adrs);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
770 OUTREG(OV0_VID_BUF5_BASE_ADRS, besr.vid_buf5_base_adrs);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
771 OUTREG(OV0_P1_V_ACCUM_INIT, besr.p1_v_accum_init);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
772 OUTREG(OV0_P1_H_ACCUM_INIT, besr.p1_h_accum_init);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
773 OUTREG(OV0_P23_H_ACCUM_INIT, besr.p23_h_accum_init);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
774 OUTREG(OV0_P23_V_ACCUM_INIT, besr.p23_v_accum_init);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
775
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
776 #ifdef RADEON
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
777 bes_flags = SCALER_ENABLE |
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
778 SCALER_SMART_SWITCH;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
779 // SCALER_HORZ_PICK_NEAREST;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
780 #else
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
781 bes_flags = SCALER_ENABLE |
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
782 SCALER_SMART_SWITCH |
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
783 SCALER_Y2R_TEMP |
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
784 SCALER_PIX_EXPAND;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
785 #endif
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
786 if(besr.double_buff) bes_flags |= SCALER_DOUBLE_BUFFER;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
787 if(besr.deinterlace_on) bes_flags |= SCALER_ADAPTIVE_DEINT;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
788 #ifdef RAGE128
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
789 bes_flags |= SCALER_BURST_PER_PLANE;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
790 #endif
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
791 switch(besr.fourcc)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
792 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
793 case IMGFMT_RGB15:
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
794 case IMGFMT_BGR15: bes_flags |= SCALER_SOURCE_15BPP; break;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
795 case IMGFMT_RGB16:
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
796 case IMGFMT_BGR16: bes_flags |= SCALER_SOURCE_16BPP; break;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
797 case IMGFMT_RGB24:
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
798 case IMGFMT_BGR24: bes_flags |= SCALER_SOURCE_24BPP; break;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
799 case IMGFMT_RGB32:
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
800 case IMGFMT_BGR32: bes_flags |= SCALER_SOURCE_32BPP; break;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
801 /* 4:1:0*/
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
802 case IMGFMT_IF09:
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
803 case IMGFMT_YVU9: bes_flags |= SCALER_SOURCE_YUV9; break;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
804 /* 4:2:0 */
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
805 case IMGFMT_IYUV:
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
806 case IMGFMT_I420:
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
807 case IMGFMT_YV12: bes_flags |= SCALER_SOURCE_YUV12;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
808 break;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
809 /* 4:2:2 */
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
810 case IMGFMT_UYVY: bes_flags |= SCALER_SOURCE_YVYU422; break;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
811 case IMGFMT_YUY2:
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
812 default: bes_flags |= SCALER_SOURCE_VYUY422; break;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
813 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
814 OUTREG(OV0_SCALE_CNTL, bes_flags);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
815 OUTREG(OV0_REG_LOAD_CNTL, 0);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
816 #ifdef DEBUG
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
817 radeon_vid_dump_regs();
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
818 #endif
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
819 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
820
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
821 void radeon_vid_set_color_key(int ckey_on, uint8_t R, uint8_t G, uint8_t B)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
822 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
823 besr.ckey_on = ckey_on;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
824 besr.graphics_key_msk=(1ULL<<radeon_vid_get_dbpp()) - 1;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
825 besr.graphics_key_clr=(R<<16)|(G<<8)|(B)|(0x00 << 24);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
826 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
827
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
828
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
829 #define XXX_SRC_X 0
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
830 #define XXX_SRC_Y 0
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
831
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
832 static int radeon_vid_init_video( mga_vid_config_t *config )
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
833 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
834 uint32_t tmp,src_w,src_h,pitch,h_inc,step_by,left,leftUV,top;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
835 int is_420;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
836 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"
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
837 ,(uint32_t)config->version
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
838 ,(uint32_t)config->format
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
839 ,(uint32_t)config->card_type
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
840 ,(uint32_t)config->ram_size
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
841 ,(uint32_t)config->src_width
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
842 ,(uint32_t)config->src_height
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
843 ,(uint32_t)config->x_org
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
844 ,(uint32_t)config->y_org
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
845 ,(uint32_t)config->dest_width
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
846 ,(uint32_t)config->dest_height
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
847 ,(uint32_t)config->frame_size
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
848 ,(uint32_t)config->num_frames);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
849 radeon_vid_stop_video();
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
850 left = XXX_SRC_X << 16;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
851 top = XXX_SRC_Y << 16;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
852 src_h = config->src_height;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
853 src_w = config->src_width;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
854 switch(config->format)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
855 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
856 case IMGFMT_RGB15:
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
857 case IMGFMT_BGR15:
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
858 case IMGFMT_RGB16:
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
859 case IMGFMT_BGR16:
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
860 case IMGFMT_RGB24:
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
861 case IMGFMT_BGR24:
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
862 case IMGFMT_RGB32:
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
863 case IMGFMT_BGR32:
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
864 /* 4:1:0 */
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
865 case IMGFMT_IF09:
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
866 case IMGFMT_YVU9:
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27757
diff changeset
867 /* 4:2:0 */
22691
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
868 case IMGFMT_IYUV:
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
869 case IMGFMT_YV12:
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
870 case IMGFMT_I420:
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
871 /* 4:2:2 */
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
872 case IMGFMT_UYVY:
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
873 case IMGFMT_YUY2:
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
874 break;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
875 default:
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
876 printk(RVID_MSG"Unsupported pixel format: 0x%X\n",config->format);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
877 return -1;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
878 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
879 is_420 = 0;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
880 if(config->format == IMGFMT_YV12 ||
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
881 config->format == IMGFMT_I420 ||
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
882 config->format == IMGFMT_IYUV) is_420 = 1;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
883 switch(config->format)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
884 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
885 /* 4:1:0 */
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
886 case IMGFMT_YVU9:
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
887 case IMGFMT_IF09:
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
888 /* 4:2:0 */
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
889 case IMGFMT_IYUV:
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
890 case IMGFMT_YV12:
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
891 case IMGFMT_I420: pitch = (src_w + 31) & ~31; break;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
892 /* 4:2:2 */
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
893 default:
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
894 case IMGFMT_UYVY:
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
895 case IMGFMT_YUY2:
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
896 case IMGFMT_RGB15:
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
897 case IMGFMT_BGR15:
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
898 case IMGFMT_RGB16:
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
899 case IMGFMT_BGR16: pitch = ((src_w*2) + 15) & ~15; break;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
900 case IMGFMT_RGB24:
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
901 case IMGFMT_BGR24: pitch = ((src_w*3) + 15) & ~15; break;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
902 case IMGFMT_RGB32:
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
903 case IMGFMT_BGR32: pitch = ((src_w*4) + 15) & ~15; break;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
904 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
905 if(radeon_is_dbl_scan()) config->dest_height *= 2;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
906 else
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
907 if(radeon_is_interlace()) config->dest_height /= 2;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
908 besr.dest_bpp = radeon_vid_get_dbpp();
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
909 besr.fourcc = config->format;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
910 besr.v_inc = (src_h << 20) / config->dest_height;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
911 h_inc = (src_w << 12) / config->dest_width;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
912 step_by = 1;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
913
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
914 while(h_inc >= (2 << 12)) {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
915 step_by++;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
916 h_inc >>= 1;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
917 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
918
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
919 /* keep everything in 16.16 */
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
920 besr.base_addr = radeon_mem_base;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
921 if(is_420)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
922 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
923 uint32_t d1line,d2line,d3line;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
924 d1line = top*pitch;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
925 d2line = src_h*pitch+(d1line>>1);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
926 d3line = d2line+((src_h*pitch)>>2);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
927 d1line += (left >> 16) & ~15;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
928 d2line += (left >> 17) & ~15;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
929 d3line += (left >> 17) & ~15;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
930 besr.vid_buf0_base_adrs=((radeon_overlay_off+d1line)&VIF_BUF0_BASE_ADRS_MASK);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
931 besr.vid_buf1_base_adrs=((radeon_overlay_off+d2line)&VIF_BUF1_BASE_ADRS_MASK)|VIF_BUF1_PITCH_SEL;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
932 besr.vid_buf2_base_adrs=((radeon_overlay_off+d3line)&VIF_BUF2_BASE_ADRS_MASK)|VIF_BUF2_PITCH_SEL;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
933 if(besr.fourcc == IMGFMT_I420 || besr.fourcc == IMGFMT_IYUV)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
934 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
935 uint32_t tmp;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
936 tmp = besr.vid_buf1_base_adrs;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
937 besr.vid_buf1_base_adrs = besr.vid_buf2_base_adrs;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
938 besr.vid_buf2_base_adrs = tmp;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
939 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
940 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
941 else
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
942 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
943 besr.vid_buf0_base_adrs = radeon_overlay_off;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
944 besr.vid_buf0_base_adrs += ((left & ~7) << 1)&VIF_BUF0_BASE_ADRS_MASK;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
945 besr.vid_buf1_base_adrs = besr.vid_buf0_base_adrs;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
946 besr.vid_buf2_base_adrs = besr.vid_buf0_base_adrs;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
947 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
948 besr.vid_buf3_base_adrs = besr.vid_buf0_base_adrs+config->frame_size;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
949 besr.vid_buf4_base_adrs = besr.vid_buf1_base_adrs+config->frame_size;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
950 besr.vid_buf5_base_adrs = besr.vid_buf2_base_adrs+config->frame_size;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
951
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
952 tmp = (left & 0x0003ffff) + 0x00028000 + (h_inc << 3);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
953 besr.p1_h_accum_init = ((tmp << 4) & 0x000f8000) |
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
954 ((tmp << 12) & 0xf0000000);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
955
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
956 tmp = ((left >> 1) & 0x0001ffff) + 0x00028000 + (h_inc << 2);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
957 besr.p23_h_accum_init = ((tmp << 4) & 0x000f8000) |
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
958 ((tmp << 12) & 0x70000000);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
959 tmp = (top & 0x0000ffff) + 0x00018000;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
960 besr.p1_v_accum_init = ((tmp << 4) & OV0_P1_V_ACCUM_INIT_MASK)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
961 |(OV0_P1_MAX_LN_IN_PER_LN_OUT & 1);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
962
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
963 tmp = ((top >> 1) & 0x0000ffff) + 0x00018000;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
964 besr.p23_v_accum_init = is_420 ? ((tmp << 4) & OV0_P23_V_ACCUM_INIT_MASK)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
965 |(OV0_P23_MAX_LN_IN_PER_LN_OUT & 1) : 0;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
966
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
967 leftUV = (left >> 17) & 15;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
968 left = (left >> 16) & 15;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
969 besr.h_inc = h_inc | ((h_inc >> 1) << 16);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
970 besr.step_by = step_by | (step_by << 8);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
971 besr.y_x_start = (config->x_org+X_ADJUST) | (config->y_org << 16);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
972 besr.y_x_end = (config->x_org + config->dest_width+X_ADJUST) | ((config->y_org + config->dest_height) << 16);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
973 besr.p1_blank_lines_at_top = P1_BLNK_LN_AT_TOP_M1_MASK|((src_h-1)<<16);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
974 if(is_420)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
975 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
976 src_h = (src_h + 1) >> 1;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
977 besr.p23_blank_lines_at_top = P23_BLNK_LN_AT_TOP_M1_MASK|((src_h-1)<<16);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
978 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
979 else besr.p23_blank_lines_at_top = 0;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
980 besr.vid_buf_pitch0_value = pitch;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
981 besr.vid_buf_pitch1_value = is_420 ? pitch>>1 : pitch;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
982 besr.p1_x_start_end = (src_w+left-1)|(left<<16);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
983 src_w>>=1;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
984 besr.p2_x_start_end = (src_w+left-1)|(leftUV<<16);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
985 besr.p3_x_start_end = besr.p2_x_start_end;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
986 return 0;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
987 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
988
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
989 static void radeon_vid_frame_sel(int frame)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
990 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
991 uint32_t off0,off1,off2;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
992 if(!besr.double_buff) return;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
993 if(frame%2)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
994 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
995 off0 = besr.vid_buf3_base_adrs;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
996 off1 = besr.vid_buf4_base_adrs;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
997 off2 = besr.vid_buf5_base_adrs;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
998 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
999 else
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1000 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1001 off0 = besr.vid_buf0_base_adrs;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1002 off1 = besr.vid_buf1_base_adrs;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1003 off2 = besr.vid_buf2_base_adrs;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1004 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1005 OUTREG(OV0_REG_LOAD_CNTL, REG_LD_CTL_LOCK);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1006 while(!(INREG(OV0_REG_LOAD_CNTL)&REG_LD_CTL_LOCK_READBACK));
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1007 OUTREG(OV0_VID_BUF0_BASE_ADRS, off0);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1008 OUTREG(OV0_VID_BUF1_BASE_ADRS, off1);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1009 OUTREG(OV0_VID_BUF2_BASE_ADRS, off2);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1010 OUTREG(OV0_REG_LOAD_CNTL, 0);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1011 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1012
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1013 static void radeon_vid_make_default(void)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1014 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1015 #ifdef RAGE128
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1016 OUTREG(OV0_COLOUR_CNTL,0x00101000UL); /* Default brihgtness and saturation for Rage128 */
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1017 #else
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1018 make_default_gamma_correction();
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1019 #endif
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1020 besr.deinterlace_pattern = 0x900AAAAA;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1021 OUTREG(OV0_DEINTERLACE_PATTERN,besr.deinterlace_pattern);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1022 besr.deinterlace_on=1;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1023 besr.double_buff=1;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1024 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1025
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1026
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1027 static void radeon_vid_preset(void)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1028 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1029 #ifdef RAGE128
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1030 unsigned tmp;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1031 tmp = INREG(OV0_COLOUR_CNTL);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1032 besr.saturation = (tmp>>8)&0x1f;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1033 besr.brightness = tmp & 0x7f;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1034 #endif
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1035 besr.graphics_key_clr = INREG(OV0_GRAPHICS_KEY_CLR);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1036 besr.deinterlace_pattern = INREG(OV0_DEINTERLACE_PATTERN);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1037 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1038
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1039 static int video_on = 0;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1040
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1041 static int radeon_vid_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1042 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1043 int frame;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1044
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1045 switch(cmd)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1046 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1047 case MGA_VID_CONFIG:
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1048 RTRACE(RVID_MSG"radeon_mmio_base = %p\n",radeon_mmio_base);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1049 RTRACE(RVID_MSG"radeon_mem_base = %08x\n",radeon_mem_base);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1050 RTRACE(RVID_MSG"Received configuration\n");
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1051
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1052 if(copy_from_user(&radeon_config,(mga_vid_config_t*) arg,sizeof(mga_vid_config_t)))
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1053 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1054 printk(RVID_MSG"failed copy from userspace\n");
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1055 return -EFAULT;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1056 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1057 if(radeon_config.version != MGA_VID_VERSION){
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1058 printk(RVID_MSG"incompatible version! driver: %X requested: %X\n",MGA_VID_VERSION,radeon_config.version);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1059 return -EFAULT;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1060 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1061
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1062 if(radeon_config.frame_size==0 || radeon_config.frame_size>1024*768*2){
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1063 printk(RVID_MSG"illegal frame_size: %d\n",radeon_config.frame_size);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1064 return -EFAULT;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1065 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1066
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1067 if(radeon_config.num_frames<1){
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1068 printk(RVID_MSG"illegal num_frames: %d\n",radeon_config.num_frames);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1069 return -EFAULT;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1070 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1071 if(radeon_config.num_frames==1) besr.double_buff=0;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1072 if(!besr.double_buff) radeon_config.num_frames=1;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1073 else radeon_config.num_frames=2;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1074 radeon_config.card_type = 0;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1075 radeon_config.ram_size = radeon_ram_size;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1076 radeon_overlay_off = radeon_ram_size*0x100000 - radeon_config.frame_size*radeon_config.num_frames;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1077 radeon_overlay_off &= 0xffff0000;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1078 if(radeon_overlay_off < 0){
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1079 printk(RVID_MSG"not enough video memory. Need: %u has: %u\n",radeon_config.frame_size*radeon_config.num_frames,radeon_ram_size*0x100000);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1080 return -EFAULT;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1081 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1082 RTRACE(RVID_MSG"using video overlay at offset %08X\n",radeon_overlay_off);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1083 if (copy_to_user((mga_vid_config_t *) arg, &radeon_config, sizeof(mga_vid_config_t)))
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1084 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1085 printk(RVID_MSG"failed copy to userspace\n");
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1086 return -EFAULT;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1087 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1088 radeon_vid_set_color_key(radeon_config.colkey_on,
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1089 radeon_config.colkey_red,
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1090 radeon_config.colkey_green,
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1091 radeon_config.colkey_blue);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27757
diff changeset
1092 if(swap_fourcc) radeon_config.format = swab32(radeon_config.format);
22691
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1093 printk(RVID_MSG"configuring for '%s' fourcc\n",fourcc_format_name(radeon_config.format));
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1094 return radeon_vid_init_video(&radeon_config);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1095 break;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1096
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1097 case MGA_VID_ON:
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1098 RTRACE(RVID_MSG"Video ON (ioctl)\n");
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1099 radeon_vid_display_video();
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1100 video_on = 1;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1101 break;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1102
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1103 case MGA_VID_OFF:
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1104 RTRACE(RVID_MSG"Video OFF (ioctl)\n");
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1105 if(video_on) radeon_vid_stop_video();
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1106 video_on = 0;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1107 break;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1108
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1109 case MGA_VID_FSEL:
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1110 if(copy_from_user(&frame,(int *) arg,sizeof(int)))
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1111 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1112 printk(RVID_MSG"FSEL failed copy from userspace\n");
26759
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26003
diff changeset
1113 return -EFAULT;
22691
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1114 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1115 radeon_vid_frame_sel(frame);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1116 break;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1117
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1118 default:
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1119 printk(RVID_MSG"Invalid ioctl\n");
26759
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26003
diff changeset
1120 return -EINVAL;
22691
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1121 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1122
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1123 return 0;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1124 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1125
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1126 struct ati_card_id_s
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1127 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1128 const int id;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1129 const char name[17];
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1130 };
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1131
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1132 const struct ati_card_id_s ati_card_ids[]=
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1133 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1134 #ifdef RAGE128
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1135 /*
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1136 This driver should be compatible with Rage128 (pro) chips.
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1137 (include adaptive deinterlacing!!!).
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1138 Moreover: the same logic can be used with Mach64 chips.
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1139 (I mean: mach64xx, 3d rage, 3d rage IIc, 3D rage pro, 3d rage mobility).
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1140 but they are incompatible by i/o ports. So if enthusiasts will want
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1141 then they can redefine OUTREG and INREG macros and redefine OV0_*
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1142 constants. Also it seems that mach64 chips supports only: YUY2, YV12, UYVY
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1143 fourccs (422 and 420 formats only).
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1144 */
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1145 /* Rage128 Pro GL */
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1146 { PCI_DEVICE_ID_ATI_Rage128_PA, "R128Pro PA" },
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1147 { PCI_DEVICE_ID_ATI_Rage128_PB, "R128Pro PB" },
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1148 { PCI_DEVICE_ID_ATI_Rage128_PC, "R128Pro PC" },
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1149 { PCI_DEVICE_ID_ATI_Rage128_PD, "R128Pro PD" },
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1150 { PCI_DEVICE_ID_ATI_Rage128_PE, "R128Pro PE" },
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1151 { PCI_DEVICE_ID_ATI_RAGE128_PF, "R128Pro PF" },
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1152 /* Rage128 Pro VR */
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1153 { PCI_DEVICE_ID_ATI_RAGE128_PG, "R128Pro PG" },
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1154 { PCI_DEVICE_ID_ATI_RAGE128_PH, "R128Pro PH" },
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1155 { PCI_DEVICE_ID_ATI_RAGE128_PI, "R128Pro PI" },
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1156 { PCI_DEVICE_ID_ATI_RAGE128_PJ, "R128Pro PJ" },
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1157 { PCI_DEVICE_ID_ATI_RAGE128_PK, "R128Pro PK" },
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1158 { PCI_DEVICE_ID_ATI_RAGE128_PL, "R128Pro PL" },
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1159 { PCI_DEVICE_ID_ATI_RAGE128_PM, "R128Pro PM" },
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1160 { PCI_DEVICE_ID_ATI_RAGE128_PN, "R128Pro PN" },
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1161 { PCI_DEVICE_ID_ATI_RAGE128_PO, "R128Pro PO" },
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1162 { PCI_DEVICE_ID_ATI_RAGE128_PP, "R128Pro PP" },
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1163 { PCI_DEVICE_ID_ATI_RAGE128_PQ, "R128Pro PQ" },
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1164 { PCI_DEVICE_ID_ATI_RAGE128_PR, "R128Pro PR" },
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1165 { PCI_DEVICE_ID_ATI_RAGE128_TR, "R128Pro TR" },
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1166 { PCI_DEVICE_ID_ATI_RAGE128_PS, "R128Pro PS" },
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1167 { PCI_DEVICE_ID_ATI_RAGE128_PT, "R128Pro PT" },
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1168 { PCI_DEVICE_ID_ATI_RAGE128_PU, "R128Pro PU" },
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1169 { PCI_DEVICE_ID_ATI_RAGE128_PV, "R128Pro PV" },
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1170 { PCI_DEVICE_ID_ATI_RAGE128_PW, "R128Pro PW" },
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1171 { PCI_DEVICE_ID_ATI_RAGE128_PX, "R128Pro PX" },
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1172 /* Rage128 GL */
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1173 { PCI_DEVICE_ID_ATI_RAGE128_RE, "R128 RE" },
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1174 { PCI_DEVICE_ID_ATI_RAGE128_RF, "R128 RF" },
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1175 { PCI_DEVICE_ID_ATI_RAGE128_RG, "R128 RG" },
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1176 { PCI_DEVICE_ID_ATI_RAGE128_RH, "R128 RH" },
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1177 { PCI_DEVICE_ID_ATI_RAGE128_RI, "R128 RI" },
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1178 /* Rage128 VR */
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1179 { PCI_DEVICE_ID_ATI_RAGE128_RK, "R128 RK" },
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1180 { PCI_DEVICE_ID_ATI_RAGE128_RL, "R128 RL" },
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1181 { PCI_DEVICE_ID_ATI_RAGE128_RM, "R128 RM" },
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1182 { PCI_DEVICE_ID_ATI_RAGE128_RN, "R128 RN" },
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1183 { PCI_DEVICE_ID_ATI_RAGE128_RO, "R128 RO" },
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1184 /* Rage128 M3 */
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1185 { PCI_DEVICE_ID_ATI_RAGE128_LE, "R128 M3 LE" },
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1186 { PCI_DEVICE_ID_ATI_RAGE128_LF, "R128 M3 LF" },
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1187 /* Rage128 Pro Ultra */
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1188 { PCI_DEVICE_ID_ATI_RAGE128_U1, "R128Pro U1" },
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1189 { PCI_DEVICE_ID_ATI_RAGE128_U2, "R128Pro U2" },
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1190 { PCI_DEVICE_ID_ATI_RAGE128_U3, "R128Pro U3" }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1191 #else
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1192 /* Radeons (indeed: Rage 256 Pro ;) */
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1193 { PCI_DEVICE_ID_RADEON_QD, "Radeon QD " },
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1194 { PCI_DEVICE_ID_RADEON_QE, "Radeon QE " },
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1195 { PCI_DEVICE_ID_RADEON_QF, "Radeon QF " },
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1196 { PCI_DEVICE_ID_RADEON_QG, "Radeon QG " },
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1197 { PCI_DEVICE_ID_RADEON_QY, "Radeon VE QY " },
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1198 { PCI_DEVICE_ID_RADEON_QZ, "Radeon VE QZ " },
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1199 { PCI_DEVICE_ID_RADEON_LY, "Radeon M6 LY " },
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1200 { PCI_DEVICE_ID_RADEON_LZ, "Radeon M6 LZ " },
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1201 { PCI_DEVICE_ID_RADEON_LW, "Radeon M7 LW " },
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1202 { PCI_DEVICE_ID_R200_QL, "Radeon2 8500 QL " },
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1203 { PCI_DEVICE_ID_R200_BB, "Radeon2 8500 AIW" },
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1204 { PCI_DEVICE_ID_RV200_QW, "Radeon2 7500 QW " }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1205 #endif
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1206 };
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1207
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1208 static int detected_chip;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1209
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1210 static int __init radeon_vid_config_card(void)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1211 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1212 struct pci_dev *dev = NULL;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1213 size_t i;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1214
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1215 for(i=0;i<sizeof(ati_card_ids)/sizeof(struct ati_card_id_s);i++)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1216 if((dev=pci_find_device(PCI_VENDOR_ID_ATI, ati_card_ids[i].id, NULL)))
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1217 break;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1218 if(!dev)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1219 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1220 printk(RVID_MSG"No supported cards found\n");
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1221 return FALSE;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1222 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1223
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1224 radeon_mmio_base = ioremap_nocache(pci_resource_start (dev, 2),RADEON_REGSIZE);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1225 radeon_mem_base = dev->resource[0].start;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1226
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1227 RTRACE(RVID_MSG"MMIO at 0x%p\n", radeon_mmio_base);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1228 RTRACE(RVID_MSG"Frame Buffer at 0x%08x\n", radeon_mem_base);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1229
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1230 /* video memory size */
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1231 radeon_ram_size = INREG(CONFIG_MEMSIZE);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1232
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1233 /* mem size is bits [28:0], mask off the rest. Range: from 1Mb up to 512 Mb */
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1234 radeon_ram_size &= CONFIG_MEMSIZE_MASK;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1235 radeon_ram_size /= 0x100000;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1236 detected_chip = i;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1237 printk(RVID_MSG"Found %s (%uMb memory)\n",ati_card_ids[i].name,radeon_ram_size);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27757
diff changeset
1238 #ifndef RAGE128
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27757
diff changeset
1239 if(ati_card_ids[i].id == PCI_DEVICE_ID_R200_QL ||
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27757
diff changeset
1240 ati_card_ids[i].id == PCI_DEVICE_ID_R200_BB ||
22691
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1241 ati_card_ids[i].id == PCI_DEVICE_ID_RV200_QW) IsR200 = 1;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1242 #endif
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1243 return TRUE;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1244 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1245
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1246 #define PARAM_BRIGHTNESS "brightness="
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1247 #define PARAM_SATURATION "saturation="
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1248 #define PARAM_CONTRAST "contrast="
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1249 #define PARAM_HUE "hue="
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1250 #define PARAM_DOUBLE_BUFF "double_buff="
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1251 #define PARAM_DEINTERLACE "deinterlace="
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1252 #define PARAM_DEINTERLACE_PATTERN "deinterlace_pattern="
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1253 #ifdef RADEON_FPU
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1254 static int ovBrightness=0, ovSaturation=0, ovContrast=0, ovHue=0, ov_trans_idx=0;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1255 #endif
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1256
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1257 static void radeon_param_buff_fill( void )
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1258 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1259 unsigned len,saturation;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1260 int8_t brightness;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1261 brightness = besr.brightness & 0x7f;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1262 /* FIXME: It's probably x86 specific convertion. But it doesn't matter
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1263 for general logic - only for printing value */
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1264 if(brightness > 63) brightness = (((~besr.brightness) & 0x3f)+1) * (-1);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1265 saturation = besr.saturation;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1266 len = 0;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1267 len += sprintf(&radeon_param_buff[len],"Interface version: %04X\nDriver version: %s\n",MGA_VID_VERSION,RADEON_VID_VERSION);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1268 len += sprintf(&radeon_param_buff[len],"Chip: %s\n",ati_card_ids[detected_chip].name);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1269 len += sprintf(&radeon_param_buff[len],"Memory: %x:%x\n",radeon_mem_base,radeon_ram_size*0x100000);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1270 len += sprintf(&radeon_param_buff[len],"MMIO: %p\n",radeon_mmio_base);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1271 len += sprintf(&radeon_param_buff[len],"Overlay offset: %x\n",radeon_overlay_off);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1272 #ifdef CONFIG_MTRR
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1273 len += sprintf(&radeon_param_buff[len],"Tune MTRR: %s\n",mtrr?"on":"off");
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1274 #endif
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1275 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);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1276 len += sprintf(&radeon_param_buff[len],"Swapped fourcc: %s\n",swap_fourcc?"on":"off");
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1277 len += sprintf(&radeon_param_buff[len],"Last BPP: %u\n",besr.dest_bpp);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1278 len += sprintf(&radeon_param_buff[len],"Last fourcc: %s\n\n",fourcc_format_name(besr.fourcc));
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1279 len += sprintf(&radeon_param_buff[len],"Configurable stuff:\n");
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1280 len += sprintf(&radeon_param_buff[len],"~~~~~~~~~~~~~~~~~~~\n");
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1281 len += sprintf(&radeon_param_buff[len],PARAM_DOUBLE_BUFF"%s\n",besr.double_buff?"on":"off");
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1282 #ifdef RAGE128
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1283 len += sprintf(&radeon_param_buff[len],PARAM_BRIGHTNESS"%i\n",(int)brightness);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1284 len += sprintf(&radeon_param_buff[len],PARAM_SATURATION"%u\n",saturation);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1285 #else
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1286 #ifdef RADEON_FPU
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1287 len += sprintf(&radeon_param_buff[len],PARAM_BRIGHTNESS"%i\n",ovBrightness);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1288 len += sprintf(&radeon_param_buff[len],PARAM_SATURATION"%i\n",ovSaturation);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1289 len += sprintf(&radeon_param_buff[len],PARAM_CONTRAST"%i\n",ovContrast);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1290 len += sprintf(&radeon_param_buff[len],PARAM_HUE"%i\n",ovHue);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1291 #endif
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1292 #endif
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1293 len += sprintf(&radeon_param_buff[len],PARAM_DEINTERLACE"%s\n",besr.deinterlace_on?"on":"off");
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1294 len += sprintf(&radeon_param_buff[len],PARAM_DEINTERLACE_PATTERN"%X\n",besr.deinterlace_pattern);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1295 radeon_param_buff_len = len;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1296 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1297
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1298 static ssize_t radeon_vid_read(struct file *file, char *buf, size_t count, loff_t *ppos)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1299 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1300 uint32_t size;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1301 if(!radeon_param_buff) return -ESPIPE;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1302 if(!(*ppos)) radeon_param_buff_fill();
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1303 if(*ppos >= radeon_param_buff_len) return 0;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1304 size = min(count,radeon_param_buff_len-(uint32_t)(*ppos));
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1305 memcpy(buf,radeon_param_buff,size);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1306 *ppos += size;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1307 return size;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1308 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1309
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1310 #define RTFSaturation(a) (1.0 + ((a)*1.0)/1000.0)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1311 #define RTFBrightness(a) (((a)*1.0)/2000.0)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1312 #define RTFContrast(a) (1.0 + ((a)*1.0)/1000.0)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1313 #define RTFHue(a) (((a)*3.1416)/1000.0)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1314 #define RadeonSetParm(a,b,c,d) if((b)>=(c)&&(b)<=(d)) { (a)=(b);\
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1315 radeon_set_transform(RTFBrightness(ovBrightness),RTFContrast(ovContrast)\
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1316 ,RTFSaturation(ovSaturation),RTFHue(ovHue),ov_trans_idx); }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1317
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1318
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1319 static ssize_t radeon_vid_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1320 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1321 #ifdef RAGE128
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1322 if(memcmp(buf,PARAM_BRIGHTNESS,min(count,strlen(PARAM_BRIGHTNESS))) == 0)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1323 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1324 long brightness;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1325 brightness=simple_strtol(&buf[strlen(PARAM_BRIGHTNESS)],NULL,10);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27757
diff changeset
1326 if(brightness >= -64 && brightness <= 63)
22691
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1327 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1328 besr.brightness = brightness;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1329 OUTREG(OV0_COLOUR_CNTL, (brightness & 0x7f) |
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1330 (besr.saturation << 8) |
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1331 (besr.saturation << 16));
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1332 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1333 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1334 else
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1335 if(memcmp(buf,PARAM_SATURATION,min(count,strlen(PARAM_SATURATION))) == 0)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1336 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1337 long saturation;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1338 saturation=simple_strtol(&buf[strlen(PARAM_SATURATION)],NULL,10);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1339 if(saturation >= 0 && saturation <= 31)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1340 OUTREG(OV0_COLOUR_CNTL, (besr.brightness & 0x7f) |
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1341 (saturation << 8) |
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1342 (saturation << 16));
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1343 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1344 else
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1345 #else
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1346 #ifdef RADEON_FPU
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1347 if(memcmp(buf,PARAM_BRIGHTNESS,min(count,strlen(PARAM_BRIGHTNESS))) == 0)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1348 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1349 int tmp;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1350 tmp=simple_strtol(&buf[strlen(PARAM_BRIGHTNESS)],NULL,10);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1351 RadeonSetParm(ovBrightness,tmp,-1000,1000);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1352 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1353 else
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1354 if(memcmp(buf,PARAM_SATURATION,min(count,strlen(PARAM_SATURATION))) == 0)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1355 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1356 int tmp;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1357 tmp=simple_strtol(&buf[strlen(PARAM_SATURATION)],NULL,10);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1358 RadeonSetParm(ovSaturation,tmp,-1000,1000);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1359 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1360 else
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1361 if(memcmp(buf,PARAM_CONTRAST,min(count,strlen(PARAM_CONTRAST))) == 0)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1362 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1363 int tmp;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1364 tmp=simple_strtol(&buf[strlen(PARAM_CONTRAST)],NULL,10);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1365 RadeonSetParm(ovContrast,tmp,-1000,1000);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1366 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1367 else
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1368 if(memcmp(buf,PARAM_HUE,min(count,strlen(PARAM_HUE))) == 0)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1369 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1370 int tmp;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1371 tmp=simple_strtol(&buf[strlen(PARAM_HUE)],NULL,10);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1372 RadeonSetParm(ovHue,tmp,-1000,1000);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1373 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1374 else
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1375 #endif
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1376 #endif
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1377 if(memcmp(buf,PARAM_DOUBLE_BUFF,min(count,strlen(PARAM_DOUBLE_BUFF))) == 0)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1378 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1379 if(memcmp(&buf[strlen(PARAM_DOUBLE_BUFF)],"on",2) == 0) besr.double_buff = 1;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1380 else besr.double_buff = 0;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1381 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1382 else
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1383 if(memcmp(buf,PARAM_DEINTERLACE,min(count,strlen(PARAM_DEINTERLACE))) == 0)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1384 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1385 if(memcmp(&buf[strlen(PARAM_DEINTERLACE)],"on",2) == 0) besr.deinterlace_on = 1;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1386 else besr.deinterlace_on = 0;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1387 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1388 else
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1389 if(memcmp(buf,PARAM_DEINTERLACE_PATTERN,min(count,strlen(PARAM_DEINTERLACE_PATTERN))) == 0)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1390 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1391 long dpat;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1392 dpat=simple_strtol(&buf[strlen(PARAM_DEINTERLACE_PATTERN)],NULL,16);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1393 OUTREG(OV0_DEINTERLACE_PATTERN, dpat);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1394 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1395 else count = -EIO;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1396 radeon_vid_preset();
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1397 return count;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1398 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1399
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1400 static int radeon_vid_mmap(struct file *file, struct vm_area_struct *vma)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1401 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1402
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1403 RTRACE(RVID_MSG"mapping video memory into userspace\n");
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1404 if(remap_page_range(vma->vm_start, radeon_mem_base + radeon_overlay_off,
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27757
diff changeset
1405 vma->vm_end - vma->vm_start, vma->vm_page_prot))
22691
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1406 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1407 printk(RVID_MSG"error mapping video memory\n");
26759
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26003
diff changeset
1408 return -EAGAIN;
22691
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1409 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1410
26759
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26003
diff changeset
1411 return 0;
22691
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1412 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1413
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1414 static int radeon_vid_release(struct inode *inode, struct file *file)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1415 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1416 radeon_vid_in_use = 0;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1417 radeon_vid_stop_video();
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1418
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1419 MOD_DEC_USE_COUNT;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1420 return 0;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1421 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1422
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1423 static long long radeon_vid_lseek(struct file *file, long long offset, int origin)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1424 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1425 return -ESPIPE;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27757
diff changeset
1426 }
22691
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1427
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1428 static int radeon_vid_open(struct inode *inode, struct file *file)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1429 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1430 int minor = MINOR(inode->i_rdev);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1431
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1432 if(minor != 0)
26759
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26003
diff changeset
1433 return -ENXIO;
22691
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1434
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27757
diff changeset
1435 if(radeon_vid_in_use == 1)
26759
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26003
diff changeset
1436 return -EBUSY;
22691
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1437
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1438 radeon_vid_in_use = 1;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1439 MOD_INC_USE_COUNT;
26759
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26003
diff changeset
1440 return 0;
22691
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1441 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1442
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1443 #if LINUX_VERSION_CODE >= 0x020400
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1444 static struct file_operations radeon_vid_fops =
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1445 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1446 llseek: radeon_vid_lseek,
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1447 read: radeon_vid_read,
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1448 write: radeon_vid_write,
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1449 /*
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1450 readdir:
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1451 poll:
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1452 */
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1453 ioctl: radeon_vid_ioctl,
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1454 mmap: radeon_vid_mmap,
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1455 open: radeon_vid_open,
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1456 /*
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1457 flush:
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1458 */
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1459 release: radeon_vid_release
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1460 /*
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1461 fsync:
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1462 fasync:
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1463 lock:
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1464 readv:
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1465 writev:
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1466 sendpage:
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1467 get_unmapped_area:
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1468 */
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1469 };
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1470 #else
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1471 static struct file_operations radeon_vid_fops =
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1472 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1473 radeon_vid_lseek,
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1474 radeon_vid_read,
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1475 radeon_vid_write,
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1476 NULL,
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1477 NULL,
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1478 radeon_vid_ioctl,
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1479 radeon_vid_mmap,
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1480 radeon_vid_open,
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1481 NULL,
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1482 radeon_vid_release
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1483 };
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1484 #endif
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1485
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27757
diff changeset
1486 /*
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27757
diff changeset
1487 * Main Initialization Function
22691
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1488 */
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1489
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1490 static int __init radeon_vid_initialize(void)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1491 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1492 radeon_vid_in_use = 0;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1493 #ifdef RAGE128
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1494 printk(RVID_MSG"Rage128/Rage128Pro video overlay driver v"RADEON_VID_VERSION" (C) Nick Kurshev\n");
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1495 #else
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1496 printk(RVID_MSG"Radeon video overlay driver v"RADEON_VID_VERSION" (C) Nick Kurshev\n");
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1497 #endif
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1498 if(register_chrdev(RADEON_VID_MAJOR, "radeon_vid", &radeon_vid_fops))
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1499 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1500 printk(RVID_MSG"unable to get major: %d\n", RADEON_VID_MAJOR);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1501 return -EIO;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1502 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1503
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1504 if (!radeon_vid_config_card())
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1505 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1506 printk(RVID_MSG"can't configure this card\n");
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1507 unregister_chrdev(RADEON_VID_MAJOR, "radeon_vid");
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1508 return -EINVAL;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1509 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1510 radeon_param_buff = kmalloc(PARAM_BUFF_SIZE,GFP_KERNEL);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1511 if(radeon_param_buff) radeon_param_buff_size = PARAM_BUFF_SIZE;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1512 #if 0
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1513 radeon_vid_save_state();
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1514 #endif
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1515 radeon_vid_make_default();
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1516 radeon_vid_preset();
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1517 #ifdef CONFIG_MTRR
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1518 if (mtrr) {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1519 smtrr.vram = mtrr_add(radeon_mem_base,
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1520 radeon_ram_size*0x100000, MTRR_TYPE_WRCOMB, 1);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1521 smtrr.vram_valid = 1;
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1522 /* let there be speed */
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1523 printk(RVID_MSG"MTRR set to ON\n");
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1524 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1525 #endif /* CONFIG_MTRR */
26759
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26003
diff changeset
1526 return 0;
22691
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1527 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1528
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1529 int __init init_module(void)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1530 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1531 return radeon_vid_initialize();
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1532 }
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1533
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1534 void __exit cleanup_module(void)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1535 {
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1536 #if 0
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1537 radeon_vid_restore_state();
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1538 #endif
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1539 if(radeon_mmio_base)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1540 iounmap(radeon_mmio_base);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1541 kfree(radeon_param_buff);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1542 RTRACE(RVID_MSG"Cleaning up module\n");
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1543 unregister_chrdev(RADEON_VID_MAJOR, "radeon_vid");
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1544 #ifdef CONFIG_MTRR
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1545 if (smtrr.vram_valid)
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1546 mtrr_del(smtrr.vram, radeon_mem_base,
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1547 radeon_ram_size*0x100000);
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1548 #endif /* CONFIG_MTRR */
544914dadb52 Move files from radeon/ subdirectory here.
diego
parents:
diff changeset
1549 }