Mercurial > mplayer.hg
comparison vidix/radeon_vid.c @ 22857:77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
author | ben |
---|---|
date | Sun, 01 Apr 2007 11:06:06 +0000 |
parents | 9a1e26fef45b |
children | 6c57087c5a2d |
comparison
equal
deleted
inserted
replaced
22856:27db9ffe00a5 | 22857:77def5093daf |
---|---|
20 #include "../libavutil/common.h" | 20 #include "../libavutil/common.h" |
21 #include "../mpbswap.h" | 21 #include "../mpbswap.h" |
22 #include "../libdha/pci_ids.h" | 22 #include "../libdha/pci_ids.h" |
23 #include "../libdha/pci_names.h" | 23 #include "../libdha/pci_names.h" |
24 #include "vidix.h" | 24 #include "vidix.h" |
25 #include "vidixlib.h" | |
25 #include "fourcc.h" | 26 #include "fourcc.h" |
26 #include "../libdha/libdha.h" | 27 #include "../libdha/libdha.h" |
27 #include "radeon.h" | 28 #include "radeon.h" |
28 | 29 |
29 #ifdef HAVE_X11 | 30 #ifdef HAVE_X11 |
792 besr.graphics_key_clr=0; | 793 besr.graphics_key_clr=0; |
793 besr.ckey_cntl = VIDEO_KEY_FN_TRUE|GRAPHIC_KEY_FN_TRUE|CMP_MIX_AND; | 794 besr.ckey_cntl = VIDEO_KEY_FN_TRUE|GRAPHIC_KEY_FN_TRUE|CMP_MIX_AND; |
794 } | 795 } |
795 | 796 |
796 | 797 |
797 unsigned vixGetVersion( void ) { return VIDIX_VERSION; } | 798 static unsigned int radeon_get_version( void ) { return VIDIX_VERSION; } |
798 | 799 |
799 static unsigned short ati_card_ids[] = | 800 static unsigned short ati_card_ids[] = |
800 { | 801 { |
801 #ifdef RAGE128 | 802 #ifdef RAGE128 |
802 /* | 803 /* |
928 } | 929 } |
929 | 930 |
930 static pciinfo_t pci_info; | 931 static pciinfo_t pci_info; |
931 static int probed=0; | 932 static int probed=0; |
932 | 933 |
933 vidix_capability_t def_cap = | 934 static vidix_capability_t def_cap = |
934 { | 935 { |
935 #ifdef RAGE128 | 936 #ifdef RAGE128 |
936 "BES driver for Rage128 cards", | 937 "BES driver for Rage128 cards", |
937 #else | 938 #else |
938 "BES driver for Radeon cards", | 939 "BES driver for Radeon cards", |
979 } | 980 } |
980 } | 981 } |
981 } | 982 } |
982 #endif | 983 #endif |
983 | 984 |
984 int vixProbe( int verbose,int force ) | 985 static int radeon_probe( int verbose,int force ) |
985 { | 986 { |
986 pciinfo_t lst[MAX_PCI_DEVICES]; | 987 pciinfo_t lst[MAX_PCI_DEVICES]; |
987 unsigned i,num_pci; | 988 unsigned i,num_pci; |
988 int err; | 989 int err; |
989 __verbose = verbose; | 990 __verbose = verbose; |
1137 return err; | 1138 return err; |
1138 } | 1139 } |
1139 | 1140 |
1140 static void radeon_vid_dump_regs( void ); /* forward declaration */ | 1141 static void radeon_vid_dump_regs( void ); /* forward declaration */ |
1141 | 1142 |
1142 int vixInit( void ) | 1143 static int radeon_init( void ) |
1143 { | 1144 { |
1144 int err; | 1145 int err; |
1145 if(!probed) | 1146 if(!probed) |
1146 { | 1147 { |
1147 printf(RADEON_MSG" Driver was not probed but is being initializing\n"); | 1148 printf(RADEON_MSG" Driver was not probed but is being initializing\n"); |
1237 | 1238 |
1238 if(__verbose > 1) radeon_vid_dump_regs(); | 1239 if(__verbose > 1) radeon_vid_dump_regs(); |
1239 return 0; | 1240 return 0; |
1240 } | 1241 } |
1241 | 1242 |
1242 void vixDestroy( void ) | 1243 static void radeon_destroy( void ) |
1243 { | 1244 { |
1244 /* remove colorkeying */ | 1245 /* remove colorkeying */ |
1245 radeon_fifo_wait(3); | 1246 radeon_fifo_wait(3); |
1246 OUTREG(OV0_GRAPHICS_KEY_CLR, SAVED_OV0_GRAPHICS_KEY_CLR); | 1247 OUTREG(OV0_GRAPHICS_KEY_CLR, SAVED_OV0_GRAPHICS_KEY_CLR); |
1247 OUTREG(OV0_GRAPHICS_KEY_MSK, SAVED_OV0_GRAPHICS_KEY_MSK); | 1248 OUTREG(OV0_GRAPHICS_KEY_MSK, SAVED_OV0_GRAPHICS_KEY_MSK); |
1262 | 1263 |
1263 unmap_phys_mem(radeon_mem_base,radeon_ram_size); | 1264 unmap_phys_mem(radeon_mem_base,radeon_ram_size); |
1264 unmap_phys_mem(radeon_mmio_base,0xFFFF); | 1265 unmap_phys_mem(radeon_mmio_base,0xFFFF); |
1265 } | 1266 } |
1266 | 1267 |
1267 int vixGetCapability(vidix_capability_t *to) | 1268 static int radeon_get_caps(vidix_capability_t *to) |
1268 { | 1269 { |
1269 memcpy(to,&def_cap,sizeof(vidix_capability_t)); | 1270 memcpy(to,&def_cap,sizeof(vidix_capability_t)); |
1270 return 0; | 1271 return 0; |
1271 } | 1272 } |
1272 | 1273 |
1273 /* | 1274 /* |
1274 Full list of fourcc which are supported by Win2K redeon driver: | 1275 Full list of fourcc which are supported by Win2K redeon driver: |
1275 YUY2, UYVY, DDES, OGLT, OGL2, OGLS, OGLB, OGNT, OGNZ, OGNS, | 1276 YUY2, UYVY, DDES, OGLT, OGL2, OGLS, OGLB, OGNT, OGNZ, OGNS, |
1276 IF09, YVU9, IMC4, M2IA, IYUV, VBID, DXT1, DXT2, DXT3, DXT4, DXT5 | 1277 IF09, YVU9, IMC4, M2IA, IYUV, VBID, DXT1, DXT2, DXT3, DXT4, DXT5 |
1277 */ | 1278 */ |
1278 uint32_t supported_fourcc[] = | 1279 static uint32_t supported_fourcc[] = |
1279 { | 1280 { |
1280 IMGFMT_Y800, IMGFMT_Y8, IMGFMT_YVU9, IMGFMT_IF09, | 1281 IMGFMT_Y800, IMGFMT_Y8, IMGFMT_YVU9, IMGFMT_IF09, |
1281 IMGFMT_YV12, IMGFMT_I420, IMGFMT_IYUV, | 1282 IMGFMT_YV12, IMGFMT_I420, IMGFMT_IYUV, |
1282 IMGFMT_UYVY, IMGFMT_YUY2, IMGFMT_YVYU, | 1283 IMGFMT_UYVY, IMGFMT_YUY2, IMGFMT_YVYU, |
1283 IMGFMT_RGB15, IMGFMT_BGR15, | 1284 IMGFMT_RGB15, IMGFMT_BGR15, |
1293 if(fourcc==supported_fourcc[i]) return 1; | 1294 if(fourcc==supported_fourcc[i]) return 1; |
1294 } | 1295 } |
1295 return 0; | 1296 return 0; |
1296 } | 1297 } |
1297 | 1298 |
1298 int vixQueryFourcc(vidix_fourcc_t *to) | 1299 static int radeon_query_fourcc(vidix_fourcc_t *to) |
1299 { | 1300 { |
1300 if(is_supported_fourcc(to->fourcc)) | 1301 if(is_supported_fourcc(to->fourcc)) |
1301 { | 1302 { |
1302 to->depth = VID_DEPTH_1BPP | VID_DEPTH_2BPP | | 1303 to->depth = VID_DEPTH_1BPP | VID_DEPTH_2BPP | |
1303 VID_DEPTH_4BPP | VID_DEPTH_8BPP | | 1304 VID_DEPTH_4BPP | VID_DEPTH_8BPP | |
1801 info->frame_size = awidth*info->src.h; | 1802 info->frame_size = awidth*info->src.h; |
1802 break; | 1803 break; |
1803 } | 1804 } |
1804 } | 1805 } |
1805 | 1806 |
1806 int vixConfigPlayback(vidix_playback_t *info) | 1807 static int radeon_config_playback(vidix_playback_t *info) |
1807 { | 1808 { |
1808 unsigned rgb_size,nfr; | 1809 unsigned rgb_size,nfr; |
1809 if(!is_supported_fourcc(info->fourcc)) return ENOSYS; | 1810 if(!is_supported_fourcc(info->fourcc)) return ENOSYS; |
1810 if(info->num_frames>VID_PLAY_MAXFRAMES) info->num_frames=VID_PLAY_MAXFRAMES; | 1811 if(info->num_frames>VID_PLAY_MAXFRAMES) info->num_frames=VID_PLAY_MAXFRAMES; |
1811 if(info->num_frames==1) besr.double_buff=0; | 1812 if(info->num_frames==1) besr.double_buff=0; |
1842 info->dga_addr = (char *)radeon_mem_base + radeon_overlay_off; | 1843 info->dga_addr = (char *)radeon_mem_base + radeon_overlay_off; |
1843 radeon_vid_init_video(info); | 1844 radeon_vid_init_video(info); |
1844 return 0; | 1845 return 0; |
1845 } | 1846 } |
1846 | 1847 |
1847 int vixPlaybackOn( void ) | 1848 static int radeon_playback_on( void ) |
1848 { | 1849 { |
1849 radeon_vid_display_video(); | 1850 radeon_vid_display_video(); |
1850 return 0; | 1851 return 0; |
1851 } | 1852 } |
1852 | 1853 |
1853 int vixPlaybackOff( void ) | 1854 static int radeon_playback_off( void ) |
1854 { | 1855 { |
1855 radeon_vid_stop_video(); | 1856 radeon_vid_stop_video(); |
1856 return 0; | 1857 return 0; |
1857 } | 1858 } |
1858 | 1859 |
1859 int vixPlaybackFrameSelect(unsigned frame) | 1860 static int radeon_frame_select(unsigned frame) |
1860 { | 1861 { |
1861 uint32_t off[6]; | 1862 uint32_t off[6]; |
1862 int prev_frame= (frame-1+besr.vid_nbufs) % besr.vid_nbufs; | 1863 int prev_frame= (frame-1+besr.vid_nbufs) % besr.vid_nbufs; |
1863 /* | 1864 /* |
1864 buf3-5 always should point onto second buffer for better | 1865 buf3-5 always should point onto second buffer for better |
1887 if(besr.vid_nbufs == 2) radeon_wait_vsync(); | 1888 if(besr.vid_nbufs == 2) radeon_wait_vsync(); |
1888 if(__verbose > 1) radeon_vid_dump_regs(); | 1889 if(__verbose > 1) radeon_vid_dump_regs(); |
1889 return 0; | 1890 return 0; |
1890 } | 1891 } |
1891 | 1892 |
1892 vidix_video_eq_t equal = | 1893 static vidix_video_eq_t equal = |
1893 { | 1894 { |
1894 VEQ_CAP_BRIGHTNESS | VEQ_CAP_SATURATION | 1895 VEQ_CAP_BRIGHTNESS | VEQ_CAP_SATURATION |
1895 #ifndef RAGE128 | 1896 #ifndef RAGE128 |
1896 | VEQ_CAP_CONTRAST | VEQ_CAP_HUE | VEQ_CAP_RGB_INTENSITY | 1897 | VEQ_CAP_CONTRAST | VEQ_CAP_HUE | VEQ_CAP_RGB_INTENSITY |
1897 #endif | 1898 #endif |
1898 , | 1899 , |
1899 0, 0, 0, 0, 0, 0, 0, 0 }; | 1900 0, 0, 0, 0, 0, 0, 0, 0 }; |
1900 | 1901 |
1901 int vixPlaybackGetEq( vidix_video_eq_t * eq) | 1902 static int radeon_get_eq( vidix_video_eq_t * eq) |
1902 { | 1903 { |
1903 memcpy(eq,&equal,sizeof(vidix_video_eq_t)); | 1904 memcpy(eq,&equal,sizeof(vidix_video_eq_t)); |
1904 return 0; | 1905 return 0; |
1905 } | 1906 } |
1906 | 1907 |
1911 #define RTFContrast(a) (1.0 + ((a)*1.0)/1000.0) | 1912 #define RTFContrast(a) (1.0 + ((a)*1.0)/1000.0) |
1912 #define RTFHue(a) (((a)*3.1416)/1000.0) | 1913 #define RTFHue(a) (((a)*3.1416)/1000.0) |
1913 #define RTFCheckParam(a) {if((a)<-1000) (a)=-1000; if((a)>1000) (a)=1000;} | 1914 #define RTFCheckParam(a) {if((a)<-1000) (a)=-1000; if((a)>1000) (a)=1000;} |
1914 #endif | 1915 #endif |
1915 | 1916 |
1916 int vixPlaybackSetEq( const vidix_video_eq_t * eq) | 1917 static int radeon_set_eq( const vidix_video_eq_t * eq) |
1917 { | 1918 { |
1918 #ifdef RAGE128 | 1919 #ifdef RAGE128 |
1919 int br,sat; | 1920 int br,sat; |
1920 #else | 1921 #else |
1921 int itu_space; | 1922 int itu_space; |
1956 itu_space); | 1957 itu_space); |
1957 #endif | 1958 #endif |
1958 return 0; | 1959 return 0; |
1959 } | 1960 } |
1960 | 1961 |
1961 int vixPlaybackSetDeint( const vidix_deinterlace_t * info) | 1962 static int radeon_playback_set_deint (const vidix_deinterlace_t * info) |
1962 { | 1963 { |
1963 unsigned sflg; | 1964 unsigned sflg; |
1964 switch(info->flags) | 1965 switch(info->flags) |
1965 { | 1966 { |
1966 default: | 1967 default: |
1994 else OUTREG(OV0_SCALE_CNTL,sflg & (~SCALER_ADAPTIVE_DEINT)); | 1995 else OUTREG(OV0_SCALE_CNTL,sflg & (~SCALER_ADAPTIVE_DEINT)); |
1995 OUTREG(OV0_REG_LOAD_CNTL, 0); | 1996 OUTREG(OV0_REG_LOAD_CNTL, 0); |
1996 return 0; | 1997 return 0; |
1997 } | 1998 } |
1998 | 1999 |
1999 int vixPlaybackGetDeint( vidix_deinterlace_t * info) | 2000 static int radeon_playback_get_deint (vidix_deinterlace_t * info) |
2000 { | 2001 { |
2001 if(!besr.deinterlace_on) info->flags = CFG_NON_INTERLACED; | 2002 if(!besr.deinterlace_on) info->flags = CFG_NON_INTERLACED; |
2002 else | 2003 else |
2003 { | 2004 { |
2004 info->flags = CFG_UNIQUE_INTERLACING; | 2005 info->flags = CFG_UNIQUE_INTERLACING; |
2085 OUTREG(OV0_GRAPHICS_KEY_MSK, besr.graphics_key_msk); | 2086 OUTREG(OV0_GRAPHICS_KEY_MSK, besr.graphics_key_msk); |
2086 OUTREG(OV0_GRAPHICS_KEY_CLR, besr.graphics_key_clr); | 2087 OUTREG(OV0_GRAPHICS_KEY_CLR, besr.graphics_key_clr); |
2087 OUTREG(OV0_KEY_CNTL,besr.ckey_cntl); | 2088 OUTREG(OV0_KEY_CNTL,besr.ckey_cntl); |
2088 } | 2089 } |
2089 | 2090 |
2090 int vixGetGrKeys(vidix_grkey_t *grkey) | 2091 static int radeon_get_gkey(vidix_grkey_t *grkey) |
2091 { | 2092 { |
2092 memcpy(grkey, &radeon_grkey, sizeof(vidix_grkey_t)); | 2093 memcpy(grkey, &radeon_grkey, sizeof(vidix_grkey_t)); |
2093 return(0); | 2094 return(0); |
2094 } | 2095 } |
2095 | 2096 |
2096 int vixSetGrKeys(const vidix_grkey_t *grkey) | 2097 static int radeon_set_gkey(const vidix_grkey_t *grkey) |
2097 { | 2098 { |
2098 memcpy(&radeon_grkey, grkey, sizeof(vidix_grkey_t)); | 2099 memcpy(&radeon_grkey, grkey, sizeof(vidix_grkey_t)); |
2099 set_gr_key(); | 2100 set_gr_key(); |
2100 return(0); | 2101 return(0); |
2101 } | 2102 } |
2103 | |
2104 #ifdef RAGE128 | |
2105 VDXDriver rage128_drv = { | |
2106 "rage128", | |
2107 #else | |
2108 VDXDriver radeon_drv = { | |
2109 "radeon", | |
2110 #endif | |
2111 NULL, | |
2112 | |
2113 .probe = radeon_probe, | |
2114 .get_version = radeon_get_version, | |
2115 .get_caps = radeon_get_caps, | |
2116 .query_fourcc = radeon_query_fourcc, | |
2117 .init = radeon_init, | |
2118 .destroy = radeon_destroy, | |
2119 .config_playback = radeon_config_playback, | |
2120 .playback_on = radeon_playback_on, | |
2121 .playback_off = radeon_playback_off, | |
2122 .frame_sel = radeon_frame_select, | |
2123 .get_eq = radeon_get_eq, | |
2124 .set_eq = radeon_set_eq, | |
2125 .get_deint = radeon_playback_get_deint, | |
2126 .set_deint = radeon_playback_set_deint, | |
2127 .get_gkey = radeon_get_gkey, | |
2128 .set_gkey = radeon_set_gkey, | |
2129 }; |