comparison vidix/radeon_vid.c @ 37107:3c5c93a30fb7

vidix: Replace printf with mp_msg - Make MPlayer more quiet when requested (e.g. when using -really-quiet) - Additionally change some minor capitalization and "bla:" to "[bla]" Patch-by: Arne Bochem >arneb.mp ccan de< Patch-also-OKed-by: Reimar
author al
date Sat, 17 May 2014 01:38:00 +0000
parents cc50b327cffa
children
comparison
equal deleted inserted replaced
37106:1b9907dfe2f4 37107:3c5c93a30fb7
38 #include "pci_names.h" 38 #include "pci_names.h"
39 #include "vidix.h" 39 #include "vidix.h"
40 #include "fourcc.h" 40 #include "fourcc.h"
41 #include "dha.h" 41 #include "dha.h"
42 #include "radeon.h" 42 #include "radeon.h"
43 #include "mp_msg.h"
43 44
44 #if !defined(RAGE128) && defined(CONFIG_X11) 45 #if !defined(RAGE128) && defined(CONFIG_X11)
45 #include <X11/Xlib.h> 46 #include <X11/Xlib.h>
46 static uint32_t firegl_shift = 0; 47 static uint32_t firegl_shift = 0;
47 #endif 48 #endif
55 #ifndef RADEON 56 #ifndef RADEON
56 #define RADEON 57 #define RADEON
57 #endif 58 #endif
58 #endif 59 #endif
59 60
60 #define RADEON_ASSERT(msg) printf(RADEON_MSG"################# FATAL:"msg); 61 #define RADEON_ASSERT(msg) mp_msg(MSGT_VO, MSGL_ERR, RADEON_MSG"################# FATAL:"msg);
61 62
62 #define VERBOSE_LEVEL 0 63 #define VERBOSE_LEVEL 0
63 static int verbosity = 0; 64 static int verbosity = 0;
64 typedef struct bes_registers_s 65 typedef struct bes_registers_s
65 { 66 {
1187 for (i = 0; i < n; i++) { 1188 for (i = 0; i < n; i++) {
1188 if (!strcmp(extlist[i], "ATIFGLEXTENSION")) ext_fgl = 1; 1189 if (!strcmp(extlist[i], "ATIFGLEXTENSION")) ext_fgl = 1;
1189 if (!strcmp(extlist[i], "ATIFGLRXDRI")) ext_fglrx = 1; 1190 if (!strcmp(extlist[i], "ATIFGLRXDRI")) ext_fglrx = 1;
1190 } 1191 }
1191 if (ext_fgl) { 1192 if (ext_fgl) {
1192 printf(RADEON_MSG" ATI FireGl driver detected"); 1193 mp_msg(MSGT_VO, MSGL_STATUS, RADEON_MSG" ATI FireGl driver detected");
1193 firegl_shift = 0x500000; 1194 firegl_shift = 0x500000;
1194 if (!ext_fglrx) { 1195 if (!ext_fglrx) {
1195 printf(", but DRI seems not to be activated\n"); 1196 mp_msg(MSGT_VO, MSGL_STATUS, ", but DRI seems not to be activated\n");
1196 printf(RADEON_MSG" Output may not work correctly, check your DRI configration!"); 1197 mp_msg(MSGT_VO, MSGL_STATUS, RADEON_MSG" Output may not work correctly, check your DRI configration!");
1197 } 1198 }
1198 printf("\n"); 1199 mp_msg(MSGT_VO, MSGL_STATUS, "\n");
1199 } 1200 }
1200 } 1201 }
1201 } 1202 }
1202 #endif 1203 #endif
1203 1204
1208 int err; 1209 int err;
1209 verbosity = verbose; 1210 verbosity = verbose;
1210 err = pci_scan(lst,&num_pci); 1211 err = pci_scan(lst,&num_pci);
1211 if(err) 1212 if(err)
1212 { 1213 {
1213 printf(RADEON_MSG" Error occurred during pci scan: %s\n",strerror(err)); 1214 mp_msg(MSGT_VO, MSGL_STATUS, RADEON_MSG" Error occurred during pci scan: %s\n",strerror(err));
1214 return err; 1215 return err;
1215 } 1216 }
1216 else 1217 else
1217 { 1218 {
1218 err = ENXIO; 1219 err = ENXIO;
1224 const char *dname; 1225 const char *dname;
1225 idx = find_chip(lst[i].device); 1226 idx = find_chip(lst[i].device);
1226 if(idx == -1 && force == PROBE_NORMAL) continue; 1227 if(idx == -1 && force == PROBE_NORMAL) continue;
1227 dname = pci_device_name(VENDOR_ATI,lst[i].device); 1228 dname = pci_device_name(VENDOR_ATI,lst[i].device);
1228 dname = dname ? dname : "Unknown chip"; 1229 dname = dname ? dname : "Unknown chip";
1229 printf(RADEON_MSG" Found chip: %s\n",dname); 1230 mp_msg(MSGT_VO, MSGL_STATUS, RADEON_MSG" Found chip: %s\n",dname);
1230 #if 0 1231 #if 0
1231 if ((lst[i].command & PCI_COMMAND_IO) == 0) 1232 if ((lst[i].command & PCI_COMMAND_IO) == 0)
1232 { 1233 {
1233 printf("[radeon] Device is disabled, ignoring\n"); 1234 mp_msg(MSGT_VO, MSGL_STATUS, "[radeon] Device is disabled, ignoring\n");
1234 continue; 1235 continue;
1235 } 1236 }
1236 #endif 1237 #endif
1237 memset(&besr,0,sizeof(bes_registers_t)); 1238 memset(&besr,0,sizeof(bes_registers_t));
1238 if(force > PROBE_NORMAL) 1239 if(force > PROBE_NORMAL)
1239 { 1240 {
1240 printf(RADEON_MSG" Driver was forced. Was found %sknown chip\n",idx == -1 ? "un" : ""); 1241 mp_msg(MSGT_VO, MSGL_STATUS, RADEON_MSG" Driver was forced. Was found %sknown chip\n",idx == -1 ? "un" : "");
1241 if(idx == -1) 1242 if(idx == -1)
1242 #ifdef RAGE128 1243 #ifdef RAGE128
1243 printf(RADEON_MSG" Assuming it as Rage128\n"); 1244 mp_msg(MSGT_VO, MSGL_STATUS, RADEON_MSG" Assuming it as Rage128\n");
1244 #else 1245 #else
1245 printf(RADEON_MSG" Assuming it as Radeon1\n"); 1246 mp_msg(MSGT_VO, MSGL_STATUS, RADEON_MSG" Assuming it as Radeon1\n");
1246 #endif 1247 #endif
1247 besr.chip_flags=R_100|R_OVL_SHIFT; 1248 besr.chip_flags=R_100|R_OVL_SHIFT;
1248 } 1249 }
1249 #if !defined(RAGE128) && defined(CONFIG_X11) 1250 #if !defined(RAGE128) && defined(CONFIG_X11)
1250 probe_fireGL_driver(); 1251 probe_fireGL_driver();
1256 probed=1; 1257 probed=1;
1257 break; 1258 break;
1258 } 1259 }
1259 } 1260 }
1260 } 1261 }
1261 if(err && verbose) printf(RADEON_MSG" Can't find chip\n"); 1262 if(err && verbose) mp_msg(MSGT_VO, MSGL_STATUS, RADEON_MSG" Can't find chip\n");
1262 return err; 1263 return err;
1263 } 1264 }
1264 1265
1265 typedef struct saved_regs_s 1266 typedef struct saved_regs_s
1266 { 1267 {
1332 { 1333 {
1333 int err; 1334 int err;
1334 1335
1335 if(!probed) 1336 if(!probed)
1336 { 1337 {
1337 printf(RADEON_MSG" Driver was not probed but is being initializing\n"); 1338 mp_msg(MSGT_VO, MSGL_STATUS, RADEON_MSG" Driver was not probed but is being initializing\n");
1338 return EINTR; 1339 return EINTR;
1339 } 1340 }
1340 if((radeon_mmio_base = map_phys_mem(pci_info.base2,0xFFFF))==(void *)-1) return ENOMEM; 1341 if((radeon_mmio_base = map_phys_mem(pci_info.base2,0xFFFF))==(void *)-1) return ENOMEM;
1341 radeon_ram_size = INREG(CONFIG_MEMSIZE); 1342 radeon_ram_size = INREG(CONFIG_MEMSIZE);
1342 /* mem size is bits [28:0], mask off the rest. Range: from 1Mb up to 512 Mb */ 1343 /* mem size is bits [28:0], mask off the rest. Range: from 1Mb up to 512 Mb */
1345 /* according to XFree86 4.2.0, some production M6's return 0 for 8MB */ 1346 /* according to XFree86 4.2.0, some production M6's return 0 for 8MB */
1346 if (radeon_ram_size == 0 && 1347 if (radeon_ram_size == 0 &&
1347 (def_cap.device_id == DEVICE_ATI_RADEON_MOBILITY_M6 || 1348 (def_cap.device_id == DEVICE_ATI_RADEON_MOBILITY_M6 ||
1348 def_cap.device_id == DEVICE_ATI_RADEON_MOBILITY_M62)) 1349 def_cap.device_id == DEVICE_ATI_RADEON_MOBILITY_M62))
1349 { 1350 {
1350 printf(RADEON_MSG" Working around buggy Radeon Mobility M6 (0 vs. 8MB ram)\n"); 1351 mp_msg(MSGT_VO, MSGL_STATUS, RADEON_MSG" Working around buggy Radeon Mobility M6 (0 vs. 8MB ram)\n");
1351 radeon_ram_size = 8192*1024; 1352 radeon_ram_size = 8192*1024;
1352 } 1353 }
1353 else if (radeon_ram_size == 0 && 1354 else if (radeon_ram_size == 0 &&
1354 (def_cap.device_id == DEVICE_ATI_RS482_RADEON_XPRESS)) 1355 (def_cap.device_id == DEVICE_ATI_RS482_RADEON_XPRESS))
1355 { 1356 {
1356 printf(RADEON_MSG" Working around buggy RS482 Radeon Xpress 200 Memory Detection\n"); 1357 mp_msg(MSGT_VO, MSGL_STATUS, RADEON_MSG" Working around buggy RS482 Radeon Xpress 200 Memory Detection\n");
1357 radeon_ram_size = (INREG(CONFIG_MEMSIZE) + 0x100000) << 2; 1358 radeon_ram_size = (INREG(CONFIG_MEMSIZE) + 0x100000) << 2;
1358 radeon_ram_size &= CONFIG_MEMSIZE_MASK; 1359 radeon_ram_size &= CONFIG_MEMSIZE_MASK;
1359 } 1360 }
1360 #else 1361 #else
1361 /* Rage Mobility (rage128) also has memsize bug */ 1362 /* Rage Mobility (rage128) also has memsize bug */
1362 if (radeon_ram_size == 0 && 1363 if (radeon_ram_size == 0 &&
1363 (def_cap.device_id == DEVICE_ATI_RAGE_MOBILITY_M3 || 1364 (def_cap.device_id == DEVICE_ATI_RAGE_MOBILITY_M3 ||
1364 def_cap.device_id == DEVICE_ATI_RAGE_MOBILITY_M32)) 1365 def_cap.device_id == DEVICE_ATI_RAGE_MOBILITY_M32))
1365 { 1366 {
1366 printf(RADEON_MSG" Working around Rage Mobility M3 (0 vs. 8MB ram)\n"); 1367 mp_msg(MSGT_VO, MSGL_STATUS, RADEON_MSG" Working around Rage Mobility M3 (0 vs. 8MB ram)\n");
1367 radeon_ram_size = 8192*1024; 1368 radeon_ram_size = 8192*1024;
1368 } 1369 }
1369 #endif 1370 #endif
1370 if((radeon_mem_base = map_phys_mem(pci_info.base0,radeon_ram_size))==(void *)-1) return ENOMEM; 1371 if((radeon_mem_base = map_phys_mem(pci_info.base0,radeon_ram_size))==(void *)-1) return ENOMEM;
1371 radeon_vid_make_default(); 1372 radeon_vid_make_default();
1372 printf(RADEON_MSG" Video memory = %uMb\n",radeon_ram_size/0x100000); 1373 mp_msg(MSGT_VO, MSGL_STATUS, RADEON_MSG" Video memory = %uMb\n",radeon_ram_size/0x100000);
1373 err = mtrr_set_type(pci_info.base0,radeon_ram_size,MTRR_TYPE_WRCOMB); 1374 err = mtrr_set_type(pci_info.base0,radeon_ram_size,MTRR_TYPE_WRCOMB);
1374 if(!err) printf(RADEON_MSG" Set write-combining type of video memory\n"); 1375 if(!err) mp_msg(MSGT_VO, MSGL_STATUS, RADEON_MSG" Set write-combining type of video memory\n");
1375 #ifndef RAGE128 1376 #ifndef RAGE128
1376 { 1377 {
1377 memset(&rinfo,0,sizeof(rinfo_t)); 1378 memset(&rinfo,0,sizeof(rinfo_t));
1378 if((besr.chip_flags&R_100) != R_100) rinfo.hasCRTC2 = 1; 1379 if((besr.chip_flags&R_100) != R_100) rinfo.hasCRTC2 = 1;
1379 1380
1380 radeon_get_moninfo(&rinfo); 1381 radeon_get_moninfo(&rinfo);
1381 if(rinfo.hasCRTC2) { 1382 if(rinfo.hasCRTC2) {
1382 printf(RADEON_MSG" DVI port has %s monitor connected\n",GET_MON_NAME(rinfo.dviDispType)); 1383 mp_msg(MSGT_VO, MSGL_STATUS, RADEON_MSG" DVI port has %s monitor connected\n",GET_MON_NAME(rinfo.dviDispType));
1383 printf(RADEON_MSG" CRT port has %s monitor connected\n",GET_MON_NAME(rinfo.crtDispType)); 1384 mp_msg(MSGT_VO, MSGL_STATUS, RADEON_MSG" CRT port has %s monitor connected\n",GET_MON_NAME(rinfo.crtDispType));
1384 } 1385 }
1385 else 1386 else
1386 printf(RADEON_MSG" CRT port has %s monitor connected\n",GET_MON_NAME(rinfo.crtDispType)); 1387 mp_msg(MSGT_VO, MSGL_STATUS, RADEON_MSG" CRT port has %s monitor connected\n",GET_MON_NAME(rinfo.crtDispType));
1387 } 1388 }
1388 #endif 1389 #endif
1389 save_regs(); 1390 save_regs();
1390 clear_swap(); 1391 clear_swap();
1391 return 0; 1392 return 0;
1459 1460
1460 static double H_scale_ratio; 1461 static double H_scale_ratio;
1461 static void radeon_vid_dump_regs( void ) 1462 static void radeon_vid_dump_regs( void )
1462 { 1463 {
1463 size_t i; 1464 size_t i;
1464 printf(RADEON_MSG"*** Begin of DRIVER variables dump ***\n"); 1465 mp_msg(MSGT_VO, MSGL_STATUS, RADEON_MSG"*** Begin of DRIVER variables dump ***\n");
1465 printf(RADEON_MSG"radeon_mmio_base=%p\n",radeon_mmio_base); 1466 mp_msg(MSGT_VO, MSGL_STATUS, RADEON_MSG"radeon_mmio_base=%p\n",radeon_mmio_base);
1466 printf(RADEON_MSG"radeon_mem_base=%p\n",radeon_mem_base); 1467 mp_msg(MSGT_VO, MSGL_STATUS, RADEON_MSG"radeon_mem_base=%p\n",radeon_mem_base);
1467 printf(RADEON_MSG"radeon_overlay_off=%08X\n",radeon_overlay_off); 1468 mp_msg(MSGT_VO, MSGL_STATUS, RADEON_MSG"radeon_overlay_off=%08X\n",radeon_overlay_off);
1468 printf(RADEON_MSG"radeon_ram_size=%08X\n",radeon_ram_size); 1469 mp_msg(MSGT_VO, MSGL_STATUS, RADEON_MSG"radeon_ram_size=%08X\n",radeon_ram_size);
1469 printf(RADEON_MSG"video mode: %ux%u@%u\n",radeon_get_xres(),radeon_get_yres(),radeon_vid_get_dbpp()); 1470 mp_msg(MSGT_VO, MSGL_STATUS, RADEON_MSG"video mode: %ux%u@%u\n",radeon_get_xres(),radeon_get_yres(),radeon_vid_get_dbpp());
1470 printf(RADEON_MSG"H_scale_ratio=%8.2f\n",H_scale_ratio); 1471 mp_msg(MSGT_VO, MSGL_STATUS, RADEON_MSG"H_scale_ratio=%8.2f\n",H_scale_ratio);
1471 printf(RADEON_MSG"*** Begin of OV0 registers dump ***\n"); 1472 mp_msg(MSGT_VO, MSGL_STATUS, RADEON_MSG"*** Begin of OV0 registers dump ***\n");
1472 for(i=0;i<sizeof(vregs)/sizeof(video_registers_t);i++) 1473 for(i=0;i<sizeof(vregs)/sizeof(video_registers_t);i++)
1473 printf(RADEON_MSG"%s = %08X\n",vregs[i].sname,INREG(vregs[i].name)); 1474 mp_msg(MSGT_VO, MSGL_STATUS, RADEON_MSG"%s = %08X\n",vregs[i].sname,INREG(vregs[i].name));
1474 printf(RADEON_MSG"*** End of OV0 registers dump ***\n"); 1475 mp_msg(MSGT_VO, MSGL_STATUS, RADEON_MSG"*** End of OV0 registers dump ***\n");
1475 } 1476 }
1476 1477
1477 static void radeon_vid_stop_video( void ) 1478 static void radeon_vid_stop_video( void )
1478 { 1479 {
1479 radeon_engine_idle(); 1480 radeon_engine_idle();
1578 OUTREG(OV0_FOUR_TAP_COEF_2,besr.four_tap_coeff[2]); 1579 OUTREG(OV0_FOUR_TAP_COEF_2,besr.four_tap_coeff[2]);
1579 OUTREG(OV0_FOUR_TAP_COEF_3,besr.four_tap_coeff[3]); 1580 OUTREG(OV0_FOUR_TAP_COEF_3,besr.four_tap_coeff[3]);
1580 OUTREG(OV0_FOUR_TAP_COEF_4,besr.four_tap_coeff[4]); 1581 OUTREG(OV0_FOUR_TAP_COEF_4,besr.four_tap_coeff[4]);
1581 if(besr.swap_uv) OUTREG(OV0_TEST,INREG(OV0_TEST)|OV0_SWAP_UV); 1582 if(besr.swap_uv) OUTREG(OV0_TEST,INREG(OV0_TEST)|OV0_SWAP_UV);
1582 OUTREG(OV0_REG_LOAD_CNTL, 0); 1583 OUTREG(OV0_REG_LOAD_CNTL, 0);
1583 if(verbosity > VERBOSE_LEVEL) printf(RADEON_MSG"we wanted: scaler=%08X\n",bes_flags); 1584 if(verbosity > VERBOSE_LEVEL) mp_msg(MSGT_VO, MSGL_STATUS, RADEON_MSG"we wanted: scaler=%08X\n",bes_flags);
1584 if(verbosity > VERBOSE_LEVEL) radeon_vid_dump_regs(); 1585 if(verbosity > VERBOSE_LEVEL) radeon_vid_dump_regs();
1585 } 1586 }
1586 1587
1587 /* Goal of this function: hide RGB background and provide black screen around movie. 1588 /* Goal of this function: hide RGB background and provide black screen around movie.
1588 Useful in '-vo fbdev:vidix -fs -zoom' mode. 1589 Useful in '-vo fbdev:vidix -fs -zoom' mode.