Mercurial > mplayer.hg
annotate vidix/drivers/radeon_vid.c @ 5132:cfccb5dbe992
Fixed problem with seeking/sync when using libfame
libfame seems to not accept some standard fps rates, like 2997/100, this
causes bad syncing with fame sometimes =(
author | mswitch |
---|---|
date | Sat, 16 Mar 2002 06:01:13 +0000 |
parents | 43dc579db3d1 |
children | 51fcb1e5c96e |
rev | line source |
---|---|
3996 | 1 /* |
2 radeon_vid - VIDIX based video driver for Radeon and Rage128 chips | |
4030 | 3 Copyrights 2002 Nick Kurshev. This file is based on sources from |
4 GATOS (gatos.sf.net) and X11 (www.xfree86.org) | |
5 Licence: GPL | |
3996 | 6 */ |
7 | |
8 #include <errno.h> | |
9 #include <stdio.h> | |
10 #include <stdlib.h> | |
11 #include <string.h> | |
12 #include <math.h> | |
4003
92c59012249d
stdint.h replaced by inttypes.h (used more frequently in the sources)
pl
parents:
3996
diff
changeset
|
13 #include <inttypes.h> |
4201 | 14 #include "../../libdha/pci_ids.h" |
15 #include "../../libdha/pci_names.h" | |
3996 | 16 #include "../vidix.h" |
17 #include "../fourcc.h" | |
18 #include "../../libdha/libdha.h" | |
19 #include "radeon.h" | |
20 | |
21 #ifdef RAGE128 | |
22 #define RADEON_MSG "Rage128_vid:" | |
23 #define X_ADJUST 0 | |
24 #else | |
25 #define RADEON_MSG "Radeon_vid:" | |
26 #define X_ADJUST 8 | |
27 #ifndef RADEON | |
28 #define RADEON | |
29 #endif | |
30 #endif | |
31 | |
4030 | 32 static int __verbose = 0; |
4015 | 33 |
3996 | 34 typedef struct bes_registers_s |
35 { | |
36 /* base address of yuv framebuffer */ | |
37 uint32_t yuv_base; | |
38 uint32_t fourcc; | |
39 uint32_t dest_bpp; | |
40 /* YUV BES registers */ | |
41 uint32_t reg_load_cntl; | |
42 uint32_t h_inc; | |
43 uint32_t step_by; | |
44 uint32_t y_x_start; | |
45 uint32_t y_x_end; | |
46 uint32_t v_inc; | |
47 uint32_t p1_blank_lines_at_top; | |
48 uint32_t p23_blank_lines_at_top; | |
49 uint32_t vid_buf_pitch0_value; | |
50 uint32_t vid_buf_pitch1_value; | |
51 uint32_t p1_x_start_end; | |
52 uint32_t p2_x_start_end; | |
53 uint32_t p3_x_start_end; | |
54 uint32_t base_addr; | |
4930 | 55 uint32_t vid_buf_base_adrs_y[VID_PLAY_MAXFRAMES]; |
56 uint32_t vid_buf_base_adrs_u[VID_PLAY_MAXFRAMES]; | |
57 uint32_t vid_buf_base_adrs_v[VID_PLAY_MAXFRAMES]; | |
58 uint32_t vid_nbufs; | |
3996 | 59 |
60 uint32_t p1_v_accum_init; | |
61 uint32_t p1_h_accum_init; | |
62 uint32_t p23_v_accum_init; | |
63 uint32_t p23_h_accum_init; | |
64 uint32_t scale_cntl; | |
65 uint32_t exclusive_horz; | |
66 uint32_t auto_flip_cntl; | |
67 uint32_t filter_cntl; | |
68 uint32_t key_cntl; | |
69 uint32_t test; | |
70 /* Configurable stuff */ | |
71 int double_buff; | |
72 | |
73 int brightness; | |
74 int saturation; | |
75 | |
76 int ckey_on; | |
77 uint32_t graphics_key_clr; | |
78 uint32_t graphics_key_msk; | |
4869 | 79 uint32_t ckey_cntl; |
3996 | 80 |
81 int deinterlace_on; | |
82 uint32_t deinterlace_pattern; | |
83 | |
84 } bes_registers_t; | |
85 | |
86 typedef struct video_registers_s | |
87 { | |
88 const char * sname; | |
89 uint32_t name; | |
90 uint32_t value; | |
91 }video_registers_t; | |
92 | |
93 static bes_registers_t besr; | |
94 #ifndef RAGE128 | |
95 static int IsR200=0; | |
96 #endif | |
97 #define DECLARE_VREG(name) { #name, name, 0 } | |
98 static video_registers_t vregs[] = | |
99 { | |
100 DECLARE_VREG(VIDEOMUX_CNTL), | |
101 DECLARE_VREG(VIPPAD_MASK), | |
102 DECLARE_VREG(VIPPAD1_A), | |
103 DECLARE_VREG(VIPPAD1_EN), | |
104 DECLARE_VREG(VIPPAD1_Y), | |
105 DECLARE_VREG(OV0_Y_X_START), | |
106 DECLARE_VREG(OV0_Y_X_END), | |
107 DECLARE_VREG(OV0_PIPELINE_CNTL), | |
108 DECLARE_VREG(OV0_EXCLUSIVE_HORZ), | |
109 DECLARE_VREG(OV0_EXCLUSIVE_VERT), | |
110 DECLARE_VREG(OV0_REG_LOAD_CNTL), | |
111 DECLARE_VREG(OV0_SCALE_CNTL), | |
112 DECLARE_VREG(OV0_V_INC), | |
113 DECLARE_VREG(OV0_P1_V_ACCUM_INIT), | |
114 DECLARE_VREG(OV0_P23_V_ACCUM_INIT), | |
115 DECLARE_VREG(OV0_P1_BLANK_LINES_AT_TOP), | |
116 DECLARE_VREG(OV0_P23_BLANK_LINES_AT_TOP), | |
117 #ifdef RADEON | |
118 DECLARE_VREG(OV0_BASE_ADDR), | |
119 #endif | |
120 DECLARE_VREG(OV0_VID_BUF0_BASE_ADRS), | |
121 DECLARE_VREG(OV0_VID_BUF1_BASE_ADRS), | |
122 DECLARE_VREG(OV0_VID_BUF2_BASE_ADRS), | |
123 DECLARE_VREG(OV0_VID_BUF3_BASE_ADRS), | |
124 DECLARE_VREG(OV0_VID_BUF4_BASE_ADRS), | |
125 DECLARE_VREG(OV0_VID_BUF5_BASE_ADRS), | |
126 DECLARE_VREG(OV0_VID_BUF_PITCH0_VALUE), | |
127 DECLARE_VREG(OV0_VID_BUF_PITCH1_VALUE), | |
128 DECLARE_VREG(OV0_AUTO_FLIP_CNTL), | |
129 DECLARE_VREG(OV0_DEINTERLACE_PATTERN), | |
130 DECLARE_VREG(OV0_SUBMIT_HISTORY), | |
131 DECLARE_VREG(OV0_H_INC), | |
132 DECLARE_VREG(OV0_STEP_BY), | |
133 DECLARE_VREG(OV0_P1_H_ACCUM_INIT), | |
134 DECLARE_VREG(OV0_P23_H_ACCUM_INIT), | |
135 DECLARE_VREG(OV0_P1_X_START_END), | |
136 DECLARE_VREG(OV0_P2_X_START_END), | |
137 DECLARE_VREG(OV0_P3_X_START_END), | |
138 DECLARE_VREG(OV0_FILTER_CNTL), | |
139 DECLARE_VREG(OV0_FOUR_TAP_COEF_0), | |
140 DECLARE_VREG(OV0_FOUR_TAP_COEF_1), | |
141 DECLARE_VREG(OV0_FOUR_TAP_COEF_2), | |
142 DECLARE_VREG(OV0_FOUR_TAP_COEF_3), | |
143 DECLARE_VREG(OV0_FOUR_TAP_COEF_4), | |
144 DECLARE_VREG(OV0_FLAG_CNTL), | |
145 #ifdef RAGE128 | |
146 DECLARE_VREG(OV0_COLOUR_CNTL), | |
147 #else | |
148 DECLARE_VREG(OV0_SLICE_CNTL), | |
149 #endif | |
150 DECLARE_VREG(OV0_VID_KEY_CLR), | |
151 DECLARE_VREG(OV0_VID_KEY_MSK), | |
152 DECLARE_VREG(OV0_GRAPHICS_KEY_CLR), | |
153 DECLARE_VREG(OV0_GRAPHICS_KEY_MSK), | |
154 DECLARE_VREG(OV0_KEY_CNTL), | |
155 DECLARE_VREG(OV0_TEST), | |
156 DECLARE_VREG(OV0_LIN_TRANS_A), | |
157 DECLARE_VREG(OV0_LIN_TRANS_B), | |
158 DECLARE_VREG(OV0_LIN_TRANS_C), | |
159 DECLARE_VREG(OV0_LIN_TRANS_D), | |
160 DECLARE_VREG(OV0_LIN_TRANS_E), | |
161 DECLARE_VREG(OV0_LIN_TRANS_F), | |
162 DECLARE_VREG(OV0_GAMMA_0_F), | |
163 DECLARE_VREG(OV0_GAMMA_10_1F), | |
164 DECLARE_VREG(OV0_GAMMA_20_3F), | |
165 DECLARE_VREG(OV0_GAMMA_40_7F), | |
166 DECLARE_VREG(OV0_GAMMA_380_3BF), | |
167 DECLARE_VREG(OV0_GAMMA_3C0_3FF), | |
168 DECLARE_VREG(SUBPIC_CNTL), | |
169 DECLARE_VREG(SUBPIC_DEFCOLCON), | |
170 DECLARE_VREG(SUBPIC_Y_X_START), | |
171 DECLARE_VREG(SUBPIC_Y_X_END), | |
172 DECLARE_VREG(SUBPIC_V_INC), | |
173 DECLARE_VREG(SUBPIC_H_INC), | |
174 DECLARE_VREG(SUBPIC_BUF0_OFFSET), | |
175 DECLARE_VREG(SUBPIC_BUF1_OFFSET), | |
176 DECLARE_VREG(SUBPIC_LC0_OFFSET), | |
177 DECLARE_VREG(SUBPIC_LC1_OFFSET), | |
178 DECLARE_VREG(SUBPIC_PITCH), | |
179 DECLARE_VREG(SUBPIC_BTN_HLI_COLCON), | |
180 DECLARE_VREG(SUBPIC_BTN_HLI_Y_X_START), | |
181 DECLARE_VREG(SUBPIC_BTN_HLI_Y_X_END), | |
182 DECLARE_VREG(SUBPIC_PALETTE_INDEX), | |
183 DECLARE_VREG(SUBPIC_PALETTE_DATA), | |
184 DECLARE_VREG(SUBPIC_H_ACCUM_INIT), | |
185 DECLARE_VREG(SUBPIC_V_ACCUM_INIT), | |
186 DECLARE_VREG(IDCT_RUNS), | |
187 DECLARE_VREG(IDCT_LEVELS), | |
188 DECLARE_VREG(IDCT_AUTH_CONTROL), | |
189 DECLARE_VREG(IDCT_AUTH), | |
190 DECLARE_VREG(IDCT_CONTROL) | |
191 }; | |
4030 | 192 |
3996 | 193 static void * radeon_mmio_base = 0; |
194 static void * radeon_mem_base = 0; | |
195 static int32_t radeon_overlay_off = 0; | |
196 static uint32_t radeon_ram_size = 0; | |
197 | |
4012 | 198 #define GETREG(TYPE,PTR,OFFZ) (*((volatile TYPE*)((PTR)+(OFFZ)))) |
199 #define SETREG(TYPE,PTR,OFFZ,VAL) (*((volatile TYPE*)((PTR)+(OFFZ))))=VAL | |
200 | |
201 #define INREG8(addr) GETREG(uint8_t,(uint32_t)(radeon_mmio_base),addr) | |
202 #define OUTREG8(addr,val) SETREG(uint8_t,(uint32_t)(radeon_mmio_base),addr,val) | |
203 #define INREG(addr) GETREG(uint32_t,(uint32_t)(radeon_mmio_base),addr) | |
204 #define OUTREG(addr,val) SETREG(uint32_t,(uint32_t)(radeon_mmio_base),addr,val) | |
3996 | 205 #define OUTREGP(addr,val,mask) \ |
206 do { \ | |
207 unsigned int _tmp = INREG(addr); \ | |
208 _tmp &= (mask); \ | |
209 _tmp |= (val); \ | |
210 OUTREG(addr, _tmp); \ | |
211 } while (0) | |
212 | |
4666 | 213 static __inline__ uint32_t INPLL(uint32_t addr) |
214 { | |
215 OUTREG8(CLOCK_CNTL_INDEX, addr & 0x0000001f); | |
216 return (INREG(CLOCK_CNTL_DATA)); | |
217 } | |
218 | |
219 #define OUTPLL(addr,val) OUTREG8(CLOCK_CNTL_INDEX, (addr & 0x0000001f) | 0x00000080); \ | |
220 OUTREG(CLOCK_CNTL_DATA, val) | |
221 #define OUTPLLP(addr,val,mask) \ | |
222 do { \ | |
223 unsigned int _tmp = INPLL(addr); \ | |
224 _tmp &= (mask); \ | |
225 _tmp |= (val); \ | |
226 OUTPLL(addr, _tmp); \ | |
227 } while (0) | |
228 | |
3996 | 229 static uint32_t radeon_vid_get_dbpp( void ) |
230 { | |
231 uint32_t dbpp,retval; | |
232 dbpp = (INREG(CRTC_GEN_CNTL)>>8)& 0xF; | |
233 switch(dbpp) | |
234 { | |
235 case DST_8BPP: retval = 8; break; | |
236 case DST_15BPP: retval = 15; break; | |
237 case DST_16BPP: retval = 16; break; | |
238 case DST_24BPP: retval = 24; break; | |
239 default: retval=32; break; | |
240 } | |
241 return retval; | |
242 } | |
243 | |
244 static int radeon_is_dbl_scan( void ) | |
245 { | |
246 return (INREG(CRTC_GEN_CNTL))&CRTC_DBL_SCAN_EN; | |
247 } | |
248 | |
249 static int radeon_is_interlace( void ) | |
250 { | |
251 return (INREG(CRTC_GEN_CNTL))&CRTC_INTERLACE_EN; | |
252 } | |
253 | |
4666 | 254 static uint32_t radeon_get_xres( void ) |
255 { | |
256 /* FIXME: currently we extract that from CRTC!!!*/ | |
257 uint32_t xres,h_total; | |
258 h_total = INREG(CRTC_H_TOTAL_DISP); | |
259 xres = (h_total >> 16) & 0xffff; | |
260 return (xres + 1)*8; | |
261 } | |
262 | |
263 static uint32_t radeon_get_yres( void ) | |
264 { | |
265 /* FIXME: currently we extract that from CRTC!!!*/ | |
266 uint32_t yres,v_total; | |
267 v_total = INREG(CRTC_V_TOTAL_DISP); | |
268 yres = (v_total >> 16) & 0xffff; | |
269 return yres + 1; | |
270 } | |
271 | |
4689 | 272 static void radeon_wait_vsync(void) |
273 { | |
274 int i; | |
275 | |
276 OUTREG(GEN_INT_STATUS, VSYNC_INT_AK); | |
277 for (i = 0; i < 2000000; i++) | |
278 { | |
279 if (INREG(GEN_INT_STATUS) & VSYNC_INT) break; | |
280 } | |
281 } | |
282 | |
283 | |
3996 | 284 static __inline__ void radeon_engine_flush ( void ) |
285 { | |
286 int i; | |
287 | |
288 /* initiate flush */ | |
289 OUTREGP(RB2D_DSTCACHE_CTLSTAT, RB2D_DC_FLUSH_ALL, | |
290 ~RB2D_DC_FLUSH_ALL); | |
291 | |
292 for (i=0; i < 2000000; i++) { | |
293 if (!(INREG(RB2D_DSTCACHE_CTLSTAT) & RB2D_DC_BUSY)) | |
294 break; | |
295 } | |
296 } | |
297 | |
4666 | 298 static void _radeon_engine_idle(void); |
299 static void _radeon_fifo_wait(unsigned); | |
300 #define radeon_engine_idle() _radeon_engine_idle() | |
301 #define radeon_fifo_wait(entries) _radeon_fifo_wait(entries) | |
3996 | 302 |
4666 | 303 static void radeon_engine_reset( void ) |
3996 | 304 { |
4666 | 305 uint32_t clock_cntl_index, mclk_cntl, rbbm_soft_reset; |
306 | |
307 radeon_engine_flush (); | |
308 | |
309 clock_cntl_index = INREG(CLOCK_CNTL_INDEX); | |
310 mclk_cntl = INPLL(MCLK_CNTL); | |
311 | |
312 OUTPLL(MCLK_CNTL, (mclk_cntl | | |
313 FORCEON_MCLKA | | |
314 FORCEON_MCLKB | | |
315 FORCEON_YCLKA | | |
316 FORCEON_YCLKB | | |
317 FORCEON_MC | | |
318 FORCEON_AIC)); | |
319 rbbm_soft_reset = INREG(RBBM_SOFT_RESET); | |
3996 | 320 |
4666 | 321 OUTREG(RBBM_SOFT_RESET, rbbm_soft_reset | |
322 SOFT_RESET_CP | | |
323 SOFT_RESET_HI | | |
324 SOFT_RESET_SE | | |
325 SOFT_RESET_RE | | |
326 SOFT_RESET_PP | | |
327 SOFT_RESET_E2 | | |
328 SOFT_RESET_RB | | |
329 SOFT_RESET_HDP); | |
330 INREG(RBBM_SOFT_RESET); | |
331 OUTREG(RBBM_SOFT_RESET, rbbm_soft_reset & (uint32_t) | |
332 ~(SOFT_RESET_CP | | |
333 SOFT_RESET_HI | | |
334 SOFT_RESET_SE | | |
335 SOFT_RESET_RE | | |
336 SOFT_RESET_PP | | |
337 SOFT_RESET_E2 | | |
338 SOFT_RESET_RB | | |
339 SOFT_RESET_HDP)); | |
340 INREG(RBBM_SOFT_RESET); | |
341 | |
342 OUTPLL(MCLK_CNTL, mclk_cntl); | |
343 OUTREG(CLOCK_CNTL_INDEX, clock_cntl_index); | |
344 OUTREG(RBBM_SOFT_RESET, rbbm_soft_reset); | |
345 | |
346 return; | |
3996 | 347 } |
348 | |
4666 | 349 static void radeon_engine_restore( void ) |
3996 | 350 { |
4666 | 351 int pitch64; |
352 uint32_t xres,yres,bpp; | |
353 radeon_fifo_wait(1); | |
354 xres = radeon_get_xres(); | |
355 yres = radeon_get_yres(); | |
356 bpp = radeon_vid_get_dbpp(); | |
357 /* turn of all automatic flushing - we'll do it all */ | |
358 OUTREG(RB2D_DSTCACHE_MODE, 0); | |
359 | |
360 pitch64 = ((xres * (bpp / 8) + 0x3f)) >> 6; | |
361 | |
362 radeon_fifo_wait(1); | |
363 OUTREG(DEFAULT_OFFSET, (INREG(DEFAULT_OFFSET) & 0xC0000000) | | |
364 (pitch64 << 22)); | |
365 | |
366 radeon_fifo_wait(1); | |
367 #if defined(__BIG_ENDIAN) | |
368 OUTREGP(DP_DATATYPE, | |
369 HOST_BIG_ENDIAN_EN, ~HOST_BIG_ENDIAN_EN); | |
370 #else | |
371 OUTREGP(DP_DATATYPE, 0, ~HOST_BIG_ENDIAN_EN); | |
372 #endif | |
373 | |
374 radeon_fifo_wait(1); | |
375 OUTREG(DEFAULT_SC_BOTTOM_RIGHT, (DEFAULT_SC_RIGHT_MAX | |
376 | DEFAULT_SC_BOTTOM_MAX)); | |
377 radeon_fifo_wait(1); | |
378 OUTREG(DP_GUI_MASTER_CNTL, (INREG(DP_GUI_MASTER_CNTL) | |
379 | GMC_BRUSH_SOLID_COLOR | |
380 | GMC_SRC_DATATYPE_COLOR)); | |
3996 | 381 |
4666 | 382 radeon_fifo_wait(7); |
383 OUTREG(DST_LINE_START, 0); | |
384 OUTREG(DST_LINE_END, 0); | |
385 OUTREG(DP_BRUSH_FRGD_CLR, 0xffffffff); | |
386 OUTREG(DP_BRUSH_BKGD_CLR, 0x00000000); | |
387 OUTREG(DP_SRC_FRGD_CLR, 0xffffffff); | |
388 OUTREG(DP_SRC_BKGD_CLR, 0x00000000); | |
389 OUTREG(DP_WRITE_MASK, 0xffffffff); | |
390 | |
391 radeon_engine_idle(); | |
392 } | |
393 | |
394 static void _radeon_fifo_wait (unsigned entries) | |
395 { | |
396 int i; | |
3996 | 397 |
4666 | 398 for(;;) |
399 { | |
400 for (i=0; i<2000000; i++) | |
401 if ((INREG(RBBM_STATUS) & RBBM_FIFOCNT_MASK) >= entries) | |
402 return; | |
403 radeon_engine_reset(); | |
404 radeon_engine_restore(); | |
405 } | |
406 } | |
407 | |
408 static void _radeon_engine_idle ( void ) | |
409 { | |
410 int i; | |
411 | |
412 /* ensure FIFO is empty before waiting for idle */ | |
413 radeon_fifo_wait (64); | |
414 for(;;) | |
415 { | |
3996 | 416 for (i=0; i<2000000; i++) { |
417 if (((INREG(RBBM_STATUS) & GUI_ACTIVE)) == 0) { | |
418 radeon_engine_flush (); | |
419 return; | |
420 } | |
421 } | |
4666 | 422 radeon_engine_reset(); |
423 radeon_engine_restore(); | |
424 } | |
3996 | 425 } |
426 | |
427 | |
428 | |
429 #ifndef RAGE128 | |
430 /* Reference color space transform data */ | |
431 typedef struct tagREF_TRANSFORM | |
432 { | |
433 float RefLuma; | |
434 float RefRCb; | |
435 float RefRCr; | |
436 float RefGCb; | |
437 float RefGCr; | |
438 float RefBCb; | |
439 float RefBCr; | |
440 } REF_TRANSFORM; | |
441 | |
442 /* Parameters for ITU-R BT.601 and ITU-R BT.709 colour spaces */ | |
443 REF_TRANSFORM trans[2] = | |
444 { | |
445 {1.1678, 0.0, 1.6007, -0.3929, -0.8154, 2.0232, 0.0}, /* BT.601 */ | |
446 {1.1678, 0.0, 1.7980, -0.2139, -0.5345, 2.1186, 0.0} /* BT.709 */ | |
447 }; | |
448 /**************************************************************************** | |
449 * SetTransform * | |
450 * Function: Calculates and sets color space transform from supplied * | |
451 * reference transform, gamma, brightness, contrast, hue and * | |
452 * saturation. * | |
453 * Inputs: bright - brightness * | |
454 * cont - contrast * | |
455 * sat - saturation * | |
456 * hue - hue * | |
4319
2d64382e8dcf
intense->intensity + capability extension + fixing R200 color correction bug
nick
parents:
4286
diff
changeset
|
457 * red_intensity - intense of red component * |
2d64382e8dcf
intense->intensity + capability extension + fixing R200 color correction bug
nick
parents:
4286
diff
changeset
|
458 * green_intensity - intense of green component * |
2d64382e8dcf
intense->intensity + capability extension + fixing R200 color correction bug
nick
parents:
4286
diff
changeset
|
459 * blue_intensity - intense of blue component * |
3996 | 460 * ref - index to the table of refernce transforms * |
461 * Outputs: NONE * | |
462 ****************************************************************************/ | |
463 | |
464 static void radeon_set_transform(float bright, float cont, float sat, | |
4319
2d64382e8dcf
intense->intensity + capability extension + fixing R200 color correction bug
nick
parents:
4286
diff
changeset
|
465 float hue, float red_intensity, |
2d64382e8dcf
intense->intensity + capability extension + fixing R200 color correction bug
nick
parents:
4286
diff
changeset
|
466 float green_intensity,float blue_intensity, |
4284 | 467 unsigned ref) |
3996 | 468 { |
469 float OvHueSin, OvHueCos; | |
470 float CAdjLuma, CAdjOff; | |
4284 | 471 float RedAdj,GreenAdj,BlueAdj; |
3996 | 472 float CAdjRCb, CAdjRCr; |
473 float CAdjGCb, CAdjGCr; | |
474 float CAdjBCb, CAdjBCr; | |
475 float OvLuma, OvROff, OvGOff, OvBOff; | |
476 float OvRCb, OvRCr; | |
477 float OvGCb, OvGCr; | |
478 float OvBCb, OvBCr; | |
479 float Loff = 64.0; | |
480 float Coff = 512.0f; | |
481 | |
482 uint32_t dwOvLuma, dwOvROff, dwOvGOff, dwOvBOff; | |
483 uint32_t dwOvRCb, dwOvRCr; | |
484 uint32_t dwOvGCb, dwOvGCr; | |
485 uint32_t dwOvBCb, dwOvBCr; | |
486 | |
487 if (ref >= 2) return; | |
488 | |
489 OvHueSin = sin((double)hue); | |
490 OvHueCos = cos((double)hue); | |
491 | |
492 CAdjLuma = cont * trans[ref].RefLuma; | |
493 CAdjOff = cont * trans[ref].RefLuma * bright * 1023.0; | |
4319
2d64382e8dcf
intense->intensity + capability extension + fixing R200 color correction bug
nick
parents:
4286
diff
changeset
|
494 RedAdj = cont * trans[ref].RefLuma * red_intensity * 1023.0; |
2d64382e8dcf
intense->intensity + capability extension + fixing R200 color correction bug
nick
parents:
4286
diff
changeset
|
495 GreenAdj = cont * trans[ref].RefLuma * green_intensity * 1023.0; |
2d64382e8dcf
intense->intensity + capability extension + fixing R200 color correction bug
nick
parents:
4286
diff
changeset
|
496 BlueAdj = cont * trans[ref].RefLuma * blue_intensity * 1023.0; |
3996 | 497 |
498 CAdjRCb = sat * -OvHueSin * trans[ref].RefRCr; | |
499 CAdjRCr = sat * OvHueCos * trans[ref].RefRCr; | |
500 CAdjGCb = sat * (OvHueCos * trans[ref].RefGCb - OvHueSin * trans[ref].RefGCr); | |
501 CAdjGCr = sat * (OvHueSin * trans[ref].RefGCb + OvHueCos * trans[ref].RefGCr); | |
502 CAdjBCb = sat * OvHueCos * trans[ref].RefBCb; | |
503 CAdjBCr = sat * OvHueSin * trans[ref].RefBCb; | |
504 | |
505 #if 0 /* default constants */ | |
506 CAdjLuma = 1.16455078125; | |
507 | |
508 CAdjRCb = 0.0; | |
509 CAdjRCr = 1.59619140625; | |
510 CAdjGCb = -0.39111328125; | |
511 CAdjGCr = -0.8125; | |
512 CAdjBCb = 2.01708984375; | |
513 CAdjBCr = 0; | |
514 #endif | |
515 OvLuma = CAdjLuma; | |
516 OvRCb = CAdjRCb; | |
517 OvRCr = CAdjRCr; | |
518 OvGCb = CAdjGCb; | |
519 OvGCr = CAdjGCr; | |
520 OvBCb = CAdjBCb; | |
521 OvBCr = CAdjBCr; | |
4284 | 522 OvROff = RedAdj + CAdjOff - |
3996 | 523 OvLuma * Loff - (OvRCb + OvRCr) * Coff; |
4284 | 524 OvGOff = GreenAdj + CAdjOff - |
3996 | 525 OvLuma * Loff - (OvGCb + OvGCr) * Coff; |
4284 | 526 OvBOff = BlueAdj + CAdjOff - |
3996 | 527 OvLuma * Loff - (OvBCb + OvBCr) * Coff; |
528 #if 0 /* default constants */ | |
529 OvROff = -888.5; | |
530 OvGOff = 545; | |
531 OvBOff = -1104; | |
532 #endif | |
533 | |
534 dwOvROff = ((int)(OvROff * 2.0)) & 0x1fff; | |
535 dwOvGOff = (int)(OvGOff * 2.0) & 0x1fff; | |
536 dwOvBOff = (int)(OvBOff * 2.0) & 0x1fff; | |
4319
2d64382e8dcf
intense->intensity + capability extension + fixing R200 color correction bug
nick
parents:
4286
diff
changeset
|
537 /* Whatever docs say about R200 having 3.8 format instead of 3.11 |
2d64382e8dcf
intense->intensity + capability extension + fixing R200 color correction bug
nick
parents:
4286
diff
changeset
|
538 as in Radeon is a lie */ |
2d64382e8dcf
intense->intensity + capability extension + fixing R200 color correction bug
nick
parents:
4286
diff
changeset
|
539 #if 0 |
3996 | 540 if(!IsR200) |
541 { | |
4319
2d64382e8dcf
intense->intensity + capability extension + fixing R200 color correction bug
nick
parents:
4286
diff
changeset
|
542 #endif |
3996 | 543 dwOvLuma =(((int)(OvLuma * 2048.0))&0x7fff)<<17; |
544 dwOvRCb = (((int)(OvRCb * 2048.0))&0x7fff)<<1; | |
545 dwOvRCr = (((int)(OvRCr * 2048.0))&0x7fff)<<17; | |
546 dwOvGCb = (((int)(OvGCb * 2048.0))&0x7fff)<<1; | |
547 dwOvGCr = (((int)(OvGCr * 2048.0))&0x7fff)<<17; | |
548 dwOvBCb = (((int)(OvBCb * 2048.0))&0x7fff)<<1; | |
549 dwOvBCr = (((int)(OvBCr * 2048.0))&0x7fff)<<17; | |
4319
2d64382e8dcf
intense->intensity + capability extension + fixing R200 color correction bug
nick
parents:
4286
diff
changeset
|
550 #if 0 |
3996 | 551 } |
552 else | |
553 { | |
554 dwOvLuma = (((int)(OvLuma * 256.0))&0x7ff)<<20; | |
555 dwOvRCb = (((int)(OvRCb * 256.0))&0x7ff)<<4; | |
556 dwOvRCr = (((int)(OvRCr * 256.0))&0x7ff)<<20; | |
557 dwOvGCb = (((int)(OvGCb * 256.0))&0x7ff)<<4; | |
558 dwOvGCr = (((int)(OvGCr * 256.0))&0x7ff)<<20; | |
559 dwOvBCb = (((int)(OvBCb * 256.0))&0x7ff)<<4; | |
560 dwOvBCr = (((int)(OvBCr * 256.0))&0x7ff)<<20; | |
561 } | |
4319
2d64382e8dcf
intense->intensity + capability extension + fixing R200 color correction bug
nick
parents:
4286
diff
changeset
|
562 #endif |
3996 | 563 OUTREG(OV0_LIN_TRANS_A, dwOvRCb | dwOvLuma); |
564 OUTREG(OV0_LIN_TRANS_B, dwOvROff | dwOvRCr); | |
565 OUTREG(OV0_LIN_TRANS_C, dwOvGCb | dwOvLuma); | |
566 OUTREG(OV0_LIN_TRANS_D, dwOvGOff | dwOvGCr); | |
567 OUTREG(OV0_LIN_TRANS_E, dwOvBCb | dwOvLuma); | |
568 OUTREG(OV0_LIN_TRANS_F, dwOvBOff | dwOvBCr); | |
569 } | |
570 | |
571 /* Gamma curve definition */ | |
572 typedef struct | |
573 { | |
574 unsigned int gammaReg; | |
575 unsigned int gammaSlope; | |
576 unsigned int gammaOffset; | |
577 }GAMMA_SETTINGS; | |
578 | |
579 /* Recommended gamma curve parameters */ | |
580 GAMMA_SETTINGS r200_def_gamma[18] = | |
581 { | |
582 {OV0_GAMMA_0_F, 0x100, 0x0000}, | |
583 {OV0_GAMMA_10_1F, 0x100, 0x0020}, | |
584 {OV0_GAMMA_20_3F, 0x100, 0x0040}, | |
585 {OV0_GAMMA_40_7F, 0x100, 0x0080}, | |
586 {OV0_GAMMA_80_BF, 0x100, 0x0100}, | |
587 {OV0_GAMMA_C0_FF, 0x100, 0x0100}, | |
588 {OV0_GAMMA_100_13F, 0x100, 0x0200}, | |
589 {OV0_GAMMA_140_17F, 0x100, 0x0200}, | |
590 {OV0_GAMMA_180_1BF, 0x100, 0x0300}, | |
591 {OV0_GAMMA_1C0_1FF, 0x100, 0x0300}, | |
592 {OV0_GAMMA_200_23F, 0x100, 0x0400}, | |
593 {OV0_GAMMA_240_27F, 0x100, 0x0400}, | |
594 {OV0_GAMMA_280_2BF, 0x100, 0x0500}, | |
595 {OV0_GAMMA_2C0_2FF, 0x100, 0x0500}, | |
596 {OV0_GAMMA_300_33F, 0x100, 0x0600}, | |
597 {OV0_GAMMA_340_37F, 0x100, 0x0600}, | |
598 {OV0_GAMMA_380_3BF, 0x100, 0x0700}, | |
599 {OV0_GAMMA_3C0_3FF, 0x100, 0x0700} | |
600 }; | |
601 | |
602 GAMMA_SETTINGS r100_def_gamma[6] = | |
603 { | |
604 {OV0_GAMMA_0_F, 0x100, 0x0000}, | |
605 {OV0_GAMMA_10_1F, 0x100, 0x0020}, | |
606 {OV0_GAMMA_20_3F, 0x100, 0x0040}, | |
607 {OV0_GAMMA_40_7F, 0x100, 0x0080}, | |
608 {OV0_GAMMA_380_3BF, 0x100, 0x0100}, | |
609 {OV0_GAMMA_3C0_3FF, 0x100, 0x0100} | |
610 }; | |
611 | |
612 static void make_default_gamma_correction( void ) | |
613 { | |
614 size_t i; | |
615 if(!IsR200){ | |
616 OUTREG(OV0_LIN_TRANS_A, 0x12A00000); | |
617 OUTREG(OV0_LIN_TRANS_B, 0x199018FE); | |
618 OUTREG(OV0_LIN_TRANS_C, 0x12A0F9B0); | |
619 OUTREG(OV0_LIN_TRANS_D, 0xF2F0043B); | |
620 OUTREG(OV0_LIN_TRANS_E, 0x12A02050); | |
621 OUTREG(OV0_LIN_TRANS_F, 0x0000174E); | |
622 for(i=0; i<6; i++){ | |
623 OUTREG(r100_def_gamma[i].gammaReg, | |
624 (r100_def_gamma[i].gammaSlope<<16) | | |
625 r100_def_gamma[i].gammaOffset); | |
626 } | |
627 } | |
628 else{ | |
629 OUTREG(OV0_LIN_TRANS_A, 0x12a00000); | |
630 OUTREG(OV0_LIN_TRANS_B, 0x1990190e); | |
631 OUTREG(OV0_LIN_TRANS_C, 0x12a0f9c0); | |
632 OUTREG(OV0_LIN_TRANS_D, 0xf3000442); | |
633 OUTREG(OV0_LIN_TRANS_E, 0x12a02040); | |
634 OUTREG(OV0_LIN_TRANS_F, 0x175f); | |
635 | |
636 /* Default Gamma, | |
637 Of 18 segments for gamma cure, all segments in R200 are programmable, | |
638 while only lower 4 and upper 2 segments are programmable in Radeon*/ | |
639 for(i=0; i<18; i++){ | |
640 OUTREG(r200_def_gamma[i].gammaReg, | |
641 (r200_def_gamma[i].gammaSlope<<16) | | |
642 r200_def_gamma[i].gammaOffset); | |
643 } | |
644 } | |
645 } | |
646 #endif | |
647 | |
648 static void radeon_vid_make_default(void) | |
649 { | |
650 #ifdef RAGE128 | |
651 OUTREG(OV0_COLOUR_CNTL,0x00101000UL); /* Default brihgtness and saturation for Rage128 */ | |
652 #else | |
653 make_default_gamma_correction(); | |
654 #endif | |
655 besr.deinterlace_pattern = 0x900AAAAA; | |
656 OUTREG(OV0_DEINTERLACE_PATTERN,besr.deinterlace_pattern); | |
657 besr.deinterlace_on=1; | |
658 besr.double_buff=1; | |
4869 | 659 besr.ckey_on=0; |
660 besr.graphics_key_msk=0; | |
661 besr.graphics_key_clr=0; | |
5044
43dc579db3d1
Fixed color key definitions. Waiting for new bugreports ;)
nick
parents:
5041
diff
changeset
|
662 besr.ckey_cntl = VIDEO_KEY_FN_TRUE|GRAPHIC_KEY_FN_TRUE|CMP_MIX_AND; |
3996 | 663 } |
664 | |
665 | |
666 unsigned vixGetVersion( void ) { return VIDIX_VERSION; } | |
667 | |
4107 | 668 static unsigned short ati_card_ids[] = |
3996 | 669 { |
670 #ifdef RAGE128 | |
671 /* | |
672 This driver should be compatible with Rage128 (pro) chips. | |
673 (include adaptive deinterlacing!!!). | |
674 Moreover: the same logic can be used with Mach64 chips. | |
675 (I mean: mach64xx, 3d rage, 3d rage IIc, 3D rage pro, 3d rage mobility). | |
676 but they are incompatible by i/o ports. So if enthusiasts will want | |
677 then they can redefine OUTREG and INREG macros and redefine OV0_* | |
678 constants. Also it seems that mach64 chips supports only: YUY2, YV12, UYVY | |
679 fourccs (422 and 420 formats only). | |
680 */ | |
681 /* Rage128 Pro GL */ | |
4107 | 682 DEVICE_ATI_RAGE_128_PA_PRO, |
683 DEVICE_ATI_RAGE_128_PB_PRO, | |
684 DEVICE_ATI_RAGE_128_PC_PRO, | |
685 DEVICE_ATI_RAGE_128_PD_PRO, | |
686 DEVICE_ATI_RAGE_128_PE_PRO, | |
687 DEVICE_ATI_RAGE_128_PF_PRO, | |
3996 | 688 /* Rage128 Pro VR */ |
4107 | 689 DEVICE_ATI_RAGE_128_PG_PRO, |
690 DEVICE_ATI_RAGE_128_PH_PRO, | |
691 DEVICE_ATI_RAGE_128_PI_PRO, | |
692 DEVICE_ATI_RAGE_128_PJ_PRO, | |
693 DEVICE_ATI_RAGE_128_PK_PRO, | |
694 DEVICE_ATI_RAGE_128_PL_PRO, | |
695 DEVICE_ATI_RAGE_128_PM_PRO, | |
696 DEVICE_ATI_RAGE_128_PN_PRO, | |
697 DEVICE_ATI_RAGE_128_PO_PRO, | |
698 DEVICE_ATI_RAGE_128_PP_PRO, | |
699 DEVICE_ATI_RAGE_128_PQ_PRO, | |
700 DEVICE_ATI_RAGE_128_PR_PRO, | |
701 DEVICE_ATI_RAGE_128_PS_PRO, | |
702 DEVICE_ATI_RAGE_128_PT_PRO, | |
703 DEVICE_ATI_RAGE_128_PU_PRO, | |
704 DEVICE_ATI_RAGE_128_PV_PRO, | |
705 DEVICE_ATI_RAGE_128_PW_PRO, | |
706 DEVICE_ATI_RAGE_128_PX_PRO, | |
3996 | 707 /* Rage128 GL */ |
4107 | 708 DEVICE_ATI_RAGE_128_RE_SG, |
709 DEVICE_ATI_RAGE_128_RF_SG, | |
710 DEVICE_ATI_RAGE_128_RG, | |
711 DEVICE_ATI_RAGE_128_RK_VR, | |
712 DEVICE_ATI_RAGE_128_RL_VR, | |
713 DEVICE_ATI_RAGE_128_SE_4X, | |
714 DEVICE_ATI_RAGE_128_SF_4X, | |
715 DEVICE_ATI_RAGE_128_SG_4X, | |
716 DEVICE_ATI_RAGE_128_4X, | |
717 DEVICE_ATI_RAGE_128_SK_4X, | |
718 DEVICE_ATI_RAGE_128_SL_4X, | |
719 DEVICE_ATI_RAGE_128_SM_4X, | |
720 DEVICE_ATI_RAGE_128_4X2, | |
721 DEVICE_ATI_RAGE_128_PRO, | |
722 DEVICE_ATI_RAGE_128_PRO2, | |
723 DEVICE_ATI_RAGE_128_PRO3 | |
3996 | 724 #else |
725 /* Radeons (indeed: Rage 256 Pro ;) */ | |
4107 | 726 DEVICE_ATI_RADEON_8500_DV, |
727 DEVICE_ATI_RADEON_MOBILITY_M6, | |
728 DEVICE_ATI_RADEON_MOBILITY_M62, | |
729 DEVICE_ATI_RADEON_MOBILITY_M63, | |
730 DEVICE_ATI_RADEON_QD, | |
731 DEVICE_ATI_RADEON_QE, | |
732 DEVICE_ATI_RADEON_QF, | |
733 DEVICE_ATI_RADEON_QG, | |
734 DEVICE_ATI_RADEON_QL, | |
735 DEVICE_ATI_RADEON_QW, | |
736 DEVICE_ATI_RADEON_VE_QY, | |
737 DEVICE_ATI_RADEON_VE_QZ | |
3996 | 738 #endif |
739 }; | |
740 | |
741 static int find_chip(unsigned chip_id) | |
742 { | |
743 unsigned i; | |
4107 | 744 for(i = 0;i < sizeof(ati_card_ids)/sizeof(unsigned short);i++) |
3996 | 745 { |
4107 | 746 if(chip_id == ati_card_ids[i]) return i; |
3996 | 747 } |
748 return -1; | |
749 } | |
750 | |
751 pciinfo_t pci_info; | |
752 static int probed=0; | |
753 | |
754 vidix_capability_t def_cap = | |
755 { | |
756 #ifdef RAGE128 | |
757 "BES driver for rage128 cards", | |
758 #else | |
759 "BES driver for radeon cards", | |
760 #endif | |
4327 | 761 "Nick Kurshev", |
3996 | 762 TYPE_OUTPUT | TYPE_FX, |
4191 | 763 { 0, 0, 0, 0 }, |
4282 | 764 2048, |
765 2048, | |
3996 | 766 4, |
767 4, | |
768 -1, | |
4264 | 769 FLAG_UPSCALER | FLAG_DOWNSCALER | FLAG_EQUALIZER, |
4134 | 770 VENDOR_ATI, |
3996 | 771 0, |
772 { 0, 0, 0, 0} | |
773 }; | |
774 | |
775 | |
4191 | 776 int vixProbe( int verbose,int force ) |
3996 | 777 { |
778 pciinfo_t lst[MAX_PCI_DEVICES]; | |
779 unsigned i,num_pci; | |
780 int err; | |
4030 | 781 __verbose = verbose; |
3996 | 782 err = pci_scan(lst,&num_pci); |
783 if(err) | |
784 { | |
785 printf(RADEON_MSG" Error occured during pci scan: %s\n",strerror(err)); | |
786 return err; | |
787 } | |
788 else | |
789 { | |
790 err = ENXIO; | |
791 for(i=0;i<num_pci;i++) | |
792 { | |
4107 | 793 if(lst[i].vendor == VENDOR_ATI) |
3996 | 794 { |
795 int idx; | |
4191 | 796 const char *dname; |
3996 | 797 idx = find_chip(lst[i].device); |
4191 | 798 if(idx == -1 && force == PROBE_NORMAL) continue; |
799 dname = pci_device_name(VENDOR_ATI,lst[i].device); | |
800 dname = dname ? dname : "Unknown chip"; | |
801 printf(RADEON_MSG" Found chip: %s\n",dname); | |
3996 | 802 #ifndef RAGE128 |
4191 | 803 if(idx != -1) |
804 if(ati_card_ids[idx] == DEVICE_ATI_RADEON_QL || | |
805 ati_card_ids[idx] == DEVICE_ATI_RADEON_8500_DV || | |
806 ati_card_ids[idx] == DEVICE_ATI_RADEON_QW) IsR200 = 1; | |
3996 | 807 #endif |
4193 | 808 if(force > PROBE_NORMAL) |
809 { | |
810 printf(RADEON_MSG" Driver was forced. Was found %sknown chip\n",idx == -1 ? "un" : ""); | |
811 if(idx == -1) | |
812 #ifdef RAGE128 | |
4373 | 813 printf(RADEON_MSG" Assuming it as Rage128\n"); |
4193 | 814 #else |
4373 | 815 printf(RADEON_MSG" Assuming it as Radeon1\n"); |
4193 | 816 #endif |
817 } | |
4191 | 818 def_cap.device_id = lst[i].device; |
3996 | 819 err = 0; |
820 memcpy(&pci_info,&lst[i],sizeof(pciinfo_t)); | |
821 probed=1; | |
822 break; | |
823 } | |
824 } | |
825 } | |
826 if(err && verbose) printf(RADEON_MSG" Can't find chip\n"); | |
827 return err; | |
828 } | |
829 | |
830 int vixInit( void ) | |
831 { | |
4477 | 832 int err; |
4012 | 833 if(!probed) |
834 { | |
835 printf(RADEON_MSG" Driver was not probed but is being initializing\n"); | |
836 return EINTR; | |
837 } | |
838 if((radeon_mmio_base = map_phys_mem(pci_info.base2,0xFFFF))==(void *)-1) return ENOMEM; | |
3996 | 839 radeon_ram_size = INREG(CONFIG_MEMSIZE); |
840 /* mem size is bits [28:0], mask off the rest. Range: from 1Mb up to 512 Mb */ | |
841 radeon_ram_size &= CONFIG_MEMSIZE_MASK; | |
842 if((radeon_mem_base = map_phys_mem(pci_info.base0,radeon_ram_size))==(void *)-1) return ENOMEM; | |
4070
b61ba6c256dd
Minor interface changes: color and video keys are moved out from playback configuring
nick
parents:
4038
diff
changeset
|
843 memset(&besr,0,sizeof(bes_registers_t)); |
3996 | 844 radeon_vid_make_default(); |
845 printf(RADEON_MSG" Video memory = %uMb\n",radeon_ram_size/0x100000); | |
4477 | 846 err = mtrr_set_type(pci_info.base0,radeon_ram_size,MTRR_TYPE_WRCOMB); |
847 if(!err) printf(RADEON_MSG" Set write-combining type of video memory\n"); | |
3996 | 848 return 0; |
849 } | |
850 | |
851 void vixDestroy( void ) | |
852 { | |
853 unmap_phys_mem(radeon_mem_base,radeon_ram_size); | |
4855 | 854 unmap_phys_mem(radeon_mmio_base,0xFFFF); |
3996 | 855 } |
856 | |
857 int vixGetCapability(vidix_capability_t *to) | |
858 { | |
859 memcpy(to,&def_cap,sizeof(vidix_capability_t)); | |
860 return 0; | |
861 } | |
862 | |
863 uint32_t supported_fourcc[] = | |
864 { | |
865 IMGFMT_YV12, IMGFMT_I420, IMGFMT_IYUV, | |
4455 | 866 IMGFMT_UYVY, IMGFMT_YUY2, IMGFMT_YVYU, |
4429 | 867 IMGFMT_RGB15, IMGFMT_BGR15, |
4416 | 868 IMGFMT_RGB16, IMGFMT_BGR16, |
869 IMGFMT_RGB32, IMGFMT_BGR32 | |
3996 | 870 }; |
871 | |
872 __inline__ static int is_supported_fourcc(uint32_t fourcc) | |
873 { | |
874 unsigned i; | |
875 for(i=0;i<sizeof(supported_fourcc)/sizeof(uint32_t);i++) | |
876 { | |
877 if(fourcc==supported_fourcc[i]) return 1; | |
878 } | |
879 return 0; | |
880 } | |
881 | |
882 int vixQueryFourcc(vidix_fourcc_t *to) | |
883 { | |
884 if(is_supported_fourcc(to->fourcc)) | |
885 { | |
886 to->depth = VID_DEPTH_1BPP | VID_DEPTH_2BPP | | |
887 VID_DEPTH_4BPP | VID_DEPTH_8BPP | | |
888 VID_DEPTH_12BPP| VID_DEPTH_15BPP| | |
889 VID_DEPTH_16BPP| VID_DEPTH_24BPP| | |
890 VID_DEPTH_32BPP; | |
5044
43dc579db3d1
Fixed color key definitions. Waiting for new bugreports ;)
nick
parents:
5041
diff
changeset
|
891 to->flags = VID_CAP_EXPAND | VID_CAP_SHRINK | VID_CAP_COLORKEY; |
3996 | 892 return 0; |
893 } | |
4015 | 894 else to->depth = to->flags = 0; |
3996 | 895 return ENOSYS; |
896 } | |
897 | |
898 static void radeon_vid_dump_regs( void ) | |
899 { | |
900 size_t i; | |
4015 | 901 printf(RADEON_MSG"*** Begin of DRIVER variables dump ***\n"); |
902 printf(RADEON_MSG"radeon_mmio_base=%p\n",radeon_mmio_base); | |
903 printf(RADEON_MSG"radeon_mem_base=%p\n",radeon_mem_base); | |
904 printf(RADEON_MSG"radeon_overlay_off=%08X\n",radeon_overlay_off); | |
905 printf(RADEON_MSG"radeon_ram_size=%08X\n",radeon_ram_size); | |
4666 | 906 printf(RADEON_MSG"video mode: %ux%u@%u\n",radeon_get_xres(),radeon_get_yres(),radeon_vid_get_dbpp()); |
4015 | 907 printf(RADEON_MSG"*** Begin of OV0 registers dump ***\n"); |
3996 | 908 for(i=0;i<sizeof(vregs)/sizeof(video_registers_t);i++) |
4015 | 909 printf(RADEON_MSG"%s = %08X\n",vregs[i].sname,INREG(vregs[i].name)); |
910 printf(RADEON_MSG"*** End of OV0 registers dump ***\n"); | |
3996 | 911 } |
912 | |
913 static void radeon_vid_stop_video( void ) | |
914 { | |
915 radeon_engine_idle(); | |
916 OUTREG(OV0_SCALE_CNTL, SCALER_SOFT_RESET); | |
917 OUTREG(OV0_EXCLUSIVE_HORZ, 0); | |
918 OUTREG(OV0_AUTO_FLIP_CNTL, 0); /* maybe */ | |
919 OUTREG(OV0_FILTER_CNTL, FILTER_HARDCODED_COEF); | |
920 OUTREG(OV0_KEY_CNTL, GRAPHIC_KEY_FN_NE); | |
921 OUTREG(OV0_TEST, 0); | |
922 } | |
923 | |
924 static void radeon_vid_display_video( void ) | |
925 { | |
926 int bes_flags; | |
927 radeon_fifo_wait(2); | |
928 OUTREG(OV0_REG_LOAD_CNTL, REG_LD_CTL_LOCK); | |
929 radeon_engine_idle(); | |
930 while(!(INREG(OV0_REG_LOAD_CNTL)®_LD_CTL_LOCK_READBACK)); | |
931 radeon_fifo_wait(15); | |
4666 | 932 |
933 /* Shutdown capturing */ | |
934 OUTREG(FCP_CNTL, FCP_CNTL__GND); | |
935 OUTREG(CAP0_TRIG_CNTL, 0); | |
936 | |
4689 | 937 OUTREG(VID_BUFFER_CONTROL, (1<<16) | 0x01); |
938 OUTREG(DISP_TEST_DEBUG_CNTL, 0); | |
4666 | 939 |
3996 | 940 OUTREG(OV0_AUTO_FLIP_CNTL,OV0_AUTO_FLIP_CNTL_SOFT_BUF_ODD); |
941 | |
4611 | 942 if(besr.deinterlace_on) OUTREG(OV0_DEINTERLACE_PATTERN,besr.deinterlace_pattern); |
3996 | 943 #ifdef RAGE128 |
944 OUTREG(OV0_COLOUR_CNTL, (besr.brightness & 0x7f) | | |
945 (besr.saturation << 8) | | |
946 (besr.saturation << 16)); | |
947 #endif | |
948 radeon_fifo_wait(2); | |
4869 | 949 OUTREG(OV0_GRAPHICS_KEY_MSK, besr.graphics_key_msk); |
950 OUTREG(OV0_GRAPHICS_KEY_CLR, besr.graphics_key_clr); | |
951 OUTREG(OV0_KEY_CNTL,besr.ckey_cntl); | |
3996 | 952 |
953 OUTREG(OV0_H_INC, besr.h_inc); | |
954 OUTREG(OV0_STEP_BY, besr.step_by); | |
955 OUTREG(OV0_Y_X_START, besr.y_x_start); | |
956 OUTREG(OV0_Y_X_END, besr.y_x_end); | |
957 OUTREG(OV0_V_INC, besr.v_inc); | |
958 OUTREG(OV0_P1_BLANK_LINES_AT_TOP, besr.p1_blank_lines_at_top); | |
959 OUTREG(OV0_P23_BLANK_LINES_AT_TOP, besr.p23_blank_lines_at_top); | |
960 OUTREG(OV0_VID_BUF_PITCH0_VALUE, besr.vid_buf_pitch0_value); | |
961 OUTREG(OV0_VID_BUF_PITCH1_VALUE, besr.vid_buf_pitch1_value); | |
962 OUTREG(OV0_P1_X_START_END, besr.p1_x_start_end); | |
963 OUTREG(OV0_P2_X_START_END, besr.p2_x_start_end); | |
964 OUTREG(OV0_P3_X_START_END, besr.p3_x_start_end); | |
965 #ifdef RADEON | |
966 OUTREG(OV0_BASE_ADDR, besr.base_addr); | |
967 #endif | |
4930 | 968 OUTREG(OV0_VID_BUF0_BASE_ADRS, besr.vid_buf_base_adrs_y[0]); |
5041 | 969 OUTREG(OV0_VID_BUF1_BASE_ADRS, besr.vid_buf_base_adrs_v[0]); |
970 OUTREG(OV0_VID_BUF2_BASE_ADRS, besr.vid_buf_base_adrs_u[0]); | |
3996 | 971 radeon_fifo_wait(9); |
4930 | 972 OUTREG(OV0_VID_BUF3_BASE_ADRS, besr.vid_buf_base_adrs_y[0]); |
5041 | 973 OUTREG(OV0_VID_BUF4_BASE_ADRS, besr.vid_buf_base_adrs_v[0]); |
974 OUTREG(OV0_VID_BUF5_BASE_ADRS, besr.vid_buf_base_adrs_u[0]); | |
3996 | 975 OUTREG(OV0_P1_V_ACCUM_INIT, besr.p1_v_accum_init); |
976 OUTREG(OV0_P1_H_ACCUM_INIT, besr.p1_h_accum_init); | |
977 OUTREG(OV0_P23_H_ACCUM_INIT, besr.p23_h_accum_init); | |
978 OUTREG(OV0_P23_V_ACCUM_INIT, besr.p23_v_accum_init); | |
979 | |
980 bes_flags = SCALER_ENABLE | | |
981 SCALER_SMART_SWITCH | | |
982 #ifdef RADEON | |
4666 | 983 SCALER_HORZ_PICK_NEAREST | |
984 #endif | |
3996 | 985 SCALER_Y2R_TEMP | |
986 SCALER_PIX_EXPAND; | |
987 if(besr.double_buff) bes_flags |= SCALER_DOUBLE_BUFFER; | |
988 if(besr.deinterlace_on) bes_flags |= SCALER_ADAPTIVE_DEINT; | |
989 #ifdef RAGE128 | |
990 bes_flags |= SCALER_BURST_PER_PLANE; | |
991 #endif | |
992 switch(besr.fourcc) | |
993 { | |
994 case IMGFMT_RGB15: | |
995 case IMGFMT_BGR15: bes_flags |= SCALER_SOURCE_15BPP; break; | |
4429 | 996 case IMGFMT_RGB16: |
3996 | 997 case IMGFMT_BGR16: bes_flags |= SCALER_SOURCE_16BPP; break; |
4416 | 998 /* |
3996 | 999 case IMGFMT_RGB24: |
1000 case IMGFMT_BGR24: bes_flags |= SCALER_SOURCE_24BPP; break; | |
4416 | 1001 */ |
3996 | 1002 case IMGFMT_RGB32: |
1003 case IMGFMT_BGR32: bes_flags |= SCALER_SOURCE_32BPP; break; | |
1004 /* 4:1:0*/ | |
1005 case IMGFMT_IF09: | |
1006 case IMGFMT_YVU9: bes_flags |= SCALER_SOURCE_YUV9; break; | |
1007 /* 4:2:0 */ | |
1008 case IMGFMT_IYUV: | |
1009 case IMGFMT_I420: | |
1010 case IMGFMT_YV12: bes_flags |= SCALER_SOURCE_YUV12; | |
1011 break; | |
1012 /* 4:2:2 */ | |
4455 | 1013 case IMGFMT_YVYU: |
3996 | 1014 case IMGFMT_UYVY: bes_flags |= SCALER_SOURCE_YVYU422; break; |
1015 case IMGFMT_YUY2: | |
1016 default: bes_flags |= SCALER_SOURCE_VYUY422; break; | |
1017 } | |
1018 OUTREG(OV0_SCALE_CNTL, bes_flags); | |
1019 OUTREG(OV0_REG_LOAD_CNTL, 0); | |
4666 | 1020 if(__verbose > 1) printf(RADEON_MSG"we wanted: scaler=%08X\n",bes_flags); |
4030 | 1021 if(__verbose > 1) radeon_vid_dump_regs(); |
3996 | 1022 } |
1023 | |
4456 | 1024 static unsigned radeon_query_pitch(unsigned fourcc,const vidix_yuv_t *spitch) |
4009 | 1025 { |
4456 | 1026 unsigned pitch,spy,spv,spu; |
1027 spy = spv = spu = 0; | |
1028 switch(spitch->y) | |
1029 { | |
1030 case 16: | |
1031 case 32: | |
1032 case 64: | |
1033 case 128: | |
1034 case 256: spy = spitch->y; break; | |
1035 default: break; | |
1036 } | |
1037 switch(spitch->u) | |
1038 { | |
1039 case 16: | |
1040 case 32: | |
1041 case 64: | |
1042 case 128: | |
1043 case 256: spu = spitch->u; break; | |
1044 default: break; | |
1045 } | |
1046 switch(spitch->v) | |
1047 { | |
1048 case 16: | |
1049 case 32: | |
1050 case 64: | |
1051 case 128: | |
1052 case 256: spv = spitch->v; break; | |
1053 default: break; | |
1054 } | |
4009 | 1055 switch(fourcc) |
1056 { | |
1057 /* 4:2:0 */ | |
1058 case IMGFMT_IYUV: | |
1059 case IMGFMT_YV12: | |
4456 | 1060 case IMGFMT_I420: |
1061 if(spy > 16 && spu == spy/2 && spv == spy/2) pitch = spy; | |
1062 else pitch = 32; | |
1063 break; | |
1064 default: | |
1065 if(spy >= 16) pitch = spy; | |
1066 else pitch = 16; | |
1067 break; | |
4009 | 1068 } |
1069 return pitch; | |
1070 } | |
1071 | |
3996 | 1072 static int radeon_vid_init_video( vidix_playback_t *config ) |
1073 { | |
4930 | 1074 uint32_t i,tmp,src_w,src_h,dest_w,dest_h,pitch,h_inc,step_by,left,leftUV,top; |
4571 | 1075 int is_420,is_rgb32,is_rgb,best_pitch,mpitch; |
3996 | 1076 radeon_vid_stop_video(); |
1077 left = config->src.x << 16; | |
1078 top = config->src.y << 16; | |
1079 src_h = config->src.h; | |
1080 src_w = config->src.w; | |
4571 | 1081 is_420 = is_rgb32 = is_rgb = 0; |
3996 | 1082 if(config->fourcc == IMGFMT_YV12 || |
1083 config->fourcc == IMGFMT_I420 || | |
1084 config->fourcc == IMGFMT_IYUV) is_420 = 1; | |
4416 | 1085 if(config->fourcc == IMGFMT_RGB32 || |
1086 config->fourcc == IMGFMT_BGR32) is_rgb32 = 1; | |
4571 | 1087 if(config->fourcc == IMGFMT_RGB32 || |
1088 config->fourcc == IMGFMT_BGR32 || | |
1089 config->fourcc == IMGFMT_RGB24 || | |
1090 config->fourcc == IMGFMT_BGR24 || | |
1091 config->fourcc == IMGFMT_RGB16 || | |
1092 config->fourcc == IMGFMT_BGR16 || | |
1093 config->fourcc == IMGFMT_RGB15 || | |
1094 config->fourcc == IMGFMT_BGR15) is_rgb = 1; | |
4456 | 1095 best_pitch = radeon_query_pitch(config->fourcc,&config->src.pitch); |
4415 | 1096 mpitch = best_pitch-1; |
3996 | 1097 switch(config->fourcc) |
1098 { | |
1099 /* 4:2:0 */ | |
1100 case IMGFMT_IYUV: | |
1101 case IMGFMT_YV12: | |
4415 | 1102 case IMGFMT_I420: pitch = (src_w + mpitch) & ~mpitch; |
4015 | 1103 config->dest.pitch.y = |
1104 config->dest.pitch.u = | |
4415 | 1105 config->dest.pitch.v = best_pitch; |
3996 | 1106 break; |
4416 | 1107 /* RGB 4:4:4:4 */ |
1108 case IMGFMT_RGB32: | |
1109 case IMGFMT_BGR32: pitch = (src_w*4 + mpitch) & ~mpitch; | |
1110 config->dest.pitch.y = | |
1111 config->dest.pitch.u = | |
1112 config->dest.pitch.v = best_pitch; | |
1113 break; | |
3996 | 1114 /* 4:2:2 */ |
4455 | 1115 default: /* RGB15, RGB16, YVYU, UYVY, YUY2 */ |
4415 | 1116 pitch = ((src_w*2) + mpitch) & ~mpitch; |
3996 | 1117 config->dest.pitch.y = |
1118 config->dest.pitch.u = | |
4415 | 1119 config->dest.pitch.v = best_pitch; |
3996 | 1120 break; |
1121 } | |
1122 dest_w = config->dest.w; | |
1123 dest_h = config->dest.h; | |
1124 if(radeon_is_dbl_scan()) dest_h *= 2; | |
1125 else | |
1126 if(radeon_is_interlace()) dest_h /= 2; | |
1127 besr.dest_bpp = radeon_vid_get_dbpp(); | |
1128 besr.fourcc = config->fourcc; | |
1129 besr.v_inc = (src_h << 20) / dest_h; | |
1130 h_inc = (src_w << 12) / dest_w; | |
1131 step_by = 1; | |
1132 while(h_inc >= (2 << 12)) { | |
1133 step_by++; | |
1134 h_inc >>= 1; | |
1135 } | |
1136 | |
1137 /* keep everything in 16.16 */ | |
4015 | 1138 besr.base_addr = INREG(DISPLAY_BASE_ADDR); |
4666 | 1139 config->offsets[0] = 0; |
4930 | 1140 for(i=1;i<besr.vid_nbufs;i++) |
1141 config->offsets[i] = config->offsets[i-1]+config->frame_size; | |
3996 | 1142 if(is_420) |
1143 { | |
1144 uint32_t d1line,d2line,d3line; | |
1145 d1line = top*pitch; | |
4666 | 1146 d2line = src_h*pitch+(d1line>>2); |
3996 | 1147 d3line = d2line+((src_h*pitch)>>2); |
1148 d1line += (left >> 16) & ~15; | |
1149 d2line += (left >> 17) & ~15; | |
1150 d3line += (left >> 17) & ~15; | |
1151 config->offset.y = d1line & VIF_BUF0_BASE_ADRS_MASK; | |
4015 | 1152 config->offset.v = d2line & VIF_BUF1_BASE_ADRS_MASK; |
1153 config->offset.u = d3line & VIF_BUF2_BASE_ADRS_MASK; | |
4930 | 1154 for(i=0;i<besr.vid_nbufs;i++) |
1155 { | |
1156 besr.vid_buf_base_adrs_y[i]=((radeon_overlay_off+config->offsets[i]+config->offset.y)&VIF_BUF0_BASE_ADRS_MASK); | |
1157 besr.vid_buf_base_adrs_v[i]=((radeon_overlay_off+config->offsets[i]+config->offset.v)&VIF_BUF1_BASE_ADRS_MASK)|VIF_BUF1_PITCH_SEL; | |
1158 besr.vid_buf_base_adrs_u[i]=((radeon_overlay_off+config->offsets[i]+config->offset.u)&VIF_BUF2_BASE_ADRS_MASK)|VIF_BUF2_PITCH_SEL; | |
1159 } | |
1160 config->offset.y = ((besr.vid_buf_base_adrs_y[0])&VIF_BUF0_BASE_ADRS_MASK) - radeon_overlay_off; | |
1161 config->offset.v = ((besr.vid_buf_base_adrs_v[0])&VIF_BUF1_BASE_ADRS_MASK) - radeon_overlay_off; | |
1162 config->offset.u = ((besr.vid_buf_base_adrs_u[0])&VIF_BUF2_BASE_ADRS_MASK) - radeon_overlay_off; | |
3996 | 1163 if(besr.fourcc == IMGFMT_I420 || besr.fourcc == IMGFMT_IYUV) |
1164 { | |
1165 uint32_t tmp; | |
1166 tmp = config->offset.u; | |
1167 config->offset.u = config->offset.v; | |
1168 config->offset.v = tmp; | |
1169 } | |
1170 } | |
1171 else | |
1172 { | |
1173 config->offset.y = config->offset.u = config->offset.v = ((left & ~7) << 1)&VIF_BUF0_BASE_ADRS_MASK; | |
4930 | 1174 for(i=0;i<besr.vid_nbufs;i++) |
1175 { | |
1176 besr.vid_buf_base_adrs_y[i] = | |
1177 besr.vid_buf_base_adrs_u[i] = | |
4932 | 1178 besr.vid_buf_base_adrs_v[i] = radeon_overlay_off + config->offsets[i] + config->offset.y; |
4930 | 1179 } |
3996 | 1180 } |
1181 | |
1182 tmp = (left & 0x0003ffff) + 0x00028000 + (h_inc << 3); | |
1183 besr.p1_h_accum_init = ((tmp << 4) & 0x000f8000) | | |
1184 ((tmp << 12) & 0xf0000000); | |
1185 | |
1186 tmp = ((left >> 1) & 0x0001ffff) + 0x00028000 + (h_inc << 2); | |
1187 besr.p23_h_accum_init = ((tmp << 4) & 0x000f8000) | | |
1188 ((tmp << 12) & 0x70000000); | |
1189 tmp = (top & 0x0000ffff) + 0x00018000; | |
1190 besr.p1_v_accum_init = ((tmp << 4) & OV0_P1_V_ACCUM_INIT_MASK) | |
1191 |(OV0_P1_MAX_LN_IN_PER_LN_OUT & 1); | |
1192 | |
1193 tmp = ((top >> 1) & 0x0000ffff) + 0x00018000; | |
1194 besr.p23_v_accum_init = is_420 ? ((tmp << 4) & OV0_P23_V_ACCUM_INIT_MASK) | |
1195 |(OV0_P23_MAX_LN_IN_PER_LN_OUT & 1) : 0; | |
1196 | |
1197 leftUV = (left >> 17) & 15; | |
1198 left = (left >> 16) & 15; | |
4571 | 1199 if(is_rgb && !is_rgb32) h_inc<<=1; |
4416 | 1200 if(is_rgb32) |
4571 | 1201 besr.h_inc = (h_inc >> 1) | ((h_inc >> 1) << 16); |
4416 | 1202 else |
1203 besr.h_inc = h_inc | ((h_inc >> 1) << 16); | |
3996 | 1204 besr.step_by = step_by | (step_by << 8); |
1205 besr.y_x_start = (config->dest.x+X_ADJUST) | (config->dest.y << 16); | |
1206 besr.y_x_end = (config->dest.x + dest_w+X_ADJUST) | ((config->dest.y + dest_h) << 16); | |
1207 besr.p1_blank_lines_at_top = P1_BLNK_LN_AT_TOP_M1_MASK|((src_h-1)<<16); | |
1208 if(is_420) | |
1209 { | |
1210 src_h = (src_h + 1) >> 1; | |
1211 besr.p23_blank_lines_at_top = P23_BLNK_LN_AT_TOP_M1_MASK|((src_h-1)<<16); | |
1212 } | |
1213 else besr.p23_blank_lines_at_top = 0; | |
1214 besr.vid_buf_pitch0_value = pitch; | |
1215 besr.vid_buf_pitch1_value = is_420 ? pitch>>1 : pitch; | |
1216 besr.p1_x_start_end = (src_w+left-1)|(left<<16); | |
1217 src_w>>=1; | |
1218 besr.p2_x_start_end = (src_w+left-1)|(leftUV<<16); | |
1219 besr.p3_x_start_end = besr.p2_x_start_end; | |
4869 | 1220 |
1221 | |
3996 | 1222 return 0; |
1223 } | |
1224 | |
4009 | 1225 static void radeon_compute_framesize(vidix_playback_t *info) |
1226 { | |
4666 | 1227 unsigned pitch,awidth,dbpp; |
4456 | 1228 pitch = radeon_query_pitch(info->fourcc,&info->src.pitch); |
4666 | 1229 dbpp = radeon_vid_get_dbpp(); |
4033 | 1230 switch(info->fourcc) |
1231 { | |
1232 case IMGFMT_I420: | |
1233 case IMGFMT_YV12: | |
1234 case IMGFMT_IYUV: | |
4666 | 1235 awidth = (info->src.w + (pitch-1)) & ~(pitch-1); |
1236 info->frame_size = (awidth*(info->src.h+info->src.h/2)+dbpp-1)/dbpp; | |
4033 | 1237 break; |
4429 | 1238 case IMGFMT_RGB32: |
1239 case IMGFMT_BGR32: | |
4666 | 1240 awidth = (info->src.w*4 + (pitch-1)) & ~(pitch-1); |
1241 info->frame_size = ((awidth*info->src.h)+dbpp-1)/dbpp; | |
4429 | 1242 break; |
1243 /* YUY2 YVYU, RGB15, RGB16 */ | |
4666 | 1244 default: |
1245 awidth = (info->src.w*2 + (pitch-1)) & ~(pitch-1); | |
1246 info->frame_size = ((awidth*info->src.h)+dbpp-1)/dbpp; | |
4033 | 1247 break; |
1248 } | |
4666 | 1249 info->frame_size *= dbpp; |
4009 | 1250 } |
1251 | |
3996 | 1252 int vixConfigPlayback(vidix_playback_t *info) |
1253 { | |
4930 | 1254 unsigned rgb_size; |
3996 | 1255 if(!is_supported_fourcc(info->fourcc)) return ENOSYS; |
4930 | 1256 if(info->num_frames>=VID_PLAY_MAXFRAMES) info->num_frames=VID_PLAY_MAXFRAMES-1; |
4666 | 1257 if(info->num_frames==1) besr.double_buff=0; |
1258 else besr.double_buff=1; | |
4009 | 1259 radeon_compute_framesize(info); |
4930 | 1260 |
1261 rgb_size = radeon_get_xres()*radeon_get_yres()*radeon_vid_get_dbpp(); | |
1262 for(;info->num_frames>0; info->num_frames--) | |
1263 { | |
1264 radeon_overlay_off = radeon_ram_size - info->frame_size*info->num_frames; | |
1265 radeon_overlay_off &= 0xffff0000; | |
1266 if(radeon_overlay_off >= (int)rgb_size ) break; | |
1267 } | |
1268 if(info->num_frames <= 3) | |
1269 for(;info->num_frames>0; info->num_frames--) | |
1270 { | |
1271 radeon_overlay_off = radeon_ram_size - info->frame_size*info->num_frames; | |
1272 radeon_overlay_off &= 0xffff0000; | |
1273 if(radeon_overlay_off > 0) break; | |
1274 } | |
1275 if(info->num_frames <= 0) return EINVAL; | |
1276 besr.vid_nbufs = info->num_frames; | |
1277 info->dga_addr = (char *)radeon_mem_base + radeon_overlay_off; | |
3996 | 1278 radeon_vid_init_video(info); |
1279 return 0; | |
1280 } | |
1281 | |
1282 int vixPlaybackOn( void ) | |
1283 { | |
1284 radeon_vid_display_video(); | |
1285 return 0; | |
1286 } | |
1287 | |
1288 int vixPlaybackOff( void ) | |
1289 { | |
1290 radeon_vid_stop_video(); | |
1291 return 0; | |
1292 } | |
1293 | |
4033 | 1294 int vixPlaybackFrameSelect(unsigned frame) |
3996 | 1295 { |
4412 | 1296 uint32_t off[6]; |
4930 | 1297 int prev_frame= (frame-1+besr.vid_nbufs) % besr.vid_nbufs; |
4412 | 1298 /* |
1299 buf3-5 always should point onto second buffer for better | |
1300 deinterlacing and TV-in | |
1301 */ | |
4666 | 1302 if(!besr.double_buff) return 0; |
4930 | 1303 if(frame > besr.vid_nbufs) frame = besr.vid_nbufs-1; |
1304 if(prev_frame > (int)besr.vid_nbufs) prev_frame = besr.vid_nbufs-1; | |
1305 off[0] = besr.vid_buf_base_adrs_y[frame]; | |
1306 off[1] = besr.vid_buf_base_adrs_v[frame]; | |
1307 off[2] = besr.vid_buf_base_adrs_u[frame]; | |
1308 off[3] = besr.vid_buf_base_adrs_y[prev_frame]; | |
1309 off[4] = besr.vid_buf_base_adrs_v[prev_frame]; | |
1310 off[5] = besr.vid_buf_base_adrs_u[prev_frame]; | |
4855 | 1311 radeon_fifo_wait(8); |
3996 | 1312 OUTREG(OV0_REG_LOAD_CNTL, REG_LD_CTL_LOCK); |
4666 | 1313 radeon_engine_idle(); |
3996 | 1314 while(!(INREG(OV0_REG_LOAD_CNTL)®_LD_CTL_LOCK_READBACK)); |
4412 | 1315 OUTREG(OV0_VID_BUF0_BASE_ADRS, off[0]); |
1316 OUTREG(OV0_VID_BUF1_BASE_ADRS, off[1]); | |
1317 OUTREG(OV0_VID_BUF2_BASE_ADRS, off[2]); | |
4413 | 1318 OUTREG(OV0_VID_BUF3_BASE_ADRS, off[3]); |
1319 OUTREG(OV0_VID_BUF4_BASE_ADRS, off[4]); | |
1320 OUTREG(OV0_VID_BUF5_BASE_ADRS, off[5]); | |
3996 | 1321 OUTREG(OV0_REG_LOAD_CNTL, 0); |
4930 | 1322 if(besr.vid_nbufs == 2) radeon_wait_vsync(); |
4030 | 1323 if(__verbose > 1) radeon_vid_dump_regs(); |
3996 | 1324 return 0; |
1325 } | |
1326 | |
4319
2d64382e8dcf
intense->intensity + capability extension + fixing R200 color correction bug
nick
parents:
4286
diff
changeset
|
1327 vidix_video_eq_t equal = |
2d64382e8dcf
intense->intensity + capability extension + fixing R200 color correction bug
nick
parents:
4286
diff
changeset
|
1328 { |
2d64382e8dcf
intense->intensity + capability extension + fixing R200 color correction bug
nick
parents:
4286
diff
changeset
|
1329 VEQ_CAP_BRIGHTNESS | VEQ_CAP_SATURATION |
2d64382e8dcf
intense->intensity + capability extension + fixing R200 color correction bug
nick
parents:
4286
diff
changeset
|
1330 #ifndef RAGE128 |
2d64382e8dcf
intense->intensity + capability extension + fixing R200 color correction bug
nick
parents:
4286
diff
changeset
|
1331 | VEQ_CAP_CONTRAST | VEQ_CAP_HUE | VEQ_CAP_RGB_INTENSITY |
2d64382e8dcf
intense->intensity + capability extension + fixing R200 color correction bug
nick
parents:
4286
diff
changeset
|
1332 #endif |
2d64382e8dcf
intense->intensity + capability extension + fixing R200 color correction bug
nick
parents:
4286
diff
changeset
|
1333 , |
2d64382e8dcf
intense->intensity + capability extension + fixing R200 color correction bug
nick
parents:
4286
diff
changeset
|
1334 0, 0, 0, 0, 0, 0, 0, 0 }; |
3996 | 1335 |
1336 int vixPlaybackGetEq( vidix_video_eq_t * eq) | |
1337 { | |
1338 memcpy(eq,&equal,sizeof(vidix_video_eq_t)); | |
1339 return 0; | |
1340 } | |
1341 | |
4229 | 1342 #ifndef RAGE128 |
1343 #define RTFSaturation(a) (1.0 + ((a)*1.0)/1000.0) | |
1344 #define RTFBrightness(a) (((a)*1.0)/2000.0) | |
4319
2d64382e8dcf
intense->intensity + capability extension + fixing R200 color correction bug
nick
parents:
4286
diff
changeset
|
1345 #define RTFIntensity(a) (((a)*1.0)/2000.0) |
4229 | 1346 #define RTFContrast(a) (1.0 + ((a)*1.0)/1000.0) |
1347 #define RTFHue(a) (((a)*3.1416)/1000.0) | |
1348 #define RTFCheckParam(a) {if((a)<-1000) (a)=-1000; if((a)>1000) (a)=1000;} | |
1349 #endif | |
1350 | |
3996 | 1351 int vixPlaybackSetEq( const vidix_video_eq_t * eq) |
1352 { | |
1353 #ifdef RAGE128 | |
1354 int br,sat; | |
4229 | 1355 #else |
1356 int itu_space; | |
3996 | 1357 #endif |
4319
2d64382e8dcf
intense->intensity + capability extension + fixing R200 color correction bug
nick
parents:
4286
diff
changeset
|
1358 if(eq->cap & VEQ_CAP_BRIGHTNESS) equal.brightness = eq->brightness; |
2d64382e8dcf
intense->intensity + capability extension + fixing R200 color correction bug
nick
parents:
4286
diff
changeset
|
1359 if(eq->cap & VEQ_CAP_CONTRAST) equal.contrast = eq->contrast; |
2d64382e8dcf
intense->intensity + capability extension + fixing R200 color correction bug
nick
parents:
4286
diff
changeset
|
1360 if(eq->cap & VEQ_CAP_SATURATION) equal.saturation = eq->saturation; |
2d64382e8dcf
intense->intensity + capability extension + fixing R200 color correction bug
nick
parents:
4286
diff
changeset
|
1361 if(eq->cap & VEQ_CAP_HUE) equal.hue = eq->hue; |
2d64382e8dcf
intense->intensity + capability extension + fixing R200 color correction bug
nick
parents:
4286
diff
changeset
|
1362 if(eq->cap & VEQ_CAP_RGB_INTENSITY) |
2d64382e8dcf
intense->intensity + capability extension + fixing R200 color correction bug
nick
parents:
4286
diff
changeset
|
1363 { |
2d64382e8dcf
intense->intensity + capability extension + fixing R200 color correction bug
nick
parents:
4286
diff
changeset
|
1364 equal.red_intensity = eq->red_intensity; |
2d64382e8dcf
intense->intensity + capability extension + fixing R200 color correction bug
nick
parents:
4286
diff
changeset
|
1365 equal.green_intensity = eq->green_intensity; |
2d64382e8dcf
intense->intensity + capability extension + fixing R200 color correction bug
nick
parents:
4286
diff
changeset
|
1366 equal.blue_intensity = eq->blue_intensity; |
2d64382e8dcf
intense->intensity + capability extension + fixing R200 color correction bug
nick
parents:
4286
diff
changeset
|
1367 } |
2d64382e8dcf
intense->intensity + capability extension + fixing R200 color correction bug
nick
parents:
4286
diff
changeset
|
1368 equal.flags = eq->flags; |
3996 | 1369 #ifdef RAGE128 |
1370 br = equal.brightness * 64 / 1000; | |
4229 | 1371 if(br < -64) br = -64; if(br > 63) br = 63; |
4230 | 1372 sat = (equal.saturation + 1000) * 16 / 1000; |
4229 | 1373 if(sat < 0) sat = 0; if(sat > 31) sat = 31; |
3996 | 1374 OUTREG(OV0_COLOUR_CNTL, (br & 0x7f) | (sat << 8) | (sat << 16)); |
1375 #else | |
4229 | 1376 itu_space = equal.flags == VEQ_FLG_ITU_R_BT_709 ? 1 : 0; |
1377 RTFCheckParam(equal.brightness); | |
1378 RTFCheckParam(equal.saturation); | |
1379 RTFCheckParam(equal.contrast); | |
1380 RTFCheckParam(equal.hue); | |
4319
2d64382e8dcf
intense->intensity + capability extension + fixing R200 color correction bug
nick
parents:
4286
diff
changeset
|
1381 RTFCheckParam(equal.red_intensity); |
2d64382e8dcf
intense->intensity + capability extension + fixing R200 color correction bug
nick
parents:
4286
diff
changeset
|
1382 RTFCheckParam(equal.green_intensity); |
2d64382e8dcf
intense->intensity + capability extension + fixing R200 color correction bug
nick
parents:
4286
diff
changeset
|
1383 RTFCheckParam(equal.blue_intensity); |
4229 | 1384 radeon_set_transform(RTFBrightness(equal.brightness), |
1385 RTFContrast(equal.contrast), | |
1386 RTFSaturation(equal.saturation), | |
1387 RTFHue(equal.hue), | |
4319
2d64382e8dcf
intense->intensity + capability extension + fixing R200 color correction bug
nick
parents:
4286
diff
changeset
|
1388 RTFIntensity(equal.red_intensity), |
2d64382e8dcf
intense->intensity + capability extension + fixing R200 color correction bug
nick
parents:
4286
diff
changeset
|
1389 RTFIntensity(equal.green_intensity), |
2d64382e8dcf
intense->intensity + capability extension + fixing R200 color correction bug
nick
parents:
4286
diff
changeset
|
1390 RTFIntensity(equal.blue_intensity), |
4229 | 1391 itu_space); |
3996 | 1392 #endif |
1393 return 0; | |
1394 } | |
1395 | |
4611 | 1396 int vixPlaybackSetDeint( const vidix_deinterlace_t * info) |
1397 { | |
1398 unsigned sflg; | |
1399 switch(info->flags) | |
1400 { | |
1401 default: | |
1402 case CFG_NON_INTERLACED: | |
1403 besr.deinterlace_on = 0; | |
1404 break; | |
1405 case CFG_EVEN_ODD_INTERLACING: | |
1406 case CFG_INTERLACED: | |
1407 besr.deinterlace_on = 1; | |
1408 besr.deinterlace_pattern = 0x900AAAAA; | |
1409 break; | |
1410 case CFG_ODD_EVEN_INTERLACING: | |
1411 besr.deinterlace_on = 1; | |
1412 besr.deinterlace_pattern = 0x00055555; | |
1413 break; | |
1414 case CFG_UNIQUE_INTERLACING: | |
1415 besr.deinterlace_on = 1; | |
1416 besr.deinterlace_pattern = info->deinterlace_pattern; | |
1417 break; | |
1418 } | |
1419 OUTREG(OV0_REG_LOAD_CNTL, REG_LD_CTL_LOCK); | |
1420 radeon_engine_idle(); | |
1421 while(!(INREG(OV0_REG_LOAD_CNTL)®_LD_CTL_LOCK_READBACK)); | |
1422 radeon_fifo_wait(15); | |
1423 sflg = INREG(OV0_SCALE_CNTL); | |
1424 if(besr.deinterlace_on) | |
1425 { | |
1426 OUTREG(OV0_SCALE_CNTL,sflg | SCALER_ADAPTIVE_DEINT); | |
1427 OUTREG(OV0_DEINTERLACE_PATTERN,besr.deinterlace_pattern); | |
1428 } | |
1429 else OUTREG(OV0_SCALE_CNTL,sflg & (~SCALER_ADAPTIVE_DEINT)); | |
1430 OUTREG(OV0_REG_LOAD_CNTL, 0); | |
1431 return 0; | |
1432 } | |
1433 | |
1434 int vixPlaybackGetDeint( vidix_deinterlace_t * info) | |
1435 { | |
1436 if(!besr.deinterlace_on) info->flags = CFG_NON_INTERLACED; | |
1437 else | |
1438 { | |
1439 info->flags = CFG_UNIQUE_INTERLACING; | |
1440 info->deinterlace_pattern = besr.deinterlace_pattern; | |
1441 } | |
1442 return 0; | |
1443 } | |
4869 | 1444 |
1445 | |
1446 /* Graphic keys */ | |
1447 static vidix_grkey_t radeon_grkey; | |
1448 | |
1449 static void set_gr_key( void ) | |
1450 { | |
1451 if(radeon_grkey.ckey.op == CKEY_TRUE) | |
1452 { | |
1453 besr.ckey_on=1; | |
1454 | |
1455 switch(radeon_vid_get_dbpp()) | |
1456 { | |
1457 case 15: | |
1458 besr.graphics_key_clr= | |
1459 ((radeon_grkey.ckey.blue &0xF8)>>3) | |
1460 | ((radeon_grkey.ckey.green&0xF8)<<2) | |
1461 | ((radeon_grkey.ckey.red &0xF8)<<7); | |
1462 break; | |
1463 case 16: | |
1464 besr.graphics_key_clr= | |
1465 ((radeon_grkey.ckey.blue &0xF8)>>3) | |
1466 | ((radeon_grkey.ckey.green&0xFC)<<3) | |
1467 | ((radeon_grkey.ckey.red &0xF8)<<8); | |
1468 break; | |
1469 case 24: | |
1470 besr.graphics_key_clr= | |
1471 ((radeon_grkey.ckey.blue &0xFF)) | |
1472 | ((radeon_grkey.ckey.green&0xFF)<<8) | |
1473 | ((radeon_grkey.ckey.red &0xFF)<<16); | |
1474 break; | |
1475 case 32: | |
1476 besr.graphics_key_clr= | |
1477 ((radeon_grkey.ckey.blue &0xFF)) | |
1478 | ((radeon_grkey.ckey.green&0xFF)<<8) | |
1479 | ((radeon_grkey.ckey.red &0xFF)<<16); | |
1480 break; | |
1481 default: | |
1482 besr.ckey_on=0; | |
1483 besr.graphics_key_msk=0; | |
1484 besr.graphics_key_clr=0; | |
1485 } | |
5044
43dc579db3d1
Fixed color key definitions. Waiting for new bugreports ;)
nick
parents:
5041
diff
changeset
|
1486 besr.graphics_key_msk = besr.graphics_key_clr; |
43dc579db3d1
Fixed color key definitions. Waiting for new bugreports ;)
nick
parents:
5041
diff
changeset
|
1487 besr.ckey_cntl = VIDEO_KEY_FN_TRUE|GRAPHIC_KEY_FN_EQ|CMP_MIX_AND; |
4869 | 1488 } |
1489 else | |
1490 { | |
1491 besr.ckey_on=0; | |
1492 besr.graphics_key_msk=0; | |
1493 besr.graphics_key_clr=0; | |
5044
43dc579db3d1
Fixed color key definitions. Waiting for new bugreports ;)
nick
parents:
5041
diff
changeset
|
1494 besr.ckey_cntl = VIDEO_KEY_FN_TRUE|GRAPHIC_KEY_FN_TRUE|CMP_MIX_AND; |
4869 | 1495 } |
5044
43dc579db3d1
Fixed color key definitions. Waiting for new bugreports ;)
nick
parents:
5041
diff
changeset
|
1496 radeon_fifo_wait(3); |
4869 | 1497 OUTREG(OV0_GRAPHICS_KEY_MSK, besr.graphics_key_msk); |
1498 OUTREG(OV0_GRAPHICS_KEY_CLR, besr.graphics_key_clr); | |
1499 OUTREG(OV0_KEY_CNTL,besr.ckey_cntl); | |
1500 } | |
1501 | |
1502 int vixGetGrKeys(vidix_grkey_t *grkey) | |
1503 { | |
1504 memcpy(grkey, &radeon_grkey, sizeof(vidix_grkey_t)); | |
1505 return(0); | |
1506 } | |
1507 | |
1508 int vixSetGrKeys(const vidix_grkey_t *grkey) | |
1509 { | |
1510 memcpy(&radeon_grkey, grkey, sizeof(vidix_grkey_t)); | |
1511 set_gr_key(); | |
1512 return(0); | |
1513 } |