From bc33257a6436fcf53bc73f4d0dcadc4a46eabe9c Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 28 Jul 2012 20:20:17 +0200 Subject: [PATCH] VO, AO: remove obsolete/problematic VO/AO drivers Some of these have only limited use, and some of these have no use at all. Remove them. They make maintainance harder and nobody needs them. It's possible that many of the removed drivers were very useful a dozen of years ago, but now it's 2012. Note that some of these could be added back, in case they were more useful than I thought. But right now, they are just a burden. Reason for removal for each module: vo_3dfx, vo_dfbmga, vo_dxr3, vo_ivtv, vo_mga, vo_s3fb, vo_tdfx_vid, vo_tdfxfb, vo_xmga: All of these are for very specific and outdated hardware. Some of them require non-standard kernel drivers or do direct HW access. vo_dga: the most crappy and ancient way to get fast output on X. vo_aa: there's vo_caca for the same purpose. vo_ggi: this never lived, and is entirely useless. vo_mpegpes: for DVB cards, I can't test this and it's crappy. vo_fbdev, vo_fbdev2: there's vo_directfb2 vo_bl: what is this even? But it's neither important, nor alive. vo_svga, vo_vesa: you want to use this? You can't be serious. vo_wii: I can't test this, and who the hell uses this? vo_xvr100: some Sun thing. vo_xover: only useful in connection with xvr100. ao_ivtv: removed along vo_ivtv. ao_mpegpes: removed along vo_mpegpes. ao_nas: still alive, but I doubt it has any meaning today. ao_sun: Sun. ao_win32: use ao_dsound or ao_portaudio instead. Additionally, I accidentally damaged Sun support, which made me completely remove Sun/Solaris support. Nobody cares about this anyway. Also clean up some leftovers from previous removals. --- Makefile | 65 +- cfg-mplayer.h | 14 - configure | 568 +------------ drivers/3dfx.h | 374 --------- drivers/README.Ati | 121 --- drivers/README.Matrox | 46 -- drivers/generic_math.h | 272 ------- drivers/hacking.ati | 313 ------- drivers/mga_vid.c | 1778 ---------------------------------------- drivers/mga_vid.h | 74 -- drivers/mga_vid_test.c | 235 ------ drivers/radeon.h | 2058 ----------------------------------------------- drivers/radeon_vid.c | 1549 ----------------------------------- drivers/radeon_vid.h | 126 --- drivers/tdfx_vid.c | 1049 ------------------------ drivers/tdfx_vid.h | 128 --- drivers/tdfx_vid_test.c | 120 --- libao2/ao_ivtv.c | 161 ---- libao2/ao_mpegpes.c | 336 -------- libao2/ao_nas.c | 646 --------------- libao2/ao_sun.c | 692 ---------------- libao2/ao_win32.c | 326 -------- libao2/audio_out.c | 29 - libmpcodecs/vfcap.h | 2 - libvo/aspect.c | 5 - libvo/aspect.h | 2 - libvo/gtf.c | 304 ------- libvo/gtf.h | 66 -- libvo/matrixview_font.h | 606 -------------- libvo/mga_template.c | 581 ------------- libvo/osd.c | 30 - libvo/osd.h | 1 - libvo/osd_template.c | 24 - libvo/spuenc.c | 237 ------ libvo/spuenc.h | 38 - libvo/vesa_lvo.c | 317 -------- libvo/vesa_lvo.h | 34 - libvo/video_out.c | 82 -- libvo/video_out.h | 15 +- libvo/vo_3dfx.c | 506 ------------ libvo/vo_aa.c | 755 ----------------- libvo/vo_bl.c | 479 ----------- libvo/vo_dfbmga.c | 1536 ----------------------------------- libvo/vo_dga.c | 999 ----------------------- libvo/vo_dxr3.c | 1321 ------------------------------ libvo/vo_fbdev.c | 1091 ------------------------- libvo/vo_fbdev2.c | 412 ---------- libvo/vo_ggi.c | 591 -------------- libvo/vo_ivtv.c | 305 ------- libvo/vo_ivtv.h | 34 - libvo/vo_mga.c | 117 --- libvo/vo_mpegpes.c | 251 ------ libvo/vo_s3fb.c | 560 ------------- libvo/vo_svga.c | 670 --------------- libvo/vo_tdfx_vid.c | 667 --------------- libvo/vo_tdfxfb.c | 529 ------------ libvo/vo_vesa.c | 1029 ------------------------ libvo/vo_wii.c | 362 --------- libvo/vo_xmga.c | 196 ----- libvo/vo_xover.c | 427 ---------- libvo/vo_xvr100.c | 451 ----------- libvo/x11_common.c | 3 +- mplayer.c | 2 - sub/spudec.c | 29 - sub/spudec.h | 2 - 65 files changed, 15 insertions(+), 26733 deletions(-) delete mode 100644 drivers/3dfx.h delete mode 100644 drivers/README.Ati delete mode 100644 drivers/README.Matrox delete mode 100644 drivers/generic_math.h delete mode 100644 drivers/hacking.ati delete mode 100644 drivers/mga_vid.c delete mode 100644 drivers/mga_vid.h delete mode 100644 drivers/mga_vid_test.c delete mode 100644 drivers/radeon.h delete mode 100644 drivers/radeon_vid.c delete mode 100644 drivers/radeon_vid.h delete mode 100644 drivers/tdfx_vid.c delete mode 100644 drivers/tdfx_vid.h delete mode 100644 drivers/tdfx_vid_test.c delete mode 100644 libao2/ao_ivtv.c delete mode 100644 libao2/ao_mpegpes.c delete mode 100644 libao2/ao_nas.c delete mode 100644 libao2/ao_sun.c delete mode 100644 libao2/ao_win32.c delete mode 100644 libvo/gtf.c delete mode 100644 libvo/gtf.h delete mode 100644 libvo/matrixview_font.h delete mode 100644 libvo/mga_template.c delete mode 100644 libvo/spuenc.c delete mode 100644 libvo/spuenc.h delete mode 100644 libvo/vesa_lvo.c delete mode 100644 libvo/vesa_lvo.h delete mode 100644 libvo/vo_3dfx.c delete mode 100644 libvo/vo_aa.c delete mode 100644 libvo/vo_bl.c delete mode 100644 libvo/vo_dfbmga.c delete mode 100644 libvo/vo_dga.c delete mode 100644 libvo/vo_dxr3.c delete mode 100644 libvo/vo_fbdev.c delete mode 100644 libvo/vo_fbdev2.c delete mode 100644 libvo/vo_ggi.c delete mode 100644 libvo/vo_ivtv.c delete mode 100644 libvo/vo_ivtv.h delete mode 100644 libvo/vo_mga.c delete mode 100644 libvo/vo_mpegpes.c delete mode 100644 libvo/vo_s3fb.c delete mode 100644 libvo/vo_svga.c delete mode 100644 libvo/vo_tdfx_vid.c delete mode 100644 libvo/vo_tdfxfb.c delete mode 100644 libvo/vo_vesa.c delete mode 100644 libvo/vo_wii.c delete mode 100644 libvo/vo_xmga.c delete mode 100644 libvo/vo_xover.c delete mode 100644 libvo/vo_xvr100.c diff --git a/Makefile b/Makefile index d1ce8dd532..8b6c140fb3 100644 --- a/Makefile +++ b/Makefile @@ -430,23 +430,16 @@ SRCS_COMMON = asxparser.c \ $(SRCS_COMMON-yes) -SRCS_MPLAYER-$(3DFX) += libvo/vo_3dfx.c -SRCS_MPLAYER-$(AA) += libvo/vo_aa.c SRCS_MPLAYER-$(ALSA) += libao2/ao_alsa.c SRCS_MPLAYER-$(APPLE_IR) += input/appleir.c SRCS_MPLAYER-$(APPLE_REMOTE) += input/ar.c -SRCS_MPLAYER-$(BL) += libvo/vo_bl.c SRCS_MPLAYER-$(CACA) += libvo/vo_caca.c SRCS_MPLAYER-$(COREAUDIO) += libao2/ao_coreaudio.c SRCS_MPLAYER-$(COREVIDEO) += libvo/vo_corevideo.m SRCS_MPLAYER-$(SHAREDBUFFER) += libvo/vo_sharedbuffer.m -SRCS_MPLAYER-$(DGA) += libvo/vo_dga.c SRCS_MPLAYER-$(DIRECT3D) += libvo/vo_direct3d.c libvo/w32_common.c -SRCS_MPLAYER-$(DIRECTFB) += libvo/vo_directfb2.c libvo/vo_dfbmga.c +SRCS_MPLAYER-$(DIRECTFB) += libvo/vo_directfb2.c SRCS_MPLAYER-$(DIRECTX) += libao2/ao_dsound.c libvo/vo_directx.c -SRCS_MPLAYER-$(DXR3) += libvo/vo_dxr3.c -SRCS_MPLAYER-$(FBDEV) += libvo/vo_fbdev.c libvo/vo_fbdev2.c -SRCS_MPLAYER-$(GGI) += libvo/vo_ggi.c SRCS_MPLAYER-$(GIF) += libvo/vo_gif89a.c SRCS_MPLAYER-$(GL) += libvo/gl_common.c libvo/vo_gl.c \ pnm_loader.c @@ -454,39 +447,25 @@ SRCS_MPLAYER-$(GL_SDL) += libvo/sdl_common.c SRCS_MPLAYER-$(GL_WIN32) += libvo/w32_common.c SRCS_MPLAYER-$(GL_X11) += libvo/x11_common.c -SRCS_MPLAYER-$(IVTV) += libao2/ao_ivtv.c libvo/vo_ivtv.c SRCS_MPLAYER-$(JACK) += libao2/ao_jack.c SRCS_MPLAYER-$(JOYSTICK) += input/joystick.c SRCS_MPLAYER-$(JPEG) += libvo/vo_jpeg.c SRCS_MPLAYER-$(LIRC) += input/lirc.c SRCS_MPLAYER-$(MD5SUM) += libvo/vo_md5sum.c -SRCS_MPLAYER-$(MGA) += libvo/vo_mga.c -SRCS_MPLAYER-$(NAS) += libao2/ao_nas.c SRCS_MPLAYER-$(OPENAL) += libao2/ao_openal.c SRCS_MPLAYER-$(OSS) += libao2/ao_oss.c SRCS_MPLAYER-$(PNM) += libvo/vo_pnm.c SRCS_MPLAYER-$(PULSE) += libao2/ao_pulse.c SRCS_MPLAYER-$(PORTAUDIO) += libao2/ao_portaudio.c SRCS_MPLAYER-$(RSOUND) += libao2/ao_rsound.c -SRCS_MPLAYER-$(S3FB) += libvo/vo_s3fb.c SRCS_MPLAYER-$(SDL) += libao2/ao_sdl.c libvo/vo_sdl.c libvo/sdl_common.c -SRCS_MPLAYER-$(SUNAUDIO) += libao2/ao_sun.c -SRCS_MPLAYER-$(SVGA) += libvo/vo_svga.c -SRCS_MPLAYER-$(TDFXFB) += libvo/vo_tdfxfb.c -SRCS_MPLAYER-$(TDFXVID) += libvo/vo_tdfx_vid.c SRCS_MPLAYER-$(TGA) += libvo/vo_tga.c SRCS_MPLAYER-$(V4L2) += libvo/vo_v4l2.c SRCS_MPLAYER-$(V4L2) += libao2/ao_v4l2.c SRCS_MPLAYER-$(VDPAU) += libvo/vo_vdpau.c -SRCS_MPLAYER-$(VESA) += libvo/gtf.c libvo/vo_vesa.c libvo/vesa_lvo.c -SRCS_MPLAYER-$(WII) += libvo/vo_wii.c -SRCS_MPLAYER-$(WIN32WAVEOUT) += libao2/ao_win32.c -SRCS_MPLAYER-$(X11) += libvo/vo_x11.c libvo/vo_xover.c \ - libvo/x11_common.c -SRCS_MPLAYER-$(XMGA) += libvo/vo_xmga.c +SRCS_MPLAYER-$(X11) += libvo/vo_x11.c libvo/x11_common.c SRCS_MPLAYER-$(XV) += libvo/vo_xv.c -SRCS_MPLAYER-$(XVR100) += libvo/vo_xvr100.c SRCS_MPLAYER-$(YUV4MPEG) += libvo/vo_yuv4mpeg.c SRCS_MPLAYER = command.c \ @@ -497,7 +476,6 @@ SRCS_MPLAYER = command.c \ parser-mpcmd.c \ screenshot.c \ input/input.c \ - libao2/ao_mpegpes.c \ libao2/ao_null.c \ libao2/ao_pcm.c \ libao2/audio_out.c \ @@ -505,9 +483,7 @@ SRCS_MPLAYER = command.c \ libvo/csputils.c \ libvo/geometry.c \ libvo/old_vo_wrapper.c \ - libvo/spuenc.c \ libvo/video_out.c \ - libvo/vo_mpegpes.c \ libvo/vo_null.c \ libvo/vo_png.c \ $(SRCS_MPLAYER-yes) @@ -706,7 +682,7 @@ clean: -$(RM) $(call ADD_ALL_EXESUFS,mplayer) -$(RM) $(MOFILES) -distclean: clean testsclean toolsclean driversclean +distclean: clean testsclean toolsclean -$(RM) -r DOCS/tech/doxygen -$(RM) -r locale -$(RM) config.log config.mak config.h codecs.conf.h version.h TAGS tags @@ -784,42 +760,9 @@ realcodecs: CFLAGS += -g -###### drivers ####### - -KERNEL_INC = /lib/modules/`uname -r`/build/include -KERNEL_VERSION = $(shell grep RELEASE $(KERNEL_INC)/linux/version.h | cut -d'"' -f2) -KERNEL_CFLAGS = -O2 -D__KERNEL__ -DMODULE -Wall -I$(KERNEL_INC) -include $(KERNEL_INC)/linux/modversions.h -KERNEL_OBJS = $(addprefix drivers/, mga_vid.o tdfx_vid.o radeon_vid.o rage128_vid.o) -MODULES_DIR = /lib/modules/$(KERNEL_VERSION)/misc -DRIVER_OBJS = $(KERNEL_OBJS) drivers/mga_vid_test drivers/tdfx_vid_test - -drivers: $(DRIVER_OBJS) - -$(DRIVER_OBJS): CFLAGS = $(KERNEL_CFLAGS) -drivers/mga_vid.o: drivers/mga_vid.c drivers/mga_vid.h -drivers/tdfx_vid.o: drivers/tdfx_vid.c drivers/3dfx.h -drivers/radeon_vid.o drivers/rage128_vid.o: CFLAGS += -fomit-frame-pointer -fno-strict-aliasing -fno-common -ffast-math -drivers/radeon_vid.o: drivers/radeon_vid.c drivers/radeon.h drivers/radeon_vid.h -drivers/rage128_vid.o: drivers/radeon_vid.c drivers/radeon.h drivers/radeon_vid.h - $(CC) $(CFLAGS) -DRAGE128 -c $< -o $@ - -install-drivers: $(DRIVER_OBJS) - -mkdir -p $(MODULES_DIR) - install -m 644 $(KERNEL_OBJS) $(MODULES_DIR) - depmod -a - -mknod /dev/mga_vid c 178 0 - -mknod /dev/tdfx_vid c 178 0 - -mknod /dev/radeon_vid c 178 0 - -ln -s /dev/radeon_vid /dev/rage128_vid - -driversclean: - -$(RM) $(DRIVER_OBJS) drivers/*~ - - - -include $(DEP_FILES) -.PHONY: all doxygen locales *install* *tools drivers +.PHONY: all doxygen locales *install* *tools .PHONY: checkheaders *clean tests .version # Disable suffix rules. Most of the builtin rules are suffix rules, diff --git a/cfg-mplayer.h b/cfg-mplayer.h index d8d556ab7c..2d1666db46 100644 --- a/cfg-mplayer.h +++ b/cfg-mplayer.h @@ -35,9 +35,6 @@ #include "stream/stream_radio.h" #include "libvo/csputils.h" -extern char *fb_mode_cfgfile; -extern char *fb_mode_name; - extern char *lirc_configfile; /* only used at startup (setting these values from configfile) */ @@ -747,17 +744,6 @@ const m_option_t mplayer_opts[]={ {"display", &mDisplayName, CONF_TYPE_STRING, 0, 0, 0, NULL}, #endif -#if defined(CONFIG_FBDEV) || defined(CONFIG_VESA) - {"monitor-hfreq", &monitor_hfreq_str, CONF_TYPE_STRING, 0, 0, 0, NULL}, - {"monitor-vfreq", &monitor_vfreq_str, CONF_TYPE_STRING, 0, 0, 0, NULL}, - {"monitor-dotclock", &monitor_dotclock_str, CONF_TYPE_STRING, 0, 0, 0, NULL}, -#endif - -#ifdef CONFIG_FBDEV - {"fbmode", &fb_mode_name, CONF_TYPE_STRING, 0, 0, 0, NULL}, - {"fbmodeconfig", &fb_mode_cfgfile, CONF_TYPE_STRING, 0, 0, 0, NULL}, -#endif - // force window width/height or resolution (with -vm) OPT_INTRANGE("x", screen_size_x, 0, 0, 4096), OPT_INTRANGE("y", screen_size_y, 0, 0, 4096), diff --git a/configure b/configure index 18bc404e07..a6ba520b62 100755 --- a/configure +++ b/configure @@ -215,7 +215,6 @@ morphos() { issystem "MorphOS"; } netbsd() { issystem "NetBSD"; } openbsd() { issystem "OpenBSD"; } qnx() { issystem "QNX"; } -sunos() { issystem "SunOS"; } win32() { cygwin || mingw32; } # arch test boolean functions @@ -395,23 +394,12 @@ Codecs: Video output: --enable-gl enable OpenGL video output [autodetect] - --enable-dga2 enable DGA 2 support [autodetect] - --enable-dga1 enable DGA 1 support [autodetect] - --enable-vesa enable VESA video output [autodetect] - --enable-svga enable SVGAlib video output [autodetect] --enable-sdl enable SDL video output [autodetect] - --enable-aa enable AAlib video output [autodetect] --enable-caca enable CACA video output [autodetect] - --enable-ggi enable GGI video output [autodetect] - --enable-ggiwmh enable GGI libggiwmh extension [autodetect] --enable-direct3d enable Direct3D video output [autodetect] --enable-directx enable DirectX video output [autodetect] - --enable-dxr3 enable DXR3/H+ video output [autodetect] - --enable-ivtv enable IVTV TV-Out video output [autodetect] --enable-v4l2 enable V4L2 Decoder audio/video output [autodetect] - --enable-dvb enable DVB video output [autodetect] - --enable-mga enable mga_vid video output [autodetect] - --enable-xmga enable mga_vid X11 video output [autodetect] + --enable-dvb enable DVB video input [autodetect] --enable-xv enable Xv video output [autodetect] --enable-vdpau enable VDPAU acceleration [autodetect] --enable-vm enable XF86VidMode support [autodetect] @@ -419,15 +407,7 @@ Video output: --enable-x11 enable X11 video output [autodetect] --enable-xshape enable XShape support [autodetect] --disable-xss disable screensaver support via xss [autodetect] - --enable-fbdev enable FBDev video output [autodetect] - --enable-3dfx enable obsolete /dev/3dfx video output [disable] - --enable-tdfxfb enable tdfxfb video output [disable] - --enable-s3fb enable s3fb (S3 ViRGE) video output [disable] - --enable-wii enable Nintendo Wii/GameCube video output [disable] --enable-directfb enable DirectFB video output [autodetect] - --enable-bl enable Blinkenlights video output [disable] - --enable-tdfxvid enable tdfx_vid video output [disable] - --enable-xvr100 enable SUN XVR-100 video output [autodetect] --disable-tga disable Targa video output [enable] --disable-pnm disable PNM video output [enable] --disable-md5sum disable md5sum video output [enable] @@ -444,9 +424,6 @@ Audio output: --disable-portaudio disable PortAudio audio output [autodetect] --disable-jack disable JACK audio output [autodetect] --enable-openal enable OpenAL audio output [disable] - --disable-nas disable NAS audio output [autodetect] - --disable-sunaudio disable Sun audio output [autodetect] - --disable-win32waveout disable Windows waveout audio output [autodetect] --disable-coreaudio disable CoreAudio audio output [autodetect] --disable-select disable using select() on the audio device [enable] @@ -563,14 +540,11 @@ _mplayer=yes _x11=auto _xshape=auto _xss=auto -_dga1=auto -_dga2=auto _xv=auto _vdpau=auto _sdl=auto _direct3d=auto _directx=auto -_win32waveout=auto _nas=auto _png=auto _mng=auto @@ -580,16 +554,9 @@ _md5sum=yes _yuv4mpeg=yes _gif=auto _gl=auto -_ggi=auto -_ggiwmh=auto _aa=auto _caca=auto -_svga=auto -_vesa=auto -_fbdev=auto _dvb=auto -_dxr3=auto -_ivtv=auto _v4l2=auto _iconv=auto _langinfo=auto @@ -627,11 +594,8 @@ _live=no _nemesi=auto _native_rtsp=yes _xinerama=auto -_mga=auto -_xmga=auto _vm=auto _xf86keysym=auto -_sunaudio=auto _alsa=auto _fastmemcpy=yes _unrar_exec=auto @@ -661,15 +625,8 @@ _apple_remote=auto _apple_ir=auto _termcap=auto _termios=auto -_3dfx=no -_s3fb=no -_wii=no -_tdfxfb=no -_tdfxvid=no -_xvr100=auto _tga=yes _directfb=auto -_bl=no #language=en _shm=auto _translation=no @@ -857,10 +814,6 @@ for ac_option do --disable-direct3d) _direct3d=no ;; --enable-directx) _directx=yes ;; --disable-directx) _directx=no ;; - --enable-win32waveout) _win32waveout=yes ;; - --disable-win32waveout) _win32waveout=no ;; - --enable-nas) _nas=yes ;; - --disable-nas) _nas=no ;; --enable-png) _png=yes ;; --disable-png) _png=no ;; --enable-mng) _mng=yes ;; @@ -877,26 +830,10 @@ for ac_option do --disable-gif) _gif=no ;; --enable-gl) _gl=yes ;; --disable-gl) _gl=no ;; - --enable-ggi) _ggi=yes ;; - --disable-ggi) _ggi=no ;; - --enable-ggiwmh) _ggiwmh=yes ;; - --disable-ggiwmh) _ggiwmh=no ;; - --enable-aa) _aa=yes ;; - --disable-aa) _aa=no ;; --enable-caca) _caca=yes ;; --disable-caca) _caca=no ;; - --enable-svga) _svga=yes ;; - --disable-svga) _svga=no ;; - --enable-vesa) _vesa=yes ;; - --disable-vesa) _vesa=no ;; - --enable-fbdev) _fbdev=yes ;; - --disable-fbdev) _fbdev=no ;; --enable-dvb) _dvb=yes ;; --disable-dvb) _dvb=no ;; - --enable-dxr3) _dxr3=yes ;; - --disable-dxr3) _dxr3=no ;; - --enable-ivtv) _ivtv=yes ;; - --disable-ivtv) _ivtv=no ;; --enable-v4l2) _v4l2=yes ;; --disable-v4l2) _v4l2=no ;; --enable-iconv) _iconv=yes ;; @@ -969,16 +906,10 @@ for ac_option do --disable-nemesi) _nemesi=no ;; --enable-xinerama) _xinerama=yes ;; --disable-xinerama) _xinerama=no ;; - --enable-mga) _mga=yes ;; - --disable-mga) _mga=no ;; - --enable-xmga) _xmga=yes ;; - --disable-xmga) _xmga=no ;; --enable-vm) _vm=yes ;; --disable-vm) _vm=no ;; --enable-xf86keysym) _xf86keysym=yes ;; --disable-xf86keysym) _xf86keysym=no ;; - --enable-sunaudio) _sunaudio=yes ;; - --disable-sunaudio) _sunaudio=no ;; --enable-alsa) _alsa=yes ;; --disable-alsa) _alsa=no ;; --enable-tv) _tv=yes ;; @@ -1035,24 +966,10 @@ for ac_option do --disable-termcap) _termcap=no ;; --enable-termios) _termios=yes ;; --disable-termios) _termios=no ;; - --enable-3dfx) _3dfx=yes ;; - --disable-3dfx) _3dfx=no ;; - --enable-s3fb) _s3fb=yes ;; - --disable-s3fb) _s3fb=no ;; - --enable-wii) _wii=yes ;; - --disable-wii) _wii=no ;; - --enable-tdfxfb) _tdfxfb=yes ;; - --disable-tdfxfb) _tdfxfb=no ;; - --disable-tdfxvid) _tdfxvid=no ;; - --enable-tdfxvid) _tdfxvid=yes ;; - --disable-xvr100) _xvr100=no ;; - --enable-xvr100) _xvr100=yes ;; --disable-tga) _tga=no ;; --enable-tga) _tga=yes ;; --enable-directfb) _directfb=yes ;; --disable-directfb) _directfb=no ;; - --enable-bl) _bl=yes ;; - --disable-bl) _bl=no ;; --enable-shm) _shm=yes ;; --disable-shm) _shm=no ;; --enable-select) _select=yes ;; @@ -1096,11 +1013,6 @@ for ac_option do --enable-gethostbyname2) _gethostbyname2=yes ;; --disable-gethostbyname2) _gethostbyname2=no ;; - --enable-dga1) _dga1=yes ;; - --disable-dga1) _dga1=no ;; - --enable-dga2) _dga2=yes ;; - --disable-dga2) _dga2=no ;; - --enable-qtx) _qtx=yes ;; --disable-qtx) _qtx=no ;; @@ -1235,7 +1147,7 @@ if test -z "$_target" ; then # OS name system_name=$(uname -s 2>&1) case "$system_name" in - Linux|FreeBSD|NetBSD|OpenBSD|DragonFly|BSD/OS|Darwin|SunOS|QNX|GNU|BeOS|MorphOS|AIX|AmigaOS) + Linux|FreeBSD|NetBSD|OpenBSD|DragonFly|BSD/OS|Darwin|QNX|GNU|BeOS|MorphOS|AIX|AmigaOS) ;; Haiku) system_name=BeOS @@ -1307,7 +1219,6 @@ else # if test -z "$_target" bsd/os) system_name=BSD/OS ;; openbsd) system_name=OpenBSD ;; dragonfly) system_name=DragonFly ;; - sunos) system_name=SunOS ;; qnx) system_name=QNX ;; morphos) system_name=MorphOS ;; amigaos) system_name=AmigaOS ;; @@ -1444,14 +1355,6 @@ else break fi cc_name_tmp=$($_cc -V 2>&1 | head -n 1 | cut -d ' ' -f 2,3) - if test "$cc_name_tmp" = "Sun C"; then - echocheck "$_cc version" - cc_vendor=sun - cc_version=$($_cc -V 2>&1 | head -n 1 | cut -d ' ' -f 4) - res_comment="experimental support only" - echores "Sun C $cc_version" - break - fi done fi # icc test "$cc_fail" = yes && die "unsupported compiler version" @@ -1945,19 +1848,6 @@ case "$host_arch" in _vis='yes' proc='ultrasparc' def_fast_64bit='#define HAVE_FAST_64BIT 1' - elif sunos ; then - echocheck "CPU type" - karch=$(uname -m) - case "$(echo $karch)" in - sun4) proc=v7 ;; - sun4c) proc=v7 ;; - sun4d) proc=v8 ;; - sun4m) proc=v8 ;; - sun4u) proc=ultrasparc _vis='yes' ;; - sun4v) proc=v9 ;; - *) proc=v8 ;; - esac - echores "$proc" else proc=v8 fi @@ -2277,8 +2167,6 @@ if test -z "$CFLAGS" ; then if test "$cc_vendor" = "intel" ; then CFLAGS="-O2 $_debug $_profile $_march $_mcpu $_pipe -fomit-frame-pointer" WARNFLAGS="-wd167 -wd556 -wd144" - elif test "$cc_vendor" = "sun" ; then - CFLAGS="-O2 $_debug $_profile $_march $_mcpu $_pipe -xc99 -xregs=frameptr" elif test "$cc_vendor" = "clang"; then CFLAGS="-O2 $_debug $_profile $_march $_pipe" WARNFLAGS="-Wall -Wno-switch-enum -Wno-logical-op-parentheses -Wpointer-arith -Wundef -Wno-pointer-sign -Wmissing-prototypes" @@ -3296,21 +3184,6 @@ echores "$_hpux_scsi_h" fi #if hpux -if sunos; then -echocheck "userspace SCSI headers (Solaris)" -_sol_scsi_h=no -header_check sys/scsi/scsi_types.h && - header_check_broken sys/types.h sys/scsi/impl/uscsi.h && - _sol_scsi_h=yes -if test "$_sol_scsi_h" = yes ; then - def_sol_scsi_h='#define SOLARIS_USCSI 1' -else - def_sol_scsi_h='#undef SOLARIS_USCSI' -fi -echores "$_sol_scsi_h" -fi #if sunos - - echocheck "termcap" if test "$_termcap" = auto ; then _termcap=no @@ -3484,20 +3357,6 @@ statement_check io.h 'setmode(0, 0)' && _setmode=yes && def_setmode='#define HAV echores "$_setmode" -if sunos; then -echocheck "sysi86()" -_sysi86=no -statement_check sys/sysi86.h 'sysi86(0)' && _sysi86=yes -if test "$_sysi86" = yes ; then - def_sysi86='#define HAVE_SYSI86 1' - statement_check sys/sysi86.h 'int sysi86(int, void*); sysi86(0)' && def_sysi86_iv='#define HAVE_SYSI86_iv 1' -else - def_sysi86='#undef HAVE_SYSI86' -fi -echores "$_sysi86" -fi #if sunos - - echocheck "sys/sysinfo.h" _sys_sysinfo=no statement_check sys/sysinfo.h 'struct sysinfo s_info; s_info.mem_unit=0; sysinfo(&s_info)' && _sys_sysinfo=yes @@ -3633,72 +3492,6 @@ echores "$_libquvi" ######### -echocheck "tdfxfb" -if test "$_tdfxfb" = yes ; then - def_tdfxfb='#define CONFIG_TDFXFB 1' - vomodules="tdfxfb $vomodules" -else - def_tdfxfb='#undef CONFIG_TDFXFB' - novomodules="tdfxfb $novomodules" -fi -echores "$_tdfxfb" - -echocheck "s3fb" -if test "$_s3fb" = yes ; then - def_s3fb='#define CONFIG_S3FB 1' - vomodules="s3fb $vomodules" -else - def_s3fb='#undef CONFIG_S3FB' - novomodules="s3fb $novomodules" -fi -echores "$_s3fb" - -echocheck "wii" -if test "$_wii" = yes ; then - def_wii='#define CONFIG_WII 1' - vomodules="wii $vomodules" -else - def_wii='#undef CONFIG_WII' - novomodules="wii $novomodules" -fi -echores "$_wii" - -echocheck "tdfxvid" -if test "$_tdfxvid" = yes ; then - def_tdfxvid='#define CONFIG_TDFX_VID 1' - vomodules="tdfx_vid $vomodules" -else - def_tdfxvid='#undef CONFIG_TDFX_VID' - novomodules="tdfx_vid $novomodules" -fi -echores "$_tdfxvid" - -echocheck "xvr100" -if test "$_xvr100" = auto ; then -cat > $TMPC << EOF -#include -#include -#include -int main(void) { -struct vis_identifier ident; -struct fbgattr attr; -ioctl(0, VIS_GETIDENTIFIER, &ident); -ioctl(0, FBIOGATTR, &attr); -return 0; -} -EOF - _xvr100=no - cc_check && _xvr100=yes -fi -if test "$_xvr100" = yes ; then - def_xvr100='#define CONFIG_XVR100 1' - vomodules="xvr100 $vomodules" -else - def_tdfxvid='#undef CONFIG_XVR100' - novomodules="xvr100 $novomodules" -fi -echores "$_xvr100" - echocheck "tga" if test "$_tga" = yes ; then def_tga='#define CONFIG_TGA 1' @@ -3732,17 +3525,6 @@ fi echores "$_yuv4mpeg" -echocheck "bl" -if test "$_bl" = yes ; then - def_bl='#define CONFIG_BL 1' - vomodules="bl $vomodules" -else - def_bl='#undef CONFIG_BL' - novomodules="bl $novomodules" -fi -echores "$_bl" - - echocheck "DirectFB" if test "$_directfb" = auto ; then _directfb=no @@ -3761,11 +3543,11 @@ EOF fi if test "$_directfb" = yes ; then def_directfb='#define CONFIG_DIRECTFB 1' - vomodules="directfb dfbmga $vomodules" + vomodules="directfb $vomodules" libs_mplayer="$libs_mplayer -ldirectfb" else def_directfb='#undef CONFIG_DIRECTFB' - novomodules="directfb dfbmga $novomodules" + novomodules="directfb $novomodules" fi echores "$_directfb" @@ -3904,7 +3686,7 @@ if test "$_x11" = auto && test "$_x11_headers" = yes ; then fi if test "$_x11" = yes ; then def_x11='#define CONFIG_X11 1' - vomodules="x11 xover $vomodules" + vomodules="x11 $vomodules" else _x11=no def_x11='#undef CONFIG_X11' @@ -4039,113 +3821,6 @@ else fi echores "$_xf86keysym" -echocheck "DGA" -if test "$_dga2" = auto && test "$_x11" = yes ; then - _dga2=no - statement_check_broken X11/Xlib.h X11/extensions/Xxf86dga.h 'XDGASetViewport(0, 0, 0, 0, 0)' -lXxf86dga && _dga2=yes -fi -if test "$_dga1" = auto && test "$_dga2" = no && test "$_vm" = yes ; then - _dga1=no - statement_check_broken X11/Xlib.h X11/extensions/Xxf86dga.h 'XF86DGASetViewPort(0, 0, 0, 0)' -lXxf86dga -lXxf86vm && _dga1=yes -fi - -_dga=no -def_dga='#undef CONFIG_DGA' -def_dga1='#undef CONFIG_DGA1' -def_dga2='#undef CONFIG_DGA2' -if test "$_dga1" = yes ; then - _dga=yes - def_dga1='#define CONFIG_DGA1 1' - res_comment="using DGA 1.0" -elif test "$_dga2" = yes ; then - _dga=yes - def_dga2='#define CONFIG_DGA2 1' - res_comment="using DGA 2.0" -fi -if test "$_dga" = yes ; then - def_dga='#define CONFIG_DGA 1' - libs_mplayer="$libs_mplayer -lXxf86dga" - vomodules="dga $vomodules" -else - novomodules="dga $novomodules" -fi -echores "$_dga" - - -echocheck "3dfx" -if test "$_3dfx" = yes && test "$_dga" = yes ; then - def_3dfx='#define CONFIG_3DFX 1' - vomodules="3dfx $vomodules" -else - _3dfx=no - def_3dfx='#undef CONFIG_3DFX' - novomodules="3dfx $novomodules" -fi -echores "$_3dfx" - - -echocheck "GGI" -if test "$_ggi" = auto ; then - _ggi=no - statement_check ggi/ggi.h 'ggiInit()' -lggi && _ggi=yes -fi -if test "$_ggi" = yes ; then - def_ggi='#define CONFIG_GGI 1' - libs_mplayer="$libs_mplayer -lggi" - vomodules="ggi $vomodules" -else - def_ggi='#undef CONFIG_GGI' - novomodules="ggi $novomodules" -fi -echores "$_ggi" - -echocheck "GGI extension: libggiwmh" -if test "$_ggiwmh" = auto ; then - _ggiwmh=no - statement_check ggi/wmh.h 'ggiWmhInit()' -lggi -lggiwmh && _ggiwmh=yes -fi -# needed to get right output on obscure combination -# like --disable-ggi --enable-ggiwmh -if test "$_ggi" = yes && test "$_ggiwmh" = yes ; then - def_ggiwmh='#define CONFIG_GGIWMH 1' - libs_mplayer="$libs_mplayer -lggiwmh" -else - _ggiwmh=no - def_ggiwmh='#undef CONFIG_GGIWMH' -fi -echores "$_ggiwmh" - - -echocheck "AA" -if test "$_aa" = auto ; then - cat > $TMPC << EOF -#include -int main(void) { -aa_context *c; -aa_renderparams *p; -aa_init(0, 0, 0); -c = aa_autoinit(&aa_defparams); -p = aa_getrenderparams(); -aa_autoinitkbd(c, 0); -return 0; } -EOF - _aa=no - for _ld_tmp in "-laa" ; do - cc_check $_ld_tmp && libs_mplayer="$libs_mplayer $_ld_tmp" && _aa=yes && break - done -fi -if test "$_aa" = yes ; then - def_aa='#define CONFIG_AA 1' - if cygwin ; then - libs_mplayer="$libs_mplayer $(aalib-config --libs | cut -d " " -f 2,5,6)" - fi - vomodules="aa $vomodules" -else - def_aa='#undef CONFIG_AA' - novomodules="aa $novomodules" -fi -echores "$_aa" - echocheck "CACA" if test "$_caca" = auto ; then @@ -4173,38 +3848,6 @@ fi echores "$_caca" -echocheck "SVGAlib" -if test "$_svga" = auto ; then - _svga=no - header_check vga.h -lvga $_ld_lm && _svga=yes -fi -if test "$_svga" = yes ; then - def_svga='#define CONFIG_SVGALIB 1' - libs_mplayer="$libs_mplayer -lvga" - vomodules="svga $vomodules" -else - def_svga='#undef CONFIG_SVGALIB' - novomodules="svga $novomodules" -fi -echores "$_svga" - - -echocheck "FBDev" -if test "$_fbdev" = auto ; then - _fbdev=no - linux && _fbdev=yes -fi -if test "$_fbdev" = yes ; then - def_fbdev='#define CONFIG_FBDEV 1' - vomodules="fbdev $vomodules" -else - def_fbdev='#undef CONFIG_FBDEV' - novomodules="fbdev $novomodules" -fi -echores "$_fbdev" - - - echocheck "DVB" if test "$_dvb" = auto ; then _dvb=no @@ -4229,17 +3872,11 @@ echores "$_dvb" if test "$_dvb" = yes ; then _dvbin=yes inputmodules="dvb $inputmodules" - def_dvb='#define CONFIG_DVB 1' def_dvbin='#define CONFIG_DVBIN 1' - aomodules="mpegpes(dvb) $aomodules" - vomodules="mpegpes(dvb) $vomodules" else _dvbin=no noinputmodules="dvb $noinputmodules" - def_dvb='#undef CONFIG_DVB' def_dvbin='#undef CONFIG_DVBIN ' - aomodules="mpegpes(file) $aomodules" - vomodules="mpegpes(file) $vomodules" fi @@ -4396,21 +4033,6 @@ EOF esac -echocheck "VESA support" -if test "$_vesa" = auto ; then - _vesa=no - statement_check vbe.h 'vbeInit()' -lvbe -llrmi && _vesa=yes -fi -if test "$_vesa" = yes ; then - def_vesa='#define CONFIG_VESA 1' - libs_mplayer="$libs_mplayer -lvbe -llrmi" - vomodules="vesa $vomodules" -else - def_vesa='#undef CONFIG_VESA' - novomodules="vesa $novomodules" -fi -echores "$_vesa" - ################# # VIDEO + AUDIO # ################# @@ -4595,21 +4217,6 @@ echores "$_gl" if win32; then -echocheck "Windows waveout" -if test "$_win32waveout" = auto ; then - _win32waveout=no - header_check_broken windows.h mmsystem.h -lwinmm && _win32waveout=yes -fi -if test "$_win32waveout" = yes ; then - def_win32waveout='#define CONFIG_WIN32WAVEOUT 1' - libs_mplayer="$libs_mplayer -lwinmm" - aomodules="win32 $aomodules" -else - def_win32waveout='#undef CONFIG_WIN32WAVEOUT' - noaomodules="win32 $noaomodules" -fi -echores "$_win32waveout" - echocheck "Direct3D" if test "$_direct3d" = auto ; then _direct3d=no @@ -4649,50 +4256,6 @@ echores "$_directx" fi #if win32; then -echocheck "DXR3/H+" -if test "$_dxr3" = auto ; then - _dxr3=no - header_check linux/em8300.h && _dxr3=yes -fi -if test "$_dxr3" = yes ; then - def_dxr3='#define CONFIG_DXR3 1' - vomodules="dxr3 $vomodules" -else - def_dxr3='#undef CONFIG_DXR3' - novomodules="dxr3 $novomodules" -fi -echores "$_dxr3" - - -echocheck "IVTV TV-Out (pre linux-2.6.24)" -if test "$_ivtv" = auto ; then - cat > $TMPC << EOF -#include -#include -#include -#include -int main(void) { -struct ivtv_cfg_stop_decode sd; -struct ivtv_cfg_start_decode sd1; -ioctl(0, IVTV_IOC_START_DECODE, &sd1); -ioctl(0, IVTV_IOC_STOP_DECODE, &sd); -return 0; } -EOF - _ivtv=no - cc_check && _ivtv=yes -fi -if test "$_ivtv" = yes ; then - def_ivtv='#define CONFIG_IVTV 1' - vomodules="ivtv $vomodules" - aomodules="ivtv $aomodules" -else - def_ivtv='#undef CONFIG_IVTV' - novomodules="ivtv $novomodules" - noaomodules="ivtv $noaomodules" -fi -echores "$_ivtv" - - echocheck "V4L2 MPEG Decoder" if test "$_v4l2" = auto ; then cat > $TMPC << EOF @@ -4791,22 +4354,6 @@ else fi -echocheck "NAS" -if test "$_nas" = auto ; then - _nas=no - header_check audio/audiolib.h $_ld_lm -laudio -lXt && _nas=yes -fi -if test "$_nas" = yes ; then - def_nas='#define CONFIG_NAS 1' - libs_mplayer="$libs_mplayer -laudio -lXt" - aomodules="nas $aomodules" -else - noaomodules="nas $noaomodules" - def_nas='#undef CONFIG_NAS' -fi -echores "$_nas" - - echocheck "pulse" if test "$_pulse" = auto ; then _pulse=no @@ -4913,26 +4460,6 @@ fi echores "$_alsa" -echocheck "Sun audio" -if test "$_sunaudio" = auto ; then - cat > $TMPC << EOF -#include -#include -int main(void) { audio_info_t info; AUDIO_INITINFO(&info); return 0; } -EOF - _sunaudio=no - cc_check && _sunaudio=yes -fi -if test "$_sunaudio" = yes ; then - def_sunaudio='#define CONFIG_SUN_AUDIO 1' - aomodules="sun $aomodules" -else - def_sunaudio='#undef CONFIG_SUN_AUDIO' - noaomodules="sun $noaomodules" -fi -echores "$_sunaudio" - - if darwin; then echocheck "CoreAudio" if test "$_coreaudio" = auto ; then @@ -4968,18 +4495,13 @@ elif freebsd ; then default_cdrom_device="/dev/acd0" elif openbsd ; then default_cdrom_device="/dev/rcd0c" -elif sunos ; then - default_cdrom_device="/vol/dev/aliases/cdrom0" - # Modern Solaris versions use HAL instead of the vold daemon, the volfs - # file system and the volfs service. - test -r "/cdrom/cdrom0" && default_cdrom_device="/cdrom/cdrom0" elif amigaos ; then default_cdrom_device="a1ide.device:2" else default_cdrom_device="/dev/cdrom" fi -if win32 || dragonfly || freebsd || openbsd || sunos || amigaos ; then +if win32 || dragonfly || freebsd || openbsd || amigaos ; then default_dvd_device=$default_cdrom_device elif darwin ; then default_dvd_device="/dev/rdiskN" @@ -4991,7 +4513,7 @@ fi echocheck "VCD support" if test "$_vcd" = auto; then _vcd=no - if linux || freebsd || netbsd || openbsd || dragonfly || bsdos || darwin || sunos; then + if linux || freebsd || netbsd || openbsd || dragonfly || bsdos || darwin ; then _vcd=yes elif mingw32; then header_check ddk/ntddcdrm.h && _vcd=yes @@ -5030,7 +4552,7 @@ fi if test "$_dvdread_internal" = auto ; then _dvdread_internal=no _dvdread=no - if (linux || freebsd || netbsd || openbsd || dragonfly || sunos || hpux) && + if (linux || freebsd || netbsd || openbsd || dragonfly || hpux) && (test "$_dvd" = yes || test "$_cdrom" = yes || test "$_cdio" = yes || test "$_dvdio" = yes || test "$_bsdi_dvd" = yes) || darwin || win32; then @@ -5713,36 +5235,6 @@ else fi echores "$_libnut" -# These VO checks must be done after the FFmpeg one -echocheck "/dev/mga_vid" -if test "$_mga" = auto ; then - _mga=no - test -c /dev/mga_vid && _mga=yes -fi -if test "$_mga" = yes ; then - def_mga='#define CONFIG_MGA 1' - vomodules="mga $vomodules" -else - def_mga='#undef CONFIG_MGA' - novomodules="mga $novomodules" -fi -echores "$_mga" - - -echocheck "xmga" -if test "$_xmga" = auto ; then - _xmga=no - test "$_x11" = yes && test "$_mga" = yes && _xmga=yes -fi -if test "$_xmga" = yes ; then - def_xmga='#define CONFIG_XMGA 1' - vomodules="xmga $vomodules" -else - def_xmga='#undef CONFIG_XMGA' - novomodules="xmga $novomodules" -fi -echores "$_xmga" - echocheck "UnRAR executable" if test "$_unrar_exec" = auto ; then @@ -6105,7 +5597,7 @@ fi # (FIXME: 'echocheck "dynamic linking"' above and modify here accordingly) _ld_dl_dynamic='' freebsd || netbsd || openbsd || dragonfly || bsdos && _ld_dl_dynamic='-rdynamic' -if test "$_real" = yes || test "$_xanim" = yes && ! win32 && ! qnx && ! darwin && ! sunos; then +if test "$_real" = yes || test "$_xanim" = yes && ! win32 && ! qnx && ! darwin ; then _ld_dl_dynamic='-rdynamic' fi @@ -6286,14 +5778,11 @@ NEED_SWAB = $need_swab NEED_VSSCANF = $need_vsscanf # features -3DFX = $_3dfx -AA = $_aa ALSA = $_alsa APPLE_IR = $_apple_ir APPLE_REMOTE = $_apple_remote AUDIO_INPUT = $_audio_input BITMAP_FONT = $_bitmap_font -BL = $_bl CACA = $_caca CDDA = $_cdda CDDB = $_cddb @@ -6301,7 +5790,6 @@ COCOA = $_cocoa COREAUDIO = $_coreaudio COREVIDEO = $_corevideo SHAREDBUFFER = $_sharedbuffer -DGA = $_dga DIRECT3D = $_direct3d DIRECTFB = $_directfb DIRECTX = $_directx @@ -6313,11 +5801,9 @@ DVDREAD_INTERNAL = $_dvdread_internal DXR3 = $_dxr3 FAAD = $_faad FASTMEMCPY = $_fastmemcpy -FBDEV = $_fbdev FREETYPE = $_freetype FTP = $_ftp GIF = $_gif -GGI = $_ggi GL = $_gl GL_COCOA = $_gl_cocoa GL_WIN32 = $_gl_win32 @@ -6325,7 +5811,6 @@ GL_X11 = $_gl_x11 GL_SDL = $_gl_sdl HAVE_POSIX_SELECT = $_posix_select HAVE_SYS_MMAN_H = $_mman -IVTV = $_ivtv JACK = $_jack JOYSTICK = $_joystick JPEG = $_jpeg @@ -6348,11 +5833,9 @@ LIRC = $_lirc LIVE555 = $_live MACOSX_FINDER = $_macosx_finder MD5SUM = $_md5sum -MGA = $_mga MNG = $_mng MPG123 = $_mpg123 MUSEPACK = $_musepack -NAS = $_nas NATIVE_RTSP = $_native_rtsp NETWORKING = $networking OPENAL = $_openal @@ -6371,14 +5854,9 @@ RADIO=$_radio RADIO_CAPTURE=$_radio_capture REAL_CODECS = $_real RSOUND = $_rsound -S3FB = $_s3fb SDL = $_sdl SPEEX = $_speex STREAM_CACHE = $_stream_cache -SUNAUDIO = $_sunaudio -SVGA = $_svga -TDFXFB = $_tdfxfb -TDFXVID = $_tdfxvid TGA = $_tga TV = $_tv TV_BSDBT848 = $_tv_bsdbt848 @@ -6390,20 +5868,15 @@ UNRAR_EXEC = $_unrar_exec V4L2 = $_v4l2 VCD = $_vcd VDPAU = $_vdpau -VESA = $_vesa VORBIS = $_vorbis VSTREAM = $_vstream -WII = $_wii WIN32DLL = $_win32dll -WIN32WAVEOUT = $_win32waveout WIN32_EMULATION = $_win32_emulation X11 = $_x11 XANIM_CODECS = $_xanim -XMGA = $_xmga XMMS_PLUGINS = $_xmms XV = $_xv XVID4 = $_xvid -XVR100 = $_xvr100 YUV4MPEG = $_yuv4mpeg # FFmpeg @@ -6638,8 +6111,6 @@ $def_ossaudio_devmixer $def_pulse $def_portaudio $def_rsound -$def_sunaudio -$def_win32waveout $def_ladspa $def_libbs2b @@ -6692,25 +6163,14 @@ $def_vstream /* libvo options */ -$def_3dfx -$def_aa -$def_bl $def_caca $def_corevideo $def_cocoa $def_sharedbuffer -$def_dga -$def_dga1 -$def_dga2 $def_direct3d $def_directfb $def_directx -$def_dvb $def_dvbin -$def_dxr3 -$def_fbdev -$def_ggi -$def_ggiwmh $def_gif $def_gif_4 $def_gif_tvt_hack @@ -6719,33 +6179,23 @@ $def_gl_cocoa $def_gl_win32 $def_gl_x11 $def_gl_sdl -$def_ivtv $def_jpeg $def_md5sum -$def_mga $def_mng $def_png $def_pnm -$def_s3fb $def_sdl $def_sdl_sdl_h -$def_svga -$def_tdfxfb -$def_tdfxvid $def_tga $def_v4l2 $def_vdpau -$def_vesa $def_vm -$def_wii $def_x11 $def_xdpms $def_xf86keysym $def_xinerama -$def_xmga $def_xss $def_xv -$def_xvr100 $def_yuv4mpeg diff --git a/drivers/3dfx.h b/drivers/3dfx.h deleted file mode 100644 index 159327d482..0000000000 --- a/drivers/3dfx.h +++ /dev/null @@ -1,374 +0,0 @@ -/* - * Copyright (C) Colin Cross Apr 2000 - * changed by zsteva Aug/Sep 2001, see vo_3dfx.c - * - * This file is part of MPlayer. - * - * MPlayer is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * MPlayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef MPLAYER_3DFX_H -#define MPLAYER_3DFX_H - -#define VOODOO_IO_REG_OFFSET ((unsigned long int)0x0000000) -#define VOODOO_YUV_REG_OFFSET ((unsigned long int)0x0080100) -#define VOODOO_AGP_REG_OFFSET ((unsigned long int)0x0080000) -#define VOODOO_2D_REG_OFFSET ((unsigned long int)0x0100000) -#define VOODOO_YUV_PLANE_OFFSET ((unsigned long int)0x0C00000) - -#define VOODOO_BLT_FORMAT_YUYV (8<<16) -#define VOODOO_BLT_FORMAT_UYVY (9<<16) -#define VOODOO_BLT_FORMAT_16 (3<<16) -#define VOODOO_BLT_FORMAT_24 (4<<16) -#define VOODOO_BLT_FORMAT_32 (5<<16) - -#define VOODOO_YUV_STRIDE (1024>>2) - -struct voodoo_yuv_fb_t { - uint32_t Y[0x0040000]; - uint32_t U[0x0040000]; - uint32_t V[0x0040000]; -}; - -struct voodoo_yuv_reg_t { - uint32_t yuvBaseAddr; - uint32_t yuvStride; -}; - -struct voodoo_2d_reg_t { - uint32_t status; - uint32_t intCtrl; - uint32_t clip0Min; - uint32_t clip0Max; - uint32_t dstBaseAddr; - uint32_t dstFormat; - uint32_t srcColorkeyMin; - uint32_t srcColorkeyMax; - uint32_t dstColorkeyMin; - uint32_t dstColorkeyMax; - signed long bresError0; - signed long bresError1; - uint32_t rop; - uint32_t srcBaseAddr; - uint32_t commandExtra; - uint32_t lineStipple; - uint32_t lineStyle; - uint32_t pattern0Alias; - uint32_t pattern1Alias; - uint32_t clip1Min; - uint32_t clip1Max; - uint32_t srcFormat; - uint32_t srcSize; - uint32_t srcXY; - uint32_t colorBack; - uint32_t colorFore; - uint32_t dstSize; - uint32_t dstXY; - uint32_t command; - uint32_t RESERVED1; - uint32_t RESERVED2; - uint32_t RESERVED3; - uint8_t launchArea[128]; -}; - - -struct voodoo_io_reg_t { - uint32_t status; - uint32_t pciInit0; - uint32_t sipMonitor; - uint32_t lfbMemoryConfig; - uint32_t miscInit0; - uint32_t miscInit1; - uint32_t dramInit0; - uint32_t dramInit1; - uint32_t agpInit; - uint32_t tmuGbeInit; - uint32_t vgaInit0; - uint32_t vgaInit1; - uint32_t dramCommand; - uint32_t dramData; - uint32_t RESERVED1; - uint32_t RESERVED2; - - uint32_t pllCtrl0; - uint32_t pllCtrl1; - uint32_t pllCtrl2; - uint32_t dacMode; - uint32_t dacAddr; - uint32_t dacData; - - uint32_t rgbMaxDelta; - uint32_t vidProcCfg; - uint32_t hwCurPatAddr; - uint32_t hwCurLoc; - uint32_t hwCurC0; - uint32_t hwCurC1; - uint32_t vidInFormat; - uint32_t vidInStatus; - uint32_t vidSerialParallelPort; - uint32_t vidInXDecimDeltas; - uint32_t vidInDecimInitErrs; - uint32_t vidInYDecimDeltas; - uint32_t vidPixelBufThold; - uint32_t vidChromaMin; - uint32_t vidChromaMax; - uint32_t vidCurrentLine; - uint32_t vidScreenSize; - uint32_t vidOverlayStartCoords; - uint32_t vidOverlayEndScreenCoord; - uint32_t vidOverlayDudx; - uint32_t vidOverlayDudxOffsetSrcWidth; - uint32_t vidOverlayDvdy; - - uint32_t vga_registers_not_mem_mapped[12]; - uint32_t vidOverlayDvdyOffset; - uint32_t vidDesktopStartAddr; - uint32_t vidDesktopOverlayStride; - uint32_t vidInAddr0; - uint32_t vidInAddr1; - uint32_t vidInAddr2; - uint32_t vidInStride; - uint32_t vidCurrOverlayStartAddr; -}; - - -struct pioData_t { - short port; - short size; - int device; - void *value; -}; - -typedef struct pioData_t pioData; -typedef struct voodoo_2d_reg_t voodoo_2d_reg; -typedef struct voodoo_io_reg_t voodoo_io_reg; -typedef struct voodoo_yuv_reg_t voodoo_yuv_reg; -typedef struct voodoo_yuv_fb_t voodoo_yuv_fb; - - -/* from linux/driver/video/tdfxfb.c, definition for 3dfx registers. - * - * author: Hannu Mallat - */ - -#ifndef PCI_DEVICE_ID_3DFX_VOODOO5 -#define PCI_DEVICE_ID_3DFX_VOODOO5 0x0009 -#endif - -/* membase0 register offsets */ -#define STATUS 0x00 -#define PCIINIT0 0x04 -#define SIPMONITOR 0x08 -#define LFBMEMORYCONFIG 0x0c -#define MISCINIT0 0x10 -#define MISCINIT1 0x14 -#define DRAMINIT0 0x18 -#define DRAMINIT1 0x1c -#define AGPINIT 0x20 -#define TMUGBEINIT 0x24 -#define VGAINIT0 0x28 -#define VGAINIT1 0x2c -#define DRAMCOMMAND 0x30 -#define DRAMDATA 0x34 -/* reserved 0x38 */ -/* reserved 0x3c */ -#define PLLCTRL0 0x40 -#define PLLCTRL1 0x44 -#define PLLCTRL2 0x48 -#define DACMODE 0x4c -#define DACADDR 0x50 -#define DACDATA 0x54 -#define RGBMAXDELTA 0x58 -#define VIDPROCCFG 0x5c -#define HWCURPATADDR 0x60 -#define HWCURLOC 0x64 -#define HWCURC0 0x68 -#define HWCURC1 0x6c -#define VIDINFORMAT 0x70 -#define VIDINSTATUS 0x74 -#define VIDSERPARPORT 0x78 -#define VIDINXDELTA 0x7c -#define VIDININITERR 0x80 -#define VIDINYDELTA 0x84 -#define VIDPIXBUFTHOLD 0x88 -#define VIDCHRMIN 0x8c -#define VIDCHRMAX 0x90 -#define VIDCURLIN 0x94 -#define VIDSCREENSIZE 0x98 -#define VIDOVRSTARTCRD 0x9c -#define VIDOVRENDCRD 0xa0 -#define VIDOVRDUDX 0xa4 -#define VIDOVRDUDXOFF 0xa8 -#define VIDOVRDVDY 0xac -/* ... */ -#define VIDOVRDVDYOFF 0xe0 -#define VIDDESKSTART 0xe4 -#define VIDDESKSTRIDE 0xe8 -#define VIDINADDR0 0xec -#define VIDINADDR1 0xf0 -#define VIDINADDR2 0xf4 -#define VIDINSTRIDE 0xf8 -#define VIDCUROVRSTART 0xfc - -#define INTCTRL (0x00100000 + 0x04) -#define CLIP0MIN (0x00100000 + 0x08) -#define CLIP0MAX (0x00100000 + 0x0c) -#define DSTBASE (0x00100000 + 0x10) -#define DSTFORMAT (0x00100000 + 0x14) -#define SRCCOLORKEYMIN (0x00100000 + 0x18) -#define SRCCOLORKEYMAX (0x00100000 + 0x1c) -#define DSTCOLORKEYMIN (0x00100000 + 0x20) -#define DSTCOLORKEYMAX (0x00100000 + 0x24) -#define ROP123 (0x00100000 + 0x30) -#define SRCBASE (0x00100000 + 0x34) -#define COMMANDEXTRA_2D (0x00100000 + 0x38) -#define CLIP1MIN (0x00100000 + 0x4c) -#define CLIP1MAX (0x00100000 + 0x50) -#define SRCFORMAT (0x00100000 + 0x54) -#define SRCSIZE (0x00100000 + 0x58) -#define SRCXY (0x00100000 + 0x5c) -#define COLORBACK (0x00100000 + 0x60) -#define COLORFORE (0x00100000 + 0x64) -#define DSTSIZE (0x00100000 + 0x68) -#define DSTXY (0x00100000 + 0x6c) -#define COMMAND_2D (0x00100000 + 0x70) -#define LAUNCH_2D (0x00100000 + 0x80) - -#define COMMAND_3D (0x00200000 + 0x120) - -#define SWAPBUFCMD (0x00200000 + 0x128) -#define SWAPPENDING (0x00200000 + 0x24C) -#define LEFTOVBUF (0x00200000 + 0x250) -#define RIGHTOVBUF (0x00200000 + 0x254) -#define FBISWAPBUFHIST (0x00200000 + 0x258) - -/* register bitfields (not all, only as needed) */ - -#define BIT(x) (1UL << (x)) - -/* COMMAND_2D reg. values */ -#define TDFXFB_ROP_COPY 0xcc // src -#define TDFXFB_ROP_INVERT 0x55 // NOT dst -#define TDFXFB_ROP_XOR 0x66 // src XOR dst -#define TDFXFB_ROP_OR 0xee // src | dst - -#define AUTOINC_DSTX BIT(10) -#define AUTOINC_DSTY BIT(11) - - -#define COMMAND_2D_S2S_BITBLT 0x01 // screen to screen -#define COMMAND_2D_S2S_STRECH_BLT 0x02 // BLT + Strech -#define COMMAND_2D_H2S_BITBLT 0x03 // host to screen -#define COMMAND_2D_FILLRECT 0x05 - -#define COMMAND_2D_DO_IMMED BIT(8) // Do it immediatly - - - -#define COMMAND_3D_NOP 0x00 -#define STATUS_RETRACE BIT(6) -#define STATUS_BUSY BIT(9) -#define MISCINIT1_CLUT_INV BIT(0) -#define MISCINIT1_2DBLOCK_DIS BIT(15) -#define DRAMINIT0_SGRAM_NUM BIT(26) -#define DRAMINIT0_SGRAM_TYPE BIT(27) -#define DRAMINIT1_MEM_SDRAM BIT(30) -#define VGAINIT0_VGA_DISABLE BIT(0) -#define VGAINIT0_EXT_TIMING BIT(1) -#define VGAINIT0_8BIT_DAC BIT(2) -#define VGAINIT0_EXT_ENABLE BIT(6) -#define VGAINIT0_WAKEUP_3C3 BIT(8) -#define VGAINIT0_LEGACY_DISABLE BIT(9) -#define VGAINIT0_ALT_READBACK BIT(10) -#define VGAINIT0_FAST_BLINK BIT(11) -#define VGAINIT0_EXTSHIFTOUT BIT(12) -#define VGAINIT0_DECODE_3C6 BIT(13) -#define VGAINIT0_SGRAM_HBLANK_DISABLE BIT(22) -#define VGAINIT1_MASK 0x1fffff -#define VIDCFG_VIDPROC_ENABLE BIT(0) -#define VIDCFG_CURS_X11 BIT(1) -#define VIDCFG_HALF_MODE BIT(4) -#define VIDCFG_DESK_ENABLE BIT(7) -#define VIDCFG_CLUT_BYPASS BIT(10) -#define VIDCFG_2X BIT(26) -#define VIDCFG_HWCURSOR_ENABLE BIT(27) -#define VIDCFG_PIXFMT_SHIFT 18 -#define DACMODE_2X BIT(0) - -/* AGP registers */ -#define AGPREQSIZE (0x0080000 + 0x00) -#define AGPHOSTADDRESSLOW (0x0080000 + 0x04) -#define AGPHOSTADDRESSHIGH (0x0080000 + 0x08) -#define AGPGRAPHICSADDRESS (0x0080000 + 0x0C) -#define AGPGRAPHICSSTRIDE (0x0080000 + 0x10) -#define AGPMOVECMD (0x0080000 + 0x14) - -/* FIFO registers */ -#define CMDBASEADDR0 (0x0080000 + 0x20) -#define CMDBASESIZE0 (0x0080000 + 0x24) -#define CMDBUMP0 (0x0080000 + 0x28) -#define CMDRDPTRL0 (0x0080000 + 0x2C) -#define CMDRDPTRH0 (0x0080000 + 0x30) -#define CMDAMIN0 (0x0080000 + 0x34) -#define CMDAMAX0 (0x0080000 + 0x38) -#define CMDFIFODEPTH0 (0x0080000 + 0x44) -#define CMDHOLECNT0 (0x0080000 + 0x48) - - -/* YUV reisters */ -#define YUVBASEADDRESS (0x0080000 + 0x100) -#define YUVSTRIDE (0x0080000 + 0x104) - -/* VGA rubbish, need to change this for multihead support */ -#define MISC_W 0x3c2 -#define MISC_R 0x3cc -#define SEQ_I 0x3c4 -#define SEQ_D 0x3c5 -#define CRT_I 0x3d4 -#define CRT_D 0x3d5 -#define ATT_IW 0x3c0 -#define RAMDAC_R 0x3c7 -#define RAMDAC_W 0x3c8 -#define RAMDAC_D 0x3c9 -#define IS1_R 0x3da -#define GRA_I 0x3ce -#define GRA_D 0x3cf - -#ifndef FB_ACCEL_3DFX_BANSHEE -#define FB_ACCEL_3DFX_BANSHEE 31 -#endif - -#define TDFXF_HSYNC_ACT_HIGH 0x01 -#define TDFXF_HSYNC_ACT_LOW 0x02 -#define TDFXF_VSYNC_ACT_HIGH 0x04 -#define TDFXF_VSYNC_ACT_LOW 0x08 -#define TDFXF_LINE_DOUBLE 0x10 -#define TDFXF_VIDEO_ENABLE 0x20 - -#define TDFXF_HSYNC_MASK 0x03 -#define TDFXF_VSYNC_MASK 0x0c - -#define XYREG(x,y) (((((unsigned long)y) & 0x1FFF) << 16) | (((unsigned long)x) & 0x1FFF)) - -//#define TDFXFB_DEBUG -#ifdef TDFXFB_DEBUG -#define DPRINTK(a,b...) printk(KERN_DEBUG "fb: %s: " a, __FUNCTION__ , ## b) -#else -#define DPRINTK(a,b...) -#endif - -/* ------------------------------------------------------------------------- */ - -#endif /* MPLAYER_3DFX_H */ diff --git a/drivers/README.Ati b/drivers/README.Ati deleted file mode 100644 index 077b6ffff2..0000000000 --- a/drivers/README.Ati +++ /dev/null @@ -1,121 +0,0 @@ - framebuffer driver for ATI Radeon chipset video boards - ====================================================== - -These files are replacement for linux-2.4.x-ac.y drivers. -To use this driver you should have at least linux-2.4.5-ac.1 -then simply replace linux/drivers/video/radeon* with files -from this directory. -Note: since linux-2.4.10 this driver was moved from -ac to -Linus distribution. - -Alternative way: -~~~~~~~~~~~~~~~~ -Simply type two commands in this directory: -make -make install - -Anyway you should have 'framebuffer support' compiled into linux-kernel -and at least '8bpp packed pixel support' compiled and installed as module. -(But if you plan to use this module with MPlayer you also should have -16bpp, 24bpp and 32bpp pixel support compiled as modules). - - - Radeon video overlay - ==================== - -It was designed for MPlayer and currently can be used only by MPlayer. -It's RGB-YUV BES for Radeon cards (althrough there is experimental -support for Rage128 / Rage128pro chips). - -rage128_vid is contained within radeon_vid.c. As for a Rage128 framebuffer - -use the one from your Linux distribution. - -Installation: -~~~~~~~~~~~~~ - -Simply type two commands in this directory: -make -make install - -Using with MPlayer: -~~~~~~~~~~~~~~~~~~~ - -Currently there is only one way to use ATI's drivers: -mplayer -vo vesa:lvo:/dev/radeon_vid - filename -or -mplayer -vo vesa:lvo:/dev/rage128_vid - filename - -For YV12 formats you can use also: -mplayer -vo mga:/dev/radeon_vid - filename - -but in this case you should load at least radeonfb driver from -this package. - -Configuring: -~~~~~~~~~~~~ - -You can tune some parameters with the following trick: -echo "parameter=value" > /dev/radeon_vid -Example (disables adaptive deinterlacing): -echo "deinterlace=off" > /dev/radeon_vid - -To know more about these parameters - try reading the /dev/radeon_vid file ;) -For example: -cat /dev/radeon_vid - -List of parameters: -~~~~~~~~~~~~~~~~~~~ -If you have Rage128 chip: -brightness=decval (-64:+63) changes brightness -saturation=decval (0:+31) changes saturation 0 == grayscale mode -else - if you have Radeon: -brightness=decval (-1000:+1000) -1000 == black screen -saturation=decval (-1000:+1000) -1000 == grayscaled mode -contrast=decval (-1000:+1000) -1000 == black screen -hue=decval (-1000:+1000) -1000 == +1000 (full circle) - all other values are within this range -Note: 0 is the default value for every parameter on Radeons. -WARNING: This driver violates the rule: "no float in the kernel". -So if you have problems then don't use color correction. - -double_buff=on/off enables/disables double buffering -deinterlace=on/off enables/disables adaptive deinterlacing -deinterlace_pattern=hexval defines deinterlacing pattern - -Driver parameters: -~~~~~~~~~~~~~~~~~~ - -You can use some additional parameters during module loading: -Example: -modprobe radeon_vid swap_fourcc=1 - -List of driver parameters: -~~~~~~~~~~~~~~~~~~~~~~~~~~ -mtrr=1/0 Configures MTRR (if available), default = 1. -swap_fourcc=1/0 Performs byte swapping of passed fourcc. - (It's required for compatibility with -vo mga.) - -To know more about driver parameters execute: -modinfo radeon_vid -or -modinfo rage128_vid - -Note: -~~~~~ -For command line of MPlayer: -You can pass only options with can be recognized by vo_vesa driver. -(Indeed radeon_vid and rage128_vid are stupid things and can only create -video overlay. Mode switching and other adjustments are performed by the -vo_vesa driver. This mean that they use the VESA BIOS as graphics server.) - -Conclusion: -~~~~~~~~~~~ -This stuff (radeon(rage128)_vid) currently doesn't support any standards. - -Full example: -~~~~~~~~~~~~~ -modprobe radeon_vid mtrr=1 -echo "deinterlace_pattern=F0055555" > /dev/radeon_vid -mplayer -vo vesa:lvo:/dev/radeon_vid -fs -zoom -bpp 32 filename - -Enjoy! diff --git a/drivers/README.Matrox b/drivers/README.Matrox deleted file mode 100644 index 48a37ed057..0000000000 --- a/drivers/README.Matrox +++ /dev/null @@ -1,46 +0,0 @@ -The code in this directory is the old mga_vid driver for Linux kernels -prior to 2.6. It does _not_ compile for version 2.6.x. - -For Linux kernel 2.6.x please get the newest version of the 2.6 port from -http://attila.kinali.ch/mga/ - - -mga_vid - MGA G200/G400 YUV Overlay kernel module - - Author: - Aaron Holtzman , Oct 1999 - - Contributions by: - Fredrik Vraalsen - Alan Cox - - WARNING ----- WARNING - -This code messes with your video card and your X server. It will probably -lock up your box, format your hard drive, and cause your brand new G400 -MAX to spout 6 inch flames. You have been warned. - - WARNING ----- WARNING - -What does this code do? - - mga_vid is a kernel module that utilitizes the Matrox G200/G400/G550 - video scaler/overlay unit to perform YUV->RGB colorspace conversion - and arbitrary video scaling. - - mga_vid is also a monster hack. - -How does mga_vid work? - - This kernel module sets up the BES (backend scaler) with appropriate - values based on parameters supplied via ioctl. It also maps a chunk of - video memory into userspace via mmap. This memory is stolen from X - (which may decide to write to it later). The application can then write - image data directly to the framebuffer (if it knows the right padding, - etc). - - -How do I know if mga_vid works on my system? - - There is a test application called mga_vid_test. This test code should - draw some nice 256x256 images for you if all is working well. diff --git a/drivers/generic_math.h b/drivers/generic_math.h deleted file mode 100644 index 00a0e976f8..0000000000 --- a/drivers/generic_math.h +++ /dev/null @@ -1,272 +0,0 @@ -/* - * generic implementation of sin(x) and cos(x) functions specially for Linux - * Copyright (C) 2002 Nick Kurshev - * - * This file is part of MPlayer. - * - * MPlayer is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * MPlayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef MPLAYER_GENERIC_MATH_H -#define MPLAYER_GENERIC_MATH_H - -typedef struct gen_sincos -{ - double x; - double sinx; - double cosx; -}gen_sincos_t; - -static gen_sincos_t g_sincos[201] = { -{ -3.141600e+00, 7.346410e-06, -1.000000e-00 }, -{ -3.110184e+00, -3.140349e-02, -9.995068e-01 }, -{ -3.078768e+00, -6.278333e-02, -9.980272e-01 }, -{ -3.047352e+00, -9.410122e-02, -9.955626e-01 }, -{ -3.015936e+00, -1.253262e-01, -9.921156e-01 }, -{ -2.984520e+00, -1.564276e-01, -9.876894e-01 }, -{ -2.953104e+00, -1.873745e-01, -9.822885e-01 }, -{ -2.921688e+00, -2.181366e-01, -9.759183e-01 }, -{ -2.890272e+00, -2.486833e-01, -9.685848e-01 }, -{ -2.858856e+00, -2.789847e-01, -9.602956e-01 }, -{ -2.827440e+00, -3.090107e-01, -9.510586e-01 }, -{ -2.796024e+00, -3.387318e-01, -9.408830e-01 }, -{ -2.764608e+00, -3.681185e-01, -9.297789e-01 }, -{ -2.733192e+00, -3.971420e-01, -9.177572e-01 }, -{ -2.701776e+00, -4.257736e-01, -9.048297e-01 }, -{ -2.670360e+00, -4.539849e-01, -8.910094e-01 }, -{ -2.638944e+00, -4.817483e-01, -8.763097e-01 }, -{ -2.607528e+00, -5.090362e-01, -8.607451e-01 }, -{ -2.576112e+00, -5.358217e-01, -8.443312e-01 }, -{ -2.544696e+00, -5.620785e-01, -8.270839e-01 }, -{ -2.513280e+00, -5.877805e-01, -8.090204e-01 }, -{ -2.481864e+00, -6.129025e-01, -7.901586e-01 }, -{ -2.450448e+00, -6.374196e-01, -7.705169e-01 }, -{ -2.419032e+00, -6.613076e-01, -7.501148e-01 }, -{ -2.387616e+00, -6.845430e-01, -7.289724e-01 }, -{ -2.356200e+00, -7.071029e-01, -7.071107e-01 }, -{ -2.324784e+00, -7.289649e-01, -6.845511e-01 }, -{ -2.293368e+00, -7.501075e-01, -6.613159e-01 }, -{ -2.261952e+00, -7.705099e-01, -6.374281e-01 }, -{ -2.230536e+00, -7.901518e-01, -6.129112e-01 }, -{ -2.199120e+00, -8.090140e-01, -5.877894e-01 }, -{ -2.167704e+00, -8.270777e-01, -5.620876e-01 }, -{ -2.136288e+00, -8.443252e-01, -5.358310e-01 }, -{ -2.104872e+00, -8.607395e-01, -5.090457e-01 }, -{ -2.073456e+00, -8.763043e-01, -4.817579e-01 }, -{ -2.042040e+00, -8.910044e-01, -4.539948e-01 }, -{ -2.010624e+00, -9.048251e-01, -4.257835e-01 }, -{ -1.979208e+00, -9.177528e-01, -3.971521e-01 }, -{ -1.947792e+00, -9.297748e-01, -3.681288e-01 }, -{ -1.916376e+00, -9.408793e-01, -3.387421e-01 }, -{ -1.884960e+00, -9.510552e-01, -3.090212e-01 }, -{ -1.853544e+00, -9.602925e-01, -2.789953e-01 }, -{ -1.822128e+00, -9.685821e-01, -2.486940e-01 }, -{ -1.790712e+00, -9.759158e-01, -2.181473e-01 }, -{ -1.759296e+00, -9.822865e-01, -1.873854e-01 }, -{ -1.727880e+00, -9.876877e-01, -1.564385e-01 }, -{ -1.696464e+00, -9.921142e-01, -1.253372e-01 }, -{ -1.665048e+00, -9.955616e-01, -9.411219e-02 }, -{ -1.633632e+00, -9.980265e-01, -6.279433e-02 }, -{ -1.602216e+00, -9.995064e-01, -3.141450e-02 }, -{ -1.570800e+00, -1.000000e-00, -3.673205e-06 }, -{ -1.539384e+00, -9.995067e-01, 3.140716e-02 }, -{ -1.507968e+00, -9.980269e-01, 6.278700e-02 }, -{ -1.476552e+00, -9.955623e-01, 9.410488e-02 }, -{ -1.445136e+00, -9.921151e-01, 1.253299e-01 }, -{ -1.413720e+00, -9.876889e-01, 1.564312e-01 }, -{ -1.382304e+00, -9.822879e-01, 1.873781e-01 }, -{ -1.350888e+00, -9.759175e-01, 2.181402e-01 }, -{ -1.319472e+00, -9.685839e-01, 2.486869e-01 }, -{ -1.288056e+00, -9.602945e-01, 2.789882e-01 }, -{ -1.256640e+00, -9.510574e-01, 3.090142e-01 }, -{ -1.225224e+00, -9.408817e-01, 3.387352e-01 }, -{ -1.193808e+00, -9.297775e-01, 3.681220e-01 }, -{ -1.162392e+00, -9.177557e-01, 3.971454e-01 }, -{ -1.130976e+00, -9.048282e-01, 4.257769e-01 }, -{ -1.099560e+00, -8.910077e-01, 4.539882e-01 }, -{ -1.068144e+00, -8.763079e-01, 4.817515e-01 }, -{ -1.036728e+00, -8.607433e-01, 5.090393e-01 }, -{ -1.005312e+00, -8.443292e-01, 5.358248e-01 }, -{ -9.738960e-01, -8.270819e-01, 5.620815e-01 }, -{ -9.424800e-01, -8.090183e-01, 5.877835e-01 }, -{ -9.110640e-01, -7.901563e-01, 6.129054e-01 }, -{ -8.796480e-01, -7.705146e-01, 6.374224e-01 }, -{ -8.482320e-01, -7.501124e-01, 6.613104e-01 }, -{ -8.168160e-01, -7.289699e-01, 6.845457e-01 }, -{ -7.854000e-01, -7.071081e-01, 7.071055e-01 }, -{ -7.539840e-01, -6.845484e-01, 7.289674e-01 }, -{ -7.225680e-01, -6.613131e-01, 7.501100e-01 }, -{ -6.911520e-01, -6.374252e-01, 7.705122e-01 }, -{ -6.597360e-01, -6.129083e-01, 7.901541e-01 }, -{ -6.283200e-01, -5.877864e-01, 8.090161e-01 }, -{ -5.969040e-01, -5.620845e-01, 8.270798e-01 }, -{ -5.654880e-01, -5.358279e-01, 8.443272e-01 }, -{ -5.340720e-01, -5.090425e-01, 8.607414e-01 }, -{ -5.026560e-01, -4.817547e-01, 8.763061e-01 }, -{ -4.712400e-01, -4.539915e-01, 8.910060e-01 }, -{ -4.398240e-01, -4.257802e-01, 9.048266e-01 }, -{ -4.084080e-01, -3.971488e-01, 9.177542e-01 }, -{ -3.769920e-01, -3.681254e-01, 9.297762e-01 }, -{ -3.455760e-01, -3.387387e-01, 9.408805e-01 }, -{ -3.141600e-01, -3.090177e-01, 9.510563e-01 }, -{ -2.827440e-01, -2.789917e-01, 9.602935e-01 }, -{ -2.513280e-01, -2.486905e-01, 9.685830e-01 }, -{ -2.199120e-01, -2.181437e-01, 9.759166e-01 }, -{ -1.884960e-01, -1.873817e-01, 9.822872e-01 }, -{ -1.570800e-01, -1.564348e-01, 9.876883e-01 }, -{ -1.256640e-01, -1.253335e-01, 9.921147e-01 }, -{ -9.424800e-02, -9.410853e-02, 9.955619e-01 }, -{ -6.283200e-02, -6.279067e-02, 9.980267e-01 }, -{ -3.141600e-02, -3.141083e-02, 9.995066e-01 }, -{ 0.000000e+00, 0.000000e+00, 1.000000e+00 }, -{ 3.141600e-02, 3.141083e-02, 9.995066e-01 }, -{ 6.283200e-02, 6.279067e-02, 9.980267e-01 }, -{ 9.424800e-02, 9.410853e-02, 9.955619e-01 }, -{ 1.256640e-01, 1.253335e-01, 9.921147e-01 }, -{ 1.570800e-01, 1.564348e-01, 9.876883e-01 }, -{ 1.884960e-01, 1.873817e-01, 9.822872e-01 }, -{ 2.199120e-01, 2.181437e-01, 9.759166e-01 }, -{ 2.513280e-01, 2.486905e-01, 9.685830e-01 }, -{ 2.827440e-01, 2.789917e-01, 9.602935e-01 }, -{ 3.141600e-01, 3.090177e-01, 9.510563e-01 }, -{ 3.455760e-01, 3.387387e-01, 9.408805e-01 }, -{ 3.769920e-01, 3.681254e-01, 9.297762e-01 }, -{ 4.084080e-01, 3.971488e-01, 9.177542e-01 }, -{ 4.398240e-01, 4.257802e-01, 9.048266e-01 }, -{ 4.712400e-01, 4.539915e-01, 8.910060e-01 }, -{ 5.026560e-01, 4.817547e-01, 8.763061e-01 }, -{ 5.340720e-01, 5.090425e-01, 8.607414e-01 }, -{ 5.654880e-01, 5.358279e-01, 8.443272e-01 }, -{ 5.969040e-01, 5.620845e-01, 8.270798e-01 }, -{ 6.283200e-01, 5.877864e-01, 8.090161e-01 }, -{ 6.597360e-01, 6.129083e-01, 7.901541e-01 }, -{ 6.911520e-01, 6.374252e-01, 7.705122e-01 }, -{ 7.225680e-01, 6.613131e-01, 7.501100e-01 }, -{ 7.539840e-01, 6.845484e-01, 7.289674e-01 }, -{ 7.854000e-01, 7.071081e-01, 7.071055e-01 }, -{ 8.168160e-01, 7.289699e-01, 6.845457e-01 }, -{ 8.482320e-01, 7.501124e-01, 6.613104e-01 }, -{ 8.796480e-01, 7.705146e-01, 6.374224e-01 }, -{ 9.110640e-01, 7.901563e-01, 6.129054e-01 }, -{ 9.424800e-01, 8.090183e-01, 5.877835e-01 }, -{ 9.738960e-01, 8.270819e-01, 5.620815e-01 }, -{ 1.005312e+00, 8.443292e-01, 5.358248e-01 }, -{ 1.036728e+00, 8.607433e-01, 5.090393e-01 }, -{ 1.068144e+00, 8.763079e-01, 4.817515e-01 }, -{ 1.099560e+00, 8.910077e-01, 4.539882e-01 }, -{ 1.130976e+00, 9.048282e-01, 4.257769e-01 }, -{ 1.162392e+00, 9.177557e-01, 3.971454e-01 }, -{ 1.193808e+00, 9.297775e-01, 3.681220e-01 }, -{ 1.225224e+00, 9.408817e-01, 3.387352e-01 }, -{ 1.256640e+00, 9.510574e-01, 3.090142e-01 }, -{ 1.288056e+00, 9.602945e-01, 2.789882e-01 }, -{ 1.319472e+00, 9.685839e-01, 2.486869e-01 }, -{ 1.350888e+00, 9.759175e-01, 2.181402e-01 }, -{ 1.382304e+00, 9.822879e-01, 1.873781e-01 }, -{ 1.413720e+00, 9.876889e-01, 1.564312e-01 }, -{ 1.445136e+00, 9.921151e-01, 1.253299e-01 }, -{ 1.476552e+00, 9.955623e-01, 9.410488e-02 }, -{ 1.507968e+00, 9.980269e-01, 6.278700e-02 }, -{ 1.539384e+00, 9.995067e-01, 3.140716e-02 }, -{ 1.570800e+00, 1.000000e-00, -3.673205e-06 }, -{ 1.602216e+00, 9.995064e-01, -3.141450e-02 }, -{ 1.633632e+00, 9.980265e-01, -6.279433e-02 }, -{ 1.665048e+00, 9.955616e-01, -9.411219e-02 }, -{ 1.696464e+00, 9.921142e-01, -1.253372e-01 }, -{ 1.727880e+00, 9.876877e-01, -1.564385e-01 }, -{ 1.759296e+00, 9.822865e-01, -1.873854e-01 }, -{ 1.790712e+00, 9.759158e-01, -2.181473e-01 }, -{ 1.822128e+00, 9.685821e-01, -2.486940e-01 }, -{ 1.853544e+00, 9.602925e-01, -2.789953e-01 }, -{ 1.884960e+00, 9.510552e-01, -3.090212e-01 }, -{ 1.916376e+00, 9.408793e-01, -3.387421e-01 }, -{ 1.947792e+00, 9.297748e-01, -3.681288e-01 }, -{ 1.979208e+00, 9.177528e-01, -3.971521e-01 }, -{ 2.010624e+00, 9.048251e-01, -4.257835e-01 }, -{ 2.042040e+00, 8.910044e-01, -4.539948e-01 }, -{ 2.073456e+00, 8.763043e-01, -4.817579e-01 }, -{ 2.104872e+00, 8.607395e-01, -5.090457e-01 }, -{ 2.136288e+00, 8.443252e-01, -5.358310e-01 }, -{ 2.167704e+00, 8.270777e-01, -5.620876e-01 }, -{ 2.199120e+00, 8.090140e-01, -5.877894e-01 }, -{ 2.230536e+00, 7.901518e-01, -6.129112e-01 }, -{ 2.261952e+00, 7.705099e-01, -6.374281e-01 }, -{ 2.293368e+00, 7.501075e-01, -6.613159e-01 }, -{ 2.324784e+00, 7.289649e-01, -6.845511e-01 }, -{ 2.356200e+00, 7.071029e-01, -7.071107e-01 }, -{ 2.387616e+00, 6.845430e-01, -7.289724e-01 }, -{ 2.419032e+00, 6.613076e-01, -7.501148e-01 }, -{ 2.450448e+00, 6.374196e-01, -7.705169e-01 }, -{ 2.481864e+00, 6.129025e-01, -7.901586e-01 }, -{ 2.513280e+00, 5.877805e-01, -8.090204e-01 }, -{ 2.544696e+00, 5.620785e-01, -8.270839e-01 }, -{ 2.576112e+00, 5.358217e-01, -8.443312e-01 }, -{ 2.607528e+00, 5.090362e-01, -8.607451e-01 }, -{ 2.638944e+00, 4.817483e-01, -8.763097e-01 }, -{ 2.670360e+00, 4.539849e-01, -8.910094e-01 }, -{ 2.701776e+00, 4.257736e-01, -9.048297e-01 }, -{ 2.733192e+00, 3.971420e-01, -9.177572e-01 }, -{ 2.764608e+00, 3.681185e-01, -9.297789e-01 }, -{ 2.796024e+00, 3.387318e-01, -9.408830e-01 }, -{ 2.827440e+00, 3.090107e-01, -9.510586e-01 }, -{ 2.858856e+00, 2.789847e-01, -9.602956e-01 }, -{ 2.890272e+00, 2.486833e-01, -9.685848e-01 }, -{ 2.921688e+00, 2.181366e-01, -9.759183e-01 }, -{ 2.953104e+00, 1.873745e-01, -9.822885e-01 }, -{ 2.984520e+00, 1.564276e-01, -9.876894e-01 }, -{ 3.015936e+00, 1.253262e-01, -9.921156e-01 }, -{ 3.047352e+00, 9.410122e-02, -9.955626e-01 }, -{ 3.078768e+00, 6.278333e-02, -9.980272e-01 }, -{ 3.110184e+00, 3.140349e-02, -9.995068e-01 }, -{ 3.141600e+00, -7.346410e-06, -1.000000e-00 } -}; - -#define M_PI 3.14159265358979323846 /* pi */ - -static double inline gen_sin(double x) -{ - int i; - if(x < 0) while(x < -M_PI) x+= M_PI; - else while(x > M_PI) x-= M_PI; - for(i=0;i=g_sincos[i].x && x <= g_sincos[i+1].x) - { - return (g_sincos[i+1].sinx-g_sincos[i].sinx)*(x-g_sincos[i].x)/(g_sincos[i+1].x-g_sincos[i].x)+g_sincos[i].sinx; - } - } - return x<0?1:-1; -} -#undef sin -#define sin(x) gen_sin(x) - -static double inline gen_cos(double x) -{ - int i; - if(x < 0) while(x < -M_PI) x+= M_PI; - else while(x > M_PI) x-= M_PI; - for(i=0;i=g_sincos[i].x && x <= g_sincos[i+1].x) - { - return (g_sincos[i+1].cosx-g_sincos[i].cosx)*(x-g_sincos[i].x)/(g_sincos[i+1].x-g_sincos[i].x)+g_sincos[i].cosx; - } - } - return x<0?1:-1; -} -#undef cos -#define cos(x) gen_cos(x) - -#endif /* MPLAYER_GENERIC_MATH_H */ diff --git a/drivers/hacking.ati b/drivers/hacking.ati deleted file mode 100644 index 20c9bfa8ea..0000000000 --- a/drivers/hacking.ati +++ /dev/null @@ -1,313 +0,0 @@ - ATI chips hacking - ================= - Dedicated to ATI's hackers. - -Preface -~~~~~~~ -This document will compare ATI chips only from point of DAC and video overlay. -There are lots of difference from 3D point, dual-head support, tv-out support -and many other things but it's already perfectly different story. -This document doesn't include information about ATI AIW (All In Wonder) chips. - -What are units on modern ATI chips: -DAC - (Digital to Analog Convertor) controls CRTC, LCD, DFP monitor's output - Consists from: - PLL - (Programable line length) registers - CRTC - CRT controller - LCD/DFP scaler - surface control -DAC2 - controls CRTC, LCD, DFP monitor's output on second head -TVDAC - controls Composite Video and Super Video output ports - Consists from: - TV_PLL - TV scaler & sync unit - TV format convertor (PAL/NTSC) -TVCAP - controls Video-In port -MPP - Miscellaneous peripheral port. (includes macrovision's filter - copy - protection mechanism) -OV - Video overlay (YUV BES) (include subpictures, gamma correction and - adaptive deinterlacing) -CAP0 - Video capturing -CAP1 - Video capturing (second unit) -RT - Rage theatre: video encoding and mixing -MUX - video muxer -MEM - PCI/AGP bus mastering -2D - GUI engine -3D - 3D-OpenGL engine (There are lots of stuff) -I2C - I2C Bus control - -This document is mainly related only with OV unit ;) -Video decoding diagram: - -RAM memory: [ App ] Copies YUV image to overlay memory - | <-- (It's possible to program DMA here) -overlay memory:[ OV ] performs scaling and YUVtoRGB convertion - /\ -RGB memory: / \ - / [ macrovision ] performs copy protection filtering - / \ (unneeded but presented by default thing;) - [ CRTC/LCD/DFP DAC ] [ TV DAC ] convert RGB memory to CRTC and NTSC/PAL signals - | | - [CRTC/LCD/DFP Monitor] [TV-screen] - -History -~~~~~~~ - What is history of ATI's chips? I can be wrong but below is my vision -of this question: - -0. I don't know any earlied chips :( -1. Mach8 -2. Mach16 -3. Mach32 - -4. Mach64. - It's first chip which has support from side of open - source drivers. Set of mach64 chips is: - mach64GX (ATI888GX00) - mach64CX (ATI888CX00) - mach64CT (ATI264CT) - mach64ET (ATI264ET) - mach64VTA3 (ATI264VT) - mach64VTA4 (ATI264VT) - mach64VTB (ATI264VTB) - mach64VT4 (ATI264VT4) - -5. 3D rage chips. - It seems that these chips have fully compatible by GPU with Mach64 - which is extended by 3D possibilities. Set of 3D rage chips is: - 3D RAGE (GT) - 3D RAGE II+ (GTB) - 3D RAGE IIC (PCI) - 3D RAGE IIC (AGP) - 3D RAGE LT - 3D RAGE LT-G - 3D RAGE PRO (BGA, AGP) - 3D RAGE PRO (BGA, AGP, 1x only) - 3D RAGE PRO (BGA, PCI) - 3D RAGE PRO (PQFP, PCI) - 3D RAGE PRO (PQFP, PCI, limited 3D) - 3D RAGE (XL) - 3D RAGE LT PRO (AGP) - 3D RAGE LT PRO (PCI) - 3D RAGE Mobility (PCI) - 3D RAGE Mobility (AGP) - -6. Rage128 chips. - These chips have perfectly new GPU which supports memory mapped IO - space for accelerating port access (It's main cause of incompatibility - with mach64). Set of Rage128 chips is: - Rage128 GL RE - Rage128 GL RF - Rage128 GL RG - Rage128 GL RH - Rage128 GL RI - Rage128 VR RK - Rage128 VR RL - Rage128 VR RM - Rage128 VR RN - Rage128 VR RO - Rage128 Mobility M3 LE - Rage128 Mobility M3 LF -7. Rage128Pro chips. - These chips are successors of Rage128 ones. - Rage128Pro GL PA - Rage128Pro GL PB - Rage128Pro GL PC - Rage128Pro GL PD - Rage128Pro GL PE - Rage128Pro GL PF - Rage128Pro VR PG - Rage128Pro VR PH - Rage128Pro VR PI - Rage128Pro VR PJ - Rage128Pro VR PK - Rage128Pro VR PL - Rage128Pro VR PM - Rage128Pro VR PN - Rage128Pro VR PO - Rage128Pro VR PP - Rage128Pro VR PQ - Rage128Pro VR PR - Rage128Pro VR TR - Rage128Pro VR PS - Rage128Pro VR PT - Rage128Pro VR PU - Rage128Pro VR PV - Rage128Pro VR PW - Rage128Pro VR PX - Rage128Pro Ultra U1 - Rage128Pro Ultra U2 - Rage128Pro Ultra U3 - -8. Radeon chips. - Indeed they could be named Rage256 Pro. (With minor changes is fully - compatible with Rage128 chips). - Radeon QD - Radeon QE - Radeon QF - Radeon QG - Radeon VE QY - Radeon VE QZ - Radeon M6 LY - Radeon M6 LZ - Radeon M7 LW -9. Radeon2 chips. - Indeed they could be named Rage512 Pro. - Radeon2 8500 QL - Radeon2 7500 QW - -10. Radeon3 and newest are cooming soon, but I hope that they will be fully - compatible with Radeon1 chips. - -In Radeon famility there were introduced also FX chips: Radeon FX and -Radeon2 8700 FX. Probably they have the same possibility as other Radeon -but currently it's unknown for me. - -What about video overlay and DAC? -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Currently it's known that there is only difference between -Mach64 and Rage128 compatible chips: -- They have different logic of io ports programming! -- They are incompatible by port numbers! -But: -- They use the same program logic from register's name point. -(Indeed exists slight difference even between Radeon and Rage128 -chips. AFAIK only Radeon has OV0_SLICE_CNTL register which currently -is not used by driver. But I know only its name ;). Also there -is difference in slight adjust of BES position but it's configured -by #ifdef blocks). - -Please compare: - -(The piece of Back-End Scaler programming) - - Sample for Mach64 compatible chips: - *********************************** - -#define SPARSE_IO_BASE 0x03fcu -#define SPARSE_IO_SELECT 0xfc00u - -#define BLOCK_IO_BASE 0xff00u -#define BLOCK_IO_SELECT 0x00fcu - -#define MM_IO_SELECT 0x03fcu -#define BLOCK_SELECT 0x0400u -#define DWORD_SELECT (BLOCK_SELECT | MM_IO_SELECT) - -#define IO_BYTE_SELECT 0x0003u - -#define SPARSE_IO_PORT (SPARSE_IO_BASE | IO_BYTE_SELECT) -#define BLOCK_IO_PORT (BLOCK_IO_BASE | IO_BYTE_SELECT) - -#define IOPortTag(_SparseIOSelect, _BlockIOSelect) \ - (SetBits(_SparseIOSelect, SPARSE_IO_SELECT) | \ - SetBits(_BlockIOSelect, BLOCK_SELECT | MM_IO_SELECT)) -#define SparseIOTag(_IOSelect) IOPortTag(_IOSelect, 0) -#define BlockIOTag(_IOSelect) IOPortTag(0, _IOSelect) - -... - -#define OVERLAY_Y_X_START BlockIOTag(0x100u) -#define OVERLAY_Y_X_END BlockIOTag(0x101u) - -... - -#define OUTREG(_Register, _Value) \ - MMIO_OUT32(pATI->pBlock[GetBits(_Register, BLOCK_SELECT)], \ - (_Register) & MM_IO_SELECT, _Value) - -... - -OUTREG(OVERLAY_Y_X_START,((drw_x)<<16)|(drw_y)|(1<<31)); -OUTREG(OVERLAY_Y_X_END,((drw_x+drw_w)<<16)|(drw_y+drw_h)); - - - Sample for Rage128 compatible chips: - ************************************ - -#define OV0_Y_X_START 0x0400 -#define OV0_Y_X_END 0x0404 - -... - -#define INREG(addr) readl((rage_mmio_base)+addr) -#define OUTREG(addr,val) writel(val, (rage_mmio_base)+addr) - -... - -rage_mmio_base = ioremap_nocache(pci_resource_start (dev, 2),RAGE_REGSIZE); - -... - -#ifdef RADEON -#define X_ADJUST 8 -#else /* rage128 */ -#define X_ADJUST 0 -#endif - -OUTREG(OV0_Y_X_START,(drw_x+X_ADJUST)|(drw_y<<16)); -OUTREG(OV0_Y_X_END,(drw_x+drw_w+X_ADJUST)|(drw_y+drw_h)<<16)); - -Thus - these chips have almost the same logic from register's name point. -(except the fact that they have swapped 16-bit halfs). -Yes - programming of Rage128 is much simpler of Mach64. - - -What about other ATI's chips? -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -I suggest you have latest copy of GATOS-CVS: -http://www.linuxvideo.org -GATOS was designed and introduced as General ATI TV and Overlay Sowfware. -You will be able to find out there a lots of useful hacking utilities -(at location gatos-ati/gatos): -gfxdump - Program for dumping graphics chips registers on Linux and Windows 9X. - (it's more useful for Win9x to hack their values). -xatitv - For working with tv-in (currently is under hard development) -atitvout- For working with tv-out -and lot of other stuff. -BUT: After studing of Gatos and X11 stuffs I've found that they are bad -optimized for movie playback. -Please compare: - radeon_vid - configures video overlay only once and provides DGA to it. - (doesn't require to be MMX optimized) - gatos and X11 - configures video overlay at every slice of frame, then - performs unoptimized copying of source stuff to video memory - often with using CopyMungedData (it's C-analog of YV12_to_YUY2) - since there are lacks in yv12 support. - (is not MMX optimized that's gladly accepted, but probably - will be never optimized due portability). - -hardware IDCT support diagram: -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - | -[ Video parser ] <---------- [ Transport demuxing ] --> [ Audio ] - | | | -[ Variable length decoder] |D | - | |V | -[ Inverse quantization ] |D | - | | | --------|---[ video card ]---------+ |s | - | | |u | -[ Run level decode & de-zigzag ] | |b | - | | |p | -[ IDCT ] | |i | - | | |c | -[ Motion compensation ] | |t | - | | |u | -[ Advanced deinterlacing ] | |r | - | | |e | -[ Filtered X-Y scaling ] [SUBPIC]-|-----+s [ OSD ] - | | | | | -[ 4-bit alpha blending ] <---+ | +-------+ - | | -[ YUV to RGB conversion ] | --------|--------------------------+ -TV-screen or CRT-display - - -Conslusion: -~~~~~~~~~~~ - -That's all folk! diff --git a/drivers/mga_vid.c b/drivers/mga_vid.c deleted file mode 100644 index de96aa1b0a..0000000000 --- a/drivers/mga_vid.c +++ /dev/null @@ -1,1778 +0,0 @@ -/* - * Matrox MGA G200/G400 YUV Video Interface module Version 0.1.0 - * BES == Back End Scaler - * - * Copyright (C) 1999 Aaron Holtzman - * - * Module skeleton based on gutted agpgart module by - * Jeff Hartmann - * YUY2 support (see config.format) added by A'rpi/ESP-team - * double buffering added by A'rpi/ESP-team - * brightness/contrast introduced by eyck - * multiple card support by Attila Kinali - * - * This file is part of mga_vid. - * - * mga_vid is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * mga_vid is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with mga_vid; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -//It's entirely possible this major conflicts with something else -//use the 'major' parameter to override the default major number (178) -/* mknod /dev/mga_vid c 178 0 */ - -//#define CRTC2 - -// Set this value, if autodetection fails! (video ram size in megabytes) -// #define MGA_MEMORY_SIZE 16 - -//#define MGA_ALLOW_IRQ - -#define MGA_VSYNC_POS 2 - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,10) -#include -#else -#include -#endif - -#include -#include -#include - -#include "mga_vid.h" - -#ifdef CONFIG_MTRR -#include -#endif - -#ifdef CONFIG_DEVFS_FS -#include -#endif - -#include -#include -#include - -#define TRUE 1 -#define FALSE 0 - -#define DEFAULT_MGA_VID_MAJOR 178 - -#ifndef PCI_DEVICE_ID_MATROX_G200_PCI -#define PCI_DEVICE_ID_MATROX_G200_PCI 0x0520 -#endif - -#ifndef PCI_DEVICE_ID_MATROX_G200_AGP -#define PCI_DEVICE_ID_MATROX_G200_AGP 0x0521 -#endif - -#ifndef PCI_DEVICE_ID_MATROX_G400 -#define PCI_DEVICE_ID_MATROX_G400 0x0525 -#endif - -#ifndef PCI_DEVICE_ID_MATROX_G550 -#define PCI_DEVICE_ID_MATROX_G550 0x2527 -#endif - -#ifndef PCI_SUBSYSTEM_ID_MATROX_G400_DH_16MB -#define PCI_SUBSYSTEM_ID_MATROX_G400_DH_16MB 0x2159 -#endif - -#ifndef PCI_SUBSYSTEM_ID_MATROX_G400_16MB_SGRAM -#define PCI_SUBSYSTEM_ID_MATROX_G400_16MB_SGRAM 0x19d8 -#endif - -#ifndef PCI_SUBSYSTEM_ID_MATROX_G400_16MB_SDRAM -#define PCI_SUBSYSTEM_ID_MATROX_G400_16MB_SDRAM 0x0328 -#endif - -MODULE_AUTHOR("Aaron Holtzman "); -#ifdef MODULE_LICENSE -MODULE_LICENSE("GPL"); -#endif - -#define PARAM_BRIGHTNESS "brightness=" -#define PARAM_CONTRAST "contrast=" -#define PARAM_BLACKIE "blackie=" - -// set PARAM_BUFF_SIZE to just below 4k because some kernel versions -// store additional information in the memory page which leads to -// the allocation of an additional page if exactly 4k is used -#define PARAM_BUFF_SIZE 4000 - -#ifndef min -#define min(x,y) (((x)<(y))?(x):(y)) -#endif - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0) -#include - -static unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base) -{ - unsigned long result = 0,value; - - if (!base) { - base = 10; - if (*cp == '0') { - base = 8; - cp++; - if ((*cp == 'x') && isxdigit(cp[1])) { - cp++; - base = 16; - } - } - } - while (isxdigit(*cp) && (value = isdigit(*cp) ? *cp-'0' : (islower(*cp) - ? toupper(*cp) : *cp)-'A'+10) < base) { - result = result*base + value; - cp++; - } - if (endp) - *endp = (char *)cp; - return result; -} - -static long simple_strtol(const char *cp,char **endp,unsigned int base) -{ - if(*cp=='-') - return -simple_strtoul(cp+1,endp,base); - return simple_strtoul(cp,endp,base); -} -#endif - - -typedef struct bes_registers_s -{ - //BES Control - uint32_t besctl; - //BES Global control - uint32_t besglobctl; - //Luma control (brightness and contrast) - uint32_t beslumactl; - //Line pitch - uint32_t bespitch; - - //Buffer A-1 Chroma 3 plane org - uint32_t besa1c3org; - //Buffer A-1 Chroma org - uint32_t besa1corg; - //Buffer A-1 Luma org - uint32_t besa1org; - - //Buffer A-2 Chroma 3 plane org - uint32_t besa2c3org; - //Buffer A-2 Chroma org - uint32_t besa2corg; - //Buffer A-2 Luma org - uint32_t besa2org; - - //Buffer B-1 Chroma 3 plane org - uint32_t besb1c3org; - //Buffer B-1 Chroma org - uint32_t besb1corg; - //Buffer B-1 Luma org - uint32_t besb1org; - - //Buffer B-2 Chroma 3 plane org - uint32_t besb2c3org; - //Buffer B-2 Chroma org - uint32_t besb2corg; - //Buffer B-2 Luma org - uint32_t besb2org; - - //BES Horizontal coord - uint32_t beshcoord; - //BES Horizontal inverse scaling [5.14] - uint32_t beshiscal; - //BES Horizontal source start [10.14] (for scaling) - uint32_t beshsrcst; - //BES Horizontal source ending [10.14] (for scaling) - uint32_t beshsrcend; - //BES Horizontal source last - uint32_t beshsrclst; - - - //BES Vertical coord - uint32_t besvcoord; - //BES Vertical inverse scaling [5.14] - uint32_t besviscal; - //BES Field 1 vertical source last position - uint32_t besv1srclst; - //BES Field 1 weight start - uint32_t besv1wght; - //BES Field 2 vertical source last position - uint32_t besv2srclst; - //BES Field 2 weight start - uint32_t besv2wght; - - - //configurable stuff - int blackie; - -} bes_registers_t; - -#ifdef CRTC2 -typedef struct crtc2_registers_s -{ - uint32_t c2ctl; - uint32_t c2datactl; - uint32_t c2misc; - uint32_t c2hparam; - uint32_t c2hsync; - uint32_t c2offset; - uint32_t c2pl2startadd0; - uint32_t c2pl2startadd1; - uint32_t c2pl3startadd0; - uint32_t c2pl3startadd1; - uint32_t c2preload; - uint32_t c2spicstartadd0; - uint32_t c2spicstartadd1; - uint32_t c2startadd0; - uint32_t c2startadd1; - uint32_t c2subpiclut; - uint32_t c2vcount; - uint32_t c2vparam; - uint32_t c2vsync; -} crtc2_registers_t; -#endif - - - - - -//All register offsets are converted to word aligned offsets (32 bit) -//because we want all our register accesses to be 32 bits -#define VCOUNT 0x1e20 - -#define PALWTADD 0x3c00 // Index register for X_DATAREG port -#define X_DATAREG 0x3c0a - -#define XMULCTRL 0x19 -#define BPP_8 0x00 -#define BPP_15 0x01 -#define BPP_16 0x02 -#define BPP_24 0x03 -#define BPP_32_DIR 0x04 -#define BPP_32_PAL 0x07 - -#define XCOLMSK 0x40 -#define X_COLKEY 0x42 -#define XKEYOPMODE 0x51 -#define XCOLMSK0RED 0x52 -#define XCOLMSK0GREEN 0x53 -#define XCOLMSK0BLUE 0x54 -#define XCOLKEY0RED 0x55 -#define XCOLKEY0GREEN 0x56 -#define XCOLKEY0BLUE 0x57 - -#ifdef CRTC2 - -/*CRTC2 registers*/ -#define XMISCCTRL 0x1e -#define C2CTL 0x3c10 -#define C2DATACTL 0x3c4c -#define C2MISC 0x3c44 -#define C2HPARAM 0x3c14 -#define C2HSYNC 0x3c18 -#define C2OFFSET 0x3c40 -#define C2PL2STARTADD0 0x3c30 // like BESA1CORG -#define C2PL2STARTADD1 0x3c34 // like BESA2CORG -#define C2PL3STARTADD0 0x3c38 // like BESA1C3ORG -#define C2PL3STARTADD1 0x3c3c // like BESA2C3ORG -#define C2PRELOAD 0x3c24 -#define C2SPICSTARTADD0 0x3c54 -#define C2SPICSTARTADD1 0x3c58 -#define C2STARTADD0 0x3c28 // like BESA1ORG -#define C2STARTADD1 0x3c2c // like BESA2ORG -#define C2SUBPICLUT 0x3c50 -#define C2VCOUNT 0x3c48 -#define C2VPARAM 0x3c1c -#define C2VSYNC 0x3c20 - -#endif - -// Backend Scaler registers -#define BESCTL 0x3d20 -#define BESGLOBCTL 0x3dc0 -#define BESLUMACTL 0x3d40 -#define BESPITCH 0x3d24 - -#define BESA1C3ORG 0x3d60 -#define BESA1CORG 0x3d10 -#define BESA1ORG 0x3d00 - -#define BESA2C3ORG 0x3d64 -#define BESA2CORG 0x3d14 -#define BESA2ORG 0x3d04 - -#define BESB1C3ORG 0x3d68 -#define BESB1CORG 0x3d18 -#define BESB1ORG 0x3d08 - -#define BESB2C3ORG 0x3d6C -#define BESB2CORG 0x3d1C -#define BESB2ORG 0x3d0C - -#define BESHCOORD 0x3d28 -#define BESHISCAL 0x3d30 -#define BESHSRCEND 0x3d3C -#define BESHSRCLST 0x3d50 -#define BESHSRCST 0x3d38 -#define BESV1WGHT 0x3d48 -#define BESV2WGHT 0x3d4c -#define BESV1SRCLST 0x3d54 -#define BESV2SRCLST 0x3d58 -#define BESVISCAL 0x3d34 -#define BESVCOORD 0x3d2c -#define BESSTATUS 0x3dc4 - -#define CRTCX 0x1fd4 -#define CRTCD 0x1fd5 -#define IEN 0x1e1c -#define ICLEAR 0x1e18 -#define STATUS 0x1e14 - - -// global devfs handle for /dev/mga_vid -#ifdef CONFIG_DEVFS_FS -static devfs_handle_t dev_handle = NULL; -#endif - -// card local config -typedef struct mga_card_s { - -// local devfs handle for /dev/mga_vidX -#ifdef CONFIG_DEVFS_FS - devfs_handle_t dev_handle; -#endif - - uint8_t *param_buff; // buffer for read() - uint32_t param_buff_size; - uint32_t param_buff_len; - bes_registers_t regs; -#ifdef CRTC2 - crtc2_registers_t cregs; -#endif - uint32_t vid_in_use; - uint32_t is_g400; - uint32_t vid_src_ready; - uint32_t vid_overlay_on; - - uint8_t *mmio_base; - uint32_t mem_base; - int src_base; // YUV buffer position in video memory - uint32_t ram_size; // how much megabytes videoram we have - uint32_t top_reserved; // reserved space for console font (matroxfb + fastfont) - - int brightness; // initial brightness - int contrast; // initial contrast - - struct pci_dev *pci_dev; - - mga_vid_config_t config; - int configured; // set to 1 when the card is configured over ioctl - - int colkey_saved; - int colkey_on; - unsigned char colkey_color[4]; - unsigned char colkey_mask[4]; - - int irq; // = -1 - int next_frame; -} mga_card_t; - -#define MGA_MAX_CARDS 16 -// this is used as init value for the parameter arrays -// it should have exactly MGA_MAX_CARDS elements -#define MGA_MAX_CARDS_INIT_ARRAY {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} -static unsigned int mga_cards_num=0; -static mga_card_t * mga_cards[MGA_MAX_CARDS] = MGA_MAX_CARDS_INIT_ARRAY; - -// module parameters -static int major = DEFAULT_MGA_VID_MAJOR; -static int mga_ram_size[MGA_MAX_CARDS] = MGA_MAX_CARDS_INIT_ARRAY; -static int mga_brightness[MGA_MAX_CARDS] = MGA_MAX_CARDS_INIT_ARRAY; -static int mga_contrast[MGA_MAX_CARDS] = MGA_MAX_CARDS_INIT_ARRAY; -static int mga_top_reserved[MGA_MAX_CARDS] = MGA_MAX_CARDS_INIT_ARRAY; - -MODULE_PARM(mga_ram_size, "1-" __MODULE_STRING(MGA_MAX_CARDS) "i"); -MODULE_PARM(mga_top_reserved, "1-" __MODULE_STRING(MGA_MAX_CARDS) "i"); -MODULE_PARM(mga_brightness, "1-" __MODULE_STRING(MGA_MAX_CARDS) "i"); -MODULE_PARM(mga_contrast, "1-" __MODULE_STRING(MGA_MAX_CARDS) "i"); -MODULE_PARM(major, "i"); - -#ifdef CRTC2 -static void crtc2_frame_sel(mga_card_t * card, int frame) -{ -switch(frame) { -case 0: - card->cregs.c2pl2startadd0=card->regs.besa1corg; - card->cregs.c2pl3startadd0=card->regs.besa1c3org; - card->cregs.c2startadd0=card->regs.besa1org; - break; -case 1: - card->cregs.c2pl2startadd0=card->regs.besa2corg; - card->cregs.c2pl3startadd0=card->regs.besa2c3org; - card->cregs.c2startadd0=card->regs.besa2org; - break; -case 2: - card->cregs.c2pl2startadd0=card->regs.besb1corg; - card->cregs.c2pl3startadd0=card->regs.besb1c3org; - card->cregs.c2startadd0=card->regs.besb1org; - break; -case 3: - card->cregs.c2pl2startadd0=card->regs.besb2corg; - card->cregs.c2pl3startadd0=card->regs.besb2c3org; - card->cregs.c2startadd0=card->regs.besb2org; - break; -} - writel(card->cregs.c2startadd0, card->mmio_base + C2STARTADD0); - writel(card->cregs.c2pl2startadd0, card->mmio_base + C2PL2STARTADD0); - writel(card->cregs.c2pl3startadd0, card->mmio_base + C2PL3STARTADD0); -} -#endif - -static void mga_vid_frame_sel(mga_card_t * card, int frame) -{ - if ( card->irq != -1 ) { - card->next_frame=frame; - } else { - - //we don't need the vcount protection as we're only hitting - //one register (and it doesn't seem to be double buffered) - card->regs.besctl = (card->regs.besctl & ~0x07000000) + (frame << 25); - writel( card->regs.besctl, card->mmio_base + BESCTL ); - -// writel( card->regs.besglobctl + ((readl(card->mmio_base + VCOUNT)+2)<<16), - writel( card->regs.besglobctl + (MGA_VSYNC_POS<<16), - card->mmio_base + BESGLOBCTL); -#ifdef CRTC2 - crtc2_frame_sel(card, frame); -#endif - - } -} - - -static void mga_vid_write_regs(mga_card_t * card, int restore) -{ - //Make sure internal registers don't get updated until we're done - writel( (readl(card->mmio_base + VCOUNT)-1)<<16, - card->mmio_base + BESGLOBCTL); - - // color or coordinate keying - - if(restore && card->colkey_saved){ - // restore it - card->colkey_saved=0; - -#ifdef MP_DEBUG - printk("mga_vid: Restoring colorkey (ON: %d %02X:%02X:%02X)\n", - card->colkey_on,card->colkey_color[0],card->colkey_color[1],card->colkey_color[2]); -#endif - - // Set color key registers: - writeb( XKEYOPMODE, card->mmio_base + PALWTADD); - writeb( card->colkey_on, card->mmio_base + X_DATAREG); - - writeb( XCOLKEY0RED, card->mmio_base + PALWTADD); - writeb( card->colkey_color[0], card->mmio_base + X_DATAREG); - writeb( XCOLKEY0GREEN, card->mmio_base + PALWTADD); - writeb( card->colkey_color[1], card->mmio_base + X_DATAREG); - writeb( XCOLKEY0BLUE, card->mmio_base + PALWTADD); - writeb( card->colkey_color[2], card->mmio_base + X_DATAREG); - writeb( X_COLKEY, card->mmio_base + PALWTADD); - writeb( card->colkey_color[3], card->mmio_base + X_DATAREG); - - writeb( XCOLMSK0RED, card->mmio_base + PALWTADD); - writeb( card->colkey_mask[0], card->mmio_base + X_DATAREG); - writeb( XCOLMSK0GREEN, card->mmio_base + PALWTADD); - writeb( card->colkey_mask[1], card->mmio_base + X_DATAREG); - writeb( XCOLMSK0BLUE, card->mmio_base + PALWTADD); - writeb( card->colkey_mask[2], card->mmio_base + X_DATAREG); - writeb( XCOLMSK, card->mmio_base + PALWTADD); - writeb( card->colkey_mask[3], card->mmio_base + X_DATAREG); - - } else if(!card->colkey_saved){ - // save it - card->colkey_saved=1; - // Get color key registers: - writeb( XKEYOPMODE, card->mmio_base + PALWTADD); - card->colkey_on=(unsigned char)readb(card->mmio_base + X_DATAREG) & 1; - - writeb( XCOLKEY0RED, card->mmio_base + PALWTADD); - card->colkey_color[0]=(unsigned char)readb(card->mmio_base + X_DATAREG); - writeb( XCOLKEY0GREEN, card->mmio_base + PALWTADD); - card->colkey_color[1]=(unsigned char)readb(card->mmio_base + X_DATAREG); - writeb( XCOLKEY0BLUE, card->mmio_base + PALWTADD); - card->colkey_color[2]=(unsigned char)readb(card->mmio_base + X_DATAREG); - writeb( X_COLKEY, card->mmio_base + PALWTADD); - card->colkey_color[3]=(unsigned char)readb(card->mmio_base + X_DATAREG); - - writeb( XCOLMSK0RED, card->mmio_base + PALWTADD); - card->colkey_mask[0]=(unsigned char)readb(card->mmio_base + X_DATAREG); - writeb( XCOLMSK0GREEN, card->mmio_base + PALWTADD); - card->colkey_mask[1]=(unsigned char)readb(card->mmio_base + X_DATAREG); - writeb( XCOLMSK0BLUE, card->mmio_base + PALWTADD); - card->colkey_mask[2]=(unsigned char)readb(card->mmio_base + X_DATAREG); - writeb( XCOLMSK, card->mmio_base + PALWTADD); - card->colkey_mask[3]=(unsigned char)readb(card->mmio_base + X_DATAREG); - -#ifdef MP_DEBUG - printk("mga_vid: Saved colorkey (ON: %d %02X:%02X:%02X)\n", - card->colkey_on, card->colkey_color[0], card->colkey_color[1], card->colkey_color[2]); -#endif - - } - - if(!restore){ - writeb( XKEYOPMODE, card->mmio_base + PALWTADD); - writeb( card->config.colkey_on, card->mmio_base + X_DATAREG); - if ( card->config.colkey_on ) - { - uint32_t r=0, g=0, b=0; - - writeb( XMULCTRL, card->mmio_base + PALWTADD); - switch (readb (card->mmio_base + X_DATAREG)) - { - case BPP_8: - /* Need to look up the color index, just using color 0 for now. */ - break; - - case BPP_15: - r = card->config.colkey_red >> 3; - g = card->config.colkey_green >> 3; - b = card->config.colkey_blue >> 3; - break; - - case BPP_16: - r = card->config.colkey_red >> 3; - g = card->config.colkey_green >> 2; - b = card->config.colkey_blue >> 3; - break; - - case BPP_24: - case BPP_32_DIR: - case BPP_32_PAL: - r = card->config.colkey_red; - g = card->config.colkey_green; - b = card->config.colkey_blue; - break; - } - - // Disable color keying on alpha channel - writeb( XCOLMSK, card->mmio_base + PALWTADD); - writeb( 0x00, card->mmio_base + X_DATAREG); - writeb( X_COLKEY, card->mmio_base + PALWTADD); - writeb( 0x00, card->mmio_base + X_DATAREG); - - - // Set up color key registers - writeb( XCOLKEY0RED, card->mmio_base + PALWTADD); - writeb( r, card->mmio_base + X_DATAREG); - writeb( XCOLKEY0GREEN, card->mmio_base + PALWTADD); - writeb( g, card->mmio_base + X_DATAREG); - writeb( XCOLKEY0BLUE, card->mmio_base + PALWTADD); - writeb( b, card->mmio_base + X_DATAREG); - - // Set up color key mask registers - writeb( XCOLMSK0RED, card->mmio_base + PALWTADD); - writeb( 0xff, card->mmio_base + X_DATAREG); - writeb( XCOLMSK0GREEN, card->mmio_base + PALWTADD); - writeb( 0xff, card->mmio_base + X_DATAREG); - writeb( XCOLMSK0BLUE, card->mmio_base + PALWTADD); - writeb( 0xff, card->mmio_base + X_DATAREG); - } - } - - // Backend Scaler - writel( card->regs.besctl, card->mmio_base + BESCTL); - if(card->is_g400) - writel( card->regs.beslumactl, card->mmio_base + BESLUMACTL); - writel( card->regs.bespitch, card->mmio_base + BESPITCH); - - writel( card->regs.besa1org, card->mmio_base + BESA1ORG); - writel( card->regs.besa1corg, card->mmio_base + BESA1CORG); - writel( card->regs.besa2org, card->mmio_base + BESA2ORG); - writel( card->regs.besa2corg, card->mmio_base + BESA2CORG); - writel( card->regs.besb1org, card->mmio_base + BESB1ORG); - writel( card->regs.besb1corg, card->mmio_base + BESB1CORG); - writel( card->regs.besb2org, card->mmio_base + BESB2ORG); - writel( card->regs.besb2corg, card->mmio_base + BESB2CORG); - if(card->is_g400) - { - writel( card->regs.besa1c3org, card->mmio_base + BESA1C3ORG); - writel( card->regs.besa2c3org, card->mmio_base + BESA2C3ORG); - writel( card->regs.besb1c3org, card->mmio_base + BESB1C3ORG); - writel( card->regs.besb2c3org, card->mmio_base + BESB2C3ORG); - } - - writel( card->regs.beshcoord, card->mmio_base + BESHCOORD); - writel( card->regs.beshiscal, card->mmio_base + BESHISCAL); - writel( card->regs.beshsrcst, card->mmio_base + BESHSRCST); - writel( card->regs.beshsrcend, card->mmio_base + BESHSRCEND); - writel( card->regs.beshsrclst, card->mmio_base + BESHSRCLST); - - writel( card->regs.besvcoord, card->mmio_base + BESVCOORD); - writel( card->regs.besviscal, card->mmio_base + BESVISCAL); - - writel( card->regs.besv1srclst, card->mmio_base + BESV1SRCLST); - writel( card->regs.besv1wght, card->mmio_base + BESV1WGHT); - writel( card->regs.besv2srclst, card->mmio_base + BESV2SRCLST); - writel( card->regs.besv2wght, card->mmio_base + BESV2WGHT); - - //update the registers somewhere between 1 and 2 frames from now. - writel( card->regs.besglobctl + ((readl(card->mmio_base + VCOUNT)+2)<<16), - card->mmio_base + BESGLOBCTL); - -#if 0 - printk(KERN_DEBUG "mga_vid: wrote BES registers\n"); - printk(KERN_DEBUG "mga_vid: BESCTL = 0x%08x\n", - readl(card->mmio_base + BESCTL)); - printk(KERN_DEBUG "mga_vid: BESGLOBCTL = 0x%08x\n", - readl(card->mmio_base + BESGLOBCTL)); - printk(KERN_DEBUG "mga_vid: BESSTATUS= 0x%08x\n", - readl(card->mmio_base + BESSTATUS)); -#endif -#ifdef CRTC2 -// printk("c2ctl:0x%08x c2datactl:0x%08x\n", readl(card->mmio_base + C2CTL), readl(card->mmio_base + C2DATACTL)); -// printk("c2misc:0x%08x\n", readl(card->mmio_base + C2MISC)); -// printk("c2ctl:0x%08x c2datactl:0x%08x\n", card->cregs.c2ctl, card->cregs.c2datactl); - -// writel(card->cregs.c2ctl, card->mmio_base + C2CTL); - - writel(((readl(card->mmio_base + C2CTL) & ~0x03e00000) + (card->cregs.c2ctl & 0x03e00000)), card->mmio_base + C2CTL); - writel(((readl(card->mmio_base + C2DATACTL) & ~0x000000ff) + (card->cregs.c2datactl & 0x000000ff)), card->mmio_base + C2DATACTL); - // ctrc2 - // disable CRTC2 acording to specs -// writel(card->cregs.c2ctl & 0xfffffff0, card->mmio_base + C2CTL); - // je to treba ??? -// writeb((readb(card->mmio_base + XMISCCTRL) & 0x19) | 0xa2, card->mmio_base + XMISCCTRL); // MAFC - mfcsel & vdoutsel -// writeb((readb(card->mmio_base + XMISCCTRL) & 0x19) | 0x92, card->mmio_base + XMISCCTRL); -// writeb((readb(card->mmio_base + XMISCCTRL) & ~0xe9) + 0xa2, card->mmio_base + XMISCCTRL); -// writel(card->cregs.c2datactl, card->mmio_base + C2DATACTL); -// writel(card->cregs.c2hparam, card->mmio_base + C2HPARAM); -// writel(card->cregs.c2hsync, card->mmio_base + C2HSYNC); -// writel(card->cregs.c2vparam, card->mmio_base + C2VPARAM); -// writel(card->cregs.c2vsync, card->mmio_base + C2VSYNC); - writel(card->cregs.c2misc, card->mmio_base + C2MISC); - -#ifdef MP_DEBUG - printk("c2offset = %d\n",card->cregs.c2offset); -#endif - - writel(card->cregs.c2offset, card->mmio_base + C2OFFSET); - writel(card->cregs.c2startadd0, card->mmio_base + C2STARTADD0); -// writel(card->cregs.c2startadd1, card->mmio_base + C2STARTADD1); - writel(card->cregs.c2pl2startadd0, card->mmio_base + C2PL2STARTADD0); -// writel(card->cregs.c2pl2startadd1, card->mmio_base + C2PL2STARTADD1); - writel(card->cregs.c2pl3startadd0, card->mmio_base + C2PL3STARTADD0); -// writel(card->cregs.c2pl3startadd1, card->mmio_base + C2PL3STARTADD1); - writel(card->cregs.c2spicstartadd0, card->mmio_base + C2SPICSTARTADD0); -// writel(card->cregs.c2spicstartadd1, card->mmio_base + C2SPICSTARTADD1); -// writel(card->cregs.c2subpiclut, card->mmio_base + C2SUBPICLUT); -// writel(card->cregs.c2preload, card->mmio_base + C2PRELOAD); - // finaly enable everything -// writel(card->cregs.c2ctl, card->mmio_base + C2CTL); -// printk("c2ctl:0x%08x c2datactl:0x%08x\n",readl(card->mmio_base + C2CTL),readl(card->mmio_base + C2DATACTL)); -// printk("c2misc:0x%08x\n", readl(card->mmio_base + C2MISC)); -#endif -} - -static int mga_vid_set_config(mga_card_t * card) -{ - int x, y, sw, sh, dw, dh; - int besleft, bestop, ifactor, ofsleft, ofstop, baseadrofs, weight, weights; - mga_vid_config_t *config = &card->config; - int frame_size = card->config.frame_size; - -#ifdef CRTC2 -#define right_margin 0 -#define left_margin 18 -#define hsync_len 46 -#define lower_margin 10 -#define vsync_len 4 -#define upper_margin 39 - - unsigned int hdispend = (config->src_width + 31) & ~31; - unsigned int hsyncstart = hdispend + (right_margin & ~7); - unsigned int hsyncend = hsyncstart + (hsync_len & ~7); - unsigned int htotal = hsyncend + (left_margin & ~7); - unsigned int vdispend = config->src_height; - unsigned int vsyncstart = vdispend + lower_margin; - unsigned int vsyncend = vsyncstart + vsync_len; - unsigned int vtotal = vsyncend + upper_margin; -#endif - x = config->x_org; - y = config->y_org; - sw = config->src_width; - sh = config->src_height; - dw = config->dest_width; - dh = config->dest_height; - -#ifdef MP_DEBUG - printk(KERN_DEBUG "mga_vid: Setting up a %dx%d+%d+%d video window (src %dx%d) format %X\n", - dw, dh, x, y, sw, sh, config->format); -#endif - - if(sw<4 || sh<4 || dw<4 || dh<4){ - printk(KERN_ERR "mga_vid: Invalid src/dest dimenstions\n"); - return -1; - } - - //FIXME check that window is valid and inside desktop - - //Setup the BES registers for a three plane 4:2:0 video source - - card->regs.besglobctl = 0; - - switch(config->format){ - case MGA_VID_FORMAT_YV12: - case MGA_VID_FORMAT_I420: - case MGA_VID_FORMAT_IYUV: - card->regs.besctl = 1 // BES enabled - + (0<<6) // even start polarity - + (1<<10) // x filtering enabled - + (1<<11) // y filtering enabled - + (1<<16) // chroma upsampling - + (1<<17) // 4:2:0 mode - + (1<<18); // dither enabled -#if 0 - if(card->is_g400) - { - //zoom disabled, zoom filter disabled, 420 3 plane format, proc amp - //disabled, rgb mode disabled - card->regs.besglobctl = (1<<5); - } - else - { - //zoom disabled, zoom filter disabled, Cb samples in 0246, Cr - //in 1357, BES register update on besvcnt - card->regs.besglobctl = 0; - } -#endif - break; - - case MGA_VID_FORMAT_YUY2: - card->regs.besctl = 1 // BES enabled - + (0<<6) // even start polarity - + (1<<10) // x filtering enabled - + (1<<11) // y filtering enabled - + (1<<16) // chroma upsampling - + (0<<17) // 4:2:2 mode - + (1<<18); // dither enabled - - card->regs.besglobctl = 0; // YUY2 format selected - break; - - case MGA_VID_FORMAT_UYVY: - card->regs.besctl = 1 // BES enabled - + (0<<6) // even start polarity - + (1<<10) // x filtering enabled - + (1<<11) // y filtering enabled - + (1<<16) // chroma upsampling - + (0<<17) // 4:2:2 mode - + (1<<18); // dither enabled - - card->regs.besglobctl = 1<<6; // UYVY format selected - break; - - default: - printk(KERN_ERR "mga_vid: Unsupported pixel format: 0x%X\n",config->format); - return -1; -} - - // setting black&white mode - card->regs.besctl|=(card->regs.blackie<<20); - - //Enable contrast and brightness control - card->regs.besglobctl |= (1<<5) + (1<<7); - - // brightness (-128..127) && contrast (0..255) - card->regs.beslumactl = (card->brightness << 16) | ((card->contrast+0x80)&0xFFFF); - - //Setup destination window boundaries - besleft = x > 0 ? x : 0; - bestop = y > 0 ? y : 0; - card->regs.beshcoord = (besleft<<16) + (x + dw-1); - card->regs.besvcoord = (bestop<<16) + (y + dh-1); - - //Setup source dimensions - card->regs.beshsrclst = (sw - 1) << 16; - card->regs.bespitch = (sw + 31) & ~31 ; - - //Setup horizontal scaling - ifactor = ((sw-1)<<14)/(dw-1); - ofsleft = besleft - x; - - card->regs.beshiscal = ifactor<<2; - card->regs.beshsrcst = (ofsleft*ifactor)<<2; - card->regs.beshsrcend = card->regs.beshsrcst + (((dw - ofsleft - 1) * ifactor) << 2); - - //Setup vertical scaling - ifactor = ((sh-1)<<14)/(dh-1); - ofstop = bestop - y; - - card->regs.besviscal = ifactor<<2; - - baseadrofs = ( (ofstop * card->regs.besviscal) >>16) * card->regs.bespitch; - //frame_size = ((sw + 31) & ~31) * sh + (((sw + 31) & ~31) * sh) / 2; - card->regs.besa1org = (uint32_t) card->src_base + baseadrofs; - card->regs.besa2org = (uint32_t) card->src_base + baseadrofs + 1*frame_size; - card->regs.besb1org = (uint32_t) card->src_base + baseadrofs + 2*frame_size; - card->regs.besb2org = (uint32_t) card->src_base + baseadrofs + 3*frame_size; - - if(config->format==MGA_VID_FORMAT_YV12 - ||config->format==MGA_VID_FORMAT_IYUV - ||config->format==MGA_VID_FORMAT_I420 - ){ - // planar YUV frames: - if (card->is_g400) - baseadrofs = ( ( (ofstop * card->regs.besviscal ) / 4 ) >> 16 ) * card->regs.bespitch; - else - baseadrofs = ( ( ( ofstop * card->regs.besviscal ) / 2 ) >> 16 ) * card->regs.bespitch; - - if(config->format==MGA_VID_FORMAT_YV12 || !card->is_g400){ - card->regs.besa1corg = (uint32_t) card->src_base + baseadrofs + card->regs.bespitch * sh ; - card->regs.besa2corg = (uint32_t) card->src_base + baseadrofs + 1*frame_size + card->regs.bespitch * sh; - card->regs.besb1corg = (uint32_t) card->src_base + baseadrofs + 2*frame_size + card->regs.bespitch * sh; - card->regs.besb2corg = (uint32_t) card->src_base + baseadrofs + 3*frame_size + card->regs.bespitch * sh; - card->regs.besa1c3org = card->regs.besa1corg + ( (card->regs.bespitch * sh) / 4); - card->regs.besa2c3org = card->regs.besa2corg + ( (card->regs.bespitch * sh) / 4); - card->regs.besb1c3org = card->regs.besb1corg + ( (card->regs.bespitch * sh) / 4); - card->regs.besb2c3org = card->regs.besb2corg + ( (card->regs.bespitch * sh) / 4); - } else { - card->regs.besa1c3org = (uint32_t) card->src_base + baseadrofs + card->regs.bespitch * sh ; - card->regs.besa2c3org = (uint32_t) card->src_base + baseadrofs + 1*frame_size + card->regs.bespitch * sh; - card->regs.besb1c3org = (uint32_t) card->src_base + baseadrofs + 2*frame_size + card->regs.bespitch * sh; - card->regs.besb2c3org = (uint32_t) card->src_base + baseadrofs + 3*frame_size + card->regs.bespitch * sh; - card->regs.besa1corg = card->regs.besa1c3org + ((card->regs.bespitch * sh) / 4); - card->regs.besa2corg = card->regs.besa2c3org + ((card->regs.bespitch * sh) / 4); - card->regs.besb1corg = card->regs.besb1c3org + ((card->regs.bespitch * sh) / 4); - card->regs.besb2corg = card->regs.besb2c3org + ((card->regs.bespitch * sh) / 4); - } - } - - weight = ofstop * (card->regs.besviscal >> 2); - weights = weight < 0 ? 1 : 0; - card->regs.besv2wght = card->regs.besv1wght = (weights << 16) + ((weight & 0x3FFF) << 2); - card->regs.besv2srclst = card->regs.besv1srclst = sh - 1 - (((ofstop * card->regs.besviscal) >> 16) & 0x03FF); - -#ifdef CRTC2 - // pridat hlavni registry - tj. casovani ... - - - switch(config->format){ - case MGA_VID_FORMAT_YV12: - case MGA_VID_FORMAT_I420: - case MGA_VID_FORMAT_IYUV: - card->cregs.c2ctl = 1 // CRTC2 enabled - + (1<<1) // external clock - + (0<<2) // external clock - + (1<<3) // pixel clock enable - not needed ??? - + (0<<4) // high prioryty req - + (1<<5) // high prioryty req - + (0<<6) // high prioryty req - + (1<<8) // high prioryty req max - + (0<<9) // high prioryty req max - + (0<<10) // high prioryty req max - + (0<<20) // CRTC1 to DAC - + (1<<21) // 420 mode - + (1<<22) // 420 mode - + (1<<23) // 420 mode - + (0<<24) // single chroma line for 420 mode - need to be corrected - + (0<<25) /*/ interlace mode - need to be corrected*/ - + (0<<26) // field legth polariry - + (0<<27) // field identification polariry - + (1<<28) // VIDRST detection mode - + (0<<29) // VIDRST detection mode - + (1<<30) // Horizontal counter preload - + (1<<31) // Vertical counter preload - ; - card->cregs.c2datactl = 1 // disable dither - propably not needed, we are already in YUV mode - + (1<<1) // Y filter enable - + (1<<2) // CbCr filter enable - + (0<<3) // subpicture enable (disabled) - + (0<<4) // NTSC enable (disabled - PAL) - + (0<<5) // C2 static subpicture enable (disabled) - + (0<<6) // C2 subpicture offset division (disabled) - + (0<<7) // 422 subformat selection ! -/* + (0<<8) // 15 bpp high alpha - + (0<<9) // 15 bpp high alpha - + (0<<10) // 15 bpp high alpha - + (0<<11) // 15 bpp high alpha - + (0<<12) // 15 bpp high alpha - + (0<<13) // 15 bpp high alpha - + (0<<14) // 15 bpp high alpha - + (0<<15) // 15 bpp high alpha - + (0<<16) // 15 bpp low alpha - + (0<<17) // 15 bpp low alpha - + (0<<18) // 15 bpp low alpha - + (0<<19) // 15 bpp low alpha - + (0<<20) // 15 bpp low alpha - + (0<<21) // 15 bpp low alpha - + (0<<22) // 15 bpp low alpha - + (0<<23) // 15 bpp low alpha - + (0<<24) // static subpicture key - + (0<<25) // static subpicture key - + (0<<26) // static subpicture key - + (0<<27) // static subpicture key - + (0<<28) // static subpicture key -*/ ; - break; - - case MGA_VID_FORMAT_YUY2: - card->cregs.c2ctl = 1 // CRTC2 enabled - + (1<<1) // external clock - + (0<<2) // external clock - + (1<<3) // pixel clock enable - not needed ??? - + (0<<4) // high prioryty req - acc to spec - + (1<<5) // high prioryty req - + (0<<6) // high prioryty req - // 7 reserved - + (1<<8) // high prioryty req max - + (0<<9) // high prioryty req max - + (0<<10) // high prioryty req max - // 11-19 reserved - + (0<<20) // CRTC1 to DAC - + (1<<21) // 422 mode - + (0<<22) // 422 mode - + (1<<23) // 422 mode - + (0<<24) // single chroma line for 420 mode - need to be corrected - + (0<<25) /*/ interlace mode - need to be corrected*/ - + (0<<26) // field legth polariry - + (0<<27) // field identification polariry - + (1<<28) // VIDRST detection mode - + (0<<29) // VIDRST detection mode - + (1<<30) // Horizontal counter preload - + (1<<31) // Vertical counter preload - ; - card->cregs.c2datactl = 1 // disable dither - propably not needed, we are already in YUV mode - + (1<<1) // Y filter enable - + (1<<2) // CbCr filter enable - + (0<<3) // subpicture enable (disabled) - + (0<<4) // NTSC enable (disabled - PAL) - + (0<<5) // C2 static subpicture enable (disabled) - + (0<<6) // C2 subpicture offset division (disabled) - + (0<<7) // 422 subformat selection ! -/* + (0<<8) // 15 bpp high alpha - + (0<<9) // 15 bpp high alpha - + (0<<10) // 15 bpp high alpha - + (0<<11) // 15 bpp high alpha - + (0<<12) // 15 bpp high alpha - + (0<<13) // 15 bpp high alpha - + (0<<14) // 15 bpp high alpha - + (0<<15) // 15 bpp high alpha - + (0<<16) // 15 bpp low alpha - + (0<<17) // 15 bpp low alpha - + (0<<18) // 15 bpp low alpha - + (0<<19) // 15 bpp low alpha - + (0<<20) // 15 bpp low alpha - + (0<<21) // 15 bpp low alpha - + (0<<22) // 15 bpp low alpha - + (0<<23) // 15 bpp low alpha - + (0<<24) // static subpicture key - + (0<<25) // static subpicture key - + (0<<26) // static subpicture key - + (0<<27) // static subpicture key - + (0<<28) // static subpicture key -*/ ; - break; - - case MGA_VID_FORMAT_UYVY: - card->cregs.c2ctl = 1 // CRTC2 enabled - + (1<<1) // external clock - + (0<<2) // external clock - + (1<<3) // pixel clock enable - not needed ??? - + (0<<4) // high prioryty req - + (1<<5) // high prioryty req - + (0<<6) // high prioryty req - + (1<<8) // high prioryty req max - + (0<<9) // high prioryty req max - + (0<<10) // high prioryty req max - + (0<<20) // CRTC1 to DAC - + (1<<21) // 422 mode - + (0<<22) // 422 mode - + (1<<23) // 422 mode - + (1<<24) // single chroma line for 420 mode - need to be corrected - + (1<<25) /*/ interlace mode - need to be corrected*/ - + (0<<26) // field legth polariry - + (0<<27) // field identification polariry - + (1<<28) // VIDRST detection mode - + (0<<29) // VIDRST detection mode - + (1<<30) // Horizontal counter preload - + (1<<31) // Vertical counter preload - ; - card->cregs.c2datactl = 0 // enable dither - propably not needed, we are already in YUV mode - + (1<<1) // Y filter enable - + (1<<2) // CbCr filter enable - + (0<<3) // subpicture enable (disabled) - + (0<<4) // NTSC enable (disabled - PAL) - + (0<<5) // C2 static subpicture enable (disabled) - + (0<<6) // C2 subpicture offset division (disabled) - + (1<<7) // 422 subformat selection ! -/* + (0<<8) // 15 bpp high alpha - + (0<<9) // 15 bpp high alpha - + (0<<10) // 15 bpp high alpha - + (0<<11) // 15 bpp high alpha - + (0<<12) // 15 bpp high alpha - + (0<<13) // 15 bpp high alpha - + (0<<14) // 15 bpp high alpha - + (0<<15) // 15 bpp high alpha - + (0<<16) // 15 bpp low alpha - + (0<<17) // 15 bpp low alpha - + (0<<18) // 15 bpp low alpha - + (0<<19) // 15 bpp low alpha - + (0<<20) // 15 bpp low alpha - + (0<<21) // 15 bpp low alpha - + (0<<22) // 15 bpp low alpha - + (0<<23) // 15 bpp low alpha - + (0<<24) // static subpicture key - + (0<<25) // static subpicture key - + (0<<26) // static subpicture key - + (0<<27) // static subpicture key - + (0<<28) // static subpicture key -*/ ; - break; - - default: - printk(KERN_ERR "mga_vid: Unsupported pixel format: 0x%X\n",config->format); - return -1; - } - - card->cregs.c2hparam = ( (hdispend - 8) << 16) | (htotal - 8); - card->cregs.c2hsync = ( (hsyncend - 8) << 16) | (hsyncstart - 8); - - card->cregs.c2misc = 0 // CRTCV2 656 togg f0 - + (0<<1) // CRTCV2 656 togg f0 - + (0<<2) // CRTCV2 656 togg f0 - + (0<<4) // CRTCV2 656 togg f1 - + (0<<5) // CRTCV2 656 togg f1 - + (0<<6) // CRTCV2 656 togg f1 - + (0<<8) // Hsync active high - + (0<<9) // Vsync active high - // 16-27 c2vlinecomp - nevim co tam dat - ; - card->cregs.c2offset=(card->regs.bespitch << 1); - - card->cregs.c2pl2startadd0=card->regs.besa1corg; -// card->cregs.c2pl2startadd1=card->regs.besa2corg; - card->cregs.c2pl3startadd0=card->regs.besa1c3org; -// card->cregs.c2pl3startadd1=card->regs.besa2c3org; - - card->cregs.c2preload=(vsyncstart << 16) | (hsyncstart); // from - - card->cregs.c2spicstartadd0=0; // not used -// card->cregs.c2spicstartadd1=0; // not used - - card->cregs.c2startadd0=card->regs.besa1org; -// card->cregs.c2startadd1=card->regs.besa2org; - - card->cregs.c2subpiclut=0; //not used - - card->cregs.c2vparam = ( (vdispend - 1) << 16) | (vtotal - 1); - card->cregs.c2vsync = ( (vsyncend - 1) << 16) | (vsyncstart - 1); - - -#endif - - mga_vid_write_regs(card, 0); - return 0; -} - -#ifdef MGA_ALLOW_IRQ - -static void enable_irq(mga_card_t * card){ - long int cc; - - cc = readl(card->mmio_base + IEN); -// printk(KERN_ALERT "*** !!! IRQREG = %d\n", (int)(cc&0xff)); - - writeb(0x11, card->mmio_base + CRTCX); - - writeb(0x20, card->mmio_base + CRTCD); /* clear 0, enable off */ - writeb(0x00, card->mmio_base + CRTCD); /* enable on */ - writeb(0x10, card->mmio_base + CRTCD); /* clear = 1 */ - - writel(card->regs.besglobctl , card->mmio_base + BESGLOBCTL); -} - -static void disable_irq(mga_card_t * card){ - writeb(0x11, card->mmio_base + CRTCX); - writeb(0x20, card->mmio_base + CRTCD); /* clear 0, enable off */ -} - -static void mga_handle_irq(int irq, void *dev_id, struct pt_regs *pregs) { -// static int frame=0; -// static int counter=0; - long int cc; - mga_card_t * card = dev_id; - -// printk(KERN_DEBUG "vcount = %d\n",readl(mga_mmio_base + VCOUNT)); - - //printk("mga_interrupt #%d\n", irq); - - // check whether the interrupt is really for us (irq sharing) - if ( irq != -1 ) { - cc = readl(card->mmio_base + STATUS); - if ( ! (cc & 0x10) ) return; /* vsyncpen */ -// debug_irqcnt++; - } - -// if ( debug_irqignore ) { -// debug_irqignore = 0; - -// frame=(frame+1)&1; - card->regs.besctl = (card->regs.besctl & ~0x07000000) + (card->next_frame << 25); - writel( card->regs.besctl, card->mmio_base + BESCTL ); - -#ifdef CRTC2 -// sem pridat vyber obrazku !!!! -// i han echt kei ahnig was das obe heisse söll - crtc2_frame_sel(card->next_frame); -#endif - -#if 0 - ++counter; - if(!(counter&63)){ - printk("mga irq counter = %d\n",counter); - } -#endif - -// } else { -// debug_irqignore = 1; -// } - - if ( irq != -1 ) { - writeb( 0x11, card->mmio_base + CRTCX); - writeb( 0, card->mmio_base + CRTCD ); - writeb( 0x10, card->mmio_base + CRTCD ); - } - -// writel( card->regs.besglobctl, card->mmio_base + BESGLOBCTL); - - return; -} - -#endif - -static int mga_vid_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) -{ - int frame, result; - uint32_t tmp; - mga_card_t * card = (mga_card_t *) file->private_data; - - switch(cmd) - { - case MGA_VID_GET_VERSION: - tmp = MGA_VID_VERSION; - if (copy_to_user((uint32_t *) arg, &tmp, sizeof(uint32_t))) { - printk(KERN_ERR "mga_vid: failed copy %p to userspace %p\n", &tmp, (uint32_t *) arg); - return -EFAULT; - } - break; - - case MGA_VID_CONFIG: - //FIXME remove -// printk(KERN_DEBUG "mga_vid: vcount = %d\n",readl(card->mmio_base + VCOUNT)); -#ifdef MP_DEBUG - printk(KERN_DEBUG "mga_vid: mmio_base = %p\n",card->mmio_base); - printk(KERN_DEBUG "mga_vid: mem_base = %08x\n",card->mem_base); - //FIXME remove - - printk(KERN_DEBUG "mga_vid: Received configuration\n"); -#endif - - if(copy_from_user(&card->config,(mga_vid_config_t*) arg,sizeof(mga_vid_config_t))) - { - printk(KERN_ERR "mga_vid: failed copy from userspace\n"); - return -EFAULT; - } - if(card->config.version != MGA_VID_VERSION){ - printk(KERN_ERR "mga_vid: incompatible version! driver: %X requested: %X\n",MGA_VID_VERSION,card->config.version); - return -EFAULT; - } - - if(card->config.frame_size==0 || card->config.frame_size>1024*768*2){ - printk(KERN_ERR "mga_vid: illegal frame_size: %d\n",card->config.frame_size); - return -EFAULT; - } - - if(card->config.num_frames<1 || card->config.num_frames>4){ - printk(KERN_ERR "mga_vid: illegal num_frames: %d\n",card->config.num_frames); - return -EFAULT; - } - - card->src_base = (card->ram_size * 0x100000 - card->config.num_frames * card->config.frame_size - card->top_reserved); - if(card->src_base<0){ - printk(KERN_ERR "mga_vid: not enough memory for frames!\n"); - return -EFAULT; - } - card->src_base &= (~0xFFFF); // 64k boundary -#ifdef MP_DEBUG - printk(KERN_DEBUG "mga YUV buffer base: 0x%X\n", card->src_base); -#endif - - if (card->is_g400) - card->config.card_type = MGA_G400; - else - card->config.card_type = MGA_G200; - - card->config.ram_size = card->ram_size; - - if (copy_to_user((mga_vid_config_t *) arg, &card->config, sizeof(mga_vid_config_t))) - { - printk(KERN_ERR "mga_vid: failed copy to userspace\n"); - return -EFAULT; - } - - result = mga_vid_set_config(card); - if(!result) card->configured=1; - return result; - break; - - case MGA_VID_ON: -#ifdef MP_DEBUG - printk(KERN_DEBUG "mga_vid: Video ON\n"); -#endif - card->vid_src_ready = 1; - if(card->vid_overlay_on) - { - card->regs.besctl |= 1; - mga_vid_write_regs(card, 0); - } -#ifdef MGA_ALLOW_IRQ - if ( card->irq != -1 ) enable_irq(card); -#endif - card->next_frame=0; - break; - - case MGA_VID_OFF: -#ifdef MP_DEBUG - printk(KERN_DEBUG "mga_vid: Video OFF (ioctl)\n"); -#endif - card->vid_src_ready = 0; -#ifdef MGA_ALLOW_IRQ - if ( card->irq != -1 ) disable_irq(card); -#endif - card->regs.besctl &= ~1; - card->regs.besglobctl &= ~(1<<6); // UYVY format selected - mga_vid_write_regs(card, 0); - break; - - case MGA_VID_FSEL: - if(copy_from_user(&frame,(int *) arg,sizeof(int))) - { - printk(KERN_ERR "mga_vid: FSEL failed copy from userspace\n"); - return -EFAULT; - } - - mga_vid_frame_sel(card, frame); - break; - - case MGA_VID_GET_LUMA: - //tmp = card->regs.beslumactl; - //tmp = (tmp&0xFFFF0000) | (((tmp&0xFFFF) - 0x80)&0xFFFF); - tmp = (card->brightness << 16) | (card->contrast&0xFFFF); - - if (copy_to_user((uint32_t *) arg, &tmp, sizeof(uint32_t))) - { - printk(KERN_ERR "mga_vid: failed copy %p to userspace %p\n", - &tmp, (uint32_t *) arg); - return -EFAULT; - } - break; - - case MGA_VID_SET_LUMA: - tmp = arg; - card->brightness=tmp>>16; card->contrast=tmp&0xFFFF; - //card->regs.beslumactl = (tmp&0xFFFF0000) | ((tmp + 0x80)&0xFFFF); - card->regs.beslumactl = (card->brightness << 16) | ((card->contrast+0x80)&0xFFFF); - mga_vid_write_regs(card, 0); - break; - - default: - printk(KERN_ERR "mga_vid: Invalid ioctl\n"); - return -EINVAL; - } - - return 0; -} - -static void cards_init(mga_card_t * card, struct pci_dev * dev, int card_number, int is_g400); - -// returns the number of found cards -static int mga_vid_find_card(void) -{ - struct pci_dev *dev = NULL; - char *mga_dev_name; - mga_card_t * card; - - while((dev = pci_find_device(PCI_VENDOR_ID_MATROX, PCI_ANY_ID, dev))) - { - mga_dev_name = ""; - mga_cards_num++; - if(mga_cards_num == MGA_MAX_CARDS) - { - printk(KERN_WARNING "mga_vid: Trying to initialize more than %d cards\n",MGA_MAX_CARDS); - mga_cards_num--; - break; - } - - card = kmalloc(sizeof(mga_card_t), GFP_KERNEL); - if(!card) - { - printk(KERN_ERR "mga_vid: memory allocation failed\n"); - mga_cards_num--; - break; - } - - mga_cards[mga_cards_num - 1] = card; - - switch(dev->device) { - case PCI_DEVICE_ID_MATROX_G550: - mga_dev_name = "MGA G550"; - printk(KERN_INFO "mga_vid: Found %s at %s [%s]\n", mga_dev_name, dev->slot_name, dev->name); - cards_init(card, dev, mga_cards_num - 1, 1); - break; - case PCI_DEVICE_ID_MATROX_G400: - mga_dev_name = "MGA G400/G450"; - printk(KERN_INFO "mga_vid: Found %s at %s [%s]\n", mga_dev_name, dev->slot_name, dev->name); - cards_init(card, dev, mga_cards_num - 1, 1); - break; - case PCI_DEVICE_ID_MATROX_G200_AGP: - mga_dev_name = "MGA G200 AGP"; - printk(KERN_INFO "mga_vid: Found %s at %s [%s]\n", mga_dev_name, dev->slot_name, dev->name); - cards_init(card, dev, mga_cards_num - 1, 0); - break; - case PCI_DEVICE_ID_MATROX_G200_PCI: - mga_dev_name = "MGA G200"; - printk(KERN_INFO "mga_vid: Found %s at %s [%s]\n", mga_dev_name, dev->slot_name, dev->name); - cards_init(card, dev, mga_cards_num - 1, 0); - break; - default: - mga_cards_num--; - printk(KERN_INFO "mga_vid: ignoring matrox device (%d) at %s [%s]\n", dev->device, dev->slot_name, dev->name); - break; - } - } - - if(!mga_cards_num) - { - printk(KERN_ERR "mga_vid: No supported cards found\n"); - } else { - printk(KERN_INFO "mga_vid: %d supported cards found\n", mga_cards_num); - } - - return mga_cards_num; -} - -static void mga_param_buff_fill( mga_card_t * card ) -{ - unsigned len; - unsigned size = card->param_buff_size; - char * buf = card->param_buff; - len = 0; - len += snprintf(&buf[len],size-len,"Interface version: %04X\n",MGA_VID_VERSION); - len += snprintf(&buf[len],size-len,"Memory: %x:%dM\n",card->mem_base,(unsigned int) card->ram_size); - len += snprintf(&buf[len],size-len,"MMIO: %p\n",card->mmio_base); - len += snprintf(&buf[len],size-len,"Configurable stuff:\n"); - len += snprintf(&buf[len],size-len,"~~~~~~~~~~~~~~~~~~~\n"); - len += snprintf(&buf[len],size-len,PARAM_BRIGHTNESS"%d\n",card->brightness); - len += snprintf(&buf[len],size-len,PARAM_CONTRAST"%d\n",card->contrast); - len += snprintf(&buf[len],size-len,PARAM_BLACKIE"%s\n",card->regs.blackie?"on":"off"); - card->param_buff_len = len; - // check boundaries of mga_param_buff before writing to it!!! -} - - -static ssize_t mga_vid_read(struct file *file, char *buf, size_t count, loff_t *ppos) -{ - uint32_t size; - mga_card_t * card = (mga_card_t *) file->private_data; - - if(!card->param_buff) return -ESPIPE; - if(!(*ppos)) mga_param_buff_fill(card); - if(*ppos >= card->param_buff_len) return 0; - size = min(count,card->param_buff_len-(uint32_t)(*ppos)); - memcpy(buf,card->param_buff,size); - *ppos += size; - return size; -} - -static ssize_t mga_vid_write(struct file *file, const char *buf, size_t count, loff_t *ppos) -{ - mga_card_t * card = (mga_card_t *) file->private_data; - - if(memcmp(buf,PARAM_BRIGHTNESS,min(count,strlen(PARAM_BRIGHTNESS))) == 0) - { - short brightness; - brightness=simple_strtol(&buf[strlen(PARAM_BRIGHTNESS)],NULL,10); - if (brightness>127 || brightness<-128) { brightness=0;} -// printk(KERN_DEBUG "mga_vid: brightness modified ( %d ) \n",brightness); - card->brightness=brightness; - } else - if(memcmp(buf,PARAM_CONTRAST,min(count,strlen(PARAM_CONTRAST))) == 0) - { - short contrast; - contrast=simple_strtol(&buf[strlen(PARAM_CONTRAST)],NULL,10); - if (contrast>127 || contrast<-128) { contrast=0;} -// printk(KERN_DEBUG "mga_vid: contrast modified ( %d ) \n",contrast); - card->contrast=contrast; - } else - - if(memcmp(buf,PARAM_BLACKIE,min(count,strlen(PARAM_BLACKIE))) == 0) - { - short blackie; - blackie=simple_strtol(&buf[strlen(PARAM_BLACKIE)],NULL,10); -// printk(KERN_DEBUG "mga_vid: shadow mode: ( %d ) \n",blackie); - card->regs.blackie=(blackie>0)?1:0; - } else count = -EIO; - // TODO: reset settings - return count; -} - -static int mga_vid_mmap(struct file *file, struct vm_area_struct *vma) -{ - mga_card_t * card = (mga_card_t *) file->private_data; - -#ifdef MP_DEBUG - printk(KERN_DEBUG "mga_vid: mapping video memory into userspace\n"); -#endif - - if(!card->configured) - { - printk(KERN_ERR "mga_vid: card is not configured, cannot mmap\n"); - return -EAGAIN; - } - - if(remap_page_range(vma->vm_start, card->mem_base + card->src_base, - vma->vm_end - vma->vm_start, vma->vm_page_prot)) - { - printk(KERN_ERR "mga_vid: error mapping video memory\n"); - return -EAGAIN; - } - - return 0; -} - -static int mga_vid_release(struct inode *inode, struct file *file) -{ - mga_card_t * card; - - //Close the window just in case -#ifdef MP_DEBUG - printk(KERN_DEBUG "mga_vid: Video OFF (release)\n"); -#endif - - card = (mga_card_t *) file->private_data; - - card->vid_src_ready = 0; - card->regs.besctl &= ~1; - card->regs.besglobctl &= ~(1<<6); // UYVY format selected -// card->config.colkey_on=0; //!!! - mga_vid_write_regs(card, 1); - card->vid_in_use = 0; - - MOD_DEC_USE_COUNT; - return 0; -} - -static long long mga_vid_lseek(struct file *file, long long offset, int origin) -{ - return -ESPIPE; -} - -static int mga_vid_open(struct inode *inode, struct file *file) -{ - mga_card_t * card; - - int minor = MINOR(inode->i_rdev); - - if(!file->private_data) - { - // we are not using devfs, use the minor - // number to specify the card we are using - - // we don't have that many cards - if(minor >= mga_cards_num) - return -ENXIO; - - file->private_data = mga_cards[minor]; -#ifdef MP_DEBUG - printk(KERN_DEBUG "mga_vid: Not using devfs\n"); -#endif - } -#ifdef MP_DEBUG - else { - printk(KERN_DEBUG "mga_vid: Using devfs\n"); - } -#endif - - card = (mga_card_t *) file->private_data; - - if(card->vid_in_use == 1) - return -EBUSY; - - card->vid_in_use = 1; - MOD_INC_USE_COUNT; - return 0; -} - -#if LINUX_VERSION_CODE >= 0x020400 -static struct file_operations mga_vid_fops = -{ - llseek: mga_vid_lseek, - read: mga_vid_read, - write: mga_vid_write, - ioctl: mga_vid_ioctl, - mmap: mga_vid_mmap, - open: mga_vid_open, - release: mga_vid_release -}; -#else -static struct file_operations mga_vid_fops = -{ - mga_vid_lseek, - mga_vid_read, - mga_vid_write, - NULL, - NULL, - mga_vid_ioctl, - mga_vid_mmap, - mga_vid_open, - NULL, - mga_vid_release -}; -#endif - -static void cards_init(mga_card_t * card, struct pci_dev * dev, int card_number, int is_g400) -{ - unsigned int card_option; -// temp buffer for device filename creation used only by devfs -#ifdef CONFIG_DEVFS_FS - char buffer[16]; -#endif - - memset(card,0,sizeof(mga_card_t)); - card->irq = -1; - - card->pci_dev = dev; - card->irq = dev->irq; - card->is_g400 = is_g400; - - card->param_buff = kmalloc(PARAM_BUFF_SIZE,GFP_KERNEL); - if(card->param_buff) card->param_buff_size = PARAM_BUFF_SIZE; - - card->brightness = mga_brightness[card_number]; - card->contrast = mga_contrast[card_number]; - card->top_reserved = mga_top_reserved[card_number]; - -#if LINUX_VERSION_CODE >= 0x020300 - card->mmio_base = ioremap_nocache(dev->resource[1].start,0x4000); - card->mem_base = dev->resource[0].start; -#else - card->mmio_base = ioremap_nocache(dev->base_address[1] & PCI_BASE_ADDRESS_MEM_MASK,0x4000); - card->mem_base = dev->base_address[0] & PCI_BASE_ADDRESS_MEM_MASK; -#endif - printk(KERN_INFO "mga_vid: MMIO at 0x%p IRQ: %d framebuffer: 0x%08X\n", card->mmio_base, card->irq, card->mem_base); - - pci_read_config_dword(dev, 0x40, &card_option); - printk(KERN_INFO "mga_vid: OPTION word: 0x%08X mem: 0x%02X %s\n", card_option, - (card_option>>10)&0x17, ((card_option>>14)&1)?"SGRAM":"SDRAM"); - - if (mga_ram_size[card_number]) { - printk(KERN_INFO "mga_vid: RAMSIZE forced to %d MB\n", mga_ram_size[card_number]); - card->ram_size=mga_ram_size[card_number]; - } else { - -#ifdef MGA_MEMORY_SIZE - card->ram_size = MGA_MEMORY_SIZE; - printk(KERN_INFO "mga_vid: hard-coded RAMSIZE is %d MB\n", (unsigned int) card->ram_size); -#else - if (card->is_g400){ - switch((card_option>>10)&0x17){ - // SDRAM: - case 0x00: - case 0x04: card->ram_size = 16; break; - case 0x03: - case 0x05: card->ram_size = 32; break; - // SGRAM: - case 0x10: - case 0x14: card->ram_size = 32; break; - case 0x11: - case 0x12: card->ram_size = 16; break; - default: - card->ram_size = 16; - printk(KERN_INFO "mga_vid: Couldn't detect RAMSIZE, assuming 16MB!"); - } - /* Check for buggy 16MB cards reporting 32 MB */ - if(card->ram_size != 16 && - (dev->subsystem_device == PCI_SUBSYSTEM_ID_MATROX_G400_16MB_SDRAM || - dev->subsystem_device == PCI_SUBSYSTEM_ID_MATROX_G400_16MB_SGRAM || - dev->subsystem_device == PCI_SUBSYSTEM_ID_MATROX_G400_DH_16MB)) - { - printk(KERN_INFO "mga_vid: Detected 16MB card reporting %d MB RAMSIZE, overriding\n", card->ram_size); - card->ram_size = 16; - } - }else{ - switch((card_option>>10)&0x17){ -// case 0x10: -// case 0x13: card->ram_size = 8; break; - default: card->ram_size = 8; - } - } -#if 0 -// printk("List resources -----------\n"); - for(temp=0;tempresource[temp]; - if(res->flags){ - int size=(1+res->end-res->start)>>20; - printk(KERN_DEBUG "res %d: start: 0x%X end: 0x%X (%d MB) flags=0x%X\n",temp,res->start,res->end,size,res->flags); - if(res->flags&(IORESOURCE_MEM|IORESOURCE_PREFETCH)){ - if(size>card->ram_size && size<=64) card->ram_size=size; - } - } - } -#endif - printk(KERN_INFO "mga_vid: detected RAMSIZE is %d MB\n", (unsigned int) card->ram_size); -#endif - } - - -#ifdef MGA_ALLOW_IRQ - if ( card->irq != -1 ) { - int tmp = request_irq(card->irq, mga_handle_irq, SA_INTERRUPT | SA_SHIRQ, "Syncfb Time Base", card); - if ( tmp ) { - printk(KERN_INFO "syncfb (mga): cannot register irq %d (Err: %d)\n", card->irq, tmp); - card->irq=-1; - } else { - printk(KERN_DEBUG "syncfb (mga): registered irq %d\n", card->irq); - } - } else { - printk(KERN_INFO "syncfb (mga): No valid irq was found\n"); - card->irq=-1; - } -#else - printk(KERN_INFO "syncfb (mga): IRQ disabled in mga_vid.c\n"); - card->irq=-1; -#endif - - // register devfs, let the kernel give us major and minor numbers -#ifdef CONFIG_DEVFS_FS - snprintf(buffer, 16, "mga_vid%d", card_number); - card->dev_handle = devfs_register(NULL, buffer, DEVFS_FL_AUTO_DEVNUM, - 0, 0, - S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IFCHR, - &mga_vid_fops, card); -#endif -} - -/* - * Main Initialization Function - */ - -static int mga_vid_initialize(void) -{ - int i; - -// printk(KERN_INFO "Matrox MGA G200/G400 YUV Video interface v0.01 (c) Aaron Holtzman \n"); - printk(KERN_INFO "Matrox MGA G200/G400/G450/G550 YUV Video interface v2.01 (c) Aaron Holtzman & A'rpi\n"); - - for(i = 0; i < MGA_MAX_CARDS; i++) - { - if (mga_ram_size[i]) { - if (mga_ram_size[i]<4 || mga_ram_size[i]>64) { - printk(KERN_ERR "mga_vid: invalid RAMSIZE: %d MB\n", mga_ram_size[i]); - return -EINVAL; - } - } - } - - if(register_chrdev(major, "mga_vid", &mga_vid_fops)) - { - printk(KERN_ERR "mga_vid: unable to get major: %d\n", major); - return -EIO; - } - - if (!mga_vid_find_card()) - { - printk(KERN_ERR "mga_vid: no supported devices found\n"); - unregister_chrdev(major, "mga_vid"); - return -EINVAL; - } -#ifdef CONFIG_DEVFS_FS - else { - // we assume that this always succeedes - dev_handle = devfs_register(NULL, "mga_vid", DEVFS_FL_AUTO_DEVNUM, - 0,0, - S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IFCHR, - &mga_vid_fops, mga_cards[0]); - } -#endif - - return 0; -} - -int init_module(void) -{ - return mga_vid_initialize(); -} - -void cleanup_module(void) -{ - int i; - mga_card_t * card; - - for (i = 0; i < MGA_MAX_CARDS; i++) - { - card = mga_cards[i]; - if(card) - { -#ifdef MGA_ALLOW_IRQ - if (card->irq != -1) - free_irq(card->irq, &(card->irq)); -#endif - - if(card->mmio_base) - iounmap(card->mmio_base); - if(card->param_buff) - kfree(card->param_buff); -#ifdef CONFIG_DEVFS_FS - if(card->dev_handle) devfs_unregister(card->dev_handle); -#endif - - kfree(card); - mga_cards[i]=NULL; - } - } - - //FIXME turn off BES - printk(KERN_INFO "mga_vid: Cleaning up module\n"); -#ifdef CONFIG_DEVFS_FS - if(dev_handle) devfs_unregister(dev_handle); -#endif - unregister_chrdev(major, "mga_vid"); -} diff --git a/drivers/mga_vid.h b/drivers/mga_vid.h deleted file mode 100644 index 0e9dcfc8f9..0000000000 --- a/drivers/mga_vid.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Matrox MGA G200/G400 YUV Video Interface module Version 0.1.0 - * BES == Back End Scaler - * - * Copyright (C) 1999 Aaron Holtzman - * - * This file is part of mga_vid. - * - * mga_vid is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * mga_vid is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with mga_vid; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef MGA_VID_H -#define MGA_VID_H - -typedef struct mga_vid_config_s -{ -uint16_t version; -uint16_t card_type; -uint32_t ram_size; -uint32_t src_width; -uint32_t src_height; -uint32_t dest_width; -uint32_t dest_height; -uint32_t x_org; -uint32_t y_org; -uint8_t colkey_on; -uint8_t colkey_red; -uint8_t colkey_green; -uint8_t colkey_blue; -uint32_t format; -uint32_t frame_size; -uint32_t num_frames; -uint32_t capabilities; -} mga_vid_config_t; - -/* supported FOURCCs */ -#define MGA_VID_FORMAT_YV12 0x32315659 -#define MGA_VID_FORMAT_IYUV (('I'<<24)|('Y'<<16)|('U'<<8)|'V') -#define MGA_VID_FORMAT_I420 (('I'<<24)|('4'<<16)|('2'<<8)|'0') -#define MGA_VID_FORMAT_YUY2 (('Y'<<24)|('U'<<16)|('Y'<<8)|'2') -#define MGA_VID_FORMAT_UYVY (('U'<<24)|('Y'<<16)|('V'<<8)|'Y') - -/* ioctl commands */ -#define MGA_VID_GET_VERSION _IOR ('J', 1, uint32_t) -#define MGA_VID_CONFIG _IOWR('J', 2, mga_vid_config_t) -#define MGA_VID_ON _IO ('J', 3) -#define MGA_VID_OFF _IO ('J', 4) -#define MGA_VID_FSEL _IOW ('J', 5, uint32_t) -#define MGA_VID_GET_LUMA _IOR ('J', 6, uint32_t) -#define MGA_VID_SET_LUMA _IOW ('J', 7, uint32_t) - -/* card identifiers */ -#define MGA_G200 0x1234 -#define MGA_G400 0x5678 -// currently unused, G450 are mapped to MGA_G400 -// #define MGA_G450 0x9ABC -#define MGA_G550 0xDEF0 - -/* version of the mga_vid_config struct */ -#define MGA_VID_VERSION 0x0202 - -#endif /* MGA_VID_H */ diff --git a/drivers/mga_vid_test.c b/drivers/mga_vid_test.c deleted file mode 100644 index 8555905a46..0000000000 --- a/drivers/mga_vid_test.c +++ /dev/null @@ -1,235 +0,0 @@ -/* - * Copyright (C) 1999 Aaron Holtzman - * - * This file is part of mga_vid. - * - * mga_vid is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * mga_vid is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with mga_vid; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -//#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "mga_vid.h" - -mga_vid_config_t config; -uint8_t *mga_vid_base; -uint32_t is_g400; - -#define SRC_IMAGE_WIDTH 256 -#define SRC_IMAGE_HEIGHT 256 - -uint8_t y_image[SRC_IMAGE_WIDTH * SRC_IMAGE_HEIGHT]; -uint8_t cr_image[SRC_IMAGE_WIDTH * SRC_IMAGE_HEIGHT]; -uint8_t cb_image[SRC_IMAGE_WIDTH * SRC_IMAGE_HEIGHT]; - - -void -write_frame_g200(uint8_t *y,uint8_t *cr, uint8_t *cb) -{ - uint8_t *dest; - uint32_t bespitch,h,w; - - dest = mga_vid_base; - bespitch = (config.src_width + 31) & ~31; - - for(h=0; h < config.src_height; h++) - { - memcpy(dest, y, config.src_width); - y += config.src_width; - dest += bespitch; - } - - for(h=0; h < config.src_height/2; h++) - { - for(w=0; w < config.src_width/2; w++) - { - *dest++ = *cb++; - *dest++ = *cr++; - } - dest += bespitch - config.src_width; - } -} - -void -write_frame_g400(uint8_t *y,uint8_t *cr, uint8_t *cb) -{ - uint8_t *dest; - uint32_t bespitch,h; - - dest = mga_vid_base; - bespitch = (config.src_width + 31) & ~31; - - for(h=0; h < config.src_height; h++) - { - memcpy(dest, y, config.src_width); - y += config.src_width; - dest += bespitch; - } - - for(h=0; h < config.src_height/2; h++) - { - memcpy(dest, cb, config.src_width/2); - cb += config.src_width/2; - dest += bespitch/2; - } - - for(h=0; h < config.src_height/2; h++) - { - memcpy(dest, cr, config.src_width/2); - cr += config.src_width/2; - dest += bespitch/2; - } -} - -void write_frame(uint8_t *y,uint8_t *cr, uint8_t *cb) -{ - if(is_g400) - write_frame_g400(y,cr,cb); - else - write_frame_g200(y,cr,cb); -} - -void -draw_cool_pattern(void) -{ - int i,x,y; - - i = 0; - for (y=0; y -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "radeon_vid.h" -#include "radeon.h" - -#ifdef CONFIG_MTRR -#include -#endif - -#include -#include -#include - -#define TRUE 1 -#define FALSE 0 - -#define RADEON_VID_MAJOR 178 - - -MODULE_AUTHOR("Nick Kurshev "); -#ifdef RAGE128 -MODULE_DESCRIPTION("Accelerated YUV BES driver for Rage128. Version: "RADEON_VID_VERSION); -#else -MODULE_DESCRIPTION("Accelerated YUV BES driver for Radeons. Version: "RADEON_VID_VERSION); -#endif -#ifdef MODULE_LICENSE -MODULE_LICENSE("GPL"); -#endif -#ifdef CONFIG_MTRR -MODULE_PARM(mtrr, "i"); -MODULE_PARM_DESC(mtrr, "Tune MTRR (touch=1(default))"); -static int mtrr __initdata = 1; -static struct { int vram; int vram_valid; } smtrr; -#endif -MODULE_PARM(swap_fourcc, "i"); -MODULE_PARM_DESC(swap_fourcc, "Swap fourcc (don't swap=0(default))"); -static int swap_fourcc __initdata = 0; - -#ifdef RAGE128 -#define RVID_MSG "rage128_vid: " -#define X_ADJUST 0 -#else -#define RVID_MSG "radeon_vid: " -#define X_ADJUST 8 -#ifndef RADEON -#define RADEON -#endif -#endif - -#undef DEBUG -#if DEBUG -#define RTRACE printk -#else -#define RTRACE(...) ((void)0) -#endif - -#ifndef min -#define min(a,b) (a < b ? a : b) -#endif - -#ifndef RAGE128 -#if defined(__i386__) -/* Ugly but only way */ -#undef AVOID_FPU -static inline double FastSin(double x) -{ - register double res; - __asm__ volatile("fsin":"=t"(res):"0"(x)); - return res; -} -#undef sin -#define sin(x) FastSin(x) - -static inline double FastCos(double x) -{ - register double res; - __asm__ volatile("fcos":"=t"(res):"0"(x)); - return res; -} -#undef cos -#define cos(x) FastCos(x) -#else -#include "generic_math.h" -#endif /*__386__*/ -#endif /*RAGE128*/ - -#if !defined( RAGE128 ) && !defined( AVOID_FPU ) -#define RADEON_FPU 1 -#endif - -typedef struct bes_registers_s -{ - /* base address of yuv framebuffer */ - uint32_t yuv_base; - uint32_t fourcc; - uint32_t dest_bpp; - /* YUV BES registers */ - uint32_t reg_load_cntl; - uint32_t h_inc; - uint32_t step_by; - uint32_t y_x_start; - uint32_t y_x_end; - uint32_t v_inc; - uint32_t p1_blank_lines_at_top; - uint32_t p23_blank_lines_at_top; - uint32_t vid_buf_pitch0_value; - uint32_t vid_buf_pitch1_value; - uint32_t p1_x_start_end; - uint32_t p2_x_start_end; - uint32_t p3_x_start_end; - uint32_t base_addr; - uint32_t vid_buf0_base_adrs; - /* These ones are for auto flip: maybe in the future */ - uint32_t vid_buf1_base_adrs; - uint32_t vid_buf2_base_adrs; - uint32_t vid_buf3_base_adrs; - uint32_t vid_buf4_base_adrs; - uint32_t vid_buf5_base_adrs; - - uint32_t p1_v_accum_init; - uint32_t p1_h_accum_init; - uint32_t p23_v_accum_init; - uint32_t p23_h_accum_init; - uint32_t scale_cntl; - uint32_t exclusive_horz; - uint32_t auto_flip_cntl; - uint32_t filter_cntl; - uint32_t key_cntl; - uint32_t test; - /* Configurable stuff */ - int double_buff; - - int brightness; - int saturation; - - int ckey_on; - uint32_t graphics_key_clr; - uint32_t graphics_key_msk; - - int deinterlace_on; - uint32_t deinterlace_pattern; - -} bes_registers_t; - -typedef struct video_registers_s -{ -#ifdef DEBUG - const char * sname; -#endif - uint32_t name; - uint32_t value; -}video_registers_t; - -static bes_registers_t besr; -#ifndef RAGE128 -static int IsR200=0; -#endif -#ifdef DEBUG -#define DECLARE_VREG(name) { #name, name, 0 } -#else -#define DECLARE_VREG(name) { name, 0 } -#endif -#ifdef DEBUG -static video_registers_t vregs[] = -{ - DECLARE_VREG(VIDEOMUX_CNTL), - DECLARE_VREG(VIPPAD_MASK), - DECLARE_VREG(VIPPAD1_A), - DECLARE_VREG(VIPPAD1_EN), - DECLARE_VREG(VIPPAD1_Y), - DECLARE_VREG(OV0_Y_X_START), - DECLARE_VREG(OV0_Y_X_END), - DECLARE_VREG(OV0_PIPELINE_CNTL), - DECLARE_VREG(OV0_EXCLUSIVE_HORZ), - DECLARE_VREG(OV0_EXCLUSIVE_VERT), - DECLARE_VREG(OV0_REG_LOAD_CNTL), - DECLARE_VREG(OV0_SCALE_CNTL), - DECLARE_VREG(OV0_V_INC), - DECLARE_VREG(OV0_P1_V_ACCUM_INIT), - DECLARE_VREG(OV0_P23_V_ACCUM_INIT), - DECLARE_VREG(OV0_P1_BLANK_LINES_AT_TOP), - DECLARE_VREG(OV0_P23_BLANK_LINES_AT_TOP), -#ifdef RADEON - DECLARE_VREG(OV0_BASE_ADDR), -#endif - DECLARE_VREG(OV0_VID_BUF0_BASE_ADRS), - DECLARE_VREG(OV0_VID_BUF1_BASE_ADRS), - DECLARE_VREG(OV0_VID_BUF2_BASE_ADRS), - DECLARE_VREG(OV0_VID_BUF3_BASE_ADRS), - DECLARE_VREG(OV0_VID_BUF4_BASE_ADRS), - DECLARE_VREG(OV0_VID_BUF5_BASE_ADRS), - DECLARE_VREG(OV0_VID_BUF_PITCH0_VALUE), - DECLARE_VREG(OV0_VID_BUF_PITCH1_VALUE), - DECLARE_VREG(OV0_AUTO_FLIP_CNTL), - DECLARE_VREG(OV0_DEINTERLACE_PATTERN), - DECLARE_VREG(OV0_SUBMIT_HISTORY), - DECLARE_VREG(OV0_H_INC), - DECLARE_VREG(OV0_STEP_BY), - DECLARE_VREG(OV0_P1_H_ACCUM_INIT), - DECLARE_VREG(OV0_P23_H_ACCUM_INIT), - DECLARE_VREG(OV0_P1_X_START_END), - DECLARE_VREG(OV0_P2_X_START_END), - DECLARE_VREG(OV0_P3_X_START_END), - DECLARE_VREG(OV0_FILTER_CNTL), - DECLARE_VREG(OV0_FOUR_TAP_COEF_0), - DECLARE_VREG(OV0_FOUR_TAP_COEF_1), - DECLARE_VREG(OV0_FOUR_TAP_COEF_2), - DECLARE_VREG(OV0_FOUR_TAP_COEF_3), - DECLARE_VREG(OV0_FOUR_TAP_COEF_4), - DECLARE_VREG(OV0_FLAG_CNTL), -#ifdef RAGE128 - DECLARE_VREG(OV0_COLOUR_CNTL), -#else - DECLARE_VREG(OV0_SLICE_CNTL), -#endif - DECLARE_VREG(OV0_VID_KEY_CLR), - DECLARE_VREG(OV0_VID_KEY_MSK), - DECLARE_VREG(OV0_GRAPHICS_KEY_CLR), - DECLARE_VREG(OV0_GRAPHICS_KEY_MSK), - DECLARE_VREG(OV0_KEY_CNTL), - DECLARE_VREG(OV0_TEST), - DECLARE_VREG(OV0_LIN_TRANS_A), - DECLARE_VREG(OV0_LIN_TRANS_B), - DECLARE_VREG(OV0_LIN_TRANS_C), - DECLARE_VREG(OV0_LIN_TRANS_D), - DECLARE_VREG(OV0_LIN_TRANS_E), - DECLARE_VREG(OV0_LIN_TRANS_F), - DECLARE_VREG(OV0_GAMMA_0_F), - DECLARE_VREG(OV0_GAMMA_10_1F), - DECLARE_VREG(OV0_GAMMA_20_3F), - DECLARE_VREG(OV0_GAMMA_40_7F), - DECLARE_VREG(OV0_GAMMA_380_3BF), - DECLARE_VREG(OV0_GAMMA_3C0_3FF), - DECLARE_VREG(SUBPIC_CNTL), - DECLARE_VREG(SUBPIC_DEFCOLCON), - DECLARE_VREG(SUBPIC_Y_X_START), - DECLARE_VREG(SUBPIC_Y_X_END), - DECLARE_VREG(SUBPIC_V_INC), - DECLARE_VREG(SUBPIC_H_INC), - DECLARE_VREG(SUBPIC_BUF0_OFFSET), - DECLARE_VREG(SUBPIC_BUF1_OFFSET), - DECLARE_VREG(SUBPIC_LC0_OFFSET), - DECLARE_VREG(SUBPIC_LC1_OFFSET), - DECLARE_VREG(SUBPIC_PITCH), - DECLARE_VREG(SUBPIC_BTN_HLI_COLCON), - DECLARE_VREG(SUBPIC_BTN_HLI_Y_X_START), - DECLARE_VREG(SUBPIC_BTN_HLI_Y_X_END), - DECLARE_VREG(SUBPIC_PALETTE_INDEX), - DECLARE_VREG(SUBPIC_PALETTE_DATA), - DECLARE_VREG(SUBPIC_H_ACCUM_INIT), - DECLARE_VREG(SUBPIC_V_ACCUM_INIT), - DECLARE_VREG(IDCT_RUNS), - DECLARE_VREG(IDCT_LEVELS), - DECLARE_VREG(IDCT_AUTH_CONTROL), - DECLARE_VREG(IDCT_AUTH), - DECLARE_VREG(IDCT_CONTROL) -}; -#endif -static uint32_t radeon_vid_in_use = 0; - -static uint8_t *radeon_mmio_base = 0; -static uint32_t radeon_mem_base = 0; -static int32_t radeon_overlay_off = 0; -static uint32_t radeon_ram_size = 0; -#define PARAM_BUFF_SIZE 4096 -static uint8_t *radeon_param_buff = NULL; -static uint32_t radeon_param_buff_size=0; -static uint32_t radeon_param_buff_len=0; /* real length of buffer */ -static mga_vid_config_t radeon_config; - -static char *fourcc_format_name(int format) -{ - switch(format) - { - case IMGFMT_RGB8: return "RGB 8-bit"; - case IMGFMT_RGB15: return "RGB 15-bit"; - case IMGFMT_RGB16: return "RGB 16-bit"; - case IMGFMT_RGB24: return "RGB 24-bit"; - case IMGFMT_RGB32: return "RGB 32-bit"; - case IMGFMT_BGR8: return "BGR 8-bit"; - case IMGFMT_BGR15: return "BGR 15-bit"; - case IMGFMT_BGR16: return "BGR 16-bit"; - case IMGFMT_BGR24: return "BGR 24-bit"; - case IMGFMT_BGR32: return "BGR 32-bit"; - case IMGFMT_YVU9: return "Planar YVU9"; - case IMGFMT_IF09: return "Planar IF09"; - case IMGFMT_YV12: return "Planar YV12"; - case IMGFMT_I420: return "Planar I420"; - case IMGFMT_IYUV: return "Planar IYUV"; - case IMGFMT_CLPL: return "Planar CLPL"; - case IMGFMT_Y800: return "Planar Y800"; - case IMGFMT_Y8: return "Planar Y8"; - case IMGFMT_IUYV: return "Packed IUYV"; - case IMGFMT_IY41: return "Packed IY41"; - case IMGFMT_IYU1: return "Packed IYU1"; - case IMGFMT_IYU2: return "Packed IYU2"; - case IMGFMT_UYNV: return "Packed UYNV"; - case IMGFMT_cyuv: return "Packed CYUV"; - case IMGFMT_Y422: return "Packed Y422"; - case IMGFMT_YUY2: return "Packed YUY2"; - case IMGFMT_YUNV: return "Packed YUNV"; - case IMGFMT_UYVY: return "Packed UYVY"; -// case IMGFMT_YVYU: return "Packed YVYU"; - case IMGFMT_Y41P: return "Packed Y41P"; - case IMGFMT_Y211: return "Packed Y211"; - case IMGFMT_Y41T: return "Packed Y41T"; - case IMGFMT_Y42T: return "Packed Y42T"; - case IMGFMT_V422: return "Packed V422"; - case IMGFMT_V655: return "Packed V655"; - case IMGFMT_CLJR: return "Packed CLJR"; - case IMGFMT_YUVP: return "Packed YUVP"; - case IMGFMT_UYVP: return "Packed UYVP"; - case IMGFMT_MPEGPES: return "Mpeg PES"; - } - return "Unknown"; -} - - -/* - * IO macros - */ - -#define INREG8(addr) readb((radeon_mmio_base)+addr) -#define OUTREG8(addr,val) writeb(val, (radeon_mmio_base)+addr) -#define INREG(addr) readl((radeon_mmio_base)+addr) -#define OUTREG(addr,val) writel(val, (radeon_mmio_base)+addr) -#define OUTREGP(addr,val,mask) \ - do { \ - unsigned int tmp = INREG(addr); \ - tmp &= (mask); \ - tmp |= (val); \ - OUTREG(addr, tmp); \ - } while (0) - -static uint32_t radeon_vid_get_dbpp( void ) -{ - uint32_t dbpp,retval; - dbpp = (INREG(CRTC_GEN_CNTL)>>8)& 0xF; - switch(dbpp) - { - case DST_8BPP: retval = 8; break; - case DST_15BPP: retval = 15; break; - case DST_16BPP: retval = 16; break; - case DST_24BPP: retval = 24; break; - default: retval=32; break; - } - return retval; -} - -static int radeon_is_dbl_scan( void ) -{ - return (INREG(CRTC_GEN_CNTL))&CRTC_DBL_SCAN_EN; -} - -static int radeon_is_interlace( void ) -{ - return (INREG(CRTC_GEN_CNTL))&CRTC_INTERLACE_EN; -} - -static __inline__ void radeon_engine_flush ( void ) -{ - int i; - - /* initiate flush */ - OUTREGP(RB2D_DSTCACHE_CTLSTAT, RB2D_DC_FLUSH_ALL, - ~RB2D_DC_FLUSH_ALL); - - for (i=0; i < 2000000; i++) { - if (!(INREG(RB2D_DSTCACHE_CTLSTAT) & RB2D_DC_BUSY)) - break; - } -} - - -static __inline__ void radeon_fifo_wait (int entries) -{ - int i; - - for (i=0; i<2000000; i++) - if ((INREG(RBBM_STATUS) & 0x7f) >= entries) - return; -} - - -static __inline__ void radeon_engine_idle ( void ) -{ - int i; - - /* ensure FIFO is empty before waiting for idle */ - radeon_fifo_wait (64); - - for (i=0; i<2000000; i++) { - if (((INREG(RBBM_STATUS) & GUI_ACTIVE)) == 0) { - radeon_engine_flush (); - return; - } - } -} - -#if 0 -static void __init radeon_vid_save_state( void ) -{ - size_t i; - for(i=0;i= 2) return; - - OvHueSin = sin((double)hue); - OvHueCos = cos((double)hue); - - CAdjLuma = cont * trans[ref].RefLuma; - CAdjOff = cont * trans[ref].RefLuma * bright * 1023.0; - - CAdjRCb = sat * -OvHueSin * trans[ref].RefRCr; - CAdjRCr = sat * OvHueCos * trans[ref].RefRCr; - CAdjGCb = sat * (OvHueCos * trans[ref].RefGCb - OvHueSin * trans[ref].RefGCr); - CAdjGCr = sat * (OvHueSin * trans[ref].RefGCb + OvHueCos * trans[ref].RefGCr); - CAdjBCb = sat * OvHueCos * trans[ref].RefBCb; - CAdjBCr = sat * OvHueSin * trans[ref].RefBCb; - -#if 0 /* default constants */ - CAdjLuma = 1.16455078125; - - CAdjRCb = 0.0; - CAdjRCr = 1.59619140625; - CAdjGCb = -0.39111328125; - CAdjGCr = -0.8125; - CAdjBCb = 2.01708984375; - CAdjBCr = 0; -#endif - OvLuma = CAdjLuma; - OvRCb = CAdjRCb; - OvRCr = CAdjRCr; - OvGCb = CAdjGCb; - OvGCr = CAdjGCr; - OvBCb = CAdjBCb; - OvBCr = CAdjBCr; - OvROff = CAdjOff - - OvLuma * Loff - (OvRCb + OvRCr) * Coff; - OvGOff = CAdjOff - - OvLuma * Loff - (OvGCb + OvGCr) * Coff; - OvBOff = CAdjOff - - OvLuma * Loff - (OvBCb + OvBCr) * Coff; -#if 0 /* default constants */ - OvROff = -888.5; - OvGOff = 545; - OvBOff = -1104; -#endif - - dwOvROff = ((int)(OvROff * 2.0)) & 0x1fff; - dwOvGOff = (int)(OvGOff * 2.0) & 0x1fff; - dwOvBOff = (int)(OvBOff * 2.0) & 0x1fff; - if(!IsR200) - { - dwOvLuma =(((int)(OvLuma * 2048.0))&0x7fff)<<17; - dwOvRCb = (((int)(OvRCb * 2048.0))&0x7fff)<<1; - dwOvRCr = (((int)(OvRCr * 2048.0))&0x7fff)<<17; - dwOvGCb = (((int)(OvGCb * 2048.0))&0x7fff)<<1; - dwOvGCr = (((int)(OvGCr * 2048.0))&0x7fff)<<17; - dwOvBCb = (((int)(OvBCb * 2048.0))&0x7fff)<<1; - dwOvBCr = (((int)(OvBCr * 2048.0))&0x7fff)<<17; - } - else - { - dwOvLuma = (((int)(OvLuma * 256.0))&0x7ff)<<20; - dwOvRCb = (((int)(OvRCb * 256.0))&0x7ff)<<4; - dwOvRCr = (((int)(OvRCr * 256.0))&0x7ff)<<20; - dwOvGCb = (((int)(OvGCb * 256.0))&0x7ff)<<4; - dwOvGCr = (((int)(OvGCr * 256.0))&0x7ff)<<20; - dwOvBCb = (((int)(OvBCb * 256.0))&0x7ff)<<4; - dwOvBCr = (((int)(OvBCr * 256.0))&0x7ff)<<20; - } - - OUTREG(OV0_LIN_TRANS_A, dwOvRCb | dwOvLuma); - OUTREG(OV0_LIN_TRANS_B, dwOvROff | dwOvRCr); - OUTREG(OV0_LIN_TRANS_C, dwOvGCb | dwOvLuma); - OUTREG(OV0_LIN_TRANS_D, dwOvGOff | dwOvGCr); - OUTREG(OV0_LIN_TRANS_E, dwOvBCb | dwOvLuma); - OUTREG(OV0_LIN_TRANS_F, dwOvBOff | dwOvBCr); -} -#endif - -#ifndef RAGE128 -/* Gamma curve definition */ -typedef struct -{ - unsigned int gammaReg; - unsigned int gammaSlope; - unsigned int gammaOffset; -}GAMMA_SETTINGS; - -/* Recommended gamma curve parameters */ -GAMMA_SETTINGS r200_def_gamma[18] = -{ - {OV0_GAMMA_0_F, 0x100, 0x0000}, - {OV0_GAMMA_10_1F, 0x100, 0x0020}, - {OV0_GAMMA_20_3F, 0x100, 0x0040}, - {OV0_GAMMA_40_7F, 0x100, 0x0080}, - {OV0_GAMMA_80_BF, 0x100, 0x0100}, - {OV0_GAMMA_C0_FF, 0x100, 0x0100}, - {OV0_GAMMA_100_13F, 0x100, 0x0200}, - {OV0_GAMMA_140_17F, 0x100, 0x0200}, - {OV0_GAMMA_180_1BF, 0x100, 0x0300}, - {OV0_GAMMA_1C0_1FF, 0x100, 0x0300}, - {OV0_GAMMA_200_23F, 0x100, 0x0400}, - {OV0_GAMMA_240_27F, 0x100, 0x0400}, - {OV0_GAMMA_280_2BF, 0x100, 0x0500}, - {OV0_GAMMA_2C0_2FF, 0x100, 0x0500}, - {OV0_GAMMA_300_33F, 0x100, 0x0600}, - {OV0_GAMMA_340_37F, 0x100, 0x0600}, - {OV0_GAMMA_380_3BF, 0x100, 0x0700}, - {OV0_GAMMA_3C0_3FF, 0x100, 0x0700} -}; - -GAMMA_SETTINGS r100_def_gamma[6] = -{ - {OV0_GAMMA_0_F, 0x100, 0x0000}, - {OV0_GAMMA_10_1F, 0x100, 0x0020}, - {OV0_GAMMA_20_3F, 0x100, 0x0040}, - {OV0_GAMMA_40_7F, 0x100, 0x0080}, - {OV0_GAMMA_380_3BF, 0x100, 0x0100}, - {OV0_GAMMA_3C0_3FF, 0x100, 0x0100} -}; - -static void make_default_gamma_correction( void ) -{ - size_t i; - if(!IsR200){ - OUTREG(OV0_LIN_TRANS_A, 0x12A00000); - OUTREG(OV0_LIN_TRANS_B, 0x199018FE); - OUTREG(OV0_LIN_TRANS_C, 0x12A0F9B0); - OUTREG(OV0_LIN_TRANS_D, 0xF2F0043B); - OUTREG(OV0_LIN_TRANS_E, 0x12A02050); - OUTREG(OV0_LIN_TRANS_F, 0x0000174E); - for(i=0; i<6; i++){ - OUTREG(r100_def_gamma[i].gammaReg, - (r100_def_gamma[i].gammaSlope<<16) | - r100_def_gamma[i].gammaOffset); - } - } - else{ - OUTREG(OV0_LIN_TRANS_A, 0x12a00000); - OUTREG(OV0_LIN_TRANS_B, 0x1990190e); - OUTREG(OV0_LIN_TRANS_C, 0x12a0f9c0); - OUTREG(OV0_LIN_TRANS_D, 0xf3000442); - OUTREG(OV0_LIN_TRANS_E, 0x12a02040); - OUTREG(OV0_LIN_TRANS_F, 0x175f); - - /* Default Gamma, - Of 18 segments for gamma cure, all segments in R200 are programmable, - while only lower 4 and upper 2 segments are programmable in Radeon*/ - for(i=0; i<18; i++){ - OUTREG(r200_def_gamma[i].gammaReg, - (r200_def_gamma[i].gammaSlope<<16) | - r200_def_gamma[i].gammaOffset); - } - } -} -#endif - -static void radeon_vid_stop_video( void ) -{ - radeon_engine_idle(); - OUTREG(OV0_SCALE_CNTL, SCALER_SOFT_RESET); - OUTREG(OV0_EXCLUSIVE_HORZ, 0); - OUTREG(OV0_AUTO_FLIP_CNTL, 0); /* maybe */ - OUTREG(OV0_FILTER_CNTL, FILTER_HARDCODED_COEF); - OUTREG(OV0_KEY_CNTL, GRAPHIC_KEY_FN_NE); - OUTREG(OV0_TEST, 0); -} - -static void radeon_vid_display_video( void ) -{ - int bes_flags; - radeon_fifo_wait(2); - OUTREG(OV0_REG_LOAD_CNTL, REG_LD_CTL_LOCK); - radeon_engine_idle(); - while(!(INREG(OV0_REG_LOAD_CNTL)®_LD_CTL_LOCK_READBACK)); - radeon_fifo_wait(15); - OUTREG(OV0_AUTO_FLIP_CNTL,OV0_AUTO_FLIP_CNTL_SOFT_BUF_ODD); - OUTREG(OV0_AUTO_FLIP_CNTL,(INREG(OV0_AUTO_FLIP_CNTL)^OV0_AUTO_FLIP_CNTL_SOFT_EOF_TOGGLE)); - OUTREG(OV0_AUTO_FLIP_CNTL,(INREG(OV0_AUTO_FLIP_CNTL)^OV0_AUTO_FLIP_CNTL_SOFT_EOF_TOGGLE)); - - OUTREG(OV0_DEINTERLACE_PATTERN,besr.deinterlace_pattern); -#ifdef RAGE128 - OUTREG(OV0_COLOUR_CNTL, (besr.brightness & 0x7f) | - (besr.saturation << 8) | - (besr.saturation << 16)); -#endif - radeon_fifo_wait(2); - if(besr.ckey_on) - { - OUTREG(OV0_GRAPHICS_KEY_MSK, besr.graphics_key_msk); - OUTREG(OV0_GRAPHICS_KEY_CLR, besr.graphics_key_clr); - OUTREG(OV0_KEY_CNTL,GRAPHIC_KEY_FN_EQ|VIDEO_KEY_FN_FALSE|CMP_MIX_OR); - } - else - { - OUTREG(OV0_GRAPHICS_KEY_MSK, 0ULL); - OUTREG(OV0_GRAPHICS_KEY_CLR, 0ULL); - OUTREG(OV0_KEY_CNTL,GRAPHIC_KEY_FN_NE); - } - - OUTREG(OV0_H_INC, besr.h_inc); - OUTREG(OV0_STEP_BY, besr.step_by); - OUTREG(OV0_Y_X_START, besr.y_x_start); - OUTREG(OV0_Y_X_END, besr.y_x_end); - OUTREG(OV0_V_INC, besr.v_inc); - OUTREG(OV0_P1_BLANK_LINES_AT_TOP, besr.p1_blank_lines_at_top); - OUTREG(OV0_P23_BLANK_LINES_AT_TOP, besr.p23_blank_lines_at_top); - OUTREG(OV0_VID_BUF_PITCH0_VALUE, besr.vid_buf_pitch0_value); - OUTREG(OV0_VID_BUF_PITCH1_VALUE, besr.vid_buf_pitch1_value); - OUTREG(OV0_P1_X_START_END, besr.p1_x_start_end); - OUTREG(OV0_P2_X_START_END, besr.p2_x_start_end); - OUTREG(OV0_P3_X_START_END, besr.p3_x_start_end); -#ifdef RADEON - OUTREG(OV0_BASE_ADDR, besr.base_addr); -#endif - OUTREG(OV0_VID_BUF0_BASE_ADRS, besr.vid_buf0_base_adrs); - OUTREG(OV0_VID_BUF1_BASE_ADRS, besr.vid_buf1_base_adrs); - OUTREG(OV0_VID_BUF2_BASE_ADRS, besr.vid_buf2_base_adrs); - radeon_fifo_wait(9); - OUTREG(OV0_VID_BUF3_BASE_ADRS, besr.vid_buf3_base_adrs); - OUTREG(OV0_VID_BUF4_BASE_ADRS, besr.vid_buf4_base_adrs); - OUTREG(OV0_VID_BUF5_BASE_ADRS, besr.vid_buf5_base_adrs); - OUTREG(OV0_P1_V_ACCUM_INIT, besr.p1_v_accum_init); - OUTREG(OV0_P1_H_ACCUM_INIT, besr.p1_h_accum_init); - OUTREG(OV0_P23_H_ACCUM_INIT, besr.p23_h_accum_init); - OUTREG(OV0_P23_V_ACCUM_INIT, besr.p23_v_accum_init); - -#ifdef RADEON - bes_flags = SCALER_ENABLE | - SCALER_SMART_SWITCH; -// SCALER_HORZ_PICK_NEAREST; -#else - bes_flags = SCALER_ENABLE | - SCALER_SMART_SWITCH | - SCALER_Y2R_TEMP | - SCALER_PIX_EXPAND; -#endif - if(besr.double_buff) bes_flags |= SCALER_DOUBLE_BUFFER; - if(besr.deinterlace_on) bes_flags |= SCALER_ADAPTIVE_DEINT; -#ifdef RAGE128 - bes_flags |= SCALER_BURST_PER_PLANE; -#endif - switch(besr.fourcc) - { - case IMGFMT_RGB15: - case IMGFMT_BGR15: bes_flags |= SCALER_SOURCE_15BPP; break; - case IMGFMT_RGB16: - case IMGFMT_BGR16: bes_flags |= SCALER_SOURCE_16BPP; break; - case IMGFMT_RGB24: - case IMGFMT_BGR24: bes_flags |= SCALER_SOURCE_24BPP; break; - case IMGFMT_RGB32: - case IMGFMT_BGR32: bes_flags |= SCALER_SOURCE_32BPP; break; - /* 4:1:0*/ - case IMGFMT_IF09: - case IMGFMT_YVU9: bes_flags |= SCALER_SOURCE_YUV9; break; - /* 4:2:0 */ - case IMGFMT_IYUV: - case IMGFMT_I420: - case IMGFMT_YV12: bes_flags |= SCALER_SOURCE_YUV12; - break; - /* 4:2:2 */ - case IMGFMT_UYVY: bes_flags |= SCALER_SOURCE_YVYU422; break; - case IMGFMT_YUY2: - default: bes_flags |= SCALER_SOURCE_VYUY422; break; - } - OUTREG(OV0_SCALE_CNTL, bes_flags); - OUTREG(OV0_REG_LOAD_CNTL, 0); -#ifdef DEBUG - radeon_vid_dump_regs(); -#endif -} - -void radeon_vid_set_color_key(int ckey_on, uint8_t R, uint8_t G, uint8_t B) -{ - besr.ckey_on = ckey_on; - besr.graphics_key_msk=(1ULL<version - ,(uint32_t)config->format - ,(uint32_t)config->card_type - ,(uint32_t)config->ram_size - ,(uint32_t)config->src_width - ,(uint32_t)config->src_height - ,(uint32_t)config->x_org - ,(uint32_t)config->y_org - ,(uint32_t)config->dest_width - ,(uint32_t)config->dest_height - ,(uint32_t)config->frame_size - ,(uint32_t)config->num_frames); - radeon_vid_stop_video(); - left = XXX_SRC_X << 16; - top = XXX_SRC_Y << 16; - src_h = config->src_height; - src_w = config->src_width; - switch(config->format) - { - case IMGFMT_RGB15: - case IMGFMT_BGR15: - case IMGFMT_RGB16: - case IMGFMT_BGR16: - case IMGFMT_RGB24: - case IMGFMT_BGR24: - case IMGFMT_RGB32: - case IMGFMT_BGR32: - /* 4:1:0 */ - case IMGFMT_IF09: - case IMGFMT_YVU9: - /* 4:2:0 */ - case IMGFMT_IYUV: - case IMGFMT_YV12: - case IMGFMT_I420: - /* 4:2:2 */ - case IMGFMT_UYVY: - case IMGFMT_YUY2: - break; - default: - printk(RVID_MSG"Unsupported pixel format: 0x%X\n",config->format); - return -1; - } - is_420 = 0; - if(config->format == IMGFMT_YV12 || - config->format == IMGFMT_I420 || - config->format == IMGFMT_IYUV) is_420 = 1; - switch(config->format) - { - /* 4:1:0 */ - case IMGFMT_YVU9: - case IMGFMT_IF09: - /* 4:2:0 */ - case IMGFMT_IYUV: - case IMGFMT_YV12: - case IMGFMT_I420: pitch = (src_w + 31) & ~31; break; - /* 4:2:2 */ - default: - case IMGFMT_UYVY: - case IMGFMT_YUY2: - case IMGFMT_RGB15: - case IMGFMT_BGR15: - case IMGFMT_RGB16: - case IMGFMT_BGR16: pitch = ((src_w*2) + 15) & ~15; break; - case IMGFMT_RGB24: - case IMGFMT_BGR24: pitch = ((src_w*3) + 15) & ~15; break; - case IMGFMT_RGB32: - case IMGFMT_BGR32: pitch = ((src_w*4) + 15) & ~15; break; - } - if(radeon_is_dbl_scan()) config->dest_height *= 2; - else - if(radeon_is_interlace()) config->dest_height /= 2; - besr.dest_bpp = radeon_vid_get_dbpp(); - besr.fourcc = config->format; - besr.v_inc = (src_h << 20) / config->dest_height; - h_inc = (src_w << 12) / config->dest_width; - step_by = 1; - - while(h_inc >= (2 << 12)) { - step_by++; - h_inc >>= 1; - } - - /* keep everything in 16.16 */ - besr.base_addr = radeon_mem_base; - if(is_420) - { - uint32_t d1line,d2line,d3line; - d1line = top*pitch; - d2line = src_h*pitch+(d1line>>1); - d3line = d2line+((src_h*pitch)>>2); - d1line += (left >> 16) & ~15; - d2line += (left >> 17) & ~15; - d3line += (left >> 17) & ~15; - besr.vid_buf0_base_adrs=((radeon_overlay_off+d1line)&VIF_BUF0_BASE_ADRS_MASK); - besr.vid_buf1_base_adrs=((radeon_overlay_off+d2line)&VIF_BUF1_BASE_ADRS_MASK)|VIF_BUF1_PITCH_SEL; - besr.vid_buf2_base_adrs=((radeon_overlay_off+d3line)&VIF_BUF2_BASE_ADRS_MASK)|VIF_BUF2_PITCH_SEL; - if(besr.fourcc == IMGFMT_I420 || besr.fourcc == IMGFMT_IYUV) - { - uint32_t tmp; - tmp = besr.vid_buf1_base_adrs; - besr.vid_buf1_base_adrs = besr.vid_buf2_base_adrs; - besr.vid_buf2_base_adrs = tmp; - } - } - else - { - besr.vid_buf0_base_adrs = radeon_overlay_off; - besr.vid_buf0_base_adrs += ((left & ~7) << 1)&VIF_BUF0_BASE_ADRS_MASK; - besr.vid_buf1_base_adrs = besr.vid_buf0_base_adrs; - besr.vid_buf2_base_adrs = besr.vid_buf0_base_adrs; - } - besr.vid_buf3_base_adrs = besr.vid_buf0_base_adrs+config->frame_size; - besr.vid_buf4_base_adrs = besr.vid_buf1_base_adrs+config->frame_size; - besr.vid_buf5_base_adrs = besr.vid_buf2_base_adrs+config->frame_size; - - tmp = (left & 0x0003ffff) + 0x00028000 + (h_inc << 3); - besr.p1_h_accum_init = ((tmp << 4) & 0x000f8000) | - ((tmp << 12) & 0xf0000000); - - tmp = ((left >> 1) & 0x0001ffff) + 0x00028000 + (h_inc << 2); - besr.p23_h_accum_init = ((tmp << 4) & 0x000f8000) | - ((tmp << 12) & 0x70000000); - tmp = (top & 0x0000ffff) + 0x00018000; - besr.p1_v_accum_init = ((tmp << 4) & OV0_P1_V_ACCUM_INIT_MASK) - |(OV0_P1_MAX_LN_IN_PER_LN_OUT & 1); - - tmp = ((top >> 1) & 0x0000ffff) + 0x00018000; - besr.p23_v_accum_init = is_420 ? ((tmp << 4) & OV0_P23_V_ACCUM_INIT_MASK) - |(OV0_P23_MAX_LN_IN_PER_LN_OUT & 1) : 0; - - leftUV = (left >> 17) & 15; - left = (left >> 16) & 15; - besr.h_inc = h_inc | ((h_inc >> 1) << 16); - besr.step_by = step_by | (step_by << 8); - besr.y_x_start = (config->x_org+X_ADJUST) | (config->y_org << 16); - besr.y_x_end = (config->x_org + config->dest_width+X_ADJUST) | ((config->y_org + config->dest_height) << 16); - besr.p1_blank_lines_at_top = P1_BLNK_LN_AT_TOP_M1_MASK|((src_h-1)<<16); - if(is_420) - { - src_h = (src_h + 1) >> 1; - besr.p23_blank_lines_at_top = P23_BLNK_LN_AT_TOP_M1_MASK|((src_h-1)<<16); - } - else besr.p23_blank_lines_at_top = 0; - besr.vid_buf_pitch0_value = pitch; - besr.vid_buf_pitch1_value = is_420 ? pitch>>1 : pitch; - besr.p1_x_start_end = (src_w+left-1)|(left<<16); - src_w>>=1; - besr.p2_x_start_end = (src_w+left-1)|(leftUV<<16); - besr.p3_x_start_end = besr.p2_x_start_end; - return 0; -} - -static void radeon_vid_frame_sel(int frame) -{ - uint32_t off0,off1,off2; - if(!besr.double_buff) return; - if(frame%2) - { - off0 = besr.vid_buf3_base_adrs; - off1 = besr.vid_buf4_base_adrs; - off2 = besr.vid_buf5_base_adrs; - } - else - { - off0 = besr.vid_buf0_base_adrs; - off1 = besr.vid_buf1_base_adrs; - off2 = besr.vid_buf2_base_adrs; - } - OUTREG(OV0_REG_LOAD_CNTL, REG_LD_CTL_LOCK); - while(!(INREG(OV0_REG_LOAD_CNTL)®_LD_CTL_LOCK_READBACK)); - OUTREG(OV0_VID_BUF0_BASE_ADRS, off0); - OUTREG(OV0_VID_BUF1_BASE_ADRS, off1); - OUTREG(OV0_VID_BUF2_BASE_ADRS, off2); - OUTREG(OV0_REG_LOAD_CNTL, 0); -} - -static void radeon_vid_make_default(void) -{ -#ifdef RAGE128 - OUTREG(OV0_COLOUR_CNTL,0x00101000UL); /* Default brihgtness and saturation for Rage128 */ -#else - make_default_gamma_correction(); -#endif - besr.deinterlace_pattern = 0x900AAAAA; - OUTREG(OV0_DEINTERLACE_PATTERN,besr.deinterlace_pattern); - besr.deinterlace_on=1; - besr.double_buff=1; -} - - -static void radeon_vid_preset(void) -{ -#ifdef RAGE128 - unsigned tmp; - tmp = INREG(OV0_COLOUR_CNTL); - besr.saturation = (tmp>>8)&0x1f; - besr.brightness = tmp & 0x7f; -#endif - besr.graphics_key_clr = INREG(OV0_GRAPHICS_KEY_CLR); - besr.deinterlace_pattern = INREG(OV0_DEINTERLACE_PATTERN); -} - -static int video_on = 0; - -static int radeon_vid_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) -{ - int frame; - - switch(cmd) - { - case MGA_VID_CONFIG: - RTRACE(RVID_MSG"radeon_mmio_base = %p\n",radeon_mmio_base); - RTRACE(RVID_MSG"radeon_mem_base = %08x\n",radeon_mem_base); - RTRACE(RVID_MSG"Received configuration\n"); - - if(copy_from_user(&radeon_config,(mga_vid_config_t*) arg,sizeof(mga_vid_config_t))) - { - printk(RVID_MSG"failed copy from userspace\n"); - return -EFAULT; - } - if(radeon_config.version != MGA_VID_VERSION){ - printk(RVID_MSG"incompatible version! driver: %X requested: %X\n",MGA_VID_VERSION,radeon_config.version); - return -EFAULT; - } - - if(radeon_config.frame_size==0 || radeon_config.frame_size>1024*768*2){ - printk(RVID_MSG"illegal frame_size: %d\n",radeon_config.frame_size); - return -EFAULT; - } - - if(radeon_config.num_frames<1){ - printk(RVID_MSG"illegal num_frames: %d\n",radeon_config.num_frames); - return -EFAULT; - } - if(radeon_config.num_frames==1) besr.double_buff=0; - if(!besr.double_buff) radeon_config.num_frames=1; - else radeon_config.num_frames=2; - radeon_config.card_type = 0; - radeon_config.ram_size = radeon_ram_size; - radeon_overlay_off = radeon_ram_size*0x100000 - radeon_config.frame_size*radeon_config.num_frames; - radeon_overlay_off &= 0xffff0000; - if(radeon_overlay_off < 0){ - printk(RVID_MSG"not enough video memory. Need: %u has: %u\n",radeon_config.frame_size*radeon_config.num_frames,radeon_ram_size*0x100000); - return -EFAULT; - } - RTRACE(RVID_MSG"using video overlay at offset %08X\n",radeon_overlay_off); - if (copy_to_user((mga_vid_config_t *) arg, &radeon_config, sizeof(mga_vid_config_t))) - { - printk(RVID_MSG"failed copy to userspace\n"); - return -EFAULT; - } - radeon_vid_set_color_key(radeon_config.colkey_on, - radeon_config.colkey_red, - radeon_config.colkey_green, - radeon_config.colkey_blue); - if(swap_fourcc) radeon_config.format = swab32(radeon_config.format); - printk(RVID_MSG"configuring for '%s' fourcc\n",fourcc_format_name(radeon_config.format)); - return radeon_vid_init_video(&radeon_config); - break; - - case MGA_VID_ON: - RTRACE(RVID_MSG"Video ON (ioctl)\n"); - radeon_vid_display_video(); - video_on = 1; - break; - - case MGA_VID_OFF: - RTRACE(RVID_MSG"Video OFF (ioctl)\n"); - if(video_on) radeon_vid_stop_video(); - video_on = 0; - break; - - case MGA_VID_FSEL: - if(copy_from_user(&frame,(int *) arg,sizeof(int))) - { - printk(RVID_MSG"FSEL failed copy from userspace\n"); - return -EFAULT; - } - radeon_vid_frame_sel(frame); - break; - - default: - printk(RVID_MSG"Invalid ioctl\n"); - return -EINVAL; - } - - return 0; -} - -struct ati_card_id_s -{ - const int id; - const char name[17]; -}; - -const struct ati_card_id_s ati_card_ids[]= -{ -#ifdef RAGE128 - /* - This driver should be compatible with Rage128 (pro) chips. - (include adaptive deinterlacing!!!). - Moreover: the same logic can be used with Mach64 chips. - (I mean: mach64xx, 3d rage, 3d rage IIc, 3D rage pro, 3d rage mobility). - but they are incompatible by i/o ports. So if enthusiasts will want - then they can redefine OUTREG and INREG macros and redefine OV0_* - constants. Also it seems that mach64 chips supports only: YUY2, YV12, UYVY - fourccs (422 and 420 formats only). - */ -/* Rage128 Pro GL */ - { PCI_DEVICE_ID_ATI_Rage128_PA, "R128Pro PA" }, - { PCI_DEVICE_ID_ATI_Rage128_PB, "R128Pro PB" }, - { PCI_DEVICE_ID_ATI_Rage128_PC, "R128Pro PC" }, - { PCI_DEVICE_ID_ATI_Rage128_PD, "R128Pro PD" }, - { PCI_DEVICE_ID_ATI_Rage128_PE, "R128Pro PE" }, - { PCI_DEVICE_ID_ATI_RAGE128_PF, "R128Pro PF" }, -/* Rage128 Pro VR */ - { PCI_DEVICE_ID_ATI_RAGE128_PG, "R128Pro PG" }, - { PCI_DEVICE_ID_ATI_RAGE128_PH, "R128Pro PH" }, - { PCI_DEVICE_ID_ATI_RAGE128_PI, "R128Pro PI" }, - { PCI_DEVICE_ID_ATI_RAGE128_PJ, "R128Pro PJ" }, - { PCI_DEVICE_ID_ATI_RAGE128_PK, "R128Pro PK" }, - { PCI_DEVICE_ID_ATI_RAGE128_PL, "R128Pro PL" }, - { PCI_DEVICE_ID_ATI_RAGE128_PM, "R128Pro PM" }, - { PCI_DEVICE_ID_ATI_RAGE128_PN, "R128Pro PN" }, - { PCI_DEVICE_ID_ATI_RAGE128_PO, "R128Pro PO" }, - { PCI_DEVICE_ID_ATI_RAGE128_PP, "R128Pro PP" }, - { PCI_DEVICE_ID_ATI_RAGE128_PQ, "R128Pro PQ" }, - { PCI_DEVICE_ID_ATI_RAGE128_PR, "R128Pro PR" }, - { PCI_DEVICE_ID_ATI_RAGE128_TR, "R128Pro TR" }, - { PCI_DEVICE_ID_ATI_RAGE128_PS, "R128Pro PS" }, - { PCI_DEVICE_ID_ATI_RAGE128_PT, "R128Pro PT" }, - { PCI_DEVICE_ID_ATI_RAGE128_PU, "R128Pro PU" }, - { PCI_DEVICE_ID_ATI_RAGE128_PV, "R128Pro PV" }, - { PCI_DEVICE_ID_ATI_RAGE128_PW, "R128Pro PW" }, - { PCI_DEVICE_ID_ATI_RAGE128_PX, "R128Pro PX" }, -/* Rage128 GL */ - { PCI_DEVICE_ID_ATI_RAGE128_RE, "R128 RE" }, - { PCI_DEVICE_ID_ATI_RAGE128_RF, "R128 RF" }, - { PCI_DEVICE_ID_ATI_RAGE128_RG, "R128 RG" }, - { PCI_DEVICE_ID_ATI_RAGE128_RH, "R128 RH" }, - { PCI_DEVICE_ID_ATI_RAGE128_RI, "R128 RI" }, -/* Rage128 VR */ - { PCI_DEVICE_ID_ATI_RAGE128_RK, "R128 RK" }, - { PCI_DEVICE_ID_ATI_RAGE128_RL, "R128 RL" }, - { PCI_DEVICE_ID_ATI_RAGE128_RM, "R128 RM" }, - { PCI_DEVICE_ID_ATI_RAGE128_RN, "R128 RN" }, - { PCI_DEVICE_ID_ATI_RAGE128_RO, "R128 RO" }, -/* Rage128 M3 */ - { PCI_DEVICE_ID_ATI_RAGE128_LE, "R128 M3 LE" }, - { PCI_DEVICE_ID_ATI_RAGE128_LF, "R128 M3 LF" }, -/* Rage128 Pro Ultra */ - { PCI_DEVICE_ID_ATI_RAGE128_U1, "R128Pro U1" }, - { PCI_DEVICE_ID_ATI_RAGE128_U2, "R128Pro U2" }, - { PCI_DEVICE_ID_ATI_RAGE128_U3, "R128Pro U3" } -#else -/* Radeons (indeed: Rage 256 Pro ;) */ - { PCI_DEVICE_ID_RADEON_QD, "Radeon QD " }, - { PCI_DEVICE_ID_RADEON_QE, "Radeon QE " }, - { PCI_DEVICE_ID_RADEON_QF, "Radeon QF " }, - { PCI_DEVICE_ID_RADEON_QG, "Radeon QG " }, - { PCI_DEVICE_ID_RADEON_QY, "Radeon VE QY " }, - { PCI_DEVICE_ID_RADEON_QZ, "Radeon VE QZ " }, - { PCI_DEVICE_ID_RADEON_LY, "Radeon M6 LY " }, - { PCI_DEVICE_ID_RADEON_LZ, "Radeon M6 LZ " }, - { PCI_DEVICE_ID_RADEON_LW, "Radeon M7 LW " }, - { PCI_DEVICE_ID_R200_QL, "Radeon2 8500 QL " }, - { PCI_DEVICE_ID_R200_BB, "Radeon2 8500 AIW" }, - { PCI_DEVICE_ID_RV200_QW, "Radeon2 7500 QW " } -#endif -}; - -static int detected_chip; - -static int __init radeon_vid_config_card(void) -{ - struct pci_dev *dev = NULL; - size_t i; - - for(i=0;iresource[0].start; - - RTRACE(RVID_MSG"MMIO at 0x%p\n", radeon_mmio_base); - RTRACE(RVID_MSG"Frame Buffer at 0x%08x\n", radeon_mem_base); - - /* video memory size */ - radeon_ram_size = INREG(CONFIG_MEMSIZE); - - /* mem size is bits [28:0], mask off the rest. Range: from 1Mb up to 512 Mb */ - radeon_ram_size &= CONFIG_MEMSIZE_MASK; - radeon_ram_size /= 0x100000; - detected_chip = i; - printk(RVID_MSG"Found %s (%uMb memory)\n",ati_card_ids[i].name,radeon_ram_size); -#ifndef RAGE128 - if(ati_card_ids[i].id == PCI_DEVICE_ID_R200_QL || - ati_card_ids[i].id == PCI_DEVICE_ID_R200_BB || - ati_card_ids[i].id == PCI_DEVICE_ID_RV200_QW) IsR200 = 1; -#endif - return TRUE; -} - -#define PARAM_BRIGHTNESS "brightness=" -#define PARAM_SATURATION "saturation=" -#define PARAM_CONTRAST "contrast=" -#define PARAM_HUE "hue=" -#define PARAM_DOUBLE_BUFF "double_buff=" -#define PARAM_DEINTERLACE "deinterlace=" -#define PARAM_DEINTERLACE_PATTERN "deinterlace_pattern=" -#ifdef RADEON_FPU -static int ovBrightness=0, ovSaturation=0, ovContrast=0, ovHue=0, ov_trans_idx=0; -#endif - -static void radeon_param_buff_fill( void ) -{ - unsigned len,saturation; - int8_t brightness; - brightness = besr.brightness & 0x7f; - /* FIXME: It's probably x86 specific convertion. But it doesn't matter - for general logic - only for printing value */ - if(brightness > 63) brightness = (((~besr.brightness) & 0x3f)+1) * (-1); - saturation = besr.saturation; - len = 0; - len += sprintf(&radeon_param_buff[len],"Interface version: %04X\nDriver version: %s\n",MGA_VID_VERSION,RADEON_VID_VERSION); - len += sprintf(&radeon_param_buff[len],"Chip: %s\n",ati_card_ids[detected_chip].name); - len += sprintf(&radeon_param_buff[len],"Memory: %x:%x\n",radeon_mem_base,radeon_ram_size*0x100000); - len += sprintf(&radeon_param_buff[len],"MMIO: %p\n",radeon_mmio_base); - len += sprintf(&radeon_param_buff[len],"Overlay offset: %x\n",radeon_overlay_off); -#ifdef CONFIG_MTRR - len += sprintf(&radeon_param_buff[len],"Tune MTRR: %s\n",mtrr?"on":"off"); -#endif - if(besr.ckey_on) len += sprintf(&radeon_param_buff[len],"Last used color_key=%X (mask=%X)\n",besr.graphics_key_clr,besr.graphics_key_msk); - len += sprintf(&radeon_param_buff[len],"Swapped fourcc: %s\n",swap_fourcc?"on":"off"); - len += sprintf(&radeon_param_buff[len],"Last BPP: %u\n",besr.dest_bpp); - len += sprintf(&radeon_param_buff[len],"Last fourcc: %s\n\n",fourcc_format_name(besr.fourcc)); - len += sprintf(&radeon_param_buff[len],"Configurable stuff:\n"); - len += sprintf(&radeon_param_buff[len],"~~~~~~~~~~~~~~~~~~~\n"); - len += sprintf(&radeon_param_buff[len],PARAM_DOUBLE_BUFF"%s\n",besr.double_buff?"on":"off"); -#ifdef RAGE128 - len += sprintf(&radeon_param_buff[len],PARAM_BRIGHTNESS"%i\n",(int)brightness); - len += sprintf(&radeon_param_buff[len],PARAM_SATURATION"%u\n",saturation); -#else -#ifdef RADEON_FPU - len += sprintf(&radeon_param_buff[len],PARAM_BRIGHTNESS"%i\n",ovBrightness); - len += sprintf(&radeon_param_buff[len],PARAM_SATURATION"%i\n",ovSaturation); - len += sprintf(&radeon_param_buff[len],PARAM_CONTRAST"%i\n",ovContrast); - len += sprintf(&radeon_param_buff[len],PARAM_HUE"%i\n",ovHue); -#endif -#endif - len += sprintf(&radeon_param_buff[len],PARAM_DEINTERLACE"%s\n",besr.deinterlace_on?"on":"off"); - len += sprintf(&radeon_param_buff[len],PARAM_DEINTERLACE_PATTERN"%X\n",besr.deinterlace_pattern); - radeon_param_buff_len = len; -} - -static ssize_t radeon_vid_read(struct file *file, char *buf, size_t count, loff_t *ppos) -{ - uint32_t size; - if(!radeon_param_buff) return -ESPIPE; - if(!(*ppos)) radeon_param_buff_fill(); - if(*ppos >= radeon_param_buff_len) return 0; - size = min(count,radeon_param_buff_len-(uint32_t)(*ppos)); - memcpy(buf,radeon_param_buff,size); - *ppos += size; - return size; -} - -#define RTFSaturation(a) (1.0 + ((a)*1.0)/1000.0) -#define RTFBrightness(a) (((a)*1.0)/2000.0) -#define RTFContrast(a) (1.0 + ((a)*1.0)/1000.0) -#define RTFHue(a) (((a)*3.1416)/1000.0) -#define RadeonSetParm(a,b,c,d) if((b)>=(c)&&(b)<=(d)) { (a)=(b);\ - radeon_set_transform(RTFBrightness(ovBrightness),RTFContrast(ovContrast)\ - ,RTFSaturation(ovSaturation),RTFHue(ovHue),ov_trans_idx); } - - -static ssize_t radeon_vid_write(struct file *file, const char *buf, size_t count, loff_t *ppos) -{ -#ifdef RAGE128 - if(memcmp(buf,PARAM_BRIGHTNESS,min(count,strlen(PARAM_BRIGHTNESS))) == 0) - { - long brightness; - brightness=simple_strtol(&buf[strlen(PARAM_BRIGHTNESS)],NULL,10); - if(brightness >= -64 && brightness <= 63) - { - besr.brightness = brightness; - OUTREG(OV0_COLOUR_CNTL, (brightness & 0x7f) | - (besr.saturation << 8) | - (besr.saturation << 16)); - } - } - else - if(memcmp(buf,PARAM_SATURATION,min(count,strlen(PARAM_SATURATION))) == 0) - { - long saturation; - saturation=simple_strtol(&buf[strlen(PARAM_SATURATION)],NULL,10); - if(saturation >= 0 && saturation <= 31) - OUTREG(OV0_COLOUR_CNTL, (besr.brightness & 0x7f) | - (saturation << 8) | - (saturation << 16)); - } - else -#else -#ifdef RADEON_FPU - if(memcmp(buf,PARAM_BRIGHTNESS,min(count,strlen(PARAM_BRIGHTNESS))) == 0) - { - int tmp; - tmp=simple_strtol(&buf[strlen(PARAM_BRIGHTNESS)],NULL,10); - RadeonSetParm(ovBrightness,tmp,-1000,1000); - } - else - if(memcmp(buf,PARAM_SATURATION,min(count,strlen(PARAM_SATURATION))) == 0) - { - int tmp; - tmp=simple_strtol(&buf[strlen(PARAM_SATURATION)],NULL,10); - RadeonSetParm(ovSaturation,tmp,-1000,1000); - } - else - if(memcmp(buf,PARAM_CONTRAST,min(count,strlen(PARAM_CONTRAST))) == 0) - { - int tmp; - tmp=simple_strtol(&buf[strlen(PARAM_CONTRAST)],NULL,10); - RadeonSetParm(ovContrast,tmp,-1000,1000); - } - else - if(memcmp(buf,PARAM_HUE,min(count,strlen(PARAM_HUE))) == 0) - { - int tmp; - tmp=simple_strtol(&buf[strlen(PARAM_HUE)],NULL,10); - RadeonSetParm(ovHue,tmp,-1000,1000); - } - else -#endif -#endif - if(memcmp(buf,PARAM_DOUBLE_BUFF,min(count,strlen(PARAM_DOUBLE_BUFF))) == 0) - { - if(memcmp(&buf[strlen(PARAM_DOUBLE_BUFF)],"on",2) == 0) besr.double_buff = 1; - else besr.double_buff = 0; - } - else - if(memcmp(buf,PARAM_DEINTERLACE,min(count,strlen(PARAM_DEINTERLACE))) == 0) - { - if(memcmp(&buf[strlen(PARAM_DEINTERLACE)],"on",2) == 0) besr.deinterlace_on = 1; - else besr.deinterlace_on = 0; - } - else - if(memcmp(buf,PARAM_DEINTERLACE_PATTERN,min(count,strlen(PARAM_DEINTERLACE_PATTERN))) == 0) - { - long dpat; - dpat=simple_strtol(&buf[strlen(PARAM_DEINTERLACE_PATTERN)],NULL,16); - OUTREG(OV0_DEINTERLACE_PATTERN, dpat); - } - else count = -EIO; - radeon_vid_preset(); - return count; -} - -static int radeon_vid_mmap(struct file *file, struct vm_area_struct *vma) -{ - - RTRACE(RVID_MSG"mapping video memory into userspace\n"); - if(remap_page_range(vma->vm_start, radeon_mem_base + radeon_overlay_off, - vma->vm_end - vma->vm_start, vma->vm_page_prot)) - { - printk(RVID_MSG"error mapping video memory\n"); - return -EAGAIN; - } - - return 0; -} - -static int radeon_vid_release(struct inode *inode, struct file *file) -{ - radeon_vid_in_use = 0; - radeon_vid_stop_video(); - - MOD_DEC_USE_COUNT; - return 0; -} - -static long long radeon_vid_lseek(struct file *file, long long offset, int origin) -{ - return -ESPIPE; -} - -static int radeon_vid_open(struct inode *inode, struct file *file) -{ - int minor = MINOR(inode->i_rdev); - - if(minor != 0) - return -ENXIO; - - if(radeon_vid_in_use == 1) - return -EBUSY; - - radeon_vid_in_use = 1; - MOD_INC_USE_COUNT; - return 0; -} - -#if LINUX_VERSION_CODE >= 0x020400 -static struct file_operations radeon_vid_fops = -{ - llseek: radeon_vid_lseek, - read: radeon_vid_read, - write: radeon_vid_write, -/* - readdir: - poll: -*/ - ioctl: radeon_vid_ioctl, - mmap: radeon_vid_mmap, - open: radeon_vid_open, -/* - flush: -*/ - release: radeon_vid_release -/* - fsync: - fasync: - lock: - readv: - writev: - sendpage: - get_unmapped_area: -*/ -}; -#else -static struct file_operations radeon_vid_fops = -{ - radeon_vid_lseek, - radeon_vid_read, - radeon_vid_write, - NULL, - NULL, - radeon_vid_ioctl, - radeon_vid_mmap, - radeon_vid_open, - NULL, - radeon_vid_release -}; -#endif - -/* - * Main Initialization Function - */ - -static int __init radeon_vid_initialize(void) -{ - radeon_vid_in_use = 0; -#ifdef RAGE128 - printk(RVID_MSG"Rage128/Rage128Pro video overlay driver v"RADEON_VID_VERSION" (C) Nick Kurshev\n"); -#else - printk(RVID_MSG"Radeon video overlay driver v"RADEON_VID_VERSION" (C) Nick Kurshev\n"); -#endif - if(register_chrdev(RADEON_VID_MAJOR, "radeon_vid", &radeon_vid_fops)) - { - printk(RVID_MSG"unable to get major: %d\n", RADEON_VID_MAJOR); - return -EIO; - } - - if (!radeon_vid_config_card()) - { - printk(RVID_MSG"can't configure this card\n"); - unregister_chrdev(RADEON_VID_MAJOR, "radeon_vid"); - return -EINVAL; - } - radeon_param_buff = kmalloc(PARAM_BUFF_SIZE,GFP_KERNEL); - if(radeon_param_buff) radeon_param_buff_size = PARAM_BUFF_SIZE; -#if 0 - radeon_vid_save_state(); -#endif - radeon_vid_make_default(); - radeon_vid_preset(); -#ifdef CONFIG_MTRR - if (mtrr) { - smtrr.vram = mtrr_add(radeon_mem_base, - radeon_ram_size*0x100000, MTRR_TYPE_WRCOMB, 1); - smtrr.vram_valid = 1; - /* let there be speed */ - printk(RVID_MSG"MTRR set to ON\n"); - } -#endif /* CONFIG_MTRR */ - return 0; -} - -int __init init_module(void) -{ - return radeon_vid_initialize(); -} - -void __exit cleanup_module(void) -{ -#if 0 - radeon_vid_restore_state(); -#endif - if(radeon_mmio_base) - iounmap(radeon_mmio_base); - kfree(radeon_param_buff); - RTRACE(RVID_MSG"Cleaning up module\n"); - unregister_chrdev(RADEON_VID_MAJOR, "radeon_vid"); -#ifdef CONFIG_MTRR - if (smtrr.vram_valid) - mtrr_del(smtrr.vram, radeon_mem_base, - radeon_ram_size*0x100000); -#endif /* CONFIG_MTRR */ -} diff --git a/drivers/radeon_vid.h b/drivers/radeon_vid.h deleted file mode 100644 index c397dc6022..0000000000 --- a/drivers/radeon_vid.h +++ /dev/null @@ -1,126 +0,0 @@ -/* - * BES YUV Framebuffer driver for Radeon cards - * - * Copyright (C) 2001 Nick Kurshev - * - * This file is partly based on mga_vid and sis_vid from MPlayer. - * - * This file is part of MPlayer. - * - * MPlayer is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * MPlayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef MPLAYER_RADEON_VID_H -#define MPLAYER_RADEON_VID_H - -typedef struct mga_vid_config_s -{ -uint16_t version; -uint16_t card_type; -uint32_t ram_size; -uint32_t src_width; -uint32_t src_height; -uint32_t dest_width; -uint32_t dest_height; -uint32_t x_org; /* dest x */ -uint32_t y_org; /* dest y */ -uint8_t colkey_on; -uint8_t colkey_red; -uint8_t colkey_green; -uint8_t colkey_blue; -uint32_t format; -uint32_t frame_size; -uint32_t num_frames; -} mga_vid_config_t; - -#define IMGFMT_RGB_MASK 0xFFFFFF00 -#define IMGFMT_RGB (('R'<<24)|('G'<<16)|('B'<<8)) -#define IMGFMT_RGB8 (IMGFMT_RGB|8) -#define IMGFMT_RGB15 (IMGFMT_RGB|15) -#define IMGFMT_RGB16 (IMGFMT_RGB|16) -#define IMGFMT_RGB24 (IMGFMT_RGB|24) -#define IMGFMT_RGB32 (IMGFMT_RGB|32) - -#define IMGFMT_BGR_MASK 0xFFFFFF00 -#define IMGFMT_BGR (('B'<<24)|('G'<<16)|('R'<<8)) -#define IMGFMT_BGR8 (IMGFMT_BGR|8) -#define IMGFMT_BGR15 (IMGFMT_BGR|15) -#define IMGFMT_BGR16 (IMGFMT_BGR|16) -#define IMGFMT_BGR24 (IMGFMT_BGR|24) -#define IMGFMT_BGR32 (IMGFMT_BGR|32) - -#define IMGFMT_IS_RGB(fmt) (((fmt)&IMGFMT_RGB_MASK)==IMGFMT_RGB) -#define IMGFMT_IS_BGR(fmt) (((fmt)&IMGFMT_BGR_MASK)==IMGFMT_BGR) - -#define IMGFMT_RGB_DEPTH(fmt) ((fmt)&~IMGFMT_RGB) -#define IMGFMT_BGR_DEPTH(fmt) ((fmt)&~IMGFMT_BGR) - - -/* Planar YUV Formats */ - -#define IMGFMT_YVU9 0x39555659 -#define IMGFMT_IF09 0x39304649 -#define IMGFMT_YV12 0x32315659 -#if 0 -#define IMGFMT_I420 0x30323449 -#define IMGFMT_IYUV 0x56555949 -#else -#define IMGFMT_I420 (('I'<<24)|('4'<<16)|('2'<<8)|'0') -#define IMGFMT_IYUV (('I'<<24)|('Y'<<16)|('U'<<8)|'V') -#endif -#define IMGFMT_CLPL 0x4C504C43 -#define IMGFMT_Y800 0x30303859 -#define IMGFMT_Y8 0x20203859 - -/* Packed YUV Formats */ - -#define IMGFMT_IUYV 0x56595549 -#define IMGFMT_IY41 0x31435949 -#define IMGFMT_IYU1 0x31555949 -#define IMGFMT_IYU2 0x32555949 -#define IMGFMT_UYNV 0x564E5955 -#define IMGFMT_cyuv 0x76757963 -#define IMGFMT_Y422 0x32323459 -#if 0 -#define IMGFMT_YUY2 0x32595559 -#define IMGFMT_UYVY 0x59565955 -#else -#define IMGFMT_YUY2 (('Y'<<24)|('U'<<16)|('Y'<<8)|'2') -#define IMGFMT_UYVY (('U'<<24)|('Y'<<16)|('V'<<8)|'Y') -#endif -#define IMGFMT_YUNV 0x564E5559 -#define IMGFMT_YVYU 0x55595659 -#define IMGFMT_Y41P 0x50313459 -#define IMGFMT_Y211 0x31313259 -#define IMGFMT_Y41T 0x54313459 -#define IMGFMT_Y42T 0x54323459 -#define IMGFMT_V422 0x32323456 -#define IMGFMT_V655 0x35353656 -#define IMGFMT_CLJR 0x524A4C43 -#define IMGFMT_YUVP 0x50565559 -#define IMGFMT_UYVP 0x50565955 - -/* Compressed Formats. MPlayer's extensions!!! */ -#define IMGFMT_MPEGPES (('M'<<24)|('P'<<16)|('E'<<8)|('S')) - - -#define MGA_VID_CONFIG _IOR('J', 1, mga_vid_config_t) -#define MGA_VID_ON _IO ('J', 2) -#define MGA_VID_OFF _IO ('J', 3) -#define MGA_VID_FSEL _IOR('J', 4, int) - -#define MGA_VID_VERSION 0x0201 - -#endif /* MPLAYER_RADEON_VID_H */ diff --git a/drivers/tdfx_vid.c b/drivers/tdfx_vid.c deleted file mode 100644 index 501f5fc603..0000000000 --- a/drivers/tdfx_vid.c +++ /dev/null @@ -1,1049 +0,0 @@ -/* - * Copyright (C) 2003 Alban Bedel - * - * This file is part of MPlayer. - * - * MPlayer is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * MPlayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,10) -#include -#else -#include -#endif - -#include -#include -#include -#include - -#include -#include -#include - -#include "tdfx_vid.h" -#include "3dfx.h" - - -#define TDFX_VID_MAJOR 178 - -MODULE_AUTHOR("Albeu"); -MODULE_DESCRIPTION("A driver for Banshee targeted for video app"); - -#ifdef MODULE_LICENSE -MODULE_LICENSE("GPL"); -#endif - -#ifndef min -#define min(x,y) (((x)<(y))?(x):(y)) -#endif - -static struct pci_dev *pci_dev; - -static uint8_t *tdfx_mmio_base = 0; -static uint32_t tdfx_mem_base = 0; -static uint32_t tdfx_io_base = 0; - -static int tdfx_ram_size = 0; - -static int tdfx_vid_in_use = 0; - -static drm_agp_t *drm_agp = NULL; -static agp_kern_info agp_info; -static agp_memory *agp_mem = NULL; - -static __initdata int tdfx_map_io = 1; -static __initdata unsigned long map_start = 0; //0x7300000; -static __initdata unsigned long map_max = (10*1024*1024); - -MODULE_PARM(tdfx_map_io,"i"); -MODULE_PARM_DESC(tdfx_map_io, "Set to 0 to use the page fault handler (you need to patch agpgart_be.c to allow the mapping in user space)\n"); -MODULE_PARM(map_start,"l"); -MODULE_PARM_DESC(map_start,"Use a block of physical mem instead of the agp arerture."); -MODULE_PARM(map_max,"l"); -MODULE_PARM_DESC(map_max, "Maximum amout of physical memory (in bytes) that can be used\n"); - -static inline u32 tdfx_inl(unsigned int reg) { - return readl(tdfx_mmio_base + reg); -} - -static inline void tdfx_outl(unsigned int reg, u32 val) { - writel(val,tdfx_mmio_base + reg); -} - -static inline void banshee_make_room(int size) { - while((tdfx_inl(STATUS) & 0x1f) < size); -} - -static inline void banshee_wait_idle(void) { - int i = 0; - - banshee_make_room(1); - tdfx_outl(COMMAND_3D, COMMAND_3D_NOP); - - while(1) { - i = (tdfx_inl(STATUS) & STATUS_BUSY) ? 0 : i + 1; - if(i == 3) break; - } -} - -static unsigned long get_lfb_size(void) { - u32 draminit0 = 0; - u32 draminit1 = 0; - // u32 miscinit1 = 0; - u32 lfbsize = 0; - int sgram_p = 0; - - draminit0 = tdfx_inl(DRAMINIT0); - draminit1 = tdfx_inl(DRAMINIT1); - - if ((pci_dev->device == PCI_DEVICE_ID_3DFX_BANSHEE) || - (pci_dev->device == PCI_DEVICE_ID_3DFX_VOODOO3)) { - sgram_p = (draminit1 & DRAMINIT1_MEM_SDRAM) ? 0 : 1; - - lfbsize = sgram_p ? - (((draminit0 & DRAMINIT0_SGRAM_NUM) ? 2 : 1) * - ((draminit0 & DRAMINIT0_SGRAM_TYPE) ? 8 : 4) * 1024 * 1024) : - 16 * 1024 * 1024; - } else { - /* Voodoo4/5 */ - u32 chips, psize, banks; - - chips = ((draminit0 & (1 << 26)) == 0) ? 4 : 8; - psize = 1 << ((draminit0 & 0x38000000) >> 28); - banks = ((draminit0 & (1 << 30)) == 0) ? 2 : 4; - lfbsize = chips * psize * banks; - lfbsize <<= 20; - } - -#if 0 - /* disable block writes for SDRAM (why?) */ - miscinit1 = tdfx_inl(MISCINIT1); - miscinit1 |= sgram_p ? 0 : MISCINIT1_2DBLOCK_DIS; - miscinit1 |= MISCINIT1_CLUT_INV; - - banshee_make_room(1); - tdfx_outl(MISCINIT1, miscinit1); -#endif - - return lfbsize; -} - -static int tdfx_vid_find_card(void) -{ - struct pci_dev *dev = NULL; - // unsigned int card_option; - - if((dev = pci_find_device(PCI_VENDOR_ID_3DFX, PCI_DEVICE_ID_3DFX_BANSHEE, NULL))) - printk(KERN_INFO "tdfx_vid: Found VOODOO BANSHEE\n"); - else if((dev = pci_find_device(PCI_VENDOR_ID_3DFX, PCI_DEVICE_ID_3DFX_VOODOO3, NULL))) - printk(KERN_INFO "tdfx_vid: Found VOODOO 3 \n"); - else - return 0; - - - pci_dev = dev; - -#if LINUX_VERSION_CODE >= 0x020300 - tdfx_mmio_base = ioremap_nocache(dev->resource[0].start,1 << 24); - tdfx_mem_base = dev->resource[1].start; - tdfx_io_base = dev->resource[2].start; -#else - tdfx_mmio_base = ioremap_nocache(dev->base_address[1] & PCI_BASE_ADDRESS_MEM_MASK,0x4000); - tdfx_mem_base = dev->base_address[1] & PCI_BASE_ADDRESS_MEM_MASK; - tdfx_io_base = dev->base_address[2] & PCI_BASE_ADDRESS_MEM_MASK; -#endif - printk(KERN_INFO "tdfx_vid: MMIO at 0x%p\n", tdfx_mmio_base); - tdfx_ram_size = get_lfb_size(); - - printk(KERN_INFO "tdfx_vid: Found %d MB (%d bytes) of memory\n", - tdfx_ram_size / 1024 / 1024,tdfx_ram_size); - - -#if 0 - { - int temp; - printk("List resources -----------\n"); - for(temp=0;tempresource[temp]; - if(res->flags){ - int size=(1+res->end-res->start)>>20; - printk(KERN_DEBUG "res %d: start: 0x%X end: 0x%X (%d MB) flags=0x%X\n",temp,res->start,res->end,size,res->flags); - if(res->flags&(IORESOURCE_MEM|IORESOURCE_PREFETCH)){ - if(size>tdfx_ram_size && size<=64) tdfx_ram_size=size; - } - } - } - } -#endif - - - return 1; -} - -static int agp_init(void) { - - drm_agp = (drm_agp_t*)inter_module_get("drm_agp"); - - if(!drm_agp) { - printk(KERN_ERR "tdfx_vid: Unable to get drm_agp pointer\n"); - return 0; - } - - if(drm_agp->acquire()) { - printk(KERN_ERR "tdfx_vid: Unable to acquire the agp backend\n"); - drm_agp = NULL; - return 0; - } - - drm_agp->copy_info(&agp_info); -#if 0 - printk(KERN_DEBUG "AGP Version : %d %d\n" - "AGP Mode: %#X\nAperture Base: %p\nAperture Size: %d\n" - "Max memory = %d\nCurrent mem = %d\nCan use perture : %s\n" - "Page mask = %#X\n", - agp_info.version.major,agp_info.version.minor, - agp_info.mode,agp_info.aper_base,agp_info.aper_size, - agp_info.max_memory,agp_info.current_memory, - agp_info.cant_use_aperture ? "no" : "yes", - agp_info.page_mask); -#endif - drm_agp->enable(agp_info.mode); - - - printk(KERN_INFO "AGP Enabled\n"); - - return 1; -} - -static void agp_close(void) { - - if(!drm_agp) return; - - if(agp_mem) { - drm_agp->unbind_memory(agp_mem); - drm_agp->free_memory(agp_mem); - agp_mem = NULL; - } - - - drm_agp->release(); - inter_module_put("drm_agp"); -} - -static int agp_move(tdfx_vid_agp_move_t* m) { - u32 src = 0; - u32 src_h,src_l; - - if(!(agp_mem||map_start)) - return -EAGAIN; - - if(m->move2 > 3) { - printk(KERN_DEBUG "tdfx_vid: AGP move invalid destination %d\n", - m->move2); - return -EAGAIN; - } - - if(map_start) - src = map_start + m->src; - else - src = agp_info.aper_base + m->src; - - src_l = (u32)src; - src_h = (m->width | (m->src_stride << 14)) & 0x0FFFFFFF; - - // banshee_wait_idle(); - banshee_make_room(6); - tdfx_outl(AGPHOSTADDRESSHIGH,src_h); - tdfx_outl(AGPHOSTADDRESSLOW,src_l); - - tdfx_outl(AGPGRAPHICSADDRESS, m->dst); - tdfx_outl(AGPGRAPHICSSTRIDE, m->dst_stride); - tdfx_outl(AGPREQSIZE,m->src_stride*m->height); - - tdfx_outl(AGPMOVECMD,m->move2 << 3); - banshee_wait_idle(); - - return 0; -} - -#if 0 -static void setup_fifo(u32 offset,ssize_t pages) { - long addr = agp_info.aper_base + offset; - u32 size = pages | 0x700; // fifo on, in agp mem, disable hole cnt - - banshee_wait_idle(); - - tdfx_outl(CMDBASEADDR0,addr >> 4); - tdfx_outl(CMDRDPTRL0, addr << 4); - tdfx_outl(CMDRDPTRH0, addr >> 28); - tdfx_outl(CMDAMIN0, (addr - 4) & 0xFFFFFF); - tdfx_outl(CMDAMAX0, (addr - 4) & 0xFFFFFF); - tdfx_outl(CMDFIFODEPTH0, 0); - tdfx_outl(CMDHOLECNT0, 0); - tdfx_outl(CMDBASESIZE0,size); - - banshee_wait_idle(); - -} -#endif - -static int bump_fifo(u16 size) { - - banshee_wait_idle(); - tdfx_outl(CMDBUMP0 , size); - banshee_wait_idle(); - - return 0; -} - -static void tdfx_vid_get_config(tdfx_vid_config_t* cfg) { - u32 in; - - cfg->version = TDFX_VID_VERSION; - cfg->ram_size = tdfx_ram_size; - - in = tdfx_inl(VIDSCREENSIZE); - cfg->screen_width = in & 0xFFF; - cfg->screen_height = (in >> 12) & 0xFFF; - in = (tdfx_inl(VIDPROCCFG)>> 18)& 0x7; - switch(in) { - case 0: - cfg->screen_format = TDFX_VID_FORMAT_BGR8; - break; - case 1: - cfg->screen_format = TDFX_VID_FORMAT_BGR16; - break; - case 2: - cfg->screen_format = TDFX_VID_FORMAT_BGR24; - break; - case 3: - cfg->screen_format = TDFX_VID_FORMAT_BGR32; - break; - default: - printk(KERN_INFO "tdfx_vid: unknown screen format %d\n",in); - cfg->screen_format = 0; - break; - } - cfg->screen_stride = tdfx_inl(VIDDESKSTRIDE) & 0x7FFF; - cfg->screen_start = tdfx_inl(VIDDESKSTART); -} - -inline static u32 tdfx_vid_make_format(int src,u16 stride,u32 fmt) { - u32 r = stride & 0xFFF3; - u32 tdfx_fmt = 0; - - // src and dest formats - switch(fmt) { - case TDFX_VID_FORMAT_BGR8: - tdfx_fmt = 1; - break; - case TDFX_VID_FORMAT_BGR16: - tdfx_fmt = 3; - break; - case TDFX_VID_FORMAT_BGR24: - tdfx_fmt = 4; - break; - case TDFX_VID_FORMAT_BGR32: - tdfx_fmt = 5; - break; - } - - if(!src && !tdfx_fmt) { - printk(KERN_INFO "tdfx_vid: Invalid destination format %#X\n",fmt); - return 0; - } - - if(src && !tdfx_fmt) { - // src only format - switch(fmt){ - case TDFX_VID_FORMAT_BGR1: - tdfx_fmt = 0; - break; - case TDFX_VID_FORMAT_BGR15: // To check - tdfx_fmt = 2; - break; - case TDFX_VID_FORMAT_YUY2: - tdfx_fmt = 8; - break; - case TDFX_VID_FORMAT_UYVY: - tdfx_fmt = 9; - break; - default: - printk(KERN_INFO "tdfx_vid: Invalid source format %#X\n",fmt); - return 0; - } - } - - r |= tdfx_fmt << 16; - - return r; -} - -static int tdfx_vid_blit(tdfx_vid_blit_t* blit) { - u32 src_fmt,dst_fmt,cmd = 2; - u32 cmin,cmax,srcbase,srcxy,srcfmt,srcsize; - u32 dstbase,dstxy,dstfmt,dstsize = 0; - u32 cmd_extra = 0,src_ck[2],dst_ck[2],rop123=0; - - //printk(KERN_INFO "tdfx_vid: Make src fmt 0x%x\n",blit->src_format); - src_fmt = tdfx_vid_make_format(1,blit->src_stride,blit->src_format); - if(!src_fmt) - return 0; - //printk(KERN_INFO "tdfx_vid: Make dst fmt 0x%x\n", blit->dst_format); - dst_fmt = tdfx_vid_make_format(0,blit->dst_stride,blit->dst_format); - if(!dst_fmt) - return 0; - blit->colorkey &= 0x3; - // Be nice if user just want a simple blit - if((!blit->colorkey) && (!blit->rop[0])) - blit->rop[0] = TDFX_VID_ROP_COPY; - // No stretch : fix me the cmd should be 1 but it - // doesn't work. Maybe some other regs need to be set - // as non-stretch blit have more options - if(((!blit->dst_w) && (!blit->dst_h)) || - ((blit->dst_w == blit->src_w) && (blit->dst_h == blit->src_h))) - cmd = 2; - - // Save the regs otherwise fb get crazy - // we can perhaps avoid some ... - banshee_wait_idle(); - cmin = tdfx_inl(CLIP0MIN); - cmax = tdfx_inl(CLIP0MAX); - srcbase = tdfx_inl(SRCBASE); - srcxy = tdfx_inl(SRCXY); - srcfmt = tdfx_inl(SRCFORMAT); - srcsize = tdfx_inl(SRCSIZE); - dstbase = tdfx_inl(DSTBASE); - dstxy = tdfx_inl(DSTXY); - dstfmt = tdfx_inl(DSTFORMAT); - if(cmd == 2) - dstsize = tdfx_inl(DSTSIZE); - if(blit->colorkey & TDFX_VID_SRC_COLORKEY) { - src_ck[0] = tdfx_inl(SRCCOLORKEYMIN); - src_ck[1] = tdfx_inl(SRCCOLORKEYMAX); - tdfx_outl(SRCCOLORKEYMIN,blit->src_colorkey[0]); - tdfx_outl(SRCCOLORKEYMAX,blit->src_colorkey[1]); - } - if(blit->colorkey & TDFX_VID_DST_COLORKEY) { - dst_ck[0] = tdfx_inl(DSTCOLORKEYMIN); - dst_ck[1] = tdfx_inl(DSTCOLORKEYMAX); - tdfx_outl(SRCCOLORKEYMIN,blit->dst_colorkey[0]); - tdfx_outl(SRCCOLORKEYMAX,blit->dst_colorkey[1]); - } - if(blit->colorkey) { - cmd_extra = tdfx_inl(COMMANDEXTRA_2D); - rop123 = tdfx_inl(ROP123); - tdfx_outl(COMMANDEXTRA_2D, blit->colorkey); - tdfx_outl(ROP123,(blit->rop[1] | (blit->rop[2] << 8) | blit->rop[3] << 16)); - - } - // Get rid of the clipping at the moment - tdfx_outl(CLIP0MIN,0); - tdfx_outl(CLIP0MAX,0x0fff0fff); - - // Setup the src - tdfx_outl(SRCBASE,blit->src & 0x00FFFFFF); - tdfx_outl(SRCXY,XYREG(blit->src_x,blit->src_y)); - tdfx_outl(SRCFORMAT,src_fmt); - tdfx_outl(SRCSIZE,XYREG(blit->src_w,blit->src_h)); - - // Setup the dst - tdfx_outl(DSTBASE,blit->dst & 0x00FFFFFF); - tdfx_outl(DSTXY,XYREG(blit->dst_x,blit->dst_y)); - tdfx_outl(DSTFORMAT,dst_fmt); - if(cmd == 2) - tdfx_outl(DSTSIZE,XYREG(blit->dst_w,blit->dst_h)); - - // Send the command - tdfx_outl(COMMAND_2D,cmd | 0x100 | (blit->rop[0] << 24)); - banshee_wait_idle(); - - // Now restore the regs to make fb happy - tdfx_outl(CLIP0MIN, cmin); - tdfx_outl(CLIP0MAX, cmax); - tdfx_outl(SRCBASE, srcbase); - tdfx_outl(SRCXY, srcxy); - tdfx_outl(SRCFORMAT, srcfmt); - tdfx_outl(SRCSIZE, srcsize); - tdfx_outl(DSTBASE, dstbase); - tdfx_outl(DSTXY, dstxy); - tdfx_outl(DSTFORMAT, dstfmt); - if(cmd == 2) - tdfx_outl(DSTSIZE, dstsize); - if(blit->colorkey & TDFX_VID_SRC_COLORKEY) { - tdfx_outl(SRCCOLORKEYMIN,src_ck[0]); - tdfx_outl(SRCCOLORKEYMAX,src_ck[1]); - } - if(blit->colorkey & TDFX_VID_DST_COLORKEY) { - tdfx_outl(SRCCOLORKEYMIN,dst_ck[0]); - tdfx_outl(SRCCOLORKEYMAX,dst_ck[1]); - } - if(blit->colorkey) { - tdfx_outl(COMMANDEXTRA_2D,cmd_extra); - tdfx_outl(ROP123,rop123); - } - return 1; -} - -static int tdfx_vid_set_yuv(unsigned long arg) { - tdfx_vid_yuv_t yuv; - - if(copy_from_user(&yuv,(tdfx_vid_yuv_t*)arg,sizeof(tdfx_vid_yuv_t))) { - printk(KERN_DEBUG "tdfx_vid:failed copy from userspace\n"); - return -EFAULT; - } - banshee_make_room(2); - tdfx_outl(YUVBASEADDRESS,yuv.base & 0x01FFFFFF); - tdfx_outl(YUVSTRIDE, yuv.stride & 0x3FFF); - - banshee_wait_idle(); - - return 0; -} - -static int tdfx_vid_get_yuv(unsigned long arg) { - tdfx_vid_yuv_t yuv; - - yuv.base = tdfx_inl(YUVBASEADDRESS) & 0x01FFFFFF; - yuv.stride = tdfx_inl(YUVSTRIDE) & 0x3FFF; - - if(copy_to_user((tdfx_vid_yuv_t*)arg,&yuv,sizeof(tdfx_vid_yuv_t))) { - printk(KERN_INFO "tdfx_vid:failed copy to userspace\n"); - return -EFAULT; - } - - return 0; -} - -static int tdfx_vid_set_overlay(unsigned long arg) { - tdfx_vid_overlay_t ov; - uint32_t screen_w,screen_h; - uint32_t vidcfg,stride,vidbuf; - int disp_w,disp_h; - - if(copy_from_user(&ov,(tdfx_vid_overlay_t*)arg,sizeof(tdfx_vid_overlay_t))) { - printk(KERN_DEBUG "tdfx_vid:failed copy from userspace\n"); - return -EFAULT; - } - - if(ov.dst_y < 0) { - int shift; - if(-ov.dst_y >= ov.src_height) { - printk(KERN_DEBUG "tdfx_vid: Overlay outside of the screen ????\n"); - return -EFAULT; - } - shift = (-ov.dst_y)/(double)ov.dst_height*ov.src_height; - ov.src[0] += shift*ov.src_stride; - ov.src_height -= shift; - ov.dst_height += ov.dst_y; - ov.dst_y = 0; - } - - if(ov.dst_x < 0) { - int shift; - if(-ov.dst_x >= ov.src_width) { - printk(KERN_DEBUG "tdfx_vid: Overlay outside of the screen ????\n"); - return -EFAULT; - } - shift = (-ov.dst_x)/(double)ov.dst_width*ov.src_width; - shift = ((shift+3)/2)*2; - ov.src[0] += shift*2; - ov.src_width -= shift; - ov.dst_width += ov.dst_x; - ov.dst_x = 0; - } - - vidcfg = tdfx_inl(VIDPROCCFG); - // clear the overlay fmt - vidcfg &= ~(7 << 21); - switch(ov.format) { - case TDFX_VID_FORMAT_BGR15: - vidcfg |= (1 << 21); - break; - case TDFX_VID_FORMAT_BGR16: - vidcfg |= (7 << 21); - break; - case TDFX_VID_FORMAT_YUY2: - vidcfg |= (5 << 21); - break; - case TDFX_VID_FORMAT_UYVY: - vidcfg |= (6 << 21); - break; - default: - printk(KERN_DEBUG "tdfx_vid: Invalid overlay fmt 0x%x\n",ov.format); - return -EFAULT; - } - - // YUV422 need 4 bytes aligned stride and address - if((ov.format == TDFX_VID_FORMAT_YUY2 || - ov.format == TDFX_VID_FORMAT_UYVY)) { - if((ov.src_stride & ~0x3) != ov.src_stride) { - printk(KERN_DEBUG "tdfx_vid: YUV need a 4 bytes aligned stride %d\n",ov.src_stride); - return -EFAULT; - } - if((ov.src[0] & ~0x3) != ov.src[0] || (ov.src[1] & ~0x3) != ov.src[1]){ - printk(KERN_DEBUG "tdfx_vid: YUV need a 4 bytes aligned address 0x%x 0x%x\n",ov.src[0],ov.src[1]); - return -EFAULT; - } - } - - // Now we have a good input format - // but first get the screen size to check a bit - // if the size/position is valid - screen_w = tdfx_inl(VIDSCREENSIZE); - screen_h = (screen_w >> 12) & 0xFFF; - screen_w &= 0xFFF; - disp_w = ov.dst_x + ov.dst_width >= screen_w ? - screen_w - ov.dst_x : ov.dst_width; - disp_h = ov.dst_y + ov.dst_height >= screen_h ? - screen_h - ov.dst_y : ov.dst_height; - - if(ov.dst_x >= screen_w || ov.dst_y >= screen_h || - disp_h <= 0 || disp_h > screen_h || disp_w <= 0 || disp_w > screen_w) { - printk(KERN_DEBUG "tdfx_vid: Invalid overlay dimension and/or position\n"); - return -EFAULT; - } - // Setup the vidproc - // H scaling - if(ov.src_width < ov.dst_width) - vidcfg |= (1<<14); - else - vidcfg &= ~(1<<14); - // V scaling - if(ov.src_height < ov.dst_height) - vidcfg |= (1<<15); - else - vidcfg &= ~(1<<15); - // Filtering can only be used in 1x mode - if(!(vidcfg | (1<<26))) - vidcfg |= (3<<16); - else - vidcfg &= ~(3<<16); - // disable overlay stereo mode - vidcfg &= ~(1<<2); - // Colorkey on/off - if(ov.use_colorkey) { - // Colorkey inversion - if(ov.invert_colorkey) - vidcfg |= (1<<6); - else - vidcfg &= ~(1<<6); - vidcfg |= (1<<5); - } else - vidcfg &= ~(1<<5); - // Overlay isn't VidIn - vidcfg &= ~(1<<9); - // vidcfg |= (1<<8); - tdfx_outl(VIDPROCCFG,vidcfg); - - // Start coord - //printk(KERN_DEBUG "tdfx_vid: start %dx%d\n",ov.dst_x & 0xFFF,ov.dst_y & 0xFFF); - tdfx_outl(VIDOVRSTARTCRD,(ov.dst_x & 0xFFF)|((ov.dst_y & 0xFFF)<<12)); - // End coord - tdfx_outl(VIDOVRENDCRD, ((ov.dst_x + disp_w-1) & 0xFFF)| - (((ov.dst_y + disp_h-1) & 0xFFF)<<12)); - // H Scaling - tdfx_outl(VIDOVRDUDX,( ((u32)ov.src_width) << 20) / ov.dst_width); - // Src offset and width (in bytes) - tdfx_outl(VIDOVRDUDXOFF,((ov.src_width<<1) & 0xFFF) << 19); - // V Scaling - tdfx_outl(VIDOVRDVDY, ( ((u32)ov.src_height) << 20) / ov.dst_height); - //else - // tdfx_outl(VIDOVRDVDY,0); - // V Offset - tdfx_outl(VIDOVRDVDYOFF,0); - // Overlay stride - stride = tdfx_inl(VIDDESKSTRIDE) & 0xFFFF; - tdfx_outl(VIDDESKSTRIDE,stride | (((u32)ov.src_stride) << 16)); - // Buffers address - tdfx_outl(LEFTOVBUF, ov.src[0]); - tdfx_outl(RIGHTOVBUF, ov.src[1]); - - // Send a swap buffer cmd if we are not on one of the 2 buffers - vidbuf = tdfx_inl(VIDCUROVRSTART); - if(vidbuf != ov.src[0] && vidbuf != ov.src[1]) { - tdfx_outl(SWAPPENDING,0); - tdfx_outl(SWAPBUFCMD, 1); - } - //printk(KERN_DEBUG "tdfx_vid: Buf0=0x%x Buf1=0x%x Current=0x%x\n", - // ov.src[0],ov.src[1],tdfx_inl(VIDCUROVRSTART)); - // Colorkey - if(ov.use_colorkey) { - tdfx_outl(VIDCHRMIN,ov.colorkey[0]); - tdfx_outl(VIDCHRMAX,ov.colorkey[1]); - } - - return 0; -} - -static int tdfx_vid_overlay_on(void) { - uint32_t vidcfg = tdfx_inl(VIDPROCCFG); - //return 0; - if(vidcfg & (1<<8)) { // Overlay is already on - //printk(KERN_DEBUG "tdfx_vid: Overlay is already on.\n"); - return -EFAULT; - } - vidcfg |= (1<<8); - tdfx_outl(VIDPROCCFG,vidcfg); - return 0; -} - -static int tdfx_vid_overlay_off(void) { - uint32_t vidcfg = tdfx_inl(VIDPROCCFG); - - if(vidcfg & (1<<8)) { - vidcfg &= ~(1<<8); - tdfx_outl(VIDPROCCFG,vidcfg); - return 0; - } - - printk(KERN_DEBUG "tdfx_vid: Overlay is already off.\n"); - return -EFAULT; -} - - -static int tdfx_vid_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) -{ - tdfx_vid_agp_move_t move; - tdfx_vid_config_t cfg; - tdfx_vid_blit_t blit; - u16 int16; - - switch(cmd) { - case TDFX_VID_AGP_MOVE: - if(copy_from_user(&move,(tdfx_vid_agp_move_t*)arg,sizeof(tdfx_vid_agp_move_t))) { - printk(KERN_INFO "tdfx_vid:failed copy from userspace\n"); - return -EFAULT; - } - return agp_move(&move); - case TDFX_VID_BUMP0: - if(copy_from_user(&int16,(u16*)arg,sizeof(u16))) { - printk(KERN_INFO "tdfx_vid:failed copy from userspace\n"); - return -EFAULT; - } - return bump_fifo(int16); - case TDFX_VID_BLIT: - if(copy_from_user(&blit,(tdfx_vid_blit_t*)arg,sizeof(tdfx_vid_blit_t))) { - printk(KERN_INFO "tdfx_vid:failed copy from userspace\n"); - return -EFAULT; - } - if(!tdfx_vid_blit(&blit)) { - printk(KERN_INFO "tdfx_vid: Blit failed\n"); - return -EFAULT; - } - return 0; - case TDFX_VID_GET_CONFIG: - if(copy_from_user(&cfg,(tdfx_vid_config_t*)arg,sizeof(tdfx_vid_config_t))) { - printk(KERN_INFO "tdfx_vid:failed copy from userspace\n"); - return -EFAULT; - } - tdfx_vid_get_config(&cfg); - if(copy_to_user((tdfx_vid_config_t*)arg,&cfg,sizeof(tdfx_vid_config_t))) { - printk(KERN_INFO "tdfx_vid:failed copy to userspace\n"); - return -EFAULT; - } - return 0; - case TDFX_VID_SET_YUV: - return tdfx_vid_set_yuv(arg); - case TDFX_VID_GET_YUV: - return tdfx_vid_get_yuv(arg); - case TDFX_VID_SET_OVERLAY: - return tdfx_vid_set_overlay(arg); - case TDFX_VID_OVERLAY_ON: - return tdfx_vid_overlay_on(); - case TDFX_VID_OVERLAY_OFF: - return tdfx_vid_overlay_off(); - default: - printk(KERN_ERR "tdfx_vid: Invalid ioctl %d\n",cmd); - return -EINVAL; - } - return 0; -} - - - -static ssize_t tdfx_vid_read(struct file *file, char *buf, size_t count, loff_t *ppos) -{ - return 0; -} - -static ssize_t tdfx_vid_write(struct file *file, const char *buf, size_t count, loff_t *ppos) -{ - - return 0; -} - -static void tdfx_vid_mopen(struct vm_area_struct *vma) { - int i; - struct page *page; - unsigned long phys; - - printk(KERN_DEBUG "tdfx_vid: mopen\n"); - - for(i = 0 ; i < agp_mem->page_count ; i++) { - phys = agp_mem->memory[i] & ~(0x00000fff); - page = virt_to_page(phys_to_virt(phys)); - if(!page) { - printk(KERN_DEBUG "tdfx_vid: Can't get the page %d\%d\n",i,agp_mem->page_count); - return; - } - get_page(page); - } - MOD_INC_USE_COUNT; -} - -static void tdfx_vid_mclose(struct vm_area_struct *vma) { - int i; - struct page *page; - unsigned long phys; - - printk(KERN_DEBUG "tdfx_vid: mclose\n"); - - for(i = 0 ; i < agp_mem->page_count ; i++) { - phys = agp_mem->memory[i] & ~(0x00000fff); - page = virt_to_page(phys_to_virt(phys)); - if(!page) { - printk(KERN_DEBUG "tdfx_vid: Can't get the page %d\%d\n",i,agp_mem->page_count); - return; - } - put_page(page); - } - - MOD_DEC_USE_COUNT; -} - -static struct page *tdfx_vid_nopage(struct vm_area_struct *vma, - unsigned long address, - int write_access) { - unsigned long off; - uint32_t n; - struct page *page; - unsigned long phys; - - off = address - vma->vm_start + (vma->vm_pgoff<= agp_mem->page_count) { - printk(KERN_DEBUG "tdfx_vid: Too far away\n"); - return (struct page *)0UL; - } - phys = agp_mem->memory[n] & ~(0x00000fff); - page = virt_to_page(phys_to_virt(phys)); - if(!page) { - printk(KERN_DEBUG "tdfx_vid: Can't get the page\n"); - return (struct page *)0UL; - } - return page; -} - -/* memory handler functions */ -static struct vm_operations_struct tdfx_vid_vm_ops = { - open: tdfx_vid_mopen, /* mmap-open */ - close: tdfx_vid_mclose,/* mmap-close */ - nopage: tdfx_vid_nopage, /* no-page fault handler */ -}; - - -static int tdfx_vid_mmap(struct file *file, struct vm_area_struct *vma) -{ - size_t size; -#ifdef MP_DEBUG - printk(KERN_DEBUG "tdfx_vid: mapping agp memory into userspace\n"); -#endif - - size = (vma->vm_end-vma->vm_start + PAGE_SIZE - 1) / PAGE_SIZE; - - if(map_start) { // Ok we map directly in the physcal ram - if(size*PAGE_SIZE > map_max) { - printk(KERN_ERR "tdfx_vid: Not enouth mem\n"); - return -EAGAIN; - } -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,3) - if(remap_page_range(vma, vma->vm_start,map_start, - vma->vm_end - vma->vm_start, vma->vm_page_prot)) -#else - if(remap_page_range(vma->vm_start, (unsigned long)map_start, - vma->vm_end - vma->vm_start, vma->vm_page_prot)) -#endif - { - printk(KERN_ERR "tdfx_vid: error mapping video memory\n"); - return -EAGAIN; - } - printk(KERN_INFO "Physical mem 0x%lx mapped in userspace\n",map_start); - return 0; - } - - if(agp_mem) - return -EAGAIN; - - agp_mem = drm_agp->allocate_memory(size,AGP_NORMAL_MEMORY); - if(!agp_mem) { - printk(KERN_ERR "Failed to allocate AGP memory\n"); - return -ENOMEM; - } - - if(drm_agp->bind_memory(agp_mem,0)) { - printk(KERN_ERR "Failed to bind the AGP memory\n"); - drm_agp->free_memory(agp_mem); - agp_mem = NULL; - return -ENOMEM; - } - - printk(KERN_INFO "%d pages of AGP mem allocated (%ld/%ld bytes) :)))\n", - size,vma->vm_end-vma->vm_start,size*PAGE_SIZE); - - - if(tdfx_map_io) { -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,3) - if(remap_page_range(vma, vma->vm_start,agp_info.aper_base, - vma->vm_end - vma->vm_start, vma->vm_page_prot)) -#else - if(remap_page_range(vma->vm_start, (unsigned long)agp_info.aper_base, - vma->vm_end - vma->vm_start, vma->vm_page_prot)) -#endif - { - printk(KERN_ERR "tdfx_vid: error mapping video memory\n"); - return -EAGAIN; - } - } else { - // Never swap it out - vma->vm_flags |= VM_LOCKED | VM_IO; - vma->vm_ops = &tdfx_vid_vm_ops; - vma->vm_ops->open(vma); - printk(KERN_INFO "Page fault handler ready !!!!!\n"); - } - - return 0; -} - - -static int tdfx_vid_release(struct inode *inode, struct file *file) -{ -#ifdef MP_DEBUG - printk(KERN_DEBUG "tdfx_vid: Video OFF (release)\n"); -#endif - - // Release the agp mem - if(agp_mem) { - drm_agp->unbind_memory(agp_mem); - drm_agp->free_memory(agp_mem); - agp_mem = NULL; - } - - tdfx_vid_in_use = 0; - - MOD_DEC_USE_COUNT; - return 0; -} - -static long long tdfx_vid_lseek(struct file *file, long long offset, int origin) -{ - return -ESPIPE; -} - -static int tdfx_vid_open(struct inode *inode, struct file *file) -{ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,2) - int minor = MINOR(inode->i_rdev.value); -#else - int minor = MINOR(inode->i_rdev); -#endif - - if(minor != 0) - return -ENXIO; - - if(tdfx_vid_in_use == 1) - return -EBUSY; - - tdfx_vid_in_use = 1; - MOD_INC_USE_COUNT; - return 0; -} - -#if LINUX_VERSION_CODE >= 0x020400 -static struct file_operations tdfx_vid_fops = -{ - llseek: tdfx_vid_lseek, - read: tdfx_vid_read, - write: tdfx_vid_write, - ioctl: tdfx_vid_ioctl, - mmap: tdfx_vid_mmap, - open: tdfx_vid_open, - release: tdfx_vid_release -}; -#else -static struct file_operations tdfx_vid_fops = -{ - tdfx_vid_lseek, - tdfx_vid_read, - tdfx_vid_write, - NULL, - NULL, - tdfx_vid_ioctl, - tdfx_vid_mmap, - tdfx_vid_open, - NULL, - tdfx_vid_release -}; -#endif - - -int init_module(void) -{ - tdfx_vid_in_use = 0; - - if(register_chrdev(TDFX_VID_MAJOR, "tdfx_vid", &tdfx_vid_fops)) { - printk(KERN_ERR "tdfx_vid: unable to get major: %d\n", TDFX_VID_MAJOR); - return -EIO; - } - - if(!agp_init()) { - printk(KERN_ERR "tdfx_vid: AGP init failed\n"); - unregister_chrdev(TDFX_VID_MAJOR, "tdfx_vid"); - return -EINVAL; - } - - if (!tdfx_vid_find_card()) { - printk(KERN_ERR "tdfx_vid: no supported devices found\n"); - agp_close(); - unregister_chrdev(TDFX_VID_MAJOR, "tdfx_vid"); - return -EINVAL; - } - - - - return 0; - -} - -void cleanup_module(void) -{ - if(tdfx_mmio_base) - iounmap(tdfx_mmio_base); - agp_close(); - printk(KERN_INFO "tdfx_vid: Cleaning up module\n"); - unregister_chrdev(TDFX_VID_MAJOR, "tdfx_vid"); -} diff --git a/drivers/tdfx_vid.h b/drivers/tdfx_vid.h deleted file mode 100644 index 434e734e46..0000000000 --- a/drivers/tdfx_vid.h +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (C) 2003 Alban Bedel - * - * This file is part of MPlayer. - * - * MPlayer is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * MPlayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef MPLAYER_TDFX_VID_H -#define MPLAYER_TDFX_VID_H - -#define TDFX_VID_VERSION 1 - -#define TDFX_VID_MOVE_2_PACKED 0 -#define TDFX_VID_MOVE_2_YUV 1 -#define TDFX_VID_MOVE_2_3D 2 -#define TDFX_VID_MOVE_2_TEXTURE 3 - -#define TDFX_VID_SRC_COLORKEY 0x1 -#define TDFX_VID_DST_COLORKEY 0x2 - -#define TDFX_VID_ROP_COPY 0xcc // src -#define TDFX_VID_ROP_INVERT 0x55 // NOT dst -#define TDFX_VID_ROP_XOR 0x66 // src XOR dst -#define TDFX_VID_ROP_OR 0xee // src OR dst - -#define TDFX_VID_FORMAT_BGR1 (('B'<<24)|('G'<<16)|('R'<<8)|1) -#define TDFX_VID_FORMAT_BGR8 (('B'<<24)|('G'<<16)|('R'<<8)|8) -#define TDFX_VID_FORMAT_BGR15 (('B'<<24)|('G'<<16)|('R'<<8)|15) -#define TDFX_VID_FORMAT_BGR16 (('B'<<24)|('G'<<16)|('R'<<8)|16) -#define TDFX_VID_FORMAT_BGR24 (('B'<<24)|('G'<<16)|('R'<<8)|24) -#define TDFX_VID_FORMAT_BGR32 (('B'<<24)|('G'<<16)|('R'<<8)|32) - -#define TDFX_VID_FORMAT_YUY2 (('2'<<24)|('Y'<<16)|('U'<<8)|'Y') -#define TDFX_VID_FORMAT_UYVY (('Y'<<24)|('V'<<16)|('Y'<<8)|'U') - -#define TDFX_VID_FORMAT_YV12 0x32315659 -#define TDFX_VID_FORMAT_IYUV (('I'<<24)|('Y'<<16)|('U'<<8)|'V') -#define TDFX_VID_FORMAT_I420 (('I'<<24)|('4'<<16)|('2'<<8)|'0') - -#define TDFX_VID_YUV_STRIDE (1024) -#define TDFX_VID_YUV_PLANE_SIZE (0x0100000) - - -typedef struct tdfx_vid_blit_s { - uint32_t src; - uint32_t src_stride; - uint16_t src_x,src_y; - uint16_t src_w,src_h; - uint32_t src_format; - - uint32_t dst; - uint32_t dst_stride; - uint16_t dst_x,dst_y; - uint16_t dst_w,dst_h; - uint32_t dst_format; - - uint32_t src_colorkey[2]; - uint32_t dst_colorkey[2]; - - uint8_t colorkey; - uint8_t rop[4]; -} tdfx_vid_blit_t; - -typedef struct tdfx_vid_config_s { - uint16_t version; - uint16_t card_type; - uint32_t ram_size; - uint16_t screen_width; - uint16_t screen_height; - uint16_t screen_stride; - uint32_t screen_format; - uint32_t screen_start; -} tdfx_vid_config_t; - -typedef struct tdfx_vid_agp_move_s { - uint16_t move2; - uint16_t width,height; - - uint32_t src; - uint32_t src_stride; - - uint32_t dst; - uint32_t dst_stride; -} tdfx_vid_agp_move_t; - -typedef struct tdfx_vid_yuv_s { - uint32_t base; - uint16_t stride; -} tdfx_vid_yuv_t; - -typedef struct tdfx_vid_overlay_s { - uint32_t src[2]; // left and right buffer (2 buffer may be NULL) - uint16_t src_width,src_height; - uint16_t src_stride; - uint32_t format; - - uint16_t dst_width,dst_height; - int16_t dst_x,dst_y; - - uint8_t use_colorkey; - uint32_t colorkey[2]; // min/max - uint8_t invert_colorkey; -} tdfx_vid_overlay_t; - -#define TDFX_VID_GET_CONFIG _IOR('J', 1, tdfx_vid_config_t) -#define TDFX_VID_AGP_MOVE _IOW('J', 2, tdfx_vid_agp_move_t) -#define TDFX_VID_BLIT _IOW('J', 3, tdfx_vid_blit_t) -#define TDFX_VID_SET_YUV _IOW('J', 4, tdfx_vid_blit_t) -#define TDFX_VID_GET_YUV _IOR('J', 5, tdfx_vid_blit_t) -#define TDFX_VID_BUMP0 _IOW('J', 6, u16) -#define TDFX_VID_SET_OVERLAY _IOW('J', 7, tdfx_vid_overlay_t) -#define TDFX_VID_OVERLAY_ON _IO ('J', 8) -#define TDFX_VID_OVERLAY_OFF _IO ('J', 9) - -#endif /* MPLAYER_TDFX_VID_H */ diff --git a/drivers/tdfx_vid_test.c b/drivers/tdfx_vid_test.c deleted file mode 100644 index 39a14f5437..0000000000 --- a/drivers/tdfx_vid_test.c +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (C) 2003 Alban Bedel - * - * This file is part of MPlayer. - * - * MPlayer is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * MPlayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "tdfx_vid.h" - - -static void print_tdfd_vid_cfg(tdfx_vid_config_t* cfg) { - printf("tdfx_vid version %d\n" - " Ram: %d\n" - " Screen: %d x %d\n", - cfg->version, - cfg->ram_size, - cfg->screen_width, cfg->screen_height); -} - - -int main(void) { - int fd; - unsigned char *mem; - /* int i; */ - /* unsigned char *ptr; */ - tdfx_vid_agp_move_t move; - tdfx_vid_config_t cfg; - tdfx_vid_blit_t blit; - - fd = open("/dev/tdfx_vid", O_RDWR); - - if(fd <= 0) { - printf("Can't open /dev/tdfx_vid\n"); - return 1; - } - - if(ioctl(fd,TDFX_VID_GET_CONFIG,&cfg)) { - printf("Ioctl GET_CONFIG error\n"); - close(fd); - return 1; - } - - print_tdfd_vid_cfg(&cfg); - - mem = mmap( NULL, 640*480*2, PROT_READ | PROT_WRITE, MAP_SHARED, - fd, 0); - - if(mem == MAP_FAILED) { - printf("Memmap failed !!!!!\n"); - return 1; - } - -/* for(ptr = mem, i = 0 ; i < 640*480 ; i++) { */ -/* ptr[0] = i & 0xFF; */ -/* ptr[1] = (i & 0xFF); */ -/* ptr += 2; */ -/* } */ - - memset(mem,0xFF,640*480*2); - - memset(&move, 0, sizeof(tdfx_vid_agp_move_t)); - move.width = 640; - move.height = 240; - move.src_stride = 640; - move.dst_stride = 640*2; - - if(ioctl(fd,TDFX_VID_AGP_MOVE,&move)) { - printf("AGP Move failed !!!!\n"); - return 0; - } - - printf("AGP Move ????\n"); - sleep(1); - - blit.src = 0; - blit.src_stride = 640*2; - blit.src_x = blit.src_y = 0; - blit.src_w = 320; - blit.src_h = 240; - blit.src_format = cfg.screen_format; - - blit.dst = 240*640*2+320; - blit.dst_stride = 640*2; - blit.dst_x = blit.dst_y = 0; - blit.dst_w = 320; - blit.dst_h = 240; - blit.dst_format = cfg.screen_format; - - if(ioctl(fd,TDFX_VID_BLIT,&blit)) { - printf("Blit failed !!!!\n"); - return 0; - } - - close(fd); - return 1; -} diff --git a/libao2/ao_ivtv.c b/libao2/ao_ivtv.c deleted file mode 100644 index e05537cbd8..0000000000 --- a/libao2/ao_ivtv.c +++ /dev/null @@ -1,161 +0,0 @@ -/* - * audio output for WinTV PVR-150/250/350 (a.k.a IVTV) cards - * through Connexant hardware MPEG decoder - * See http://ivtvdriver.org/index.php/Main_Page for more details on the - * cards supported by the ivtv driver. - * - * WARNING: You need to force -ac hwmpa for audio output to work. - * - * Copyright (C) 2006 Benjamin Zores - * - * This file is part of MPlayer. - * - * MPlayer is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * MPlayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include - -#include "config.h" - -#include "mp_msg.h" - -#include "audio_out.h" -#include "audio_out_internal.h" -#include "libaf/af_format.h" -#include "libmpdemux/mpeg_packetizer.h" -#include "libvo/vo_ivtv.h" - -#define MPEG_AUDIO_ID 0x1C0 - -static int freq = 0; - -static const ao_info_t info = -{ - "IVTV MPEG Audio Decoder output", - "ivtv", - "Benjamin Zores", - "" -}; - -LIBAO_EXTERN(ivtv) - -/* to set/get/query special features/parameters */ -static int -control (int cmd,void *arg) -{ - return CONTROL_UNKNOWN; -} - -/* open & setup audio device */ -static int -init (int rate, int channels, int format, int flags) -{ - if (ivtv_fd < 0) - return 0; - - if (format != AF_FORMAT_MPEG2) - { - mp_msg (MSGT_AO, MSGL_FATAL, - "AO: [ivtv] can only handle MPEG audio streams.\n"); - return 0; - } - - ao_data.outburst = 2048; - ao_data.samplerate = rate; - ao_data.channels = channels; - ao_data.format = AF_FORMAT_MPEG2; - ao_data.buffersize = 2048; - ao_data.bps = rate * 2 * 2; - ao_data.brokenpts = 0; - freq = rate; - - /* check for supported audio rate */ - if (rate != 32000 || rate != 41000 || rate != 48000) - { - mp_tmsg (MSGT_AO, MSGL_ERR, "[AO MPEGPES] %d Hz not supported, try to resample.\n", rate); - rate = 48000; - } - - return 1; -} - -/* close audio device */ -static void -uninit (int immed) -{ - /* nothing to do */ -} - -/* stop playing and empty buffers (for seeking/pause) */ -static void -reset (void) -{ - /* nothing to do */ -} - -/* stop playing, keep buffers (for pause) */ -static void -audio_pause (void) -{ - reset (); -} - -/* resume playing, after audio_pause() */ -static void -audio_resume (void) -{ - /* nothing to do */ -} - -/* how many bytes can be played without blocking */ -static int -get_space (void) -{ - extern int vo_pts; - float x; - int y; - - x = (float) (vo_pts - ao_data.brokenpts) / 90000.0; - if (x <= 0) - return 0; - - y = freq * 4 * x; - y /= ao_data.outburst; - y *= ao_data.outburst; - - if (y > 32000) - y = 32000; - - return y; -} - -/* number of bytes played */ -static int -play (void *data, int len, int flags) -{ - if (ao_data.format != AF_FORMAT_MPEG2) - return 0; - - send_mpeg_pes_packet (data, len, MPEG_AUDIO_ID, ao_data.brokenpts, 2, ivtv_write); - - return len; -} - -/* delay in seconds between first and last sample in buffer */ -static float -get_delay (void) -{ - return 0.0; -} diff --git a/libao2/ao_mpegpes.c b/libao2/ao_mpegpes.c deleted file mode 100644 index fe3f20fc85..0000000000 --- a/libao2/ao_mpegpes.c +++ /dev/null @@ -1,336 +0,0 @@ -/* - * MPEG-PES audio output driver - * - * This file is part of MPlayer. - * - * MPlayer is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * MPlayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "config.h" - -#include "audio_out.h" -#include "audio_out_internal.h" - -#include "libaf/af_format.h" -#include "libmpdemux/mpeg_packetizer.h" -#include "subopt-helper.h" - -#include "mp_msg.h" - -#ifdef CONFIG_DVB -#include -#include -#include -audio_mixer_t dvb_mixer={255,255}; -#endif - -#define true 1 -#define false 0 - -extern int vo_mpegpes_fd; -int ao_mpegpes_fd = -1; - -#include - -static const ao_info_t info = -{ -#ifdef CONFIG_DVB - "DVB audio output", -#else - "MPEG-PES audio output", -#endif - "mpegpes", - "A'rpi", - "" -}; - -LIBAO_EXTERN(mpegpes) - - -// to set/get/query special features/parameters -static int control(int cmd,void *arg){ -#ifdef CONFIG_DVB - switch(cmd){ - case AOCONTROL_GET_VOLUME: - if(ao_mpegpes_fd >= 0){ - ((ao_control_vol_t*)(arg))->left=dvb_mixer.volume_left/2.56; - ((ao_control_vol_t*)(arg))->right=dvb_mixer.volume_right/2.56; - return CONTROL_OK; - } - return CONTROL_ERROR; - case AOCONTROL_SET_VOLUME: - if(ao_mpegpes_fd >= 0){ - dvb_mixer.volume_left=((ao_control_vol_t*)(arg))->left*2.56; - dvb_mixer.volume_right=((ao_control_vol_t*)(arg))->right*2.56; - if(dvb_mixer.volume_left>255) dvb_mixer.volume_left=255; - if(dvb_mixer.volume_right>255) dvb_mixer.volume_right=255; - // printf("Setting DVB volume: %d ; %d \n",dvb_mixer.volume_left,dvb_mixer.volume_right); - if ( (ioctl(vo_mpegpes_fd,AUDIO_SET_MIXER, &dvb_mixer) < 0)){ - mp_tmsg(MSGT_AO, MSGL_ERR, "[AO MPEGPES] DVB audio set mixer failed: %s.\n", - strerror(errno)); - return CONTROL_ERROR; - } - return CONTROL_OK; - } - return CONTROL_ERROR; - } -#endif - return CONTROL_UNKNOWN; -} - -static int freq=0; -static int freq_id=0; - -#ifdef CONFIG_DVB -static int init_device(int card) -{ - char ao_file[30]; - sprintf(ao_file, "/dev/dvb/adapter%d/audio0", card); - mp_msg(MSGT_VO,MSGL_INFO, "Opening %s\n", ao_file); - if((ao_mpegpes_fd = open(ao_file,O_RDWR|O_NONBLOCK)) < 0) - { - mp_msg(MSGT_VO, MSGL_ERR, "DVB AUDIO DEVICE: %s\n", strerror(errno)); - return -1; - } - if( (ioctl(ao_mpegpes_fd, AUDIO_SELECT_SOURCE, AUDIO_SOURCE_MEMORY) < 0)) - { - mp_msg(MSGT_VO, MSGL_ERR, "DVB AUDIO SELECT SOURCE: %s\n", strerror(errno)); - goto fail; - } - if((ioctl(ao_mpegpes_fd, AUDIO_PLAY) < 0)) - { - mp_msg(MSGT_VO, MSGL_ERR, "DVB AUDIO PLAY: %s\n", strerror(errno)); - goto fail; - } - if((ioctl(ao_mpegpes_fd, AUDIO_SET_AV_SYNC, true) < 0)) - { - mp_msg(MSGT_VO, MSGL_ERR, "DVB AUDIO SET AV SYNC: %s\n", strerror(errno)); - goto fail; - } - //FIXME: in vo_mpegpes audio was initialized as MUTEd - if((ioctl(ao_mpegpes_fd, AUDIO_SET_MUTE, false) < 0)) - { - mp_msg(MSGT_VO, MSGL_ERR, "DVB AUDIO SET MUTE: %s\n", strerror(errno)); - goto fail; - } - return ao_mpegpes_fd; -fail: - close(ao_mpegpes_fd); - ao_mpegpes_fd = -1; - return -1; -} -#endif - -static int preinit(const char *arg) -{ - int card = -1; - char *ao_file = NULL; - - const opt_t subopts[] = { - {"card", OPT_ARG_INT, &card, NULL}, - {"file", OPT_ARG_MSTRZ, &ao_file, NULL}, - {NULL} - }; - - if(subopt_parse(ao_subdevice, subopts) != 0) - { - mp_msg(MSGT_VO, MSGL_ERR, "AO_MPEGPES, Unrecognized options\n"); - return -1; - } - if(card==-1) - { - //search the first usable card - int n; - char file[30]; - for(n=0; n<4; n++) - { - sprintf(file, "/dev/dvb/adapter%d/audio0", n); - if(access(file, F_OK | W_OK)==0) - { - card = n+1; - break; - } - } - } - if((card < 1) || (card > 4)) - { - mp_msg(MSGT_VO, MSGL_ERR, "DVB card number must be between 1 and 4\n"); - return -1; - } - card--; - -#ifdef CONFIG_DVB - if(!ao_file) - return init_device(card); -#else - if(!ao_file) - return vo_mpegpes_fd; //video fd -#endif - - ao_mpegpes_fd = open(ao_file, O_WRONLY | O_CREAT, 0666); - if(ao_mpegpes_fd < 0) - { - mp_msg(MSGT_VO, MSGL_ERR, "ao_mpegpes: %s\n", strerror(errno)); - return -1; - } - return ao_mpegpes_fd; -} - -static int my_ao_write(const unsigned char* data,int len){ - int orig_len = len; -#ifdef CONFIG_DVB -#define NFD 1 - struct pollfd pfd[NFD]; - - pfd[0].fd = ao_mpegpes_fd; - pfd[0].events = POLLOUT; - - while(len>0){ - if(poll(pfd,NFD,1)){ - if(pfd[0].revents & POLLOUT){ - int ret = write(ao_mpegpes_fd, data, len); - if(ret<=0){ - mp_msg(MSGT_VO, MSGL_ERR, "ao_mpegpes write: %s\n", strerror(errno)); - usleep(0); - } else { - len-=ret; - data+=ret; - } - } else usleep(1000); - } - } - -#else - if(ao_mpegpes_fd < 0) return 0; // no file - write(ao_mpegpes_fd, data, len); // write to file -#endif - return orig_len; -} - - -// open & setup audio device -// return: 1=success 0=fail -static int init(int rate,int channels,int format,int flags){ - if(preinit(NULL)<0) return 0; - - ao_data.channels=2; - ao_data.outburst=2000; - switch(format){ - case AF_FORMAT_S16_BE: - case AF_FORMAT_MPEG2: - case AF_FORMAT_AC3_BE: - ao_data.format=format; - break; - case AF_FORMAT_AC3_LE: - ao_data.format=AF_FORMAT_AC3_BE; - break; - default: - ao_data.format=AF_FORMAT_S16_BE; - } - - switch(rate){ - case 48000: freq_id=0;break; - case 96000: freq_id=1;break; - case 44100: freq_id=2;break; - case 32000: freq_id=3;break; - default: - mp_tmsg(MSGT_AO, MSGL_ERR, "[AO MPEGPES] %d Hz not supported, try to resample.\n", rate); -#if 0 - if(rate>48000) rate=96000; else - if(rate>44100) rate=48000; else - if(rate>32000) rate=44100; else - rate=32000; - goto retry; -#else - rate=48000; freq_id=0; -#endif - } - - ao_data.bps=rate*2*2; - freq=ao_data.samplerate=rate; - - return 1; -} - -// close audio device -static void uninit(int immed){ - if (ao_mpegpes_fd >= 0) - close(ao_mpegpes_fd); - ao_mpegpes_fd = -1; -} - -// stop playing and empty buffers (for seeking/pause) -static void reset(void){ - -} - -// stop playing, keep buffers (for pause) -static void audio_pause(void) -{ - // for now, just call reset(); - reset(); -} - -// resume playing, after audio_pause() -static void audio_resume(void) -{ -} - -extern int vo_pts; - -// return: how many bytes can be played without blocking -static int get_space(void){ - float x=(float)(vo_pts-ao_data.brokenpts)/90000.0; - int y; - //FIXME: is it correct? - if(vo_mpegpes_fd < 0) return 32000; //not using -vo mpegpes -// printf("vo_pts: %5.3f ao_pts: %5.3f\n",vo_pts/90000.0,ao_data.brokenpts/90000.0); - if(x<=0) return 0; - y=freq*4*x;y/=ao_data.outburst;y*=ao_data.outburst; - if(y>32000) y=32000; -// printf("diff: %5.3f -> %d \n",x,y); - return y; -} - -// plays 'len' bytes of 'data' -// it should round it down to outburst*n -// return: number of bytes played -static int play(void* data,int len,int flags){ -// printf("\nao_mpegpes: play(%d) freq=%d\n",len,freq_id); - if(ao_data.format==AF_FORMAT_MPEG2) - send_mpeg_pes_packet (data, len, 0x1C0, ao_data.brokenpts, 1, my_ao_write); - else { -// if(len>2000) len=2000; -// printf("ao_mpegpes: len=%d \n",len); - send_mpeg_lpcm_packet(data, len, 0xA0, ao_data.brokenpts, freq_id, my_ao_write); - } - return len; -} - -// return: delay in seconds between first and last sample in buffer -static float get_delay(void){ - - return 0.0; -} diff --git a/libao2/ao_nas.c b/libao2/ao_nas.c deleted file mode 100644 index d3274df9a5..0000000000 --- a/libao2/ao_nas.c +++ /dev/null @@ -1,646 +0,0 @@ -/* - * NAS audio output driver - * - * copyright (c) 2001 Tobias Diedrich - * - * Based on the libaudiooss parts rewritten by me, which were - * originally based on the NAS output plugin for XMMS. - * - * XMMS plugin by Willem Monsuwe - * adapted for libaudiooss by Jon Trulson - * further modified by Erik Inge Bolsø - * largely rewritten and used for this ao driver by Tobias Diedrich - * - * This file is part of MPlayer. - * - * MPlayer is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * MPlayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -/* - * Theory of operation: - * - * The NAS consists of two parts, a server daemon and a client. - * We setup the server to use a buffer of size bytes_per_second - * with a low watermark of buffer_size - NAS_FRAG_SIZE. - * Upon starting the flow the server will generate a buffer underrun - * event and the event handler will fill the buffer for the first time. - * Now the server will generate a lowwater event when the server buffer - * falls below the low watermark value. The event handler gets called - * again and refills the buffer by the number of bytes requested by the - * server (usually a multiple of 4096). To prevent stuttering on - * startup (start of playing, seeks, unpausing) the client buffer should - * be bigger than the server buffer. (For debugging we also do some - * accounting of what we think how much of the server buffer is filled) - */ - -#include -#include -#include -#include -#include -#include -#include