Mercurial > mplayer.hg
comparison drivers/radeon/radeon_vid.c @ 2925:49bcb6176569
BES resisters now are really changed!
author | nick |
---|---|
date | Fri, 16 Nov 2001 18:44:01 +0000 |
parents | 3dd4e8a45d0d |
children | ff8389ac4eb7 |
comparison
equal
deleted
inserted
replaced
2924:8350b8c25c02 | 2925:49bcb6176569 |
---|---|
146 { OV0_KEY_CNTL, 0 }, | 146 { OV0_KEY_CNTL, 0 }, |
147 { OV0_TEST, 0 } | 147 { OV0_TEST, 0 } |
148 }; | 148 }; |
149 | 149 |
150 static uint32_t radeon_vid_in_use = 0; | 150 static uint32_t radeon_vid_in_use = 0; |
151 static uint32_t vid_src_ready = 0; | |
152 static uint32_t vid_overlay_on = 0; | |
153 | 151 |
154 static uint8_t *radeon_mmio_base = 0; | 152 static uint8_t *radeon_mmio_base = 0; |
155 static uint32_t radeon_mem_base = 0; | 153 static uint32_t radeon_mem_base = 0; |
156 #define RADEON_SRC_BASE 0ULL /* this driver uses all video memory */ | 154 #define RADEON_SRC_BASE 2000000ULL /* this driver uses all video memory */ |
157 | 155 |
158 static uint32_t radeon_ram_size = 0; | 156 static uint32_t radeon_ram_size = 0; |
159 | 157 |
160 //static struct video_window radeon_win; | 158 //static struct video_window radeon_win; |
161 static mga_vid_config_t radeon_config; | 159 static mga_vid_config_t radeon_config; |
191 OUTREG(vregs[i].name,vregs[i].value); | 189 OUTREG(vregs[i].name,vregs[i].value); |
192 } | 190 } |
193 | 191 |
194 static void radeon_vid_stop_video( void ) | 192 static void radeon_vid_stop_video( void ) |
195 { | 193 { |
196 if(vid_src_ready == 1) | |
197 { | |
198 OUTREG(OV0_SCALE_CNTL, SCALER_SOFT_RESET); | 194 OUTREG(OV0_SCALE_CNTL, SCALER_SOFT_RESET); |
199 OUTREG(OV0_EXCLUSIVE_HORZ, 0); | 195 OUTREG(OV0_EXCLUSIVE_HORZ, 0); |
200 OUTREG(OV0_AUTO_FLIP_CNTL, 0); /* maybe */ | 196 OUTREG(OV0_AUTO_FLIP_CNTL, 0); /* maybe */ |
201 OUTREG(OV0_FILTER_CNTL, 0x0000000f); | 197 OUTREG(OV0_FILTER_CNTL, 0x0000000f); |
202 /* | 198 /* |
206 OUTREG(OV0_GRAPHICS_KEY_MSK, (1 << depth) - 1); | 202 OUTREG(OV0_GRAPHICS_KEY_MSK, (1 << depth) - 1); |
207 OUTREG(OV0_GRAPHICS_KEY_CLR, colorKey); | 203 OUTREG(OV0_GRAPHICS_KEY_CLR, colorKey); |
208 */ | 204 */ |
209 OUTREG(OV0_KEY_CNTL, GRAPHIC_KEY_FN_NE); | 205 OUTREG(OV0_KEY_CNTL, GRAPHIC_KEY_FN_NE); |
210 OUTREG(OV0_TEST, 0); | 206 OUTREG(OV0_TEST, 0); |
211 } | |
212 vid_src_ready = 0; | |
213 } | 207 } |
214 | 208 |
215 static void radeon_vid_display_video( void ) | 209 static void radeon_vid_display_video( void ) |
216 { | 210 { |
217 int bes_flags; | 211 int bes_flags; |
212 RTRACE("radeon_vid: OV0: v_inc=%x h_inc=%x step_by=%x\n",besr.v_inc,besr.h_inc,besr.step_by); | |
213 RTRACE("radeon_vid: OV0: vid_buf0_basey=%x\n",besr.vid_buf0_base_adrs); | |
214 RTRACE("radeon_vid: OV0: y_x_start=%x y_x_end=%x blank_at_top=%x pitch0_value=%x\n" | |
215 ,besr.y_x_start,besr.y_x_end,besr.p1_blank_lines_at_top,besr.vid_buf_pitch0_value); | |
218 OUTREG(OV0_REG_LOAD_CNTL, REG_LD_CTL_LOCK); | 216 OUTREG(OV0_REG_LOAD_CNTL, REG_LD_CTL_LOCK); |
219 while(!(INREG(OV0_REG_LOAD_CNTL)®_LD_CTL_LOCK_READBACK)); | 217 while(!(INREG(OV0_REG_LOAD_CNTL)®_LD_CTL_LOCK_READBACK)); |
220 | 218 |
221 OUTREG(OV0_AUTO_FLIP_CNTL,OV0_AUTO_FLIP_CNTL_SOFT_BUF_ODD); | 219 OUTREG(OV0_AUTO_FLIP_CNTL,OV0_AUTO_FLIP_CNTL_SOFT_BUF_ODD); |
222 | 220 |
259 case IMGFMT_RGB24: | 257 case IMGFMT_RGB24: |
260 case IMGFMT_BGR24: bes_flags |= SCALER_SOURCE_24BPP; break; | 258 case IMGFMT_BGR24: bes_flags |= SCALER_SOURCE_24BPP; break; |
261 case IMGFMT_RGB32: | 259 case IMGFMT_RGB32: |
262 case IMGFMT_BGR32: bes_flags |= SCALER_SOURCE_32BPP; break; | 260 case IMGFMT_BGR32: bes_flags |= SCALER_SOURCE_32BPP; break; |
263 | 261 |
262 case IMGFMT_UYVY: bes_flags |= SCALER_SOURCE_YVYU422; break; | |
264 case IMGFMT_YVU9: bes_flags |= SCALER_SOURCE_YUV9; break; | 263 case IMGFMT_YVU9: bes_flags |= SCALER_SOURCE_YUV9; break; |
265 case IMGFMT_IYUV: bes_flags |= SCALER_SOURCE_YUV12; break; | 264 case IMGFMT_IYUV: bes_flags |= SCALER_SOURCE_YUV12; break; |
266 case IMGFMT_UYVY: bes_flags |= SCALER_SOURCE_YVYU422; break; | |
267 | 265 |
268 case IMGFMT_YV12: | 266 case IMGFMT_YV12: |
269 case IMGFMT_I420: | 267 case IMGFMT_I420: |
270 case IMGFMT_YUY2: | 268 case IMGFMT_YUY2: |
271 default: bes_flags |= SCALER_SOURCE_VYUY422; break; | 269 default: bes_flags |= SCALER_SOURCE_VYUY422; break; |
284 OUTREG(OV0_REG_LOAD_CNTL, 0); | 282 OUTREG(OV0_REG_LOAD_CNTL, 0); |
285 } | 283 } |
286 | 284 |
287 static void radeon_vid_start_video( void ) | 285 static void radeon_vid_start_video( void ) |
288 { | 286 { |
289 if(vid_src_ready == 0) radeon_vid_display_video(); | 287 radeon_vid_display_video(); |
290 vid_src_ready = 1; | |
291 } | 288 } |
292 | 289 |
293 #define XXX_SRC_X 0 | 290 #define XXX_SRC_X 0 |
294 #define XXX_SRC_Y 0 | 291 #define XXX_SRC_Y 0 |
295 | 292 |
296 #define XXX_WIDTH config->dest_width | 293 #define XXX_WIDTH config->dest_width |
297 #define XXX_HEIGHT config->dest_height | 294 #define XXX_HEIGHT config->dest_height |
295 | |
296 #define XXX_DRW_W (config->dest_width) | |
297 #define XXX_DRW_H (config->dest_height) | |
298 | 298 |
299 static int radeon_vid_init_video( mga_vid_config_t *config ) | 299 static int radeon_vid_init_video( mga_vid_config_t *config ) |
300 { | 300 { |
301 uint32_t tmp,left,src_w,pitch; | 301 uint32_t tmp,left,src_w,pitch; |
302 | 302 |
338 } | 338 } |
339 | 339 |
340 pitch = ((XXX_WIDTH << 1) + 15) & ~15; | 340 pitch = ((XXX_WIDTH << 1) + 15) & ~15; |
341 besr.fourcc = config->format; | 341 besr.fourcc = config->format; |
342 | 342 |
343 besr.v_inc = (config->src_height << 20) / (config->dest_height); | 343 besr.v_inc = (config->src_height << 20) / XXX_DRW_H; |
344 besr.h_inc = (config->src_width << 12) / (config->dest_width); | 344 besr.h_inc = (config->src_width << 12) / XXX_DRW_W; |
345 besr.step_by = 1; | 345 besr.step_by = 1; |
346 | 346 |
347 while(besr.h_inc >= (2 << 12)) { | 347 while(besr.h_inc >= (2 << 12)) { |
348 besr.step_by++; | 348 besr.step_by++; |
349 besr.h_inc >>= 1; | 349 besr.h_inc >>= 1; |
350 } | 350 } |
351 | 351 |
352 RTRACE("radeon_vid: BES: v_inc=%x h_inc=%x step_by=%x\n",besr.v_inc,besr.h_inc,besr.step_by); | |
353 /* keep everything in 16.16 */ | 352 /* keep everything in 16.16 */ |
354 | 353 |
355 besr.vid_buf0_base_adrs = RADEON_SRC_BASE; /* I guess that offset 0 is o'k */ | 354 besr.vid_buf0_base_adrs = RADEON_SRC_BASE; /* I guess that offset 0 is o'k */ |
356 /* besr.vid_buf0_base_adrs += (((XXX_SRC_X >> 16) & ~7) << 1)&0xfffffff0;*/ | 355 besr.vid_buf0_base_adrs += (((XXX_SRC_X >> 16) & ~7) << 1)&0xfffffff0; |
357 RTRACE("radeon_vid: BES: vid_buf0_basey=%x\n",besr.vid_buf0_base_adrs); | |
358 besr.vid_buf1_base_adrs = besr.vid_buf0_base_adrs + config->frame_size; | 356 besr.vid_buf1_base_adrs = besr.vid_buf0_base_adrs + config->frame_size; |
359 besr.vid_buf2_base_adrs = besr.vid_buf0_base_adrs; | 357 besr.vid_buf2_base_adrs = besr.vid_buf0_base_adrs; |
360 besr.vid_buf3_base_adrs = besr.vid_buf0_base_adrs + config->frame_size; | 358 besr.vid_buf3_base_adrs = besr.vid_buf0_base_adrs + config->frame_size; |
361 besr.vid_buf4_base_adrs = besr.vid_buf0_base_adrs; | 359 besr.vid_buf4_base_adrs = besr.vid_buf0_base_adrs; |
362 besr.vid_buf5_base_adrs = besr.vid_buf0_base_adrs + config->frame_size; | 360 besr.vid_buf5_base_adrs = besr.vid_buf0_base_adrs + config->frame_size; |
370 ((tmp << 12) & 0x70000000); | 368 ((tmp << 12) & 0x70000000); |
371 | 369 |
372 tmp = (XXX_SRC_Y & 0x0000ffff) + 0x00018000; | 370 tmp = (XXX_SRC_Y & 0x0000ffff) + 0x00018000; |
373 besr.p1_v_accum_init = ((tmp << 4) & 0x03ff8000) | 0x00000001; | 371 besr.p1_v_accum_init = ((tmp << 4) & 0x03ff8000) | 0x00000001; |
374 | 372 |
375 left = 0; /*(XXX_SRC_X >> 16) & 7;*/ | 373 left = (XXX_SRC_X >> 16) & 7; |
376 besr.h_inc |= ((besr.h_inc/* >> 1*/) << 16); | 374 besr.h_inc |= ((besr.h_inc >> 1) << 16); |
377 besr.step_by |= (besr.step_by << 8); | 375 besr.step_by |= (besr.step_by << 8); |
378 besr.y_x_start = (config->x_org + 8) | (config->y_org << 16); | 376 besr.y_x_start = (config->x_org+8) | (config->y_org << 16); |
379 besr.y_x_end = ((config->x_org + config->dest_width) + 8) | ((config->y_org + config->dest_height) << 16); | 377 besr.y_x_end = (config->x_org + config->dest_width+8) | ((config->y_org + config->dest_height) << 16); |
380 besr.p1_blank_lines_at_top = 0x00000fff | ((config->src_height - 1) << 16); | 378 besr.p1_blank_lines_at_top = 0x00000fff | ((config->src_height - 1) << 16); |
381 besr.vid_buf_pitch0_value = pitch; | 379 besr.vid_buf_pitch0_value = pitch; |
380 RTRACE("radeon_vid: BES: v_inc=%x h_inc=%x step_by=%x\n",besr.v_inc,besr.h_inc,besr.step_by); | |
381 RTRACE("radeon_vid: BES: vid_buf0_basey=%x\n",besr.vid_buf0_base_adrs); | |
382 RTRACE("radeon_vid: BES: y_x_start=%x y_x_end=%x blank_at_top=%x pitch0_value=%x\n" | 382 RTRACE("radeon_vid: BES: y_x_start=%x y_x_end=%x blank_at_top=%x pitch0_value=%x\n" |
383 ,besr.y_x_start,besr.y_x_end,besr.p1_blank_lines_at_top,besr.vid_buf_pitch0_value); | 383 ,besr.y_x_start,besr.y_x_end,besr.p1_blank_lines_at_top,besr.vid_buf_pitch0_value); |
384 besr.p1_x_start_end = (config->src_width + left - 1) | (left << 16); | 384 besr.p1_x_start_end = (config->src_width + left - 1) | (left << 16); |
385 left >>= 1; src_w=config->src_width >> 1; | 385 left >>= 1; src_w=config->src_width >> 1; |
386 besr.p2_x_start_end = (src_w + left - 1) | (left << 16); | 386 besr.p2_x_start_end = (src_w + left - 1) | (left << 16); |
387 besr.p3_x_start_end = besr.p2_x_start_end; | 387 besr.p3_x_start_end = besr.p2_x_start_end; |
388 return 0; | 388 return 0; |
451 return radeon_vid_init_video(&radeon_config); | 451 return radeon_vid_init_video(&radeon_config); |
452 break; | 452 break; |
453 | 453 |
454 case MGA_VID_ON: | 454 case MGA_VID_ON: |
455 RTRACE( "radeon_vid: Video ON (ioctl)\n"); | 455 RTRACE( "radeon_vid: Video ON (ioctl)\n"); |
456 vid_src_ready = 1; | 456 radeon_vid_start_video(); |
457 if(vid_overlay_on) radeon_vid_start_video(); | |
458 break; | 457 break; |
459 | 458 |
460 case MGA_VID_OFF: | 459 case MGA_VID_OFF: |
461 RTRACE( "radeon_vid: Video OFF (ioctl)\n"); | 460 RTRACE( "radeon_vid: Video OFF (ioctl)\n"); |
462 radeon_vid_stop_video(); | 461 radeon_vid_stop_video(); |
551 } | 550 } |
552 | 551 |
553 static int radeon_vid_release(struct inode *inode, struct file *file) | 552 static int radeon_vid_release(struct inode *inode, struct file *file) |
554 { | 553 { |
555 //Close the window just in case | 554 //Close the window just in case |
556 vid_src_ready = 0; | |
557 radeon_vid_in_use = 0; | 555 radeon_vid_in_use = 0; |
558 radeon_vid_stop_video(); | 556 radeon_vid_stop_video(); |
559 | 557 |
560 MOD_DEC_USE_COUNT; | 558 MOD_DEC_USE_COUNT; |
561 return 0; | 559 return 0; |