From fb8dc89b4d3c2752f4d00c6e3f870a869c8de483 Mon Sep 17 00:00:00 2001 From: "Sergey Semyonov (Serge)" Date: Wed, 11 Feb 2009 06:52:01 +0000 Subject: [PATCH] move drivers from programs/system/drivers into /drivers git-svn-id: svn://kolibrios.org@1029 a494cfbc-eb01-0410-851d-a64ba20cac60 --- drivers/audio/a5536/geode.c | 21 +- drivers/audio/a5536/geode.lk | 23 + drivers/audio/a5536/makefile | 10 +- drivers/{ => audio}/sisnbook/codec.inc | 0 drivers/{ => audio}/sisnbook/readme.txt | 0 drivers/{ => audio}/sisnbook/sis.asm | 0 .../drivers/agp => drivers/include}/link.h | 0 drivers/include/pci.h | 183 ++++ .../drivers => drivers}/include/syscall.h | 6 + .../drivers => drivers}/include/types.h | 0 .../drivers/usb => drivers/usb/uhci}/ch9.h | 0 .../usb => drivers/usb/uhci}/detect.inc | 2 +- .../drivers/usb => drivers/usb/uhci}/hcd.inc | 0 .../drivers/usb => drivers/usb/uhci}/hid.h | 0 .../drivers/usb => drivers/usb/uhci}/hid.inc | 0 .../drivers/usb => drivers/usb/uhci}/makefile | 12 +- .../drivers/usb => drivers/usb/uhci}/pci.inc | 0 .../drivers/usb => drivers/usb/uhci}/usb.asm | 0 .../drivers/usb => drivers/usb/uhci}/usb.c | 1 + .../drivers/usb => drivers/usb/uhci}/usb.h | 0 .../usb/usb.lk1 => drivers/usb/uhci/usb.lk | 0 .../drivers => drivers/video}/agp/agp.c | 0 .../drivers => drivers/video}/agp/agp.h | 5 + .../drivers => drivers/video}/agp/agp.lk | 0 .../drivers => drivers/video}/agp/detect.inc | 0 .../drivers => drivers/video}/agp/isoch.inc | 0 .../include => drivers/video/agp}/link.h | 0 .../drivers => drivers/video}/agp/makefile | 9 +- .../drivers => drivers/video}/agp/pci.inc | 0 .../drivers => drivers/video}/agp/syscall.h | 0 .../drivers => drivers/video}/agp/types.h | 0 .../video}/ati2d/accel_2d.h | 0 .../video}/ati2d/accel_2d.inc | 475 +++++----- .../video}/ati2d/accel_3d.inc | 0 .../drivers => drivers/video}/ati2d/ati2d.c | 19 +- .../rhd.lk1 => drivers/video/ati2d/ati2d.lk | 7 +- .../drivers => drivers/video}/ati2d/ati_mem.c | 0 .../video}/ati2d/ati_pciids_gen.h | 0 .../drivers => drivers/video}/ati2d/atihw.h | 184 ++-- .../drivers => drivers/video}/ati2d/blend.inc | 389 ++------ .../drivers => drivers/video}/ati2d/clip.inc | 0 .../drivers => drivers/video}/ati2d/init.c | 35 +- .../video}/ati2d/init_3d.inc | 90 +- .../drivers => drivers/video}/ati2d/init_cp.c | 68 -- .../drivers => drivers/video}/ati2d/makefile | 10 +- .../drivers => drivers/video}/ati2d/pci.c | 76 ++ .../video}/ati2d/pixmap.inc | 53 +- .../drivers => drivers/video}/ati2d/r500.inc | 75 +- .../video}/ati2d/r5xx_2dregs.h | 0 .../video}/ati2d/r5xx_regs.h | 0 .../video}/ati2d/radeon_chipinfo_gen.h | 0 .../video}/ati2d/radeon_chipset_gen.h | 0 .../video}/ati2d/radeon_microcode.h | 0 .../video}/ati2d/radeon_reg.h | 0 .../video}/ati2d/rhd_regs.h | 0 .../video}/ati2d/vs_prog.inc | 0 .../video/radeonhd}/AtomBios/CD_Operations.c | 0 .../video/radeonhd}/AtomBios/Decoder.c | 0 .../video/radeonhd}/AtomBios/hwserv_drv.c | 0 .../AtomBios/includes/CD_Common_Types.h | 0 .../AtomBios/includes/CD_Definitions.h | 0 .../radeonhd}/AtomBios/includes/CD_Opcodes.h | 0 .../radeonhd}/AtomBios/includes/CD_Structs.h | 0 .../radeonhd}/AtomBios/includes/CD_binding.h | 0 .../AtomBios/includes/CD_hw_services.h | 0 .../radeonhd}/AtomBios/includes/Decoder.h | 0 .../radeonhd}/AtomBios/includes/ObjectID.h | 0 .../radeonhd}/AtomBios/includes/atombios.h | 0 .../radeonhd}/AtomBios/includes/regsdef.h | 0 .../rhd => drivers/video/radeonhd}/Xmd.h | 1 + .../rhd => drivers/video/radeonhd}/common.h | 0 .../rhd => drivers/video/radeonhd}/dbg.c | 0 .../rhd => drivers/video/radeonhd}/edid.h | 0 .../rhd => drivers/video/radeonhd}/loc_incl.h | 0 .../rhd => drivers/video/radeonhd}/makefile | 2 +- .../rhd => drivers/video/radeonhd}/malloc.c | 0 .../rhd => drivers/video/radeonhd}/memset.asm | 0 .../rhd => drivers/video/radeonhd}/pci.c | 0 drivers/video/radeonhd/pci.h | 196 ++++ .../video/radeonhd}/proc32.inc | 0 .../video/radeonhd}/r5xx_accel.h | 0 .../video/radeonhd}/radeon_reg.h | 0 .../rhd => drivers/video/radeonhd}/rhd.c | 625 ++++++++----- .../rhd => drivers/video/radeonhd}/rhd.h | 124 ++- .../rhd => drivers/video/radeonhd}/rhd.lk1 | 0 .../rhd => drivers/video/radeonhd}/rhd.mk | 0 .../video/radeonhd}/rhd_atombios.c | 2 +- .../video/radeonhd}/rhd_atombios.h | 0 .../video/radeonhd}/rhd_atomcrtc.c | 11 +- .../video/radeonhd}/rhd_atomout.c | 0 .../video/radeonhd}/rhd_atomout.h | 0 .../video/radeonhd}/rhd_atompll.c | 0 .../video/radeonhd}/rhd_atomwrapper.c | 0 .../video/radeonhd}/rhd_atomwrapper.h | 0 .../video/radeonhd}/rhd_audio.h | 0 .../video/radeonhd}/rhd_biosscratch.c | 0 .../video/radeonhd}/rhd_biosscratch.h | 0 .../rhd => drivers/video/radeonhd}/rhd_card.h | 0 .../video/radeonhd}/rhd_connector.c | 0 .../video/radeonhd}/rhd_connector.h | 0 .../rhd => drivers/video/radeonhd}/rhd_crtc.c | 38 +- .../rhd => drivers/video/radeonhd}/rhd_crtc.h | 2 +- .../rhd => drivers/video/radeonhd}/rhd_dac.c | 0 .../rhd => drivers/video/radeonhd}/rhd_ddia.c | 0 .../rhd => drivers/video/radeonhd}/rhd_dig.c | 0 .../rhd => drivers/video/radeonhd}/rhd_edid.c | 7 +- .../rhd => drivers/video/radeonhd}/rhd_hdmi.c | 0 .../rhd => drivers/video/radeonhd}/rhd_hdmi.h | 0 .../rhd => drivers/video/radeonhd}/rhd_i2c.c | 2 +- .../rhd => drivers/video/radeonhd}/rhd_i2c.h | 1 - .../rhd => drivers/video/radeonhd}/rhd_id.c | 2 + .../rhd => drivers/video/radeonhd}/rhd_lut.c | 0 .../rhd => drivers/video/radeonhd}/rhd_lut.h | 0 .../video/radeonhd}/rhd_lvtma.c | 10 +- drivers/video/radeonhd/rhd_mc.c | 803 ++++++++++++++++ .../rhd => drivers/video/radeonhd}/rhd_mc.h | 14 +- .../rhd => drivers/video/radeonhd}/rhd_mem.c | 0 .../video/radeonhd}/rhd_modes.c | 8 +- .../video/radeonhd}/rhd_modes.h | 0 .../video/radeonhd}/rhd_monitor.c | 0 .../video/radeonhd}/rhd_monitor.h | 0 .../video/radeonhd}/rhd_output.c | 0 .../video/radeonhd}/rhd_output.h | 0 .../rhd => drivers/video/radeonhd}/rhd_pll.c | 0 .../rhd => drivers/video/radeonhd}/rhd_pll.h | 0 .../rhd => drivers/video/radeonhd}/rhd_regs.h | 0 .../rhd => drivers/video/radeonhd}/rhd_tmds.c | 0 .../rhd => drivers/video/radeonhd}/rhd_vga.c | 147 ++- .../rhd => drivers/video/radeonhd}/rhd_vga.h | 21 +- .../video/radeonhd}/s_ceilf.asm | 0 .../rhd => drivers/video/radeonhd}/stdio.h | 0 .../rhd => drivers/video/radeonhd}/string.c | 0 .../rhd => drivers/video/radeonhd}/stub.asm | 0 .../rhd => drivers/video/radeonhd}/vdif.h | 0 .../rhd => drivers/video/radeonhd}/vsprintf.c | 0 .../rhd => drivers/video/radeonhd}/xf86.h | 0 .../rhd => drivers/video/radeonhd}/xf86DDC.h | 0 .../rhd => drivers/video/radeonhd}/xf86i2c.c | 0 .../rhd => drivers/video/radeonhd}/xf86i2c.h | 0 programs/develop/fast_call_test/test.ASM | 31 +- programs/system/drivers/agp/pci.h | 182 ---- programs/system/drivers/ati2d/pci.h | 82 -- programs/system/drivers/rhd/pci.h | 70 -- programs/system/drivers/rhd/proc32.inc | 269 ------ programs/system/drivers/rhd/rhd.bat | 5 - programs/system/drivers/rhd/rhd_mc.c | 882 ------------------ programs/system/drivers/usb/pci.h | 95 -- 147 files changed, 2570 insertions(+), 2815 deletions(-) create mode 100644 drivers/audio/a5536/geode.lk rename drivers/{ => audio}/sisnbook/codec.inc (100%) rename drivers/{ => audio}/sisnbook/readme.txt (100%) rename drivers/{ => audio}/sisnbook/sis.asm (100%) rename {programs/system/drivers/agp => drivers/include}/link.h (100%) create mode 100644 drivers/include/pci.h rename {programs/system/drivers => drivers}/include/syscall.h (94%) rename {programs/system/drivers => drivers}/include/types.h (100%) rename {programs/system/drivers/usb => drivers/usb/uhci}/ch9.h (100%) rename {programs/system/drivers/usb => drivers/usb/uhci}/detect.inc (94%) rename {programs/system/drivers/usb => drivers/usb/uhci}/hcd.inc (100%) rename {programs/system/drivers/usb => drivers/usb/uhci}/hid.h (100%) rename {programs/system/drivers/usb => drivers/usb/uhci}/hid.inc (100%) rename {programs/system/drivers/usb => drivers/usb/uhci}/makefile (68%) rename {programs/system/drivers/usb => drivers/usb/uhci}/pci.inc (100%) rename {programs/system/drivers/usb => drivers/usb/uhci}/usb.asm (100%) rename {programs/system/drivers/usb => drivers/usb/uhci}/usb.c (94%) rename {programs/system/drivers/usb => drivers/usb/uhci}/usb.h (100%) rename programs/system/drivers/usb/usb.lk1 => drivers/usb/uhci/usb.lk (100%) rename {programs/system/drivers => drivers/video}/agp/agp.c (100%) rename {programs/system/drivers => drivers/video}/agp/agp.h (93%) rename {programs/system/drivers => drivers/video}/agp/agp.lk (100%) rename {programs/system/drivers => drivers/video}/agp/detect.inc (100%) rename {programs/system/drivers => drivers/video}/agp/isoch.inc (100%) rename {programs/system/drivers/include => drivers/video/agp}/link.h (100%) rename {programs/system/drivers => drivers/video}/agp/makefile (75%) rename {programs/system/drivers => drivers/video}/agp/pci.inc (100%) rename {programs/system/drivers => drivers/video}/agp/syscall.h (100%) rename {programs/system/drivers => drivers/video}/agp/types.h (100%) rename {programs/system/drivers => drivers/video}/ati2d/accel_2d.h (100%) rename {programs/system/drivers => drivers/video}/ati2d/accel_2d.inc (66%) rename {programs/system/drivers => drivers/video}/ati2d/accel_3d.inc (100%) rename {programs/system/drivers => drivers/video}/ati2d/ati2d.c (91%) rename programs/system/drivers/ati2d/rhd.lk1 => drivers/video/ati2d/ati2d.lk (74%) rename {programs/system/drivers => drivers/video}/ati2d/ati_mem.c (100%) rename {programs/system/drivers => drivers/video}/ati2d/ati_pciids_gen.h (100%) rename {programs/system/drivers => drivers/video}/ati2d/atihw.h (74%) rename {programs/system/drivers => drivers/video}/ati2d/blend.inc (64%) rename {programs/system/drivers => drivers/video}/ati2d/clip.inc (100%) rename {programs/system/drivers => drivers/video}/ati2d/init.c (95%) rename {programs/system/drivers => drivers/video}/ati2d/init_3d.inc (92%) rename {programs/system/drivers => drivers/video}/ati2d/init_cp.c (81%) rename {programs/system/drivers => drivers/video}/ati2d/makefile (81%) rename {programs/system/drivers => drivers/video}/ati2d/pci.c (73%) rename {programs/system/drivers => drivers/video}/ati2d/pixmap.inc (82%) rename {programs/system/drivers => drivers/video}/ati2d/r500.inc (68%) rename {programs/system/drivers => drivers/video}/ati2d/r5xx_2dregs.h (100%) rename {programs/system/drivers => drivers/video}/ati2d/r5xx_regs.h (100%) rename {programs/system/drivers => drivers/video}/ati2d/radeon_chipinfo_gen.h (100%) rename {programs/system/drivers => drivers/video}/ati2d/radeon_chipset_gen.h (100%) rename {programs/system/drivers => drivers/video}/ati2d/radeon_microcode.h (100%) rename {programs/system/drivers => drivers/video}/ati2d/radeon_reg.h (100%) rename {programs/system/drivers => drivers/video}/ati2d/rhd_regs.h (100%) rename {programs/system/drivers => drivers/video}/ati2d/vs_prog.inc (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/AtomBios/CD_Operations.c (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/AtomBios/Decoder.c (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/AtomBios/hwserv_drv.c (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/AtomBios/includes/CD_Common_Types.h (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/AtomBios/includes/CD_Definitions.h (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/AtomBios/includes/CD_Opcodes.h (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/AtomBios/includes/CD_Structs.h (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/AtomBios/includes/CD_binding.h (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/AtomBios/includes/CD_hw_services.h (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/AtomBios/includes/Decoder.h (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/AtomBios/includes/ObjectID.h (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/AtomBios/includes/atombios.h (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/AtomBios/includes/regsdef.h (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/Xmd.h (99%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/common.h (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/dbg.c (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/edid.h (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/loc_incl.h (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/makefile (95%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/malloc.c (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/memset.asm (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/pci.c (100%) create mode 100644 drivers/video/radeonhd/pci.h rename {programs/system/drivers/ati2d => drivers/video/radeonhd}/proc32.inc (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/r5xx_accel.h (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/radeon_reg.h (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/rhd.c (59%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/rhd.h (83%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/rhd.lk1 (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/rhd.mk (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/rhd_atombios.c (99%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/rhd_atombios.h (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/rhd_atomcrtc.c (97%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/rhd_atomout.c (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/rhd_atomout.h (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/rhd_atompll.c (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/rhd_atomwrapper.c (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/rhd_atomwrapper.h (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/rhd_audio.h (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/rhd_biosscratch.c (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/rhd_biosscratch.h (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/rhd_card.h (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/rhd_connector.c (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/rhd_connector.h (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/rhd_crtc.c (99%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/rhd_crtc.h (99%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/rhd_dac.c (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/rhd_ddia.c (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/rhd_dig.c (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/rhd_edid.c (95%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/rhd_hdmi.c (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/rhd_hdmi.h (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/rhd_i2c.c (99%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/rhd_i2c.h (99%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/rhd_id.c (99%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/rhd_lut.c (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/rhd_lut.h (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/rhd_lvtma.c (99%) create mode 100644 drivers/video/radeonhd/rhd_mc.c rename {programs/system/drivers/rhd => drivers/video/radeonhd}/rhd_mc.h (79%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/rhd_mem.c (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/rhd_modes.c (99%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/rhd_modes.h (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/rhd_monitor.c (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/rhd_monitor.h (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/rhd_output.c (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/rhd_output.h (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/rhd_pll.c (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/rhd_pll.h (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/rhd_regs.h (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/rhd_tmds.c (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/rhd_vga.c (50%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/rhd_vga.h (74%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/s_ceilf.asm (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/stdio.h (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/string.c (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/stub.asm (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/vdif.h (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/vsprintf.c (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/xf86.h (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/xf86DDC.h (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/xf86i2c.c (100%) rename {programs/system/drivers/rhd => drivers/video/radeonhd}/xf86i2c.h (100%) delete mode 100644 programs/system/drivers/agp/pci.h delete mode 100644 programs/system/drivers/ati2d/pci.h delete mode 100644 programs/system/drivers/rhd/pci.h delete mode 100644 programs/system/drivers/rhd/proc32.inc delete mode 100644 programs/system/drivers/rhd/rhd.bat delete mode 100644 programs/system/drivers/rhd/rhd_mc.c delete mode 100644 programs/system/drivers/usb/pci.h diff --git a/drivers/audio/a5536/geode.c b/drivers/audio/a5536/geode.c index 66a69e6696..d577676d9f 100644 --- a/drivers/audio/a5536/geode.c +++ b/drivers/audio/a5536/geode.c @@ -9,6 +9,8 @@ #include "geode.h" +#define DEBUG + #ifdef DEBUG #define DBG(format,...) dbgprintf(format,##__VA_ARGS__) #else @@ -308,9 +310,16 @@ Bool init_device() return FALSE; } + u16_t id7c, id7e; + + id7c = snd_hw_CodecRead(AD1819A_VENDORID1); + id7e = snd_hw_CodecRead(AD1819A_VENDORID2); + + dbgprintf("codec id 0x7C %x 0x7E %x\n", id7c, id7e); + /*Check which codec is being used */ - if (snd_hw_CodecRead(AD1819A_VENDORID1) == 0x4144 && - snd_hw_CodecRead(AD1819A_VENDORID2) == 0x5303) + if ( (id7c == 0x4144) && + (id7e == 0x5303) ) { geode.fAD1819A = TRUE; /* Enable non-48kHz sample rates. */ @@ -322,16 +331,16 @@ Bool init_device() else { geode.fAD1819A = FALSE; - snd_hw_CodecWrite (EXT_AUDIO_CTRL_STAT, + snd_hw_CodecWrite(EXT_AUDIO_CTRL_STAT, (snd_hw_CodecRead(EXT_AUDIO_CTRL_STAT) | 0x0001)); /* set the VRA bit to ON*/ } /* set default volume*/ - snd_hw_CodecWrite( MASTER_VOLUME, 0x0B0B); - snd_hw_CodecWrite( PCM_OUT_VOL, 0x0808); + snd_hw_CodecWrite( MASTER_VOLUME, 0x0909); + snd_hw_CodecWrite( PCM_OUT_VOL, 0x0606); snd_hw_CodecWrite( PC_BEEP_VOLUME, 0x0000); - snd_hw_CodecWrite( PHONE_VOLUME, 0x8000); + snd_hw_CodecWrite( PHONE_VOLUME, 0x0606); snd_hw_CodecWrite( MIC_VOLUME, 0x8048); snd_hw_CodecWrite( LINE_IN_VOLUME, 0x0808); snd_hw_CodecWrite( CD_VOLUME, 0x8000); diff --git a/drivers/audio/a5536/geode.lk b/drivers/audio/a5536/geode.lk new file mode 100644 index 0000000000..022016e891 --- /dev/null +++ b/drivers/audio/a5536/geode.lk @@ -0,0 +1,23 @@ +IMP + _KernelAlloc core.KernelAlloc, + _KernelFree core.KernelFree, + _CommitPages core.CommitPages, + _MapIoMem core.MapIoMem, + _GetPgAddr core.GetPgAddr, + _CreateRingBuffer core.CreateRingBuffer, + _PciApi core.PciApi, + _PciRead8 core.PciRead8, + _PciRead16 core.PciRead16, + _PciRead32 core.PciRead32, + _PciWrite8 core.PciWrite8, + _PciWrite16 core.PciWrite16, + _PciWrite32 core.PciWrite32, + _RegService core.RegService, + _AttachIntHandler core.AttachIntHandler, + _SysMsgBoardStr core.SysMsgBoardStr, + _Delay core.Delay + + +FIL geode.obj, + vsprintf.obj, + icompute.obj diff --git a/drivers/audio/a5536/makefile b/drivers/audio/a5536/makefile index f1ce75adb4..dd601dc94f 100644 --- a/drivers/audio/a5536/makefile +++ b/drivers/audio/a5536/makefile @@ -4,12 +4,12 @@ FASM = e:/fasm/fasm.exe CFLAGS = -c -O2 -fomit-frame-pointer -fno-builtin-printf LDRHD = -shared -T ld.x -s --file-alignment 32 -INCLUDES = -I ../include +INCLUDES = -I ../../include -HFILES:= ../include/types.h \ - ../include/syscall.h \ - geode.h \ - pci.h +HFILES:= ../../include/types.h \ + ../../include/syscall.h \ + ../../include/pci.h \ + geode.h SRC_DEP:= GEODE_SRC:= amd_geode.h diff --git a/drivers/sisnbook/codec.inc b/drivers/audio/sisnbook/codec.inc similarity index 100% rename from drivers/sisnbook/codec.inc rename to drivers/audio/sisnbook/codec.inc diff --git a/drivers/sisnbook/readme.txt b/drivers/audio/sisnbook/readme.txt similarity index 100% rename from drivers/sisnbook/readme.txt rename to drivers/audio/sisnbook/readme.txt diff --git a/drivers/sisnbook/sis.asm b/drivers/audio/sisnbook/sis.asm similarity index 100% rename from drivers/sisnbook/sis.asm rename to drivers/audio/sisnbook/sis.asm diff --git a/programs/system/drivers/agp/link.h b/drivers/include/link.h similarity index 100% rename from programs/system/drivers/agp/link.h rename to drivers/include/link.h diff --git a/drivers/include/pci.h b/drivers/include/pci.h new file mode 100644 index 0000000000..e92c7cbf70 --- /dev/null +++ b/drivers/include/pci.h @@ -0,0 +1,183 @@ + + +#pragma pack(push, 1) +typedef struct +{ + u16_t device; + u16_t ChipSet; +}PciChipset_t; +#pragma pack(pop) + +#define VENDOR_ATI 0x1002 + + +#define PCI_CLASS_DISPLAY_VGA 0x0300 +/* + * Under PCI, each device has 256 bytes of configuration address space, + * of which the first 64 bytes are standardized as follows: + */ +#define PCI_VENDOR_ID 0x000 /* 16 bits */ +#define PCI_DEVICE_ID 0x002 /* 16 bits */ +#define PCI_COMMAND 0x004 /* 16 bits */ +#define PCI_COMMAND_IO 0x001 /* Enable response in I/O space */ +#define PCI_COMMAND_MEMORY 0x002 /* Enable response in Memory space */ +#define PCI_COMMAND_MASTER 0x004 /* Enable bus mastering */ +#define PCI_COMMAND_SPECIAL 0x008 /* Enable response to special cycles */ +#define PCI_COMMAND_INVALIDATE 0x010 /* Use memory write and invalidate */ +#define PCI_COMMAND_VGA_PALETTE 0x020 /* Enable palette snooping */ +#define PCI_COMMAND_PARITY 0x040 /* Enable parity checking */ +#define PCI_COMMAND_WAIT 0x080 /* Enable address/data stepping */ +#define PCI_COMMAND_SERR 0x100 /* Enable SERR */ +#define PCI_COMMAND_FAST_BACK 0x200 /* Enable back-to-back writes */ +#define PCI_COMMAND_INTX_DISABLE 0x400 /* INTx Emulation Disable */ + +#define PCI_STATUS 0x006 /* 16 bits */ +#define PCI_STATUS_CAP_LIST 0x010 /* Support Capability List */ +#define PCI_STATUS_66MHZ 0x020 /* Support 66 Mhz PCI 2.1 bus */ +#define PCI_STATUS_UDF 0x040 /* Support User Definable Features [obsolete] */ +#define PCI_STATUS_FAST_BACK 0x080 /* Accept fast-back to back */ +#define PCI_STATUS_PARITY 0x100 /* Detected parity error */ +#define PCI_STATUS_DEVSEL_MASK 0x600 /* DEVSEL timing */ +#define PCI_STATUS_DEVSEL_FAST 0x000 +#define PCI_STATUS_DEVSEL_MEDIUM 0x200 +#define PCI_STATUS_DEVSEL_SLOW 0x400 +#define PCI_STATUS_SIG_TARGET_ABORT 0x800 /* Set on target abort */ +#define PCI_STATUS_REC_TARGET_ABORT 0x1000 /* Master ack of " */ +#define PCI_STATUS_REC_MASTER_ABORT 0x2000 /* Set on master abort */ +#define PCI_STATUS_SIG_SYSTEM_ERROR 0x4000 /* Set when we drive SERR */ +#define PCI_STATUS_DETECTED_PARITY 0x8000 /* Set on parity error */ + +#define PCI_CLASS_REVISION 0x08 /* High 24 bits are class, low 8 revision */ +#define PCI_REVISION_ID 0x08 /* Revision ID */ +#define PCI_CLASS_PROG 0x09 /* Reg. Level Programming Interface */ +#define PCI_CLASS_DEVICE 0x0a /* Device class */ + +#define PCI_CACHE_LINE_SIZE 0x0c /* 8 bits */ +#define PCI_LATENCY_TIMER 0x0d /* 8 bits */ +#define PCI_HEADER_TYPE 0x0e /* 8 bits */ +#define PCI_HEADER_TYPE_NORMAL 0 +#define PCI_HEADER_TYPE_BRIDGE 1 +#define PCI_HEADER_TYPE_CARDBUS 2 + +#define PCI_BIST 0x0f /* 8 bits */ +#define PCI_BIST_CODE_MASK 0x0f /* Return result */ +#define PCI_BIST_START 0x40 /* 1 to start BIST, 2 secs or less */ +#define PCI_BIST_CAPABLE 0x80 /* 1 if BIST capable */ + +#define PCI_CAPABILITY_LIST 0x34 /* Offset of first capability list entry */ +#define PCI_CB_CAPABILITY_LIST 0x14 +/* Capability lists */ + +#define PCI_CAP_LIST_ID 0 /* Capability ID */ +#define PCI_CAP_ID_PM 0x01 /* Power Management */ +#define PCI_CAP_ID_AGP 0x02 /* Accelerated Graphics Port */ +#define PCI_CAP_ID_VPD 0x03 /* Vital Product Data */ +#define PCI_CAP_ID_SLOTID 0x04 /* Slot Identification */ +#define PCI_CAP_ID_MSI 0x05 /* Message Signalled Interrupts */ +#define PCI_CAP_ID_CHSWP 0x06 /* CompactPCI HotSwap */ +#define PCI_CAP_ID_PCIX 0x07 /* PCI-X */ +#define PCI_CAP_ID_HT 0x08 /* HyperTransport */ +#define PCI_CAP_ID_VNDR 0x09 /* Vendor specific capability */ +#define PCI_CAP_ID_SHPC 0x0C /* PCI Standard Hot-Plug Controller */ +#define PCI_CAP_ID_EXP 0x10 /* PCI Express */ +#define PCI_CAP_ID_MSIX 0x11 /* MSI-X */ +#define PCI_CAP_LIST_NEXT 1 /* Next capability in the list */ +#define PCI_CAP_FLAGS 2 /* Capability defined flags (16 bits) */ +#define PCI_CAP_SIZEOF 4 + + +/* AGP registers */ + +#define PCI_AGP_VERSION 2 /* BCD version number */ +#define PCI_AGP_RFU 3 /* Rest of capability flags */ +#define PCI_AGP_STATUS 4 /* Status register */ +#define PCI_AGP_STATUS_RQ_MASK 0xff000000 /* Maximum number of requests - 1 */ +#define PCI_AGP_STATUS_SBA 0x0200 /* Sideband addressing supported */ +#define PCI_AGP_STATUS_64BIT 0x0020 /* 64-bit addressing supported */ +#define PCI_AGP_STATUS_FW 0x0010 /* FW transfers supported */ +#define PCI_AGP_STATUS_RATE4 0x0004 /* 4x transfer rate supported */ +#define PCI_AGP_STATUS_RATE2 0x0002 /* 2x transfer rate supported */ +#define PCI_AGP_STATUS_RATE1 0x0001 /* 1x transfer rate supported */ +#define PCI_AGP_COMMAND 8 /* Control register */ +#define PCI_AGP_COMMAND_RQ_MASK 0xff000000 /* Master: Maximum number of requests */ +#define PCI_AGP_COMMAND_SBA 0x0200 /* Sideband addressing enabled */ +#define PCI_AGP_COMMAND_AGP 0x0100 /* Allow processing of AGP transactions */ +#define PCI_AGP_COMMAND_64BIT 0x0020 /* Allow processing of 64-bit addresses */ +#define PCI_AGP_COMMAND_FW 0x0010 /* Force FW transfers */ +#define PCI_AGP_COMMAND_RATE4 0x0004 /* Use 4x rate */ +#define PCI_AGP_COMMAND_RATE2 0x0002 /* Use 2x rate */ +#define PCI_AGP_COMMAND_RATE1 0x0001 /* Use 1x rate */ +#define PCI_AGP_SIZEOF 12 + + +#define PCI_MAP_REG_START 0x10 +#define PCI_MAP_REG_END 0x28 +#define PCI_MAP_ROM_REG 0x30 + +#define PCI_MAP_MEMORY 0x00000000 +#define PCI_MAP_IO 0x00000001 + +#define PCI_MAP_MEMORY_TYPE 0x00000007 +#define PCI_MAP_IO_TYPE 0x00000003 + +#define PCI_MAP_MEMORY_TYPE_32BIT 0x00000000 +#define PCI_MAP_MEMORY_TYPE_32BIT_1M 0x00000002 +#define PCI_MAP_MEMORY_TYPE_64BIT 0x00000004 +#define PCI_MAP_MEMORY_TYPE_MASK 0x00000006 +#define PCI_MAP_MEMORY_CACHABLE 0x00000008 +#define PCI_MAP_MEMORY_ATTR_MASK 0x0000000e +#define PCI_MAP_MEMORY_ADDRESS_MASK 0xfffffff0 + +#define PCI_MAP_IO_ATTR_MASK 0x00000003 + + + +#define PCI_MAP_IS_IO(b) ((b) & PCI_MAP_IO) +#define PCI_MAP_IS_MEM(b) (!PCI_MAP_IS_IO(b)) + +#define PCI_MAP_IS64BITMEM(b) \ + (((b) & PCI_MAP_MEMORY_TYPE_MASK) == PCI_MAP_MEMORY_TYPE_64BIT) + +#define PCIGETMEMORY(b) ((b) & PCI_MAP_MEMORY_ADDRESS_MASK) +#define PCIGETMEMORY64HIGH(b) (*((CARD32*)&b + 1)) +#define PCIGETMEMORY64(b) \ + (PCIGETMEMORY(b) | ((CARD64)PCIGETMEMORY64HIGH(b) << 32)) + +#define PCI_MAP_IO_ADDRESS_MASK 0xfffffffc + +#define PCIGETIO(b) ((b) & PCI_MAP_IO_ADDRESS_MASK) + +#define PCI_MAP_ROM_DECODE_ENABLE 0x00000001 +#define PCI_MAP_ROM_ADDRESS_MASK 0xfffff800 + +#define PCIGETROM(b) ((b) & PCI_MAP_ROM_ADDRESS_MASK) + + +#ifndef PCI_DOM_MASK +# define PCI_DOM_MASK 0x0ffu +#endif +#define PCI_DOMBUS_MASK (((PCI_DOM_MASK) << 8) | 0x0ffu) + +#define PCI_MAKE_TAG(b,d,f) ((((b) & (PCI_DOMBUS_MASK)) << 16) | \ + (((d) & 0x00001fu) << 11) | \ + (((f) & 0x000007u) << 8)) + +#define PCI_BUS_FROM_TAG(tag) (((tag) >> 16) & (PCI_DOMBUS_MASK)) +#define PCI_DEV_FROM_TAG(tag) (((tag) & 0x0000f800u) >> 11) +#define PCI_FUNC_FROM_TAG(tag) (((tag) & 0x00000700u) >> 8) +#define PCI_DFN_FROM_TAG(tag) (((tag) & 0x0000ff00u) >> 8) + + +#define PCI_CMD_STAT_REG 0x04 + + +typedef unsigned int PCITAG; + +extern inline PCITAG +pciTag(int busnum, int devnum, int funcnum) +{ + return(PCI_MAKE_TAG(busnum,devnum,funcnum)); +} + +const PciChipset_t *PciDevMatch(u16_t dev,const PciChipset_t *list); +u32_t pciGetBaseSize(int bus, int devfn, int index, Bool destructive, Bool *min); diff --git a/programs/system/drivers/include/syscall.h b/drivers/include/syscall.h similarity index 94% rename from programs/system/drivers/include/syscall.h rename to drivers/include/syscall.h index 8478122449..5e326ae1a6 100644 --- a/programs/system/drivers/include/syscall.h +++ b/drivers/include/syscall.h @@ -308,3 +308,9 @@ extern inline void delay(int time) } +extern inline void change_task() +{ + __asm__ __volatile__ ( + "call *__imp__ChangeTask"); +} + diff --git a/programs/system/drivers/include/types.h b/drivers/include/types.h similarity index 100% rename from programs/system/drivers/include/types.h rename to drivers/include/types.h diff --git a/programs/system/drivers/usb/ch9.h b/drivers/usb/uhci/ch9.h similarity index 100% rename from programs/system/drivers/usb/ch9.h rename to drivers/usb/uhci/ch9.h diff --git a/programs/system/drivers/usb/detect.inc b/drivers/usb/uhci/detect.inc similarity index 94% rename from programs/system/drivers/usb/detect.inc rename to drivers/usb/uhci/detect.inc index fcdb6c3cd0..0b7f43807f 100644 --- a/programs/system/drivers/usb/detect.inc +++ b/drivers/usb/uhci/detect.inc @@ -1,6 +1,6 @@ -Bool FindPciDevice() +static Bool FindPciDevice() { Bool retval = FALSE; u32_t bus, last_bus; diff --git a/programs/system/drivers/usb/hcd.inc b/drivers/usb/uhci/hcd.inc similarity index 100% rename from programs/system/drivers/usb/hcd.inc rename to drivers/usb/uhci/hcd.inc diff --git a/programs/system/drivers/usb/hid.h b/drivers/usb/uhci/hid.h similarity index 100% rename from programs/system/drivers/usb/hid.h rename to drivers/usb/uhci/hid.h diff --git a/programs/system/drivers/usb/hid.inc b/drivers/usb/uhci/hid.inc similarity index 100% rename from programs/system/drivers/usb/hid.inc rename to drivers/usb/uhci/hid.inc diff --git a/programs/system/drivers/usb/makefile b/drivers/usb/uhci/makefile similarity index 68% rename from programs/system/drivers/usb/makefile rename to drivers/usb/uhci/makefile index 60128bb6c7..f40c710c4d 100644 --- a/programs/system/drivers/usb/makefile +++ b/drivers/usb/uhci/makefile @@ -4,12 +4,12 @@ FASM = e:/fasm/fasm.exe CFLAGS = -c -O2 -fomit-frame-pointer -fno-builtin-printf LDRHD = -shared -T ld.x -s --file-alignment 32 -INCLUDES = -I ../include +INCLUDES = -I ../../include -HFILES:= ../include/types.h \ - ../include/syscall.h \ - ../include/link.h \ - pci.h \ +HFILES:= ../../include/types.h \ + ../../include/syscall.h \ + ../../include/link.h \ + ../../include/pci.h \ usb.h SRC_DEP:= pci.inc \ @@ -27,7 +27,7 @@ USB = usb.dll all: $(USB) $(USB): $(USB_OBJ) $(SRC_DEP) $(HFILES) Makefile - wlink name usb.dll SYS nt_dll lib libdrv op offset=0 op nod op maxe=25 op el op STUB=stub.exe op START=_drvEntry @usb.lk1 + wlink name usb.dll SYS nt_dll lib libdrv op offset=0 op nod op maxe=25 op el op STUB=stub.exe op START=_drvEntry @usb.lk kpack.exe usb.dll usb.drv usb.obj : usb.c $(SRC_DEP) $(HFILES) Makefile diff --git a/programs/system/drivers/usb/pci.inc b/drivers/usb/uhci/pci.inc similarity index 100% rename from programs/system/drivers/usb/pci.inc rename to drivers/usb/uhci/pci.inc diff --git a/programs/system/drivers/usb/usb.asm b/drivers/usb/uhci/usb.asm similarity index 100% rename from programs/system/drivers/usb/usb.asm rename to drivers/usb/uhci/usb.asm diff --git a/programs/system/drivers/usb/usb.c b/drivers/usb/uhci/usb.c similarity index 94% rename from programs/system/drivers/usb/usb.c rename to drivers/usb/uhci/usb.c index 8169237963..2614bc2f5c 100644 --- a/programs/system/drivers/usb/usb.c +++ b/drivers/usb/uhci/usb.c @@ -12,6 +12,7 @@ #include "syscall.h" #include "usb.h" +static Bool FindPciDevice(); int __stdcall srv_usb(ioctl_t *io); diff --git a/programs/system/drivers/usb/usb.h b/drivers/usb/uhci/usb.h similarity index 100% rename from programs/system/drivers/usb/usb.h rename to drivers/usb/uhci/usb.h diff --git a/programs/system/drivers/usb/usb.lk1 b/drivers/usb/uhci/usb.lk similarity index 100% rename from programs/system/drivers/usb/usb.lk1 rename to drivers/usb/uhci/usb.lk diff --git a/programs/system/drivers/agp/agp.c b/drivers/video/agp/agp.c similarity index 100% rename from programs/system/drivers/agp/agp.c rename to drivers/video/agp/agp.c diff --git a/programs/system/drivers/agp/agp.h b/drivers/video/agp/agp.h similarity index 93% rename from programs/system/drivers/agp/agp.h rename to drivers/video/agp/agp.h index 2880553a12..a25dc3006e 100644 --- a/programs/system/drivers/agp/agp.h +++ b/drivers/video/agp/agp.h @@ -138,5 +138,10 @@ typedef struct #define max_t(type,x,y) \ ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; }) +#define PCI_ANY_ID (~0) + +#define for_each_pci_dev(d) while ((d = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, d))!=-1) + + diff --git a/programs/system/drivers/agp/agp.lk b/drivers/video/agp/agp.lk similarity index 100% rename from programs/system/drivers/agp/agp.lk rename to drivers/video/agp/agp.lk diff --git a/programs/system/drivers/agp/detect.inc b/drivers/video/agp/detect.inc similarity index 100% rename from programs/system/drivers/agp/detect.inc rename to drivers/video/agp/detect.inc diff --git a/programs/system/drivers/agp/isoch.inc b/drivers/video/agp/isoch.inc similarity index 100% rename from programs/system/drivers/agp/isoch.inc rename to drivers/video/agp/isoch.inc diff --git a/programs/system/drivers/include/link.h b/drivers/video/agp/link.h similarity index 100% rename from programs/system/drivers/include/link.h rename to drivers/video/agp/link.h diff --git a/programs/system/drivers/agp/makefile b/drivers/video/agp/makefile similarity index 75% rename from programs/system/drivers/agp/makefile rename to drivers/video/agp/makefile index 51b23250a8..175e75c65b 100644 --- a/programs/system/drivers/agp/makefile +++ b/drivers/video/agp/makefile @@ -4,12 +4,11 @@ FASM = e:/fasm/fasm.exe CFLAGS = -c -O2 -fomit-frame-pointer -fno-builtin-printf LDRHD = -shared -T ld.x -s --file-alignment 32 -INCLUDES = -I ../include +INCLUDES = -I ../../include -HFILES:= ../include/types.h \ - ../include/syscall.h \ - agp.h \ - pci.h \ +HFILES:= ../../include/types.h \ + ../../include/syscall.h \ + agp.h SRC_DEP:= pci.inc \ detect.inc \ diff --git a/programs/system/drivers/agp/pci.inc b/drivers/video/agp/pci.inc similarity index 100% rename from programs/system/drivers/agp/pci.inc rename to drivers/video/agp/pci.inc diff --git a/programs/system/drivers/agp/syscall.h b/drivers/video/agp/syscall.h similarity index 100% rename from programs/system/drivers/agp/syscall.h rename to drivers/video/agp/syscall.h diff --git a/programs/system/drivers/agp/types.h b/drivers/video/agp/types.h similarity index 100% rename from programs/system/drivers/agp/types.h rename to drivers/video/agp/types.h diff --git a/programs/system/drivers/ati2d/accel_2d.h b/drivers/video/ati2d/accel_2d.h similarity index 100% rename from programs/system/drivers/ati2d/accel_2d.h rename to drivers/video/ati2d/accel_2d.h diff --git a/programs/system/drivers/ati2d/accel_2d.inc b/drivers/video/ati2d/accel_2d.inc similarity index 66% rename from programs/system/drivers/ati2d/accel_2d.inc rename to drivers/video/ati2d/accel_2d.inc index 0977cc55c2..dccd44e420 100644 --- a/programs/system/drivers/ati2d/accel_2d.inc +++ b/drivers/video/ati2d/accel_2d.inc @@ -2,18 +2,17 @@ int ClearPixmap(io_clear_t *io) { - u32_t ifl; u32_t *ring; local_pixmap_t *dstpixmap; dstpixmap = (io->dstpix == (void*)-1) ? &scr_pixmap : io->dstpix ; - ifl = safe_cli(); + lock_device(); #if R300_PIO - R5xxFIFOWait(6); + FIFOWait(6); OUTREG(R5XX_DP_GUI_MASTER_CNTL, RADEON_GMC_DST_PITCH_OFFSET_CNTL | @@ -53,7 +52,7 @@ int ClearPixmap(io_clear_t *io) #endif - safe_sti(ifl); + unlock_device(); return ERR_OK; } @@ -78,16 +77,15 @@ int Line(io_draw_t *draw) clip.xmax = dstpixmap->width-1; clip.ymax = dstpixmap->height-1; - if ( !LineClip(&clip, &x0, &y0, &x1, &y1 )) - { - u32_t ifl; + if ( !LineClip(&clip, &x0, &y0, &x1, &y1 )) + { u32_t *ring, write; - ifl = safe_cli(); + lock_device(); #if R300_PIO - R5xxFIFOWait(6); + FIFOWait(6); OUTREG(R5XX_DP_GUI_MASTER_CNTL, RADEON_GMC_DST_PITCH_OFFSET_CNTL | @@ -124,49 +122,49 @@ int Line(io_draw_t *draw) OUT_RING((y1<<16)|x1); COMMIT_RING(); #endif - safe_sti(ifl); - }; - return ERR_OK; + + unlock_device(); + }; + return ERR_OK; } int DrawRect(io_draw_t* draw) { - int x0, y0, x1, y1, xend, yend; + int x0, y0, x1, y1, xend, yend; - local_pixmap_t *dstpixmap; - clip_t dst_clip; + local_pixmap_t *dstpixmap; + clip_t dst_clip; - dstpixmap = (draw->dstpix == (void*)-1) ? &scr_pixmap : draw->dstpix ; + dstpixmap = (draw->dstpix == (void*)-1) ? &scr_pixmap : draw->dstpix ; - x0 = draw->x0; - y0 = draw->y0; + x0 = draw->x0; + y0 = draw->y0; - x1 = xend = x0 + draw->w - 1; - y1 = yend = y0 + draw->h - 1; + x1 = xend = x0 + draw->w - 1; + y1 = yend = y0 + draw->h - 1; - dst_clip.xmin = 0; - dst_clip.ymin = 0; - dst_clip.xmax = dstpixmap->width-1; - dst_clip.ymax = dstpixmap->height-1; + dst_clip.xmin = 0; + dst_clip.ymin = 0; + dst_clip.xmax = dstpixmap->width-1; + dst_clip.ymax = dstpixmap->height-1; // dbgprintf("draw rect x0:%d, y0:%d, x1:%d, y1:%d, color: %x\n", // x0, y0, x1, y1, draw->color); - if( ! BlockClip( &dst_clip, &x0, &y0, &x1, &y1)) - { + if( ! BlockClip( &dst_clip, &x0, &y0, &x1, &y1)) + { u32_t *ring; - u32_t ifl; int w, h; w = x1 - x0 + 1; h = y1 - y0 + 1; - ifl = safe_cli(); + lock_device(); #if R300_PIO - R5xxFIFOWait(6); + FIFOWait(7); OUTREG(R5XX_DP_GUI_MASTER_CNTL, RADEON_GMC_DST_PITCH_OFFSET_CNTL | @@ -186,39 +184,39 @@ int DrawRect(io_draw_t* draw) if( draw->color != draw->border) { - OUTREG(R5XX_DP_BRUSH_FRGD_CLR, draw->border); + OUTREG(R5XX_DP_BRUSH_FRGD_CLR, draw->border); - if( y0 == draw->y0) - { - R5xxFIFOWait(2); + if( y0 == draw->y0) + { + FIFOWait(2); - OUTREG(R5XX_DST_Y_X,(y0<<16)|x0); - OUTREG(R5XX_DST_WIDTH_HEIGHT,(w<<16)|1); - y0++; - h--; - } - if( y1 == yend ) - { - R5xxFIFOWait(2); + OUTREG(R5XX_DST_Y_X,(y0<<16)|x0); + OUTREG(R5XX_DST_WIDTH_HEIGHT,(w<<16)|1); + y0++; + h--; + } + if( y1 == yend ) + { + FIFOWait(2); - OUTREG(R5XX_DST_Y_X,(y1<<16)|x0); - OUTREG(R5XX_DST_WIDTH_HEIGHT,(w<<16)|1); - h--; - } - if( (h > 0) && (x0 == draw->x0)) - { - R5xxFIFOWait(2); + OUTREG(R5XX_DST_Y_X,(y1<<16)|x0); + OUTREG(R5XX_DST_WIDTH_HEIGHT,(w<<16)|1); + h--; + } + if( (h > 0) && (x0 == draw->x0)) + { + FIFOWait(2); - OUTREG(R5XX_DST_Y_X,(y0<<16)|x0); - OUTREG(R5XX_DST_WIDTH_HEIGHT,(1<<16)|h); - } - if( (h > 0) && (x1 == xend)) - { - R5xxFIFOWait(2); + OUTREG(R5XX_DST_Y_X,(y0<<16)|x0); + OUTREG(R5XX_DST_WIDTH_HEIGHT,(1<<16)|h); + } + if( (h > 0) && (x1 == xend)) + { + FIFOWait(2); - OUTREG(R5XX_DST_Y_X,(y0<<16)|x1); - OUTREG(R5XX_DST_WIDTH_HEIGHT,(1<<16)|h); - } + OUTREG(R5XX_DST_Y_X,(y0<<16)|x1); + OUTREG(R5XX_DST_WIDTH_HEIGHT,(1<<16)|h); + } }; #else @@ -244,50 +242,67 @@ int DrawRect(io_draw_t* draw) if( draw->color != draw->border) { - if( y0 == draw->y0) { - OUT_RING(CP_PACKET3(RADEON_CNTL_PAINT_MULTI, 4)); - OUT_RING(RADEON_GMC_DST_PITCH_OFFSET_CNTL | - RADEON_GMC_BRUSH_SOLID_COLOR | - RADEON_GMC_DST_32BPP | - RADEON_GMC_SRC_DATATYPE_COLOR | - R5XX_GMC_CLR_CMP_CNTL_DIS | - R5XX_GMC_WR_MSK_DIS | - R5XX_ROP3_P - ); + if( y0 == draw->y0) { + OUT_RING(CP_PACKET3(RADEON_CNTL_PAINT_MULTI, 4)); + OUT_RING(RADEON_GMC_DST_PITCH_OFFSET_CNTL | + RADEON_GMC_BRUSH_SOLID_COLOR | + RADEON_GMC_DST_32BPP | + RADEON_GMC_SRC_DATATYPE_COLOR | + R5XX_GMC_CLR_CMP_CNTL_DIS | + R5XX_GMC_WR_MSK_DIS | + R5XX_ROP3_P + ); - OUT_RING(dstpixmap->pitch_offset); - OUT_RING(draw->border); - OUT_RING((x0<<16)|y0); - OUT_RING((w<<16)|1); - OUT_RING(CP_PACKET2()); - OUT_RING(CP_PACKET2()); + OUT_RING(dstpixmap->pitch_offset); + OUT_RING(draw->border); + OUT_RING((x0<<16)|y0); + OUT_RING((w<<16)|1); + OUT_RING(CP_PACKET2()); + OUT_RING(CP_PACKET2()); // y0++; // h--; - } - if( y1 == yend ) { - OUT_RING(CP_PACKET3(RADEON_CNTL_PAINT_MULTI, 4)); - OUT_RING(RADEON_GMC_DST_PITCH_OFFSET_CNTL | - RADEON_GMC_BRUSH_SOLID_COLOR | - RADEON_GMC_DST_32BPP | - RADEON_GMC_SRC_DATATYPE_COLOR | - R5XX_GMC_CLR_CMP_CNTL_DIS | - R5XX_GMC_WR_MSK_DIS | - R5XX_ROP3_P - ); - - OUT_RING(dstpixmap->pitch_offset); - OUT_RING(draw->border); - OUT_RING((x0<<16)|y1); - OUT_RING((w<<16)|1); - OUT_RING(CP_PACKET2()); - OUT_RING(CP_PACKET2()); + } + if( y1 == yend ) { + OUT_RING(CP_PACKET3(RADEON_CNTL_PAINT_MULTI, 4)); + OUT_RING(RADEON_GMC_DST_PITCH_OFFSET_CNTL | + RADEON_GMC_BRUSH_SOLID_COLOR | + RADEON_GMC_DST_32BPP | + RADEON_GMC_SRC_DATATYPE_COLOR | + R5XX_GMC_CLR_CMP_CNTL_DIS | + R5XX_GMC_WR_MSK_DIS | + R5XX_ROP3_P + ); + OUT_RING(dstpixmap->pitch_offset); + OUT_RING(draw->border); + OUT_RING((x0<<16)|y1); + OUT_RING((w<<16)|1); + OUT_RING(CP_PACKET2()); + OUT_RING(CP_PACKET2()); // h--; - } - if( (h > 0) && (x0 == draw->x0)) { - OUT_RING(CP_PACKET3(RADEON_CNTL_PAINT_MULTI, 4)); - OUT_RING(RADEON_GMC_DST_PITCH_OFFSET_CNTL | + } + if( (h > 0) && (x0 == draw->x0)) { + OUT_RING(CP_PACKET3(RADEON_CNTL_PAINT_MULTI, 4)); + OUT_RING(RADEON_GMC_DST_PITCH_OFFSET_CNTL | + RADEON_GMC_BRUSH_SOLID_COLOR | + RADEON_GMC_DST_32BPP | + RADEON_GMC_SRC_DATATYPE_COLOR | + R5XX_GMC_CLR_CMP_CNTL_DIS | + R5XX_GMC_WR_MSK_DIS | + R5XX_ROP3_P + ); + + OUT_RING(dstpixmap->pitch_offset); + OUT_RING(draw->border); + OUT_RING((x0<<16)|y0); + OUT_RING((1<<16)|h); + OUT_RING(CP_PACKET2()); + OUT_RING(CP_PACKET2()); + } + if( (h > 0) && (x1 == xend)) { + OUT_RING(CP_PACKET3(RADEON_CNTL_PAINT_MULTI, 4)); + OUT_RING(RADEON_GMC_DST_PITCH_OFFSET_CNTL | RADEON_GMC_BRUSH_SOLID_COLOR | RADEON_GMC_DST_32BPP | RADEON_GMC_SRC_DATATYPE_COLOR | @@ -296,33 +311,13 @@ int DrawRect(io_draw_t* draw) R5XX_ROP3_P ); - OUT_RING(dstpixmap->pitch_offset); - OUT_RING(draw->border); - OUT_RING((x0<<16)|y0); - OUT_RING((1<<16)|h); - OUT_RING(CP_PACKET2()); - OUT_RING(CP_PACKET2()); - - } - if( (h > 0) && (x1 == xend)) { - OUT_RING(CP_PACKET3(RADEON_CNTL_PAINT_MULTI, 4)); - OUT_RING(RADEON_GMC_DST_PITCH_OFFSET_CNTL | - RADEON_GMC_BRUSH_SOLID_COLOR | - RADEON_GMC_DST_32BPP | - RADEON_GMC_SRC_DATATYPE_COLOR | - R5XX_GMC_CLR_CMP_CNTL_DIS | - R5XX_GMC_WR_MSK_DIS | - R5XX_ROP3_P - ); - - OUT_RING(dstpixmap->pitch_offset); - OUT_RING(draw->border); - OUT_RING((x1<<16)|y0); - OUT_RING((1<<16)|h); - OUT_RING(CP_PACKET2()); - OUT_RING(CP_PACKET2()); - - } + OUT_RING(dstpixmap->pitch_offset); + OUT_RING(draw->border); + OUT_RING((x1<<16)|y0); + OUT_RING((1<<16)|h); + OUT_RING(CP_PACKET2()); + OUT_RING(CP_PACKET2()); + } }; /* @@ -383,46 +378,45 @@ int DrawRect(io_draw_t* draw) COMMIT_RING(); #endif - safe_sti(ifl); - }; - return ERR_OK; + unlock_device(); + }; + return ERR_OK; } int FillRect(io_fill_t *fill) { - local_pixmap_t *dstpixmap; - clip_t dst_clip; - int x0, y0, x1, y1, xend, yend; + local_pixmap_t *dstpixmap; + clip_t dst_clip; + int x0, y0, x1, y1, xend, yend; - dstpixmap = (fill->dstpix == (void*)-1) ? &scr_pixmap : fill->dstpix ; + dstpixmap = (fill->dstpix == (void*)-1) ? &scr_pixmap : fill->dstpix ; - x0 = fill->x; - y0 = fill->y; + x0 = fill->x; + y0 = fill->y; - xend = x1 = x0 + fill->w - 1; - yend = y1 = y0 + fill->h - 1; + xend = x1 = x0 + fill->w - 1; + yend = y1 = y0 + fill->h - 1; - dst_clip.xmin = 0; - dst_clip.ymin = 0; - dst_clip.xmax = dstpixmap->width-1; - dst_clip.ymax = dstpixmap->height-1; + dst_clip.xmin = 0; + dst_clip.ymin = 0; + dst_clip.xmax = dstpixmap->width-1; + dst_clip.ymax = dstpixmap->height-1; // dbgprintf("fill rect x0:%d, y0:%d, x1:%d, y1:%d\n", // x0, y0, x1, y1); - if( ! BlockClip(&dst_clip, &x0, &y0, &x1, &y1)) - { + if( ! BlockClip(&dst_clip, &x0, &y0, &x1, &y1)) + { u32_t *ring, write; - u32_t ifl; int w = x1 - x0 + 1; int h = y1 - y0 + 1; - ifl = safe_cli(); + lock_device(); #if R300_PIO - R5xxFIFOWait(9); + FIFOWait(9); OUTREG(R5XX_DP_GUI_MASTER_CNTL, RADEON_GMC_DST_PITCH_OFFSET_CNTL | @@ -448,51 +442,51 @@ int FillRect(io_fill_t *fill) if( (fill->border & 0xFF000000) != 0) { - R5xxFIFOWait(2); + FIFOWait(2); - OUTREG(R5XX_DP_GUI_MASTER_CNTL, - RADEON_GMC_DST_PITCH_OFFSET_CNTL | - RADEON_GMC_BRUSH_SOLID_COLOR | - RADEON_GMC_DST_32BPP | - RADEON_GMC_SRC_DATATYPE_COLOR | - R5XX_GMC_CLR_CMP_CNTL_DIS | - R5XX_GMC_WR_MSK_DIS | - R5XX_ROP3_P - ); + OUTREG(R5XX_DP_GUI_MASTER_CNTL, + RADEON_GMC_DST_PITCH_OFFSET_CNTL | + RADEON_GMC_BRUSH_SOLID_COLOR | + RADEON_GMC_DST_32BPP | + RADEON_GMC_SRC_DATATYPE_COLOR | + R5XX_GMC_CLR_CMP_CNTL_DIS | + R5XX_GMC_WR_MSK_DIS | + R5XX_ROP3_P + ); - OUTREG(R5XX_DP_BRUSH_FRGD_CLR, fill->border); + OUTREG(R5XX_DP_BRUSH_FRGD_CLR, fill->border); - if( y0 == fill->y) - { - R5xxFIFOWait(2); + if( y0 == fill->y) + { + FIFOWait(2); - OUTREG(R5XX_DST_Y_X,(y0<<16)|x0); - OUTREG(R5XX_DST_WIDTH_HEIGHT,(w<<16)|1); - y0++; - h--; - } - if( y1 == yend ) - { - R5xxFIFOWait(2); + OUTREG(R5XX_DST_Y_X,(y0<<16)|x0); + OUTREG(R5XX_DST_WIDTH_HEIGHT,(w<<16)|1); + y0++; + h--; + } + if( y1 == yend ) + { + FIFOWait(2); - OUTREG(R5XX_DST_Y_X,(y1<<16)|x0); - OUTREG(R5XX_DST_WIDTH_HEIGHT,(w<<16)|1); - h--; - } - if( (h > 0) && (x0 == fill->x)) - { - R5xxFIFOWait(2); + OUTREG(R5XX_DST_Y_X,(y1<<16)|x0); + OUTREG(R5XX_DST_WIDTH_HEIGHT,(w<<16)|1); + h--; + } + if( (h > 0) && (x0 == fill->x)) + { + FIFOWait(2); - OUTREG(R5XX_DST_Y_X,(y0<<16)|x0); - OUTREG(R5XX_DST_WIDTH_HEIGHT,(1<<16)|h); - } - if( (h > 0) && (x1 == xend)) - { - R5xxFIFOWait(2); + OUTREG(R5XX_DST_Y_X,(y0<<16)|x0); + OUTREG(R5XX_DST_WIDTH_HEIGHT,(1<<16)|h); + } + if( (h > 0) && (x1 == xend)) + { + FIFOWait(2); - OUTREG(R5XX_DST_Y_X,(y0<<16)|x1); - OUTREG(R5XX_DST_WIDTH_HEIGHT,(1<<16)|h); - } + OUTREG(R5XX_DST_Y_X,(y0<<16)|x1); + OUTREG(R5XX_DST_WIDTH_HEIGHT,(1<<16)|h); + } }; @@ -521,47 +515,47 @@ int FillRect(io_fill_t *fill) if( (fill->border & 0xFF000000) != 0) { - CP_REG(R5XX_DP_GUI_MASTER_CNTL, - RADEON_GMC_DST_PITCH_OFFSET_CNTL | - RADEON_GMC_BRUSH_SOLID_COLOR | - RADEON_GMC_DST_32BPP | - RADEON_GMC_SRC_DATATYPE_COLOR | - R5XX_GMC_CLR_CMP_CNTL_DIS | - R5XX_GMC_WR_MSK_DIS | - R5XX_ROP3_P - ); + CP_REG(R5XX_DP_GUI_MASTER_CNTL, + RADEON_GMC_DST_PITCH_OFFSET_CNTL | + RADEON_GMC_BRUSH_SOLID_COLOR | + RADEON_GMC_DST_32BPP | + RADEON_GMC_SRC_DATATYPE_COLOR | + R5XX_GMC_CLR_CMP_CNTL_DIS | + R5XX_GMC_WR_MSK_DIS | + R5XX_ROP3_P + ); - CP_REG(R5XX_DP_BRUSH_FRGD_CLR, fill->border); + CP_REG(R5XX_DP_BRUSH_FRGD_CLR, fill->border); - if( y0 == fill->y) - { - CP_REG(R5XX_DST_Y_X,(y0<<16)|x0); - CP_REG(R5XX_DST_WIDTH_HEIGHT,(w<<16)|1); - y0++; - h--; - } - if( y1 == yend ) - { - CP_REG(R5XX_DST_Y_X,(y1<<16)|x0); - CP_REG(R5XX_DST_WIDTH_HEIGHT,(w<<16)|1); - h--; - } - if( (h > 0) && (x0 == fill->x)) - { - CP_REG(R5XX_DST_Y_X,(y0<<16)|x0); - CP_REG(R5XX_DST_WIDTH_HEIGHT,(1<<16)|h); - } - if( (h > 0) && (x1 == xend)) - { - CP_REG(R5XX_DST_Y_X,(y0<<16)|x1); - CP_REG(R5XX_DST_WIDTH_HEIGHT,(1<<16)|h); - } + if( y0 == fill->y) + { + CP_REG(R5XX_DST_Y_X,(y0<<16)|x0); + CP_REG(R5XX_DST_WIDTH_HEIGHT,(w<<16)|1); + y0++; + h--; + } + if( y1 == yend ) + { + CP_REG(R5XX_DST_Y_X,(y1<<16)|x0); + CP_REG(R5XX_DST_WIDTH_HEIGHT,(w<<16)|1); + h--; + } + if( (h > 0) && (x0 == fill->x)) + { + CP_REG(R5XX_DST_Y_X,(y0<<16)|x0); + CP_REG(R5XX_DST_WIDTH_HEIGHT,(1<<16)|h); + } + if( (h > 0) && (x1 == xend)) + { + CP_REG(R5XX_DST_Y_X,(y0<<16)|x1); + CP_REG(R5XX_DST_WIDTH_HEIGHT,(1<<16)|h); + } }; COMMIT_RING(); #endif - safe_sti(ifl); + unlock_device(); }; return ERR_OK; }; @@ -574,11 +568,10 @@ static int blit_host(u32_t dstpitch, int dstx, int dsty, u32_t src, int srcx, int srcy, int w, int h, int srcpitch, Bool trans, color_t key) { - u32_t ifl; u32_t dp_cntl; color_t *src_addr; - ifl = safe_cli(); + lock_device(); #if R300_PIO @@ -593,10 +586,10 @@ static int blit_host(u32_t dstpitch, int dstx, int dsty, if( trans == FALSE ) { dp_cntl|= R5XX_GMC_CLR_CMP_CNTL_DIS; - R5xxFIFOWait(5); + FIFOWait(5); } else - R5xxFIFOWait(8); + FIFOWait(8); OUTREG(R5XX_DP_GUI_MASTER_CNTL, dp_cntl); @@ -659,7 +652,7 @@ static int blit_host(u32_t dstpitch, int dstx, int dsty, #endif - safe_sti(ifl); + unlock_device(); return ERR_OK; } @@ -673,6 +666,7 @@ int Blit(io_blit_t *blit) local_pixmap_t *dstpixmap; u32_t srcpitchoffset; + Bool need_sync = FALSE; dstpixmap = (blit->dstpix == (void*)-1) ? &scr_pixmap : blit->dstpix ; srcpixmap = (blit->srcpix == (void*)-1) ? &scr_pixmap : blit->srcpix ; @@ -692,7 +686,6 @@ int Blit(io_blit_t *blit) &blit->w, &blit->h) ) { u32_t *ring, write; - u32_t ifl; /* if( (srcpixmap->flags & PX_MEM_MASK)==PX_MEM_SYSTEM) return blit_host(dstpixmap->pitch_offset, @@ -704,16 +697,19 @@ int Blit(io_blit_t *blit) FALSE, 0 ); */ - if( (srcpixmap->flags & PX_MEM_MASK)==PX_MEM_SYSTEM) - srcpitchoffset = bind_pixmap(srcpixmap); - else +// if( (srcpixmap->flags & PX_MEM_MASK)==PX_MEM_SYSTEM) +// { +// srcpitchoffset = bind_pixmap(srcpixmap); +// need_sync = TRUE; +// } +// else srcpitchoffset = srcpixmap->pitch_offset; - ifl = safe_cli(); + lock_device(); #if R300_PIO - R5xxFIFOWait(7); + FIFOWait(7); OUTREG(R5XX_DP_GUI_MASTER_CNTL, RADEON_GMC_SRC_PITCH_OFFSET_CNTL | @@ -761,16 +757,17 @@ int Blit(io_blit_t *blit) COMMIT_RING(); #endif - safe_sti(ifl); - if( (srcpixmap->flags & PX_MEM_MASK)==PX_MEM_SYSTEM) + if( need_sync == TRUE ) R5xx2DIdleLocal(); + + unlock_device(); + }; return ERR_OK; }; - int BlitTransparent(io_blit_t *blit) { clip_t src_clip, dst_clip; @@ -779,6 +776,7 @@ int BlitTransparent(io_blit_t *blit) local_pixmap_t *dstpixmap; u32_t srcpitchoffset; + Bool need_sync = FALSE; // dbgprintf("Transblit src: %x dst: %x\n",blit->srcpix, blit->dstpix); @@ -806,19 +804,21 @@ int BlitTransparent(io_blit_t *blit) &blit->w, &blit->h) ) { u32_t *ring, write; - u32_t ifl; - if( (srcpixmap->flags & PX_MEM_MASK)==PX_MEM_SYSTEM) - srcpitchoffset = bind_pixmap(srcpixmap); - else +// if( (srcpixmap->flags & PX_MEM_MASK)==PX_MEM_SYSTEM) +// { +// srcpitchoffset = bind_pixmap(srcpixmap); +// need_sync = TRUE; +// } +// else srcpitchoffset = srcpixmap->pitch_offset; - ifl = safe_cli(); + lock_device(); #if R300_PIO - R5xxFIFOWait(10); + FIFOWait(10); OUTREG(R5XX_DP_GUI_MASTER_CNTL, RADEON_GMC_SRC_PITCH_OFFSET_CNTL | @@ -875,11 +875,12 @@ int BlitTransparent(io_blit_t *blit) #endif - safe_sti(ifl); - - if( (srcpixmap->flags & PX_MEM_MASK)==PX_MEM_SYSTEM) + if( need_sync == TRUE ) R5xx2DIdleLocal(); + unlock_device(); + + }; return ERR_OK; } diff --git a/programs/system/drivers/ati2d/accel_3d.inc b/drivers/video/ati2d/accel_3d.inc similarity index 100% rename from programs/system/drivers/ati2d/accel_3d.inc rename to drivers/video/ati2d/accel_3d.inc diff --git a/programs/system/drivers/ati2d/ati2d.c b/drivers/video/ati2d/ati2d.c similarity index 91% rename from programs/system/drivers/ati2d/ati2d.c rename to drivers/video/ati2d/ati2d.c index e41cc18e85..f58ab66d63 100644 --- a/programs/system/drivers/ati2d/ati2d.c +++ b/drivers/video/ati2d/ati2d.c @@ -1,6 +1,6 @@ -#define R300_PIO 1 +#define R300_PIO 0 #define API_VERSION 0x01000100 @@ -60,6 +60,9 @@ u32_t __stdcall drvEntry(int action) return 0; }; + dbgprintf("detect %s GART\n", + rhd.gart_type == RADEON_IS_PCIE ? "PCIE":"PCI"); + for(i=0;i<6;i++) { if(rhd.memBase[i]) @@ -77,12 +80,8 @@ u32_t __stdcall drvEntry(int action) R5xx2DInit(); -#if !R300_PIO - Init3DEngine(&rhd); -#endif - retval = RegService("HDRAW", srv_2d); dbgprintf("reg service %s as: %x\n", "HDRAW", retval); @@ -148,13 +147,10 @@ int __stdcall srv_2d(ioctl_t *io) return BlitTransparent((io_blit_t*)inp); break; -#if !R300_PIO - case PX_BLIT_ALPHA: if(io->inp_size==9) return RadeonComposite((io_blit_t*)inp); break; -#endif default: return ERR_PARAM; @@ -168,18 +164,17 @@ int __stdcall srv_2d(ioctl_t *io) #include "pci.c" #include "ati_mem.c" -#include "init_cp.c" - #include "r500.inc" #include "clip.inc" #include "pixmap.inc" #include "accel_2d.inc" +#include "init_3d.inc" +#include "blend.inc" #if !R300_PIO -#include "init_3d.inc" -#include "blend.inc" +#include "init_cp.c" #endif diff --git a/programs/system/drivers/ati2d/rhd.lk1 b/drivers/video/ati2d/ati2d.lk similarity index 74% rename from programs/system/drivers/ati2d/rhd.lk1 rename to drivers/video/ati2d/ati2d.lk index f503be6031..c36b9ff8c8 100644 --- a/programs/system/drivers/ati2d/rhd.lk1 +++ b/drivers/video/ati2d/ati2d.lk @@ -3,18 +3,21 @@ IMP _KernelFree core.KernelFree, _UserAlloc core.UserAlloc, _UserFree core.UserFree, + _AllocPages core.AllocPages, _CommitPages core.CommitPages, _UnmapPages core.UnmapPages, - _CreateObject core.CreateObject, - _DestroyObject core.DestroyObject, _MapIoMem core.MapIoMem, _GetPgAddr core.GetPgAddr, _CreateRingBuffer core.CreateRingBuffer, _PciApi core.PciApi, _PciRead8 core.PciRead8, + _PciRead16 core.PciRead16, _PciRead32 core.PciRead32, _PciWrite32 core.PciWrite32, _RegService core.RegService, + _WaitMutex core.WaitMutex, + _Delay core.Delay, + _ChangeTask core.ChangeTask, _SysMsgBoardStr core.SysMsgBoardStr diff --git a/programs/system/drivers/ati2d/ati_mem.c b/drivers/video/ati2d/ati_mem.c similarity index 100% rename from programs/system/drivers/ati2d/ati_mem.c rename to drivers/video/ati2d/ati_mem.c diff --git a/programs/system/drivers/ati2d/ati_pciids_gen.h b/drivers/video/ati2d/ati_pciids_gen.h similarity index 100% rename from programs/system/drivers/ati2d/ati_pciids_gen.h rename to drivers/video/ati2d/ati_pciids_gen.h diff --git a/programs/system/drivers/ati2d/atihw.h b/drivers/video/ati2d/atihw.h similarity index 74% rename from programs/system/drivers/ati2d/atihw.h rename to drivers/video/ati2d/atihw.h index 945486ef22..862fd84b44 100644 --- a/programs/system/drivers/ati2d/atihw.h +++ b/drivers/video/ati2d/atihw.h @@ -96,6 +96,21 @@ typedef enum { CARD_PCIE } RADEONCardType; +enum radeon_chip_flags { + RADEON_FAMILY_MASK = 0x0000ffffUL, + RADEON_FLAGS_MASK = 0xffff0000UL, + RADEON_IS_MOBILITY = 0x00010000UL, + RADEON_IS_IGP = 0x00020000UL, + RADEON_SINGLE_CRTC = 0x00040000UL, + RADEON_IS_AGP = 0x00080000UL, + RADEON_HAS_HIERZ = 0x00100000UL, + RADEON_IS_PCIE = 0x00200000UL, + RADEON_NEW_MEMMAP = 0x00400000UL, + RADEON_IS_PCI = 0x00800000UL, + RADEON_IS_IGPGART = 0x01000000UL, +}; + + /* * Errata workarounds */ @@ -135,13 +150,19 @@ typedef struct #define RADEON_PCIGART_TABLE_SIZE (32*1024) +#define RADEON_IDLE_RETRY 16 /* Fall out of idle loops after this count */ +#define RADEON_TIMEOUT 4000000 /* Fall out of wait loops after this count */ + + typedef struct RHDRec { - addr_t MMIOBase; - size_t MMIOMapSize; + addr_t MMIOBase; + size_t MMIOMapSize; - addr_t FbFreeStart; - addr_t FbFreeSize; + u32_t lock; + + addr_t FbFreeStart; + addr_t FbFreeSize; /* visible part of the framebuffer */ // unsigned int FbScanoutStart; @@ -149,21 +170,21 @@ typedef struct RHDRec // u32_t LinearAddr; /* Frame buffer physical address */ - addr_t fbLocation; /* Frame buffer physical address */ - u32_t mc_fb_location; - u32_t mc_agp_location; - u32_t mc_agp_location_hi; + addr_t fbLocation; /* Frame buffer physical address */ + u32_t mc_fb_location; + u32_t mc_agp_location; + u32_t mc_agp_location_hi; - size_t videoRam; + size_t videoRam; - u32_t MemCntl; - u32_t BusCntl; - unsigned long FbMapSize; /* Size of frame buffer, in bytes */ - unsigned long FbSecureSize; /* Size of secured fb area at end of + u32_t MemCntl; + u32_t BusCntl; + unsigned long FbMapSize; /* Size of frame buffer, in bytes */ + unsigned long FbSecureSize; /* Size of secured fb area at end of framebuffer */ - RADEONChipFamily ChipFamily; - RADEONErrata ChipErrata; + RADEONChipFamily ChipFamily; + RADEONErrata ChipErrata; char *chipset; @@ -171,75 +192,95 @@ typedef struct RHDRec Bool IsMobility; Bool HasCRTC2; - u32_t bus; - u32_t devfn; + u32_t bus; + u32_t devfn; - PCITAG PciTag; - u16_t PciDeviceID; + PCITAG PciTag; + u16_t PciDeviceID; - u16_t subvendor_id; - u16_t subdevice_id; + u16_t subvendor_id; + u16_t subdevice_id; - RADEONCardType cardType; /* Current card is a PCI card */ + RADEONCardType cardType; /* Current card is a PCI card */ - u32_t memBase[6]; - u32_t ioBase[6]; - u32_t memtype[6]; - u32_t memsize[6]; + u32_t memBase[6]; + u32_t ioBase[6]; + u32_t memtype[6]; + u32_t memsize[6]; struct mem_block *fb_heap; struct mem_block *gart_heap; - u32_t displayWidth; - u32_t displayHeight; + u32_t displayWidth; + u32_t displayHeight; - u32_t *gart_table; - addr_t gart_table_dma; - addr_t gart_vm_start; - size_t gart_size; + u32_t gart_type; + u32_t *gart_table; + addr_t gart_table_dma; + addr_t gart_vm_start; + size_t gart_size; - u32_t* ringBase; - u32_t ring_rp; - u32_t ring_wp; - u32_t ringSize; - u32_t ring_avail; + u32_t* ringBase; + u32_t ring_rp; + u32_t ring_wp; + u32_t ringSize; + u32_t ring_avail; - u32_t bufSize; - u32_t pciAperSize; - u32_t CPusecTimeout; + u32_t bufSize; + u32_t pciAperSize; + u32_t CPusecTimeout; - int __xmin; - int __ymin; - int __xmax; - int __ymax; + int __xmin; + int __ymin; + int __xmax; + int __ymax; - u32_t gui_control; - u32_t dst_pitch_offset; - u32_t surface_cntl; + u32_t gui_control; + u32_t dst_pitch_offset; + u32_t surface_cntl; - volatile u32_t host_rp __attribute__ ((aligned (128))); + volatile u32_t host_rp __attribute__ ((aligned (128))); - volatile u32_t scratch0 __attribute__ ((aligned (128))); - volatile u32_t scratch1; - volatile u32_t scratch2; - volatile u32_t scratch3; - volatile u32_t scratch4; - volatile u32_t scratch5; - volatile u32_t scratch6; - volatile u32_t scratch7; + volatile u32_t scratch0 __attribute__ ((aligned (128))); + volatile u32_t scratch1; + volatile u32_t scratch2; + volatile u32_t scratch3; + volatile u32_t scratch4; + volatile u32_t scratch5; + volatile u32_t scratch6; + volatile u32_t scratch7; - int RamWidth __attribute__ ((aligned (128))); - Bool IsDDR; + int RamWidth __attribute__ ((aligned (128))); + Bool IsDDR; - int num_gb_pipes; - int has_tcl; + int num_gb_pipes; + int has_tcl; }RHD_t, *RHDPtr; extern RHD_t rhd; +#define RADEON_CP_PACKET0 0x00000000 +#define RADEON_CP_PACKET1 0x40000000 +#define RADEON_CP_PACKET2 0x80000000 +#define RADEON_CP_PACKET3 0xC0000000 +# define RADEON_CNTL_PAINT 0x00009100 +# define RADEON_CNTL_BITBLT 0x00009200 +# define RADEON_CNTL_TRANBLT 0x00009C00 + +# define RADEON_CNTL_PAINT_POLYLINE 0x00009500 +# define RADEON_CNTL_PAINT_MULTI 0x00009A00 + +#if R300_PIO + +#define BEGIN_ACCEL(n) FIFOWait(n) +#define FINISH_ACCEL() +#define COMMIT_RING() +#define OUT_ACCEL_REG(reg, val) OUTREG(reg, val) + +#else #define CP_PACKET0(reg, n) \ (RADEON_CP_PACKET0 | ((n - 1 ) << 16) | ((reg) >> 2)) @@ -263,12 +304,12 @@ extern RHD_t rhd; avail = rhd.ring_rp-rhd.ring_wp; \ if (avail <= 0) avail+= 0x4000; \ if( (req)+128 > avail){ \ - safe_sti(ifl); \ + unlock_device(); \ return 0; \ }; \ } \ ring = &rhd.ringBase[rhd.ring_wp]; \ -}while(0); +}while(0) #define ADVANCE_RING() @@ -298,6 +339,7 @@ do { \ #define OUT_ACCEL_REG(reg, val) CP_REG((reg), (val)) +#endif typedef struct { int token; /* id of the token */ @@ -305,6 +347,17 @@ typedef struct { } SymTabRec, *SymTabPtr; +extern inline void lock_device() +{ + __asm__ __volatile__ ( + "call *__imp__WaitMutex" + ::"b" (&rhd.lock)); +}; + +extern inline void unlock_device() +{ + rhd.lock = 0; +} extern inline void OUTREG8(u16_t offset, u8_t value) @@ -372,8 +425,6 @@ _RHDRegMask(RHDPtr rhdPtr, u16_t offset, u32_t value, u32_t mask) #define RHDRegMask(ptr, offset, value, mask) _RHDRegMask((ptr)->rhdPtr, (offset), (value), (mask)) - - #define RHDFUNC(ptr) #define DBG(x) x @@ -408,7 +459,6 @@ void __stdcall r500_SetCursor(cursor_t *cursor, int x, int y); void __stdcall r500_CursorRestore(int x, int y); - typedef struct { u32_t x ; u32_t y ; @@ -502,6 +552,10 @@ void dump_mem(); RHDPtr FindPciDevice(); +static __inline__ int drm_device_is_pcie(PCITAG pciTag); +static void init_pipes(RHDPtr info); +Bool init_cp(RHDPtr info); + Bool RHDPreInit(); void R5xx2DInit(); diff --git a/programs/system/drivers/ati2d/blend.inc b/drivers/video/ati2d/blend.inc similarity index 64% rename from programs/system/drivers/ati2d/blend.inc rename to drivers/video/ati2d/blend.inc index 24b993ca1c..08ae164305 100644 --- a/programs/system/drivers/ati2d/blend.inc +++ b/drivers/video/ati2d/blend.inc @@ -34,69 +34,11 @@ static struct blendinfo RadeonBlendOp[] = { {0, 0, RADEON_SRC_BLEND_GL_ONE | RADEON_DST_BLEND_GL_ONE}, }; -static Bool R200PrepareComposite(local_pixmap_t *dstpix, int dstX, int dstY, - local_pixmap_t *srcpix, int srcX, int srcY, - int w, int h, int alpha) -{ - u32_t tex_size = 0, txformat, blend_cntl; - int dst_pitch; - - if ((w > 2048) || (h > 2048)) - return FALSE; - - txformat = RADEON_TXFORMAT_ARGB8888 | - RADEON_TXFORMAT_ALPHA_IN_MAP | - RADEON_TXFORMAT_NON_POWER2; - - blend_cntl = RADEON_SRC_BLEND_GL_SRC_ALPHA | - RADEON_DST_BLEND_GL_ONE_MINUS_SRC_ALPHA; - - tex_size = ((h - 1) << 16) | (w - 1); - { - u32_t *ring; - u32_t ifl = safe_cli(); - - BEGIN_ACCEL(168); - OUT_ACCEL_REG(R200_PP_TXFORMAT_0, txformat); - OUT_ACCEL_REG(R200_PP_TXFORMAT_X_0, 0); - OUT_ACCEL_REG(R200_PP_TXSIZE_0, tex_size); - OUT_ACCEL_REG(R200_PP_TXPITCH_0, srcpix->pitch - 32); - OUT_ACCEL_REG(R200_PP_TXOFFSET_0, (u32_t)srcpix->local); - OUT_ACCEL_REG(R200_PP_TXFILTER_0, R200_MAG_FILTER_NEAREST | - R200_MIN_FILTER_NEAREST | - R200_CLAMP_S_WRAP | - R200_CLAMP_T_WRAP); - - OUT_ACCEL_REG(RADEON_RB3D_CNTL, RADEON_COLOR_FORMAT_ARGB8888 | - RADEON_ALPHA_BLEND_ENABLE); - OUT_ACCEL_REG(RADEON_PP_CNTL, RADEON_TEX_0_ENABLE | - RADEON_TEX_BLEND_0_ENABLE); - OUT_ACCEL_REG(R200_PP_TFACTOR_0, alpha << 24); - OUT_ACCEL_REG(R200_PP_TXCBLEND_0, R200_TXC_ARG_A_TFACTOR_COLOR | - R200_TXC_ARG_B_R0_ALPHA); - OUT_ACCEL_REG(R200_PP_TXCBLEND2_0,R200_TXC_OUTPUT_REG_R0); - OUT_ACCEL_REG(R200_PP_TXABLEND_0, R200_TXA_ARG_A_TFACTOR_ALPHA | - R200_TXA_ARG_B_R0_ALPHA); - OUT_ACCEL_REG(R200_PP_TXABLEND2_0, R200_TXA_OUTPUT_REG_R0); - OUT_ACCEL_REG(R200_SE_VTX_FMT_0, 0); - OUT_ACCEL_REG(R200_SE_VTX_FMT_1, (2 << R200_VTX_TEX0_COMP_CNT_SHIFT)); - OUT_ACCEL_REG(RADEON_RB3D_BLENDCNTL, blend_cntl); - - OUT_ACCEL_REG(RADEON_RB3D_COLORPITCH, dstpix->pitch >> 2); - OUT_ACCEL_REG(RADEON_RB3D_COLOROFFSET, (u32_t)dstpix->local); - - COMMIT_RING(); - safe_sti(ifl); - }; - - return TRUE; -} static Bool R300TextureSetup(RHDPtr info,local_pixmap_t *srcpix, int w, int h, int unit) { u32_t txfilter, txformat0, txformat1, txoffset, txpitch; - // int w = pPict->pDrawable->width; - // int h = pPict->pDrawable->height; + int i, pixel_shift; @@ -113,27 +55,16 @@ static Bool R300TextureSetup(RHDPtr info,local_pixmap_t *srcpix, int w, int h, i txpitch >>= pixel_shift; txpitch -= 1; - // if (RADEONPixmapIsColortiled(pPix)) - // txoffset |= R300_MACRO_TILE; - - // for (i = 0; i < sizeof(R300TexFormats) / sizeof(R300TexFormats[0]); i++) - // { - // if (R300TexFormats[i].fmt == pPict->format) - // break; - // } - - //txformat1 = R300TexFormats[i].card_fmt; - txformat1 = R300_TX_FORMAT_A8R8G8B8; txformat0 = ((((w - 1) & 0x7ff) << R300_TXWIDTH_SHIFT) | (((h - 1) & 0x7ff) << R300_TXHEIGHT_SHIFT)); if (IS_R500_3D && ((w - 1) & 0x800)) - txpitch |= R500_TXWIDTH_11; + txpitch |= R500_TXWIDTH_11; if (IS_R500_3D && ((h - 1) & 0x800)) - txpitch |= R500_TXHEIGHT_11; + txpitch |= R500_TXHEIGHT_11; /* Use TXPITCH instead of TXWIDTH for address computations: we could * omit this if there is no padding, but there is no apparent advantage @@ -141,35 +72,17 @@ static Bool R300TextureSetup(RHDPtr info,local_pixmap_t *srcpix, int w, int h, i */ txformat0 |= R300_TXPITCH_EN; - // info->texW[unit] = w; - // info->texH[unit] = h; + txfilter = R300_TX_CLAMP_S(R300_TX_CLAMP_CLAMP_GL); - // if (pPict->repeat && !(unit == 0 && need_src_tile_x)) - // txfilter = R300_TX_CLAMP_S(R300_TX_CLAMP_WRAP); - // else - txfilter = R300_TX_CLAMP_S(R300_TX_CLAMP_CLAMP_GL); - - // if (pPict->repeat && !(unit == 0 && need_src_tile_y)) - // txfilter |= R300_TX_CLAMP_T(R300_TX_CLAMP_WRAP); - // else - txfilter |= R300_TX_CLAMP_T(R300_TX_CLAMP_CLAMP_GL); + txfilter |= R300_TX_CLAMP_T(R300_TX_CLAMP_CLAMP_GL); txfilter |= (unit << R300_TX_ID_SHIFT); -// switch (pPict->filter) { -// case PictFilterNearest: txfilter |= (R300_TX_MAG_FILTER_NEAREST | R300_TX_MIN_FILTER_NEAREST); -// break; -// case PictFilterBilinear: -// txfilter |= (R300_TX_MAG_FILTER_LINEAR | R300_TX_MIN_FILTER_LINEAR); -// break; -// default: -// RADEON_FALLBACK(("Bad filter 0x%x\n", pPict->filter)); -// } + { u32_t *ring; - u32_t ifl = safe_cli(); BEGIN_ACCEL(7); @@ -183,14 +96,7 @@ static Bool R300TextureSetup(RHDPtr info,local_pixmap_t *srcpix, int w, int h, i OUT_ACCEL_REG(R300_TX_BORDER_COLOR_0 + (unit * 4), 0); COMMIT_RING(); - safe_sti(ifl); } -// if (pPict->transform != 0) { -// is_transform[unit] = TRUE; -// transform[unit] = pPict->transform; -// } else { -// is_transform[unit] = FALSE; -// } return TRUE; } @@ -199,20 +105,6 @@ static u32_t RADEONGetBlendCntl(int op, u32_t dst_format) { u32_t sblend, dblend; - // sblend = RadeonBlendOp[op].blend_cntl & RADEON_SRC_BLEND_MASK; - // dblend = RadeonBlendOp[op].blend_cntl & RADEON_DST_BLEND_MASK; - - /* If there's no dst alpha channel, adjust the blend op so that we'll treat - * it as always 1. - */ - // if ( RadeonBlendOp[op].dst_alpha) { - // if (sblend == RADEON_SRC_BLEND_GL_DST_ALPHA) - // sblend = RADEON_SRC_BLEND_GL_ONE; - // else if (sblend == RADEON_SRC_BLEND_GL_ONE_MINUS_DST_ALPHA) - // sblend = RADEON_SRC_BLEND_GL_ZERO; - // } - - //return sblend | dblend; return RADEON_SRC_BLEND_GL_SRC_ALPHA | RADEON_DST_BLEND_GL_ONE_MINUS_SRC_ALPHA; } @@ -222,15 +114,12 @@ Bool R300PrepareComposite(local_pixmap_t *dstpix, int dstX, int dstY, local_pixmap_t *srcpix, int srcX, int srcY, int w, int h, int op) { - // RINFO_FROM_SCREEN(pDst->drawable.pScreen); u32_t dst_format, dst_offset, dst_pitch; u32_t txenable, colorpitch; u32_t blendcntl; int pixel_shift; u32_t *ring; - u32_t ifl; - RHDPtr info = &rhd; dst_format = R300_COLORFORMAT_ARGB8888; @@ -243,9 +132,6 @@ Bool R300PrepareComposite(local_pixmap_t *dstpix, int dstX, int dstY, colorpitch = dst_pitch >> pixel_shift; - // if (RADEONPixmapIsColortiled(pDst)) - // colorpitch |= R300_COLORTILE; - colorpitch |= dst_format; if ((dst_offset & 0x0f) != 0) @@ -253,8 +139,6 @@ Bool R300PrepareComposite(local_pixmap_t *dstpix, int dstX, int dstY, if (((dst_pitch >> pixel_shift) & 0x7) != 0) dbgprintf("Bad destination pitch 0x%x\n", (int)dst_pitch); - // if (!RADEONSetupSourceTile(pSrcPicture, pSrc, TRUE, FALSE)) - // return FALSE; if (!R300TextureSetup(&rhd, srcpix, w, h, 0)) return FALSE; @@ -265,12 +149,7 @@ Bool R300PrepareComposite(local_pixmap_t *dstpix, int dstX, int dstY, /* setup the VAP */ - ifl = safe_cli(); - - BEGIN_RING(32*2); - - OUT_ACCEL_REG(RADEON_WAIT_UNTIL, RADEON_WAIT_HOST_IDLECLEAN | - RADEON_WAIT_3D_IDLECLEAN); + BEGIN_ACCEL(7); /* These registers define the number, type, and location of data submitted * to the PVS unit of GA input (when PVS is disabled) @@ -373,7 +252,7 @@ Bool R300PrepareComposite(local_pixmap_t *dstpix, int dstX, int dstY, R300_TEX_SIZE(0) | R300_RGBA_OUT)); - OUT_ACCEL_REG(R300_US_PIXSIZE, 1); /* highest temp used */ +// OUT_ACCEL_REG(R300_US_PIXSIZE, 1); /* highest temp used */ /* shader output swizzling */ OUT_ACCEL_REG(R300_US_OUT_FMT_0, output_fmt); @@ -445,18 +324,10 @@ Bool R300PrepareComposite(local_pixmap_t *dstpix, int dstX, int dstY, u32_t src_color, src_alpha; u32_t mask_color, mask_alpha; -// if (PICT_FORMAT_RGB(PICT_a8r8g8b8) == 0) -// src_color = (R500_ALU_RGB_R_SWIZ_A_0 | -// R500_ALU_RGB_G_SWIZ_A_0 | -// R500_ALU_RGB_B_SWIZ_A_0); -// else src_color = (R500_ALU_RGB_R_SWIZ_A_R | R500_ALU_RGB_G_SWIZ_A_G | R500_ALU_RGB_B_SWIZ_A_B); -// if (PICT_FORMAT_A(PICT_a8r8g8b8) == 0) -// src_alpha = R500_ALPHA_SWIZ_A_1; -// else src_alpha = R500_ALPHA_SWIZ_A_A; mask_color = (R500_ALU_RGB_R_SWIZ_B_1 | @@ -471,7 +342,7 @@ Bool R300PrepareComposite(local_pixmap_t *dstpix, int dstX, int dstY, R300_OUT_FMT_C2_SEL_RED | R300_OUT_FMT_C3_SEL_ALPHA); - BEGIN_ACCEL(6); + BEGIN_ACCEL(6); OUT_ACCEL_REG(R300_RS_COUNT, ((2 << R300_RS_COUNT_IT_COUNT_SHIFT) | R300_RS_COUNT_HIRES_EN)); @@ -484,7 +355,7 @@ Bool R300PrepareComposite(local_pixmap_t *dstpix, int dstX, int dstY, R500_US_CODE_RANGE_SIZE(1))); OUT_ACCEL_REG(R500_US_CODE_OFFSET, 0); - OUT_ACCEL_REG(R300_US_OUT_FMT_0, output_fmt); + OUT_ACCEL_REG(R300_US_OUT_FMT_0, output_fmt); COMMIT_RING(); BEGIN_ACCEL(13); @@ -527,7 +398,7 @@ Bool R300PrepareComposite(local_pixmap_t *dstpix, int dstX, int dstY, /* ALU inst */ /* *_OMASK* - output component write mask */ - OUT_ACCEL_REG(R500_GA_US_VECTOR_DATA, (R500_INST_TYPE_OUT | + OUT_ACCEL_REG(R500_GA_US_VECTOR_DATA, (R500_INST_TYPE_OUT | R500_INST_TEX_SEM_WAIT | R500_INST_LAST | R500_INST_RGB_OMASK_R | @@ -541,7 +412,7 @@ Bool R300PrepareComposite(local_pixmap_t *dstpix, int dstX, int dstY, * RGB_ADDR0 is src tex (temp 0) * RGB_ADDR1 is mask tex (temp 1) */ - OUT_ACCEL_REG(R500_GA_US_VECTOR_DATA, (R500_RGB_ADDR0(0) | + OUT_ACCEL_REG(R500_GA_US_VECTOR_DATA, (R500_RGB_ADDR0(0) | R500_RGB_ADDR1(1) | R500_RGB_ADDR2(0))); /* ALU inst @@ -549,19 +420,19 @@ Bool R300PrepareComposite(local_pixmap_t *dstpix, int dstX, int dstY, * ALPHA_ADDR0 is src tex (temp 0) * ALPHA_ADDR1 is mask tex (temp 1) */ - OUT_ACCEL_REG(R500_GA_US_VECTOR_DATA, (R500_ALPHA_ADDR0(0) | + OUT_ACCEL_REG(R500_GA_US_VECTOR_DATA, (R500_ALPHA_ADDR0(0) | R500_ALPHA_ADDR1(1) | R500_ALPHA_ADDR2(0))); /* R500_ALU_RGB_TARGET - RGB render target */ - OUT_ACCEL_REG(R500_GA_US_VECTOR_DATA, (R500_ALU_RGB_SEL_A_SRC0 | + OUT_ACCEL_REG(R500_GA_US_VECTOR_DATA, (R500_ALU_RGB_SEL_A_SRC0 | src_color | R500_ALU_RGB_SEL_B_SRC1 | mask_color | R500_ALU_RGB_TARGET(0))); /* R500_ALPHA_RGB_TARGET - alpha render target */ - OUT_ACCEL_REG(R500_GA_US_VECTOR_DATA, (R500_ALPHA_OP_MAD | + OUT_ACCEL_REG(R500_GA_US_VECTOR_DATA, (R500_ALPHA_OP_MAD | R500_ALPHA_ADDRD(0) | R500_ALPHA_SEL_A_SRC0 | src_alpha | @@ -569,7 +440,7 @@ Bool R300PrepareComposite(local_pixmap_t *dstpix, int dstX, int dstY, mask_alpha | R500_ALPHA_TARGET(0))); - OUT_ACCEL_REG(R500_GA_US_VECTOR_DATA, (R500_ALU_RGBA_OP_MAD | + OUT_ACCEL_REG(R500_GA_US_VECTOR_DATA, (R500_ALU_RGBA_OP_MAD | R500_ALU_RGBA_ADDRD(0) | R500_ALU_RGBA_R_SWIZ_0 | R500_ALU_RGBA_G_SWIZ_0 | @@ -588,8 +459,6 @@ Bool R300PrepareComposite(local_pixmap_t *dstpix, int dstX, int dstY, FINISH_ACCEL(); - safe_sti(ifl); - return TRUE; } @@ -599,13 +468,27 @@ Bool R300PrepareComposite(local_pixmap_t *dstpix, int dstX, int dstY, static __inline__ u32_t F_TO_DW(float val) { union { - float f; - u32_t l; - } tmp; + float f; + u32_t l; + }tmp; tmp.f = val; return tmp.l; } +#if R300_PIO + +#define OUT_ACCEL_REG_F(reg, val) OUTREG(reg, F_TO_DW(val)) + +#define VTX_OUT(_dstX, _dstY, _srcX, _srcY) \ +do { \ + OUT_ACCEL_REG_F(RADEON_SE_PORT_DATA0, _dstX); \ + OUT_ACCEL_REG_F(RADEON_SE_PORT_DATA0, _dstY); \ + OUT_ACCEL_REG_F(RADEON_SE_PORT_DATA0, _srcX); \ + OUT_ACCEL_REG_F(RADEON_SE_PORT_DATA0, _srcY); \ +} while (0) + +#else + #define OUT_RING_F(x) OUT_RING(F_TO_DW(x)) #define VTX_OUT(_dstX, _dstY, _srcX, _srcY) \ @@ -616,28 +499,20 @@ do { \ OUT_RING_F(_srcY); \ } while (0) - +#endif static int R300CompositeTile(int srcX, int srcY, int dstX, int dstY, int w, int h) { - // RINFO_FROM_SCREEN(pDst->drawable.pScreen); int vtx_count; xPointFixed srcTopLeft, srcTopRight, srcBottomLeft, srcBottomRight; xPointFixed maskTopLeft, maskTopRight, maskBottomLeft, maskBottomRight; + RHDPtr info = &rhd; + u32_t *ring; - u32_t ifl; - - // ACCEL_PREAMBLE(); - - // ENTER_DRAW(0); - - /* ErrorF("RadeonComposite (%d,%d) (%d,%d) (%d,%d) (%d,%d)\n", - srcX, srcY, maskX, maskY,dstX, dstY, w, h); */ - srcTopLeft.x = IntToxFixed(srcX); srcTopLeft.y = IntToxFixed(srcY); srcTopRight.x = IntToxFixed(srcX + w); @@ -647,35 +522,28 @@ static int R300CompositeTile(int srcX, int srcY, srcBottomRight.x = IntToxFixed(srcX + w); srcBottomRight.y = IntToxFixed(srcY + h); -/* - if (is_transform[0]) { - transformPoint(transform[0], &srcTopLeft); - transformPoint(transform[0], &srcTopRight); - transformPoint(transform[0], &srcBottomLeft); - transformPoint(transform[0], &srcBottomRight); - } - if (is_transform[1]) { - transformPoint(transform[1], &maskTopLeft); - transformPoint(transform[1], &maskTopRight); - transformPoint(transform[1], &maskBottomLeft); - transformPoint(transform[1], &maskBottomRight); - } -*/ vtx_count = VTX_COUNT; +#if R300_PIO - ifl = safe_cli(); + BEGIN_ACCEL(6 + vtx_count * 4); + OUT_ACCEL_REG(R300_VAP_VTX_SIZE, vtx_count); + OUT_ACCEL_REG(RADEON_SE_VF_CNTL, + (RADEON_VF_PRIM_TYPE_QUAD_LIST | + RADEON_VF_PRIM_WALK_DATA | + (4 << RADEON_VF_NUM_VERTICES_SHIFT))); - BEGIN_RING(7 + 4 * vtx_count); +#else + BEGIN_ACCEL(7 + 4 * vtx_count); + OUT_ACCEL_REG(R300_VAP_VTX_SIZE, vtx_count); - OUT_ACCEL_REG(R300_VAP_VTX_SIZE, vtx_count); - - OUT_RING(CP_PACKET3(R200_CP_PACKET3_3D_DRAW_IMMD_2, + OUT_RING(CP_PACKET3(R200_CP_PACKET3_3D_DRAW_IMMD_2, 4 * vtx_count)); - OUT_RING(RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_FAN | + OUT_RING(RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_FAN | RADEON_CP_VC_CNTL_PRIM_WALK_RING | (4 << RADEON_CP_VC_CNTL_NUM_SHIFT)); +#endif VTX_OUT((float)dstX, (float)dstY, xFixedToFloat(srcTopLeft.x) / w, // info->texW[0], @@ -695,68 +563,14 @@ static int R300CompositeTile(int srcX, int srcY, /* flushing is pipelined, free/finish is not */ OUT_ACCEL_REG(R300_RB3D_DSTCACHE_CTLSTAT, R300_DC_FLUSH_3D); - - // OUT_ACCEL_REG(RADEON_WAIT_UNTIL, RADEON_WAIT_3D_IDLECLEAN); + OUT_ACCEL_REG(R300_SC_CLIP_RULE, 0xAAAA); + OUT_ACCEL_REG(R300_RB3D_DSTCACHE_CTLSTAT, R300_RB3D_DC_FLUSH_ALL); + OUT_ACCEL_REG(RADEON_WAIT_UNTIL, RADEON_WAIT_3D_IDLECLEAN); COMMIT_RING(); - - safe_sti(ifl); - - // LEAVE_DRAW(0); } -static int R200CompositeTile(int srcX, int srcY, - int dstX, int dstY, - int w, int h) -{ - xPointFixed srcTopLeft, srcTopRight, srcBottomLeft, srcBottomRight; - xPointFixed maskTopLeft, maskTopRight, maskBottomLeft, maskBottomRight; - - srcTopLeft.x = IntToxFixed(srcX); - srcTopLeft.y = IntToxFixed(srcY); - srcTopRight.x = IntToxFixed(srcX + w); - srcTopRight.y = IntToxFixed(srcY); - srcBottomLeft.x = IntToxFixed(srcX); - srcBottomLeft.y = IntToxFixed(srcY + h); - srcBottomRight.x = IntToxFixed(srcX + w); - srcBottomRight.y = IntToxFixed(srcY + h); - - { - u32_t *ring; - u32_t ifl = safe_cli(); - - BEGIN_RING(4 + 4 * VTX_COUNT); - - OUT_RING(CP_PACKET3(R200_CP_PACKET3_3D_DRAW_IMMD_2, 4 * VTX_COUNT)); - OUT_RING(RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_FAN | - RADEON_CP_VC_CNTL_PRIM_WALK_RING | - (4 << RADEON_CP_VC_CNTL_NUM_SHIFT)); - - - VTX_OUT((float)dstX, (float)dstY, - xFixedToFloat(srcTopLeft.x) / w, // info->texW[0], - xFixedToFloat(srcTopLeft.y) / h); // info->texH[0]); - - VTX_OUT((float)dstX, (float)(dstY + h), - xFixedToFloat(srcBottomLeft.x) / w, // info->texW[0], - xFixedToFloat(srcBottomLeft.y) / h); // info->texH[0]); - - VTX_OUT((float)(dstX + w), (float)(dstY + h), - xFixedToFloat(srcBottomRight.x) / w, // info->texW[0], - xFixedToFloat(srcBottomRight.y) / h); // info->texH[0]); - - VTX_OUT((float)(dstX + w), (float)dstY, - xFixedToFloat(srcTopRight.x) / w, // info->texW[0], - xFixedToFloat(srcTopRight.y) / h); // info->texH[0]); - - OUT_ACCEL_REG(RADEON_WAIT_UNTIL, RADEON_WAIT_3D_IDLECLEAN); - - COMMIT_RING(); - safe_sti(ifl); - }; -}; - #undef VTX_OUT #undef VTX_OUT_MASK @@ -774,10 +588,39 @@ int RadeonComposite( io_blit_t *blit) dstpixmap = (blit->dstpix == (void*)-1) ? &scr_pixmap : blit->dstpix ; srcpixmap = (blit->srcpix == (void*)-1) ? &scr_pixmap : blit->srcpix ; + lock_device(); + { u32_t *ring; - u32_t ifl = safe_cli(); +#if R300_PIO + + FIFOWait(10); + + OUTREG(R5XX_DP_GUI_MASTER_CNTL, + RADEON_GMC_DST_PITCH_OFFSET_CNTL | + RADEON_GMC_BRUSH_SOLID_COLOR | + RADEON_GMC_DST_32BPP | + RADEON_GMC_SRC_DATATYPE_COLOR | + R5XX_GMC_CLR_CMP_CNTL_DIS | + R5XX_ROP3_P + ); + + OUTREG(R5XX_DST_PITCH_OFFSET, srcpixmap->pitch_offset); + OUTREG(R5XX_DP_BRUSH_FRGD_CLR, blit->alpha<<24); + OUTREG(R5XX_DP_WRITE_MASK, 0xFF000000); + OUTREG(R5XX_DP_CNTL, R5XX_DST_X_LEFT_TO_RIGHT | R5XX_DST_Y_TOP_TO_BOTTOM); + OUTREG(R5XX_DST_Y_X, 0); + OUTREG(R5XX_DST_WIDTH_HEIGHT,(srcpixmap->width<<16)|srcpixmap->height); + + OUTREG( RADEON_WAIT_UNTIL, RADEON_WAIT_2D_IDLECLEAN + | RADEON_WAIT_HOST_IDLECLEAN ); + + OUTREG(R5XX_DP_WRITE_MASK, 0xFFFFFFFF); + OUTREG(RADEON_WAIT_UNTIL, RADEON_WAIT_HOST_IDLECLEAN | + RADEON_WAIT_2D_IDLECLEAN); + +#else BEGIN_RING(2 + 6); CP_REG(R5XX_DP_WRITE_MASK, 0xFF000000); @@ -798,16 +641,18 @@ int RadeonComposite( io_blit_t *blit) OUT_RING((srcpixmap->width<<16)|srcpixmap->height); COMMIT_RING(); - +#endif RHDPtr info = &rhd; + FIFOWait(64); + delay(2); + if( IS_R300_3D || IS_R500_3D ) { R300PrepareComposite(dstpixmap, blit->dst_x, blit->dst_y, srcpixmap, blit->src_x, blit->src_y, blit->w, blit->h, 3); -// if (!need_src_tile_x && !need_src_tile_y) { R300CompositeTile( blit->src_x, blit->src_y, blit->dst_x, blit->dst_y, blit->w, blit->h); @@ -817,64 +662,16 @@ int RadeonComposite( io_blit_t *blit) (info->ChipFamily == CHIP_FAMILY_RS300) || (info->ChipFamily == CHIP_FAMILY_R200)) { - R200PrepareComposite(dstpixmap, blit->dst_x, blit->dst_y, - srcpixmap, blit->src_x, blit->src_y, - blit->w, blit->h, blit->alpha); - R200CompositeTile( blit->src_x, blit->src_y, - blit->dst_x, blit->dst_y, - blit->w, blit->h); }; - - safe_sti(ifl); }; + FIFOWait(64); + delay(2); + + unlock_device(); + + return 0; +}; - return 0; - // } - - /* Tiling logic borrowed from exaFillRegionTiled */ - -#if 0 - modulus(srcY, src_tile_height, tileSrcY); - tileMaskY = maskY; - tileDstY = dstY; - - remainingHeight = height; - while (remainingHeight > 0) { - int remainingWidth = width; - int tileSrcX, tileMaskX, tileDstX; - int h = src_tile_height - tileSrcY; - - if (h > remainingHeight) - h = remainingHeight; - remainingHeight -= h; - - modulus(srcX, src_tile_width, tileSrcX); - tileMaskX = maskX; - tileDstX = dstX; - - while (remainingWidth > 0) { - int w = src_tile_width - tileSrcX; - if (w > remainingWidth) - w = remainingWidth; - remainingWidth -= w; - - FUNC_NAME(RadeonCompositeTile)(pDst, - tileSrcX, tileSrcY, - tileMaskX, tileMaskY, - tileDstX, tileDstY, - w, h); - - tileSrcX = 0; - tileMaskX += w; - tileDstX += w; - } - tileSrcY = 0; - tileMaskY += h; - tileDstY += h; - } -#endif - -} diff --git a/programs/system/drivers/ati2d/clip.inc b/drivers/video/ati2d/clip.inc similarity index 100% rename from programs/system/drivers/ati2d/clip.inc rename to drivers/video/ati2d/clip.inc diff --git a/programs/system/drivers/ati2d/init.c b/drivers/video/ati2d/init.c similarity index 95% rename from programs/system/drivers/ati2d/init.c rename to drivers/video/ati2d/init.c index b993069842..7f064a66ad 100644 --- a/programs/system/drivers/ati2d/init.c +++ b/drivers/video/ati2d/init.c @@ -971,7 +971,6 @@ Bool RHDPreInit() return FALSE; }; - if( !RADEONPreInitChipType(&rhd)) return FALSE; @@ -987,6 +986,9 @@ Bool RHDPreInit() } dbgprintf("VideoRAM: %d kByte\n",rhd.videoRam); + /* setup the raster pipes */ + init_pipes(&rhd); + init_gart(&rhd); rhd.FbFreeSize = rhd.videoRam << 10; @@ -1225,23 +1227,27 @@ void init_gart(RHDPtr info) info->gart_vm_start = info->fbLocation + (info->videoRam << 10); -// info->gart_vm_start = info->fbLocation - info->gart_size; -// info->gart_table = (u32_t*)KernelAlloc( RADEON_PCIGART_TABLE_SIZE ); + if( info->gart_type == RADEON_IS_PCIE) + info->gart_table_dma = info->gart_vm_start + - RADEON_PCIGART_TABLE_SIZE; + else + info->gart_table_dma = AllocPages(RADEON_PCIGART_TABLE_SIZE >> 12); -// if ( ! info->gart_table) { -// dbgprintf("cannot allocate PCI GART page!\n"); -// return; -// } - -// info->gart_table_dma = GetPgAddr(info->gart_table); - - info->gart_table_dma = info->gart_vm_start - RADEON_PCIGART_TABLE_SIZE; + if ( ! info->gart_table_dma) { + dbgprintf("cannot allocate PCI GART page!\n"); + return; + } info->gart_table = (u32_t*)MapIoMem(info->gart_table_dma, RADEON_PCIGART_TABLE_SIZE, PG_SW | PG_NOCACHE); + if ( ! info->gart_table) { + dbgprintf("cannot map PCI GART page!\n"); + return; + } + pci_gart = info->gart_table; memset(pci_gart, 0, RADEON_PCIGART_TABLE_SIZE); @@ -1250,9 +1256,12 @@ void init_gart(RHDPtr info) "wbinvd" :::"memory"); - radeon_set_pciegart(info, 1); + if( info->gart_type == RADEON_IS_PCIE) + radeon_set_pciegart(info, 1); + else + radeon_set_pcigart(info, 1); - dbgprintf("gart size 0x%x\n", info->gart_size); + dbgprintf("gart size 0x%x\n", info->gart_size); dbgprintf("gart base 0x%x\n", info->gart_vm_start); dbgprintf("gart table 0x%x\n", info->gart_table); dbgprintf("gart table dma 0x%x\n", info->gart_table_dma); diff --git a/programs/system/drivers/ati2d/init_3d.inc b/drivers/video/ati2d/init_3d.inc similarity index 92% rename from programs/system/drivers/ati2d/init_3d.inc rename to drivers/video/ati2d/init_3d.inc index d10ca80462..7b671eefb6 100644 --- a/programs/system/drivers/ati2d/init_3d.inc +++ b/drivers/video/ati2d/init_3d.inc @@ -1,3 +1,30 @@ +/* + * Copyright 2000 ATI Technologies Inc., Markham, Ontario, and + * VA Linux Systems Inc., Fremont, California. + * + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation on the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NON-INFRINGEMENT. IN NO EVENT SHALL ATI, VA LINUX SYSTEMS AND/OR + * THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ int Init3DEngine(RHDPtr info) @@ -11,6 +38,9 @@ int Init3DEngine(RHDPtr info) ifl = safe_cli(); + FIFOWait(64); + delay(2); + if (IS_R300_3D || IS_R500_3D) { BEGIN_ACCEL(3); @@ -123,10 +153,9 @@ int Init3DEngine(RHDPtr info) vap_cntl |= (4 << R300_PVS_NUM_FPUS_SHIFT); if (info->has_tcl) - BEGIN_ACCEL(15) + BEGIN_ACCEL(15); else BEGIN_ACCEL(9); - OUT_ACCEL_REG(R300_VAP_VTX_STATE_CNTL, 0); OUT_ACCEL_REG(R300_VAP_PVS_STATE_FLUSH_REG, 0); @@ -467,44 +496,9 @@ int Init3DEngine(RHDPtr info) } FINISH_ACCEL(); - /* pre-load FS tex instructions */ - if (IS_R300_3D) { - BEGIN_ACCEL(2); - /* tex inst for src texture */ - OUT_ACCEL_REG(R300_US_TEX_INST_0, - (R300_TEX_SRC_ADDR(0) | - R300_TEX_DST_ADDR(0) | - R300_TEX_ID(0) | - R300_TEX_INST(R300_TEX_INST_LD))); - - /* tex inst for mask texture */ - OUT_ACCEL_REG(R300_US_TEX_INST_1, - (R300_TEX_SRC_ADDR(1) | - R300_TEX_DST_ADDR(1) | - R300_TEX_ID(1) | - R300_TEX_INST(R300_TEX_INST_LD))); - FINISH_ACCEL(); - } - - if (IS_R300_3D) { - BEGIN_ACCEL(8); - OUT_ACCEL_REG(R300_US_CONFIG, (0 << R300_NLEVEL_SHIFT) | R300_FIRST_TEX); - OUT_ACCEL_REG(R300_US_CODE_ADDR_0, - (R300_ALU_START(0) | - R300_ALU_SIZE(0) | - R300_TEX_START(0) | - R300_TEX_SIZE(0))); - OUT_ACCEL_REG(R300_US_CODE_ADDR_1, - (R300_ALU_START(0) | - R300_ALU_SIZE(0) | - R300_TEX_START(0) | - R300_TEX_SIZE(0))); - OUT_ACCEL_REG(R300_US_CODE_ADDR_2, - (R300_ALU_START(0) | - R300_ALU_SIZE(0) | - R300_TEX_START(0) | - R300_TEX_SIZE(0))); - } else { + if (IS_R300_3D) + BEGIN_ACCEL(4); + else { BEGIN_ACCEL(6); OUT_ACCEL_REG(R300_US_CONFIG, R500_ZERO_TIMES_ANYTHING_EQUALS_ZERO); OUT_ACCEL_REG(R500_US_FC_CTRL, 0); @@ -554,13 +548,8 @@ int Init3DEngine(RHDPtr info) OUT_ACCEL_REG(R300_RB3D_DSTCACHE_CTLSTAT, R300_DC_FLUSH_3D | R300_DC_FREE_3D); FINISH_ACCEL(); - BEGIN_ACCEL(7); + BEGIN_ACCEL(5); OUT_ACCEL_REG(R300_SC_EDGERULE, 0xA5294A5); - OUT_ACCEL_REG(R300_SC_SCISSOR0, ((0 << R300_SCISSOR_X_SHIFT) | - (0 << R300_SCISSOR_Y_SHIFT))); - OUT_ACCEL_REG(R300_SC_SCISSOR1, ((8191 << R300_SCISSOR_X_SHIFT) | - (8191 << R300_SCISSOR_Y_SHIFT))); - if (IS_R300_3D) { /* clip has offset 1440 */ OUT_ACCEL_REG(R300_SC_CLIP_0_A, ((1088 << R300_CLIP_X_SHIFT) | @@ -581,7 +570,7 @@ int Init3DEngine(RHDPtr info) (info->ChipFamily == CHIP_FAMILY_RS300) || (info->ChipFamily == CHIP_FAMILY_R200)) { - BEGIN_ACCEL(7); + BEGIN_ACCEL(6); if (info->ChipFamily == CHIP_FAMILY_RS300) { OUT_ACCEL_REG(R200_SE_VAP_CNTL_STATUS, RADEON_TCL_BYPASS); } else { @@ -590,7 +579,6 @@ int Init3DEngine(RHDPtr info) OUT_ACCEL_REG(R200_PP_CNTL_X, 0); OUT_ACCEL_REG(R200_PP_TXMULTI_CTL_0, 0); OUT_ACCEL_REG(R200_SE_VTX_STATE_CNTL, 0); - OUT_ACCEL_REG(R200_RE_CNTL, 0x0); OUT_ACCEL_REG(R200_SE_VTE_CNTL, 0); OUT_ACCEL_REG(R200_SE_VAP_CNTL, R200_VAP_FORCE_W_TO_ONE | R200_VAP_VF_MAX_VTX_NUM); @@ -615,7 +603,8 @@ int Init3DEngine(RHDPtr info) OUT_ACCEL_REG(RADEON_SE_CNTL_STATUS, 0); else OUT_ACCEL_REG(RADEON_SE_CNTL_STATUS, RADEON_TCL_BYPASS); - OUT_ACCEL_REG(RADEON_SE_COORD_FMT, RADEON_VTX_XY_PRE_MULT_1_OVER_W0 | + OUT_ACCEL_REG(RADEON_SE_COORD_FMT, + RADEON_VTX_XY_PRE_MULT_1_OVER_W0 | RADEON_VTX_ST0_NONPARAMETRIC | RADEON_VTX_ST1_NONPARAMETRIC | RADEON_TEX1_W_ROUTING_USE_W0); @@ -634,8 +623,9 @@ int Init3DEngine(RHDPtr info) RADEON_ROUND_PREC_4TH_PIX)); FINISH_ACCEL(); } - safe_sti(ifl); + FIFOWait(64); + delay(2); } diff --git a/programs/system/drivers/ati2d/init_cp.c b/drivers/video/ati2d/init_cp.c similarity index 81% rename from programs/system/drivers/ati2d/init_cp.c rename to drivers/video/ati2d/init_cp.c index ad6cecade7..bceb890f3f 100644 --- a/programs/system/drivers/ati2d/init_cp.c +++ b/drivers/video/ati2d/init_cp.c @@ -19,11 +19,6 @@ # define RADEON_ISYNC_CPSCRATCH_IDLEGUI (1 << 5) -#define RADEON_IDLE_RETRY 16 /* Fall out of idle loops after this count */ -#define RADEON_TIMEOUT 4000000 /* Fall out of wait loops after this count */ - - - void RADEONEngineFlush(RHDPtr info) { int i; @@ -56,17 +51,6 @@ void RADEONEngineFlush(RHDPtr info) } } -static Bool R5xxFIFOWaitLocal(u32_t required) //R100-R500 -{ - int i; - - for (i = 0; i < RADEON_TIMEOUT; i++) - if (required <= (INREG(RADEON_RBBM_STATUS) & RADEON_RBBM_FIFOCNT_MASK)) - return TRUE; - - dbgprintf("%s: Timeout 0x%08X.\n", __func__, (u32_t) INREG(RADEON_RBBM_STATUS)); - return FALSE; -} static int radeon_do_wait_for_idle() { @@ -244,55 +228,6 @@ void init_ring_buffer(RHDPtr info) } -void radeon_engine_reset(RHDPtr info) -{ - u32_t clock_cntl_index; - u32_t mclk_cntl; - u32_t rbbm_soft_reset; - u32_t host_path_cntl; - - if (info->ChipFamily <= CHIP_FAMILY_RV410) - { - /* may need something similar for newer chips */ - clock_cntl_index = INREG(RADEON_CLOCK_CNTL_INDEX); - mclk_cntl = INPLL( RADEON_MCLK_CNTL); - - OUTPLL(RADEON_MCLK_CNTL, (mclk_cntl | - RADEON_FORCEON_MCLKA | - RADEON_FORCEON_MCLKB | - RADEON_FORCEON_YCLKA | - RADEON_FORCEON_YCLKB | - RADEON_FORCEON_MC | - RADEON_FORCEON_AIC)); - } - - rbbm_soft_reset = INREG(RADEON_RBBM_SOFT_RESET); - - OUTREG(RADEON_RBBM_SOFT_RESET, (rbbm_soft_reset | - RADEON_SOFT_RESET_CP | - RADEON_SOFT_RESET_HI | - RADEON_SOFT_RESET_SE | - RADEON_SOFT_RESET_RE | - RADEON_SOFT_RESET_PP | - RADEON_SOFT_RESET_E2 | - RADEON_SOFT_RESET_RB)); - INREG(RADEON_RBBM_SOFT_RESET); - OUTREG(RADEON_RBBM_SOFT_RESET, (rbbm_soft_reset & - ~(RADEON_SOFT_RESET_CP | - RADEON_SOFT_RESET_HI | - RADEON_SOFT_RESET_SE | - RADEON_SOFT_RESET_RE | - RADEON_SOFT_RESET_PP | - RADEON_SOFT_RESET_E2 | - RADEON_SOFT_RESET_RB))); - INREG(RADEON_RBBM_SOFT_RESET); - - if (info->ChipFamily <= CHIP_FAMILY_RV410) { - OUTPLL(RADEON_MCLK_CNTL, mclk_cntl); - OUTREG(RADEON_CLOCK_CNTL_INDEX, clock_cntl_index); - OUTREG(RADEON_RBBM_SOFT_RESET, rbbm_soft_reset); - } - }; #define RADEON_WAIT_UNTIL_IDLE() do { \ OUT_RING( CP_PACKET0( RADEON_WAIT_UNTIL, 1 ) ); \ @@ -382,9 +317,6 @@ Bool init_cp(RHDPtr info) radeon_engine_reset(&rhd); - /* setup the raster pipes */ - init_pipes(&rhd); - rhd.ring_rp = rhd.ring_wp = INREG(RADEON_CP_RB_RPTR); OUTREG(RADEON_CP_RB_WPTR, rhd.ring_rp); diff --git a/programs/system/drivers/ati2d/makefile b/drivers/video/ati2d/makefile similarity index 81% rename from programs/system/drivers/ati2d/makefile rename to drivers/video/ati2d/makefile index 0664fbef4d..55179606c3 100644 --- a/programs/system/drivers/ati2d/makefile +++ b/drivers/video/ati2d/makefile @@ -4,12 +4,12 @@ FASM = e:/fasm/fasm.exe CFLAGS = -c -O2 -fomit-frame-pointer -fno-builtin-printf LDRHD = -shared -T ld.x -s --file-alignment 32 -INCLUDES = -I ../include +INCLUDES = -I ../../include -HFILES:= ../include/types.h \ - ../include/syscall.h \ +HFILES:= ../../include/types.h \ + ../../include/syscall.h \ + ../../include/pci.h \ atihw.h \ - pci.h \ accel_2d.h \ r5xx_regs.h \ radeon_microcode.h @@ -38,7 +38,7 @@ ATI2D = ati2d.dll all: $(ATI2D) $(ATI2D): $(ATI_OBJ) $(SRC_DEP) $(HFILES) Makefile - wlink name ati2d.dll SYS nt_dll lib libdrv op offset=0 op nod op maxe=25 op el op STUB=stub.exe op START=_drvEntry @rhd.lk1 + wlink name ati2d.dll SYS nt_dll lib libdrv op offset=0 op nod op maxe=25 op el op STUB=stub.exe op START=_drvEntry @ati2d.lk kpack.exe ati2d.dll ati2d.drv ati2d.obj : ati2d.c $(SRC_DEP) $(HFILES) Makefile diff --git a/programs/system/drivers/ati2d/pci.c b/drivers/video/ati2d/pci.c similarity index 73% rename from programs/system/drivers/ati2d/pci.c rename to drivers/video/ati2d/pci.c index db7391acc8..ec0aadd19a 100644 --- a/programs/system/drivers/ati2d/pci.c +++ b/drivers/video/ati2d/pci.c @@ -84,6 +84,10 @@ RHDPtr FindPciDevice() if (rhd.ChipFamily >= CHIP_FAMILY_R600) dbgprintf("R600 unsupported yet.\nExit\n"); + if( rhd.ChipFamily >= CHIP_FAMILY_R420) + rhd.gart_type = RADEON_IS_PCIE; + else + rhd.gart_type = RADEON_IS_PCI; for (i = 0; i < 6; i++) { @@ -210,3 +214,75 @@ u32_t pciGetBaseSize(int bus, int devfn, int index, Bool destructive, Bool *min) } + +#define PCI_FIND_CAP_TTL 48 + +static int __pci_find_next_cap_ttl(PCITAG pciTag, u8_t pos, + int cap, int *ttl) +{ + u8_t id; + + while ((*ttl)--) + { + pos = pciReadByte(pciTag, pos); + if (pos < 0x40) + break; + pos &= ~3; + id = pciReadByte(pciTag, pos + PCI_CAP_LIST_ID); + if (id == 0xff) + break; + if (id == cap) + return pos; + pos += PCI_CAP_LIST_NEXT; + } + return 0; +} + +static int __pci_find_next_cap(PCITAG pciTag, u8_t pos, int cap) +{ + int ttl = PCI_FIND_CAP_TTL; + + return __pci_find_next_cap_ttl(pciTag, pos, cap, &ttl); +} + +static int __pci_bus_find_cap_start(PCITAG pciTag) +{ + u16_t status; + u8_t hdr_type; + + status = pciReadWord(pciTag, PCI_STATUS); + if (!(status & PCI_STATUS_CAP_LIST)) + return 0; + + hdr_type = pciReadByte(pciTag, 0x0E); + switch (hdr_type) + { + case PCI_HEADER_TYPE_NORMAL: + case PCI_HEADER_TYPE_BRIDGE: + return PCI_CAPABILITY_LIST; + case PCI_HEADER_TYPE_CARDBUS: + return PCI_CB_CAPABILITY_LIST; + default: + return 0; + } + return 0; +} + + +int pci_find_capability(PCITAG pciTag, int cap) +{ + int pos; + + pos = __pci_bus_find_cap_start(pciTag); + if (pos) + pos = __pci_find_next_cap(pciTag, pos, cap); + + return pos; +} + + +static __inline__ int drm_device_is_pcie(PCITAG pciTag) +{ + return pci_find_capability(pciTag, PCI_CAP_ID_EXP); +} + diff --git a/programs/system/drivers/ati2d/pixmap.inc b/drivers/video/ati2d/pixmap.inc similarity index 82% rename from programs/system/drivers/ati2d/pixmap.inc rename to drivers/video/ati2d/pixmap.inc index 39e9d57f1a..a26321d665 100644 --- a/programs/system/drivers/ati2d/pixmap.inc +++ b/drivers/video/ati2d/pixmap.inc @@ -129,28 +129,12 @@ int DestroyPixmap( pixmap_t *io ) #define upper_32_bits(n) ((u32_t)(((n) >> 16) >> 16)) -static addr_t bind_pixmap(local_pixmap_t *pixmap) +static void bind_pcie(u32_t *gart, addr_t base, count_t pages) { - count_t pages; - addr_t base; - - u32_t tmp; - - u32_t *gart = rhd.gart_table; - - pages = ((pixmap->height * pixmap->pitch+4095)&~4095)>>12; - base = pixmap->local; - - // tmp = INREG(RADEON_AIC_CNTL); - // OUTREG(RADEON_AIC_CNTL, tmp & ~RADEON_PCIGART_TRANSLATE_EN); + addr_t page_base; while(pages--) { - addr_t page_base; - - // *gart = base & ATI_PCIGART_PAGE_MASK; - // base+= 4096; - // gart++; page_base = base & ATI_PCIGART_PAGE_MASK; page_base >>= 8; @@ -163,11 +147,40 @@ static addr_t bind_pixmap(local_pixmap_t *pixmap) } __asm__ __volatile("sfence":::"memory"); - // OUTREG(RADEON_AIC_CNTL, tmp | RADEON_PCIGART_TRANSLATE_EN); - // OUTREG(RADEON_AIC_PT_BASE, rhd.gart_table_dma); RADEON_WRITE_PCIE(RADEON_PCIE_TX_GART_CNTL, RADEON_PCIE_TX_GART_EN | RADEON_PCIE_TX_GART_INVALIDATE_TLB); +} + +static void bind_pci(u32_t *gart, addr_t base, count_t pages) +{ + u32_t tmp; + + tmp = INREG(RADEON_AIC_CNTL); + OUTREG(RADEON_AIC_CNTL, tmp & ~RADEON_PCIGART_TRANSLATE_EN); + + while(pages--) + { + *gart = base & ATI_PCIGART_PAGE_MASK; + base+= 4096; + gart++; + } + __asm__ __volatile("sfence":::"memory"); + + OUTREG(RADEON_AIC_CNTL, tmp | RADEON_PCIGART_TRANSLATE_EN); + OUTREG(RADEON_AIC_PT_BASE, rhd.gart_table_dma); +} + +static addr_t bind_pixmap(local_pixmap_t *pixmap) +{ + u32_t *gart = rhd.gart_table; + count_t pages = ((pixmap->height * pixmap->pitch+4095)&~4095)>>12; + addr_t base = pixmap->local; + + if( rhd.gart_type == RADEON_IS_PCIE) + bind_pcie(gart, base, pages); + else + bind_pci(gart, base, pages); return ((pixmap->pitch / 64) << 22) | (rhd.gart_vm_start >> 10); } diff --git a/programs/system/drivers/ati2d/r500.inc b/drivers/video/ati2d/r500.inc similarity index 68% rename from programs/system/drivers/ati2d/r500.inc rename to drivers/video/ati2d/r500.inc index 9a3d16d28e..33464313d0 100644 --- a/programs/system/drivers/ati2d/r500.inc +++ b/drivers/video/ati2d/r500.inc @@ -23,7 +23,79 @@ # define R300_DISABLE_MC_MCLKA (1 << 21) # define R300_DISABLE_MC_MCLKB (1 << 21) +void radeon_engine_reset(RHDPtr info) +{ + u32_t clock_cntl_index; + u32_t mclk_cntl; + u32_t rbbm_soft_reset; + u32_t host_path_cntl; + if (info->ChipFamily <= CHIP_FAMILY_RV410) + { + /* may need something similar for newer chips */ + clock_cntl_index = INREG(RADEON_CLOCK_CNTL_INDEX); + mclk_cntl = INPLL( RADEON_MCLK_CNTL); + + OUTPLL(RADEON_MCLK_CNTL, (mclk_cntl | + RADEON_FORCEON_MCLKA | + RADEON_FORCEON_MCLKB | + RADEON_FORCEON_YCLKA | + RADEON_FORCEON_YCLKB | + RADEON_FORCEON_MC | + RADEON_FORCEON_AIC)); + } + + rbbm_soft_reset = INREG(RADEON_RBBM_SOFT_RESET); + + OUTREG(RADEON_RBBM_SOFT_RESET, (rbbm_soft_reset | + RADEON_SOFT_RESET_CP | + RADEON_SOFT_RESET_HI | + RADEON_SOFT_RESET_SE | + RADEON_SOFT_RESET_RE | + RADEON_SOFT_RESET_PP | + RADEON_SOFT_RESET_E2 | + RADEON_SOFT_RESET_RB)); + INREG(RADEON_RBBM_SOFT_RESET); + OUTREG(RADEON_RBBM_SOFT_RESET, (rbbm_soft_reset & + ~(RADEON_SOFT_RESET_CP | + RADEON_SOFT_RESET_HI | + RADEON_SOFT_RESET_SE | + RADEON_SOFT_RESET_RE | + RADEON_SOFT_RESET_PP | + RADEON_SOFT_RESET_E2 | + RADEON_SOFT_RESET_RB))); + INREG(RADEON_RBBM_SOFT_RESET); + + if (info->ChipFamily <= CHIP_FAMILY_RV410) { + OUTPLL(RADEON_MCLK_CNTL, mclk_cntl); + OUTREG(RADEON_CLOCK_CNTL_INDEX, clock_cntl_index); + OUTREG(RADEON_RBBM_SOFT_RESET, rbbm_soft_reset); + } + }; + +static Bool R5xxFIFOWaitLocal(u32_t required) //R100-R500 +{ + int i; + + for (i = 0; i < RADEON_TIMEOUT; i++) + if (required <= (INREG(RADEON_RBBM_STATUS) & RADEON_RBBM_FIFOCNT_MASK)) + return TRUE; + + dbgprintf("%s: Timeout 0x%08X.\n", __func__, (u32_t) INREG(RADEON_RBBM_STATUS)); + return FALSE; +} + +void FIFOWait(u32_t required) +{ + int i; + for (i = 0; i < 200; i++) + { + if (required <= (INREG(RADEON_RBBM_STATUS) & + RADEON_RBBM_FIFOCNT_MASK)) + return ; + delay(2); + }; +}; /* @@ -116,7 +188,7 @@ R5xx2DSetup() void R5xxFIFOWait(u32_t required) { if (!R5xxFIFOWaitLocal(required)) { - // R5xx2DReset(); + radeon_engine_reset(&rhd); R5xx2DSetup(); } } @@ -130,7 +202,6 @@ void R5xx2DIdle() } - void R5xx2DInit() { u32_t base; diff --git a/programs/system/drivers/ati2d/r5xx_2dregs.h b/drivers/video/ati2d/r5xx_2dregs.h similarity index 100% rename from programs/system/drivers/ati2d/r5xx_2dregs.h rename to drivers/video/ati2d/r5xx_2dregs.h diff --git a/programs/system/drivers/ati2d/r5xx_regs.h b/drivers/video/ati2d/r5xx_regs.h similarity index 100% rename from programs/system/drivers/ati2d/r5xx_regs.h rename to drivers/video/ati2d/r5xx_regs.h diff --git a/programs/system/drivers/ati2d/radeon_chipinfo_gen.h b/drivers/video/ati2d/radeon_chipinfo_gen.h similarity index 100% rename from programs/system/drivers/ati2d/radeon_chipinfo_gen.h rename to drivers/video/ati2d/radeon_chipinfo_gen.h diff --git a/programs/system/drivers/ati2d/radeon_chipset_gen.h b/drivers/video/ati2d/radeon_chipset_gen.h similarity index 100% rename from programs/system/drivers/ati2d/radeon_chipset_gen.h rename to drivers/video/ati2d/radeon_chipset_gen.h diff --git a/programs/system/drivers/ati2d/radeon_microcode.h b/drivers/video/ati2d/radeon_microcode.h similarity index 100% rename from programs/system/drivers/ati2d/radeon_microcode.h rename to drivers/video/ati2d/radeon_microcode.h diff --git a/programs/system/drivers/ati2d/radeon_reg.h b/drivers/video/ati2d/radeon_reg.h similarity index 100% rename from programs/system/drivers/ati2d/radeon_reg.h rename to drivers/video/ati2d/radeon_reg.h diff --git a/programs/system/drivers/ati2d/rhd_regs.h b/drivers/video/ati2d/rhd_regs.h similarity index 100% rename from programs/system/drivers/ati2d/rhd_regs.h rename to drivers/video/ati2d/rhd_regs.h diff --git a/programs/system/drivers/ati2d/vs_prog.inc b/drivers/video/ati2d/vs_prog.inc similarity index 100% rename from programs/system/drivers/ati2d/vs_prog.inc rename to drivers/video/ati2d/vs_prog.inc diff --git a/programs/system/drivers/rhd/AtomBios/CD_Operations.c b/drivers/video/radeonhd/AtomBios/CD_Operations.c similarity index 100% rename from programs/system/drivers/rhd/AtomBios/CD_Operations.c rename to drivers/video/radeonhd/AtomBios/CD_Operations.c diff --git a/programs/system/drivers/rhd/AtomBios/Decoder.c b/drivers/video/radeonhd/AtomBios/Decoder.c similarity index 100% rename from programs/system/drivers/rhd/AtomBios/Decoder.c rename to drivers/video/radeonhd/AtomBios/Decoder.c diff --git a/programs/system/drivers/rhd/AtomBios/hwserv_drv.c b/drivers/video/radeonhd/AtomBios/hwserv_drv.c similarity index 100% rename from programs/system/drivers/rhd/AtomBios/hwserv_drv.c rename to drivers/video/radeonhd/AtomBios/hwserv_drv.c diff --git a/programs/system/drivers/rhd/AtomBios/includes/CD_Common_Types.h b/drivers/video/radeonhd/AtomBios/includes/CD_Common_Types.h similarity index 100% rename from programs/system/drivers/rhd/AtomBios/includes/CD_Common_Types.h rename to drivers/video/radeonhd/AtomBios/includes/CD_Common_Types.h diff --git a/programs/system/drivers/rhd/AtomBios/includes/CD_Definitions.h b/drivers/video/radeonhd/AtomBios/includes/CD_Definitions.h similarity index 100% rename from programs/system/drivers/rhd/AtomBios/includes/CD_Definitions.h rename to drivers/video/radeonhd/AtomBios/includes/CD_Definitions.h diff --git a/programs/system/drivers/rhd/AtomBios/includes/CD_Opcodes.h b/drivers/video/radeonhd/AtomBios/includes/CD_Opcodes.h similarity index 100% rename from programs/system/drivers/rhd/AtomBios/includes/CD_Opcodes.h rename to drivers/video/radeonhd/AtomBios/includes/CD_Opcodes.h diff --git a/programs/system/drivers/rhd/AtomBios/includes/CD_Structs.h b/drivers/video/radeonhd/AtomBios/includes/CD_Structs.h similarity index 100% rename from programs/system/drivers/rhd/AtomBios/includes/CD_Structs.h rename to drivers/video/radeonhd/AtomBios/includes/CD_Structs.h diff --git a/programs/system/drivers/rhd/AtomBios/includes/CD_binding.h b/drivers/video/radeonhd/AtomBios/includes/CD_binding.h similarity index 100% rename from programs/system/drivers/rhd/AtomBios/includes/CD_binding.h rename to drivers/video/radeonhd/AtomBios/includes/CD_binding.h diff --git a/programs/system/drivers/rhd/AtomBios/includes/CD_hw_services.h b/drivers/video/radeonhd/AtomBios/includes/CD_hw_services.h similarity index 100% rename from programs/system/drivers/rhd/AtomBios/includes/CD_hw_services.h rename to drivers/video/radeonhd/AtomBios/includes/CD_hw_services.h diff --git a/programs/system/drivers/rhd/AtomBios/includes/Decoder.h b/drivers/video/radeonhd/AtomBios/includes/Decoder.h similarity index 100% rename from programs/system/drivers/rhd/AtomBios/includes/Decoder.h rename to drivers/video/radeonhd/AtomBios/includes/Decoder.h diff --git a/programs/system/drivers/rhd/AtomBios/includes/ObjectID.h b/drivers/video/radeonhd/AtomBios/includes/ObjectID.h similarity index 100% rename from programs/system/drivers/rhd/AtomBios/includes/ObjectID.h rename to drivers/video/radeonhd/AtomBios/includes/ObjectID.h diff --git a/programs/system/drivers/rhd/AtomBios/includes/atombios.h b/drivers/video/radeonhd/AtomBios/includes/atombios.h similarity index 100% rename from programs/system/drivers/rhd/AtomBios/includes/atombios.h rename to drivers/video/radeonhd/AtomBios/includes/atombios.h diff --git a/programs/system/drivers/rhd/AtomBios/includes/regsdef.h b/drivers/video/radeonhd/AtomBios/includes/regsdef.h similarity index 100% rename from programs/system/drivers/rhd/AtomBios/includes/regsdef.h rename to drivers/video/radeonhd/AtomBios/includes/regsdef.h diff --git a/programs/system/drivers/rhd/Xmd.h b/drivers/video/radeonhd/Xmd.h similarity index 99% rename from programs/system/drivers/rhd/Xmd.h rename to drivers/video/radeonhd/Xmd.h index 8c70de94ab..44687d70db 100644 --- a/programs/system/drivers/rhd/Xmd.h +++ b/drivers/video/radeonhd/Xmd.h @@ -160,6 +160,7 @@ typedef CARD8 BOOL; #define BOOL CARD8 #endif +typedef unsigned long long CARD64; /* * definitions for sign-extending bitfields on 64-bit architectures */ diff --git a/programs/system/drivers/rhd/common.h b/drivers/video/radeonhd/common.h similarity index 100% rename from programs/system/drivers/rhd/common.h rename to drivers/video/radeonhd/common.h diff --git a/programs/system/drivers/rhd/dbg.c b/drivers/video/radeonhd/dbg.c similarity index 100% rename from programs/system/drivers/rhd/dbg.c rename to drivers/video/radeonhd/dbg.c diff --git a/programs/system/drivers/rhd/edid.h b/drivers/video/radeonhd/edid.h similarity index 100% rename from programs/system/drivers/rhd/edid.h rename to drivers/video/radeonhd/edid.h diff --git a/programs/system/drivers/rhd/loc_incl.h b/drivers/video/radeonhd/loc_incl.h similarity index 100% rename from programs/system/drivers/rhd/loc_incl.h rename to drivers/video/radeonhd/loc_incl.h diff --git a/programs/system/drivers/rhd/makefile b/drivers/video/radeonhd/makefile similarity index 95% rename from programs/system/drivers/rhd/makefile rename to drivers/video/radeonhd/makefile index 69f2c0f403..61dd6f456f 100644 --- a/programs/system/drivers/rhd/makefile +++ b/drivers/video/radeonhd/makefile @@ -50,7 +50,7 @@ RHD_SRC:= rhd.c \ dbg.c \ pci.c -DBG_DEFINES = -DDBG_NONE +DBG_DEFINES = -DDBG_CALL ATOM_BIOS_PARSER_SRCS = rhd_atomwrapper.c \ AtomBios/CD_Operations.c \ diff --git a/programs/system/drivers/rhd/malloc.c b/drivers/video/radeonhd/malloc.c similarity index 100% rename from programs/system/drivers/rhd/malloc.c rename to drivers/video/radeonhd/malloc.c diff --git a/programs/system/drivers/rhd/memset.asm b/drivers/video/radeonhd/memset.asm similarity index 100% rename from programs/system/drivers/rhd/memset.asm rename to drivers/video/radeonhd/memset.asm diff --git a/programs/system/drivers/rhd/pci.c b/drivers/video/radeonhd/pci.c similarity index 100% rename from programs/system/drivers/rhd/pci.c rename to drivers/video/radeonhd/pci.c diff --git a/drivers/video/radeonhd/pci.h b/drivers/video/radeonhd/pci.h new file mode 100644 index 0000000000..459b97d2ee --- /dev/null +++ b/drivers/video/radeonhd/pci.h @@ -0,0 +1,196 @@ + + +typedef struct { + int vendor; + int devtype; + int devRev; + int subsysVendor; + int subsysCard; + int bus; + int devfn; +// int func; + int class; + int subclass; + int interface; + memType memBase[6]; + memType ioBase[6]; + int size[6]; + unsigned char type[6]; + memType biosBase; + int biosSize; +// pointer thisCard; + Bool validSize; +// Bool validate; +// CARD32 listed_class; +} pciVideoRec, *pciVideoPtr; + +#define PCI_CLASS_DISPLAY_VGA 0x0300 +/* + * Under PCI, each device has 256 bytes of configuration address space, + * of which the first 64 bytes are standardized as follows: + */ +#define PCI_VENDOR_ID 0x000 /* 16 bits */ +#define PCI_DEVICE_ID 0x002 /* 16 bits */ +#define PCI_COMMAND 0x004 /* 16 bits */ +#define PCI_COMMAND_IO 0x001 /* Enable response in I/O space */ +#define PCI_COMMAND_MEMORY 0x002 /* Enable response in Memory space */ +#define PCI_COMMAND_MASTER 0x004 /* Enable bus mastering */ +#define PCI_COMMAND_SPECIAL 0x008 /* Enable response to special cycles */ +#define PCI_COMMAND_INVALIDATE 0x010 /* Use memory write and invalidate */ +#define PCI_COMMAND_VGA_PALETTE 0x020 /* Enable palette snooping */ +#define PCI_COMMAND_PARITY 0x040 /* Enable parity checking */ +#define PCI_COMMAND_WAIT 0x080 /* Enable address/data stepping */ +#define PCI_COMMAND_SERR 0x100 /* Enable SERR */ +#define PCI_COMMAND_FAST_BACK 0x200 /* Enable back-to-back writes */ +#define PCI_COMMAND_INTX_DISABLE 0x400 /* INTx Emulation Disable */ + +#define PCI_STATUS 0x006 /* 16 bits */ +#define PCI_STATUS_CAP_LIST 0x010 /* Support Capability List */ +#define PCI_STATUS_66MHZ 0x020 /* Support 66 Mhz PCI 2.1 bus */ +#define PCI_STATUS_UDF 0x040 /* Support User Definable Features [obsolete] */ +#define PCI_STATUS_FAST_BACK 0x080 /* Accept fast-back to back */ +#define PCI_STATUS_PARITY 0x100 /* Detected parity error */ +#define PCI_STATUS_DEVSEL_MASK 0x600 /* DEVSEL timing */ +#define PCI_STATUS_DEVSEL_FAST 0x000 +#define PCI_STATUS_DEVSEL_MEDIUM 0x200 +#define PCI_STATUS_DEVSEL_SLOW 0x400 +#define PCI_STATUS_SIG_TARGET_ABORT 0x800 /* Set on target abort */ +#define PCI_STATUS_REC_TARGET_ABORT 0x1000 /* Master ack of " */ +#define PCI_STATUS_REC_MASTER_ABORT 0x2000 /* Set on master abort */ +#define PCI_STATUS_SIG_SYSTEM_ERROR 0x4000 /* Set when we drive SERR */ +#define PCI_STATUS_DETECTED_PARITY 0x8000 /* Set on parity error */ + +#define PCI_CLASS_REVISION 0x08 /* High 24 bits are class, low 8 revision */ +#define PCI_REVISION_ID 0x08 /* Revision ID */ +#define PCI_CLASS_PROG 0x09 /* Reg. Level Programming Interface */ +#define PCI_CLASS_DEVICE 0x0a /* Device class */ + +#define PCI_CACHE_LINE_SIZE 0x0c /* 8 bits */ +#define PCI_LATENCY_TIMER 0x0d /* 8 bits */ +#define PCI_HEADER_TYPE 0x0e /* 8 bits */ +#define PCI_HEADER_TYPE_NORMAL 0 +#define PCI_HEADER_TYPE_BRIDGE 1 +#define PCI_HEADER_TYPE_CARDBUS 2 + +#define PCI_BIST 0x0f /* 8 bits */ +#define PCI_BIST_CODE_MASK 0x0f /* Return result */ +#define PCI_BIST_START 0x40 /* 1 to start BIST, 2 secs or less */ +#define PCI_BIST_CAPABLE 0x80 /* 1 if BIST capable */ + +#define PCI_CAPABILITY_LIST 0x34 /* Offset of first capability list entry */ +#define PCI_CB_CAPABILITY_LIST 0x14 +/* Capability lists */ + +#define PCI_CAP_LIST_ID 0 /* Capability ID */ +#define PCI_CAP_ID_PM 0x01 /* Power Management */ +#define PCI_CAP_ID_AGP 0x02 /* Accelerated Graphics Port */ +#define PCI_CAP_ID_VPD 0x03 /* Vital Product Data */ +#define PCI_CAP_ID_SLOTID 0x04 /* Slot Identification */ +#define PCI_CAP_ID_MSI 0x05 /* Message Signalled Interrupts */ +#define PCI_CAP_ID_CHSWP 0x06 /* CompactPCI HotSwap */ +#define PCI_CAP_ID_PCIX 0x07 /* PCI-X */ +#define PCI_CAP_ID_HT 0x08 /* HyperTransport */ +#define PCI_CAP_ID_VNDR 0x09 /* Vendor specific capability */ +#define PCI_CAP_ID_SHPC 0x0C /* PCI Standard Hot-Plug Controller */ +#define PCI_CAP_ID_EXP 0x10 /* PCI Express */ +#define PCI_CAP_ID_MSIX 0x11 /* MSI-X */ +#define PCI_CAP_LIST_NEXT 1 /* Next capability in the list */ +#define PCI_CAP_FLAGS 2 /* Capability defined flags (16 bits) */ +#define PCI_CAP_SIZEOF 4 + + +/* AGP registers */ + +#define PCI_AGP_VERSION 2 /* BCD version number */ +#define PCI_AGP_RFU 3 /* Rest of capability flags */ +#define PCI_AGP_STATUS 4 /* Status register */ +#define PCI_AGP_STATUS_RQ_MASK 0xff000000 /* Maximum number of requests - 1 */ +#define PCI_AGP_STATUS_SBA 0x0200 /* Sideband addressing supported */ +#define PCI_AGP_STATUS_64BIT 0x0020 /* 64-bit addressing supported */ +#define PCI_AGP_STATUS_FW 0x0010 /* FW transfers supported */ +#define PCI_AGP_STATUS_RATE4 0x0004 /* 4x transfer rate supported */ +#define PCI_AGP_STATUS_RATE2 0x0002 /* 2x transfer rate supported */ +#define PCI_AGP_STATUS_RATE1 0x0001 /* 1x transfer rate supported */ +#define PCI_AGP_COMMAND 8 /* Control register */ +#define PCI_AGP_COMMAND_RQ_MASK 0xff000000 /* Master: Maximum number of requests */ +#define PCI_AGP_COMMAND_SBA 0x0200 /* Sideband addressing enabled */ +#define PCI_AGP_COMMAND_AGP 0x0100 /* Allow processing of AGP transactions */ +#define PCI_AGP_COMMAND_64BIT 0x0020 /* Allow processing of 64-bit addresses */ +#define PCI_AGP_COMMAND_FW 0x0010 /* Force FW transfers */ +#define PCI_AGP_COMMAND_RATE4 0x0004 /* Use 4x rate */ +#define PCI_AGP_COMMAND_RATE2 0x0002 /* Use 2x rate */ +#define PCI_AGP_COMMAND_RATE1 0x0001 /* Use 1x rate */ +#define PCI_AGP_SIZEOF 12 + + +#define PCI_MAP_REG_START 0x10 +#define PCI_MAP_REG_END 0x28 +#define PCI_MAP_ROM_REG 0x30 + +#define PCI_MAP_MEMORY 0x00000000 +#define PCI_MAP_IO 0x00000001 + +#define PCI_MAP_MEMORY_TYPE 0x00000007 +#define PCI_MAP_IO_TYPE 0x00000003 + +#define PCI_MAP_MEMORY_TYPE_32BIT 0x00000000 +#define PCI_MAP_MEMORY_TYPE_32BIT_1M 0x00000002 +#define PCI_MAP_MEMORY_TYPE_64BIT 0x00000004 +#define PCI_MAP_MEMORY_TYPE_MASK 0x00000006 +#define PCI_MAP_MEMORY_CACHABLE 0x00000008 +#define PCI_MAP_MEMORY_ATTR_MASK 0x0000000e +#define PCI_MAP_MEMORY_ADDRESS_MASK 0xfffffff0 + +#define PCI_MAP_IO_ATTR_MASK 0x00000003 + +#define PCI_MAP_IS_IO(b) ((b) & PCI_MAP_IO) +#define PCI_MAP_IS_MEM(b) (!PCI_MAP_IS_IO(b)) + +#define PCI_MAP_IS64BITMEM(b) \ + (((b) & PCI_MAP_MEMORY_TYPE_MASK) == PCI_MAP_MEMORY_TYPE_64BIT) + +#define PCIGETMEMORY(b) ((b) & PCI_MAP_MEMORY_ADDRESS_MASK) +#define PCIGETMEMORY64HIGH(b) (*((CARD32*)&b + 1)) +#define PCIGETMEMORY64(b) \ + (PCIGETMEMORY(b) | ((CARD64)PCIGETMEMORY64HIGH(b) << 32)) + +#define PCI_MAP_IO_ADDRESS_MASK 0xfffffffc + +#define PCIGETIO(b) ((b) & PCI_MAP_IO_ADDRESS_MASK) + +#define PCI_MAP_ROM_DECODE_ENABLE 0x00000001 +#define PCI_MAP_ROM_ADDRESS_MASK 0xfffff800 + +#define PCIGETROM(b) ((b) & PCI_MAP_ROM_ADDRESS_MASK) + +int pciGetBaseSize(int bus, int devfn, int index, Bool destructive, Bool *min); +int pciGetInfo(pciVideoPtr pci); + + + +#ifndef PCI_DOM_MASK +# define PCI_DOM_MASK 0x0ffu +#endif +#define PCI_DOMBUS_MASK (((PCI_DOM_MASK) << 8) | 0x0ffu) + +#define PCI_MAKE_TAG(b,d,f) ((((b) & (PCI_DOMBUS_MASK)) << 16) | \ + (((d) & 0x00001fu) << 11) | \ + (((f) & 0x000007u) << 8)) + +#define PCI_BUS_FROM_TAG(tag) (((tag) >> 16) & (PCI_DOMBUS_MASK)) +#define PCI_DEV_FROM_TAG(tag) (((tag) & 0x0000f800u) >> 11) +#define PCI_FUNC_FROM_TAG(tag) (((tag) & 0x00000700u) >> 8) +#define PCI_DFN_FROM_TAG(tag) (((tag) & 0x0000ff00u) >> 8) + + +#define PCI_CMD_STAT_REG 0x04 + + +typedef unsigned int PCITAG; + +extern inline PCITAG +pciTag(int busnum, int devnum, int funcnum) +{ + return(PCI_MAKE_TAG(busnum,devnum,funcnum)); +} + diff --git a/programs/system/drivers/ati2d/proc32.inc b/drivers/video/radeonhd/proc32.inc similarity index 100% rename from programs/system/drivers/ati2d/proc32.inc rename to drivers/video/radeonhd/proc32.inc diff --git a/programs/system/drivers/rhd/r5xx_accel.h b/drivers/video/radeonhd/r5xx_accel.h similarity index 100% rename from programs/system/drivers/rhd/r5xx_accel.h rename to drivers/video/radeonhd/r5xx_accel.h diff --git a/programs/system/drivers/rhd/radeon_reg.h b/drivers/video/radeonhd/radeon_reg.h similarity index 100% rename from programs/system/drivers/rhd/radeon_reg.h rename to drivers/video/radeonhd/radeon_reg.h diff --git a/programs/system/drivers/rhd/rhd.c b/drivers/video/radeonhd/rhd.c similarity index 59% rename from programs/system/drivers/rhd/rhd.c rename to drivers/video/radeonhd/rhd.c index 1a334349e2..8846185c24 100644 --- a/programs/system/drivers/rhd/rhd.c +++ b/drivers/video/radeonhd/rhd.c @@ -1,3 +1,27 @@ +/* + * Copyright 2007 Luc Verhaegen + * Copyright 2007 Matthias Hopf + * Copyright 2007 Egbert Eich + * Copyright 2007 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ //ld -T ld.x -s --shared --image-base 0 --file-alignment 32 -o test.exe test.obj core.lib @@ -8,8 +32,10 @@ #include "rhd_atombios.h" #include "rhd_regs.h" #include "rhd_mc.h" +#include "rhd_atombios.h" #include "rhd_connector.h" #include "rhd_output.h" +#include "rhd_biosscratch.h" #include "rhd_card.h" #include "rhd_vga.h" #include "rhd_crtc.h" @@ -28,12 +54,16 @@ static void rhdModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode); static void rhdSetMode(ScrnInfoPtr pScrn, DisplayModePtr mode); static void RHDAdjustFrame(RHDPtr rhdPtr, int x, int y, int flags); static Bool rhdMapFB(RHDPtr rhdPtr); +static void rhdGetIGPNorthBridgeInfo(RHDPtr rhdPtr); Bool OldSetupConnectors(RHDPtr rhdPtr); Bool OldConnectorsInit(RHDPtr rhdPtr); int rhdInitHeap(RHDPtr rhdPtr); +static enum rhdCardType rhdGetCardType(RHDPtr rhdPtr); + + static u32_t _PciApi(int cmd); static int SupportedModes; @@ -257,22 +287,22 @@ rhdOutputConnectorCheck(struct rhdConnector *Connector) /* First, try to sense */ for (i = 0; i < 2; i++) { - Output = Connector->Output[i]; - if (Output && Output->Sense) { + Output = Connector->Output[i]; + if (Output && Output->Sense) { /* * This is ugly and needs to change when the TV support patches are in. * The problem here is that the Output struct can be used for two connectors * and thus two different devices */ - if (Output->SensedType == RHD_SENSED_NONE) { - /* Do this before sensing as AtomBIOS sense needs this info */ - if ((Output->SensedType = Output->Sense(Output, Connector)) != RHD_SENSED_NONE) { - RHDOutputPrintSensedType(Output); - Output->Connector = Connector; - break; - } - } - } + if (Output->SensedType == RHD_SENSED_NONE) { + /* Do this before sensing as AtomBIOS sense needs this info */ + if ((Output->SensedType = Output->Sense(Output, Connector)) != RHD_SENSED_NONE) { + RHDOutputPrintSensedType(Output); + Output->Connector = Connector; + break; + } + } + } } if (i == 2) { @@ -287,6 +317,9 @@ rhdOutputConnectorCheck(struct rhdConnector *Connector) } } +/* + * + */ static Bool rhdModeLayoutSelect(RHDPtr rhdPtr) { @@ -323,7 +356,8 @@ rhdModeLayoutSelect(RHDPtr rhdPtr) { ConnectorIsDMS59 = rhdPtr->Card->flags & RHD_CARD_FLAG_DMS59; if (ConnectorIsDMS59) - dbgprintf("Card %s has a DMS-59 connector.\n", rhdPtr->Card->name); + xf86DrvMsg(rhdPtr->scrnIndex, X_INFO, "Card %s has a DMS-59" + " connector.\n", rhdPtr->Card->name); } /* Check on the basis of Connector->HPD */ @@ -334,42 +368,34 @@ rhdModeLayoutSelect(RHDPtr rhdPtr) if (!Connector) continue; - if (Connector->HPDCheck) - { - if (Connector->HPDCheck(Connector)) - { + + if (Connector->HPDCheck) { + if (Connector->HPDCheck(Connector)) { Connector->HPDAttached = TRUE; rhdOutputConnectorCheck(Connector); - } - else - { + } else { Connector->HPDAttached = FALSE; if (ConnectorIsDMS59) rhdOutputConnectorCheck(Connector); } - } - else + } else rhdOutputConnectorCheck(Connector); } i = 0; /* counter for CRTCs */ for (Output = rhdPtr->Outputs; Output; Output = Output->Next) - if (Output->Connector) - { + if (Output->Connector) { struct rhdMonitor *Monitor = NULL; Connector = Output->Connector; Monitor = RHDMonitorInit(Connector); - if (!Monitor && (Connector->Type == RHD_CONNECTOR_PANEL)) - { + if (!Monitor && (Connector->Type == RHD_CONNECTOR_PANEL)) { xf86DrvMsg(rhdPtr->scrnIndex, X_WARNING, "Unable to attach a" " monitor to connector \"%s\"\n", Connector->Name); Output->Active = FALSE; - } - else - { + } else if (!Output->AllocFree || Output->AllocFree(Output, RHD_OUTPUT_ALLOC)){ Connector->Monitor = Monitor; Output->Active = TRUE; @@ -379,8 +405,7 @@ rhdModeLayoutSelect(RHDPtr rhdPtr) Output->Crtc->Active = TRUE; - if (RHDScalePolicy(Monitor, Connector)) - { + if (RHDScalePolicy(Monitor, Connector)) { Output->Crtc->ScaledToMode = RHDModeCopy(Monitor->NativeMode); xf86DrvMsg(rhdPtr->scrnIndex, X_INFO, "Crtc[%i]: found native mode from Monitor[%s]: ", @@ -389,8 +414,7 @@ rhdModeLayoutSelect(RHDPtr rhdPtr) } Found = TRUE; - if (Monitor) - { + if (Monitor) { /* If this is a DVI attached monitor, enable reduced blanking. * TODO: iiyama vm pro 453: CRT with DVI-D == No reduced. */ @@ -409,8 +433,7 @@ rhdModeLayoutSelect(RHDPtr rhdPtr) "Connector \"%s\" uses Monitor \"%s\":\n", Connector->Name, Monitor->Name); RHDMonitorPrint(Monitor); - } - else + } else xf86DrvMsg(rhdPtr->scrnIndex, X_WARNING, "Connector \"%s\": Failed to retrieve Monitor" " information.\n", Connector->Name); @@ -418,296 +441,365 @@ rhdModeLayoutSelect(RHDPtr rhdPtr) } /* Now validate the scaled modes attached to crtcs */ - for (i = 0; i < 2; i++) - { + for (i = 0; i < 2; i++) { struct rhdCrtc *crtc = rhdPtr->Crtc[i]; - if (crtc->ScaledToMode && RHDValidateScaledToMode(crtc, crtc->ScaledToMode) != MODE_OK) - { + if (crtc->ScaledToMode && RHDValidateScaledToMode(crtc, crtc->ScaledToMode) != MODE_OK) { xf86DrvMsg(rhdPtr->scrnIndex, X_ERROR, "Crtc[%i]: scaled mode invalid.\n", crtc->Id); xfree(crtc->ScaledToMode); crtc->ScaledToMode = NULL; } - }; + } return Found; } -void rhdModeLayoutPrint(RHDPtr rhdPtr) + /* + * + */ +static void +rhdModeLayoutPrint(RHDPtr rhdPtr) { - struct rhdCrtc *Crtc; - struct rhdOutput *Output; - Bool Found; + struct rhdCrtc *Crtc; + struct rhdOutput *Output; + Bool Found; - xf86DrvMsg(rhdPtr->scrnIndex, X_INFO, "Listing modesetting layout:\n\n"); + xf86DrvMsg(rhdPtr->scrnIndex, X_INFO, "Listing modesetting layout:\n\n"); /* CRTC 1 */ - Crtc = rhdPtr->Crtc[0]; + Crtc = rhdPtr->Crtc[0]; if (Crtc->Active) { xf86Msg(X_NONE, "\t%s: tied to %s and %s:\n", - Crtc->Name, Crtc->PLL->Name, Crtc->LUT->Name); + Crtc->Name, Crtc->PLL->Name, Crtc->LUT->Name); - Found = FALSE; - for (Output = rhdPtr->Outputs; Output; Output = Output->Next) + Found = FALSE; + for (Output = rhdPtr->Outputs; Output; Output = Output->Next) if (Output->Active && (Output->Crtc == Crtc)) { if (!Found) { - xf86Msg(X_NONE, "\t\tOutputs: %s (%s)", - Output->Name, Output->Connector->Name); - Found = TRUE; - } else - xf86Msg(X_NONE, ", %s (%s)", Output->Name, - Output->Connector->Name); - } + xf86Msg(X_NONE, "\t\tOutputs: %s (%s)", + Output->Name, Output->Connector->Name); + Found = TRUE; + } else + xf86Msg(X_NONE, ", %s (%s)", Output->Name, + Output->Connector->Name); + } - if (!Found) + if (!Found) xf86DrvMsg(rhdPtr->scrnIndex, X_ERROR, "%s is active without outputs\n", Crtc->Name); - else + else xf86Msg(X_NONE, "\n"); } else xf86Msg(X_NONE, "\t%s: unused\n", Crtc->Name); xf86Msg(X_NONE, "\n"); /* CRTC 2 */ - Crtc = rhdPtr->Crtc[1]; + Crtc = rhdPtr->Crtc[1]; if (Crtc->Active) { xf86Msg(X_NONE, "\t%s: tied to %s and %s:\n", - Crtc->Name, Crtc->PLL->Name, Crtc->LUT->Name); + Crtc->Name, Crtc->PLL->Name, Crtc->LUT->Name); - Found = FALSE; - for (Output = rhdPtr->Outputs; Output; Output = Output->Next) + Found = FALSE; + for (Output = rhdPtr->Outputs; Output; Output = Output->Next) if (Output->Active && (Output->Crtc == Crtc)) { if (!Found) { xf86Msg(X_NONE, "\t\tOutputs: %s (%s)", Output->Name, Output->Connector->Name); - Found = TRUE; + Found = TRUE; } else xf86Msg(X_NONE, ", %s (%s)", Output->Name, Output->Connector->Name); - } + } - if (!Found) + if (!Found) xf86DrvMsg(rhdPtr->scrnIndex, X_ERROR, "%s is active without outputs\n", Crtc->Name); - else + else xf86Msg(X_NONE, "\n"); } else xf86Msg(X_NONE, "\t%s: unused\n", Crtc->Name); xf86Msg(X_NONE, "\n"); /* Print out unused Outputs */ - Found = FALSE; - for (Output = rhdPtr->Outputs; Output; Output = Output->Next) + Found = FALSE; + for (Output = rhdPtr->Outputs; Output; Output = Output->Next) if (!Output->Active) { if (!Found) { xf86Msg(X_NONE, "\t\tUnused Outputs: %s", Output->Name); - Found = TRUE; + Found = TRUE; } else xf86Msg(X_NONE, ", %s", Output->Name); - } + } - if (Found) + if (Found) xf86Msg(X_NONE, "\n"); xf86Msg(X_NONE, "\n"); } + DisplayModePtr rhdCreateModesListAndValidate(ScrnInfoPtr pScrn, Bool Silent); void RHDPrintModeline(DisplayModePtr mode); int RHDPreInit() { - RHDI2CDataArg i2cArg; - - if (rhd.Card && rhd.Card->flags & RHD_CARD_FLAG_HPDSWAP && - rhd.hpdUsage == RHD_HPD_USAGE_AUTO) - rhd.hpdUsage = RHD_HPD_USAGE_AUTO_SWAP; - if (rhd.Card && rhd.Card->flags & RHD_CARD_FLAG_HPDOFF && - rhd.hpdUsage == RHD_HPD_USAGE_AUTO) - rhd.hpdUsage = RHD_HPD_USAGE_AUTO_OFF; + RHDI2CDataArg i2cArg; + RHDPtr rhdPtr = &rhd; /* We need access to IO space already */ - if (!rhdMapMMIO()) { - dbgprintf("Failed to map MMIO.\n"); - return 0; - }; + if (!rhdMapMMIO()) { + dbgprintf("Failed to map MMIO.\n"); + return 0; + }; - rhd.videoRam = rhdGetVideoRamSize(&rhd); - if (!rhd.videoRam) - { - dbgprintf("No Video RAM detected.\n"); - goto error1; - } - dbgprintf("VideoRAM: %d kByte\n",rhd.videoRam); - rhd.FbFreeStart = 0; - rhd.FbFreeSize = rhd.videoRam << 10; + if (RHDIsIGP(rhd.ChipSet)) + rhdGetIGPNorthBridgeInfo(&rhd); -#ifdef ATOM_BIOS - { - AtomBiosArgRec atomBiosArg; + rhd.Card = RHDCardIdentify(&rhd); + if (rhd.Card) + dbgprintf("Detected an %s on a %s\n", rhd.chipset_name, rhd.Card->name); + else + dbgprintf("Detected an %s on an unidentified card\n", rhd.chipset_name); - rhd.UseAtomFlags = (RHD_ATOMBIOS_ON << RHD_ATOMBIOS_CRTC) | - (RHD_ATOMBIOS_ON << RHD_ATOMBIOS_OUTPUT) | - (RHD_ATOMBIOS_ON << RHD_ATOMBIOS_PLL); + if (rhdPtr->Card && rhdPtr->Card->flags & RHD_CARD_FLAG_HPDSWAP && + rhdPtr->hpdUsage == RHD_HPD_USAGE_AUTO) + rhdPtr->hpdUsage = RHD_HPD_USAGE_AUTO_SWAP; + if (rhdPtr->Card && rhdPtr->Card->flags & RHD_CARD_FLAG_HPDOFF && + rhdPtr->hpdUsage == RHD_HPD_USAGE_AUTO) + rhdPtr->hpdUsage = RHD_HPD_USAGE_AUTO_OFF; + + rhdPtr->cardType = rhdGetCardType(rhdPtr); + + + { + AtomBiosArgRec atomBiosArg; + + rhd.UseAtomFlags = (RHD_ATOMBIOS_ON << RHD_ATOMBIOS_CRTC) | + (RHD_ATOMBIOS_ON << RHD_ATOMBIOS_OUTPUT) | + (RHD_ATOMBIOS_ON << RHD_ATOMBIOS_PLL); // rhd.UseAtomFlags = 0; - if (RHDAtomBiosFunc(&rhd, NULL, ATOMBIOS_INIT, &atomBiosArg) - == ATOM_SUCCESS) - { - rhd.atomBIOS = atomBiosArg.atomhandle; + if (RHDAtomBiosFunc(&rhd, NULL, ATOMBIOS_INIT, &atomBiosArg) == ATOM_SUCCESS) + { + rhd.atomBIOS = atomBiosArg.atomhandle; + } } - } - if (rhd.atomBIOS) /* for testing functions */ - { - AtomBiosArgRec atomBiosArg; - - atomBiosArg.fb.start = rhd.FbFreeStart; - atomBiosArg.fb.size = rhd.FbFreeSize; - if (RHDAtomBiosFunc(&rhd, rhd.atomBIOS, ATOMBIOS_ALLOCATE_FB_SCRATCH, - &atomBiosArg) == ATOM_SUCCESS) + rhd.videoRam = rhdGetVideoRamSize(&rhd); + if (!rhd.videoRam) { - rhd.FbFreeStart = atomBiosArg.fb.start; - rhd.FbFreeSize = atomBiosArg.fb.size; - }; - RHDAtomBiosFunc(&rhd, rhd.atomBIOS, GET_DEFAULT_ENGINE_CLOCK, &atomBiosArg); - RHDAtomBiosFunc(&rhd, rhd.atomBIOS, GET_DEFAULT_MEMORY_CLOCK, &atomBiosArg); - RHDAtomBiosFunc(&rhd, rhd.atomBIOS, GET_MAX_PIXEL_CLOCK_PLL_OUTPUT, &atomBiosArg); - RHDAtomBiosFunc(&rhd, rhd.atomBIOS, GET_MIN_PIXEL_CLOCK_PLL_OUTPUT, &atomBiosArg); - RHDAtomBiosFunc(&rhd, rhd.atomBIOS, GET_MAX_PIXEL_CLOCK_PLL_INPUT, &atomBiosArg); - RHDAtomBiosFunc(&rhd, rhd.atomBIOS, GET_MIN_PIXEL_CLOCK_PLL_INPUT, &atomBiosArg); - RHDAtomBiosFunc(&rhd, rhd.atomBIOS, GET_MAX_PIXEL_CLK, &atomBiosArg); - RHDAtomBiosFunc(&rhd, rhd.atomBIOS, GET_REF_CLOCK, &atomBiosArg); - } -#endif - - if (RHDI2CFunc((int)&rhd, NULL, RHD_I2C_INIT, &i2cArg) == RHD_I2C_SUCCESS) - rhd.I2C = i2cArg.I2CBusList; - else - { - dbgprintf("I2C init failed\n"); - goto error1; - }; - - if (!rhd.atomBIOS) - { - dbgprintf("No ATOMBIOS detected. Done.\n"); - return 0; - } - - rhdMapFB(&rhd); - - Scrn.rhdPtr = &rhd; - Scrn.driverName = "Radeon HD driver"; - Scrn.bitsPerPixel = 32; - Scrn.depth = 32; - Scrn.virtualX = 1280; - Scrn.virtualY = 1024; - Scrn.displayWidth = 1280; - - rhd.pScrn = &Scrn; - - rhd.FbScanoutStart = 0; - rhd.FbScanoutSize = 8*1024*1024; - rhd.FbFreeStart = 8*1024*1024; - rhd.FbFreeSize = rhd.FbMapSize - 8*1024*1024; - - rhdInitHeap(&rhd); - - RHDVGAInit(&rhd); - RHDMCInit(&rhd); - if (!RHDCrtcsInit(&rhd)) - RHDAtomCrtcsInit(&rhd); - if (!RHDPLLsInit(&rhd)) - RHDAtomPLLsInit(&rhd); - - RHDLUTsInit(&rhd); - - if (!RHDConnectorsInit(&rhd, rhd.Card)) - { - dbgprintf("Card information has invalid connector information\n"); - goto error1; - } - - if (!rhdModeLayoutSelect(&rhd)) - { - dbgprintf("Failed to detect a connected monitor\n"); - goto error1; + dbgprintf("No Video RAM detected.\n"); + goto error1; } - RHDConfigMonitorSet(&rhd, FALSE); - rhdModeLayoutPrint(&rhd); + dbgprintf("VideoRAM: %d kByte\n",rhd.videoRam); - { - DisplayModePtr Modes, tmp; - - Modes = RHDModesPoolCreate(&Scrn, FALSE); - Scrn.modePool = Modes; - - tmp = Modes; - SupportedModes=0; - while(tmp) + if (rhd.atomBIOS) /* for testing functions */ { - dbgprintf("%dx%d@%3.1fHz\n",tmp->CrtcHDisplay, - tmp->CrtcVDisplay,tmp->VRefresh); - tmp=tmp->next; - SupportedModes++; + AtomBiosArgRec atomBiosArg; + + atomBiosArg.fb.start = rhd.FbFreeStart; + atomBiosArg.fb.size = rhd.FbFreeSize; + if (RHDAtomBiosFunc(&rhd, rhd.atomBIOS, ATOMBIOS_ALLOCATE_FB_SCRATCH, + &atomBiosArg) == ATOM_SUCCESS) + { + rhd.FbFreeStart = atomBiosArg.fb.start; + rhd.FbFreeSize = atomBiosArg.fb.size; + }; + RHDAtomBiosFunc(&rhd, rhd.atomBIOS, GET_DEFAULT_ENGINE_CLOCK, &atomBiosArg); + RHDAtomBiosFunc(&rhd, rhd.atomBIOS, GET_DEFAULT_MEMORY_CLOCK, &atomBiosArg); + RHDAtomBiosFunc(&rhd, rhd.atomBIOS, GET_MAX_PIXEL_CLOCK_PLL_OUTPUT, &atomBiosArg); + RHDAtomBiosFunc(&rhd, rhd.atomBIOS, GET_MIN_PIXEL_CLOCK_PLL_OUTPUT, &atomBiosArg); + RHDAtomBiosFunc(&rhd, rhd.atomBIOS, GET_MAX_PIXEL_CLOCK_PLL_INPUT, &atomBiosArg); + RHDAtomBiosFunc(&rhd, rhd.atomBIOS, GET_MIN_PIXEL_CLOCK_PLL_INPUT, &atomBiosArg); + RHDAtomBiosFunc(&rhd, rhd.atomBIOS, GET_MAX_PIXEL_CLK, &atomBiosArg); + RHDAtomBiosFunc(&rhd, rhd.atomBIOS, GET_REF_CLOCK, &atomBiosArg); + } + + + rhd.FbFreeStart = 0; + rhd.FbFreeSize = rhd.videoRam << 10; + + + if (RHDI2CFunc((int)&rhd, NULL, RHD_I2C_INIT, &i2cArg) == RHD_I2C_SUCCESS) + rhd.I2C = i2cArg.I2CBusList; + else + { + dbgprintf("I2C init failed\n"); + goto error1; }; + + if (!rhd.atomBIOS) + { + dbgprintf("No ATOMBIOS detected. Done.\n"); + return 0; + } + +// rhdMapFB(&rhd); + + Scrn.rhdPtr = &rhd; + Scrn.driverName = "Radeon HD driver"; + Scrn.bitsPerPixel = 32; + Scrn.depth = 32; + Scrn.virtualX = 1280; + Scrn.virtualY = 1024; + Scrn.displayWidth = 1280; + + rhd.pScrn = &Scrn; + + rhd.FbScanoutStart = 0; + rhd.FbScanoutSize = 8*1024*1024; + rhd.FbFreeStart = 8*1024*1024; + rhd.FbFreeSize = rhd.FbMapSize - 8*1024*1024; + + rhdInitHeap(&rhd); + + RHDVGAInit(&rhd); + RHDMCInit(&rhd); + + if (!RHDCrtcsInit(&rhd)) + RHDAtomCrtcsInit(&rhd); + if (!RHDPLLsInit(&rhd)) + RHDAtomPLLsInit(&rhd); + + RHDLUTsInit(&rhd); + + if (!RHDConnectorsInit(&rhd, rhd.Card)) + { + dbgprintf("Card information has invalid connector information\n"); + goto error1; + } + + { + struct rhdAtomOutputDeviceList *OutputDeviceList = NULL; + + if (rhdPtr->Card + && rhdPtr->Card->ConnectorInfo[0].Type != RHD_CONNECTOR_NONE + && (rhdPtr->Card->DeviceInfo[0][0] != atomNone + || rhdPtr->Card->DeviceInfo[0][1] != atomNone)) + { + int i, k = 0; + + for (i = 0; i < RHD_CONNECTORS_MAX; i++) + { + int j; + if (rhdPtr->Card->ConnectorInfo[i].Type == RHD_CONNECTOR_NONE) + break; + for (j = 0; j < MAX_OUTPUTS_PER_CONNECTOR; j++) + { + if (rhdPtr->Card->ConnectorInfo[i].Output[j] != RHD_OUTPUT_NONE) + { + if (!(OutputDeviceList = + (struct rhdAtomOutputDeviceList *) + xrealloc(OutputDeviceList, + sizeof (struct rhdAtomOutputDeviceList) * (k + 1)))) + break; + OutputDeviceList[k].ConnectorType = rhdPtr->Card->ConnectorInfo[i].Type; + OutputDeviceList[k].DeviceId = rhdPtr->Card->DeviceInfo[i][j]; + OutputDeviceList[k].OutputType = rhdPtr->Card->ConnectorInfo[i].Output[j]; + dbgprintf("OutputDevice: C: 0x%2.2x O: 0x%2.2x DevID: 0x%2.2x\n", + OutputDeviceList[k].ConnectorType, + OutputDeviceList[k].OutputType, + OutputDeviceList[k].DeviceId); + k++; + } + } + } + } + else + { + AtomBiosArgRec data; + + data.chipset = rhdPtr->ChipSet; + if (RHDAtomBiosFunc(rhdPtr, rhdPtr->atomBIOS, + ATOMBIOS_GET_OUTPUT_DEVICE_LIST, &data) == ATOM_SUCCESS) + OutputDeviceList = data.OutputDeviceList; + } + + if (OutputDeviceList) + { + struct rhdOutput *Output; + + for (Output = rhdPtr->Outputs; Output; Output = Output->Next) + RHDAtomSetupOutputDriverPrivate(OutputDeviceList, Output); + xfree(OutputDeviceList); + } + } + + + if (!rhdModeLayoutSelect(&rhd)) + { + dbgprintf("Failed to detect a connected monitor\n"); + goto error1; + } + + RHDConfigMonitorSet(&rhd, FALSE); + rhdModeLayoutPrint(&rhd); + + { + DisplayModePtr Modes, tmp; + + Modes = RHDModesPoolCreate(&Scrn, FALSE); + Scrn.modePool = Modes; + + tmp = Modes; + SupportedModes=0; + while(tmp) + { + dbgprintf("%dx%d@%3.1fHz\n",tmp->CrtcHDisplay, + tmp->CrtcVDisplay,tmp->VRefresh); + tmp=tmp->next; + SupportedModes++; + }; // rhdModeInit(&Scrn,Modes); //RHDAdjustFrame(&rhd,0,0,0); - }; - dbgprintf("All done\n"); - return 1; + }; + dbgprintf("All done\n"); + return 1; error1: - return 0; + return 0; }; int __stdcall drvEntry(int action) { - int i; + int i; - if(action != 1) - return 0; + if(action != 1) + return 0; - if(!dbg_open("/rd/1/ati.txt")) - { - printf("Can't open /rd/1/ati.txt\nExit\n"); - return 0; - } - if(!FindPciDevice()) - return 0; + if(!dbg_open("/rd/1/drivers/ati.txt")) + { + printf("Can't open /rd/1/drivers/ati.txt\nExit\n"); + return 0; + } + if(!FindPciDevice()) + return 0; - rhd.scrnIndex = (int)&rhd; + rhd.scrnIndex = (int)&rhd; - rhd.Card = RHDCardIdentify(&rhd); - if (rhd.Card) - dbgprintf("Detected an %s on a %s\n", rhd.chipset_name, rhd.Card->name); - else - dbgprintf("Detected an %s on an unidentified card\n", rhd.chipset_name); + for(i=0;i<6;i++) + { + if(rhd.pci.memBase[i]) + dbgprintf("Memory base_%d 0x%x size 0x%x\n", + i,rhd.pci.memBase[i],(1<Crtc[0]->Power(rhdPtr->Crtc[0], RHD_POWER_RESET); - rhdPtr->Crtc[1]->Power(rhdPtr->Crtc[1], RHD_POWER_RESET); } - -static void +/* + * */static void rhdModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) { RHDPtr rhdPtr = pScrn->rhdPtr; RHDFUNC(rhdPtr); -// pScrn->vtSema = TRUE; - - /* Stop crap from being shown: gets reenabled through SaveScreen */ -// rhdPtr->Crtc[0]->Blank(rhdPtr->Crtc[0], TRUE); -// rhdPtr->Crtc[1]->Blank(rhdPtr->Crtc[1], TRUE); - - rhdPrepareMode(rhdPtr); - - /* now disable our VGA Mode */ - RHDVGADisable(rhdPtr); - - /* now set up the MC */ - RHDMCSetup(rhdPtr); rhdSetMode(pScrn, mode); } -static void +/* * */static void rhdSetMode(ScrnInfoPtr pScrn, DisplayModePtr mode) { RHDPtr rhdPtr = RHDPTR(pScrn); @@ -1033,3 +1108,57 @@ _RHDWriteMC(int scrnIndex, CARD32 addr, CARD32 data) } } +/* + * + */ +static void +rhdGetIGPNorthBridgeInfo(RHDPtr rhdPtr) +{ + switch (rhdPtr->ChipSet) + { + case RHD_RS600: + break; + case RHD_RS690: + case RHD_RS740: + case RHD_RS780: + rhdPtr->NBPciTag = pciTag(0,0,0); + break; + default: + break; + } +} + +static enum rhdCardType +rhdGetCardType(RHDPtr rhdPtr) +{ + CARD32 cmd_stat; + + if (rhdPtr->ChipSet == RHD_RS780) + return RHD_CARD_PCIE; + + cmd_stat = pciReadLong(rhdPtr->PciTag, PCI_CMD_STAT_REG); + + if (cmd_stat & 0x100000) { + CARD32 cap_ptr, cap_id; + + cap_ptr = pciReadLong(rhdPtr->PciTag, 0x34); + cap_ptr &= 0xfc; + + while (cap_ptr) + { + cap_id = pciReadLong(rhdPtr->PciTag, cap_ptr); + switch (cap_id & 0xff) { + case RHD_PCI_CAPID_AGP: + xf86DrvMsg(rhdPtr->scrnIndex, X_INFO, "AGP Card Detected\n"); + return RHD_CARD_AGP; + case RHD_PCI_CAPID_PCIE: + xf86DrvMsg(rhdPtr->scrnIndex, X_INFO, "PCIE Card Detected\n"); + return RHD_CARD_PCIE; + } + cap_ptr = (cap_id >> 8) & 0xff; + } + } + return RHD_CARD_NONE; +} + + diff --git a/programs/system/drivers/rhd/rhd.h b/drivers/video/radeonhd/rhd.h similarity index 83% rename from programs/system/drivers/rhd/rhd.h rename to drivers/video/radeonhd/rhd.h index eb9b5110cf..638f8ecf5e 100644 --- a/programs/system/drivers/rhd/rhd.h +++ b/drivers/video/radeonhd/rhd.h @@ -1,4 +1,6 @@ + #include "pci.h" + #include "rhd_regs.h" typedef struct _ScrnInfoRec *ScrnInfoPtr; @@ -413,80 +415,84 @@ typedef struct { typedef struct RHDRec { - ScrnInfoPtr pScrn; - int scrnIndex; + ScrnInfoPtr pScrn; + int scrnIndex; - CARD32 MMIOBase; - CARD32 MMIOMapSize; - CARD32 videoRam; + CARD32 MMIOBase; + CARD32 MMIOMapSize; + CARD32 videoRam; - enum RHD_HPD_USAGE hpdUsage; - RHDOpt forceReduced; + enum RHD_HPD_USAGE hpdUsage; + RHDOpt forceReduced; - CARD32 FbBase; /* map base of fb */ - CARD32 FbIntAddress; /* card internal address of FB */ - CARD32 FbMapSize; + CARD32 FbBase; /* map base of fb */ + CARD32 FbIntAddress; /* card internal address of FB */ + CARD32 FbIntSize; /* card internal FB aperture size */ - CARD32 FbFreeStart; - CARD32 FbFreeSize; + CARD32 FbMapSize; + + CARD32 FbFreeStart; + CARD32 FbFreeSize; /* visible part of the framebuffer */ - unsigned int FbScanoutStart; - unsigned int FbScanoutSize; + unsigned int FbScanoutStart; + unsigned int FbScanoutSize; - unsigned char* BIOSCopy; + unsigned char* BIOSCopy; - enum RHD_CHIPSETS ChipSet; - struct rhdCard *Card; - char *chipset_name; + enum RHD_CHIPSETS ChipSet; + struct rhdCard *Card; + char *chipset_name; - Bool IsMobility; - Bool IsIGP; - Bool HasCRTC2; - Bool HasSingleDAC; - Bool InternalTVOut; + Bool IsMobility; + Bool IsIGP; + Bool HasCRTC2; + Bool HasSingleDAC; + Bool InternalTVOut; - u32_t bus; - u32_t devfn; + u32_t bus; + u32_t devfn; - PCITAG PciTag; - PCITAG NBPciTag; + PCITAG PciTag; + PCITAG NBPciTag; - CARD16 PciDeviceID; - CARD16 subvendor_id; - CARD16 subdevice_id; - pciVideoRec pci; + CARD16 PciDeviceID; + enum rhdCardType cardType; - struct _I2CBusRec **I2C; /* I2C bus list */ - atomBiosHandlePtr atomBIOS; /* handle for AtomBIOS */ + CARD16 subvendor_id; + CARD16 subdevice_id; + pciVideoRec pci; - struct rhdMC *MC; - struct rhdVGA *VGA; - struct rhdCrtc *Crtc[2]; - struct rhdPLL *PLLs[2]; /* Pixelclock PLLs */ + struct _I2CBusRec **I2C; /* I2C bus list */ + atomBiosHandlePtr atomBIOS; /* handle for AtomBIOS */ - struct rhdLUTStore *LUTStore; - struct rhdLUT *LUT[2]; + struct rhdMC *MC; + struct rhdVGA *VGA; + struct rhdCrtc *Crtc[2]; + struct rhdPLL *PLLs[2]; /* Pixelclock PLLs */ - struct rhdConnector *Connector[RHD_CONNECTORS_MAX]; + struct rhdLUTStore *LUTStore; + struct rhdLUT *LUT[2]; - struct rhdOutput *Outputs; + struct rhdConnector *Connector[RHD_CONNECTORS_MAX]; - struct rhdHPD *HPD; /* Hot plug detect subsystem */ - enum RHD_TV_MODE tvMode; - struct rhdMonitor *ConfigMonitor; + struct rhdOutput *Outputs; - struct mem_block *fb_heap; - struct mem_block *gart_heap; + struct rhdHPD *HPD; /* Hot plug detect subsystem */ + enum RHD_TV_MODE tvMode; + struct rhdMonitor *ConfigMonitor; - RHDOpt scaleTypeOpt; + struct mem_block *fb_heap; + struct mem_block *gart_heap; - int verbosity; + RHDOpt scaleTypeOpt; + + int verbosity; /* AtomBIOS usage */ - RHDOpt UseAtomBIOS; - CARD32 UseAtomFlags; + RHDOpt UseAtomBIOS; + CARD32 UseAtomFlags; struct rhdOutput *DigEncoderOutput[2]; }RHD_t; @@ -555,25 +561,7 @@ extern void _RHDWriteMC(int scrnIndex, CARD32 addr, CARD32 data); char * RhdAppendString(char *s1, const char *s2); -#ifndef PCI_DOM_MASK -# define PCI_DOM_MASK 0x0ffu -#endif -#define PCI_DOMBUS_MASK (((PCI_DOM_MASK) << 8) | 0x0ffu) -#define PCI_MAKE_TAG(b,d,f) ((((b) & (PCI_DOMBUS_MASK)) << 16) | \ - (((d) & 0x00001fu) << 11) | \ - (((f) & 0x000007u) << 8)) - -#define PCI_BUS_FROM_TAG(tag) (((tag) >> 16) & (PCI_DOMBUS_MASK)) -#define PCI_DEV_FROM_TAG(tag) (((tag) & 0x0000f800u) >> 11) -#define PCI_FUNC_FROM_TAG(tag) (((tag) & 0x00000700u) >> 8) -#define PCI_DFN_FROM_TAG(tag) (((tag) & 0x0000ff00u) >> 8) - -extern inline PCITAG -pciTag(int busnum, int devnum, int funcnum) -{ - return(PCI_MAKE_TAG(busnum,devnum,funcnum)); -} #define LOG_DEBUG 0 diff --git a/programs/system/drivers/rhd/rhd.lk1 b/drivers/video/radeonhd/rhd.lk1 similarity index 100% rename from programs/system/drivers/rhd/rhd.lk1 rename to drivers/video/radeonhd/rhd.lk1 diff --git a/programs/system/drivers/rhd/rhd.mk b/drivers/video/radeonhd/rhd.mk similarity index 100% rename from programs/system/drivers/rhd/rhd.mk rename to drivers/video/radeonhd/rhd.mk diff --git a/programs/system/drivers/rhd/rhd_atombios.c b/drivers/video/radeonhd/rhd_atombios.c similarity index 99% rename from programs/system/drivers/rhd/rhd_atombios.c rename to drivers/video/radeonhd/rhd_atombios.c index 40d49d6dc7..c5fae516b1 100644 --- a/programs/system/drivers/rhd/rhd_atombios.c +++ b/drivers/video/radeonhd/rhd_atombios.c @@ -27,11 +27,11 @@ #ifdef HAVE_CONFIG_H # include "config.h" #endif +#include "xf86.h" /* only for testing now */ -#include "common.h" #include "rhd.h" #include "edid.h" #include "rhd_atombios.h" diff --git a/programs/system/drivers/rhd/rhd_atombios.h b/drivers/video/radeonhd/rhd_atombios.h similarity index 100% rename from programs/system/drivers/rhd/rhd_atombios.h rename to drivers/video/radeonhd/rhd_atombios.h diff --git a/programs/system/drivers/rhd/rhd_atomcrtc.c b/drivers/video/radeonhd/rhd_atomcrtc.c similarity index 97% rename from programs/system/drivers/rhd/rhd_atomcrtc.c rename to drivers/video/radeonhd/rhd_atomcrtc.c index 3ae1c8772e..ab45afade7 100644 --- a/programs/system/drivers/rhd/rhd_atomcrtc.c +++ b/drivers/video/radeonhd/rhd_atomcrtc.c @@ -140,7 +140,7 @@ rhdAtomScaleSet(struct rhdCrtc *Crtc, enum rhdCrtcScaleType Type, data.Address = NULL; RHDAtomBiosFunc(rhdPtr->scrnIndex, rhdPtr->atomBIOS, ATOM_SET_REGISTER_LIST_LOCATION, &data); - RHDTuneMCAccessForDisplay(rhdPtr, Crtc->Id, Mode, + RHDMCTuneAccessForDisplay(rhdPtr, Crtc->Id, Mode, ScaledToMode ? ScaledToMode : Mode); } @@ -254,7 +254,7 @@ rhdAtomModeSet(struct rhdCrtc *Crtc, DisplayModePtr Mode) /* * */ -static void +static Bool rhdAtomCrtcPower(struct rhdCrtc *Crtc, int Power) { RHDPtr rhdPtr = RHDPTRI(Crtc); @@ -292,6 +292,13 @@ rhdAtomCrtcPower(struct rhdCrtc *Crtc, int Power) } data.Address = NULL; RHDAtomBiosFunc(Crtc->scrnIndex, rhdPtr->atomBIOS, ATOM_SET_REGISTER_LIST_LOCATION, &data); + + /* + * we always claim we succeeded here, after all, we know, AtomBIOS knows + * how to do things, right? + * Err, no, when we use AtomBIOS we should not have a clue how to find out. + */ + return TRUE; } /* diff --git a/programs/system/drivers/rhd/rhd_atomout.c b/drivers/video/radeonhd/rhd_atomout.c similarity index 100% rename from programs/system/drivers/rhd/rhd_atomout.c rename to drivers/video/radeonhd/rhd_atomout.c diff --git a/programs/system/drivers/rhd/rhd_atomout.h b/drivers/video/radeonhd/rhd_atomout.h similarity index 100% rename from programs/system/drivers/rhd/rhd_atomout.h rename to drivers/video/radeonhd/rhd_atomout.h diff --git a/programs/system/drivers/rhd/rhd_atompll.c b/drivers/video/radeonhd/rhd_atompll.c similarity index 100% rename from programs/system/drivers/rhd/rhd_atompll.c rename to drivers/video/radeonhd/rhd_atompll.c diff --git a/programs/system/drivers/rhd/rhd_atomwrapper.c b/drivers/video/radeonhd/rhd_atomwrapper.c similarity index 100% rename from programs/system/drivers/rhd/rhd_atomwrapper.c rename to drivers/video/radeonhd/rhd_atomwrapper.c diff --git a/programs/system/drivers/rhd/rhd_atomwrapper.h b/drivers/video/radeonhd/rhd_atomwrapper.h similarity index 100% rename from programs/system/drivers/rhd/rhd_atomwrapper.h rename to drivers/video/radeonhd/rhd_atomwrapper.h diff --git a/programs/system/drivers/rhd/rhd_audio.h b/drivers/video/radeonhd/rhd_audio.h similarity index 100% rename from programs/system/drivers/rhd/rhd_audio.h rename to drivers/video/radeonhd/rhd_audio.h diff --git a/programs/system/drivers/rhd/rhd_biosscratch.c b/drivers/video/radeonhd/rhd_biosscratch.c similarity index 100% rename from programs/system/drivers/rhd/rhd_biosscratch.c rename to drivers/video/radeonhd/rhd_biosscratch.c diff --git a/programs/system/drivers/rhd/rhd_biosscratch.h b/drivers/video/radeonhd/rhd_biosscratch.h similarity index 100% rename from programs/system/drivers/rhd/rhd_biosscratch.h rename to drivers/video/radeonhd/rhd_biosscratch.h diff --git a/programs/system/drivers/rhd/rhd_card.h b/drivers/video/radeonhd/rhd_card.h similarity index 100% rename from programs/system/drivers/rhd/rhd_card.h rename to drivers/video/radeonhd/rhd_card.h diff --git a/programs/system/drivers/rhd/rhd_connector.c b/drivers/video/radeonhd/rhd_connector.c similarity index 100% rename from programs/system/drivers/rhd/rhd_connector.c rename to drivers/video/radeonhd/rhd_connector.c diff --git a/programs/system/drivers/rhd/rhd_connector.h b/drivers/video/radeonhd/rhd_connector.h similarity index 100% rename from programs/system/drivers/rhd/rhd_connector.h rename to drivers/video/radeonhd/rhd_connector.h diff --git a/programs/system/drivers/rhd/rhd_crtc.c b/drivers/video/radeonhd/rhd_crtc.c similarity index 99% rename from programs/system/drivers/rhd/rhd_crtc.c rename to drivers/video/radeonhd/rhd_crtc.c index 5325ca4446..3631ef6acd 100644 --- a/programs/system/drivers/rhd/rhd_crtc.c +++ b/drivers/video/radeonhd/rhd_crtc.c @@ -787,7 +787,7 @@ DxScaleSet(struct rhdCrtc *Crtc, enum rhdCrtcScaleType Type, RHDRegWrite(Crtc, RegOff + D1SCL_DITHER, 0x00001010); break; } - RHDTuneMCAccessForDisplay(rhdPtr, Crtc->Id, Mode, + RHDMCTuneAccessForDisplay(rhdPtr, Crtc->Id, Mode, ScaledToMode ? ScaledToMode : Mode); } @@ -1013,7 +1013,7 @@ D2ViewPortStart(struct rhdCrtc *Crtc, CARD16 X, CARD16 Y) /* * */ -static void +static Bool D1CRTCDisable(struct rhdCrtc *Crtc) { if (RHDRegRead(Crtc, D1CRTC_CONTROL) & 0x00000001) { @@ -1027,18 +1027,20 @@ D1CRTCDisable(struct rhdCrtc *Crtc) if (!(RHDRegRead(Crtc, D1CRTC_CONTROL) & 0x00010000)) { RHDDebug(Crtc->scrnIndex, "%s: %d loops\n", __func__, i); RHDRegMask(Crtc, D1CRTC_CONTROL, Control, 0x00000300); - return; + return TRUE; } xf86DrvMsg(Crtc->scrnIndex, X_ERROR, "%s: Failed to Unsync %s\n", __func__, Crtc->Name); RHDRegMask(Crtc, D1CRTC_CONTROL, Control, 0x00000300); + return FALSE; } + return TRUE; } /* * */ -static void +static Bool D2CRTCDisable(struct rhdCrtc *Crtc) { if (RHDRegRead(Crtc, D2CRTC_CONTROL) & 0x00000001) { @@ -1052,20 +1054,23 @@ D2CRTCDisable(struct rhdCrtc *Crtc) if (!(RHDRegRead(Crtc, D2CRTC_CONTROL) & 0x00010000)) { RHDDebug(Crtc->scrnIndex, "%s: %d loops\n", __func__, i); RHDRegMask(Crtc, D2CRTC_CONTROL, Control, 0x00000300); - return; + return TRUE; } xf86DrvMsg(Crtc->scrnIndex, X_ERROR, "%s: Failed to Unsync %s\n", __func__, Crtc->Name); RHDRegMask(Crtc, D2CRTC_CONTROL, Control, 0x00000300); + return FALSE; } + return TRUE; } /* * */ -static void +static Bool D1Power(struct rhdCrtc *Crtc, int Power) { + Bool ret; RHDFUNC(Crtc); switch (Power) { @@ -1074,26 +1079,26 @@ D1Power(struct rhdCrtc *Crtc, int Power) usleep(2); RHDRegMask(Crtc, D1CRTC_CONTROL, 0, 0x01000000); /* enable read requests */ RHDRegMask(Crtc, D1CRTC_CONTROL, 1, 1); - return; + return TRUE; case RHD_POWER_RESET: RHDRegMask(Crtc, D1CRTC_CONTROL, 0x01000000, 0x01000000); /* disable read requests */ - D1CRTCDisable(Crtc); - return; + return D1CRTCDisable(Crtc); case RHD_POWER_SHUTDOWN: default: RHDRegMask(Crtc, D1CRTC_CONTROL, 0x01000000, 0x01000000); /* disable read requests */ - D1CRTCDisable(Crtc); + ret = D1CRTCDisable(Crtc); RHDRegMask(Crtc, D1GRPH_ENABLE, 0, 0x00000001); - return; + return ret; } } /* * */ -static void +static Bool D2Power(struct rhdCrtc *Crtc, int Power) { + Bool ret; RHDFUNC(Crtc); switch (Power) { @@ -1102,17 +1107,16 @@ D2Power(struct rhdCrtc *Crtc, int Power) usleep(2); RHDRegMask(Crtc, D2CRTC_CONTROL, 0, 0x01000000); /* enable read requests */ RHDRegMask(Crtc, D2CRTC_CONTROL, 1, 1); - return; + return TRUE; case RHD_POWER_RESET: RHDRegMask(Crtc, D2CRTC_CONTROL, 0x01000000, 0x01000000); /* disable read requests */ - D2CRTCDisable(Crtc); - return; + return D2CRTCDisable(Crtc); case RHD_POWER_SHUTDOWN: default: RHDRegMask(Crtc, D2CRTC_CONTROL, 0x01000000, 0x01000000); /* disable read requests */ - D2CRTCDisable(Crtc); + ret = D2CRTCDisable(Crtc); RHDRegMask(Crtc, D2GRPH_ENABLE, 0, 0x00000001); - return; + return ret; } } diff --git a/programs/system/drivers/rhd/rhd_crtc.h b/drivers/video/radeonhd/rhd_crtc.h similarity index 99% rename from programs/system/drivers/rhd/rhd_crtc.h rename to drivers/video/radeonhd/rhd_crtc.h index 8f58c13a8b..5f67084d04 100644 --- a/programs/system/drivers/rhd/rhd_crtc.h +++ b/drivers/video/radeonhd/rhd_crtc.h @@ -108,7 +108,7 @@ struct rhdCrtc { void (*LUTRestore) (struct rhdCrtc *Crtc); void (*LUTDestroy) (struct rhdCrtc *Crtc); - void (*Power) (struct rhdCrtc *Crtc, int Power); + Bool (*Power) (struct rhdCrtc *Crtc, int Power); void (*Blank) (struct rhdCrtc *Crtc, Bool Blank); }; diff --git a/programs/system/drivers/rhd/rhd_dac.c b/drivers/video/radeonhd/rhd_dac.c similarity index 100% rename from programs/system/drivers/rhd/rhd_dac.c rename to drivers/video/radeonhd/rhd_dac.c diff --git a/programs/system/drivers/rhd/rhd_ddia.c b/drivers/video/radeonhd/rhd_ddia.c similarity index 100% rename from programs/system/drivers/rhd/rhd_ddia.c rename to drivers/video/radeonhd/rhd_ddia.c diff --git a/programs/system/drivers/rhd/rhd_dig.c b/drivers/video/radeonhd/rhd_dig.c similarity index 100% rename from programs/system/drivers/rhd/rhd_dig.c rename to drivers/video/radeonhd/rhd_dig.c diff --git a/programs/system/drivers/rhd/rhd_edid.c b/drivers/video/radeonhd/rhd_edid.c similarity index 95% rename from programs/system/drivers/rhd/rhd_edid.c rename to drivers/video/radeonhd/rhd_edid.c index fd2a93d05f..efec30eb2a 100644 --- a/programs/system/drivers/rhd/rhd_edid.c +++ b/drivers/video/radeonhd/rhd_edid.c @@ -65,7 +65,7 @@ static DisplayModeRec EDIDEstablishedModes[17] = { }; static DisplayModePtr -EDIDModesFromEstablished(RHDPtr rhdPtr, struct established_timings *timing) +EDIDModesFromEstablished(int scrnIndex, struct established_timings *timing) { DisplayModePtr Modes = NULL, Mode = NULL; CARD32 bits = (timing->t1) | (timing->t2 << 8) | @@ -85,7 +85,7 @@ EDIDModesFromEstablished(RHDPtr rhdPtr, struct established_timings *timing) * */ static DisplayModePtr -EDIDModesFromStandardTiming(RHDPtr rhdPtr, struct std_timings *timing) +EDIDModesFromStandardTiming(int scrnIndex, struct std_timings *timing) { DisplayModePtr Modes = NULL, Mode = NULL; int i; @@ -105,10 +105,9 @@ EDIDModesFromStandardTiming(RHDPtr rhdPtr, struct std_timings *timing) * */ static DisplayModePtr -EDIDModeFromDetailedTiming(RHDPtr rhdPtr, struct detailed_timings *timing) +EDIDModeFromDetailedTiming(int scrnIndex, struct detailed_timings *timing) { DisplayModePtr Mode; - int scrnIndex; /* We don't do stereo */ if (timing->stereo) { diff --git a/programs/system/drivers/rhd/rhd_hdmi.c b/drivers/video/radeonhd/rhd_hdmi.c similarity index 100% rename from programs/system/drivers/rhd/rhd_hdmi.c rename to drivers/video/radeonhd/rhd_hdmi.c diff --git a/programs/system/drivers/rhd/rhd_hdmi.h b/drivers/video/radeonhd/rhd_hdmi.h similarity index 100% rename from programs/system/drivers/rhd/rhd_hdmi.h rename to drivers/video/radeonhd/rhd_hdmi.h diff --git a/programs/system/drivers/rhd/rhd_i2c.c b/drivers/video/radeonhd/rhd_i2c.c similarity index 99% rename from programs/system/drivers/rhd/rhd_i2c.c rename to drivers/video/radeonhd/rhd_i2c.c index 83e889d7c7..a736a4d7b7 100644 --- a/programs/system/drivers/rhd/rhd_i2c.c +++ b/drivers/video/radeonhd/rhd_i2c.c @@ -1132,7 +1132,7 @@ rhdTearDownI2C(I2CBusPtr *I2C) * broken in older server versions. * So we cannot use it. How bad! */ - for (i = 0; i < I2C_LINES; i++) { + for (i = 0; i < MAX_I2C_LINES; i++) { char *name; if (!I2C[i]) break; diff --git a/programs/system/drivers/rhd/rhd_i2c.h b/drivers/video/radeonhd/rhd_i2c.h similarity index 99% rename from programs/system/drivers/rhd/rhd_i2c.h rename to drivers/video/radeonhd/rhd_i2c.h index d9f1f20b1c..baa8ad722f 100644 --- a/programs/system/drivers/rhd/rhd_i2c.h +++ b/drivers/video/radeonhd/rhd_i2c.h @@ -28,7 +28,6 @@ //#include "xf86DDC.h" #include "xf86i2c.h" -#define I2C_LINES 5 typedef enum { RHD_I2C_INIT, diff --git a/programs/system/drivers/rhd/rhd_id.c b/drivers/video/radeonhd/rhd_id.c similarity index 99% rename from programs/system/drivers/rhd/rhd_id.c rename to drivers/video/radeonhd/rhd_id.c index 5f818eccf6..1884cf730a 100644 --- a/programs/system/drivers/rhd/rhd_id.c +++ b/drivers/video/radeonhd/rhd_id.c @@ -211,6 +211,7 @@ const PCI_ID_LIST = { // RHD_DEVICE_MATCH( 0x9447, RHD_R700 ), /* K2 ATI FirePro Graphics Accelerator */ RHD_DEVICE_MATCH( 0x944A, RHD_M98 ), /* M98 */ RHD_DEVICE_MATCH( 0x944B, RHD_M98 ), /* M98 */ + RHD_DEVICE_MATCH( 0x944C, RHD_RV770 ), /* RV770 */ RHD_DEVICE_MATCH( 0x944E, RHD_RV770 ), /* RV770 */ // RHD_DEVICE_MATCH( 0x944F, RHD_R700 ), /* R700 */ RHD_DEVICE_MATCH( 0x9456, RHD_RV770 ), /* Denali ATI FirePro Graphics Accelerator */ @@ -719,6 +720,7 @@ rhdCards[] = /* 0x94C3 : RV610 : Radeon HD 2400 Pro */ { 0x94C3, 0x1545, 0x3210, "ATI Radeon 2400HD Pro", RHD_CARD_FLAG_HPDSWAP, ID_CONNECTORINFO_EMPTY, DEVINFO_EMPTY }, { 0x94C3, 0x174B, 0xE370, "Sapphire HD 2400 Pro", RHD_CARD_FLAG_NONE, VGA_A0_DVI_BB10, DEVINFO_EMPTY }, + { 0x94C3, 0x18BC, 0x3550, "GeCube Radeon HD 2400PRO", RHD_CARD_FLAG_NONE, BROKEN_VGA_B1_DVI_AB00, DEVINFO_EMPTY }, /* 0x94C4 : RV610 : ATI Radeon HD 2400 PRO AGP */ { 0x94C4, 0x18BC, 0x0028, "GeCube Radeon HD 2400PRO AGP", RHD_CARD_FLAG_NONE, BROKEN_VGA_B1_DVI_AB00, DEVINFO_EMPTY }, /* 0x94C5 : RV610 : ATI FireGL V4000 */ diff --git a/programs/system/drivers/rhd/rhd_lut.c b/drivers/video/radeonhd/rhd_lut.c similarity index 100% rename from programs/system/drivers/rhd/rhd_lut.c rename to drivers/video/radeonhd/rhd_lut.c diff --git a/programs/system/drivers/rhd/rhd_lut.h b/drivers/video/radeonhd/rhd_lut.h similarity index 100% rename from programs/system/drivers/rhd/rhd_lut.h rename to drivers/video/radeonhd/rhd_lut.h diff --git a/programs/system/drivers/rhd/rhd_lvtma.c b/drivers/video/radeonhd/rhd_lvtma.c similarity index 99% rename from programs/system/drivers/rhd/rhd_lvtma.c rename to drivers/video/radeonhd/rhd_lvtma.c index 8a414c2d2c..148ab265bc 100644 --- a/programs/system/drivers/rhd/rhd_lvtma.c +++ b/drivers/video/radeonhd/rhd_lvtma.c @@ -43,17 +43,15 @@ #include "rhd.h" #include "rhd_crtc.h" - +#include "rhd_connector.h" +#include "rhd_output.h" +#include "rhd_regs.h" +#include "rhd_hdmi.h" #ifdef ATOM_BIOS #include "rhd_atombios.h" #include "rhd_atomout.h" #endif -#include "rhd_connector.h" -#include "rhd_output.h" -#include "rhd_regs.h" -#include "rhd_card.h" - /* * First of all, make it more managable to code for both R500 and R600, as * there was a 1 register shift, right in the middle of the register block. diff --git a/drivers/video/radeonhd/rhd_mc.c b/drivers/video/radeonhd/rhd_mc.c new file mode 100644 index 0000000000..3e4c1ae71e --- /dev/null +++ b/drivers/video/radeonhd/rhd_mc.c @@ -0,0 +1,803 @@ +/* + * Copyright 2007, 2008 Luc Verhaegen + * Copyright 2007, 2008 Matthias Hopf + * Copyright 2007, 2008 Egbert Eich + * Copyright 2007, 2008 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * MC idling: + * + * For SetupFBLocation and Restore, we require a fully idle MC as we might lock up + * otherwise. Both calls now check whether the MC is Idle before attempting + * to set up the MC, and complain loudly when this fails. + * + * Likely suspect registers for when the Idle fails: + * DxVGA_CONTROL & D1VGA_MODE_ENABLE (run RHDVGADisable beforehand) + * DxCRTC_CONTROL & 0x1 (run DxCRTCDisable beforehand) + * (... Add more here...) + * + * + * MC addressing: + * + * On R600 and up the MC can use a larger than 32bit card internal address for + * its framebuffer. This is why the Address used inside the MC code is a + * CARD64. + * + * rhdPtr->FbIntAddress is kept as a CARD32 for the time being. This is still + * valid, as this makes the R500 code simpler, and since we pick FbIntAddress + * from a 32bit register anyway on R600. FbIntAddress will also correctly cast + * to a CARD64 when passed to the likes of the SetupFBLocation callback. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#if HAVE_XF86_ANSIC_H +# include "xf86_ansic.h" +#else +# include +#endif + +#include "xf86.h" + +#include "rhd.h" +#include "rhd_regs.h" +#include "rhd_crtc.h" /* for definition of Crtc->Id */ + +struct rhdMC { + int scrnIndex; + + CARD32 FbLocation; + CARD32 HdpFbAddress; + CARD32 MiscLatencyTimer; + Bool Stored; + void (*Save)(struct rhdMC *MC); + void (*Restore)(struct rhdMC *MC); + Bool (*Idle)(struct rhdMC *MC); + CARD64 (*GetFBLocation)(struct rhdMC *MC, CARD32 *size); + void (*SetupFBLocation)(struct rhdMC *MC, CARD64 Address, CARD32 Size); + void (*TuneAccessForDisplay)(struct rhdMC *MC, int crtc, + DisplayModePtr Mode, DisplayModePtr ScaledToMode); +}; + +/* + * Some common FB location calculations. + */ +/* + * Applicable for all R5xx and RS600, RS690, RS740 + */ +static CARD64 +R5xxMCGetFBLocation(CARD32 Value, CARD32 *Size) +{ + *Size = (Value & 0xFFFF0000) - ((Value & 0xFFFF) << 16); + return (Value & 0xFFFF) << 16; +} + +#define R5XX_FB_LOCATION(address, size) \ + ((((address) + (size)) & 0xFFFF0000) | (((address) >> 16) & 0xFFFF)) +#define R5XX_HDP_LOCATION(address) \ + (((address) >> 16) & 0xFFFF) + +/* + * Applicable for all R6xx and R7xx, and RS780/RS790 + */ +static CARD64 +R6xxMCGetFBLocation(CARD32 Value, CARD32 *Size) +{ + *Size = (((Value & 0xFFFF0000) - ((Value & 0xFFFF) << 16))) << 8; + return (Value & 0xFFFF) << 24; +} + +#define R6XX_FB_LOCATION(address, size) \ + (((((address) + (size)) >> 8) & 0xFFFF0000) | (((address) >> 24) & 0xFFFF)) +#define R6XX_HDP_LOCATION(address) \ + ((((address) >> 8) & 0x00FF0000)) + +/* + * + */ +static void +RV515MCSave(struct rhdMC *MC) +{ + MC->FbLocation = RHDReadMC(MC, MC_IND_ALL | RV515_MC_FB_LOCATION); + MC->MiscLatencyTimer = RHDReadMC(MC, MC_IND_ALL | RV515_MC_MISC_LAT_TIMER); + MC->HdpFbAddress = RHDRegRead(MC, HDP_FB_LOCATION); +} + +/* + * + */ +static void +RV515MCRestore(struct rhdMC *MC) +{ + RHDWriteMC(MC, MC_IND_ALL | RV515_MC_FB_LOCATION, MC->FbLocation); + RHDWriteMC(MC, MC_IND_ALL | RV515_MC_MISC_LAT_TIMER, MC->MiscLatencyTimer); + RHDRegWrite(MC, HDP_FB_LOCATION, MC->HdpFbAddress); +} + +/* + * + */ +static Bool +RV515MCWaitIdle(struct rhdMC *MC) +{ + if (RHDReadMC(MC, MC_IND_ALL | RV515_MC_STATUS) & RV515_MC_IDLE) + return TRUE; + return FALSE; +} + +/* + * + */ +static CARD64 +RV515MCGetFBLocation(struct rhdMC *MC, CARD32 *Size) +{ + return R5xxMCGetFBLocation(RHDReadMC(MC, RV515_MC_FB_LOCATION | MC_IND_ALL), Size); +} + +/* + * + */ +static void +RV515MCSetupFBLocation(struct rhdMC *MC, CARD64 Address, CARD32 Size) +{ + RHDWriteMC(MC, RV515_MC_FB_LOCATION | MC_IND_ALL, + R5XX_FB_LOCATION(Address, Size)); + RHDRegWrite(MC, HDP_FB_LOCATION, R5XX_HDP_LOCATION(Address)); +} + +/* + * + */ +static void +RV515MCTuneMCAccessForDisplay(struct rhdMC *MC, int Crtc, + DisplayModePtr Mode, DisplayModePtr ScaledToMode) +{ + CARD32 value, setting = 0x1; + + value = RHDReadMC(MC, RV515_MC_MISC_LAT_TIMER); + + if (Crtc == RHD_CRTC_1) { + value &= ~(0x0F << MC_DISP0R_INIT_LAT_SHIFT); + value |= setting << MC_DISP0R_INIT_LAT_SHIFT; + } else { /* RHD_CRTC_2 */ + value &= ~(0x0F << MC_DISP1R_INIT_LAT_SHIFT); + value |= setting << MC_DISP1R_INIT_LAT_SHIFT; + } + + RHDWriteMC(MC, RV515_MC_MISC_LAT_TIMER, value); +} + +/* + * + */ +static void +R500MCSave(struct rhdMC *MC) +{ + MC->FbLocation = RHDReadMC(MC, MC_IND_ALL | R5XX_MC_FB_LOCATION); + MC->HdpFbAddress = RHDRegRead(MC, HDP_FB_LOCATION); +} + +/* + * + */ +static void +R500MCRestore(struct rhdMC *MC) +{ + RHDWriteMC(MC, MC_IND_ALL | R5XX_MC_FB_LOCATION, MC->FbLocation); + RHDRegWrite(MC, HDP_FB_LOCATION, MC->HdpFbAddress); +} + +/* + * + */ +static Bool +R500MCWaitIdle(struct rhdMC *MC) +{ + if (RHDReadMC(MC, MC_IND_ALL | R5XX_MC_STATUS) & R5XX_MC_IDLE) + return TRUE; + return FALSE; +} + +/* + * + */ +static CARD64 +R500MCGetFBLocation(struct rhdMC *MC, CARD32 *Size) +{ + return R5xxMCGetFBLocation(RHDReadMC(MC, R5XX_MC_FB_LOCATION | MC_IND_ALL), Size); +} + +/* + * + */ +static void +R500MCSetupFBLocation(struct rhdMC *MC, CARD64 Address, CARD32 Size) +{ + RHDWriteMC(MC, R5XX_MC_FB_LOCATION | MC_IND_ALL, + R5XX_FB_LOCATION(Address, Size)); + RHDRegWrite(MC, HDP_FB_LOCATION, R5XX_HDP_LOCATION(Address)); +} + +/* + * + */ +static void +RS600MCSave(struct rhdMC *MC) +{ + MC->FbLocation = RHDReadMC(MC, RS60_NB_FB_LOCATION); + MC->HdpFbAddress = RHDRegRead(MC, HDP_FB_LOCATION); +} + +/* + * + */ +static void +RS600MCRestore(struct rhdMC *MC) +{ + RHDWriteMC(MC, RS60_NB_FB_LOCATION, MC->FbLocation); + RHDRegWrite(MC, HDP_FB_LOCATION, MC->HdpFbAddress); +} + +/* + * + */ +static Bool +RS600MCWaitIdle(struct rhdMC *MC) +{ + if (RHDReadMC(MC, RS60_MC_SYSTEM_STATUS) & RS6X_MC_SEQUENCER_IDLE) + return TRUE; + return FALSE; +} + +/* + * + */ +static CARD64 +RS600MCGetFBLocation(struct rhdMC *MC, CARD32 *Size) +{ + return R5xxMCGetFBLocation(RHDReadMC(MC, RS60_NB_FB_LOCATION), Size); +} + +/* + * + */ +static void +RS600MCSetupFBLocation(struct rhdMC *MC, CARD64 Address, CARD32 Size) +{ + RHDWriteMC(MC, RS60_NB_FB_LOCATION, R5XX_FB_LOCATION(Address, Size)); + RHDRegWrite(MC, HDP_FB_LOCATION, R5XX_HDP_LOCATION(Address)); +} + +/* + * + */ +static void +RS690MCSave(struct rhdMC *MC) +{ + MC->FbLocation = RHDReadMC(MC, RS69_MCCFG_FB_LOCATION); + MC->HdpFbAddress = RHDRegRead(MC, HDP_FB_LOCATION); + MC->MiscLatencyTimer = RHDReadMC(MC, RS69_MC_INIT_MISC_LAT_TIMER); + +} + +/* + * + */ +static void +RS690MCRestore(struct rhdMC *MC) +{ + RHDWriteMC(MC, RS69_MCCFG_FB_LOCATION, MC->FbLocation); + RHDRegWrite(MC, HDP_FB_LOCATION, MC->HdpFbAddress); + RHDWriteMC(MC, RS69_MC_INIT_MISC_LAT_TIMER, MC->MiscLatencyTimer); +} + +/* + * + */ +static Bool +RS690MCWaitIdle(struct rhdMC *MC) +{ + if (RHDReadMC(MC, RS69_MC_SYSTEM_STATUS) & RS6X_MC_SEQUENCER_IDLE) + return TRUE; + return FALSE; +} + +/* + * + */ +static CARD64 +RS690MCGetFBLocation(struct rhdMC *MC, CARD32 *Size) +{ + return R5xxMCGetFBLocation(RHDReadMC(MC, RS69_MCCFG_FB_LOCATION), Size); +} + +/* + * + */ +static void +RS690MCSetupFBLocation(struct rhdMC *MC, CARD64 Address, CARD32 Size) +{ + RHDWriteMC(MC, RS69_MCCFG_FB_LOCATION, R5XX_FB_LOCATION(Address, Size)); + RHDRegWrite(MC, HDP_FB_LOCATION, R5XX_HDP_LOCATION(Address)); +} + +/* + * + */ +static void +RS690MCTuneMCAccessForDisplay(struct rhdMC *MC, int Crtc, + DisplayModePtr Mode, DisplayModePtr ScaledToMode) +{ + CARD32 value, setting = 0x1; + + value = RHDReadMC(MC, RS69_MC_INIT_MISC_LAT_TIMER); + + if (Crtc == RHD_CRTC_1) { + value &= ~(0x0F << MC_DISP0R_INIT_LAT_SHIFT); + value |= setting << MC_DISP0R_INIT_LAT_SHIFT; + } else { /* RHD_CRTC_2 */ + value &= ~(0x0F << MC_DISP1R_INIT_LAT_SHIFT); + value |= setting << MC_DISP1R_INIT_LAT_SHIFT; + } + + RHDWriteMC(MC, RS69_MC_INIT_MISC_LAT_TIMER, value); +} + +/* + * + */ +static void +R600MCSave(struct rhdMC *MC) +{ + MC->FbLocation = RHDRegRead(MC, R6XX_MC_VM_FB_LOCATION); + MC->HdpFbAddress = RHDRegRead(MC, R6XX_HDP_NONSURFACE_BASE); +} + +/* + * + */ +static void +R600MCRestore(struct rhdMC *MC) +{ + RHDRegWrite(MC, R6XX_MC_VM_FB_LOCATION, MC->FbLocation); + RHDRegWrite(MC, R6XX_HDP_NONSURFACE_BASE, MC->HdpFbAddress); +} + +/* + * + */ +static Bool +R600MCWaitIdle(struct rhdMC *MC) +{ + if (!(RHDRegRead(MC, SRBM_STATUS) & 0x3f00)) + return TRUE; + return FALSE; +} + + +/* + * + */ +static CARD64 +R600MCGetFBLocation(struct rhdMC *MC, CARD32 *Size) +{ + return R6xxMCGetFBLocation(RHDRegRead(MC, R6XX_MC_VM_FB_LOCATION), Size); +} + +/* + * + */ +static void +R600MCSetupFBLocation(struct rhdMC *MC, CARD64 Address, CARD32 Size) +{ + RHDRegWrite(MC, R6XX_MC_VM_FB_LOCATION, R6XX_FB_LOCATION(Address, Size)); + RHDRegWrite(MC, R6XX_HDP_NONSURFACE_BASE, R6XX_HDP_LOCATION(Address)); +} + +/* + * + */ +#ifdef NOTYET + +/* + * + */ +static void +RS780MCSave(struct rhdMC *MC) +{ + MC->FbLocation = RHDReadMC(MC, RS78_MC_FB_LOCATION); + MC->HdpFbAddress = RHDRegRead(MC, R6XX_HDP_NONSURFACE_BASE); +} + +/* + * + */ +static void +RS780MCRestore(struct rhdMC *MC) +{ + RHDWriteMC(MC, RS78_MC_FB_LOCATION, MC->FbLocation); + RHDRegWrite(MC, R6XX_HDP_NONSURFACE_BASE, MC->HdpFbAddress); +} + +/* + * + */ +static Bool +RS780MCWaitIdle(struct rhdMC *MC) +{ + if (RHDReadMC(MC, RS78_MC_SYSTEM_STATUS) & RS78_MC_SEQUENCER_IDLE) + return TRUE; + return FALSE; +} + +/* + * + */ +static CARD64 +RS780MCGetFBLocation(struct rhdMC *MC, CARD32 *Size) +{ + /* is this correct? */ + + return R5xxMCGetFBLocation(RHDReadMC(MC, RS78_MC_FB_LOCATION), Size); +} + +/* + * + */ +static void +RS780MCSetupFBLocation(struct rhdMC *MC, CARD64 Address, CARD32 Size) +{ + /* is this correct? */ + RHDWriteMC(MC, RS78_MC_FB_LOCATION, R5XX_FB_LOCATION(Address, Size)); + RHDRegWrite(MC, R6XX_HDP_NONSURFACE_BASE, R6XX_HDP_LOCATION(Address)); +} +#endif /* NOTYET */ + +/* + * + */ +static void +R700MCSave(struct rhdMC *MC) +{ + MC->FbLocation = RHDRegRead(MC, R7XX_MC_VM_FB_LOCATION); + MC->HdpFbAddress = RHDRegRead(MC, R6XX_HDP_NONSURFACE_BASE); +} + +/* + * + */ +static void +R700MCRestore(struct rhdMC *MC) +{ + RHDFUNC(MC); + + RHDRegWrite(MC, R7XX_MC_VM_FB_LOCATION, MC->FbLocation); + RHDRegWrite(MC, R6XX_HDP_NONSURFACE_BASE, MC->HdpFbAddress); +} + +/* + * Idle is the R600 one... + */ + +/* + * + */ +static CARD64 +R700MCGetFBLocation(struct rhdMC *MC, CARD32 *Size) +{ + return R6xxMCGetFBLocation(RHDRegRead(MC, R7XX_MC_VM_FB_LOCATION), Size); +} + +/* + * + */ +static void +R700MCSetupFBLocation(struct rhdMC *MC, CARD64 Address, CARD32 Size) +{ + RHDRegWrite(MC, R7XX_MC_VM_FB_LOCATION, R6XX_FB_LOCATION(Address, Size)); + RHDRegWrite(MC, R6XX_HDP_NONSURFACE_BASE, R6XX_HDP_LOCATION(Address)); +} + + +/* + * + */ +void +RHDMCInit(RHDPtr rhdPtr) +{ + struct rhdMC *MC; + + RHDFUNC(rhdPtr); + + /* These devices have an internal address reference, which some other + * address registers in there also use. This can be different from the + * address in the BAR. + * + * We read out the address here from some known location. This address + * is as good a guess as any, we just need to pick one, but then make + * sure that it is made consistent in MCSetupFBLocation and the various MC + * accessing subsystems. + */ + + RHDDebug(rhdPtr->scrnIndex, "MC FB Address: 0x%08X.\n", + rhdPtr->FbIntAddress); + + MC = xnfcalloc(1, sizeof(struct rhdMC)); + MC->scrnIndex = rhdPtr->scrnIndex; + + if (rhdPtr->ChipSet < RHD_RS600) { + switch(rhdPtr->ChipSet) { + case RHD_RV515: + case RHD_RV505: + case RHD_RV516: + case RHD_RV550: + case RHD_M52: + case RHD_M54: + case RHD_M62: + case RHD_M64: + case RHD_M71: + MC->Save = RV515MCSave; + MC->Restore = RV515MCRestore; + MC->SetupFBLocation = RV515MCSetupFBLocation; + MC->GetFBLocation = RV515MCGetFBLocation; + MC->Idle = RV515MCWaitIdle; + MC->TuneAccessForDisplay = RV515MCTuneMCAccessForDisplay; + break; + default: + MC->Save = R500MCSave; + MC->Restore = R500MCRestore; + MC->SetupFBLocation = R500MCSetupFBLocation; + MC->GetFBLocation = R500MCGetFBLocation; + MC->Idle = R500MCWaitIdle; + break; + } + + } else if (rhdPtr->ChipSet == RHD_RS600) { + MC->Save = RS600MCSave; + MC->Restore = RS600MCRestore; + MC->SetupFBLocation = RS600MCSetupFBLocation; + MC->Idle = RS600MCWaitIdle; + MC->GetFBLocation = RS600MCGetFBLocation; + } else if (rhdPtr->ChipSet < RHD_R600) { + MC->Save = RS690MCSave; + MC->Restore = RS690MCRestore; + MC->SetupFBLocation = RS690MCSetupFBLocation; + MC->Idle = RS690MCWaitIdle; + MC->GetFBLocation = RS690MCGetFBLocation; + MC->TuneAccessForDisplay = RS690MCTuneMCAccessForDisplay; + } else if (rhdPtr->ChipSet <= RHD_RS780) { + MC->Save = R600MCSave; + MC->Restore = R600MCRestore; + MC->SetupFBLocation = R600MCSetupFBLocation; + MC->Idle = R600MCWaitIdle; + MC->GetFBLocation = R600MCGetFBLocation; + } +#ifdef NOTYET + else if (rhdPtr->ChipSet == RHD_RS780) { + MC->Save = RS780MCSave; + MC->Restore = RS780MCRestore; + MC->SetupFBLocation = RS780MCSetupFBLocation; + MC->Idle = RS780MCWaitIdle; + MC->GetFBLocation = RS780MCGetFBLocation; + } +#endif /* NOTYET */ + else if (rhdPtr->ChipSet >= RHD_RV770) { + MC->Save = R700MCSave; + MC->Restore = R700MCRestore; + MC->SetupFBLocation = R700MCSetupFBLocation; + MC->Idle = R600MCWaitIdle; + MC->GetFBLocation = R700MCGetFBLocation; + } else { + xf86DrvMsg(rhdPtr->scrnIndex, X_ERROR, "I don't know anything about MC on this chipset\n"); + xfree(MC); + return; + } + if (rhdPtr->ChipSet < RHD_R600) + rhdPtr->FbIntAddress = RHDRegRead(rhdPtr, HDP_FB_LOCATION) << 16; + else + rhdPtr->FbIntAddress = RHDRegRead(rhdPtr, R6XX_CONFIG_FB_BASE); + MC->GetFBLocation(MC, &rhdPtr->FbIntSize); + + rhdPtr->MC = MC; + +} + +/* + * Free structure. + */ +void +RHDMCDestroy(RHDPtr rhdPtr) +{ + RHDFUNC(rhdPtr); + + if (!rhdPtr->MC) + return; + + xfree(rhdPtr->MC); + rhdPtr->MC = NULL; +} + +/* + * + */ +void +RHDMCSave(RHDPtr rhdPtr) +{ + struct rhdMC *MC = rhdPtr->MC; + + ASSERT(MC); + + RHDFUNC(rhdPtr); + + MC->Save(MC); + + MC->Stored = TRUE; +} + +/* + * Make sure that nothing is accessing memory anymore before calling this. + */ +void +RHDMCRestore(RHDPtr rhdPtr) +{ + struct rhdMC *MC = rhdPtr->MC; + + // ASSERT(MC); + // RHD_UNSETDEBUGFLAG(rhdPtr, MC_SETUP); + + RHDFUNC(rhdPtr); + + if (!MC->Stored) { + xf86DrvMsg(rhdPtr->scrnIndex, X_ERROR, + "%s: trying to restore uninitialized values.\n",__func__); + return; + } + + if (MC->Idle(MC)) + MC->Restore(MC); + else + xf86DrvMsg(rhdPtr->scrnIndex, X_ERROR, + "%s: MC is still not idle!!!\n", __func__); +} + +/* + * + */ +Bool +RHDMCIdleWait(RHDPtr rhdPtr, CARD32 count) +{ + struct rhdMC *MC = rhdPtr->MC; + + RHDFUNC(rhdPtr); + + ASSERT(MC); + + do { + if (MC->Idle(MC)) + return TRUE; + usleep(100); + } while (count--); + + RHDDebug(rhdPtr->scrnIndex, "%s: MC not idle\n",__func__); + + return FALSE; +} + +/* + * Get FB location and size. + */ +CARD64 +RHDMCGetFBLocation(RHDPtr rhdPtr, CARD32 *size) +{ + struct rhdMC *MC = rhdPtr->MC; + + // ASSERT(MC); + // ASSERT(size); + + RHDFUNC(rhdPtr); + + return MC->GetFBLocation(MC, size); +} + +/* + * Make sure that nothing is accessing memory anymore before calling this. + */ +Bool +RHDMCSetupFBLocation(RHDPtr rhdPtr, CARD64 Address, CARD32 Size) +{ + struct rhdMC *MC = rhdPtr->MC; + CARD64 OldAddress; + CARD32 OldSize; + + // ASSERT(MC); + // RHD_SETDEBUGFLAG(rhdPtr, MC_SETUP); + + RHDFUNC(rhdPtr); + + if (!MC->Idle(MC)) { + xf86DrvMsg(rhdPtr->scrnIndex, X_ERROR, + "%s: Cannot setup MC: not idle!!!\n", __func__); + return FALSE; + } + + OldAddress = MC->GetFBLocation(MC, &OldSize); + if (OldAddress == Address && OldSize == Size) + return TRUE; + + /* If this ever occurs, we might have issues */ + if (OldAddress >> 32) + xf86DrvMsg(rhdPtr->scrnIndex, X_WARNING, "%s: Board claims to use a " + "higher than 32bit address for its FB\n", __func__); + + RHDDebug(rhdPtr->scrnIndex, + "Setting MC from 0x%08X to 0x%08X [Size 0x%08X]\n", + OldAddress, rhdPtr->FbIntAddress, Size); + + MC->SetupFBLocation(MC, Address, Size); + + return TRUE; +} + +/* + * + */ +void +RHDMCTuneAccessForDisplay(RHDPtr rhdPtr, int Crtc, + DisplayModePtr Mode, DisplayModePtr ScaledToMode) +{ + struct rhdMC *MC = rhdPtr->MC; + + ASSERT(MC); + + RHDFUNC(rhdPtr); + + if (MC->TuneAccessForDisplay) + MC->TuneAccessForDisplay(MC, Crtc, Mode, ScaledToMode); +} + +/* + * + */ +Bool +RHD_MC_IGP_SideportMemoryPresent(RHDPtr rhdPtr) +{ + Bool Present = FALSE; + + RHDFUNC(rhdPtr); + + switch (rhdPtr->ChipSet) { + case RHD_RS690: + case RHD_RS740: + Present = (RHDReadMC(rhdPtr, RS69_MC_MISC_UMA_CNTL) & RS69_SIDE_PORT_PRESENT_R) != 0; + break; + case RHD_RS780: + Present = (RHDReadMC(rhdPtr, RS78_MC_MISC_UMA_CNTL) & RS78_SIDE_PORT_PRESENT_R) != 0; + break; + default: + break; + } + xf86DrvMsg(rhdPtr->scrnIndex, X_INFO, "IGP sideport memory %s present.\n", Present ? "" : "not"); + + return Present; +} diff --git a/programs/system/drivers/rhd/rhd_mc.h b/drivers/video/radeonhd/rhd_mc.h similarity index 79% rename from programs/system/drivers/rhd/rhd_mc.h rename to drivers/video/radeonhd/rhd_mc.h index a0481cdbc4..f8a5af1ee6 100644 --- a/programs/system/drivers/rhd/rhd_mc.h +++ b/drivers/video/radeonhd/rhd_mc.h @@ -27,13 +27,13 @@ extern void RHDMCInit(RHDPtr rhdPtr); extern void RHDMCDestroy(RHDPtr rhdPtr); -extern void RHDSaveMC(RHDPtr rhdPtr); -extern void RHDRestoreMC(RHDPtr rhdPtr); -extern void RHDMCSetup(RHDPtr rhdPtr); -extern Bool RHDMCIdle(RHDPtr rhdPtr, CARD32 count); -extern void RHDTuneMCAccessForDisplay(RHDPtr rhdPtr, int crtc, - DisplayModePtr Mode, DisplayModePtr ScaledToMode); -extern CARD32 RHDGetFBLocation(RHDPtr rhdPtr, CARD32 *size); +extern void RHDMCSave(RHDPtr rhdPtr); +extern void RHDMCRestore(RHDPtr rhdPtr); +extern Bool RHDMCSetupFBLocation(RHDPtr rhdPtr, CARD64 Address, CARD32 Size); +extern Bool RHDMCIdleWait(RHDPtr rhdPtr, CARD32 count); +extern void RHDMCTuneAccessForDisplay(RHDPtr rhdPtr, int Crtc, DisplayModePtr Mode, + DisplayModePtr ScaledToMode); +extern CARD64 RHDMCGetFBLocation(RHDPtr rhdPtr, CARD32 *size); extern Bool RHD_MC_IGP_SideportMemoryPresent(RHDPtr rhdPtr); diff --git a/programs/system/drivers/rhd/rhd_mem.c b/drivers/video/radeonhd/rhd_mem.c similarity index 100% rename from programs/system/drivers/rhd/rhd_mem.c rename to drivers/video/radeonhd/rhd_mem.c diff --git a/programs/system/drivers/rhd/rhd_modes.c b/drivers/video/radeonhd/rhd_modes.c similarity index 99% rename from programs/system/drivers/rhd/rhd_modes.c rename to drivers/video/radeonhd/rhd_modes.c index 073385464e..110b3b79a5 100644 --- a/programs/system/drivers/rhd/rhd_modes.c +++ b/drivers/video/radeonhd/rhd_modes.c @@ -1008,11 +1008,11 @@ struct { { MODE_MINHEIGHT, "Height too low."}, { MODE_FIXED, "Mode not compatible with fixed mode."}, { MODE_SCALE, "Mode cannot be scaled to fixed mode."}, + { MODE_NO_ENCODER, "No encoder available for this output."}, { 0, NULL} }; -const char * -xf86ModeStatusToString(ModeStatus status) +const char * xf86ModeStatusToString(ModeStatus status) { switch (status) { case MODE_OK: @@ -1092,7 +1092,9 @@ xf86ModeStatusToString(ModeStatus status) } } -const char *RHDModeStatusToString(int Status) + +const char * +RHDModeStatusToString(int Status) { if ((Status & 0xFFF00) == RHD_MODE_STATUS) { int i; diff --git a/programs/system/drivers/rhd/rhd_modes.h b/drivers/video/radeonhd/rhd_modes.h similarity index 100% rename from programs/system/drivers/rhd/rhd_modes.h rename to drivers/video/radeonhd/rhd_modes.h diff --git a/programs/system/drivers/rhd/rhd_monitor.c b/drivers/video/radeonhd/rhd_monitor.c similarity index 100% rename from programs/system/drivers/rhd/rhd_monitor.c rename to drivers/video/radeonhd/rhd_monitor.c diff --git a/programs/system/drivers/rhd/rhd_monitor.h b/drivers/video/radeonhd/rhd_monitor.h similarity index 100% rename from programs/system/drivers/rhd/rhd_monitor.h rename to drivers/video/radeonhd/rhd_monitor.h diff --git a/programs/system/drivers/rhd/rhd_output.c b/drivers/video/radeonhd/rhd_output.c similarity index 100% rename from programs/system/drivers/rhd/rhd_output.c rename to drivers/video/radeonhd/rhd_output.c diff --git a/programs/system/drivers/rhd/rhd_output.h b/drivers/video/radeonhd/rhd_output.h similarity index 100% rename from programs/system/drivers/rhd/rhd_output.h rename to drivers/video/radeonhd/rhd_output.h diff --git a/programs/system/drivers/rhd/rhd_pll.c b/drivers/video/radeonhd/rhd_pll.c similarity index 100% rename from programs/system/drivers/rhd/rhd_pll.c rename to drivers/video/radeonhd/rhd_pll.c diff --git a/programs/system/drivers/rhd/rhd_pll.h b/drivers/video/radeonhd/rhd_pll.h similarity index 100% rename from programs/system/drivers/rhd/rhd_pll.h rename to drivers/video/radeonhd/rhd_pll.h diff --git a/programs/system/drivers/rhd/rhd_regs.h b/drivers/video/radeonhd/rhd_regs.h similarity index 100% rename from programs/system/drivers/rhd/rhd_regs.h rename to drivers/video/radeonhd/rhd_regs.h diff --git a/programs/system/drivers/rhd/rhd_tmds.c b/drivers/video/radeonhd/rhd_tmds.c similarity index 100% rename from programs/system/drivers/rhd/rhd_tmds.c rename to drivers/video/radeonhd/rhd_tmds.c diff --git a/programs/system/drivers/rhd/rhd_vga.c b/drivers/video/radeonhd/rhd_vga.c similarity index 50% rename from programs/system/drivers/rhd/rhd_vga.c rename to drivers/video/radeonhd/rhd_vga.c index 8faecc86ba..39f0b8b287 100644 --- a/programs/system/drivers/rhd/rhd_vga.c +++ b/drivers/video/radeonhd/rhd_vga.c @@ -1,8 +1,7 @@ /* - * Copyright 2007 Luc Verhaegen - * Copyright 2007 Matthias Hopf - * Copyright 2007 Egbert Eich - * Copyright 2007 Advanced Micro Devices, Inc. + * Copyright 2007-2008 Luc Verhaegen + * Copyright 2007-2008 Matthias Hopf + * Copyright 2007-2008 Egbert Eich * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -37,13 +36,29 @@ #include "rhd_regs.h" #include "rhd_mc.h" +struct rhdVGA { + Bool Stored; + + CARD32 FBOffset; + CARD8 *FB; + int FBSize; /* 256kB */ + + CARD32 Render_Control; + CARD32 Mode_Control; + CARD32 HDP_Control; + CARD32 D1_Control; + CARD32 D2_Control; +}; + /* * */ void RHDVGAInit(RHDPtr rhdPtr) { - static struct rhdVGA VGA; + struct rhdVGA *VGA; + + RHDFUNC(rhdPtr); /* Check whether one of our VGA bits is set */ if (!(_RHDRegRead(rhdPtr, VGA_RENDER_CONTROL) & 0x00030000) && @@ -52,55 +67,105 @@ RHDVGAInit(RHDPtr rhdPtr) !(_RHDRegRead(rhdPtr, D2VGA_CONTROL) & 0x00000001)) return; - DBG(dbgprintf("Detected VGA mode.\n")); + xf86DrvMsg(rhdPtr->scrnIndex, X_INFO, "Detected VGA mode.\n"); - VGA.Stored = FALSE; - rhdPtr->VGA = &VGA; + VGA = xnfcalloc(sizeof(struct rhdVGA), 1); + VGA->Stored = FALSE; + + rhdPtr->VGA = VGA; } #if 0 /* * */ -void -RHDVGASave(RHDPtr rhdPtr) +static CARD32 +rhdVGAFBOffsetGet(RHDPtr rhdPtr) { - struct rhdVGA *VGA = &rhdPtr->VGA; + CARD32 FBSize, VGAFBOffset, VGAFBSize = 256 * 1024; + CARD64 FBAddress = RHDMCGetFBLocation(rhdPtr, &FBSize); + CARD64 VGAFBAddress = RHDRegRead(rhdPtr, VGA_MEMORY_BASE_ADDRESS); - VGA->Render_Control = _RHDRegRead(rhdPtr, VGA_RENDER_CONTROL); - VGA->Mode_Control = _RHDRegRead(rhdPtr, VGA_MODE_CONTROL); - VGA->HDP_Control = _RHDRegRead(rhdPtr, VGA_HDP_CONTROL); - VGA->D1_Control = _RHDRegRead(rhdPtr, D1VGA_CONTROL); - VGA->D2_Control = _RHDRegRead(rhdPtr, D2VGA_CONTROL); + if (VGAFBAddress < FBAddress) + return 0xFFFFFFFF; - /* Store our VGA FB */ - VGA->FBOffset = - _RHDRegRead(rhdPtr, VGA_MEMORY_BASE_ADDRESS) - rhdPtr->FbIntAddress; + if ((VGAFBAddress + VGAFBSize) > (FBAddress + FBSize)) + return 0xFFFFFFFF; + + VGAFBOffset = VGAFBAddress - FBAddress; /* < FBSize, so 32bit */ + + if ((VGAFBOffset + VGAFBSize) >= rhdPtr->FbMapSize) + return 0xFFFFFFFF; + + return VGAFBOffset; +} + +/* + * This is (usually) ok, as VGASave is called after the memory has been mapped, + * but before the MC is set up. So the use of RHDMCGetFBLocation is correct in + * rhdVGAFBOffsetGet. + */ +static void +rhdVGASaveFB(RHDPtr rhdPtr) +{ + struct rhdVGA *VGA = rhdPtr->VGA; + + ASSERT(rhdPtr->FbBase); + + RHDFUNC(rhdPtr); + + VGA->FBOffset = rhdVGAFBOffsetGet(rhdPtr); + + if (VGA->FBOffset == 0xFFFFFFFF) { + xf86DrvMsg(rhdPtr->scrnIndex, X_WARNING, "%s: Unable to access the VGA " + "framebuffer (0x%08X)\n", __func__, + (unsigned int) RHDRegRead(rhdPtr, VGA_MEMORY_BASE_ADDRESS)); + if (VGA->FB) + xfree(VGA->FB); + VGA->FB = NULL; + VGA->FBSize = 0; + return; + } - /* Could be that the VGA internal address no longer is pointing to what - we know as our FB memory, in which case we should give up cleanly. */ - if (VGA->FBOffset < (unsigned) (rhdPtr->videoRam * 1024)) { VGA->FBSize = 256 * 1024; - VGA->FB = calloc(VGA->FBSize, 1); + + RHDDebug(rhdPtr->scrnIndex, "%s: VGA FB Offset 0x%08X [0x%08X]\n", + __func__, VGA->FBOffset, VGA->FBSize); + + if (!VGA->FB) + VGA->FB = xcalloc(VGA->FBSize, 1); + if (VGA->FB) memcpy(VGA->FB, ((CARD8 *) rhdPtr->FbBase) + VGA->FBOffset, VGA->FBSize); else { - dbgprintf("%s: Failed to allocate" + xf86DrvMsg(rhdPtr->scrnIndex, X_WARNING, "%s: Failed to allocate" " space for storing the VGA framebuffer.\n", __func__); - VGA->FBSize = 0; - VGA->FB = NULL; - } - } else { - dbgprintf("%s: VGA FB Offset (0x%08X) is " - "out of range of the Cards Internal FB Address (0x%08X)\n", - __func__, (int) RHDRegRead(rhdPtr, VGA_MEMORY_BASE_ADDRESS), - rhdPtr->FbIntAddress); VGA->FBOffset = 0xFFFFFFFF; VGA->FBSize = 0; - VGA->FB = NULL; } +} +/* + * + */ +void +RHDVGASave(RHDPtr rhdPtr) +{ + struct rhdVGA *VGA = rhdPtr->VGA; + + RHDFUNC(rhdPtr); + + if (!VGA) + return; /* We don't need to warn , this is intended use */ + + VGA->Render_Control = RHDRegRead(rhdPtr, VGA_RENDER_CONTROL); + VGA->Mode_Control = RHDRegRead(rhdPtr, VGA_MODE_CONTROL); + VGA->HDP_Control = RHDRegRead(rhdPtr, VGA_HDP_CONTROL); + VGA->D1_Control = RHDRegRead(rhdPtr, D1VGA_CONTROL); + VGA->D2_Control = RHDRegRead(rhdPtr, D2VGA_CONTROL); + + rhdVGASaveFB(rhdPtr); VGA->Stored = TRUE; } @@ -118,19 +183,21 @@ RHDVGARestore(RHDPtr rhdPtr) return; /* We don't need to warn , this is intended use */ if (!VGA->Stored) { - dbgprintf("%s: trying to restore uninitialized values.\n", __func__); + xf86DrvMsg(rhdPtr->scrnIndex, X_ERROR, + "%s: trying to restore uninitialized values.\n", __func__); return; } if (VGA->FB) - memcpy(((CARD8 *) rhdPtr->FbBase) + VGA->FBOffset, - VGA->FB, VGA->FBSize); + memcpy(((CARD8 *) rhdPtr->FbBase) + VGA->FBOffset, VGA->FB, + VGA->FBSize); RHDRegWrite(rhdPtr, VGA_RENDER_CONTROL, VGA->Render_Control); RHDRegWrite(rhdPtr, VGA_MODE_CONTROL, VGA->Mode_Control); RHDRegWrite(rhdPtr, VGA_HDP_CONTROL, VGA->HDP_Control); RHDRegWrite(rhdPtr, D1VGA_CONTROL, VGA->D1_Control); RHDRegWrite(rhdPtr, D2VGA_CONTROL, VGA->D2_Control); + RHD_UNSETDEBUGFLAG(rhdPtr, VGA_SETUP); } #endif /* @@ -144,8 +211,8 @@ RHDVGADisable(RHDPtr rhdPtr) _RHDRegMask(rhdPtr, VGA_RENDER_CONTROL, 0, 0x00030000); _RHDRegMask(rhdPtr, VGA_MODE_CONTROL, 0, 0x00000030); _RHDRegMask(rhdPtr, VGA_HDP_CONTROL, 0x00010010, 0x00010010); - _RHDRegMask(rhdPtr, D1VGA_CONTROL, 0, 0x00000001); - _RHDRegMask(rhdPtr, D2VGA_CONTROL, 0, 0x00000001); + RHDRegMask(rhdPtr, D1VGA_CONTROL, 0, D1VGA_MODE_ENABLE); + RHDRegMask(rhdPtr, D2VGA_CONTROL, 0, D2VGA_MODE_ENABLE); } /* @@ -162,8 +229,8 @@ RHDVGADestroy(RHDPtr rhdPtr) return; /* We don't need to warn , this is intended use */ if (VGA->FB) - free(VGA->FB); - rhdPtr->VGA=NULL; + xfree(VGA->FB); + xfree(VGA); } diff --git a/programs/system/drivers/rhd/rhd_vga.h b/drivers/video/radeonhd/rhd_vga.h similarity index 74% rename from programs/system/drivers/rhd/rhd_vga.h rename to drivers/video/radeonhd/rhd_vga.h index 7745372164..59cbd17420 100644 --- a/programs/system/drivers/rhd/rhd_vga.h +++ b/drivers/video/radeonhd/rhd_vga.h @@ -1,8 +1,7 @@ /* - * Copyright 2007 Luc Verhaegen - * Copyright 2007 Matthias Hopf - * Copyright 2007 Egbert Eich - * Copyright 2007 Advanced Micro Devices, Inc. + * Copyright 2007-2008 Luc Verhaegen + * Copyright 2007-2008 Matthias Hopf + * Copyright 2007-2008 Egbert Eich * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -26,20 +25,6 @@ #ifndef _RHD_VGA_H #define _RHD_VGA_H -struct rhdVGA { - Bool Stored; - - CARD32 FBBase; - CARD8 *FB; - int FBSize; /* most cases, 256kB */ - - CARD32 Render_Control; - CARD32 Mode_Control; - CARD32 HDP_Control; - CARD32 D1_Control; - CARD32 D2_Control; -}; - void RHDVGAInit(RHDPtr rhdPtr); void RHDVGASave(RHDPtr rhdPtr); void RHDVGARestore(RHDPtr rhdPtr); diff --git a/programs/system/drivers/rhd/s_ceilf.asm b/drivers/video/radeonhd/s_ceilf.asm similarity index 100% rename from programs/system/drivers/rhd/s_ceilf.asm rename to drivers/video/radeonhd/s_ceilf.asm diff --git a/programs/system/drivers/rhd/stdio.h b/drivers/video/radeonhd/stdio.h similarity index 100% rename from programs/system/drivers/rhd/stdio.h rename to drivers/video/radeonhd/stdio.h diff --git a/programs/system/drivers/rhd/string.c b/drivers/video/radeonhd/string.c similarity index 100% rename from programs/system/drivers/rhd/string.c rename to drivers/video/radeonhd/string.c diff --git a/programs/system/drivers/rhd/stub.asm b/drivers/video/radeonhd/stub.asm similarity index 100% rename from programs/system/drivers/rhd/stub.asm rename to drivers/video/radeonhd/stub.asm diff --git a/programs/system/drivers/rhd/vdif.h b/drivers/video/radeonhd/vdif.h similarity index 100% rename from programs/system/drivers/rhd/vdif.h rename to drivers/video/radeonhd/vdif.h diff --git a/programs/system/drivers/rhd/vsprintf.c b/drivers/video/radeonhd/vsprintf.c similarity index 100% rename from programs/system/drivers/rhd/vsprintf.c rename to drivers/video/radeonhd/vsprintf.c diff --git a/programs/system/drivers/rhd/xf86.h b/drivers/video/radeonhd/xf86.h similarity index 100% rename from programs/system/drivers/rhd/xf86.h rename to drivers/video/radeonhd/xf86.h diff --git a/programs/system/drivers/rhd/xf86DDC.h b/drivers/video/radeonhd/xf86DDC.h similarity index 100% rename from programs/system/drivers/rhd/xf86DDC.h rename to drivers/video/radeonhd/xf86DDC.h diff --git a/programs/system/drivers/rhd/xf86i2c.c b/drivers/video/radeonhd/xf86i2c.c similarity index 100% rename from programs/system/drivers/rhd/xf86i2c.c rename to drivers/video/radeonhd/xf86i2c.c diff --git a/programs/system/drivers/rhd/xf86i2c.h b/drivers/video/radeonhd/xf86i2c.h similarity index 100% rename from programs/system/drivers/rhd/xf86i2c.h rename to drivers/video/radeonhd/xf86i2c.h diff --git a/programs/develop/fast_call_test/test.ASM b/programs/develop/fast_call_test/test.ASM index 7a79219999..d6f457002c 100644 --- a/programs/develop/fast_call_test/test.ASM +++ b/programs/develop/fast_call_test/test.ASM @@ -35,7 +35,7 @@ test1: mov eax, 1 mov ebx, 0x100000 align 32 -.nxt: mcall 19 ; функция пустышка +.nxt: ;mcall 19 ; функция пустышка ; портятся ecx, edx dec ebx jnz .nxt @@ -43,11 +43,8 @@ test1: mov eax, 1 xor eax, eax cpuid rdtsc - cmp eax, [old_tsc] - jnb @f - dec edx -@@: sub eax, [old_tsc] - sub edx, [old_tsc + 4] + sub eax, [old_tsc] + sbb edx, [old_tsc + 4] debug_print_hex edx debug_print_hex eax .end: print ' <- Fast call (SYSENTER)' @@ -74,7 +71,7 @@ test2: xor eax, eax mov ebx, 0x100000 align 32 -.nxt: mcall 19 ; функция пустышка +.nxt: ;mcall 19 ; функция пустышка dec ebx jnz .nxt @@ -82,16 +79,14 @@ test2: xor eax, eax xor eax, eax cpuid rdtsc - cmp eax, [old_tsc] - jnb @f - dec edx -@@: sub eax, [old_tsc] - sub edx, [old_tsc + 4] + + sub eax, [old_tsc] + sbb edx, [old_tsc + 4] debug_print_hex edx debug_print_hex eax .end: print ' <- Fast call (SYSCALL)' ;---------------------------------------------- - ; через шлюз прерывания + ; через шлюз прерывани __CPU_type equ p5 xor eax, eax cpuid @@ -101,18 +96,16 @@ test2: xor eax, eax test3: mov ebx, 0x100000 align 32 -.nxt: mcall 19 ; функция пустышка +.nxt: ;mcall 19 ; функция пустышка dec ebx jnz .nxt xor eax, eax cpuid rdtsc - cmp eax, [old_tsc] - jnb @f - dec edx -@@: sub eax, [old_tsc] - sub edx, [old_tsc + 4] + + sub eax, [old_tsc] + sbb edx, [old_tsc + 4] debug_print_hex edx debug_print_hex eax print ' <- Interrupt' diff --git a/programs/system/drivers/agp/pci.h b/programs/system/drivers/agp/pci.h deleted file mode 100644 index 90a2efedc4..0000000000 --- a/programs/system/drivers/agp/pci.h +++ /dev/null @@ -1,182 +0,0 @@ - - -#pragma pack(push, 1) -typedef struct -{ - u16_t device; - u16_t ChipSet; -}PciChipset_t; -#pragma pack(pop) - -#define VENDOR_ATI 0x1002 - - -#define PCI_CLASS_DISPLAY_VGA 0x0300 -/* - * Under PCI, each device has 256 bytes of configuration address space, - * of which the first 64 bytes are standardized as follows: - */ -#define PCI_VENDOR_ID 0x00 /* 16 bits */ -#define PCI_DEVICE_ID 0x02 /* 16 bits */ -#define PCI_COMMAND 0x04 /* 16 bits */ -#define PCI_COMMAND_IO 0x01 /* Enable response in I/O space */ -#define PCI_COMMAND_MEMORY 0x02 /* Enable response in Memory space */ -#define PCI_COMMAND_MASTER 0x04 /* Enable bus mastering */ -#define PCI_COMMAND_SPECIAL 0x08 /* Enable response to special cycles */ -#define PCI_COMMAND_INVALIDATE 0x10 /* Use memory write and invalidate */ -#define PCI_COMMAND_VGA_PALETTE 0x20 /* Enable palette snooping */ -#define PCI_COMMAND_PARITY 0x40 /* Enable parity checking */ -#define PCI_COMMAND_WAIT 0x80 /* Enable address/data stepping */ -#define PCI_COMMAND_SERR 0x100 /* Enable SERR */ -#define PCI_COMMAND_FAST_BACK 0x200 /* Enable back-to-back writes */ -#define PCI_COMMAND_INTX_DISABLE 0x400 /* INTx Emulation Disable */ - -#define PCI_STATUS 0x06 /* 16 bits */ -#define PCI_STATUS_CAP_LIST 0x10 /* Support Capability List */ -#define PCI_STATUS_66MHZ 0x20 /* Support 66 Mhz PCI 2.1 bus */ -#define PCI_STATUS_UDF 0x40 /* Support User Definable Features [obsolete] */ -#define PCI_STATUS_FAST_BACK 0x80 /* Accept fast-back to back */ -#define PCI_STATUS_PARITY 0x100 /* Detected parity error */ -#define PCI_STATUS_DEVSEL_MASK 0x600 /* DEVSEL timing */ -#define PCI_STATUS_DEVSEL_FAST 0x000 -#define PCI_STATUS_DEVSEL_MEDIUM 0x200 -#define PCI_STATUS_DEVSEL_SLOW 0x400 -#define PCI_STATUS_SIG_TARGET_ABORT 0x800 /* Set on target abort */ -#define PCI_STATUS_REC_TARGET_ABORT 0x1000 /* Master ack of " */ -#define PCI_STATUS_REC_MASTER_ABORT 0x2000 /* Set on master abort */ -#define PCI_STATUS_SIG_SYSTEM_ERROR 0x4000 /* Set when we drive SERR */ -#define PCI_STATUS_DETECTED_PARITY 0x8000 /* Set on parity error */ - -#define PCI_CLASS_REVISION 0x08 /* High 24 bits are class, low 8 revision */ -#define PCI_REVISION_ID 0x08 /* Revision ID */ -#define PCI_CLASS_PROG 0x09 /* Reg. Level Programming Interface */ -#define PCI_CLASS_DEVICE 0x0a /* Device class */ - -#define PCI_CACHE_LINE_SIZE 0x0c /* 8 bits */ -#define PCI_LATENCY_TIMER 0x0d /* 8 bits */ -#define PCI_HEADER_TYPE 0x0e /* 8 bits */ -#define PCI_HEADER_TYPE_NORMAL 0 -#define PCI_HEADER_TYPE_BRIDGE 1 -#define PCI_HEADER_TYPE_CARDBUS 2 - -#define PCI_BIST 0x0f /* 8 bits */ -#define PCI_BIST_CODE_MASK 0x0f /* Return result */ -#define PCI_BIST_START 0x40 /* 1 to start BIST, 2 secs or less */ -#define PCI_BIST_CAPABLE 0x80 /* 1 if BIST capable */ - -#define PCI_CAPABILITY_LIST 0x34 /* Offset of first capability list entry */ -#define PCI_CB_CAPABILITY_LIST 0x14 -/* Capability lists */ - -#define PCI_CAP_LIST_ID 0 /* Capability ID */ -#define PCI_CAP_ID_PM 0x01 /* Power Management */ -#define PCI_CAP_ID_AGP 0x02 /* Accelerated Graphics Port */ -#define PCI_CAP_ID_VPD 0x03 /* Vital Product Data */ -#define PCI_CAP_ID_SLOTID 0x04 /* Slot Identification */ -#define PCI_CAP_ID_MSI 0x05 /* Message Signalled Interrupts */ -#define PCI_CAP_ID_CHSWP 0x06 /* CompactPCI HotSwap */ -#define PCI_CAP_ID_PCIX 0x07 /* PCI-X */ -#define PCI_CAP_ID_HT 0x08 /* HyperTransport */ -#define PCI_CAP_ID_VNDR 0x09 /* Vendor specific capability */ -#define PCI_CAP_ID_SHPC 0x0C /* PCI Standard Hot-Plug Controller */ -#define PCI_CAP_ID_EXP 0x10 /* PCI Express */ -#define PCI_CAP_ID_MSIX 0x11 /* MSI-X */ -#define PCI_CAP_LIST_NEXT 1 /* Next capability in the list */ -#define PCI_CAP_FLAGS 2 /* Capability defined flags (16 bits) */ -#define PCI_CAP_SIZEOF 4 - - -/* AGP registers */ - -#define PCI_AGP_VERSION 2 /* BCD version number */ -#define PCI_AGP_RFU 3 /* Rest of capability flags */ -#define PCI_AGP_STATUS 4 /* Status register */ -#define PCI_AGP_STATUS_RQ_MASK 0xff000000 /* Maximum number of requests - 1 */ -#define PCI_AGP_STATUS_SBA 0x0200 /* Sideband addressing supported */ -#define PCI_AGP_STATUS_64BIT 0x0020 /* 64-bit addressing supported */ -#define PCI_AGP_STATUS_FW 0x0010 /* FW transfers supported */ -#define PCI_AGP_STATUS_RATE4 0x0004 /* 4x transfer rate supported */ -#define PCI_AGP_STATUS_RATE2 0x0002 /* 2x transfer rate supported */ -#define PCI_AGP_STATUS_RATE1 0x0001 /* 1x transfer rate supported */ -#define PCI_AGP_COMMAND 8 /* Control register */ -#define PCI_AGP_COMMAND_RQ_MASK 0xff000000 /* Master: Maximum number of requests */ -#define PCI_AGP_COMMAND_SBA 0x0200 /* Sideband addressing enabled */ -#define PCI_AGP_COMMAND_AGP 0x0100 /* Allow processing of AGP transactions */ -#define PCI_AGP_COMMAND_64BIT 0x0020 /* Allow processing of 64-bit addresses */ -#define PCI_AGP_COMMAND_FW 0x0010 /* Force FW transfers */ -#define PCI_AGP_COMMAND_RATE4 0x0004 /* Use 4x rate */ -#define PCI_AGP_COMMAND_RATE2 0x0002 /* Use 2x rate */ -#define PCI_AGP_COMMAND_RATE1 0x0001 /* Use 1x rate */ -#define PCI_AGP_SIZEOF 12 - - -#define PCI_MAP_REG_START 0x10 -#define PCI_MAP_REG_END 0x28 -#define PCI_MAP_ROM_REG 0x30 - -#define PCI_MAP_MEMORY 0x00000000 -#define PCI_MAP_IO 0x00000001 - -#define PCI_MAP_MEMORY_TYPE 0x00000007 -#define PCI_MAP_IO_TYPE 0x00000003 - -#define PCI_MAP_MEMORY_TYPE_32BIT 0x00000000 -#define PCI_MAP_MEMORY_TYPE_32BIT_1M 0x00000002 -#define PCI_MAP_MEMORY_TYPE_64BIT 0x00000004 -#define PCI_MAP_MEMORY_TYPE_MASK 0x00000006 -#define PCI_MAP_MEMORY_CACHABLE 0x00000008 -#define PCI_MAP_MEMORY_ATTR_MASK 0x0000000e -#define PCI_MAP_MEMORY_ADDRESS_MASK 0xfffffff0 - -#define PCI_MAP_IO_ATTR_MASK 0x00000003 - -#define PCI_MAP_IS_IO(b) ((b) & PCI_MAP_IO) -#define PCI_MAP_IS_MEM(b) (!PCI_MAP_IS_IO(b)) - -#define PCI_MAP_IS64BITMEM(b) \ - (((b) & PCI_MAP_MEMORY_TYPE_MASK) == PCI_MAP_MEMORY_TYPE_64BIT) - -#define PCIGETMEMORY(b) ((b) & PCI_MAP_MEMORY_ADDRESS_MASK) -#define PCIGETMEMORY64HIGH(b) (*((CARD32*)&b + 1)) -#define PCIGETMEMORY64(b) \ - (PCIGETMEMORY(b) | ((CARD64)PCIGETMEMORY64HIGH(b) << 32)) - -#define PCI_MAP_IO_ADDRESS_MASK 0xfffffffc - -#define PCIGETIO(b) ((b) & PCI_MAP_IO_ADDRESS_MASK) - -#define PCI_MAP_ROM_DECODE_ENABLE 0x00000001 -#define PCI_MAP_ROM_ADDRESS_MASK 0xfffff800 - -#define PCIGETROM(b) ((b) & PCI_MAP_ROM_ADDRESS_MASK) - - -#ifndef PCI_DOM_MASK -# define PCI_DOM_MASK 0x0ffu -#endif -#define PCI_DOMBUS_MASK (((PCI_DOM_MASK) << 8) | 0x0ffu) - -#define PCI_MAKE_TAG(b,d,f) ((((b) & (PCI_DOMBUS_MASK)) << 16) | \ - (((d) & 0x00001fu) << 11) | \ - (((f) & 0x000007u) << 8)) - -#define PCI_BUS_FROM_TAG(tag) (((tag) >> 16) & (PCI_DOMBUS_MASK)) -#define PCI_DEV_FROM_TAG(tag) (((tag) & 0x0000f800u) >> 11) -#define PCI_FUNC_FROM_TAG(tag) (((tag) & 0x00000700u) >> 8) -#define PCI_DFN_FROM_TAG(tag) (((tag) & 0x0000ff00u) >> 8) - - -typedef unsigned int PCITAG; - -extern inline PCITAG -pciTag(int busnum, int devnum, int funcnum) -{ - return(PCI_MAKE_TAG(busnum,devnum,funcnum)); -} - -const PciChipset_t *PciDevMatch(u16_t dev,const PciChipset_t *list); -u32_t pciGetBaseSize(int bus, int devfn, int index, Bool destructive, Bool *min); - -#define PCI_ANY_ID (~0) - -#define for_each_pci_dev(d) while ((d = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, d))!=-1) diff --git a/programs/system/drivers/ati2d/pci.h b/programs/system/drivers/ati2d/pci.h deleted file mode 100644 index b1d2de046e..0000000000 --- a/programs/system/drivers/ati2d/pci.h +++ /dev/null @@ -1,82 +0,0 @@ - - -#pragma pack(push, 1) -typedef struct -{ - u16_t device; - u16_t ChipSet; -}PciChipset_t; -#pragma pack(pop) - -#define VENDOR_ATI 0x1002 - - -#define PCI_MAP_REG_START 0x10 -#define PCI_MAP_REG_END 0x28 -#define PCI_MAP_ROM_REG 0x30 - -#define PCI_MAP_MEMORY 0x00000000 -#define PCI_MAP_IO 0x00000001 - -#define PCI_MAP_MEMORY_TYPE 0x00000007 -#define PCI_MAP_IO_TYPE 0x00000003 - -#define PCI_MAP_MEMORY_TYPE_32BIT 0x00000000 -#define PCI_MAP_MEMORY_TYPE_32BIT_1M 0x00000002 -#define PCI_MAP_MEMORY_TYPE_64BIT 0x00000004 -#define PCI_MAP_MEMORY_TYPE_MASK 0x00000006 -#define PCI_MAP_MEMORY_CACHABLE 0x00000008 -#define PCI_MAP_MEMORY_ATTR_MASK 0x0000000e -#define PCI_MAP_MEMORY_ADDRESS_MASK 0xfffffff0 - -#define PCI_MAP_IO_ATTR_MASK 0x00000003 - -#define PCI_MAP_IS_IO(b) ((b) & PCI_MAP_IO) -#define PCI_MAP_IS_MEM(b) (!PCI_MAP_IS_IO(b)) - -#define PCI_MAP_IS64BITMEM(b) \ - (((b) & PCI_MAP_MEMORY_TYPE_MASK) == PCI_MAP_MEMORY_TYPE_64BIT) - -#define PCIGETMEMORY(b) ((b) & PCI_MAP_MEMORY_ADDRESS_MASK) -#define PCIGETMEMORY64HIGH(b) (*((CARD32*)&b + 1)) -#define PCIGETMEMORY64(b) \ - (PCIGETMEMORY(b) | ((CARD64)PCIGETMEMORY64HIGH(b) << 32)) - -#define PCI_MAP_IO_ADDRESS_MASK 0xfffffffc - -#define PCIGETIO(b) ((b) & PCI_MAP_IO_ADDRESS_MASK) - -#define PCI_MAP_ROM_DECODE_ENABLE 0x00000001 -#define PCI_MAP_ROM_ADDRESS_MASK 0xfffff800 - -#define PCIGETROM(b) ((b) & PCI_MAP_ROM_ADDRESS_MASK) - - -#ifndef PCI_DOM_MASK -# define PCI_DOM_MASK 0x0ffu -#endif -#define PCI_DOMBUS_MASK (((PCI_DOM_MASK) << 8) | 0x0ffu) - -#define PCI_MAKE_TAG(b,d,f) ((((b) & (PCI_DOMBUS_MASK)) << 16) | \ - (((d) & 0x00001fu) << 11) | \ - (((f) & 0x000007u) << 8)) - -#define PCI_BUS_FROM_TAG(tag) (((tag) >> 16) & (PCI_DOMBUS_MASK)) -#define PCI_DEV_FROM_TAG(tag) (((tag) & 0x0000f800u) >> 11) -#define PCI_FUNC_FROM_TAG(tag) (((tag) & 0x00000700u) >> 8) -#define PCI_DFN_FROM_TAG(tag) (((tag) & 0x0000ff00u) >> 8) - - -#define PCI_CMD_STAT_REG 0x04 - - -typedef unsigned int PCITAG; - -extern inline PCITAG -pciTag(int busnum, int devnum, int funcnum) -{ - return(PCI_MAKE_TAG(busnum,devnum,funcnum)); -} - -const PciChipset_t *PciDevMatch(u16_t dev,const PciChipset_t *list); -u32_t pciGetBaseSize(int bus, int devfn, int index, Bool destructive, Bool *min); diff --git a/programs/system/drivers/rhd/pci.h b/programs/system/drivers/rhd/pci.h deleted file mode 100644 index df45a4124c..0000000000 --- a/programs/system/drivers/rhd/pci.h +++ /dev/null @@ -1,70 +0,0 @@ - -typedef unsigned long PCITAG; - -typedef struct { - int vendor; - int devtype; - int devRev; - int subsysVendor; - int subsysCard; - int bus; - int devfn; -// int func; - int class; - int subclass; - int interface; - memType memBase[6]; - memType ioBase[6]; - int size[6]; - unsigned char type[6]; - memType biosBase; - int biosSize; -// pointer thisCard; - Bool validSize; -// Bool validate; -// CARD32 listed_class; -} pciVideoRec, *pciVideoPtr; - - -#define PCI_MAP_REG_START 0x10 -#define PCI_MAP_REG_END 0x28 -#define PCI_MAP_ROM_REG 0x30 - -#define PCI_MAP_MEMORY 0x00000000 -#define PCI_MAP_IO 0x00000001 - -#define PCI_MAP_MEMORY_TYPE 0x00000007 -#define PCI_MAP_IO_TYPE 0x00000003 - -#define PCI_MAP_MEMORY_TYPE_32BIT 0x00000000 -#define PCI_MAP_MEMORY_TYPE_32BIT_1M 0x00000002 -#define PCI_MAP_MEMORY_TYPE_64BIT 0x00000004 -#define PCI_MAP_MEMORY_TYPE_MASK 0x00000006 -#define PCI_MAP_MEMORY_CACHABLE 0x00000008 -#define PCI_MAP_MEMORY_ATTR_MASK 0x0000000e -#define PCI_MAP_MEMORY_ADDRESS_MASK 0xfffffff0 - -#define PCI_MAP_IO_ATTR_MASK 0x00000003 - -#define PCI_MAP_IS_IO(b) ((b) & PCI_MAP_IO) -#define PCI_MAP_IS_MEM(b) (!PCI_MAP_IS_IO(b)) - -#define PCI_MAP_IS64BITMEM(b) \ - (((b) & PCI_MAP_MEMORY_TYPE_MASK) == PCI_MAP_MEMORY_TYPE_64BIT) - -#define PCIGETMEMORY(b) ((b) & PCI_MAP_MEMORY_ADDRESS_MASK) -#define PCIGETMEMORY64HIGH(b) (*((CARD32*)&b + 1)) -#define PCIGETMEMORY64(b) \ - (PCIGETMEMORY(b) | ((CARD64)PCIGETMEMORY64HIGH(b) << 32)) - -#define PCI_MAP_IO_ADDRESS_MASK 0xfffffffc - -#define PCIGETIO(b) ((b) & PCI_MAP_IO_ADDRESS_MASK) - -#define PCI_MAP_ROM_DECODE_ENABLE 0x00000001 -#define PCI_MAP_ROM_ADDRESS_MASK 0xfffff800 - -#define PCIGETROM(b) ((b) & PCI_MAP_ROM_ADDRESS_MASK) - -int pciGetBaseSize(int bus, int devfn, int index, Bool destructive, Bool *min); -int pciGetInfo(pciVideoPtr pci); diff --git a/programs/system/drivers/rhd/proc32.inc b/programs/system/drivers/rhd/proc32.inc deleted file mode 100644 index f623e7273d..0000000000 --- a/programs/system/drivers/rhd/proc32.inc +++ /dev/null @@ -1,269 +0,0 @@ - - -; Macroinstructions for defining and calling procedures - -macro stdcall proc,[arg] ; directly call STDCALL procedure - { common - if ~ arg eq - reverse - pushd arg - common - end if - call proc } - -macro invoke proc,[arg] ; indirectly call STDCALL procedure - { common - if ~ arg eq - reverse - pushd arg - common - end if - call [proc] } - -macro ccall proc,[arg] ; directly call CDECL procedure - { common - size@ccall = 0 - if ~ arg eq - reverse - pushd arg - size@ccall = size@ccall+4 - common - end if - call proc - if size@ccall - add esp,size@ccall - end if } - -macro cinvoke proc,[arg] ; indirectly call CDECL procedure - { common - size@ccall = 0 - if ~ arg eq - reverse - pushd arg - size@ccall = size@ccall+4 - common - end if - call [proc] - if size@ccall - add esp,size@ccall - end if } - -macro proc [args] ; define procedure - { common - match name params, args> - \{ define@proc name, \{ prologue name,flag,parmbytes,localbytes,reglist \} - macro locals - \{ virtual at ebp-localbytes+current - macro label . \\{ deflocal@proc .,:, \\} - struc db [val] \\{ \common deflocal@proc .,db,val \\} - struc dw [val] \\{ \common deflocal@proc .,dw,val \\} - struc dp [val] \\{ \common deflocal@proc .,dp,val \\} - struc dd [val] \\{ \common deflocal@proc .,dd,val \\} - struc dt [val] \\{ \common deflocal@proc .,dt,val \\} - struc dq [val] \\{ \common deflocal@proc .,dq,val \\} - struc rb cnt \\{ deflocal@proc .,rb cnt, \\} - struc rw cnt \\{ deflocal@proc .,rw cnt, \\} - struc rp cnt \\{ deflocal@proc .,rp cnt, \\} - struc rd cnt \\{ deflocal@proc .,rd cnt, \\} - struc rt cnt \\{ deflocal@proc .,rt cnt, \\} - struc rq cnt \\{ deflocal@proc .,rq cnt, \\} \} - macro endl - \{ purge label - restruc db,dw,dp,dd,dt,dq - restruc rb,rw,rp,rd,rt,rq - restruc byte,word,dword,pword,tword,qword - current = $-(ebp-localbytes) - end virtual \} - macro ret operand - \{ match any, operand \\{ retn operand \\} - match , operand \\{ match epilogue:reglist, epilogue@proc: - \\\{ epilogue name,flag,parmbytes,localbytes,reglist \\\} \\} \} - macro finish@proc \{ localbytes = (((current-1) shr 2)+1) shl 2 - end if \} } - -macro defargs@proc [arg] - { common - if ~ arg eq - forward - local ..arg,current@arg - match argname:type, arg - \{ current@arg equ argname - label ..arg type - argname equ ..arg - if dqword eq type - dd ?,?,?,? - else if tbyte eq type - dd ?,?,? - else if qword eq type | pword eq type - dd ?,? - else - dd ? - end if \} - match =current@arg,current@arg - \{ current@arg equ arg - arg equ ..arg - ..arg dd ? \} - common - args@proc equ current@arg - forward - restore current@arg - common - end if } - -macro deflocal@proc name,def,[val] - { common - match vars, all@vars \{ all@vars equ all@vars, \} - all@vars equ all@vars name - forward - local ..var,..tmp - ..var def val - match =?, val \{ ..tmp equ \} - match any =dup (=?), val \{ ..tmp equ \} - match tmp : value, ..tmp : val - \{ tmp: end virtual - initlocal@proc ..var,def value - virtual at tmp\} - common - match first rest, ..var, \{ name equ first \} } - -macro initlocal@proc name,def - { virtual at name - def - size@initlocal = $ - name - end virtual - position@initlocal = 0 - while size@initlocal > position@initlocal - virtual at name - def - if size@initlocal - position@initlocal < 2 - current@initlocal = 1 - load byte@initlocal byte from name+position@initlocal - else if size@initlocal - position@initlocal < 4 - current@initlocal = 2 - load word@initlocal word from name+position@initlocal - else - current@initlocal = 4 - load dword@initlocal dword from name+position@initlocal - end if - end virtual - if current@initlocal = 1 - mov byte [name+position@initlocal],byte@initlocal - else if current@initlocal = 2 - mov word [name+position@initlocal],word@initlocal - else - mov dword [name+position@initlocal],dword@initlocal - end if - position@initlocal = position@initlocal + current@initlocal - end while } - -macro endp - { purge ret,locals,endl - finish@proc - purge finish@proc - restore regs@proc - match all,args@proc \{ restore all \} - restore args@proc - match all,all@vars \{ restore all \} } - -macro local [var] - { common - locals - forward done@local equ - match varname[count]:vartype, var - \{ match =BYTE, vartype \\{ varname rb count - restore done@local \\} - match =WORD, vartype \\{ varname rw count - restore done@local \\} - match =DWORD, vartype \\{ varname rd count - restore done@local \\} - match =PWORD, vartype \\{ varname rp count - restore done@local \\} - match =QWORD, vartype \\{ varname rq count - restore done@local \\} - match =TBYTE, vartype \\{ varname rt count - restore done@local \\} - match =DQWORD, vartype \\{ label varname dqword - rq count+count - restore done@local \\} - match , done@local \\{ virtual - varname vartype - end virtual - rb count*sizeof.\#vartype - restore done@local \\} \} - match :varname:vartype, done@local:var - \{ match =BYTE, vartype \\{ varname db ? - restore done@local \\} - match =WORD, vartype \\{ varname dw ? - restore done@local \\} - match =DWORD, vartype \\{ varname dd ? - restore done@local \\} - match =PWORD, vartype \\{ varname dp ? - restore done@local \\} - match =QWORD, vartype \\{ varname dq ? - restore done@local \\} - match =TBYTE, vartype \\{ varname dt ? - restore done@local \\} - match =DQWORD, vartype \\{ label varname dqword - dq ?,? - restore done@local \\} - match , done@local \\{ varname vartype - restore done@local \\} \} - match ,done@local - \{ var - restore done@local \} - common - endl } diff --git a/programs/system/drivers/rhd/rhd.bat b/programs/system/drivers/rhd/rhd.bat deleted file mode 100644 index 79ac32888e..0000000000 --- a/programs/system/drivers/rhd/rhd.bat +++ /dev/null @@ -1,5 +0,0 @@ -del rhd -del rhd.exe -make -kpack.exe rhd.exe rhd.drv -@pause \ No newline at end of file diff --git a/programs/system/drivers/rhd/rhd_mc.c b/programs/system/drivers/rhd/rhd_mc.c deleted file mode 100644 index 09a6ebf393..0000000000 --- a/programs/system/drivers/rhd/rhd_mc.c +++ /dev/null @@ -1,882 +0,0 @@ -/* - * Copyright 2007 Luc Verhaegen - * Copyright 2007 Matthias Hopf - * Copyright 2007 Egbert Eich - * Copyright 2007 Advanced Micro Devices, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#if HAVE_XF86_ANSIC_H -# include "xf86_ansic.h" -#else -# include -#endif - -#include "xf86.h" - -#include "rhd.h" -#include "rhd_regs.h" - -Bool RHDMCIdle(RHDPtr rhdPtr, CARD32 count); - -Bool RHDMCIdle(RHDPtr rhdPtr, CARD32 count); - -struct rhdMC { - CARD32 FbLocation; - CARD32 HdpFbBase; - CARD32 MiscLatencyTimer; - Bool Stored; - void (*SaveMC)(RHDPtr rhdPtr); - void (*RestoreMC)(RHDPtr rhdPtr); - void (*SetupMC)(RHDPtr rhdPtr); - Bool (*MCIdle)(RHDPtr rhdPtr); - CARD32 (*GetFBLocation)(RHDPtr rhdPtr, CARD32 *size); - void (*TuneMCAccessForDisplay)(RHDPtr rhdPtr, int crtc, - DisplayModePtr Mode, DisplayModePtr ScaledToMode); - Bool RV515Variant; -}; - -/* - * Save MC_VM state. - */ -static void -rs600SaveMC(RHDPtr rhdPtr) -{ - struct rhdMC *MC = rhdPtr->MC; - - RHDFUNC(rhdPtr); - - MC->FbLocation = RHDReadMC(rhdPtr, RS60_NB_FB_LOCATION); - MC->HdpFbBase = RHDRegRead(rhdPtr, HDP_FB_LOCATION); -} - -/* - * - */ -static void -rs690SaveMC(RHDPtr rhdPtr) -{ - struct rhdMC *MC = rhdPtr->MC; - - RHDFUNC(rhdPtr); - - MC->FbLocation = RHDReadMC(rhdPtr, RS69_MCCFG_FB_LOCATION); - MC->HdpFbBase = RHDRegRead(rhdPtr, HDP_FB_LOCATION); - MC->MiscLatencyTimer = RHDReadMC(rhdPtr, RS69_MC_INIT_MISC_LAT_TIMER); -} - -/* - * - */ -static void -r6xxSaveMC(RHDPtr rhdPtr) -{ - struct rhdMC *MC = rhdPtr->MC; - - RHDFUNC(rhdPtr); - - MC->FbLocation = RHDRegRead(rhdPtr, R6XX_MC_VM_FB_LOCATION); - MC->HdpFbBase = RHDRegRead(rhdPtr, R6XX_HDP_NONSURFACE_BASE); -} - -/* - * - */ -#ifdef NOTYET -static void -rs780SaveMC(RHDPtr rhdPtr) -{ - struct rhdMC *MC = rhdPtr->MC; - - RHDFUNC(rhdPtr); - - MC->FbLocation = RHDReadMC(rhdPtr, RS78_MC_FB_LOCATION); - /* RS780 uses the same register as R6xx */ - MC->HdpFbBase = RHDRegRead(rhdPtr, R6XX_HDP_NONSURFACE_BASE); -} -#endif - -/* - * - */ -static void -r7xxSaveMC(RHDPtr rhdPtr) -{ - struct rhdMC *MC = rhdPtr->MC; - - RHDFUNC(rhdPtr); - - MC->FbLocation = RHDRegRead(rhdPtr, R7XX_MC_VM_FB_LOCATION); - MC->HdpFbBase = RHDRegRead(rhdPtr, R6XX_HDP_NONSURFACE_BASE); -} - -/* - * - */ -static void -r5xxRestoreMC(RHDPtr rhdPtr) -{ - struct rhdMC *MC = rhdPtr->MC; - - RHDFUNC(rhdPtr); - - if (MC->RV515Variant) { - RHDWriteMC(rhdPtr, MC_IND_ALL | RV515_MC_FB_LOCATION, - MC->FbLocation); - RHDWriteMC(rhdPtr, MC_IND_ALL | RV515_MC_MISC_LAT_TIMER, - MC->MiscLatencyTimer); - } else - RHDWriteMC(rhdPtr, MC_IND_ALL | R5XX_MC_FB_LOCATION, - MC->FbLocation); - RHDRegWrite(rhdPtr, HDP_FB_LOCATION, MC->HdpFbBase); -} - -/* - * - */ -static void -rs600RestoreMC(RHDPtr rhdPtr) -{ - struct rhdMC *MC = rhdPtr->MC; - - RHDFUNC(rhdPtr); - - RHDWriteMC(rhdPtr, RS60_NB_FB_LOCATION, MC->FbLocation); - RHDRegWrite(rhdPtr, HDP_FB_LOCATION, MC->HdpFbBase); -} - -/* - * - */ -static void -rs690RestoreMC(RHDPtr rhdPtr) -{ - struct rhdMC *MC = rhdPtr->MC; - - RHDFUNC(rhdPtr); - - RHDWriteMC(rhdPtr, RS69_MCCFG_FB_LOCATION, MC->FbLocation); - RHDRegWrite(rhdPtr, HDP_FB_LOCATION, MC->HdpFbBase); - RHDWriteMC(rhdPtr, RS69_MC_INIT_MISC_LAT_TIMER, MC->MiscLatencyTimer); -} - -/* - * - */ -static void -r6xxRestoreMC(RHDPtr rhdPtr) -{ - struct rhdMC *MC = rhdPtr->MC; - - RHDFUNC(rhdPtr); - - RHDRegWrite(rhdPtr, R6XX_MC_VM_FB_LOCATION, MC->FbLocation); - RHDRegWrite(rhdPtr, R6XX_HDP_NONSURFACE_BASE, MC->HdpFbBase); -} - -/* - * - */ -#ifdef NOTYET -static void -rs780RestoreMC(RHDPtr rhdPtr) -{ - struct rhdMC *MC = rhdPtr->MC; - - RHDFUNC(rhdPtr); - - RHDWriteMC(rhdPtr, RS78_MC_FB_LOCATION, MC->FbLocation); - /* RS780 uses the same register as R6xx */ - RHDRegWrite(rhdPtr, R6XX_HDP_NONSURFACE_BASE, MC->HdpFbBase); -} -#endif - -/* - * - */ -static void -r7xxRestoreMC(RHDPtr rhdPtr) -{ - struct rhdMC *MC = rhdPtr->MC; - - RHDFUNC(rhdPtr); - - RHDRegWrite(rhdPtr, R7XX_MC_VM_FB_LOCATION, MC->FbLocation); - RHDRegWrite(rhdPtr, R6XX_HDP_NONSURFACE_BASE, MC->HdpFbBase); -} - -/* - * Setup the MC - */ - -/* - * - */ -static void -r5xxSetupMC(RHDPtr rhdPtr) -{ - struct rhdMC *MC = rhdPtr->MC; - CARD32 fb_location, fb_location_tmp; - CARD16 fb_size; - unsigned int reg; - - RHDFUNC(rhdPtr); - - - if (MC->RV515Variant) - reg = RV515_MC_FB_LOCATION | MC_IND_ALL; - else - reg = R5XX_MC_FB_LOCATION | MC_IND_ALL; - - fb_location = RHDReadMC(rhdPtr, reg); - fb_size = (fb_location >> 16) - (fb_location & 0xFFFF); - fb_location_tmp = rhdPtr->FbIntAddress >> 16; - fb_location_tmp |= (fb_location_tmp + fb_size) << 16; - - RHDDebug(rhdPtr->scrnIndex, "%s: fb_location: 0x%08X " - "[fb_size: 0x%04X] -> fb_location: 0x%08X\n", - __func__, (unsigned int)fb_location, - fb_size,(unsigned int)fb_location_tmp); - RHDWriteMC(rhdPtr, reg, fb_location_tmp); - RHDRegWrite(rhdPtr, HDP_FB_LOCATION, fb_location_tmp & 0xFFFF); -} - -/* - * - */ -static void -rs600SetupMC(RHDPtr rhdPtr) -{ - CARD32 fb_location, fb_location_tmp; - CARD16 fb_size; - - RHDFUNC(rhdPtr); - - fb_location = RHDReadMC(rhdPtr, RS60_NB_FB_LOCATION); - fb_size = (fb_location >> 16) - (fb_location & 0xFFFF); - fb_location_tmp = rhdPtr->FbIntAddress >> 16; - fb_location_tmp |= (fb_location_tmp + fb_size) << 16; - - RHDDebug(rhdPtr->scrnIndex, "%s: fb_location: 0x%08X " - "[fb_size: 0x%04X] -> fb_location: 0x%08X\n", - __func__, (unsigned int)fb_location, - fb_size,(unsigned int)fb_location_tmp); - RHDWriteMC(rhdPtr, RS60_NB_FB_LOCATION, fb_location_tmp); - RHDRegWrite(rhdPtr, HDP_FB_LOCATION, fb_location_tmp & 0xFFFF); /* same ;) */ -} - -/* - * - */ -static void -rs690SetupMC(RHDPtr rhdPtr) -{ - CARD32 fb_location, fb_location_tmp; - CARD16 fb_size; - - RHDFUNC(rhdPtr); - - fb_location = RHDReadMC(rhdPtr, RS69_MCCFG_FB_LOCATION); - fb_size = (fb_location >> 16) - (fb_location & 0xFFFF); - fb_location_tmp = rhdPtr->FbIntAddress >> 16; - fb_location_tmp |= (fb_location_tmp + fb_size) << 16; - - RHDDebug(rhdPtr->scrnIndex, "%s: fb_location: 0x%08X " - "[fb_size: 0x%04X] -> fb_location: 0x%08X\n", - __func__, (unsigned int)fb_location, - fb_size,(unsigned int)fb_location_tmp); - RHDWriteMC(rhdPtr, RS69_MCCFG_FB_LOCATION, fb_location_tmp); - RHDRegWrite(rhdPtr, HDP_FB_LOCATION, fb_location_tmp & 0xFFFF); -} - -/* - * - */ -static void -r6xxSetupMC(RHDPtr rhdPtr) -{ - CARD32 fb_location, fb_location_tmp, hdp_fbbase_tmp; - CARD16 fb_size; - - RHDFUNC(rhdPtr); - - fb_location = RHDRegRead(rhdPtr, R6XX_MC_VM_FB_LOCATION); - fb_size = (fb_location >> 16) - (fb_location & 0xFFFF); - fb_location_tmp = rhdPtr->FbIntAddress >> 24; - fb_location_tmp |= (fb_location_tmp + fb_size) << 16; - hdp_fbbase_tmp = (rhdPtr->FbIntAddress >> 8) & 0xff0000; - - RHDDebug(rhdPtr->scrnIndex, "%s: fb_location: 0x%08X " - "fb_offset: 0x%08X [fb_size: 0x%04X] -> fb_location: 0x%08X " - "fb_offset: 0x%08X\n", - __func__, (unsigned int)fb_location, - RHDRegRead(rhdPtr,R6XX_HDP_NONSURFACE_BASE), fb_size, - (unsigned int)fb_location_tmp, (unsigned int)hdp_fbbase_tmp); - - RHDRegWrite(rhdPtr, R6XX_MC_VM_FB_LOCATION, fb_location_tmp); - RHDRegWrite(rhdPtr, R6XX_HDP_NONSURFACE_BASE, hdp_fbbase_tmp); -} - -/* - * - */ -#ifdef NOTYET -static void -rs780SetupMC(RHDPtr rhdPtr) -{ - CARD32 fb_location, fb_location_tmp, hdp_fbbase_tmp; - CARD16 fb_size; - - RHDFUNC(rhdPtr); - - fb_location = RHDReadMC(rhdPtr, RS78_MC_FB_LOCATION); - fb_size = (fb_location >> 16) - (fb_location & 0xFFFF); - fb_location_tmp = rhdPtr->FbIntAddress >> 16; - fb_location_tmp |= (fb_location_tmp + fb_size) << 16; - hdp_fbbase_tmp = (rhdPtr->FbIntAddress >> 8) & 0xff0000; - - RHDDebug(rhdPtr->scrnIndex, "%s: fb_location: 0x%08X " - "[fb_size: 0x%04X] -> fb_location: 0x%08X\n", - __func__, (unsigned int)fb_location, - fb_size,(unsigned int)fb_location_tmp); - RHDWriteMC(rhdPtr, RS78_MC_FB_LOCATION, fb_location_tmp); - /* RS780 uses the same register as R6xx */ - RHDRegWrite(rhdPtr, R6XX_HDP_NONSURFACE_BASE, hdp_fbbase_tmp); -} -#endif - -/* - * - */ -static void -r7xxSetupMC(RHDPtr rhdPtr) -{ - CARD32 fb_location, fb_location_tmp, hdp_fbbase_tmp; - CARD16 fb_size; - - RHDFUNC(rhdPtr); - - fb_location = RHDRegRead(rhdPtr, R7XX_MC_VM_FB_LOCATION); - fb_size = (fb_location >> 16) - (fb_location & 0xFFFF); - fb_location_tmp = rhdPtr->FbIntAddress >> 24; - fb_location_tmp |= (fb_location_tmp + fb_size) << 16; - hdp_fbbase_tmp = (rhdPtr->FbIntAddress >> 8) & 0xff0000; - - RHDDebug(rhdPtr->scrnIndex, "%s: fb_location: 0x%08X " - "fb_offset: 0x%08X [fb_size: 0x%04X] -> fb_location: 0x%08X " - "fb_offset: 0x%08X\n", - __func__, (unsigned int)fb_location, - RHDRegRead(rhdPtr,R6XX_HDP_NONSURFACE_BASE), fb_size, - (unsigned int)fb_location_tmp, (unsigned int)hdp_fbbase_tmp); - - RHDRegWrite(rhdPtr, R7XX_MC_VM_FB_LOCATION, fb_location_tmp); - RHDRegWrite(rhdPtr, R6XX_HDP_NONSURFACE_BASE, hdp_fbbase_tmp); -} - -/* - * - */ -void -RHDMCSetup(RHDPtr rhdPtr) -{ - struct rhdMC *MC = rhdPtr->MC; - RHDFUNC(rhdPtr); - - if (!MC) - return; - /* - * make sure the hw is in a state such that we can update - * the MC - ie no subsystem is currently accessing memory. - */ - ASSERT((RHDRegRead(rhdPtr, D1VGA_CONTROL) & D1VGA_MODE_ENABLE) != D1VGA_MODE_ENABLE); - ASSERT((RHDRegRead(rhdPtr, D2VGA_CONTROL) & D2VGA_MODE_ENABLE) != D2VGA_MODE_ENABLE); - ASSERT((RHDRegRead(rhdPtr, D1CRTC_CONTROL) & 0x1) != 0x1); - ASSERT((RHDRegRead(rhdPtr, D2CRTC_CONTROL) & 0x1) != 0x1); - ASSERT(RHDMCIdle(rhdPtr, 1)); - - MC->SetupMC(rhdPtr); -} - -/* - * Get FB location and size. - */ -static CARD32 -r5xxGetFBLocation(RHDPtr rhdPtr, CARD32 *size) -{ - struct rhdMC *MC = rhdPtr->MC; - CARD32 val; - CARD32 reg; - - if (MC->RV515Variant) - reg = RV515_MC_FB_LOCATION | MC_IND_ALL; - else - reg = R5XX_MC_FB_LOCATION | MC_IND_ALL; - - val = RHDReadMC(rhdPtr, reg); - - if (size) *size = ((val >> 16) - (val & 0xFFFF)) << 16; - - return (val & 0xFFFF) << 16; -} - -/* - * - */ -static CARD32 -rs600GetFBLocation(RHDPtr rhdPtr, CARD32 *size) -{ - CARD32 val = RHDReadMC(rhdPtr, RS60_NB_FB_LOCATION); - - if (size) *size = ((val >> 16) - (val & 0xFFFF)) << 16; - - return (val & 0xFFFF) << 16; -} - -/* - * - */ -static CARD32 -rs690GetFBLocation(RHDPtr rhdPtr, CARD32 *size) -{ - CARD32 val = RHDReadMC(rhdPtr, RS69_MCCFG_FB_LOCATION); - - if (size) *size = ((val >> 16) - (val & 0xFFFF)) << 16; - - return (val & 0xFFFF) << 16; -} - -/* - * - */ -static CARD32 -r6xxGetFBLocation(RHDPtr rhdPtr, CARD32 *size) -{ - CARD32 val = RHDRegRead(rhdPtr, R6XX_MC_VM_FB_LOCATION); - - if (size) *size = ((val >> 16) - (val & 0xFFFF)) << 24; - - return (val & 0xFFFF) << 24; -} - -/* - * - */ -#ifdef NOTYET -static CARD32 -rs780GetFBLocation(RHDPtr rhdPtr, CARD32 *size) -{ - CARD32 val = RHDReadMC(rhdPtr, RS78_MC_FB_LOCATION); - if (size) *size = ((val >> 16) - (val & 0xFFFF)) << 16; - - return (val & 0xFFFF) << 16; -} -#endif - -/* - * - */ -static CARD32 -r7xxGetFBLocation(RHDPtr rhdPtr, CARD32 *size) -{ - CARD32 val = RHDRegRead(rhdPtr, R7XX_MC_VM_FB_LOCATION); - - if (size) *size = ((val >> 16) - (val & 0xFFFF)) << 24; - - return (val & 0xFFFF) << 24; -} - -/* - * - */ -CARD32 -RHDGetFBLocation(RHDPtr rhdPtr, CARD32 *size) -{ - struct rhdMC *MC = rhdPtr->MC; - RHDFUNC(rhdPtr); - - if (!MC) { - if (size) *size = 0; - return 0; - } - - return MC->GetFBLocation(rhdPtr, size); -} - -/* - * - */ -static Bool -rv515MCIdle(RHDPtr rhdPtr) -{ - RHDFUNC(rhdPtr); - - if (RHDReadMC(rhdPtr, MC_IND_ALL | RV515_MC_STATUS) & RV515_MC_IDLE) - return TRUE; - return FALSE; -} - - -/* - * - */ -static Bool -r5xxMCIdle(RHDPtr rhdPtr) -{ - RHDFUNC(rhdPtr); - - if (RHDReadMC(rhdPtr, MC_IND_ALL | R5XX_MC_STATUS) & R5XX_MC_IDLE) - return TRUE; - return FALSE; -} - -/* - * - */ -static Bool -rs600MCIdle(RHDPtr rhdPtr) -{ - RHDFUNC(rhdPtr); - - if (RHDReadMC(rhdPtr, RS60_MC_SYSTEM_STATUS) & RS6X_MC_SEQUENCER_IDLE) - return TRUE; - return FALSE; -} - -/* - * - */ -static Bool -rs690MCIdle(RHDPtr rhdPtr) -{ - RHDFUNC(rhdPtr); - - if (RHDReadMC(rhdPtr, RS69_MC_SYSTEM_STATUS) & RS6X_MC_SEQUENCER_IDLE) - return TRUE; - return FALSE; -} - -/* - * - */ -static Bool -r6xxMCIdle(RHDPtr rhdPtr) -{ - RHDFUNC(rhdPtr); - - if (!(RHDRegRead(rhdPtr, SRBM_STATUS) & 0x3f00)) - return TRUE; - return FALSE; -} - -/* - * - */ -#ifdef NOTYET -static Bool -rs780MCIdle(RHDPtr rhdPtr) -{ - RHDFUNC(rhdPtr); - - if (RHDReadMC(rhdPtr, RS78_MC_SYSTEM_STATUS) & RS78_MC_SEQUENCER_IDLE) - return TRUE; - return FALSE; -} -#endif - -/* - * - */ -Bool -RHDMCIdle(RHDPtr rhdPtr, CARD32 count) -{ - struct rhdMC *MC = rhdPtr->MC; - RHDFUNC(rhdPtr); - - if (!MC) - return TRUE; - - do { - if (MC->MCIdle(rhdPtr)) - return TRUE; - usleep(10); - } while (count--); - - RHDDebug(rhdPtr->scrnIndex, "%s: MC not idle\n",__func__); - - return FALSE; -} - -/* - * - */ -void -RHDSaveMC(RHDPtr rhdPtr) -{ - struct rhdMC *MC = rhdPtr->MC; - RHDFUNC(rhdPtr); - - if (!MC) - return; - - MC->SaveMC(rhdPtr); - - MC->Stored = TRUE; -} - -/* - * Restore MC VM state. - */ -void -RHDRestoreMC(RHDPtr rhdPtr) -{ - struct rhdMC *MC = rhdPtr->MC; - RHDFUNC(rhdPtr); - - if (!MC) - return; - - if (!MC->Stored) { - xf86DrvMsg(rhdPtr->scrnIndex, X_ERROR, - "%s: trying to restore uninitialized values.\n",__func__); - return; - } - /* - * make sure the hw is in a state such that we can update - * the MC - ie no subsystem is currently accessing memory. - */ - ASSERT((RHDRegRead(rhdPtr, D1VGA_CONTROL) & D1VGA_MODE_ENABLE) != D1VGA_MODE_ENABLE); - ASSERT((RHDRegRead(rhdPtr, D2VGA_CONTROL) & D2VGA_MODE_ENABLE) != D2VGA_MODE_ENABLE); - ASSERT((RHDRegRead(rhdPtr, D1CRTC_CONTROL) & 0x1) != 0x1); - ASSERT((RHDRegRead(rhdPtr, D2CRTC_CONTROL) & 0x1) != 0x1); - ASSERT(RHDMCIdle(rhdPtr, 1)); - - MC->RestoreMC(rhdPtr); -} - -/* - * - */ -static void -r5xxSaveMC(RHDPtr rhdPtr) -{ - struct rhdMC *MC = rhdPtr->MC; - - RHDFUNC(rhdPtr); - - if (MC->RV515Variant) { - MC->FbLocation = RHDReadMC(rhdPtr, MC_IND_ALL | RV515_MC_FB_LOCATION); - MC->MiscLatencyTimer = RHDReadMC(rhdPtr, MC_IND_ALL | RV515_MC_MISC_LAT_TIMER); - } else - MC->FbLocation = RHDReadMC(rhdPtr, MC_IND_ALL | R5XX_MC_FB_LOCATION); - MC->HdpFbBase = RHDRegRead(rhdPtr, HDP_FB_LOCATION); -} - -/* - * - */ -static void -rv515TuneMCAccessForDisplay(RHDPtr rhdPtr, int crtc, - DisplayModePtr Mode, DisplayModePtr ScaledToMode) -{ - CARD32 value, setting = 0x1; - - RHDFUNC(rhdPtr); - - value = RHDReadMC(rhdPtr, RV515_MC_MISC_LAT_TIMER); - - value |= (setting << (crtc ? MC_DISP1R_INIT_LAT_SHIFT : MC_DISP0R_INIT_LAT_SHIFT)); - RHDWriteMC(rhdPtr, RV515_MC_MISC_LAT_TIMER, value); -} - -/* - * - */ -static void -rs690TuneMCAccessForDisplay(RHDPtr rhdPtr, int crtc, - DisplayModePtr Mode, DisplayModePtr ScaledToMode) -{ - CARD32 value, setting = 0x1; - - RHDFUNC(rhdPtr); - - value = RHDReadMC(rhdPtr, RS69_MC_INIT_MISC_LAT_TIMER); - value |= setting << (crtc ? MC_DISP1R_INIT_LAT_SHIFT : MC_DISP0R_INIT_LAT_SHIFT); - RHDWriteMC(rhdPtr, RS69_MC_INIT_MISC_LAT_TIMER, value); -} - -/* - * - */ -void -RHDTuneMCAccessForDisplay(RHDPtr rhdPtr, int crtc, - DisplayModePtr Mode, DisplayModePtr ScaledToMode) -{ - struct rhdMC *MC = rhdPtr->MC; - - RHDFUNC(rhdPtr); - - if (MC->TuneMCAccessForDisplay) - MC->TuneMCAccessForDisplay(rhdPtr, crtc, Mode, ScaledToMode); -} - -/* - * - */ -void -RHDMCInit(RHDPtr rhdPtr) -{ - struct rhdMC *MC; - - RHDFUNC(rhdPtr); - - /* These devices have an internal address reference, which some other - * address registers in there also use. This can be different from the - * address in the BAR. - * - * We read out the address here from some known location. This address - * is as good a guess as any, we just need to pick one, but then make - * sure that it is made consistent in MCSetup and the various MC - * accessing subsystems. - */ - if (rhdPtr->ChipSet < RHD_R600) - rhdPtr->FbIntAddress = RHDRegRead(rhdPtr, HDP_FB_LOCATION) << 16; - else - rhdPtr->FbIntAddress = RHDRegRead(rhdPtr, R6XX_CONFIG_FB_BASE); - - RHDDebug(rhdPtr->scrnIndex, "MC FB Address: 0x%08X.\n", - rhdPtr->FbIntAddress); - - MC = xnfcalloc(1, sizeof(struct rhdMC)); - MC->Stored = FALSE; - - if (rhdPtr->ChipSet < RHD_RS600) { - MC->SaveMC = r5xxSaveMC; - MC->RestoreMC = r5xxRestoreMC; - MC->SetupMC = r5xxSetupMC; - MC->GetFBLocation = r5xxGetFBLocation; - - if (rhdPtr->ChipSet == RHD_RV515 - || rhdPtr->ChipSet == RHD_RV505 - || rhdPtr->ChipSet == RHD_RV516 - || rhdPtr->ChipSet == RHD_RV550 - || rhdPtr->ChipSet == RHD_M52 - || rhdPtr->ChipSet == RHD_M54 - || rhdPtr->ChipSet == RHD_M62 - || rhdPtr->ChipSet == RHD_M64 - || rhdPtr->ChipSet == RHD_M71) { - - MC->RV515Variant = TRUE; - MC->MCIdle = rv515MCIdle; - MC->TuneMCAccessForDisplay = rv515TuneMCAccessForDisplay; - } else { - - MC->RV515Variant = FALSE; - MC->MCIdle = r5xxMCIdle; - - } - - } else if (rhdPtr->ChipSet == RHD_RS600) { - MC->SaveMC = rs600SaveMC; - MC->RestoreMC = rs600RestoreMC; - MC->SetupMC = rs600SetupMC; - MC->MCIdle = rs600MCIdle; - MC->GetFBLocation = rs600GetFBLocation; - } else if (rhdPtr->ChipSet < RHD_R600) { - MC->SaveMC = rs690SaveMC; - MC->RestoreMC = rs690RestoreMC; - MC->SetupMC = rs690SetupMC; - MC->MCIdle = rs690MCIdle; - MC->GetFBLocation = rs690GetFBLocation; - MC->TuneMCAccessForDisplay = rs690TuneMCAccessForDisplay; - } else if (rhdPtr->ChipSet <= RHD_RS780) { - MC->SaveMC = r6xxSaveMC; - MC->RestoreMC = r6xxRestoreMC; - MC->SetupMC = r6xxSetupMC; - MC->MCIdle = r6xxMCIdle; - MC->GetFBLocation = r6xxGetFBLocation; - } -#if 0 - else if (rhdPtr->ChipSet == RHD_RS780) { - MC->SaveMC = rs780SaveMC; - MC->RestoreMC = rs780RestoreMC; - MC->SetupMC = rs780SetupMC; - MC->MCIdle = rs780MCIdle; - MC->GetFBLocation = rs780GetFBLocation; - } -#endif - else if (rhdPtr->ChipSet >= RHD_RV770) { - MC->SaveMC = r7xxSaveMC; - MC->RestoreMC = r7xxRestoreMC; - MC->SetupMC = r7xxSetupMC; - MC->MCIdle = r6xxMCIdle; - MC->GetFBLocation = r7xxGetFBLocation; - } else { - xf86DrvMsg(rhdPtr->scrnIndex, X_ERROR, "I don't know anything about MC on this chipset\n"); - xfree(MC); - return; - } - rhdPtr->MC = MC; - -} - -/* - * Free structure. - */ -void -RHDMCDestroy(RHDPtr rhdPtr) -{ - RHDFUNC(rhdPtr); - - if (!rhdPtr->MC) - return; - - xfree(rhdPtr->MC); - rhdPtr->MC = NULL; -} - -/* - * - */ -Bool -RHD_MC_IGP_SideportMemoryPresent(RHDPtr rhdPtr) -{ - Bool Present = FALSE; - - RHDFUNC(rhdPtr); - - switch (rhdPtr->ChipSet) { - case RHD_RS690: - case RHD_RS740: - Present = (RHDReadMC(rhdPtr, RS69_MC_MISC_UMA_CNTL) & RS69_SIDE_PORT_PRESENT_R) != 0; - break; - case RHD_RS780: - Present = (RHDReadMC(rhdPtr, RS78_MC_MISC_UMA_CNTL) & RS78_SIDE_PORT_PRESENT_R) != 0; - break; - default: - break; - } - xf86DrvMsg(rhdPtr->scrnIndex, X_INFO, "IPG sideport memory %s present.\n", Present ? "" : "not"); - - return Present; -} diff --git a/programs/system/drivers/usb/pci.h b/programs/system/drivers/usb/pci.h deleted file mode 100644 index 4ec48ac41c..0000000000 --- a/programs/system/drivers/usb/pci.h +++ /dev/null @@ -1,95 +0,0 @@ - - -#pragma pack(push, 1) -typedef struct -{ - u16_t device; - u16_t ChipSet; -}PciChipset_t; -#pragma pack(pop) - - -#define PCI_VENDOR_ID 0x00 /* 16 bits */ -#define PCI_DEVICE_ID 0x02 /* 16 bits */ -#define PCI_COMMAND 0x04 /* 16 bits */ -#define PCI_COMMAND_IO 0x01 /* Enable response in I/O space */ -#define PCI_COMMAND_MEMORY 0x02 /* Enable response in Memory space */ -#define PCI_COMMAND_MASTER 0x04 /* Enable bus mastering */ -#define PCI_COMMAND_SPECIAL 0x08 /* Enable response to special cycles */ -#define PCI_COMMAND_INVALIDATE 0x10 /* Use memory write and invalidate */ -#define PCI_COMMAND_VGA_PALETTE 0x20 /* Enable palette snooping */ -#define PCI_COMMAND_PARITY 0x40 /* Enable parity checking */ -#define PCI_COMMAND_WAIT 0x80 /* Enable address/data stepping */ -#define PCI_COMMAND_SERR 0x100 /* Enable SERR */ -#define PCI_COMMAND_FAST_BACK 0x200 /* Enable back-to-back writes */ -#define PCI_COMMAND_INTX_DISABLE 0x400 /* INTx Emulation Disable */ - - - -#define PCI_MAP_REG_START 0x10 -#define PCI_MAP_REG_END 0x28 -#define PCI_MAP_ROM_REG 0x30 - -#define PCI_MAP_MEMORY 0x00000000 -#define PCI_MAP_IO 0x00000001 - -#define PCI_MAP_MEMORY_TYPE 0x00000007 -#define PCI_MAP_IO_TYPE 0x00000003 - -#define PCI_MAP_MEMORY_TYPE_32BIT 0x00000000 -#define PCI_MAP_MEMORY_TYPE_32BIT_1M 0x00000002 -#define PCI_MAP_MEMORY_TYPE_64BIT 0x00000004 -#define PCI_MAP_MEMORY_TYPE_MASK 0x00000006 -#define PCI_MAP_MEMORY_CACHABLE 0x00000008 -#define PCI_MAP_MEMORY_ATTR_MASK 0x0000000e -#define PCI_MAP_MEMORY_ADDRESS_MASK 0xfffffff0 - -#define PCI_MAP_IO_ATTR_MASK 0x00000003 - -#define PCI_MAP_IS_IO(b) ((b) & PCI_MAP_IO) -#define PCI_MAP_IS_MEM(b) (!PCI_MAP_IS_IO(b)) - -#define PCI_MAP_IS64BITMEM(b) \ - (((b) & PCI_MAP_MEMORY_TYPE_MASK) == PCI_MAP_MEMORY_TYPE_64BIT) - -#define PCIGETMEMORY(b) ((b) & PCI_MAP_MEMORY_ADDRESS_MASK) -#define PCIGETMEMORY64HIGH(b) (*((CARD32*)&b + 1)) -#define PCIGETMEMORY64(b) \ - (PCIGETMEMORY(b) | ((CARD64)PCIGETMEMORY64HIGH(b) << 32)) - -#define PCI_MAP_IO_ADDRESS_MASK 0xfffffffc - -#define PCIGETIO(b) ((b) & PCI_MAP_IO_ADDRESS_MASK) - -#define PCI_MAP_ROM_DECODE_ENABLE 0x00000001 -#define PCI_MAP_ROM_ADDRESS_MASK 0xfffff800 - -#define PCIGETROM(b) ((b) & PCI_MAP_ROM_ADDRESS_MASK) - - -#ifndef PCI_DOM_MASK -# define PCI_DOM_MASK 0x0ffu -#endif -#define PCI_DOMBUS_MASK (((PCI_DOM_MASK) << 8) | 0x0ffu) - -#define PCI_MAKE_TAG(b,d,f) ((((b) & (PCI_DOMBUS_MASK)) << 16) | \ - (((d) & 0x00001fu) << 11) | \ - (((f) & 0x000007u) << 8)) - -#define PCI_BUS_FROM_TAG(tag) (((tag) >> 16) & (PCI_DOMBUS_MASK)) -#define PCI_DEV_FROM_TAG(tag) (((tag) & 0x0000f800u) >> 11) -#define PCI_FUNC_FROM_TAG(tag) (((tag) & 0x00000700u) >> 8) -#define PCI_DFN_FROM_TAG(tag) (((tag) & 0x0000ff00u) >> 8) - - -typedef unsigned int PCITAG; - -extern inline PCITAG -pciTag(int busnum, int devnum, int funcnum) -{ - return(PCI_MAKE_TAG(busnum,devnum,funcnum)); -} - -u32_t pciGetBaseSize(int bus, int devfn, int index, Bool destructive, Bool *min); - -Bool FindPciDevice();