Changeset 593
- Timestamp:
- Mar 14, 2017, 9:14:21 PM (8 years ago)
- Location:
- GPL/branches/uniaud32-2.1.x
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
GPL/branches/uniaud32-2.1.x/alsa-kernel/include/sound/asound.h
r569 r593 735 735 #define SNDRV_CTL_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 6) 736 736 737 /******************** This section used in uniaud.dll interface *********************/ 737 738 struct snd_ctl_card_info { 738 739 int card; /* card number */ -
GPL/branches/uniaud32-2.1.x/alsa-kernel/pci/hda/hda_intel.c
r592 r593 2772 2772 if (err < 0) 2773 2773 goto out_free; 2774 2774 2775 2775 /* create mixer controls */ 2776 2776 err = azx_mixer_create(chip); -
GPL/branches/uniaud32-2.1.x/drv32/Makefile
r592 r593 86 86 @%write $^@ option alignment=16 87 87 @%write $^@ option map=$(WMAPNAME) 88 @$(ROOT)\tools\AddToFile.cmd $^@,$option description,BLDLEVEL,$(BLDLVL_VENDOR),$(BLDLVL_VERSION),Universal Audio Driver for OS/2 (c) %Y $(BLDLVL_VENDOR),$(BLDLVL_FIXPACK) 88 @$(ROOT)\tools\AddToFile.cmd $^@,$option description,BLDLEVEL,$(BLDLVL_VENDOR),$(BLDLVL_VERSION),Universal Audio Driver for OS/2 (c) %Y $(BLDLVL_VENDOR),$(BLDLVL_FIXPACK),$(BLDLVL_ALSA) 89 89 @%write $^@ name $(OBJDIR)\$(TARGET).sys 90 90 @for %f in ($(FILES)) do @%append $^@ file $(OBJDIR)\%f … … 105 105 $(OBJDIR)\$(TARGET).sys: $(LNKFILE) $(FILES) $(LIBS) 106 106 @%create $(DEFFILE) 107 $(ROOT)\tools\AddToFile.cmd $(DEFFILE),description,BLDLEVEL,$(BLDLVL_VENDOR),$(BLDLVL_VERSION),Universal Audio Driver for OS/2 (c) %Y $(BLDLVL_VENDOR),$(BLDLVL_FIXPACK) 107 $(ROOT)\tools\AddToFile.cmd $(DEFFILE),description,BLDLEVEL,$(BLDLVL_VENDOR),$(BLDLVL_VERSION),Universal Audio Driver for OS/2 (c) %Y $(BLDLVL_VENDOR),$(BLDLVL_FIXPACK),$(BLDLVL_ALSA) 108 108 $(LINK) @$(LNKFILE) 109 109 copy $(OBJDIR)\$(TARGET).sys $(ALSA_BIN) -
GPL/branches/uniaud32-2.1.x/drv32/parse.c
r588 r593 44 44 int fDebug = FALSE; 45 45 int ForceCard = CARD_NONE; 46 int iAdapterNumber = 0; 46 47 47 48 extern short int midi_port; … … 209 210 { 210 211 switch (cParm) { 212 case 'A': 213 iAdapterNumber = *pszOption & 0x07; 214 break; 211 215 case 'V': // Verbose option 212 216 fVerbose = TRUE; -
GPL/branches/uniaud32-2.1.x/lib32/initcall.h
r588 r593 108 108 extern_module_init(patch_analog_init) 109 109 extern_module_exit(patch_analog_exit) 110 extern_module_init(patch_atihdmi_init)111 extern_module_exit(patch_atihdmi_init)112 110 extern_module_init(patch_cmedia_init) 113 111 extern_module_exit(patch_cmedia_exit) -
GPL/branches/uniaud32-2.1.x/lib32/pci.c
r592 r593 5 5 * (C) 2000-2002 InnoTek Systemberatung GmbH 6 6 * (C) 2000-2001 Sander van Leeuwen (sandervl@xs4all.nl) 7 * Copyright (c) 2016-2017 David Azarewicz <david@88watts.net> 7 8 * 8 9 * Parts based on Linux kernel sources … … 41 42 #include <osspci.h> 42 43 43 #define MAX_PCI_BUSSES25644 #define MAX_PCI_DEVICES1644 #define MAX_PCI_BUSSES 256 45 #define MAX_PCI_DEVICES 16 45 46 46 47 struct pci_dev pci_devices[MAX_PCI_DEVICES] = {0}; … … 48 49 49 50 extern int nrCardsDetected; 50 51 52 #define PCI_CONFIG_ENABLE 0x80000000 53 #define PCI_CONFIG_ADDRESS 0xCF8 54 #define PCI_CONFIG_DATA 0xCFC 55 56 //****************************************************************************** 57 #define CONFIG_CMD(dev, where) \ 58 (PCI_CONFIG_ENABLE | (dev->bus->number<<16) | (dev->devfn<<8) | (where & ~3)) 51 extern int iAdapterNumber; 52 53 54 #define PCI_CONFIG_ENABLE 0x80000000 55 #define PCI_CONFIG_ADDRESS 0xCF8 56 #define PCI_CONFIG_DATA 0xCFC 57 58 //****************************************************************************** 59 #define CONFIG_CMD(dev, where) \ 60 (PCI_CONFIG_ENABLE | (dev->bus->number<<16) | (dev->devfn<<8) | (where & ~3)) 59 61 //****************************************************************************** 60 62 int pci_read_config_byte(struct pci_dev *dev, int where, u8 *value) 61 63 { 62 63 64 64 outl(CONFIG_CMD(dev,where), PCI_CONFIG_ADDRESS); 65 *value = inb(PCI_CONFIG_DATA + (where&3)); 66 return PCIBIOS_SUCCESSFUL; 65 67 } 66 68 //****************************************************************************** … … 68 70 int pci_read_config_word(struct pci_dev *dev, int where, u16 *value) 69 71 { 70 71 72 72 outl(CONFIG_CMD(dev,where), PCI_CONFIG_ADDRESS); 73 *value = inw(PCI_CONFIG_DATA + (where&2)); 74 return PCIBIOS_SUCCESSFUL; 73 75 } 74 76 //****************************************************************************** … … 76 78 int pci_read_config_dword(struct pci_dev *dev, int where, u32 *value) 77 79 { 78 79 80 80 outl(CONFIG_CMD(dev,where), PCI_CONFIG_ADDRESS); 81 *value = inl(PCI_CONFIG_DATA); 82 return PCIBIOS_SUCCESSFUL; 81 83 } 82 84 //****************************************************************************** … … 84 86 int pci_write_config_byte(struct pci_dev *dev, int where, u8 value) 85 87 { 86 87 88 88 outl(CONFIG_CMD(dev,where), PCI_CONFIG_ADDRESS); 89 outb(value, PCI_CONFIG_DATA + (where&3)); 90 return PCIBIOS_SUCCESSFUL; 89 91 } 90 92 //****************************************************************************** … … 92 94 int pci_write_config_word(struct pci_dev *dev, int where, u16 value) 93 95 { 94 95 96 96 outl(CONFIG_CMD(dev,where), PCI_CONFIG_ADDRESS); 97 outw(value, PCI_CONFIG_DATA + (where&2)); 98 return PCIBIOS_SUCCESSFUL; 97 99 } 98 100 //****************************************************************************** … … 100 102 int pci_write_config_dword(struct pci_dev *dev, int where, u32 value) 101 103 { 102 103 104 104 outl(CONFIG_CMD(dev,where), PCI_CONFIG_ADDRESS); 105 outl(value, PCI_CONFIG_DATA); 106 return PCIBIOS_SUCCESSFUL; 105 107 } 106 108 //****************************************************************************** … … 108 110 int pcidev_prepare(struct pci_dev *dev) 109 111 { 110 111 112 dprintf(("pcidev_prepare %x not implemented", dev)); 113 return 1; //todo: correct return value?? 112 114 } 113 115 //****************************************************************************** … … 115 117 int pcidev_activate(struct pci_dev *dev) 116 118 { 117 118 119 dprintf(("pcidev_activate %x not implemented", dev)); 120 return 1; //todo: correct return value?? 119 121 } 120 122 //****************************************************************************** … … 122 124 int pcidev_deactivate(struct pci_dev *dev) 123 125 { 124 dprintf(("pcidev_deactivate %x not implemented", dev)); 125 return 1; //todo: correct return value?? 126 } 127 128 129 130 //****************************************************************************** 131 //****************************************************************************** 132 //Find the next matching PCI device starting with the device specified by pcidev 133 static ULONG pci_query_device(const struct pci_device_id *id_table, struct pci_dev near *pcidev, ULONG ulLast) 134 { 135 int resNo, addr; 136 u32 devNr, busNr, funcNr, detectedId, cfgaddrreg, ulPciAdr, ulTmp1, ulTmp2; 137 u8 headerType; 138 139 busNr = (ulLast >> 8) & 0xff; 140 devNr = PCI_SLOT(ulLast); 141 funcNr = PCI_FUNC(ulLast); 142 if (ulLast) funcNr++; 143 144 cfgaddrreg = inl(PCI_CONFIG_ADDRESS); 145 for(;busNr<MAX_PCI_BUSSES;busNr++) { //BusNumber<255 146 for(;devNr<32;devNr++) { 147 for(;funcNr<8;funcNr++) { 148 headerType = 0; 149 ulPciAdr = PCI_CONFIG_ENABLE | (busNr<<16) | (devNr<<11) | (funcNr<<8); 150 outl(ulPciAdr, PCI_CONFIG_ADDRESS); 151 detectedId = inl(PCI_CONFIG_DATA); 152 153 if ( detectedId == 0xffffffff ) { 154 if ( funcNr == 0 ) break; /* if func 0 isn't there, the others aren't either */ 155 continue; 156 } 157 158 outl(ulPciAdr + PCI_CLASS_REVISION, PCI_CONFIG_ADDRESS); 159 ulTmp2 = inl(PCI_CONFIG_DATA) >> 8; /* get class */ 160 161 //dprintf(("det=%x(%x) %x need=%x%x %x", detectedId, headerType, ulTmp2, id_table->device&0xffff, id_table->vendor, id_table->class)); 162 163 if ( id_table->class ) { 164 if ( (ulTmp2 & id_table->class_mask) != id_table->class ) continue; 165 } else { 166 if ( (id_table->device == PCI_ANY_ID) && ((ulTmp2 >> 8) != PCI_CLASS_MULTIMEDIA_AUDIO) ) continue; 167 } 168 169 if (id_table->vendor != (detectedId & 0xffff)) continue; 170 if ( (id_table->device != PCI_ANY_ID) && (id_table->device != (detectedId >> 16)) ) continue; 171 172 outl(ulPciAdr | (PCI_HEADER_TYPE & ~3), PCI_CONFIG_ADDRESS); 173 headerType = inb(PCI_CONFIG_DATA + (PCI_HEADER_TYPE & 3)); 174 175 if ( (headerType & 0x7f) != PCI_HEADER_TYPE_NORMAL ) continue; 176 177 memset((void near *)pcidev, 0, sizeof(struct pci_dev)); 178 179 pcidev->vendor = detectedId & 0xffff; 180 pcidev->device = detectedId >> 16; 181 //pcidev->bus = &pci_busses[busNr]; 182 pcidev->bus = kmalloc(sizeof(struct pci_bus), GFP_KERNEL); 183 if (pcidev->bus == NULL) return 0; 184 memset (pcidev->bus, 0, sizeof(struct pci_bus)); 185 pcidev->bus->number = busNr; 186 pcidev->devfn = PCI_DEVFN(devNr, funcNr); 187 pcidev->hdr_type = headerType & 0x7f; 188 189 pcidev->prepare = pcidev_prepare; 190 pcidev->activate = pcidev_activate; 191 pcidev->deactivate = pcidev_deactivate; 192 pcidev->active = 1; 193 pcidev->ro = 0; 194 pcidev->sibling = NULL; 195 pcidev->next = NULL; 196 pcidev->dma_mask = 0xFFFFFFFF; 197 198 // Subsystem ID 199 pci_read_config_word(pcidev, PCI_SUBSYSTEM_VENDOR_ID, &pcidev->subsystem_vendor); 200 pci_read_config_word(pcidev, PCI_SUBSYSTEM_ID, &pcidev->subsystem_device); 201 202 // I/O and MEM 203 resNo = 0; 204 for( addr = PCI_BASE_ADDRESS_0; addr <= PCI_BASE_ADDRESS_5; addr += 4 ) { 205 pci_read_config_dword(pcidev, addr, &ulTmp1); 206 if( ulTmp1 != 0 && ulTmp1 != 0xffffffff ) { 207 pci_write_config_dword(pcidev, addr, 0xffffffff); 208 pci_read_config_dword(pcidev, addr, &ulTmp2); 209 pci_write_config_dword(pcidev, addr, ulTmp1); 210 211 if( ulTmp1 & PCI_BASE_ADDRESS_SPACE_IO ) { 212 pcidev->resource[resNo].flags = IORESOURCE_IO | PCI_BASE_ADDRESS_SPACE_IO; 213 pcidev->resource[resNo].start = ulTmp1 & PCI_BASE_ADDRESS_IO_MASK; 214 pcidev->resource[resNo].end = pcidev->resource[resNo].start + 215 ~(ulTmp2 & PCI_BASE_ADDRESS_IO_MASK) + 1; 216 } 217 else 218 { 219 pcidev->resource[resNo].flags = IORESOURCE_MEM | IORESOURCE_MEM_WRITEABLE; 220 pcidev->resource[resNo].start = ulTmp1 & PCI_BASE_ADDRESS_MEM_MASK; 221 pcidev->resource[resNo].end = pcidev->resource[resNo].start + 222 ~(ulTmp2 & PCI_BASE_ADDRESS_MEM_MASK) + 1; 223 } 224 225 resNo++; 226 } 227 } 228 229 // IRQ and PIN 230 pci_read_config_dword(pcidev, PCI_INTERRUPT_LINE, &ulTmp1); 231 rprintf(("pci_query_device: PCI config IRQ=%d", ulTmp1&0xff)); 232 if( (u8)ulTmp1 && (u8)ulTmp1 != 0xff ) { 233 pcidev->irq_resource[0].flags = IORESOURCE_IRQ; 234 pcidev->irq_resource[0].start = pcidev->irq_resource[0].end = ulTmp1 & 0xffff; 235 pcidev->irq = (u8)ulTmp1; // This is the interrupt used for init time processing 236 } 237 238 return (0x8000 | (busNr << 8) | PCI_DEVFN(devNr, funcNr)); 239 } /* for funcNr */ 240 funcNr = 0; 241 } /* for devNr */ 242 devNr = 0; 243 } 244 outl(cfgaddrreg, PCI_CONFIG_ADDRESS); 245 return 0; 246 } 247 248 //****************************************************************************** 249 //****************************************************************************** 250 // Called from: 251 //if from==NULL search pci bus 252 //if from!=NULL only search already found devices starting with from 126 dprintf(("pcidev_deactivate %x not implemented", dev)); 127 return 1; //todo: correct return value?? 128 } 129 130 /** 131 * Called by: pci_find_device, register_driver 132 * 133 * Find the next matching PCI device starting with the device specified by ulLast 134 * Returns: the found device, pcidev filled in. Returns zero if no device found. 135 */ 136 static ULONG pci_query_device(const struct pci_device_id *pIdTable, struct pci_dev near *pcidev, ULONG ulLast) 137 { 138 int resNo, addr; 139 u32 devNr, busNr, funcNr, detectedId, cfgaddrreg, ulPciAdr, ulTmp1, ulTmp2; 140 u8 headerType; 141 142 busNr = (ulLast >> 8) & 0xff; 143 devNr = PCI_SLOT(ulLast); 144 funcNr = PCI_FUNC(ulLast); 145 if (ulLast) funcNr++; 146 147 cfgaddrreg = inl(PCI_CONFIG_ADDRESS); 148 for ( ; busNr<MAX_PCI_BUSSES; busNr++) //BusNumber<255 149 { 150 for( ; devNr<32; devNr++) 151 { 152 for( ; funcNr<8; funcNr++) 153 { 154 headerType = 0; 155 ulPciAdr = PCI_CONFIG_ENABLE | (busNr<<16) | (devNr<<11) | (funcNr<<8); 156 outl(ulPciAdr, PCI_CONFIG_ADDRESS); 157 detectedId = inl(PCI_CONFIG_DATA); 158 159 if ( detectedId == 0xffffffff ) 160 { 161 if ( funcNr == 0 ) break; /* if func 0 isn't there, the others aren't either */ 162 continue; 163 } 164 165 outl(ulPciAdr + PCI_CLASS_REVISION, PCI_CONFIG_ADDRESS); 166 ulTmp2 = inl(PCI_CONFIG_DATA) >> 8; /* get class */ 167 168 //dprintf(("Found: %x Class=%x need: %x%x class=%x", detectedId, ulTmp2, pIdTable->device&0xffff, pIdTable->vendor, pIdTable->class)); 169 170 if ( pIdTable->class ) 171 { 172 if ( (ulTmp2 & pIdTable->class_mask) != pIdTable->class ) continue; 173 } 174 175 if ( pIdTable->vendor && (pIdTable->vendor != (detectedId & 0xffff)) ) continue; 176 if ( pIdTable->device && (pIdTable->device != PCI_ANY_ID) && (pIdTable->device != (detectedId >> 16)) ) continue; 177 178 outl(ulPciAdr | (PCI_HEADER_TYPE & ~3), PCI_CONFIG_ADDRESS); 179 headerType = inb(PCI_CONFIG_DATA + (PCI_HEADER_TYPE & 3)); 180 181 if ( (headerType & 0x7f) != PCI_HEADER_TYPE_NORMAL ) continue; 182 183 memset((void near *)pcidev, 0, sizeof(struct pci_dev)); 184 185 pcidev->_class = ulTmp2; 186 pcidev->vendor = detectedId & 0xffff; 187 pcidev->device = detectedId >> 16; 188 //pcidev->bus = &pci_busses[busNr]; 189 pcidev->bus = kmalloc(sizeof(struct pci_bus), GFP_KERNEL); 190 if (pcidev->bus == NULL) return 0; 191 memset (pcidev->bus, 0, sizeof(struct pci_bus)); 192 pcidev->bus->number = busNr; 193 pcidev->devfn = PCI_DEVFN(devNr, funcNr); 194 pcidev->hdr_type = headerType & 0x7f; 195 196 pcidev->prepare = pcidev_prepare; 197 pcidev->activate = pcidev_activate; 198 pcidev->deactivate = pcidev_deactivate; 199 pcidev->active = 1; 200 pcidev->ro = 0; 201 pcidev->sibling = NULL; 202 pcidev->next = NULL; 203 pcidev->dma_mask = 0xFFFFFFFF; 204 205 // Subsystem ID 206 pci_read_config_word(pcidev, PCI_SUBSYSTEM_VENDOR_ID, &pcidev->subsystem_vendor); 207 pci_read_config_word(pcidev, PCI_SUBSYSTEM_ID, &pcidev->subsystem_device); 208 209 // I/O and MEM 210 resNo = 0; 211 for( addr = PCI_BASE_ADDRESS_0; addr <= PCI_BASE_ADDRESS_5; addr += 4 ) 212 { 213 pci_read_config_dword(pcidev, addr, &ulTmp1); 214 if( ulTmp1 != 0 && ulTmp1 != 0xffffffff ) 215 { 216 pci_write_config_dword(pcidev, addr, 0xffffffff); 217 pci_read_config_dword(pcidev, addr, &ulTmp2); 218 pci_write_config_dword(pcidev, addr, ulTmp1); 219 220 if( ulTmp1 & PCI_BASE_ADDRESS_SPACE_IO ) 221 { 222 pcidev->resource[resNo].flags = IORESOURCE_IO | PCI_BASE_ADDRESS_SPACE_IO; 223 pcidev->resource[resNo].start = ulTmp1 & PCI_BASE_ADDRESS_IO_MASK; 224 pcidev->resource[resNo].end = pcidev->resource[resNo].start + 225 ~(ulTmp2 & PCI_BASE_ADDRESS_IO_MASK) + 1; 226 } 227 else 228 { 229 pcidev->resource[resNo].flags = IORESOURCE_MEM | IORESOURCE_MEM_WRITEABLE; 230 pcidev->resource[resNo].start = ulTmp1 & PCI_BASE_ADDRESS_MEM_MASK; 231 pcidev->resource[resNo].end = pcidev->resource[resNo].start + 232 ~(ulTmp2 & PCI_BASE_ADDRESS_MEM_MASK) + 1; 233 } 234 235 resNo++; 236 } 237 } 238 239 // IRQ and PIN 240 pci_read_config_dword(pcidev, PCI_INTERRUPT_LINE, &ulTmp1); 241 //rprintf(("pci_query_device: PCI config IRQ=%d", ulTmp1&0xff)); 242 if( (u8)ulTmp1 && (u8)ulTmp1 != 0xff ) 243 { 244 pcidev->irq_resource[0].flags = IORESOURCE_IRQ; 245 pcidev->irq_resource[0].start = pcidev->irq_resource[0].end = ulTmp1 & 0xffff; 246 pcidev->irq = (u8)ulTmp1; // This is the interrupt used for init time processing 247 } 248 249 return ((busNr << 8) | PCI_DEVFN(devNr, funcNr)); 250 } /* for funcNr */ 251 funcNr = 0; 252 } /* for devNr */ 253 devNr = 0; 254 } 255 outl(cfgaddrreg, PCI_CONFIG_ADDRESS); 256 return 0; 257 } 258 259 /** 260 * Called by: snd_pci_dev_present, various sound drivers 261 * 262 * Find the requested device 263 */ 253 264 struct pci_dev *pci_find_device (unsigned int vendor, unsigned int device, struct pci_dev *from) 254 265 { 255 int i; 256 struct pci_device_id id_table; 257 258 for(i=0;i<MAX_PCI_DEVICES;i++) { 259 if ( pci_devices[i].devfn && (pci_devices[i].vendor == vendor) && (pci_devices[i].device == device) ) return &pci_devices[i]; 260 } 261 262 for(i=0;i<MAX_PCI_DEVICES;i++) { 263 if(pci_devices[i].devfn == 0) { 264 memset(&id_table, 0, sizeof(id_table)); 265 id_table.vendor = vendor; 266 id_table.device = device; 267 if( pci_query_device(&id_table, (struct pci_dev near *)&pci_devices[i], 0) ) return &pci_devices[i]; 268 else break; 269 } 270 } 271 272 return NULL; 273 } 274 //****************************************************************************** 275 //****************************************************************************** 276 struct resource * __request_region(struct resource *a, unsigned long start, 277 unsigned long n, const char *name) 278 { 279 struct resource *resource; 280 281 if(a->flags & IORESOURCE_MEM) { 282 if(RMRequestMem(/*hResMgr,*/ start, n) == FALSE) { 283 printk("RMRequestIO failed for io %x, length %x\n", start, n); 284 return NULL; 285 } 286 } 287 else if(a->flags & IORESOURCE_IO) { 288 if(RMRequestIO(/*hResMgr,*/ start, n) == FALSE) { 289 printk("RMRequestIO failed for io %x, length %x\n", start, n); 290 return NULL; 291 } 292 } 293 294 resource = kmalloc(sizeof(struct resource), GFP_KERNEL); 295 if (resource == NULL) 296 return NULL; 297 resource->name = name; 298 resource->start = start; 299 resource->end = start + n; // - 1; 300 resource->flags = a->flags; 301 resource->parent = 302 resource->child = NULL; 303 304 // insert in list 305 resource->sibling = a->sibling; 306 a->sibling = resource; 307 308 return resource; 309 } 310 //****************************************************************************** 311 //****************************************************************************** 312 void __release_region(struct resource *a, 313 unsigned long start, unsigned long n) 314 { 315 struct resource *resource; 316 struct resource **ppres = &a->sibling; 317 unsigned long end = start + n; // - 1; 318 319 while( *ppres ) 320 { 321 resource = *ppres; 322 323 if( resource->start == start && resource->end == end ) 324 { 325 // remove from list 326 *ppres = resource->sibling; 327 kfree(resource); 328 return; 329 } 330 331 ppres = &resource->sibling; 332 } 333 } 334 //****************************************************************************** 335 //****************************************************************************** 266 int i; 267 struct pci_device_id id_table; 268 269 for(i=0; i<MAX_PCI_DEVICES; i++) 270 { 271 if ( pci_devices[i].devfn && (pci_devices[i].vendor == vendor) && (pci_devices[i].device == device) ) return &pci_devices[i]; 272 } 273 274 for(i=0; i<MAX_PCI_DEVICES; i++) 275 { 276 if(pci_devices[i].devfn == 0) 277 { 278 memset(&id_table, 0, sizeof(id_table)); 279 id_table.vendor = vendor; 280 id_table.device = device; 281 if( pci_query_device(&id_table, (struct pci_dev near *)&pci_devices[i], 0) ) return &pci_devices[i]; 282 else break; 283 } 284 } 285 286 return NULL; 287 } 288 289 /** __request_region 290 */ 291 struct resource * __request_region(struct resource *a, unsigned long start, unsigned long n, const char *name) 292 { 293 struct resource *resource; 294 295 if(a->flags & IORESOURCE_MEM) { 296 if(RMRequestMem(/*hResMgr,*/ start, n) == FALSE) { 297 printk("RMRequestIO failed for io %x, length %x\n", start, n); 298 return NULL; 299 } 300 } 301 else if(a->flags & IORESOURCE_IO) { 302 if(RMRequestIO(/*hResMgr,*/ start, n) == FALSE) { 303 printk("RMRequestIO failed for io %x, length %x\n", start, n); 304 return NULL; 305 } 306 } 307 308 resource = kmalloc(sizeof(struct resource), GFP_KERNEL); 309 if (resource == NULL) 310 return NULL; 311 resource->name = name; 312 resource->start = start; 313 resource->end = start + n; // - 1; 314 resource->flags = a->flags; 315 resource->parent = 316 resource->child = NULL; 317 318 // insert in list 319 resource->sibling = a->sibling; 320 a->sibling = resource; 321 322 return resource; 323 } 324 325 /** 326 */ 327 void __release_region(struct resource *a, unsigned long start, unsigned long n) 328 { 329 struct resource *resource; 330 struct resource **ppres = &a->sibling; 331 unsigned long end = start + n; // - 1; 332 333 while( *ppres ) 334 { 335 resource = *ppres; 336 337 if( resource->start == start && resource->end == end ) 338 { 339 // remove from list 340 *ppres = resource->sibling; 341 kfree(resource); 342 return; 343 } 344 345 ppres = &resource->sibling; 346 } 347 } 348 349 /** 350 */ 336 351 int pci_get_flags (struct pci_dev *dev, int n_base) 337 352 { 338 if(n_base >= DEVICE_COUNT_RESOURCE || !dev->resource[n_base].flags) { 339 DebugInt3(); 340 return 0; 341 } 342 return dev->resource[n_base].flags; 343 } 344 //****************************************************************************** 345 //****************************************************************************** 353 if(n_base >= DEVICE_COUNT_RESOURCE || !dev->resource[n_base].flags) { 354 DebugInt3(); 355 return 0; 356 } 357 return dev->resource[n_base].flags; 358 } 359 360 /** 361 */ 346 362 int pcibios_present(void) 347 363 { 348 printk("pcibios_present -> pretend BIOS present\n"); 349 return 1; 350 } 351 //****************************************************************************** 352 //****************************************************************************** 364 printk("pcibios_present -> pretend BIOS present\n"); 365 return 1; 366 } 367 368 /** 369 */ 353 370 struct pci_dev *pci_find_slot (unsigned int bus, unsigned int devfn) 354 371 { 355 printk("pci_find_slot %d %x not implemented!!\n", bus, devfn); 356 DebugInt3(); 357 return NULL; 358 } 359 //****************************************************************************** 360 //****************************************************************************** 372 printk("pci_find_slot %d %x not implemented!!\n", bus, devfn); 373 DebugInt3(); 374 return NULL; 375 } 376 377 /** 378 */ 361 379 int pci_dma_supported(struct pci_dev *dev, unsigned long mask) 362 380 { 363 printk("pci_dma_supported: return TRUE\n"); 364 return 1; 365 } 366 //****************************************************************************** 367 //****************************************************************************** 381 printk("pci_dma_supported: return TRUE\n"); 382 return 1; 383 } 384 385 /** 386 */ 368 387 int pci_find_capability(struct pci_dev *dev, int cap) 369 388 { 370 u16 status; 371 u8 pos, id; 372 int ttl = 48; 373 374 pci_read_config_word(dev, PCI_STATUS, &status); 375 if (!(status & PCI_STATUS_CAP_LIST)) 376 return 0; 377 pci_read_config_byte(dev, PCI_CAPABILITY_LIST, &pos); 378 while (ttl-- && pos >= 0x40) { 379 pos &= ~3; 380 pci_read_config_byte(dev, pos + PCI_CAP_LIST_ID, &id); 381 if (id == 0xff) 382 break; 383 if (id == cap) 384 return pos; 385 pci_read_config_byte(dev, pos + PCI_CAP_LIST_NEXT, &pos); 386 } 387 return 0; 388 } 389 //****************************************************************************** 390 /* 391 * Set power management state of a device. For transitions from state D3 392 * it isn't as straightforward as one could assume since many devices forget 393 * their configuration space during wakeup. Returns old power state. 394 */ 395 //****************************************************************************** 389 u16 status; 390 u8 pos, id; 391 int ttl = 48; 392 393 pci_read_config_word(dev, PCI_STATUS, &status); 394 if (!(status & PCI_STATUS_CAP_LIST)) 395 return 0; 396 pci_read_config_byte(dev, PCI_CAPABILITY_LIST, &pos); 397 while (ttl-- && pos >= 0x40) { 398 pos &= ~3; 399 pci_read_config_byte(dev, pos + PCI_CAP_LIST_ID, &id); 400 if (id == 0xff) 401 break; 402 if (id == cap) 403 return pos; 404 pci_read_config_byte(dev, pos + PCI_CAP_LIST_NEXT, &pos); 405 } 406 return 0; 407 } 408 409 /** 410 * Set power management state of a device. For transitions from state D3 411 * it isn't as straightforward as one could assume since many devices forget 412 * their configuration space during wakeup. Returns old power state. 413 */ 396 414 int pci_set_power_state(struct pci_dev *dev, int new_state) 397 415 { 398 u32 base[5], romaddr; 399 u16 pci_command, pwr_command; 400 u8 pci_latency, pci_cacheline; 401 int i, old_state; 402 int pm = pci_find_capability(dev, PCI_CAP_ID_PM); 403 404 if (!pm) 405 return 0; 406 pci_read_config_word(dev, pm + PCI_PM_CTRL, &pwr_command); 407 old_state = pwr_command & PCI_PM_CTRL_STATE_MASK; 408 if (old_state == new_state) 409 return old_state; 410 if (old_state == 3) { 411 pci_read_config_word(dev, PCI_COMMAND, &pci_command); 412 pci_write_config_word(dev, PCI_COMMAND, pci_command & ~(PCI_COMMAND_IO | PCI_COMMAND_MEMORY)); 413 for (i = 0; i < 5; i++) 414 pci_read_config_dword(dev, PCI_BASE_ADDRESS_0 + i*4, &base[i]); 415 pci_read_config_dword(dev, PCI_ROM_ADDRESS, &romaddr); 416 pci_read_config_byte(dev, PCI_LATENCY_TIMER, &pci_latency); 417 pci_read_config_byte(dev, PCI_CACHE_LINE_SIZE, &pci_cacheline); 418 pci_write_config_word(dev, pm + PCI_PM_CTRL, new_state); 419 for (i = 0; i < 5; i++) 420 pci_write_config_dword(dev, PCI_BASE_ADDRESS_0 + i*4, base[i]); 421 pci_write_config_dword(dev, PCI_ROM_ADDRESS, romaddr); 422 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq); 423 pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, pci_cacheline); 424 pci_write_config_byte(dev, PCI_LATENCY_TIMER, pci_latency); 425 pci_write_config_word(dev, PCI_COMMAND, pci_command); 426 } else 427 pci_write_config_word(dev, pm + PCI_PM_CTRL, (pwr_command & ~PCI_PM_CTRL_STATE_MASK) | new_state); 428 return old_state; 429 } 430 //****************************************************************************** 431 /* 432 * Initialize device before it's used by a driver. Ask low-level code 433 * to enable I/O and memory. Wake up the device if it was suspended. 434 * Beware, this function can fail. 435 */ 436 //****************************************************************************** 416 u32 base[5], romaddr; 417 u16 pci_command, pwr_command; 418 u8 pci_latency, pci_cacheline; 419 int i, old_state; 420 int pm = pci_find_capability(dev, PCI_CAP_ID_PM); 421 422 if (!pm) 423 return 0; 424 pci_read_config_word(dev, pm + PCI_PM_CTRL, &pwr_command); 425 old_state = pwr_command & PCI_PM_CTRL_STATE_MASK; 426 if (old_state == new_state) 427 return old_state; 428 if (old_state == 3) { 429 pci_read_config_word(dev, PCI_COMMAND, &pci_command); 430 pci_write_config_word(dev, PCI_COMMAND, pci_command & ~(PCI_COMMAND_IO | PCI_COMMAND_MEMORY)); 431 for (i = 0; i < 5; i++) 432 pci_read_config_dword(dev, PCI_BASE_ADDRESS_0 + i*4, &base[i]); 433 pci_read_config_dword(dev, PCI_ROM_ADDRESS, &romaddr); 434 pci_read_config_byte(dev, PCI_LATENCY_TIMER, &pci_latency); 435 pci_read_config_byte(dev, PCI_CACHE_LINE_SIZE, &pci_cacheline); 436 pci_write_config_word(dev, pm + PCI_PM_CTRL, new_state); 437 for (i = 0; i < 5; i++) 438 pci_write_config_dword(dev, PCI_BASE_ADDRESS_0 + i*4, base[i]); 439 pci_write_config_dword(dev, PCI_ROM_ADDRESS, romaddr); 440 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq); 441 pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, pci_cacheline); 442 pci_write_config_byte(dev, PCI_LATENCY_TIMER, pci_latency); 443 pci_write_config_word(dev, PCI_COMMAND, pci_command); 444 } else 445 pci_write_config_word(dev, pm + PCI_PM_CTRL, (pwr_command & ~PCI_PM_CTRL_STATE_MASK) | new_state); 446 return old_state; 447 } 448 449 /** 450 * Initialize device before it's used by a driver. Ask low-level code 451 * to enable I/O and memory. Wake up the device if it was suspended. 452 * Beware, this function can fail. 453 */ 437 454 int pci_enable_device(struct pci_dev *dev) 438 455 { 439 u16 pci_command; 440 441 dprintf(("pci_enable_device %x\n", dev)); 442 443 pci_read_config_word(dev, PCI_COMMAND, &pci_command); 444 pci_write_config_word(dev, PCI_COMMAND, pci_command | (PCI_COMMAND_IO | PCI_COMMAND_MEMORY)); 445 pci_set_power_state(dev, 0); 446 return 0; 447 } 448 //****************************************************************************** 449 //****************************************************************************** 456 u16 pci_command; 457 458 dprintf(("pci_enable_device %x\n", dev)); 459 460 pci_read_config_word(dev, PCI_COMMAND, &pci_command); 461 pci_write_config_word(dev, PCI_COMMAND, pci_command | (PCI_COMMAND_IO | PCI_COMMAND_MEMORY)); 462 pci_set_power_state(dev, 0); 463 return 0; 464 } 465 466 /** pci_register_driver 467 * 468 * probes and registers a sound driver with RM. 469 * 470 * Returns: number of cards found. 471 */ 450 472 int pci_register_driver(struct pci_driver *driver) 451 473 { 452 int iTableIx, iNumCards, iTmp; 453 ULONG ulLast; 454 struct pci_dev *pcidev; 455 456 if (!driver->probe) return 0; 457 458 iNumCards = 0; 459 460 /* find an empty slot */ 461 for (iTmp=0; iTmp<MAX_PCI_DEVICES; iTmp++) { 462 if (pci_devices[iTmp].devfn == 0) break; 463 } 464 if (iTmp >= MAX_PCI_DEVICES) return 0; 465 pcidev = &pci_devices[iTmp]; 466 467 for( iTableIx = 0; driver->id_table[iTableIx].vendor; iTableIx++) { 468 ulLast = 0; 469 while( (ulLast = pci_query_device(&driver->id_table[iTableIx], pcidev, ulLast)) ) { 470 471 RMInit(); 472 dprintf(("pci_register_driver: found=%x:%x searching for %x:%x with %s", 473 pcidev->vendor, pcidev->device, driver->id_table[iTableIx].vendor, driver->id_table[iTableIx].device, driver->name)); 474 475 if(driver->probe(pcidev, &driver->id_table[iTableIx]) == 0) { 476 pcidev->pcidriver = (void *)driver; 477 pcidev->current_state = 4; 478 479 // create adapter 480 RMDone((pcidev->device << 16) | pcidev->vendor, &pcidev->hAdapter, &pcidev->hDevice); 481 iNumCards++; 482 483 /* find another empty slot */ 484 for (iTmp=0; iTmp<MAX_PCI_DEVICES; iTmp++) { 485 if (pci_devices[iTmp].devfn == 0) break; 486 } 487 if (iTmp >= MAX_PCI_DEVICES) break; 488 pcidev = &pci_devices[iTmp]; 489 } else { 490 kfree(pcidev->bus); 491 pcidev->devfn = 0; 492 } 493 494 RMDone(0, 0, 0); 495 } 496 } 497 498 return iNumCards; 499 } 500 //****************************************************************************** 501 //****************************************************************************** 474 int iNumCards, iTmp; 475 ULONG ulLast; 476 struct pci_dev *pcidev; 477 struct pci_device_id IdTable; 478 int iAdapter = 0; 479 480 if (!driver->probe) return 0; 481 482 iNumCards = 0; 483 484 /* find an empty slot */ 485 for (iTmp=0; iTmp<MAX_PCI_DEVICES; iTmp++) 486 { 487 if (pci_devices[iTmp].devfn == 0) break; 488 } 489 if (iTmp >= MAX_PCI_DEVICES) return 0; 490 pcidev = &pci_devices[iTmp]; 491 492 memset(&IdTable, 0, sizeof(IdTable)); 493 IdTable.class = 0x000400 << 8; /* Any multimedia device */ 494 IdTable.class_mask = 0xffff00 << 8; 495 ulLast = 0; 496 while( (ulLast = pci_query_device(&IdTable, pcidev, ulLast)) != 0 ) 497 { 498 int iTableIx; 499 500 rprintf(("pci_register_driver: query_device found %x %x:%x class=%x checking %s", 501 ulLast, pcidev->vendor, pcidev->device, pcidev->_class, driver->name)); 502 503 for( iTableIx = 0; driver->id_table[iTableIx].vendor; iTableIx++) 504 { 505 struct pci_device_id const *pDriverId = &driver->id_table[iTableIx]; 506 507 if ( (pDriverId->class) && ((pcidev->_class & pDriverId->class_mask) != pDriverId->class) ) continue; 508 if (pDriverId->vendor != pcidev->vendor) continue; 509 if ( (pDriverId->device != PCI_ANY_ID) && (pDriverId->device != pcidev->device) ) continue; 510 511 rprintf(("pci_register_driver: matched %d %x:%x/%x with %x:%x/%x %x (%s)", iTableIx, 512 pcidev->vendor, pcidev->device, pcidev->_class, 513 pDriverId->vendor, pDriverId->device, pDriverId->class, pDriverId->class_mask, driver->name)); 514 515 if (iAdapter < iAdapterNumber) 516 { 517 iAdapter++; 518 continue; 519 } 520 521 RMInit(); 522 if (driver->probe(pcidev, pDriverId) == 0) 523 { 524 pcidev->pcidriver = (void *)driver; 525 pcidev->current_state = 4; 526 527 // create adapter 528 RMDone((pcidev->device << 16) | pcidev->vendor, &pcidev->hAdapter, &pcidev->hDevice); 529 iNumCards++; 530 pcidev = NULL; /* we need a new slot */ 531 break; 532 } 533 RMDone(0, 0, 0); 534 } /* for id_table loop */ 535 if (pcidev) 536 { 537 kfree(pcidev->bus); 538 pcidev->devfn = 0; 539 } 540 else 541 { 542 /* find another empty slot */ 543 for (iTmp=0; iTmp<MAX_PCI_DEVICES; iTmp++) 544 { 545 if (pci_devices[iTmp].devfn == 0) break; 546 } 547 if (iTmp >= MAX_PCI_DEVICES) break; 548 pcidev = &pci_devices[iTmp]; 549 } 550 } /* pci_query_device loop */ 551 552 return iNumCards; 553 } 554 555 /** 556 */ 502 557 int pci_module_init(struct pci_driver *drv) 503 558 { 504 int res = pci_register_driver(drv); 505 if (res == 0) return -ENODEV; 506 return res; 507 } 508 //****************************************************************************** 509 //****************************************************************************** 559 int res = pci_register_driver(drv); 560 if (res == 0) return -ENODEV; 561 return res; 562 } 563 564 /** 565 */ 510 566 int pci_unregister_driver(struct pci_driver *driver) 511 567 { 512 struct pci_dev *pcidev; 513 int i, j; 514 515 for (i=0; driver->id_table[i].vendor; i++) { 516 for(j=0; j<MAX_PCI_DEVICES; j++) { 517 pcidev = &pci_devices[j]; 518 if (pcidev->devfn == 0) continue; 519 if (pcidev->vendor != driver->id_table[i].vendor) continue; 520 if ( (driver->id_table[i].device != PCI_ANY_ID) && (pcidev->device != driver->id_table[i].device) ) continue; 521 dprintf(("pci unreg match: %x:%x %x:%x", pci_devices[j].vendor, pci_devices[j].device, driver->id_table[i].vendor, driver->id_table[i].device)); 522 if (driver->remove) driver->remove(pcidev); 523 kfree(pcidev->bus); 524 pcidev->devfn = 0; 525 } 526 } 527 return 0; 528 } 529 //****************************************************************************** 530 //****************************************************************************** 568 struct pci_dev *pcidev; 569 int i, j; 570 571 for (i=0; driver->id_table[i].vendor; i++) { 572 for(j=0; j<MAX_PCI_DEVICES; j++) { 573 pcidev = &pci_devices[j]; 574 if (pcidev->devfn == 0) continue; 575 if (pcidev->vendor != driver->id_table[i].vendor) continue; 576 if ( (driver->id_table[i].device != PCI_ANY_ID) && (pcidev->device != driver->id_table[i].device) ) continue; 577 dprintf(("pci unreg match: %x:%x %x:%x", pci_devices[j].vendor, pci_devices[j].device, driver->id_table[i].vendor, driver->id_table[i].device)); 578 if (driver->remove) driver->remove(pcidev); 579 kfree(pcidev->bus); 580 pcidev->devfn = 0; 581 } 582 } 583 return 0; 584 } 585 586 /** 587 */ 531 588 void pci_set_master(struct pci_dev *dev) 532 589 { 533 u16 cmd; 534 535 pci_read_config_word(dev, PCI_COMMAND, &cmd); 536 if (! (cmd & PCI_COMMAND_MASTER)) { 537 dprintf(("pci_set_master %x", dev)); 538 cmd |= PCI_COMMAND_MASTER; 539 pci_write_config_word(dev, PCI_COMMAND, cmd); 540 } 541 return; 542 } 543 //****************************************************************************** 544 // * Register a device with power management 545 //****************************************************************************** 590 u16 cmd; 591 592 pci_read_config_word(dev, PCI_COMMAND, &cmd); 593 if (! (cmd & PCI_COMMAND_MASTER)) { 594 dprintf(("pci_set_master %x", dev)); 595 cmd |= PCI_COMMAND_MASTER; 596 pci_write_config_word(dev, PCI_COMMAND, cmd); 597 } 598 return; 599 } 600 601 /** 602 * Register a device with power management 603 */ 546 604 struct pm_dev *pm_register(pm_dev_t type, unsigned long id, pm_callback callback) 547 605 { 548 dprintf(("pm_register STUB")); 549 DebugInt3(); 550 return NULL; 551 } 552 //****************************************************************************** 553 // * Unregister a device with power management 554 //****************************************************************************** 606 dprintf(("pm_register STUB")); 607 DebugInt3(); 608 return NULL; 609 } 610 611 /** 612 * Unregister a device with power management 613 */ 555 614 void pm_unregister(struct pm_dev *dev) 556 615 { 557 dprintf(("pm_unregister STUB")); 558 } 559 //****************************************************************************** 560 //****************************************************************************** 616 dprintf(("pm_unregister STUB")); 617 } 618 619 /** 620 */ 561 621 int __compat_get_order(unsigned long size) 562 622 { 563 int order; 564 565 size = (size-1) >> (PAGE_SHIFT-1); 566 order = -1; 567 do { 568 size >>= 1; 569 order++; 570 } while (size); 571 return order; 572 } 573 //****************************************************************************** 574 //****************************************************************************** 623 int order; 624 625 size = (size-1) >> (PAGE_SHIFT-1); 626 order = -1; 627 do { 628 size >>= 1; 629 order++; 630 } while (size); 631 return order; 632 } 633 634 /** 635 */ 575 636 void *pci_alloc_consistent(struct pci_dev *hwdev, 576 long size, dma_addr_t *dma_handle) 577 { 578 void *ret = NULL; 579 int gfp = GFP_ATOMIC; 580 int order; 581 dprintf(("pci_alloc_consistent %d mask %x", size, (hwdev) ? hwdev->dma_mask : 0)); 582 if (hwdev == NULL || hwdev->dma_mask != 0xffffffff) { 583 //try not to exhaust low memory (< 16mb) so allocate from the high region first 584 //if that doesn't satisfy the dma mask requirement, then get it from the low 585 //regino anyway 586 if(hwdev->dma_mask > 0x00ffffff) { 587 order = __compat_get_order(size); 588 ret = (void *)__get_free_pages(gfp|GFP_DMAHIGHMEM, order); 589 *dma_handle = virt_to_bus(ret); 590 if(*dma_handle > hwdev->dma_mask) { 591 free_pages((unsigned long)ret, __compat_get_order(size)); 592 //be sure and allocate below 16 mb 593 gfp |= GFP_DMA; 594 ret = NULL; 595 } 596 } 597 else { //must always allocate below 16 mb 598 gfp |= GFP_DMA; 599 } 600 } 601 if(ret == NULL) { 602 ret = (void *)__get_free_pages(gfp, __compat_get_order(size)); 603 } 604 605 if (ret != NULL) { 606 memset(ret, 0, size); 607 *dma_handle = virt_to_bus(ret); 608 } 609 return ret; 610 } 611 //****************************************************************************** 612 //****************************************************************************** 637 long size, dma_addr_t *dma_handle) 638 { 639 void *ret = NULL; 640 int gfp = GFP_ATOMIC; 641 int order; 642 dprintf(("pci_alloc_consistent %d mask %x", size, (hwdev) ? hwdev->dma_mask : 0)); 643 if (hwdev == NULL || hwdev->dma_mask != 0xffffffff) { 644 //try not to exhaust low memory (< 16mb) so allocate from the high region first 645 //if that doesn't satisfy the dma mask requirement, then get it from the low 646 //regino anyway 647 if(hwdev->dma_mask > 0x00ffffff) { 648 order = __compat_get_order(size); 649 ret = (void *)__get_free_pages(gfp|GFP_DMAHIGHMEM, order); 650 *dma_handle = virt_to_bus(ret); 651 if(*dma_handle > hwdev->dma_mask) { 652 free_pages((unsigned long)ret, __compat_get_order(size)); 653 //be sure and allocate below 16 mb 654 gfp |= GFP_DMA; 655 ret = NULL; 656 } 657 } 658 else { //must always allocate below 16 mb 659 gfp |= GFP_DMA; 660 } 661 } 662 if(ret == NULL) { 663 ret = (void *)__get_free_pages(gfp, __compat_get_order(size)); 664 } 665 666 if (ret != NULL) { 667 memset(ret, 0, size); 668 *dma_handle = virt_to_bus(ret); 669 } 670 return ret; 671 } 672 673 /** 674 */ 613 675 void pci_free_consistent(struct pci_dev *hwdev, long size, 614 void *vaddr, dma_addr_t dma_handle) 615 { 616 free_pages((unsigned long)vaddr, __compat_get_order(size)); 617 } 618 //****************************************************************************** 619 //****************************************************************************** 676 void *vaddr, dma_addr_t dma_handle) 677 { 678 free_pages((unsigned long)vaddr, __compat_get_order(size)); 679 } 680 681 /** 682 */ 620 683 void pci_set_driver_data (struct pci_dev *dev, void *driver_data) 621 684 { 622 if (dev) 623 dev->driver_data = driver_data; 624 } 625 //****************************************************************************** 626 //****************************************************************************** 685 if (dev) 686 dev->driver_data = driver_data; 687 } 688 689 /** 690 */ 627 691 void *pci_get_driver_data (struct pci_dev *dev) 628 692 { 629 if (dev) 630 return dev->driver_data; 631 return 0; 632 } 633 //****************************************************************************** 634 //****************************************************************************** 693 if (dev) 694 return dev->driver_data; 695 return 0; 696 } 697 698 /** 699 */ 635 700 unsigned long pci_get_dma_mask (struct pci_dev *dev) 636 701 { 637 if (dev) 638 return dev->dma_mask; 639 return 0; 640 } 641 //****************************************************************************** 642 //****************************************************************************** 702 if (dev) 703 return dev->dma_mask; 704 return 0; 705 } 706 707 /** 708 */ 643 709 int release_resource(struct resource *newres) 644 710 { 645 646 } 647 648 / /******************************************************************************649 //****************************************************************************** 711 return 0; 712 } 713 714 /** 715 */ 650 716 int pci_set_latency_time(struct pci_dev *dev, int latency) 651 717 { 652 pci_write_config_byte(dev, PCI_LATENCY_TIMER, latency); 653 return 0; 654 } 655 656 //****************************************************************************** 657 //****************************************************************************** 718 pci_write_config_byte(dev, PCI_LATENCY_TIMER, latency); 719 return 0; 720 } 721 658 722 /** 659 723 * pci_save_state - save the PCI configuration space of a device before suspending … … 666 730 int pci_orig_save_state(struct pci_dev *dev, u32 *buffer) 667 731 { 668 669 670 671 672 673 674 732 int i; 733 if (buffer) { 734 /* XXX: 100% dword access ok here? */ 735 for (i = 0; i < 16; i++) 736 pci_read_config_dword(dev, i * 4,&buffer[i]); 737 } 738 return 0; 675 739 } 676 740 … … 681 745 * 682 746 */ 683 int 684 pci_orig_restore_state(struct pci_dev *dev, u32 *buffer) 685 { 686 int i; 687 688 if (buffer) { 689 for (i = 0; i < 16; i++) 690 pci_write_config_dword(dev,i * 4, buffer[i]); 691 } 692 /* 693 * otherwise, write the context information we know from bootup. 694 * This works around a problem where warm-booting from Windows 695 * combined with a D3(hot)->D0 transition causes PCI config 696 * header data to be forgotten. 697 */ 698 else { 699 for (i = 0; i < 6; i ++) 700 pci_write_config_dword(dev, 701 PCI_BASE_ADDRESS_0 + (i * 4), 702 dev->resource[i].start); 703 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq); 704 } 705 return 0; 747 int pci_orig_restore_state(struct pci_dev *dev, u32 *buffer) 748 { 749 int i; 750 751 if (buffer) { 752 for (i = 0; i < 16; i++) 753 pci_write_config_dword(dev,i * 4, buffer[i]); 754 } 755 /* 756 * otherwise, write the context information we know from bootup. 757 * This works around a problem where warm-booting from Windows 758 * combined with a D3(hot)->D0 transition causes PCI config 759 * header data to be forgotten. 760 */ 761 else { 762 for (i = 0; i < 6; i ++) 763 pci_write_config_dword(dev, 764 PCI_BASE_ADDRESS_0 + (i * 4), 765 dev->resource[i].start); 766 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq); 767 } 768 return 0; 706 769 } 707 770 708 771 struct saved_config_tbl { 709 710 772 struct pci_dev *pci; 773 u32 config[16]; 711 774 }; 712 775 static struct saved_config_tbl saved_tbl[16]; … … 714 777 int pci_save_state(struct pci_dev *pci) 715 778 { 716 717 718 719 720 721 722 723 724 725 726 779 int i; 780 /* FIXME: mutex needed for race? */ 781 for (i = 0; i < ARRAY_SIZE(saved_tbl); i++) { 782 if (! saved_tbl[i].pci) { 783 saved_tbl[i].pci = pci; 784 pci_orig_save_state(pci, saved_tbl[i].config); 785 return 1; 786 } 787 } 788 printk(KERN_DEBUG "snd: no pci config space found!\n"); 789 return 0; 727 790 } 728 791 729 792 int pci_restore_state(struct pci_dev *pci) 730 793 { 731 732 733 734 735 736 737 738 739 740 741 794 int i; 795 /* FIXME: mutex needed for race? */ 796 for (i = 0; i < ARRAY_SIZE(saved_tbl); i++) { 797 if (saved_tbl[i].pci == pci) { 798 saved_tbl[i].pci = NULL; 799 pci_orig_restore_state(pci, saved_tbl[i].config); 800 return 0; 801 } 802 } 803 printk(KERN_DEBUG "snd: no saved pci config!\n"); 804 return 1; 742 805 } 743 806 744 807 void pci_disable_device(struct pci_dev *dev) 745 808 { 746 747 748 749 750 751 752 809 u16 pci_command; 810 811 pci_read_config_word(dev, PCI_COMMAND, &pci_command); 812 if (pci_command & PCI_COMMAND_MASTER) { 813 pci_command &= ~PCI_COMMAND_MASTER; 814 pci_write_config_word(dev, PCI_COMMAND, pci_command); 815 } 753 816 } 754 817 755 818 int pci_request_region(struct pci_dev *pdev, int bar, char *res_name) 756 819 { 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 820 int flags; 821 822 if (pci_resource_len(pdev, bar) == 0) 823 return 0; 824 flags = pci_get_flags(pdev, bar); 825 if (flags & IORESOURCE_IO) { 826 if (check_region(pci_resource_start(pdev, bar), pci_resource_len(pdev, bar))) 827 goto err_out; 828 request_region(pci_resource_start(pdev, bar), 829 pci_resource_len(pdev, bar), res_name); 830 } 831 else if (flags & IORESOURCE_MEM) { 832 if (check_mem_region(pci_resource_start(pdev, bar), pci_resource_len(pdev, bar))) 833 goto err_out; 834 request_mem_region(pci_resource_start(pdev, bar), 835 pci_resource_len(pdev, bar), res_name); 836 } 837 838 return 0; 776 839 777 840 err_out: 778 779 780 781 782 783 841 printk(KERN_WARNING "PCI: Unable to reserve %s region #%d:%lx@%lx for device %s\n", 842 flags & IORESOURCE_IO ? "I/O" : "mem", 843 bar + 1, /* PCI BAR # */ 844 pci_resource_len(pdev, bar), pci_resource_start(pdev, bar), 845 res_name); 846 return -EBUSY; 784 847 } 785 848 786 849 void pci_release_region(struct pci_dev *pdev, int bar) 787 850 { 788 789 790 791 792 793 794 795 796 797 798 799 800 851 int flags; 852 853 if (pci_resource_len(pdev, bar) == 0) 854 return; 855 flags = pci_get_flags(pdev, bar); 856 if (flags & IORESOURCE_IO) { 857 release_region(pci_resource_start(pdev, bar), 858 pci_resource_len(pdev, bar)); 859 } 860 else if (flags & IORESOURCE_MEM) { 861 release_mem_region(pci_resource_start(pdev, bar), 862 pci_resource_len(pdev, bar)); 863 } 801 864 } 802 865 803 866 int pci_request_regions(struct pci_dev *pdev, char *res_name) 804 867 { 805 806 807 808 809 810 811 812 813 814 868 int i; 869 870 for (i = 0; i < 6; i++) 871 if (pci_request_region(pdev, i, res_name)) 872 goto err; 873 return 0; 874 err: 875 while (--i >= 0) 876 pci_release_region(pdev, i); 877 return -EBUSY; 815 878 } 816 879 817 880 void pci_release_regions(struct pci_dev *pdev) 818 881 { 819 820 821 882 int i; 883 for (i = 0; i < 6; i++) 884 pci_release_region(pdev, i); 822 885 } 823 886 824 887 const struct pci_device_id * pci_match_device(const struct pci_device_id *ids, struct pci_dev *dev) 825 888 { 826 u16 subsystem_vendor, subsystem_device; 827 828 pci_read_config_word(dev, PCI_SUBSYSTEM_VENDOR_ID, &subsystem_vendor); 829 pci_read_config_word(dev, PCI_SUBSYSTEM_ID, &subsystem_device); 830 831 while (ids->vendor || ids->subvendor || ids->class_mask) { 832 if ((ids->vendor == PCI_ANY_ID || ids->vendor == dev->vendor) && 833 (ids->device == PCI_ANY_ID || ids->device == dev->device) && 834 (ids->subvendor == PCI_ANY_ID || ids->subvendor == subsystem_vendor) && 835 (ids->subdevice == PCI_ANY_ID || ids->subdevice == subsystem_device) && 836 !((ids->class ^ dev->_class) & ids->class_mask)) 837 return ids; 838 ids++; 839 } 840 return NULL; 841 } 842 889 u16 subsystem_vendor, subsystem_device; 890 891 pci_read_config_word(dev, PCI_SUBSYSTEM_VENDOR_ID, &subsystem_vendor); 892 pci_read_config_word(dev, PCI_SUBSYSTEM_ID, &subsystem_device); 893 894 while (ids->vendor || ids->subvendor || ids->class_mask) { 895 if ((ids->vendor == PCI_ANY_ID || ids->vendor == dev->vendor) && 896 (ids->device == PCI_ANY_ID || ids->device == dev->device) && 897 (ids->subvendor == PCI_ANY_ID || ids->subvendor == subsystem_vendor) && 898 (ids->subdevice == PCI_ANY_ID || ids->subdevice == subsystem_device) && 899 !((ids->class ^ dev->_class) & ids->class_mask)) 900 return ids; 901 ids++; 902 } 903 return NULL; 904 } 905 906 /** snd_pci_dev_present 907 * Called by: various sound drivers 908 */ 843 909 int snd_pci_dev_present(const struct pci_device_id *ids) 844 910 { 845 while (ids->vendor || ids->subvendor) { 846 if (pci_find_device(ids->vendor, ids->subvendor, NULL)) 847 848 849 850 911 while (ids->vendor || ids->subvendor) 912 { 913 if (pci_find_device(ids->vendor, ids->subvendor, NULL)) return 1; 914 ids++; 915 } 916 return 0; 851 917 } 852 918 853 919 struct pci_driver_mapping { 854 855 856 857 858 920 struct pci_dev *dev; 921 struct pci_driver *drv; 922 unsigned long dma_mask; 923 void *driver_data; 924 u32 saved_config[16]; 859 925 }; 860 926 … … 865 931 static struct pci_driver_mapping *get_pci_driver_mapping(struct pci_dev *dev) 866 932 { 867 868 869 870 871 872 933 int i; 934 935 for (i = 0; i < PCI_MAX_MAPPINGS; i++) 936 if (drvmap[i].dev == dev) 937 return &drvmap[i]; 938 return NULL; 873 939 } 874 940 875 941 struct pci_driver *snd_pci_compat_get_pci_driver(struct pci_dev *dev) 876 942 { 877 878 879 880 943 struct pci_driver_mapping *map = get_pci_driver_mapping(dev); 944 if (map) 945 return map->drv; 946 return NULL; 881 947 } 882 948 #if 0 883 949 void * pci_get_drvdata (struct pci_dev *dev) 884 950 { 885 886 887 888 951 struct pci_driver_mapping *map = get_pci_driver_mapping(dev); 952 if (map) 953 return map->driver_data; 954 return NULL; 889 955 } 890 956 … … 892 958 void pci_set_drvdata (struct pci_dev *dev, void *driver_data) 893 959 { 894 895 896 960 struct pci_driver_mapping *map = get_pci_driver_mapping(dev); 961 if (map) 962 map->driver_data = driver_data; 897 963 } 898 964 #endif … … 903 969 OSSRET OSS32_APMResume() 904 970 { 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 971 int i; 972 struct pci_driver *driver; 973 974 dprintf(("OSS32_APMResume")); 975 976 for(i=0;i<MAX_PCI_DEVICES;i++) 977 { 978 if(pci_devices[i].devfn) 979 { 980 RMSetHandles(pci_devices[i].hAdapter, pci_devices[i].hDevice); /* DAZ - dirty hack */ 981 driver = pci_devices[i].pcidriver; 982 if(driver && driver->resume) { 983 driver->resume(&pci_devices[i]); 984 } 985 } 986 } 987 988 return OSSERR_SUCCESS; 923 989 } 924 990 //****************************************************************************** … … 926 992 OSSRET OSS32_APMSuspend() 927 993 { 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 } 948 994 int i; 995 struct pci_driver *driver; 996 997 dprintf(("OSS32_APMSuspend 1")); 998 999 for(i=0;i<MAX_PCI_DEVICES;i++) 1000 { 1001 if(pci_devices[i].devfn) 1002 { 1003 RMSetHandles(pci_devices[i].hAdapter, pci_devices[i].hDevice); /* DAZ - dirty hack */ 1004 driver = pci_devices[i].pcidriver; 1005 if(driver && driver->suspend) { 1006 driver->suspend(&pci_devices[i], SNDRV_CTL_POWER_D3cold); 1007 } 1008 } 1009 } 1010 1011 dprintf(("OSS32_APMSuspend 2")); 1012 return OSSERR_SUCCESS; 1013 } 1014 -
GPL/branches/uniaud32-2.1.x/tools/AddToFile.cmd
r588 r593 11 11 call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs' 12 12 call SysLoadFuncs 13 parse arg OutFile','String','Function','Parm1','Parm2','Parm3','Parm4 ;13 parse arg OutFile','String','Function','Parm1','Parm2','Parm3','Parm4','Parm5; 14 14 15 15 if (OutFile='') then do … … 33 33 rc=LineOut(MyFile, '--- AddToFile.cmd '||MyCmd); 34 34 call 'AddToFile.cmd' MyCmd; 35 MyCmd=MyFile||',option description,BLDLEVEL,Vendor,1.2.3,Description,Fixpack ';35 MyCmd=MyFile||',option description,BLDLEVEL,Vendor,1.2.3,Description,Fixpack,Asd'; 36 36 rc=LineOut(MyFile, '--- AddToFile.cmd '||MyCmd); 37 37 call 'AddToFile.cmd' MyCmd; … … 100 100 end 101 101 102 NewStr='@#'||Parm1||':'||Parm2||'#@##1## '||ProjString||': :::'||ProjVersion||'::'||Parm4||'@@'||Parm3;102 NewStr='@#'||Parm1||':'||Parm2||'#@##1## '||ProjString||':'||Parm5||':::'||ProjVersion||'::'||Parm4||'@@'||Parm3; 103 103 if (Type='2') then do 104 104 /*OutStr=String||' "@#'||Parm1||':'||Parm2||'#@##1## '||ProjString||'::::'||ProjVersion||'::'||Parm4||'@@'||Parm3||'"';*/ -
GPL/branches/uniaud32-2.1.x/tools/header.mif
r588 r593 45 45 46 46 !if "$(DEBUG)" == "1" 47 CFLAGS = -dDEBUG -bt=os2v2 -e60 -hc -5r -omlinear -s -w4 -ze -zdp -zl -zq -nt=CODE32 -zff -zgf 47 CFLAGS = -dDEBUG -bt=os2v2 -e60 -hc -5r -omlinear -s -w4 -ze -zdp -zl -zq -nt=CODE32 -zff -zgf -ei 48 48 CPPFLAGS= -xd 49 49 ASFLAGS = -D:DEBUG -Mb -Li -Sv:M510 50 50 !else 51 CFLAGS = -bt=os2v2 -e60 -5r -omlinear -s -w4 -ze -zdp -zl -zq -nt=CODE32 -zff -zgf 51 CFLAGS = -bt=os2v2 -e60 -5r -omlinear -s -w4 -ze -zdp -zl -zq -nt=CODE32 -zff -zgf -ei 52 52 CPPFLAGS= -xd 53 53 ASFLAGS = -Mb -Li -Sv:M510 -
GPL/branches/uniaud32-2.1.x/uniaud.inc
r592 r593 7 7 # BUILDVERSION must be 3 parts, and only numbers like 5.44.108 8 8 # The second and third numbers must be 2 digits 9 BUILDVERSION = 2.02.0 19 BUILDVERSION = 2.02.02 10 10 11 11 # Fixpack version
Note:
See TracChangeset
for help on using the changeset viewer.