Changeset 604
- Timestamp:
- Jan 8, 2018, 2:07:36 AM (8 years ago)
- Location:
- GPL/trunk
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
GPL/trunk/alsa-kernel/core/pcm_lib.c
r598 r604 433 433 434 434 /* Do jiffies check only in xrun_debug mode */ 435 #ifdef CONFIG_SND_PCM_XRUN_DEBUG435 //#ifdef CONFIG_SND_PCM_XRUN_DEBUG 436 436 if (!xrun_debug(substream, XRUN_DEBUG_JIFFIESCHECK)) 437 437 goto no_jiffies_check; 438 #endif438 //#endif 439 439 /* Skip the jiffies check for hardwares with BATCH flag. 440 440 * Such hardware usually just increases the position at each IRQ, -
GPL/trunk/alsa-kernel/pci/hda/hda_intel.c
r598 r604 25 25 * CONTACTS: 26 26 * 27 * Matt Jared 28 * Andy Kopp 29 * Dan Kogan 27 * Matt Jared matt.jared@intel.com 28 * Andy Kopp andy.kopp@intel.com 29 * Dan Kogan dan.d.kogan@intel.com 30 30 * 31 31 * CHANGES: 32 32 * 33 * 2004.12.01 33 * 2004.12.01 Major rewrite by tiwai, merged the work of pshou 34 34 * 35 35 */ … … 72 72 #ifdef CONFIG_SND_HDA_INPUT_BEEP 73 73 static int beep_mode[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = 74 74 CONFIG_SND_HDA_INPUT_BEEP_MODE}; 75 75 #endif 76 76 … … 85 85 module_param_array(position_fix, int, NULL, 0444); 86 86 MODULE_PARM_DESC(position_fix, "DMA pointer read method." 87 87 "(0 = auto, 1 = LPIB, 2 = POSBUF, 3 = VIACOMBO)."); 88 88 module_param_array(bdl_pos_adj, int, NULL, 0644); 89 89 MODULE_PARM_DESC(bdl_pos_adj, "BDL position adjustment offset."); … … 94 94 module_param(single_cmd, bool, 0444); 95 95 MODULE_PARM_DESC(single_cmd, "Use single command to communicate with codecs " 96 96 "(for debugging only)."); 97 97 module_param(enable_msi, int, 0444); 98 98 MODULE_PARM_DESC(enable_msi, "Enable Message Signaled Interrupt (MSI)"); … … 104 104 module_param_array(beep_mode, int, NULL, 0444); 105 105 MODULE_PARM_DESC(beep_mode, "Select HDA Beep registration mode " 106 106 "(0=off, 1=on, 2=mute switch on/off) (default=1)."); 107 107 #endif 108 108 … … 111 111 module_param(power_save, int, 0644); 112 112 MODULE_PARM_DESC(power_save, "Automatic power-saving timeout " 113 113 "(in second, 0 = disable)."); 114 114 115 115 /* reset the HD-audio controller in power save mode. … … 124 124 MODULE_LICENSE("GPL"); 125 125 MODULE_SUPPORTED_DEVICE("{{Intel, ICH6}," 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 126 "{Intel, ICH6M}," 127 "{Intel, ICH7}," 128 "{Intel, ESB2}," 129 "{Intel, ICH8}," 130 "{Intel, ICH9}," 131 "{Intel, ICH10}," 132 "{Intel, PCH}," 133 "{Intel, CPT}," 134 "{Intel, PBG}," 135 "{Intel, SCH}," 136 "{ATI, SB450}," 137 "{ATI, SB600}," 138 "{ATI, RS600}," 139 "{ATI, RS690}," 140 "{ATI, RS780}," 141 "{ATI, R600}," 142 "{ATI, RV630}," 143 "{ATI, RV610}," 144 "{ATI, RV670}," 145 "{ATI, RV635}," 146 "{ATI, RV620}," 147 "{ATI, RV770}," 148 "{VIA, VT8251}," 149 "{VIA, VT8237A}," 150 "{SiS, SIS966}," 151 "{ULI, M5461}}"); 152 152 MODULE_DESCRIPTION("Intel HDA driver"); 153 153 154 154 #ifdef CONFIG_SND_VERBOSE_PRINTK 155 #define SFX 155 #define SFX /* nop */ 156 156 #else 157 #define SFX 157 #define SFX "hda-intel: " 158 158 #endif 159 159 … … 161 161 * registers 162 162 */ 163 #define ICH6_REG_GCAP 164 #define ICH6_GCAP_64OK 165 #define ICH6_GCAP_NSDO 166 #define ICH6_GCAP_BSS 167 #define ICH6_GCAP_ISS 168 #define ICH6_GCAP_OSS 169 #define ICH6_REG_VMIN 170 #define ICH6_REG_VMAJ 171 #define ICH6_REG_OUTPAY 172 #define ICH6_REG_INPAY 173 #define ICH6_REG_GCTL 174 #define ICH6_GCTL_RESET 175 #define ICH6_GCTL_FCNTRL 176 #define ICH6_GCTL_UNSOL 177 #define ICH6_REG_WAKEEN 178 #define ICH6_REG_STATESTS 179 #define ICH6_REG_GSTS 180 #define ICH6_GSTS_FSTS 181 #define ICH6_REG_INTCTL 182 #define ICH6_REG_INTSTS 183 #define ICH6_REG_WALLCLK 0x30/* 24Mhz source */184 #define ICH6_REG_SYNC 0x34185 #define ICH6_REG_CORBLBASE 186 #define ICH6_REG_CORBUBASE 187 #define ICH6_REG_CORBWP 188 #define ICH6_REG_CORBRP 189 #define ICH6_CORBRP_RST 190 #define ICH6_REG_CORBCTL 191 #define ICH6_CORBCTL_RUN 192 #define ICH6_CORBCTL_CMEIE 193 #define ICH6_REG_CORBSTS 194 #define ICH6_CORBSTS_CMEI 195 #define ICH6_REG_CORBSIZE 196 197 #define ICH6_REG_RIRBLBASE 198 #define ICH6_REG_RIRBUBASE 199 #define ICH6_REG_RIRBWP 200 #define ICH6_RIRBWP_RST 201 #define ICH6_REG_RINTCNT 202 #define ICH6_REG_RIRBCTL 203 #define ICH6_RBCTL_IRQ_EN 204 #define ICH6_RBCTL_DMA_EN 205 #define ICH6_RBCTL_OVERRUN_EN 206 #define ICH6_REG_RIRBSTS 207 #define ICH6_RBSTS_IRQ 208 #define ICH6_RBSTS_OVERRUN 209 #define ICH6_REG_RIRBSIZE 210 211 #define ICH6_REG_IC 212 #define ICH6_REG_IR 213 #define ICH6_REG_IRS 214 #define ICH6_IRS_VALID 215 #define ICH6_IRS_BUSY 216 217 #define ICH6_REG_DPLBASE 218 #define ICH6_REG_DPUBASE 219 #define ICH6_DPLBASE_ENABLE 0x1/* Enable position buffer */163 #define ICH6_REG_GCAP 0x00 164 #define ICH6_GCAP_64OK (1 << 0) /* 64bit address support */ 165 #define ICH6_GCAP_NSDO (3 << 1) /* # of serial data out signals */ 166 #define ICH6_GCAP_BSS (31 << 3) /* # of bidirectional streams */ 167 #define ICH6_GCAP_ISS (15 << 8) /* # of input streams */ 168 #define ICH6_GCAP_OSS (15 << 12) /* # of output streams */ 169 #define ICH6_REG_VMIN 0x02 170 #define ICH6_REG_VMAJ 0x03 171 #define ICH6_REG_OUTPAY 0x04 172 #define ICH6_REG_INPAY 0x06 173 #define ICH6_REG_GCTL 0x08 174 #define ICH6_GCTL_RESET (1 << 0) /* controller reset */ 175 #define ICH6_GCTL_FCNTRL (1 << 1) /* flush control */ 176 #define ICH6_GCTL_UNSOL (1 << 8) /* accept unsol. response enable */ 177 #define ICH6_REG_WAKEEN 0x0c 178 #define ICH6_REG_STATESTS 0x0e 179 #define ICH6_REG_GSTS 0x10 180 #define ICH6_GSTS_FSTS (1 << 1) /* flush status */ 181 #define ICH6_REG_INTCTL 0x20 182 #define ICH6_REG_INTSTS 0x24 183 #define ICH6_REG_WALLCLK 0x30 /* 24Mhz source */ 184 #define ICH6_REG_SYNC 0x34 185 #define ICH6_REG_CORBLBASE 0x40 186 #define ICH6_REG_CORBUBASE 0x44 187 #define ICH6_REG_CORBWP 0x48 188 #define ICH6_REG_CORBRP 0x4a 189 #define ICH6_CORBRP_RST (1 << 15) /* read pointer reset */ 190 #define ICH6_REG_CORBCTL 0x4c 191 #define ICH6_CORBCTL_RUN (1 << 1) /* enable DMA */ 192 #define ICH6_CORBCTL_CMEIE (1 << 0) /* enable memory error irq */ 193 #define ICH6_REG_CORBSTS 0x4d 194 #define ICH6_CORBSTS_CMEI (1 << 0) /* memory error indication */ 195 #define ICH6_REG_CORBSIZE 0x4e 196 197 #define ICH6_REG_RIRBLBASE 0x50 198 #define ICH6_REG_RIRBUBASE 0x54 199 #define ICH6_REG_RIRBWP 0x58 200 #define ICH6_RIRBWP_RST (1 << 15) /* write pointer reset */ 201 #define ICH6_REG_RINTCNT 0x5a 202 #define ICH6_REG_RIRBCTL 0x5c 203 #define ICH6_RBCTL_IRQ_EN (1 << 0) /* enable IRQ */ 204 #define ICH6_RBCTL_DMA_EN (1 << 1) /* enable DMA */ 205 #define ICH6_RBCTL_OVERRUN_EN (1 << 2) /* enable overrun irq */ 206 #define ICH6_REG_RIRBSTS 0x5d 207 #define ICH6_RBSTS_IRQ (1 << 0) /* response irq */ 208 #define ICH6_RBSTS_OVERRUN (1 << 2) /* overrun irq */ 209 #define ICH6_REG_RIRBSIZE 0x5e 210 211 #define ICH6_REG_IC 0x60 212 #define ICH6_REG_IR 0x64 213 #define ICH6_REG_IRS 0x68 214 #define ICH6_IRS_VALID (1<<1) 215 #define ICH6_IRS_BUSY (1<<0) 216 217 #define ICH6_REG_DPLBASE 0x70 218 #define ICH6_REG_DPUBASE 0x74 219 #define ICH6_DPLBASE_ENABLE 0x1 /* Enable position buffer */ 220 220 221 221 /* SD offset: SDI0=0x80, SDI1=0xa0, ... SDO3=0x160 */ … … 223 223 224 224 /* stream register offsets from stream base */ 225 #define ICH6_REG_SD_CTL 226 #define ICH6_REG_SD_STS 227 #define ICH6_REG_SD_LPIB 228 #define ICH6_REG_SD_CBL 229 #define ICH6_REG_SD_LVI 230 #define ICH6_REG_SD_FIFOW 231 #define ICH6_REG_SD_FIFOSIZE 232 #define ICH6_REG_SD_FORMAT 233 #define ICH6_REG_SD_BDLPL 234 #define ICH6_REG_SD_BDLPU 225 #define ICH6_REG_SD_CTL 0x00 226 #define ICH6_REG_SD_STS 0x03 227 #define ICH6_REG_SD_LPIB 0x04 228 #define ICH6_REG_SD_CBL 0x08 229 #define ICH6_REG_SD_LVI 0x0c 230 #define ICH6_REG_SD_FIFOW 0x0e 231 #define ICH6_REG_SD_FIFOSIZE 0x10 232 #define ICH6_REG_SD_FORMAT 0x12 233 #define ICH6_REG_SD_BDLPL 0x18 234 #define ICH6_REG_SD_BDLPU 0x1c 235 235 236 236 /* PCI space */ 237 #define ICH6_PCIREG_TCSEL 237 #define ICH6_PCIREG_TCSEL 0x44 238 238 239 239 /* … … 243 243 /* max number of SDs */ 244 244 /* ICH, ATI and VIA have 4 playback and 4 capture */ 245 #define ICH6_NUM_CAPTURE 246 #define ICH6_NUM_PLAYBACK 245 #define ICH6_NUM_CAPTURE 4 246 #define ICH6_NUM_PLAYBACK 4 247 247 248 248 /* ULI has 6 playback and 5 capture */ 249 #define ULI_NUM_CAPTURE 250 #define ULI_NUM_PLAYBACK 249 #define ULI_NUM_CAPTURE 5 250 #define ULI_NUM_PLAYBACK 6 251 251 252 252 /* ATI HDMI has 1 playback and 0 capture */ 253 #define ATIHDMI_NUM_CAPTURE 254 #define ATIHDMI_NUM_PLAYBACK 253 #define ATIHDMI_NUM_CAPTURE 0 254 #define ATIHDMI_NUM_PLAYBACK 1 255 255 256 256 /* TERA has 4 playback and 3 capture */ 257 #define TERA_NUM_CAPTURE 258 #define TERA_NUM_PLAYBACK 257 #define TERA_NUM_CAPTURE 3 258 #define TERA_NUM_PLAYBACK 4 259 259 260 260 /* this number is statically defined for simplicity */ 261 #define MAX_AZX_DEV 261 #define MAX_AZX_DEV 16 262 262 263 263 /* max number of fragments - we may use more if allocating more pages for BDL */ 264 #define BDL_SIZE 265 #define AZX_MAX_BDL_ENTRIES 266 #define AZX_MAX_FRAG 264 #define BDL_SIZE 4096 265 #define AZX_MAX_BDL_ENTRIES (BDL_SIZE / 16) 266 #define AZX_MAX_FRAG 32 267 267 /* max buffer size - no h/w limit, you can increase as you like */ 268 #define AZX_MAX_BUF_SIZE 268 #define AZX_MAX_BUF_SIZE (1024*1024*1024) 269 269 270 270 /* RIRB int mask: overrun[2], response[0] */ 271 #define RIRB_INT_RESPONSE 272 #define RIRB_INT_OVERRUN 273 #define RIRB_INT_MASK 271 #define RIRB_INT_RESPONSE 0x01 272 #define RIRB_INT_OVERRUN 0x04 273 #define RIRB_INT_MASK 0x05 274 274 275 275 /* STATESTS int mask: S3,SD2,SD1,SD0 */ 276 #define AZX_MAX_CODECS 277 #define AZX_DEFAULT_CODECS 278 #define STATESTS_INT_MASK 276 #define AZX_MAX_CODECS 8 277 #define AZX_DEFAULT_CODECS 4 278 #define STATESTS_INT_MASK ((1 << AZX_MAX_CODECS) - 1) 279 279 280 280 /* SD_CTL bits */ 281 #define SD_CTL_STREAM_RESET 0x01/* stream reset bit */282 #define SD_CTL_DMA_START 0x02/* stream DMA start bit */283 #define SD_CTL_STRIPE (3 << 16)/* stripe control */284 #define SD_CTL_TRAFFIC_PRIO (1 << 18)/* traffic priority */285 #define SD_CTL_DIR (1 << 19)/* bi-directional stream */286 #define SD_CTL_STREAM_TAG_MASK 287 #define SD_CTL_STREAM_TAG_SHIFT 281 #define SD_CTL_STREAM_RESET 0x01 /* stream reset bit */ 282 #define SD_CTL_DMA_START 0x02 /* stream DMA start bit */ 283 #define SD_CTL_STRIPE (3 << 16) /* stripe control */ 284 #define SD_CTL_TRAFFIC_PRIO (1 << 18) /* traffic priority */ 285 #define SD_CTL_DIR (1 << 19) /* bi-directional stream */ 286 #define SD_CTL_STREAM_TAG_MASK (0xf << 20) 287 #define SD_CTL_STREAM_TAG_SHIFT 20 288 288 289 289 /* SD_CTL and SD_STS */ 290 #define SD_INT_DESC_ERR 0x10/* descriptor error interrupt */291 #define SD_INT_FIFO_ERR 0x08/* FIFO error interrupt */292 #define SD_INT_COMPLETE 0x04/* completion interrupt */293 #define SD_INT_MASK 294 290 #define SD_INT_DESC_ERR 0x10 /* descriptor error interrupt */ 291 #define SD_INT_FIFO_ERR 0x08 /* FIFO error interrupt */ 292 #define SD_INT_COMPLETE 0x04 /* completion interrupt */ 293 #define SD_INT_MASK (SD_INT_DESC_ERR|SD_INT_FIFO_ERR|\ 294 SD_INT_COMPLETE) 295 295 296 296 /* SD_STS */ 297 #define SD_STS_FIFO_READY 0x20/* FIFO ready */297 #define SD_STS_FIFO_READY 0x20 /* FIFO ready */ 298 298 299 299 /* INTCTL and INTSTS */ 300 #define ICH6_INT_ALL_STREAM 0xff/* all stream interrupts */301 #define ICH6_INT_CTRL_EN 302 #define ICH6_INT_GLOBAL_EN 300 #define ICH6_INT_ALL_STREAM 0xff /* all stream interrupts */ 301 #define ICH6_INT_CTRL_EN 0x40000000 /* controller interrupt enable bit */ 302 #define ICH6_INT_GLOBAL_EN 0x80000000 /* global interrupt enable bit */ 303 303 304 304 /* below are so far hardcoded - should read registers in future */ 305 #define ICH6_MAX_CORB_ENTRIES 306 #define ICH6_MAX_RIRB_ENTRIES 305 #define ICH6_MAX_CORB_ENTRIES 256 306 #define ICH6_MAX_RIRB_ENTRIES 256 307 307 308 308 /* position fix mode */ 309 309 enum { 310 311 312 313 310 POS_FIX_AUTO, 311 POS_FIX_LPIB, 312 POS_FIX_POSBUF, 313 POS_FIX_VIACOMBO, 314 314 }; 315 315 … … 330 330 331 331 /* Define IN stream 0 FIFO size offset in VIA controller */ 332 #define VIA_IN_STREAM0_FIFO_SIZE_OFFSET 332 #define VIA_IN_STREAM0_FIFO_SIZE_OFFSET 0x90 333 333 /* Define VIA HD Audio Device ID*/ 334 #define VIA_HDAC_DEVICE_ID 334 #define VIA_HDAC_DEVICE_ID 0x3288 335 335 336 336 /* HD Audio class code */ 337 #define PCI_CLASS_MULTIMEDIA_HD_AUDIO 337 #define PCI_CLASS_MULTIMEDIA_HD_AUDIO 0x0403 338 338 339 339 /* … … 341 341 342 342 struct azx_dev { 343 343 struct snd_dma_buffer bdl; /* BDL buffer */ 344 344 #ifdef TARGET_OS2 345 volatile u32 *posbuf;/* position buffer pointer */345 volatile u32 *posbuf; /* position buffer pointer */ 346 346 #else 347 u32 *posbuf;/* position buffer pointer */347 u32 *posbuf; /* position buffer pointer */ 348 348 #endif 349 349 350 unsigned int bufsize;/* size of the play buffer in bytes */351 352 unsigned int frags;/* number for period in the play buffer */353 unsigned int fifo_size;/* FIFO size */354 unsigned long start_wallclk;/* start + minimum wallclk */355 unsigned long period_wallclk;/* wallclk for period */350 unsigned int bufsize; /* size of the play buffer in bytes */ 351 unsigned int period_bytes; /* size of the period in bytes */ 352 unsigned int frags; /* number for period in the play buffer */ 353 unsigned int fifo_size; /* FIFO size */ 354 unsigned long start_wallclk; /* start + minimum wallclk */ 355 unsigned long period_wallclk; /* wallclk for period */ 356 356 357 357 #ifdef TARGET_OS2 358 volatile void __iomem *sd_addr;/* stream descriptor pointer */358 volatile void __iomem *sd_addr; /* stream descriptor pointer */ 359 359 #else 360 void __iomem *sd_addr;/* stream descriptor pointer */360 void __iomem *sd_addr; /* stream descriptor pointer */ 361 361 #endif 362 362 363 u32 sd_int_sta_mask;/* stream int status mask */364 365 366 struct snd_pcm_substream *substream;/* assigned substream,367 368 369 unsigned int format_val;/* format value to be set in the370 371 372 unsigned char stream_tag;/* assigned stream */373 unsigned char index;/* stream index */374 int device;/* last device number assigned to */375 376 377 378 379 380 381 382 383 384 363 u32 sd_int_sta_mask; /* stream int status mask */ 364 365 /* pcm support */ 366 struct snd_pcm_substream *substream; /* assigned substream, 367 * set in PCM open 368 */ 369 unsigned int format_val; /* format value to be set in the 370 * controller and the codec 371 */ 372 unsigned char stream_tag; /* assigned stream */ 373 unsigned char index; /* stream index */ 374 int device; /* last device number assigned to */ 375 376 unsigned int opened :1; 377 unsigned int running :1; 378 unsigned int irq_pending :1; 379 /* 380 * For VIA: 381 * A flag to ensure DMA position is 0 382 * when link position is not greater than FIFO size 383 */ 384 unsigned int insufficient :1; 385 385 }; 386 386 … … 388 388 struct azx_rb { 389 389 #ifdef TARGET_OS2 390 volatile u32 *buf;/* CORB/RIRB buffer */390 volatile u32 *buf; /* CORB/RIRB buffer */ 391 391 #else 392 u32 *buf;/* CORB/RIRB buffer */392 u32 *buf; /* CORB/RIRB buffer */ 393 393 #endif 394 395 396 dma_addr_t addr;/* physical address of CORB/RIRB buffer */397 398 unsigned short rp, wp;/* read/write pointers */399 int cmds[AZX_MAX_CODECS];/* number of pending requests */400 u32 res[AZX_MAX_CODECS];/* last read value */394 /* Each CORB entry is 4byte, RIRB is 8byte 395 */ 396 dma_addr_t addr; /* physical address of CORB/RIRB buffer */ 397 /* for RIRB */ 398 unsigned short rp, wp; /* read/write pointers */ 399 int cmds[AZX_MAX_CODECS]; /* number of pending requests */ 400 u32 res[AZX_MAX_CODECS]; /* last read value */ 401 401 }; 402 402 403 403 struct azx { 404 405 406 407 408 409 410 411 412 413 414 415 416 417 404 struct snd_card *card; 405 struct pci_dev *pci; 406 int dev_index; 407 408 /* chip type specific */ 409 int driver_type; 410 int playback_streams; 411 int playback_index_offset; 412 int capture_streams; 413 int capture_index_offset; 414 int num_streams; 415 416 /* pci resources */ 417 unsigned long addr; 418 418 #ifdef TARGET_OS2 419 419 volatile void __iomem *remap_addr; 420 420 #else /* !TARGET_OS2 */ 421 421 void __iomem *remap_addr; 422 422 #endif /* !TARGET_OS2 */ 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 423 int irq; 424 425 /* locks */ 426 spinlock_t reg_lock; 427 struct mutex open_mutex; 428 429 /* streams (x num_streams) */ 430 struct azx_dev *azx_dev; 431 432 /* PCM */ 433 struct snd_pcm *pcm[HDA_MAX_PCMS]; 434 435 /* HD codec */ 436 unsigned short codec_mask; 437 int codec_probe_mask; /* copied from probe_mask option */ 438 struct hda_bus *bus; 439 unsigned int beep_mode; 440 441 /* CORB/RIRB */ 442 struct azx_rb corb; 443 struct azx_rb rirb; 444 445 /* CORB/RIRB and position buffers */ 446 struct snd_dma_buffer rb; 447 struct snd_dma_buffer posbuf; 448 449 /* flags */ 450 int position_fix[2]; /* for both playback/capture streams */ 451 int poll_count; 452 unsigned int running :1; 453 unsigned int initialized :1; 454 unsigned int single_cmd :1; 455 unsigned int polling_mode :1; 456 unsigned int msi :1; 457 unsigned int irq_pending_warned :1; 458 unsigned int probing :1; /* codec probing phase */ 459 460 /* for debugging */ 461 unsigned int last_cmd[AZX_MAX_CODECS]; 462 463 /* for pending irqs */ 464 struct work_struct irq_pending_work; 465 466 /* reboot notifier (for mysterious hangup problem at power-down) */ 467 struct notifier_block reboot_notifier; 468 468 }; 469 469 470 470 /* driver types */ 471 471 enum { 472 AZX_DRIVER_ICH, 473 AZX_DRIVER_PCH, 474 AZX_DRIVER_SCH, 475 AZX_DRIVER_ATI, 476 AZX_DRIVER_ATIHDMI, 477 AZX_DRIVER_VIA, 478 AZX_DRIVER_SIS, 479 AZX_DRIVER_ULI, 480 AZX_DRIVER_NVIDIA, 481 AZX_DRIVER_TERA, 482 AZX_DRIVER_CTX, 483 AZX_DRIVER_GENERIC, 484 AZX_NUM_DRIVERS, /* keep this as last entry */ 472 AZX_DRIVER_ICH, 473 AZX_DRIVER_PCH, 474 AZX_DRIVER_SCH, 475 AZX_DRIVER_HDMI, 476 AZX_DRIVER_ATI, 477 AZX_DRIVER_ATIHDMI, 478 AZX_DRIVER_VIA, 479 AZX_DRIVER_SIS, 480 AZX_DRIVER_ULI, 481 AZX_DRIVER_NVIDIA, 482 AZX_DRIVER_TERA, 483 AZX_DRIVER_CTX, 484 AZX_DRIVER_GENERIC, 485 AZX_NUM_DRIVERS, /* keep this as last entry */ 485 486 }; 486 487 487 488 static char *driver_short_names[] __devinitdata = { 488 [AZX_DRIVER_ICH] = "HDA Intel", 489 [AZX_DRIVER_PCH] = "HDA Intel PCH", 490 [AZX_DRIVER_SCH] = "HDA Intel MID", 491 [AZX_DRIVER_ATI] = "HDA ATI SB", 492 [AZX_DRIVER_ATIHDMI] = "HDA ATI HDMI", 493 [AZX_DRIVER_VIA] = "HDA VIA VT82xx", 494 [AZX_DRIVER_SIS] = "HDA SIS966", 495 [AZX_DRIVER_ULI] = "HDA ULI M5461", 496 [AZX_DRIVER_NVIDIA] = "HDA NVidia", 497 [AZX_DRIVER_TERA] = "HDA Teradici", 498 [AZX_DRIVER_CTX] = "HDA Creative", 499 [AZX_DRIVER_GENERIC] = "HD-Audio Generic", 489 [AZX_DRIVER_ICH] = "HDA Intel", 490 [AZX_DRIVER_PCH] = "HDA Intel PCH", 491 [AZX_DRIVER_SCH] = "HDA Intel MID", 492 [AZX_DRIVER_HDMI] = "HDA Intel HDMI", 493 [AZX_DRIVER_ATI] = "HDA ATI SB", 494 [AZX_DRIVER_ATIHDMI] = "HDA ATI HDMI", 495 [AZX_DRIVER_VIA] = "HDA VIA VT82xx", 496 [AZX_DRIVER_SIS] = "HDA SIS966", 497 [AZX_DRIVER_ULI] = "HDA ULI M5461", 498 [AZX_DRIVER_NVIDIA] = "HDA NVidia", 499 [AZX_DRIVER_TERA] = "HDA Teradici", 500 [AZX_DRIVER_CTX] = "HDA Creative", 501 [AZX_DRIVER_GENERIC] = "HD-Audio Generic", 500 502 }; 501 503 … … 504 506 */ 505 507 #define azx_writel(chip,reg,value) \ 506 508 writel(value, (chip)->remap_addr + ICH6_REG_##reg) 507 509 #define azx_readl(chip,reg) \ 508 510 readl((chip)->remap_addr + ICH6_REG_##reg) 509 511 #define azx_writew(chip,reg,value) \ 510 512 writew(value, (chip)->remap_addr + ICH6_REG_##reg) 511 513 #define azx_readw(chip,reg) \ 512 514 readw((chip)->remap_addr + ICH6_REG_##reg) 513 515 #define azx_writeb(chip,reg,value) \ 514 516 writeb(value, (chip)->remap_addr + ICH6_REG_##reg) 515 517 #define azx_readb(chip,reg) \ 516 518 readb((chip)->remap_addr + ICH6_REG_##reg) 517 519 518 520 #define azx_sd_writel(dev,reg,value) \ 519 521 writel(value, (dev)->sd_addr + ICH6_REG_##reg) 520 522 #define azx_sd_readl(dev,reg) \ 521 523 readl((dev)->sd_addr + ICH6_REG_##reg) 522 524 #define azx_sd_writew(dev,reg,value) \ 523 525 writew(value, (dev)->sd_addr + ICH6_REG_##reg) 524 526 #define azx_sd_readw(dev,reg) \ 525 527 readw((dev)->sd_addr + ICH6_REG_##reg) 526 528 #define azx_sd_writeb(dev,reg,value) \ 527 529 writeb(value, (dev)->sd_addr + ICH6_REG_##reg) 528 530 #define azx_sd_readb(dev,reg) \ 529 531 readb((dev)->sd_addr + ICH6_REG_##reg) 530 532 531 533 /* for pcm support */ … … 543 545 static int azx_alloc_cmd_io(struct azx *chip) 544 546 { 545 546 547 548 549 550 551 552 553 554 555 547 int err; 548 549 /* single page (at least 4096 bytes) must suffice for both ringbuffes */ 550 err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, 551 snd_dma_pci_data(chip->pci), 552 PAGE_SIZE, &chip->rb); 553 if (err < 0) { 554 snd_printk(KERN_ERR SFX "cannot allocate CORB/RIRB\n"); 555 return err; 556 } 557 return 0; 556 558 } 557 559 558 560 static void azx_init_cmd_io(struct azx *chip) 559 561 { 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 562 spin_lock_irq(&chip->reg_lock); 563 /* CORB set up */ 564 chip->corb.addr = chip->rb.addr; 565 chip->corb.buf = (u32 *)chip->rb.area; 566 azx_writel(chip, CORBLBASE, (u32)chip->corb.addr); 567 azx_writel(chip, CORBUBASE, upper_32_bits(chip->corb.addr)); 568 569 /* set the corb size to 256 entries (ULI requires explicitly) */ 570 azx_writeb(chip, CORBSIZE, 0x02); 571 /* set the corb write pointer to 0 */ 572 azx_writew(chip, CORBWP, 0); 573 /* reset the corb hw read pointer */ 574 azx_writew(chip, CORBRP, ICH6_CORBRP_RST); 575 /* enable corb dma */ 576 azx_writeb(chip, CORBCTL, ICH6_CORBCTL_RUN); 577 578 /* RIRB set up */ 579 chip->rirb.addr = chip->rb.addr + 2048; 580 chip->rirb.buf = (u32 *)(chip->rb.area + 2048); 581 chip->rirb.wp = chip->rirb.rp = 0; 582 memset(chip->rirb.cmds, 0, sizeof(chip->rirb.cmds)); 583 azx_writel(chip, RIRBLBASE, (u32)chip->rirb.addr); 584 azx_writel(chip, RIRBUBASE, upper_32_bits(chip->rirb.addr)); 585 586 /* set the rirb size to 256 entries (ULI requires explicitly) */ 587 azx_writeb(chip, RIRBSIZE, 0x02); 588 /* reset the rirb hw write pointer */ 589 azx_writew(chip, RIRBWP, ICH6_RIRBWP_RST); 590 /* set N=1, get RIRB response interrupt for new entry */ 591 if (chip->driver_type == AZX_DRIVER_CTX) 592 azx_writew(chip, RINTCNT, 0xc0); 593 else 594 azx_writew(chip, RINTCNT, 1); 595 /* enable rirb dma and response irq */ 596 azx_writeb(chip, RIRBCTL, ICH6_RBCTL_DMA_EN | ICH6_RBCTL_IRQ_EN); 597 spin_unlock_irq(&chip->reg_lock); 596 598 } 597 599 598 600 static void azx_free_cmd_io(struct azx *chip) 599 601 { 600 601 602 603 604 602 spin_lock_irq(&chip->reg_lock); 603 /* disable ringbuffer DMAs */ 604 azx_writeb(chip, RIRBCTL, 0); 605 azx_writeb(chip, CORBCTL, 0); 606 spin_unlock_irq(&chip->reg_lock); 605 607 } 606 608 607 609 static unsigned int azx_command_addr(u32 cmd) 608 610 { 609 610 611 612 613 614 615 616 611 unsigned int addr = cmd >> 28; 612 613 if (addr >= AZX_MAX_CODECS) { 614 snd_BUG(); 615 addr = 0; 616 } 617 618 return addr; 617 619 } 618 620 619 621 static unsigned int azx_response_addr(u32 res) 620 622 { 621 622 623 624 625 626 627 628 623 unsigned int addr = res & 0xf; 624 625 if (addr >= AZX_MAX_CODECS) { 626 snd_BUG(); 627 addr = 0; 628 } 629 630 return addr; 629 631 } 630 632 … … 632 634 static int azx_corb_send_cmd(struct hda_bus *bus, u32 val) 633 635 { 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 } 653 654 #define ICH6_RIRB_EX_UNSOL_EV 636 struct azx *chip = bus->private_data; 637 unsigned int addr = azx_command_addr(val); 638 unsigned int wp; 639 640 spin_lock_irq(&chip->reg_lock); 641 642 /* add command to corb */ 643 wp = azx_readb(chip, CORBWP); 644 wp++; 645 wp %= ICH6_MAX_CORB_ENTRIES; 646 647 chip->rirb.cmds[addr]++; 648 chip->corb.buf[wp] = cpu_to_le32(val); 649 azx_writel(chip, CORBWP, wp); 650 651 spin_unlock_irq(&chip->reg_lock); 652 653 return 0; 654 } 655 656 #define ICH6_RIRB_EX_UNSOL_EV (1<<4) 655 657 656 658 /* retrieve RIRB entry - called from interrupt handler */ 657 659 static void azx_update_rirb(struct azx *chip) 658 660 { 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 661 unsigned int rp, wp; 662 unsigned int addr; 663 u32 res, res_ex; 664 665 wp = azx_readb(chip, RIRBWP); 666 if (wp == chip->rirb.wp) 667 return; 668 chip->rirb.wp = wp; 669 670 while (chip->rirb.rp != wp) { 671 chip->rirb.rp++; 672 chip->rirb.rp %= ICH6_MAX_RIRB_ENTRIES; 673 674 rp = chip->rirb.rp << 1; /* an RIRB entry is 8-bytes */ 675 res_ex = le32_to_cpu(chip->rirb.buf[rp + 1]); 676 res = le32_to_cpu(chip->rirb.buf[rp]); 677 addr = azx_response_addr(res_ex); 678 if (res_ex & ICH6_RIRB_EX_UNSOL_EV) 679 snd_hda_queue_unsol_event(chip->bus, res, res_ex); 680 else if (chip->rirb.cmds[addr]) { 681 chip->rirb.res[addr] = res; 682 smp_wmb(); 683 chip->rirb.cmds[addr]--; 684 } else 685 snd_printk(KERN_ERR SFX "spurious response %#x:%#x, " 686 "last cmd=%#08x\n", 687 res, res_ex, 688 chip->last_cmd[addr]); 689 } 688 690 } 689 691 690 692 /* receive a response */ 691 693 static unsigned int azx_rirb_get_response(struct hda_bus *bus, 692 693 { 694 695 694 unsigned int addr) 695 { 696 struct azx *chip = bus->private_data; 697 unsigned long timeout; 696 698 #ifdef TARGET_OS2 697 699 int count = 0; 698 700 #endif 699 701 int do_poll = 0; 700 702 701 703 again: 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 704 timeout = jiffies + msecs_to_jiffies(1000); 705 for ( ; ; ) { 706 if (chip->polling_mode || do_poll) { 707 spin_lock_irq(&chip->reg_lock); 708 azx_update_rirb(chip); 709 spin_unlock_irq(&chip->reg_lock); 710 } 711 if (!chip->rirb.cmds[addr]) { 712 smp_rmb(); 713 bus->rirb_error = 0; 714 715 if (!do_poll) 716 chip->poll_count = 0; 717 return chip->rirb.res[addr]; /* the last value */ 718 } 719 if (time_after(jiffies, timeout)) 720 break; 719 721 #ifdef TARGET_OS2 720 721 722 if (count >= 5000) /* Hack on OS/2 to stop infinite loop as jiffies sometimes don't increment */ 723 break; 722 724 #endif 723 724 725 726 727 728 725 if (bus->needs_damn_long_delay) 726 msleep(2); /* temporary workaround */ 727 else { 728 udelay(10); 729 cond_resched(); 730 } 729 731 #ifdef TARGET_OS2 730 732 count++; 731 733 #endif 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 734 } 735 736 if (!chip->polling_mode && chip->poll_count < 2) { 737 snd_printdd(SFX "azx_get_response timeout, " 738 "polling the codec once: last cmd=0x%08x\n", 739 chip->last_cmd[addr]); 740 do_poll = 1; 741 chip->poll_count++; 742 goto again; 743 } 744 745 746 if (!chip->polling_mode) { 747 snd_printk(KERN_WARNING SFX "azx_get_response timeout, " 748 "switching to polling mode: last cmd=0x%08x\n", 749 chip->last_cmd[addr]); 750 chip->polling_mode = 1; 751 goto again; 752 } 751 753 #ifdef TARGET_OS2 752 753 754 754 if (count >= 5000) { 755 snd_printk(KERN_WARNING "hda_intel: count >= 5000, aborting loop in azx_rirb_get_response\n"); 756 } 755 757 #endif 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 758 if (chip->msi) { 759 snd_printk(KERN_WARNING SFX "No response from codec, " 760 "disabling MSI: last cmd=0x%08x\n", 761 chip->last_cmd[addr]); 762 free_irq(chip->irq, chip); 763 chip->irq = -1; 764 pci_disable_msi(chip->pci); 765 chip->msi = 0; 766 if (azx_acquire_irq(chip, 1) < 0) { 767 bus->rirb_error = 1; 768 return -1; 769 } 770 goto again; 771 } 772 773 if (chip->probing) { 774 /* If this critical timeout happens during the codec probing 775 * phase, this is likely an access to a non-existing codec 776 * slot. Better to return an error and reset the system. 777 */ 778 return -1; 779 } 780 781 /* a fatal communication error; need either to reset or to fallback 782 * to the single_cmd mode 783 */ 784 bus->rirb_error = 1; 785 if (bus->allow_bus_reset && !bus->response_reset && !bus->in_reset) { 786 bus->response_reset = 1; 787 return -1; /* give a chance to retry */ 788 } 789 790 snd_printk(KERN_ERR "hda_intel: azx_get_response timeout, " 791 "switching to single_cmd mode: last cmd=0x%08x\n", 792 chip->last_cmd[addr]); 793 chip->single_cmd = 1; 794 bus->response_reset = 0; 795 /* release CORB/RIRB */ 796 azx_free_cmd_io(chip); 797 /* disable unsolicited responses */ 798 azx_writel(chip, GCTL, azx_readl(chip, GCTL) & ~ICH6_GCTL_UNSOL); 799 return -1; 798 800 } 799 801 … … 811 813 static int azx_single_wait_for_response(struct azx *chip, unsigned int addr) 812 814 { 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 815 int timeout = 50; 816 817 while (timeout--) { 818 /* check IRV busy bit */ 819 if (azx_readw(chip, IRS) & ICH6_IRS_VALID) { 820 /* reuse rirb.res as the response return value */ 821 chip->rirb.res[addr] = azx_readl(chip, IR); 822 return 0; 823 } 824 udelay(1); 825 } 826 if (printk_ratelimit()) 827 snd_printd(SFX "get_response timeout: IRS=0x%x\n", 828 azx_readw(chip, IRS)); 829 chip->rirb.res[addr] = -1; 830 return -EIO; 829 831 } 830 832 … … 832 834 static int azx_single_send_cmd(struct hda_bus *bus, u32 val) 833 835 { 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 836 struct azx *chip = bus->private_data; 837 unsigned int addr = azx_command_addr(val); 838 int timeout = 50; 839 840 bus->rirb_error = 0; 841 while (timeout--) { 842 /* check ICB busy bit */ 843 if (!((azx_readw(chip, IRS) & ICH6_IRS_BUSY))) { 844 /* Clear IRV valid bit */ 845 azx_writew(chip, IRS, azx_readw(chip, IRS) | 846 ICH6_IRS_VALID); 847 azx_writel(chip, IC, val); 848 azx_writew(chip, IRS, azx_readw(chip, IRS) | 849 ICH6_IRS_BUSY); 850 return azx_single_wait_for_response(chip, addr); 851 } 852 udelay(1); 853 } 854 if (printk_ratelimit()) 855 snd_printd(SFX "send_cmd timeout: IRS=0x%x, val=0x%x\n", 856 azx_readw(chip, IRS), val); 857 return -EIO; 856 858 } 857 859 858 860 /* receive a response */ 859 861 static unsigned int azx_single_get_response(struct hda_bus *bus, 860 861 { 862 863 862 unsigned int addr) 863 { 864 struct azx *chip = bus->private_data; 865 return chip->rirb.res[addr]; 864 866 } 865 867 … … 874 876 static int azx_send_cmd(struct hda_bus *bus, unsigned int val) 875 877 { 876 877 878 879 880 881 882 878 struct azx *chip = bus->private_data; 879 880 chip->last_cmd[azx_command_addr(val)] = val; 881 if (chip->single_cmd) 882 return azx_single_send_cmd(bus, val); 883 else 884 return azx_corb_send_cmd(bus, val); 883 885 } 884 886 885 887 /* get a response */ 886 888 static unsigned int azx_get_response(struct hda_bus *bus, 887 888 { 889 890 891 892 893 889 unsigned int addr) 890 { 891 struct azx *chip = bus->private_data; 892 if (chip->single_cmd) 893 return azx_single_get_response(bus, addr); 894 else 895 return azx_rirb_get_response(bus, addr); 894 896 } 895 897 … … 901 903 static int azx_reset(struct azx *chip, int full_reset) 902 904 { 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 905 int count; 906 907 if (!full_reset) 908 goto __skip; 909 910 /* clear STATESTS */ 911 azx_writeb(chip, STATESTS, STATESTS_INT_MASK); 912 913 /* reset controller */ 914 azx_writel(chip, GCTL, azx_readl(chip, GCTL) & ~ICH6_GCTL_RESET); 915 916 count = 50; 917 while (azx_readb(chip, GCTL) && --count) 918 msleep(1); 919 920 /* delay for >= 100us for codec PLL to settle per spec 921 * Rev 0.9 section 5.5.1 922 */ 923 msleep(1); 924 925 /* Bring controller out of reset */ 926 azx_writeb(chip, GCTL, azx_readb(chip, GCTL) | ICH6_GCTL_RESET); 927 928 count = 50; 929 while (!azx_readb(chip, GCTL) && --count) 930 msleep(1); 931 932 /* Brent Chartrand said to wait >= 540us for codecs to initialize */ 933 msleep(1); 932 934 933 935 __skip: 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 936 /* check to see if controller is ready */ 937 if (!azx_readb(chip, GCTL)) { 938 snd_printd(SFX "azx_reset: controller not ready!\n"); 939 return -EBUSY; 940 } 941 942 /* Accept unsolicited responses */ 943 if (!chip->single_cmd) 944 azx_writel(chip, GCTL, azx_readl(chip, GCTL) | 945 ICH6_GCTL_UNSOL); 946 947 /* detect codecs */ 948 if (!chip->codec_mask) { 949 chip->codec_mask = azx_readw(chip, STATESTS); 950 snd_printdd(SFX "codec_mask = 0x%x\n", chip->codec_mask); 951 } 952 953 return 0; 952 954 } 953 955 … … 960 962 static void azx_int_enable(struct azx *chip) 961 963 { 962 963 964 964 /* enable controller CIE and GIE */ 965 azx_writel(chip, INTCTL, azx_readl(chip, INTCTL) | 966 ICH6_INT_CTRL_EN | ICH6_INT_GLOBAL_EN); 965 967 } 966 968 … … 968 970 static void azx_int_disable(struct azx *chip) 969 971 { 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 972 int i; 973 974 /* disable interrupts in stream descriptor */ 975 for (i = 0; i < chip->num_streams; i++) { 976 struct azx_dev *azx_dev = &chip->azx_dev[i]; 977 azx_sd_writeb(azx_dev, SD_CTL, 978 azx_sd_readb(azx_dev, SD_CTL) & ~SD_INT_MASK); 979 } 980 981 /* disable SIE for all streams */ 982 azx_writeb(chip, INTCTL, 0); 983 984 /* disable controller CIE and GIE */ 985 azx_writel(chip, INTCTL, azx_readl(chip, INTCTL) & 986 ~(ICH6_INT_CTRL_EN | ICH6_INT_GLOBAL_EN)); 985 987 } 986 988 … … 988 990 static void azx_int_clear(struct azx *chip) 989 991 { 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 992 int i; 993 994 /* clear stream status */ 995 for (i = 0; i < chip->num_streams; i++) { 996 struct azx_dev *azx_dev = &chip->azx_dev[i]; 997 azx_sd_writeb(azx_dev, SD_STS, SD_INT_MASK); 998 } 999 1000 /* clear STATESTS */ 1001 azx_writeb(chip, STATESTS, STATESTS_INT_MASK); 1002 1003 /* clear rirb status */ 1004 azx_writeb(chip, RIRBSTS, RIRB_INT_MASK); 1005 1006 /* clear int status */ 1007 azx_writel(chip, INTSTS, ICH6_INT_CTRL_EN | ICH6_INT_ALL_STREAM); 1006 1008 } 1007 1009 … … 1009 1011 static void azx_stream_start(struct azx *chip, struct azx_dev *azx_dev) 1010 1012 { 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1013 /* 1014 * Before stream start, initialize parameter 1015 */ 1016 azx_dev->insufficient = 1; 1017 1018 /* enable SIE */ 1019 azx_writel(chip, INTCTL, 1020 azx_readl(chip, INTCTL) | (1 << azx_dev->index)); 1021 /* set DMA start and interrupt mask */ 1022 azx_sd_writeb(azx_dev, SD_CTL, azx_sd_readb(azx_dev, SD_CTL) | 1023 SD_CTL_DMA_START | SD_INT_MASK); 1022 1024 } 1023 1025 … … 1025 1027 static void azx_stream_clear(struct azx *chip, struct azx_dev *azx_dev) 1026 1028 { 1027 1028 1029 1029 azx_sd_writeb(azx_dev, SD_CTL, azx_sd_readb(azx_dev, SD_CTL) & 1030 ~(SD_CTL_DMA_START | SD_INT_MASK)); 1031 azx_sd_writeb(azx_dev, SD_STS, SD_INT_MASK); /* to be sure */ 1030 1032 } 1031 1033 … … 1033 1035 static void azx_stream_stop(struct azx *chip, struct azx_dev *azx_dev) 1034 1036 { 1035 1036 1037 1038 1037 azx_stream_clear(chip, azx_dev); 1038 /* disable SIE */ 1039 azx_writel(chip, INTCTL, 1040 azx_readl(chip, INTCTL) & ~(1 << azx_dev->index)); 1039 1041 } 1040 1042 … … 1045 1047 static void azx_init_chip(struct azx *chip, int full_reset) 1046 1048 { 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1049 if (chip->initialized) 1050 return; 1051 1052 /* reset controller */ 1053 azx_reset(chip, full_reset); 1054 1055 /* initialize interrupts */ 1056 azx_int_clear(chip); 1057 azx_int_enable(chip); 1058 1059 /* initialize the codec command I/O */ 1060 if (!chip->single_cmd) 1061 azx_init_cmd_io(chip); 1062 1063 /* program the position buffer */ 1064 azx_writel(chip, DPLBASE, (u32)chip->posbuf.addr); 1065 azx_writel(chip, DPUBASE, upper_32_bits(chip->posbuf.addr)); 1066 1067 chip->initialized = 1; 1066 1068 } 1067 1069 … … 1071 1073 /* update bits in a PCI register byte */ 1072 1074 static void update_pci_byte(struct pci_dev *pci, unsigned int reg, 1073 1074 { 1075 1076 1077 1078 1079 1080 1075 unsigned char mask, unsigned char val) 1076 { 1077 unsigned char data; 1078 1079 pci_read_config_byte(pci, reg, &data); 1080 data &= ~mask; 1081 data |= (val & mask); 1082 pci_write_config_byte(pci, reg, data); 1081 1083 } 1082 1084 1083 1085 static void azx_init_pci(struct azx *chip) 1084 1086 { 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1087 unsigned short snoop; 1088 1089 /* Clear bits 0-2 of PCI register TCSEL (at offset 0x44) 1090 * TCSEL == Traffic Class Select Register, which sets PCI express QOS 1091 * Ensuring these bits are 0 clears playback static on some HD Audio 1092 * codecs 1093 */ 1094 update_pci_byte(chip->pci, ICH6_PCIREG_TCSEL, 0x07, 0); 1095 1096 switch (chip->driver_type) { 1097 case AZX_DRIVER_ATI: 1098 /* For ATI SB450 azalia HD audio, we need to enable snoop */ 1099 update_pci_byte(chip->pci, 1100 ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR, 1101 0x07, ATI_SB450_HDAUDIO_ENABLE_SNOOP); 1102 break; 1103 case AZX_DRIVER_NVIDIA: 1104 /* For NVIDIA HDA, enable snoop */ 1105 update_pci_byte(chip->pci, 1106 NVIDIA_HDA_TRANSREG_ADDR, 1107 0x0f, NVIDIA_HDA_ENABLE_COHBITS); 1108 update_pci_byte(chip->pci, 1109 NVIDIA_HDA_ISTRM_COH, 1110 0x01, NVIDIA_HDA_ENABLE_COHBIT); 1111 update_pci_byte(chip->pci, 1112 NVIDIA_HDA_OSTRM_COH, 1113 0x01, NVIDIA_HDA_ENABLE_COHBIT); 1114 break; 1115 case AZX_DRIVER_SCH: 1116 case AZX_DRIVER_PCH: 1117 pci_read_config_word(chip->pci, INTEL_SCH_HDA_DEVC, &snoop); 1118 if (snoop & INTEL_SCH_HDA_DEVC_NOSNOOP) { 1119 pci_write_config_word(chip->pci, INTEL_SCH_HDA_DEVC, 1120 snoop & (~INTEL_SCH_HDA_DEVC_NOSNOOP)); 1121 pci_read_config_word(chip->pci, 1122 INTEL_SCH_HDA_DEVC, &snoop); 1123 snd_printdd(SFX "HDA snoop disabled, enabling ... %s\n", 1124 (snoop & INTEL_SCH_HDA_DEVC_NOSNOOP) 1125 ? "Failed" : "OK"); 1126 } 1127 break; 1126 1128 1127 1129 } … … 1136 1138 static irqreturn_t azx_interrupt(int irq, void *dev_id) 1137 1139 { 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1140 struct azx *chip = dev_id; 1141 struct azx_dev *azx_dev; 1142 u32 status; 1143 u8 sd_status; 1144 int i, ok; 1145 1146 spin_lock(&chip->reg_lock); 1147 1148 status = azx_readl(chip, INTSTS); 1149 if (status == 0) { 1150 spin_unlock(&chip->reg_lock); 1151 return IRQ_NONE; 1152 } 1153 1154 for (i = 0; i < chip->num_streams; i++) { 1155 azx_dev = &chip->azx_dev[i]; 1156 if (status & azx_dev->sd_int_sta_mask) { 1157 sd_status = azx_sd_readb(azx_dev, SD_STS); 1158 azx_sd_writeb(azx_dev, SD_STS, SD_INT_MASK); 1159 if (!azx_dev->substream || !azx_dev->running || 1160 !(sd_status & SD_INT_COMPLETE)) 1161 continue; 1162 /* check whether this IRQ is really acceptable */ 1163 ok = azx_position_ok(chip, azx_dev); 1164 if (ok == 1) { 1165 azx_dev->irq_pending = 0; 1166 spin_unlock(&chip->reg_lock); 1167 snd_pcm_period_elapsed(azx_dev->substream); 1168 spin_lock(&chip->reg_lock); 1169 } else if (ok == 0 && chip->bus && chip->bus->workq) { 1170 /* bogus IRQ, process it later */ 1171 azx_dev->irq_pending = 1; 1172 queue_work(chip->bus->workq, 1173 &chip->irq_pending_work); 1174 } 1175 } 1176 } 1177 1178 /* clear rirb int */ 1179 status = azx_readb(chip, RIRBSTS); 1180 if (status & RIRB_INT_MASK) { 1181 if (status & RIRB_INT_RESPONSE) { 1182 if (chip->driver_type == AZX_DRIVER_CTX) 1183 udelay(80); 1184 azx_update_rirb(chip); 1185 } 1186 azx_writeb(chip, RIRBSTS, RIRB_INT_MASK); 1187 } 1186 1188 1187 1189 #if 0 1188 1189 1190 1190 /* clear state status int */ 1191 if (azx_readb(chip, STATESTS) & 0x04) 1192 azx_writeb(chip, STATESTS, 0x04); 1191 1193 #endif 1192 1194 spin_unlock(&chip->reg_lock); 1193 1195 1194 1196 #ifdef TARGET_OS2 … … 1198 1200 #endif 1199 1201 1200 1202 return IRQ_HANDLED; 1201 1203 } 1202 1204 … … 1206 1208 */ 1207 1209 static int setup_bdle(struct snd_pcm_substream *substream, 1208 1209 1210 { 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1210 struct azx_dev *azx_dev, u32 **bdlp, 1211 int ofs, int size, int with_ioc) 1212 { 1213 u32 *bdl = *bdlp; 1214 1215 while (size > 0) { 1216 dma_addr_t addr; 1217 int chunk; 1218 1219 if (azx_dev->frags >= AZX_MAX_BDL_ENTRIES) 1220 return -EINVAL; 1221 1222 addr = snd_pcm_sgbuf_get_addr(substream, ofs); 1223 /* program the address field of the BDL entry */ 1224 bdl[0] = cpu_to_le32((u32)addr); 1225 bdl[1] = cpu_to_le32(upper_32_bits(addr)); 1226 /* program the size field of the BDL entry */ 1227 chunk = snd_pcm_sgbuf_get_chunk_size(substream, ofs, size); 1228 bdl[2] = cpu_to_le32(chunk); 1229 /* program the IOC to enable interrupt 1230 * only when the whole fragment is processed 1231 */ 1232 size -= chunk; 1233 bdl[3] = (size || !with_ioc) ? 0 : cpu_to_le32(0x01); 1234 bdl += 4; 1235 azx_dev->frags++; 1236 ofs += chunk; 1237 } 1238 *bdlp = bdl; 1239 return ofs; 1238 1240 } 1239 1241 … … 1242 1244 */ 1243 1245 static int azx_setup_periods(struct azx *chip, 1244 1245 1246 { 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1246 struct snd_pcm_substream *substream, 1247 struct azx_dev *azx_dev) 1248 { 1249 u32 *bdl; 1250 int i, ofs, periods, period_bytes; 1251 int pos_adj; 1252 1253 /* reset BDL address */ 1254 azx_sd_writel(azx_dev, SD_BDLPL, 0); 1255 azx_sd_writel(azx_dev, SD_BDLPU, 0); 1256 1257 period_bytes = azx_dev->period_bytes; 1258 periods = azx_dev->bufsize / period_bytes; 1259 1260 /* program the initial BDL entries */ 1261 bdl = (u32 *)azx_dev->bdl.area; 1262 ofs = 0; 1263 azx_dev->frags = 0; 1264 pos_adj = bdl_pos_adj[chip->dev_index]; 1265 if (pos_adj > 0) { 1266 struct snd_pcm_runtime *runtime = substream->runtime; 1267 int pos_align = pos_adj; 1268 pos_adj = (pos_adj * runtime->rate + 47999) / 48000; 1269 if (!pos_adj) 1270 pos_adj = pos_align; 1271 else 1272 pos_adj = ((pos_adj + pos_align - 1) / pos_align) * 1273 pos_align; 1274 pos_adj = frames_to_bytes(runtime, pos_adj); 1275 if (pos_adj >= period_bytes) { 1276 snd_printk(KERN_WARNING SFX "Too big adjustment %d\n", 1277 bdl_pos_adj[chip->dev_index]); 1278 pos_adj = 0; 1279 } else { 1280 ofs = setup_bdle(substream, azx_dev, 1281 &bdl, ofs, pos_adj, 1282 !substream->runtime->no_period_wakeup); 1283 if (ofs < 0) 1284 goto error; 1285 } 1286 } else 1287 pos_adj = 0; 1288 for (i = 0; i < periods; i++) { 1289 if (i == periods - 1 && pos_adj) 1290 ofs = setup_bdle(substream, azx_dev, &bdl, ofs, 1291 period_bytes - pos_adj, 0); 1292 else 1293 ofs = setup_bdle(substream, azx_dev, &bdl, ofs, 1294 period_bytes, 1295 !substream->runtime->no_period_wakeup); 1296 if (ofs < 0) 1297 goto error; 1298 } 1299 return 0; 1298 1300 1299 1301 error: 1300 1301 1302 1302 snd_printk(KERN_ERR SFX "Too many BDL entries: buffer=%d, period=%d\n", 1303 azx_dev->bufsize, period_bytes); 1304 return -EINVAL; 1303 1305 } 1304 1306 … … 1306 1308 static void azx_stream_reset(struct azx *chip, struct azx_dev *azx_dev) 1307 1309 { 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1310 unsigned char val; 1311 int timeout; 1312 1313 azx_stream_clear(chip, azx_dev); 1314 1315 azx_sd_writeb(azx_dev, SD_CTL, azx_sd_readb(azx_dev, SD_CTL) | 1316 SD_CTL_STREAM_RESET); 1317 udelay(3); 1318 timeout = 300; 1319 while (!((val = azx_sd_readb(azx_dev, SD_CTL)) & SD_CTL_STREAM_RESET) && 1320 --timeout) 1321 ; 1322 val &= ~SD_CTL_STREAM_RESET; 1323 azx_sd_writeb(azx_dev, SD_CTL, val); 1324 udelay(3); 1325 1326 timeout = 300; 1327 /* waiting for hardware to report that the stream is out of reset */ 1328 while (((val = azx_sd_readb(azx_dev, SD_CTL)) & SD_CTL_STREAM_RESET) && 1329 --timeout) 1330 ; 1331 1332 /* reset first position - may not be synced with hw at this time */ 1333 *azx_dev->posbuf = 0; 1332 1334 } 1333 1335 … … 1337 1339 static int azx_setup_controller(struct azx *chip, struct azx_dev *azx_dev) 1338 1340 { 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1341 /* make sure the run bit is zero for SD */ 1342 azx_stream_clear(chip, azx_dev); 1343 /* program the stream_tag */ 1344 azx_sd_writel(azx_dev, SD_CTL, 1345 (azx_sd_readl(azx_dev, SD_CTL) & ~SD_CTL_STREAM_TAG_MASK)| 1346 (azx_dev->stream_tag << SD_CTL_STREAM_TAG_SHIFT)); 1347 1348 /* program the length of samples in cyclic buffer */ 1349 azx_sd_writel(azx_dev, SD_CBL, azx_dev->bufsize); 1350 1351 /* program the stream format */ 1352 /* this value needs to be the same as the one programmed */ 1353 azx_sd_writew(azx_dev, SD_FORMAT, azx_dev->format_val); 1354 1355 /* program the stream LVI (last valid index) of the BDL */ 1356 azx_sd_writew(azx_dev, SD_LVI, azx_dev->frags - 1); 1357 1358 /* program the BDL address */ 1359 /* lower BDL address */ 1360 azx_sd_writel(azx_dev, SD_BDLPL, (u32)azx_dev->bdl.addr); 1361 /* upper BDL address */ 1362 azx_sd_writel(azx_dev, SD_BDLPU, upper_32_bits(azx_dev->bdl.addr)); 1363 1364 /* enable the position buffer */ 1365 if (chip->position_fix[0] != POS_FIX_LPIB || 1366 chip->position_fix[1] != POS_FIX_LPIB) { 1367 if (!(azx_readl(chip, DPLBASE) & ICH6_DPLBASE_ENABLE)) 1368 azx_writel(chip, DPLBASE, 1369 (u32)chip->posbuf.addr | ICH6_DPLBASE_ENABLE); 1370 } 1371 1372 /* set the interrupt enable bits in the descriptor control register */ 1373 azx_sd_writel(azx_dev, SD_CTL, 1374 azx_sd_readl(azx_dev, SD_CTL) | SD_INT_MASK); 1375 1376 return 0; 1375 1377 } 1376 1378 … … 1380 1382 static int probe_codec(struct azx *chip, int addr) 1381 1383 { 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1384 unsigned int cmd = (addr << 28) | (AC_NODE_ROOT << 20) | 1385 (AC_VERB_PARAMETERS << 8) | AC_PAR_VENDOR_ID; 1386 unsigned int res; 1387 1388 mutex_lock(&chip->bus->cmd_mutex); 1389 chip->probing = 1; 1390 azx_send_cmd(chip->bus, cmd); 1391 res = azx_get_response(chip->bus, addr); 1392 chip->probing = 0; 1393 mutex_unlock(&chip->bus->cmd_mutex); 1394 if (res == -1) 1395 return -EIO; 1396 snd_printdd(SFX "codec #%d probed OK\n", addr); 1397 return 0; 1396 1398 } 1397 1399 1398 1400 static int azx_attach_pcm_stream(struct hda_bus *bus, struct hda_codec *codec, 1399 1401 struct hda_pcm *cpcm); 1400 1402 static void azx_stop_chip(struct azx *chip); 1401 1403 1402 1404 static void azx_bus_reset(struct hda_bus *bus) 1403 1405 { 1404 1405 1406 1407 1408 1406 struct azx *chip = bus->private_data; 1407 1408 bus->in_reset = 1; 1409 azx_stop_chip(chip); 1410 azx_init_chip(chip, 1); 1409 1411 #ifdef CONFIG_PM 1410 1411 1412 1413 1414 1415 1416 1417 1412 if (chip->initialized) { 1413 int i; 1414 1415 for (i = 0; i < HDA_MAX_PCMS; i++) 1416 snd_pcm_suspend_all(chip->pcm[i]); 1417 snd_hda_suspend(chip->bus); 1418 snd_hda_resume(chip->bus); 1419 } 1418 1420 #endif 1419 1421 bus->in_reset = 0; 1420 1422 } 1421 1423 … … 1426 1428 /* number of codec slots for each chipset: 0 = default slots (i.e. 4) */ 1427 1429 static unsigned int azx_max_codecs[AZX_NUM_DRIVERS] __devinitdata = { 1428 1429 1430 [AZX_DRIVER_NVIDIA] = 8, 1431 [AZX_DRIVER_TERA] = 1, 1430 1432 }; 1431 1433 1432 1434 static int __devinit azx_codec_create(struct azx *chip, const char *model) 1433 1435 { 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1436 struct hda_bus_template bus_temp; 1437 int c, codecs, err; 1438 int max_slots; 1439 1440 memset(&bus_temp, 0, sizeof(bus_temp)); 1441 bus_temp.private_data = chip; 1442 bus_temp.modelname = model; 1443 bus_temp.pci = chip->pci; 1444 bus_temp.ops.command = azx_send_cmd; 1445 bus_temp.ops.get_response = azx_get_response; 1446 bus_temp.ops.attach_pcm = azx_attach_pcm_stream; 1447 bus_temp.ops.bus_reset = azx_bus_reset; 1446 1448 #ifdef CONFIG_SND_HDA_POWER_SAVE 1447 1448 1449 bus_temp.power_save = &power_save; 1450 bus_temp.ops.pm_notify = azx_power_notify; 1449 1451 #endif 1450 1452 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1453 err = snd_hda_bus_new(chip->card, &bus_temp, &chip->bus); 1454 if (err < 0) 1455 return err; 1456 1457 if (chip->driver_type == AZX_DRIVER_NVIDIA) 1458 chip->bus->needs_damn_long_delay = 1; 1459 1460 codecs = 0; 1461 max_slots = azx_max_codecs[chip->driver_type]; 1462 if (!max_slots) 1463 max_slots = AZX_DEFAULT_CODECS; 1464 1465 /* First try to probe all given codec slots */ 1466 for (c = 0; c < max_slots; c++) { 1467 if ((chip->codec_mask & (1 << c)) & chip->codec_probe_mask) { 1468 if (probe_codec(chip, c) < 0) { 1469 /* Some BIOSen give you wrong codec addresses 1470 * that don't exist 1471 */ 1472 snd_printk(KERN_WARNING SFX 1473 "Codec #%d probe error; " 1474 "disabling it...\n", c); 1475 chip->codec_mask &= ~(1 << c); 1476 /* More badly, accessing to a non-existing 1477 * codec often screws up the controller chip, 1478 * and disturbs the further communications. 1479 * Thus if an error occurs during probing, 1480 * better to reset the controller chip to 1481 * get back to the sanity state. 1482 */ 1483 azx_stop_chip(chip); 1484 azx_init_chip(chip, 1); 1485 } 1486 } 1487 } 1488 1489 /* Then create codec instances */ 1490 for (c = 0; c < max_slots; c++) { 1491 if ((chip->codec_mask & (1 << c)) & chip->codec_probe_mask) { 1492 struct hda_codec *codec; 1493 err = snd_hda_codec_new(chip->bus, c, &codec); 1494 if (err < 0) 1495 continue; 1496 codec->beep_mode = chip->beep_mode; 1497 codecs++; 1498 } 1499 } 1500 if (!codecs) { 1501 snd_printk(KERN_ERR SFX "no codecs initialized\n"); 1502 return -ENXIO; 1503 } 1504 return 0; 1503 1505 } 1504 1506 … … 1506 1508 static int __devinit azx_codec_configure(struct azx *chip) 1507 1509 { 1508 1509 1510 1511 1512 1510 struct hda_codec *codec; 1511 list_for_each_entry(codec, &chip->bus->codec_list, list, struct hda_codec) { 1512 snd_hda_codec_configure(codec); 1513 } 1514 return 0; 1513 1515 } 1514 1516 … … 1522 1524 azx_assign_device(struct azx *chip, struct snd_pcm_substream *substream) 1523 1525 { 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1526 int dev, i, nums; 1527 struct azx_dev *res = NULL; 1528 1529 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { 1530 dev = chip->playback_index_offset; 1531 nums = chip->playback_streams; 1532 } else { 1533 dev = chip->capture_index_offset; 1534 nums = chip->capture_streams; 1535 } 1536 for (i = 0; i < nums; i++, dev++) 1537 if (!chip->azx_dev[dev].opened) { 1538 res = &chip->azx_dev[dev]; 1539 if (res->device == substream->pcm->device) 1540 break; 1541 } 1542 if (res) { 1543 res->opened = 1; 1544 res->device = substream->pcm->device; 1545 } 1546 return res; 1545 1547 } 1546 1548 … … 1548 1550 static inline void azx_release_device(struct azx_dev *azx_dev) 1549 1551 { 1550 1552 azx_dev->opened = 0; 1551 1553 } 1552 1554 1553 1555 static struct snd_pcm_hardware azx_pcm_hw = { 1554 .info =(SNDRV_PCM_INFO_MMAP |1555 1556 1557 1558 1559 1560 1561 1562 1563 .formats =SNDRV_PCM_FMTBIT_S16_LE,1564 .rates =SNDRV_PCM_RATE_48000,1565 .rate_min =48000,1566 .rate_max =48000,1567 .channels_min =2,1568 .channels_max =2,1569 .buffer_bytes_max =AZX_MAX_BUF_SIZE,1570 .period_bytes_min =128,1571 .period_bytes_max =AZX_MAX_BUF_SIZE / 2,1572 .periods_min =2,1573 .periods_max =AZX_MAX_FRAG,1574 .fifo_size =0,1556 .info = (SNDRV_PCM_INFO_MMAP | 1557 SNDRV_PCM_INFO_INTERLEAVED | 1558 SNDRV_PCM_INFO_BLOCK_TRANSFER | 1559 SNDRV_PCM_INFO_MMAP_VALID | 1560 /* No full-resume yet implemented */ 1561 /* SNDRV_PCM_INFO_RESUME |*/ 1562 SNDRV_PCM_INFO_PAUSE | 1563 SNDRV_PCM_INFO_SYNC_START | 1564 SNDRV_PCM_INFO_NO_PERIOD_WAKEUP), 1565 .formats = SNDRV_PCM_FMTBIT_S16_LE, 1566 .rates = SNDRV_PCM_RATE_48000, 1567 .rate_min = 48000, 1568 .rate_max = 48000, 1569 .channels_min = 2, 1570 .channels_max = 2, 1571 .buffer_bytes_max = AZX_MAX_BUF_SIZE, 1572 .period_bytes_min = 128, 1573 .period_bytes_max = AZX_MAX_BUF_SIZE / 2, 1574 .periods_min = 2, 1575 .periods_max = AZX_MAX_FRAG, 1576 .fifo_size = 0, 1575 1577 }; 1576 1578 1577 1579 struct azx_pcm { 1578 1579 1580 1580 struct azx *chip; 1581 struct hda_codec *codec; 1582 struct hda_pcm_stream *hinfo[2]; 1581 1583 }; 1582 1584 1583 1585 static int azx_pcm_open(struct snd_pcm_substream *substream) 1584 1586 { 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1587 struct azx_pcm *apcm = snd_pcm_substream_chip(substream); 1588 struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream]; 1589 struct azx *chip = apcm->chip; 1590 struct azx_dev *azx_dev; 1591 struct snd_pcm_runtime *runtime = substream->runtime; 1592 unsigned long flags; 1593 int err; 1594 1595 mutex_lock(&chip->open_mutex); 1596 azx_dev = azx_assign_device(chip, substream); 1597 if (azx_dev == NULL) { 1598 mutex_unlock(&chip->open_mutex); 1599 return -EBUSY; 1600 } 1601 runtime->hw = azx_pcm_hw; 1602 runtime->hw.channels_min = hinfo->channels_min; 1603 runtime->hw.channels_max = hinfo->channels_max; 1604 runtime->hw.formats = hinfo->formats; 1605 runtime->hw.rates = hinfo->rates; 1606 snd_pcm_limit_hw_rates(runtime); 1607 snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); 1608 snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 1609 128); 1610 snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 1611 128); 1612 snd_hda_power_up(apcm->codec); 1613 err = hinfo->ops.open(hinfo, apcm->codec, substream); 1614 if (err < 0) { 1615 azx_release_device(azx_dev); 1616 snd_hda_power_down(apcm->codec); 1617 mutex_unlock(&chip->open_mutex); 1618 return err; 1619 } 1620 snd_pcm_limit_hw_rates(runtime); 1621 /* sanity check */ 1622 if (snd_BUG_ON(!runtime->hw.channels_min) || 1623 snd_BUG_ON(!runtime->hw.channels_max) || 1624 snd_BUG_ON(!runtime->hw.formats) || 1625 snd_BUG_ON(!runtime->hw.rates)) { 1626 azx_release_device(azx_dev); 1627 hinfo->ops.close(hinfo, apcm->codec, substream); 1628 snd_hda_power_down(apcm->codec); 1629 mutex_unlock(&chip->open_mutex); 1630 return -EINVAL; 1631 } 1632 spin_lock_irqsave(&chip->reg_lock, flags); 1633 azx_dev->substream = substream; 1634 azx_dev->running = 0; 1635 spin_unlock_irqrestore(&chip->reg_lock, flags); 1636 1637 runtime->private_data = azx_dev; 1638 snd_pcm_set_sync(substream); 1639 mutex_unlock(&chip->open_mutex); 1640 return 0; 1639 1641 } 1640 1642 1641 1643 static int azx_pcm_close(struct snd_pcm_substream *substream) 1642 1644 { 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1645 struct azx_pcm *apcm = snd_pcm_substream_chip(substream); 1646 struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream]; 1647 struct azx *chip = apcm->chip; 1648 struct azx_dev *azx_dev = get_azx_dev(substream); 1649 unsigned long flags; 1650 1651 mutex_lock(&chip->open_mutex); 1652 spin_lock_irqsave(&chip->reg_lock, flags); 1653 azx_dev->substream = NULL; 1654 azx_dev->running = 0; 1655 spin_unlock_irqrestore(&chip->reg_lock, flags); 1656 azx_release_device(azx_dev); 1657 hinfo->ops.close(hinfo, apcm->codec, substream); 1658 snd_hda_power_down(apcm->codec); 1659 mutex_unlock(&chip->open_mutex); 1660 return 0; 1659 1661 } 1660 1662 1661 1663 static int azx_pcm_hw_params(struct snd_pcm_substream *substream, 1662 1663 { 1664 1665 1666 1667 1668 1669 1670 1664 struct snd_pcm_hw_params *hw_params) 1665 { 1666 struct azx_dev *azx_dev = get_azx_dev(substream); 1667 1668 azx_dev->bufsize = 0; 1669 azx_dev->period_bytes = 0; 1670 azx_dev->format_val = 0; 1671 return snd_pcm_lib_malloc_pages(substream, 1672 params_buffer_bytes(hw_params)); 1671 1673 } 1672 1674 1673 1675 static int azx_pcm_hw_free(struct snd_pcm_substream *substream) 1674 1676 { 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1677 struct azx_pcm *apcm = snd_pcm_substream_chip(substream); 1678 struct azx_dev *azx_dev = get_azx_dev(substream); 1679 struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream]; 1680 1681 /* reset BDL address */ 1682 azx_sd_writel(azx_dev, SD_BDLPL, 0); 1683 azx_sd_writel(azx_dev, SD_BDLPU, 0); 1684 azx_sd_writel(azx_dev, SD_CTL, 0); 1685 azx_dev->bufsize = 0; 1686 azx_dev->period_bytes = 0; 1687 azx_dev->format_val = 0; 1688 1689 snd_hda_codec_cleanup(apcm->codec, hinfo, substream); 1690 1691 return snd_pcm_lib_free_pages(substream); 1690 1692 } 1691 1693 1692 1694 static int azx_pcm_prepare(struct snd_pcm_substream *substream) 1693 1695 { 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1696 struct azx_pcm *apcm = snd_pcm_substream_chip(substream); 1697 struct azx *chip = apcm->chip; 1698 struct azx_dev *azx_dev = get_azx_dev(substream); 1699 struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream]; 1700 struct snd_pcm_runtime *runtime = substream->runtime; 1701 unsigned int bufsize, period_bytes, format_val, stream_tag; 1702 int err; 1703 1704 azx_stream_reset(chip, azx_dev); 1705 format_val = snd_hda_calc_stream_format(runtime->rate, 1706 runtime->channels, 1707 runtime->format, 1708 hinfo->maxbps, 1709 apcm->codec->spdif_ctls); 1710 if (!format_val) { 1711 snd_printk(KERN_ERR SFX 1712 "invalid format_val, rate=%d, ch=%d, format=%d\n", 1713 runtime->rate, runtime->channels, runtime->format); 1714 return -EINVAL; 1715 } 1716 1717 bufsize = snd_pcm_lib_buffer_bytes(substream); 1718 period_bytes = snd_pcm_lib_period_bytes(substream); 1719 1720 snd_printdd(SFX "azx_pcm_prepare: bufsize=0x%x, format=0x%x\n", 1721 bufsize, format_val); 1722 1723 if (bufsize != azx_dev->bufsize || 1724 period_bytes != azx_dev->period_bytes || 1725 format_val != azx_dev->format_val) { 1726 azx_dev->bufsize = bufsize; 1727 azx_dev->period_bytes = period_bytes; 1728 azx_dev->format_val = format_val; 1729 err = azx_setup_periods(chip, substream, azx_dev); 1730 if (err < 0) 1731 return err; 1732 } 1733 1734 /* wallclk has 24Mhz clock source */ 1735 azx_dev->period_wallclk = (((runtime->period_size * 24000) / 1736 runtime->rate) * 1000); 1737 azx_setup_controller(chip, azx_dev); 1738 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 1739 azx_dev->fifo_size = azx_sd_readw(azx_dev, SD_FIFOSIZE) + 1; 1740 else 1741 azx_dev->fifo_size = 0; 1742 1743 stream_tag = azx_dev->stream_tag; 1744 /* CA-IBG chips need the playback stream starting from 1 */ 1745 if (chip->driver_type == AZX_DRIVER_CTX && 1746 stream_tag > chip->capture_streams) 1747 stream_tag -= chip->capture_streams; 1748 return snd_hda_codec_prepare(apcm->codec, hinfo, stream_tag, 1749 azx_dev->format_val, substream); 1748 1750 } 1749 1751 1750 1752 static int azx_pcm_trigger(struct snd_pcm_substream *substream, int cmd) 1751 1753 { 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1754 struct azx_pcm *apcm = snd_pcm_substream_chip(substream); 1755 struct azx *chip = apcm->chip; 1756 struct azx_dev *azx_dev; 1757 struct snd_pcm_substream *s; 1758 int rstart = 0, start, nsync = 0, sbits = 0; 1759 int nwait, timeout; 1760 1761 switch (cmd) { 1762 case SNDRV_PCM_TRIGGER_START: 1763 rstart = 1; 1764 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 1765 case SNDRV_PCM_TRIGGER_RESUME: 1766 start = 1; 1767 break; 1768 case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 1769 case SNDRV_PCM_TRIGGER_SUSPEND: 1770 case SNDRV_PCM_TRIGGER_STOP: 1771 start = 0; 1772 break; 1773 default: 1774 return -EINVAL; 1775 } 1776 1777 snd_pcm_group_for_each_entry(s, substream) { 1778 if (s->pcm->card != substream->pcm->card) 1779 continue; 1780 azx_dev = get_azx_dev(s); 1781 sbits |= 1 << azx_dev->index; 1782 nsync++; 1783 snd_pcm_trigger_done(s, substream); 1784 } 1785 1786 spin_lock(&chip->reg_lock); 1787 if (nsync > 1) { 1788 /* first, set SYNC bits of corresponding streams */ 1789 azx_writel(chip, SYNC, azx_readl(chip, SYNC) | sbits); 1790 } 1791 snd_pcm_group_for_each_entry(s, substream) { 1792 if (s->pcm->card != substream->pcm->card) 1793 continue; 1794 azx_dev = get_azx_dev(s); 1795 if (start) { 1796 azx_dev->start_wallclk = azx_readl(chip, WALLCLK); 1797 if (!rstart) 1798 azx_dev->start_wallclk -= 1799 azx_dev->period_wallclk; 1800 azx_stream_start(chip, azx_dev); 1801 } else { 1802 azx_stream_stop(chip, azx_dev); 1803 } 1804 azx_dev->running = start; 1805 } 1806 spin_unlock(&chip->reg_lock); 1807 if (start) { 1808 if (nsync == 1) 1809 return 0; 1810 /* wait until all FIFOs get ready */ 1811 for (timeout = 5000; timeout; timeout--) { 1812 nwait = 0; 1813 snd_pcm_group_for_each_entry(s, substream) { 1814 if (s->pcm->card != substream->pcm->card) 1815 continue; 1816 azx_dev = get_azx_dev(s); 1817 if (!(azx_sd_readb(azx_dev, SD_STS) & 1818 SD_STS_FIFO_READY)) 1819 nwait++; 1820 } 1821 if (!nwait) 1822 break; 1823 cpu_relax(); 1824 } 1825 } else { 1826 /* wait until all RUN bits are cleared */ 1827 for (timeout = 5000; timeout; timeout--) { 1828 nwait = 0; 1829 snd_pcm_group_for_each_entry(s, substream) { 1830 if (s->pcm->card != substream->pcm->card) 1831 continue; 1832 azx_dev = get_azx_dev(s); 1833 if (azx_sd_readb(azx_dev, SD_CTL) & 1834 SD_CTL_DMA_START) 1835 nwait++; 1836 } 1837 if (!nwait) 1838 break; 1839 cpu_relax(); 1840 } 1841 } 1842 if (nsync > 1) { 1843 spin_lock(&chip->reg_lock); 1844 /* reset SYNC bits */ 1845 azx_writel(chip, SYNC, azx_readl(chip, SYNC) & ~sbits); 1846 spin_unlock(&chip->reg_lock); 1847 } 1848 return 0; 1847 1849 } 1848 1850 1849 1851 /* get the current DMA position with correction on VIA chips */ 1850 1852 static unsigned int azx_via_get_position(struct azx *chip, 1851 1852 { 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1853 struct azx_dev *azx_dev) 1854 { 1855 unsigned int link_pos, mini_pos, bound_pos; 1856 unsigned int mod_link_pos, mod_dma_pos, mod_mini_pos; 1857 unsigned int fifo_size; 1858 1859 link_pos = azx_sd_readl(azx_dev, SD_LPIB); 1860 if (azx_dev->index >= 4) { 1861 /* Playback, no problem using link position */ 1862 return link_pos; 1863 } 1864 1865 /* Capture */ 1866 /* For new chipset, 1867 * use mod to get the DMA position just like old chipset 1868 */ 1869 mod_dma_pos = le32_to_cpu(*azx_dev->posbuf); 1870 mod_dma_pos %= azx_dev->period_bytes; 1871 1872 /* azx_dev->fifo_size can't get FIFO size of in stream. 1873 * Get from base address + offset. 1874 */ 1875 fifo_size = readw(chip->remap_addr + VIA_IN_STREAM0_FIFO_SIZE_OFFSET); 1876 1877 if (azx_dev->insufficient) { 1878 /* Link position never gather than FIFO size */ 1879 if (link_pos <= fifo_size) 1880 return 0; 1881 1882 azx_dev->insufficient = 0; 1883 } 1884 1885 if (link_pos <= fifo_size) 1886 mini_pos = azx_dev->bufsize + link_pos - fifo_size; 1887 else 1888 mini_pos = link_pos - fifo_size; 1889 1890 /* Find nearest previous boudary */ 1891 mod_mini_pos = mini_pos % azx_dev->period_bytes; 1892 mod_link_pos = link_pos % azx_dev->period_bytes; 1893 if (mod_link_pos >= fifo_size) 1894 bound_pos = link_pos - mod_link_pos; 1895 else if (mod_dma_pos >= mod_mini_pos) 1896 bound_pos = mini_pos - mod_mini_pos; 1897 else { 1898 bound_pos = mini_pos - mod_mini_pos + azx_dev->period_bytes; 1899 if (bound_pos >= azx_dev->bufsize) 1900 bound_pos = 0; 1901 } 1902 1903 /* Calculate real DMA position we want */ 1904 return bound_pos + mod_dma_pos; 1903 1905 } 1904 1906 1905 1907 static unsigned int azx_get_position(struct azx *chip, 1906 1907 { 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1908 struct azx_dev *azx_dev) 1909 { 1910 unsigned int pos; 1911 int stream = azx_dev->substream->stream; 1912 1913 switch (chip->position_fix[stream]) { 1914 case POS_FIX_LPIB: 1915 /* read LPIB */ 1916 pos = azx_sd_readl(azx_dev, SD_LPIB); 1917 break; 1918 case POS_FIX_VIACOMBO: 1919 pos = azx_via_get_position(chip, azx_dev); 1920 break; 1921 default: 1922 /* use the position buffer */ 1923 pos = le32_to_cpu(*azx_dev->posbuf); 1924 } 1925 1926 if (pos >= azx_dev->bufsize) 1927 pos = 0; 1928 return pos; 1927 1929 } 1928 1930 1929 1931 static snd_pcm_uframes_t azx_pcm_pointer(struct snd_pcm_substream *substream) 1930 1932 { 1931 1932 1933 1934 1935 1933 struct azx_pcm *apcm = snd_pcm_substream_chip(substream); 1934 struct azx *chip = apcm->chip; 1935 struct azx_dev *azx_dev = get_azx_dev(substream); 1936 return bytes_to_frames(substream->runtime, 1937 azx_get_position(chip, azx_dev)); 1936 1938 } 1937 1939 … … 1947 1949 static int azx_position_ok(struct azx *chip, struct azx_dev *azx_dev) 1948 1950 { 1949 1950 1951 1952 1953 1954 1955 return -1;/* bogus (too early) interrupt */1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1951 u32 wallclk; 1952 unsigned int pos; 1953 int stream; 1954 1955 wallclk = azx_readl(chip, WALLCLK) - azx_dev->start_wallclk; 1956 if (wallclk < (azx_dev->period_wallclk * 2) / 3) 1957 return -1; /* bogus (too early) interrupt */ 1958 1959 stream = azx_dev->substream->stream; 1960 pos = azx_get_position(chip, azx_dev); 1961 if (chip->position_fix[stream] == POS_FIX_AUTO) { 1962 if (!pos) { 1963 printk(KERN_WARNING 1964 "hda-intel: Invalid position buffer, " 1965 "using LPIB read method instead.\n"); 1966 chip->position_fix[stream] = POS_FIX_LPIB; 1967 pos = azx_get_position(chip, azx_dev); 1968 } else 1969 chip->position_fix[stream] = POS_FIX_POSBUF; 1970 } 1969 1971 1970 1972 #ifndef TARGET_OS2 1971 1972 1973 1973 if (WARN_ONCE(!azx_dev->period_bytes, 1974 "hda-intel: zero azx_dev->period_bytes")) 1975 return -1; /* this shouldn't happen! */ 1974 1976 #endif 1975 1976 1977 1978 1979 1980 1977 if (wallclk < (azx_dev->period_wallclk * 5) / 4 && 1978 pos % azx_dev->period_bytes > azx_dev->period_bytes / 2) 1979 /* NG - it's below the first next period boundary */ 1980 return bdl_pos_adj[chip->dev_index] ? 0 : -1; 1981 azx_dev->start_wallclk += wallclk; 1982 return 1; /* OK, it's fine */ 1981 1983 } 1982 1984 … … 1986 1988 static void azx_irq_pending_work(struct work_struct *work) 1987 1989 { 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 pending = 0;/* too early */2016 2017 2018 2019 2020 2021 2022 2023 1990 struct azx *chip = container_of(work, struct azx, irq_pending_work); 1991 int i, pending, ok; 1992 1993 if (!chip->irq_pending_warned) { 1994 printk(KERN_WARNING 1995 "hda-intel: IRQ timing workaround is activated " 1996 "for card #%d. Suggest a bigger bdl_pos_adj.\n", 1997 chip->card->number); 1998 chip->irq_pending_warned = 1; 1999 } 2000 2001 for (;;) { 2002 pending = 0; 2003 spin_lock_irq(&chip->reg_lock); 2004 for (i = 0; i < chip->num_streams; i++) { 2005 struct azx_dev *azx_dev = &chip->azx_dev[i]; 2006 if (!azx_dev->irq_pending || 2007 !azx_dev->substream || 2008 !azx_dev->running) 2009 continue; 2010 ok = azx_position_ok(chip, azx_dev); 2011 if (ok > 0) { 2012 azx_dev->irq_pending = 0; 2013 spin_unlock(&chip->reg_lock); 2014 snd_pcm_period_elapsed(azx_dev->substream); 2015 spin_lock(&chip->reg_lock); 2016 } else if (ok < 0) { 2017 pending = 0; /* too early */ 2018 } else 2019 pending++; 2020 } 2021 spin_unlock_irq(&chip->reg_lock); 2022 if (!pending) 2023 return; 2024 msleep(1); 2025 } 2024 2026 } 2025 2027 … … 2027 2029 static void azx_clear_irq_pending(struct azx *chip) 2028 2030 { 2029 2030 2031 2032 2033 2034 2031 int i; 2032 2033 spin_lock_irq(&chip->reg_lock); 2034 for (i = 0; i < chip->num_streams; i++) 2035 chip->azx_dev[i].irq_pending = 0; 2036 spin_unlock_irq(&chip->reg_lock); 2035 2037 } 2036 2038 2037 2039 static struct snd_pcm_ops azx_pcm_ops = { 2038 2039 2040 2041 2042 2043 2044 2045 2046 2040 .open = azx_pcm_open, 2041 .close = azx_pcm_close, 2042 .ioctl = snd_pcm_lib_ioctl, 2043 .hw_params = azx_pcm_hw_params, 2044 .hw_free = azx_pcm_hw_free, 2045 .prepare = azx_pcm_prepare, 2046 .trigger = azx_pcm_trigger, 2047 .pointer = azx_pcm_pointer, 2048 .page = snd_pcm_sgbuf_ops_page, 2047 2049 }; 2048 2050 2049 2051 static void azx_pcm_free(struct snd_pcm *pcm) 2050 2052 { 2051 2052 2053 2054 2055 2053 struct azx_pcm *apcm = pcm->private_data; 2054 if (apcm) { 2055 apcm->chip->pcm[pcm->device] = NULL; 2056 kfree(apcm); 2057 } 2056 2058 } 2057 2059 2058 2060 static int 2059 2061 azx_attach_pcm_stream(struct hda_bus *bus, struct hda_codec *codec, 2060 2061 { 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2062 struct hda_pcm *cpcm) 2063 { 2064 struct azx *chip = bus->private_data; 2065 struct snd_pcm *pcm; 2066 struct azx_pcm *apcm; 2067 int pcm_dev = cpcm->device; 2068 int s, err; 2069 2070 if (pcm_dev >= HDA_MAX_PCMS) { 2071 snd_printk(KERN_ERR SFX "Invalid PCM device number %d\n", 2072 pcm_dev); 2073 return -EINVAL; 2074 } 2075 if (chip->pcm[pcm_dev]) { 2076 snd_printk(KERN_ERR SFX "PCM %d already exists\n", pcm_dev); 2077 return -EBUSY; 2078 } 2079 err = snd_pcm_new(chip->card, cpcm->name, pcm_dev, 2080 cpcm->stream[SNDRV_PCM_STREAM_PLAYBACK].substreams, 2081 cpcm->stream[SNDRV_PCM_STREAM_CAPTURE].substreams, 2082 &pcm); 2083 if (err < 0) 2084 return err; 2085 strlcpy(pcm->name, cpcm->name, sizeof(pcm->name)); 2086 apcm = kzalloc(sizeof(*apcm), GFP_KERNEL); 2087 if (apcm == NULL) 2088 return -ENOMEM; 2089 apcm->chip = chip; 2090 apcm->codec = codec; 2091 pcm->private_data = apcm; 2092 pcm->private_free = azx_pcm_free; 2093 if (cpcm->pcm_type == HDA_PCM_TYPE_MODEM) 2094 pcm->dev_class = SNDRV_PCM_CLASS_MODEM; 2095 chip->pcm[pcm_dev] = pcm; 2096 cpcm->pcm = pcm; 2097 for (s = 0; s < 2; s++) { 2098 apcm->hinfo[s] = &cpcm->stream[s]; 2099 if (cpcm->stream[s].substreams) 2100 snd_pcm_set_ops(pcm, s, &azx_pcm_ops); 2101 } 2102 /* buffer pre-allocation */ 2103 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, 2104 snd_dma_pci_data(chip->pci), 2105 1024 * 64, 32 * 1024 * 1024); 2106 return 0; 2105 2107 } 2106 2108 … … 2110 2112 static int __devinit azx_mixer_create(struct azx *chip) 2111 2113 { 2112 2114 return snd_hda_build_controls(chip->bus); 2113 2115 } 2114 2116 … … 2119 2121 static int __devinit azx_init_stream(struct azx *chip) 2120 2122 { 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2123 int i; 2124 2125 /* initialize each stream (aka device) 2126 * assign the starting bdl address to each stream (device) 2127 * and initialize 2128 */ 2129 for (i = 0; i < chip->num_streams; i++) { 2130 struct azx_dev *azx_dev = &chip->azx_dev[i]; 2131 azx_dev->posbuf = (u32 __iomem *)(chip->posbuf.area + i * 8); 2132 /* offset: SDI0=0x80, SDI1=0xa0, ... SDO3=0x160 */ 2133 azx_dev->sd_addr = chip->remap_addr + (0x20 * i + 0x80); 2134 /* int mask: SDI0=0x01, SDI1=0x02, ... SDO3=0x80 */ 2135 azx_dev->sd_int_sta_mask = 1 << i; 2136 /* stream tag: must be non-zero and unique */ 2137 azx_dev->index = i; 2138 azx_dev->stream_tag = i + 1; 2139 } 2140 2141 return 0; 2140 2142 } 2141 2143 2142 2144 static int azx_acquire_irq(struct azx *chip, int do_disconnect) 2143 2145 { 2144 2145 2146 2147 2148 2146 if (request_irq(chip->pci->irq, azx_interrupt, 2147 chip->msi ? 0 : IRQF_SHARED, 2148 "hda_intel", chip)) { 2149 printk(KERN_ERR "hda-intel: unable to grab IRQ %d, " 2150 "disabling device\n", chip->pci->irq); 2149 2151 #ifndef TARGET_OS2 2150 2151 2152 if (do_disconnect) 2153 snd_card_disconnect(chip->card); 2152 2154 #endif 2153 2154 2155 2156 2157 2155 return -1; 2156 } 2157 chip->irq = chip->pci->irq; 2158 pci_intx(chip->pci, !chip->msi); 2159 return 0; 2158 2160 } 2159 2161 … … 2161 2163 static void azx_stop_chip(struct azx *chip) 2162 2164 { 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2165 if (!chip->initialized) 2166 return; 2167 2168 /* disable interrupts */ 2169 azx_int_disable(chip); 2170 azx_int_clear(chip); 2171 2172 /* disable CORB/RIRB */ 2173 azx_free_cmd_io(chip); 2174 2175 /* disable position buffer */ 2176 azx_writel(chip, DPLBASE, 0); 2177 azx_writel(chip, DPUBASE, 0); 2178 2179 chip->initialized = 0; 2178 2180 } 2179 2181 … … 2182 2184 static void azx_power_notify(struct hda_bus *bus) 2183 2185 { 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2186 struct azx *chip = bus->private_data; 2187 struct hda_codec *c; 2188 int power_on = 0; 2189 2190 list_for_each_entry(c, &bus->codec_list, list, struct hda_codec) { 2191 if (c->power_on) { 2192 power_on = 1; 2193 break; 2194 } 2195 } 2196 if (power_on) 2197 azx_init_chip(chip, 1); 2198 else if (chip->running && power_save_controller && 2199 !bus->power_keep_link_on) 2200 azx_stop_chip(chip); 2199 2201 } 2200 2202 #endif /* CONFIG_SND_HDA_POWER_SAVE */ … … 2207 2209 static int snd_hda_codecs_inuse(struct hda_bus *bus) 2208 2210 { 2209 2210 2211 2212 2213 2214 2215 2211 struct hda_codec *codec; 2212 2213 list_for_each_entry(codec, &bus->codec_list, list, struct hda_codec) { 2214 if (snd_hda_codec_needs_resume(codec)) 2215 return 1; 2216 } 2217 return 0; 2216 2218 } 2217 2219 2218 2220 static int azx_suspend(struct pci_dev *pci, pm_message_t state) 2219 2221 { 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2222 struct snd_card *card = pci_get_drvdata(pci); 2223 struct azx *chip = card->private_data; 2224 int i; 2225 2226 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 2227 azx_clear_irq_pending(chip); 2228 for (i = 0; i < HDA_MAX_PCMS; i++) 2229 snd_pcm_suspend_all(chip->pcm[i]); 2230 if (chip->initialized) 2231 snd_hda_suspend(chip->bus); 2232 azx_stop_chip(chip); 2233 if (chip->irq >= 0) { 2234 free_irq(chip->irq, chip); 2235 chip->irq = -1; 2236 } 2237 if (chip->msi) 2238 pci_disable_msi(chip->pci); 2239 pci_disable_device(pci); 2240 pci_save_state(pci); 2241 pci_set_power_state(pci, pci_choose_state(pci, state)); 2242 return 0; 2241 2243 } 2242 2244 2243 2245 static int azx_resume(struct pci_dev *pci) 2244 2246 { 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2247 struct snd_card *card = pci_get_drvdata(pci); 2248 struct azx *chip = card->private_data; 2249 2250 pci_set_power_state(pci, PCI_D0); 2251 pci_restore_state(pci); 2252 if (pci_enable_device(pci) < 0) { 2253 printk(KERN_ERR "hda-intel: pci_enable_device failed, " 2254 "disabling device\n"); 2255 snd_card_disconnect(card); 2256 return -EIO; 2257 } 2258 pci_set_master(pci); 2259 if (chip->msi) 2260 if (pci_enable_msi(pci) < 0) 2261 chip->msi = 0; 2262 if (azx_acquire_irq(chip, 1) < 0) 2263 return -EIO; 2264 azx_init_pci(chip); 2265 2266 if (snd_hda_codecs_inuse(chip->bus)) 2267 azx_init_chip(chip, 1); 2268 2269 snd_hda_resume(chip->bus); 2270 snd_power_change_state(card, SNDRV_CTL_POWER_D0); 2271 return 0; 2270 2272 } 2271 2273 #endif /* CONFIG_PM */ … … 2277 2279 static int azx_halt(struct notifier_block *nb, unsigned long event, void *buf) 2278 2280 { 2279 2280 2281 2282 2281 struct azx *chip = container_of(nb, struct azx, reboot_notifier); 2282 snd_hda_bus_reboot_notify(chip->bus); 2283 azx_stop_chip(chip); 2284 return NOTIFY_OK; 2283 2285 } 2284 2286 2285 2287 static void azx_notifier_register(struct azx *chip) 2286 2288 { 2287 2288 2289 chip->reboot_notifier.notifier_call = azx_halt; 2290 register_reboot_notifier(&chip->reboot_notifier); 2289 2291 } 2290 2292 2291 2293 static void azx_notifier_unregister(struct azx *chip) 2292 2294 { 2293 2294 2295 if (chip->reboot_notifier.notifier_call) 2296 unregister_reboot_notifier(&chip->reboot_notifier); 2295 2297 } 2296 2298 … … 2300 2302 static int azx_free(struct azx *chip) 2301 2303 { 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2304 int i; 2305 2306 azx_notifier_unregister(chip); 2307 2308 if (chip->initialized) { 2309 azx_clear_irq_pending(chip); 2310 for (i = 0; i < chip->num_streams; i++) 2311 azx_stream_stop(chip, &chip->azx_dev[i]); 2312 azx_stop_chip(chip); 2313 } 2314 2315 if (chip->irq >= 0) 2316 free_irq(chip->irq, (void*)chip); 2317 if (chip->msi) 2318 pci_disable_msi(chip->pci); 2319 if (chip->remap_addr) 2318 2320 #ifdef TARGET_OS2 2319 2321 iounmap((void *)chip->remap_addr); 2320 2322 #else 2321 2323 iounmap(chip->remap_addr); 2322 2324 #endif 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2325 if (chip->azx_dev) { 2326 for (i = 0; i < chip->num_streams; i++) 2327 if (chip->azx_dev[i].bdl.area) 2328 snd_dma_free_pages(&chip->azx_dev[i].bdl); 2329 } 2330 if (chip->rb.area) 2331 snd_dma_free_pages(&chip->rb); 2332 if (chip->posbuf.area) 2333 snd_dma_free_pages(&chip->posbuf); 2334 pci_release_regions(chip->pci); 2335 pci_disable_device(chip->pci); 2336 kfree(chip->azx_dev); 2337 kfree(chip); 2338 2339 return 0; 2338 2340 } 2339 2341 2340 2342 static int azx_dev_free(struct snd_device *device) 2341 2343 { 2342 2344 return azx_free(device->device_data); 2343 2345 } 2344 2346 … … 2347 2349 */ 2348 2350 static struct snd_pci_quirk position_fix_list[] __devinitdata = { 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2351 SND_PCI_QUIRK(0x1025, 0x009f, "Acer Aspire 5110", POS_FIX_LPIB), 2352 SND_PCI_QUIRK(0x1025, 0x026f, "Acer Aspire 5538", POS_FIX_LPIB), 2353 SND_PCI_QUIRK(0x1028, 0x01cc, "Dell D820", POS_FIX_LPIB), 2354 SND_PCI_QUIRK(0x1028, 0x01de, "Dell Precision 390", POS_FIX_LPIB), 2355 SND_PCI_QUIRK(0x1028, 0x01f6, "Dell Latitude 131L", POS_FIX_LPIB), 2356 SND_PCI_QUIRK(0x1028, 0x0470, "Dell Inspiron 1120", POS_FIX_LPIB), 2357 SND_PCI_QUIRK(0x103c, 0x306d, "HP dv3", POS_FIX_LPIB), 2358 SND_PCI_QUIRK(0x1043, 0x813d, "ASUS P5AD2", POS_FIX_LPIB), 2359 SND_PCI_QUIRK(0x1043, 0x81b3, "ASUS", POS_FIX_LPIB), 2360 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS M2V", POS_FIX_LPIB), 2361 SND_PCI_QUIRK(0x104d, 0x9069, "Sony VPCS11V9E", POS_FIX_LPIB), 2362 SND_PCI_QUIRK(0x1106, 0x3288, "ASUS M2V-MX SE", POS_FIX_LPIB), 2363 SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba A100-259", POS_FIX_LPIB), 2364 SND_PCI_QUIRK(0x1297, 0x3166, "Shuttle", POS_FIX_LPIB), 2365 SND_PCI_QUIRK(0x1458, 0xa022, "ga-ma770-ud3", POS_FIX_LPIB), 2366 SND_PCI_QUIRK(0x1462, 0x1002, "MSI Wind U115", POS_FIX_LPIB), 2367 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar Microtech", POS_FIX_LPIB), 2368 SND_PCI_QUIRK(0x1565, 0x8218, "Biostar Microtech", POS_FIX_LPIB), 2369 SND_PCI_QUIRK(0x1849, 0x0888, "775Dual-VSTA", POS_FIX_LPIB), 2370 SND_PCI_QUIRK(0x8086, 0x2503, "DG965OT AAD63733-203", POS_FIX_LPIB), 2371 SND_PCI_QUIRK(0x8086, 0xd601, "eMachines T5212", POS_FIX_LPIB), 2372 {0} 2371 2373 }; 2372 2374 2373 2375 static int __devinit check_position_fix(struct azx *chip, int fix) 2374 2376 { 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2377 const struct snd_pci_quirk *q; 2378 2379 switch (fix) { 2380 case POS_FIX_LPIB: 2381 case POS_FIX_POSBUF: 2382 case POS_FIX_VIACOMBO: 2383 return fix; 2384 } 2385 2386 q = snd_pci_quirk_lookup(chip->pci, position_fix_list); 2387 if (q) { 2388 printk(KERN_INFO 2389 "hda_intel: position_fix set to %d " 2390 "for device %04x:%04x\n", 2391 q->value, q->subvendor, q->subdevice); 2392 return q->value; 2393 } 2394 2395 /* Check VIA/ATI HD Audio Controller exist */ 2396 switch (chip->driver_type) { 2397 case AZX_DRIVER_VIA: 2398 case AZX_DRIVER_ATI: 2399 /* Use link position directly, avoid any transfer problem. */ 2400 return POS_FIX_VIACOMBO; 2401 } 2402 2403 return POS_FIX_AUTO; 2402 2404 } 2403 2405 … … 2406 2408 */ 2407 2409 static struct snd_pci_quirk probe_mask_list[] __devinitdata = { 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2410 /* Thinkpad often breaks the controller communication when accessing 2411 * to the non-working (or non-existing) modem codec slot. 2412 */ 2413 SND_PCI_QUIRK(0x1014, 0x05b7, "Thinkpad Z60", 0x01), 2414 SND_PCI_QUIRK(0x17aa, 0x2010, "Thinkpad X/T/R60", 0x01), 2415 SND_PCI_QUIRK(0x17aa, 0x20ac, "Thinkpad X/T/R61", 0x01), 2416 /* broken BIOS */ 2417 SND_PCI_QUIRK(0x1028, 0x20ac, "Dell Studio Desktop", 0x01), 2418 /* including bogus ALC268 in slot#2 that conflicts with ALC888 */ 2419 SND_PCI_QUIRK(0x17c0, 0x4085, "Medion MD96630", 0x01), 2420 /* forced codec slots */ 2421 SND_PCI_QUIRK(0x1043, 0x1262, "ASUS W5Fm", 0x103), 2422 SND_PCI_QUIRK(0x1046, 0x1262, "ASUS W5F", 0x103), 2423 {0} 2422 2424 }; 2423 2425 2424 #define AZX_FORCE_CODEC_MASK 2426 #define AZX_FORCE_CODEC_MASK 0x100 2425 2427 2426 2428 static void __devinit check_probe_mask(struct azx *chip, int dev) 2427 2429 { 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2430 const struct snd_pci_quirk *q; 2431 2432 chip->codec_probe_mask = probe_mask[dev]; 2433 if (chip->codec_probe_mask == -1) { 2434 q = snd_pci_quirk_lookup(chip->pci, probe_mask_list); 2435 if (q) { 2436 printk(KERN_INFO 2437 "hda_intel: probe_mask set to 0x%x " 2438 "for device %04x:%04x\n", 2439 q->value, q->subvendor, q->subdevice); 2440 chip->codec_probe_mask = q->value; 2441 } 2442 } 2443 2444 /* check forced option */ 2445 if (chip->codec_probe_mask != -1 && 2446 (chip->codec_probe_mask & AZX_FORCE_CODEC_MASK)) { 2447 chip->codec_mask = chip->codec_probe_mask & 0xff; 2448 printk(KERN_INFO "hda_intel: codec_mask forced to 0x%x\n", 2449 chip->codec_mask); 2450 } 2449 2451 } 2450 2452 … … 2453 2455 */ 2454 2456 static struct snd_pci_quirk msi_black_list[] __devinitdata = { 2455 2456 2457 2458 2459 2460 2457 SND_PCI_QUIRK(0x1043, 0x81f2, "ASUS", 0), /* Athlon64 X2 + nvidia */ 2458 SND_PCI_QUIRK(0x1043, 0x81f6, "ASUS", 0), /* nvidia */ 2459 SND_PCI_QUIRK(0x1043, 0x822d, "ASUS", 0), /* Athlon64 X2 + nvidia MCP55 */ 2460 SND_PCI_QUIRK(0x1849, 0x0888, "ASRock", 0), /* Athlon64 X2 + nvidia */ 2461 SND_PCI_QUIRK(0xa0a0, 0x0575, "Aopen MZ915-M", 0), /* ICH6 */ 2462 {0} 2461 2463 }; 2462 2464 2463 2465 static void __devinit check_msi(struct azx *chip) 2464 2466 { 2465 2466 2467 2468 2469 2470 2471 chip->msi = 1;/* enable MSI as default */2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2467 const struct snd_pci_quirk *q; 2468 2469 if (enable_msi >= 0) { 2470 chip->msi = !!enable_msi; 2471 return; 2472 } 2473 chip->msi = 1; /* enable MSI as default */ 2474 q = snd_pci_quirk_lookup(chip->pci, msi_black_list); 2475 if (q) { 2476 printk(KERN_INFO 2477 "hda_intel: msi for device %04x:%04x set to %d\n", 2478 q->subvendor, q->subdevice, q->value); 2479 chip->msi = q->value; 2480 return; 2481 } 2482 2483 /* NVidia chipsets seem to cause troubles with MSI */ 2484 if (chip->driver_type == AZX_DRIVER_NVIDIA) { 2485 printk(KERN_INFO "hda_intel: Disable MSI for Nvidia chipset\n"); 2486 chip->msi = 0; 2487 } 2486 2488 } 2487 2489 … … 2491 2493 */ 2492 2494 static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci, 2493 2494 2495 { 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2495 int dev, int driver_type, 2496 struct azx **rchip) 2497 { 2498 struct azx *chip; 2499 int i, err; 2500 unsigned short gcap; 2501 static struct snd_device_ops ops = { 2502 .dev_free = azx_dev_free, 2503 }; 2504 2505 *rchip = NULL; 2506 2507 err = pci_enable_device(pci); 2508 if (err < 0) 2509 return err; 2510 2511 chip = kzalloc(sizeof(*chip), GFP_KERNEL); 2512 if (!chip) { 2513 snd_printk(KERN_ERR SFX "cannot allocate chip\n"); 2514 pci_disable_device(pci); 2515 return -ENOMEM; 2516 } 2517 2518 spin_lock_init(&chip->reg_lock); 2519 mutex_init(&chip->open_mutex); 2520 chip->card = card; 2521 chip->pci = pci; 2522 chip->irq = -1; 2523 chip->driver_type = driver_type; 2524 check_msi(chip); 2525 chip->dev_index = dev; 2526 INIT_WORK(&chip->irq_pending_work, azx_irq_pending_work); 2527 2528 chip->position_fix[0] = chip->position_fix[1] = 2529 check_position_fix(chip, position_fix[dev]); 2530 check_probe_mask(chip, dev); 2531 2532 chip->single_cmd = single_cmd; 2533 2534 if (bdl_pos_adj[dev] < 0) { 2535 switch (chip->driver_type) { 2536 case AZX_DRIVER_ICH: 2537 case AZX_DRIVER_PCH: 2538 bdl_pos_adj[dev] = 1; 2539 break; 2540 default: 2541 bdl_pos_adj[dev] = 32; 2542 break; 2543 } 2544 } 2543 2545 2544 2546 #if BITS_PER_LONG != 64 2545 2546 2547 2548 2549 2550 2551 2547 /* Fix up base address on ULI M5461 */ 2548 if (chip->driver_type == AZX_DRIVER_ULI) { 2549 u16 tmp3; 2550 pci_read_config_word(pci, 0x40, &tmp3); 2551 pci_write_config_word(pci, 0x40, tmp3 | 0x10); 2552 pci_write_config_dword(pci, PCI_BASE_ADDRESS_1, 0); 2553 } 2552 2554 #endif 2553 2555 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2556 err = pci_request_regions(pci, "ICH HD audio"); 2557 if (err < 0) { 2558 kfree(chip); 2559 pci_disable_device(pci); 2560 return err; 2561 } 2562 2563 chip->addr = pci_resource_start(pci, 0); 2564 chip->remap_addr = pci_ioremap_bar(pci, 0); 2565 if (chip->remap_addr == NULL) { 2566 snd_printk(KERN_ERR SFX "ioremap error\n"); 2567 err = -ENXIO; 2568 goto errout; 2569 } 2570 2571 if (chip->msi) 2572 if (pci_enable_msi(pci) < 0) 2573 chip->msi = 0; 2574 2575 if (azx_acquire_irq(chip, 0) < 0) { 2576 err = -EBUSY; 2577 goto errout; 2578 } 2579 2580 pci_set_master(pci); 2581 synchronize_irq(chip->irq); 2582 2583 gcap = azx_readw(chip, GCAP); 2584 snd_printdd(SFX "chipset global capabilities = 0x%x\n", gcap); 2585 2586 /* disable SB600 64bit support for safety */ 2587 if ((chip->driver_type == AZX_DRIVER_ATI) || 2588 (chip->driver_type == AZX_DRIVER_ATIHDMI)) { 2589 struct pci_dev *p_smbus; 2590 p_smbus = pci_get_device(PCI_VENDOR_ID_ATI, 2591 PCI_DEVICE_ID_ATI_SBX00_SMBUS, 2592 NULL); 2593 if (p_smbus) { 2594 if (snd_pci_revision(p_smbus) < 0x30) 2595 gcap &= ~ICH6_GCAP_64OK; 2596 pci_dev_put(p_smbus); 2597 } 2598 } 2599 2600 /* disable 64bit DMA address for Teradici */ 2601 /* it does not work with device 6549:1200 subsys e4a2:040b */ 2602 if (chip->driver_type == AZX_DRIVER_TERA) 2603 gcap &= ~ICH6_GCAP_64OK; 2602 2604 2603 2605 #pragma disable_message (135,302) 2604 2605 2606 2607 2608 2609 2610 2606 /* allow 64bit DMA address if supported by H/W */ 2607 if ((gcap & ICH6_GCAP_64OK) && !pci_set_dma_mask(pci, DMA_BIT_MASK(64))) 2608 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(64)); 2609 else { 2610 pci_set_dma_mask(pci, DMA_BIT_MASK(32)); 2611 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(32)); 2612 } 2611 2613 #pragma enable_message (135,302) 2612 2614 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2615 /* read number of streams from GCAP register instead of using 2616 * hardcoded value 2617 */ 2618 chip->capture_streams = (gcap >> 8) & 0x0f; 2619 chip->playback_streams = (gcap >> 12) & 0x0f; 2620 if (!chip->playback_streams && !chip->capture_streams) { 2621 /* gcap didn't give any info, switching to old method */ 2622 2623 switch (chip->driver_type) { 2624 case AZX_DRIVER_ULI: 2625 chip->playback_streams = ULI_NUM_PLAYBACK; 2626 chip->capture_streams = ULI_NUM_CAPTURE; 2627 break; 2628 case AZX_DRIVER_ATIHDMI: 2629 chip->playback_streams = ATIHDMI_NUM_PLAYBACK; 2630 chip->capture_streams = ATIHDMI_NUM_CAPTURE; 2631 break; 2632 case AZX_DRIVER_GENERIC: 2633 default: 2634 chip->playback_streams = ICH6_NUM_PLAYBACK; 2635 chip->capture_streams = ICH6_NUM_CAPTURE; 2636 break; 2637 } 2638 } 2639 chip->capture_index_offset = 0; 2640 chip->playback_index_offset = chip->capture_streams; 2641 chip->num_streams = chip->playback_streams + chip->capture_streams; 2642 chip->azx_dev = kcalloc(chip->num_streams, sizeof(*chip->azx_dev), 2643 GFP_KERNEL); 2644 if (!chip->azx_dev) { 2645 snd_printk(KERN_ERR SFX "cannot malloc azx_dev\n"); 2646 goto errout; 2647 } 2648 2649 for (i = 0; i < chip->num_streams; i++) { 2650 /* allocate memory for the BDL for each stream */ 2651 err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, 2652 snd_dma_pci_data(chip->pci), 2653 BDL_SIZE, &chip->azx_dev[i].bdl); 2654 if (err < 0) { 2655 snd_printk(KERN_ERR SFX "cannot allocate BDL\n"); 2656 goto errout; 2657 } 2658 } 2659 /* allocate memory for the position buffer */ 2660 err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, 2661 snd_dma_pci_data(chip->pci), 2662 chip->num_streams * 8, &chip->posbuf); 2663 if (err < 0) { 2664 snd_printk(KERN_ERR SFX "cannot allocate posbuf\n"); 2665 goto errout; 2666 } 2667 /* allocate CORB/RIRB */ 2668 err = azx_alloc_cmd_io(chip); 2669 if (err < 0) 2670 goto errout; 2671 2672 /* initialize streams */ 2673 azx_init_stream(chip); 2674 2675 /* initialize chip */ 2676 azx_init_pci(chip); 2677 azx_init_chip(chip, (probe_only[dev] & 2) == 0); 2678 2679 /* codec detection */ 2680 if (!chip->codec_mask) { 2681 snd_printk(KERN_ERR SFX "no codecs found!\n"); 2682 err = -ENODEV; 2683 goto errout; 2684 } 2685 2686 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); 2687 if (err <0) { 2688 snd_printk(KERN_ERR SFX "Error creating device [card]!\n"); 2689 goto errout; 2690 } 2691 2692 strcpy(card->driver, "HDA-Intel"); 2693 strlcpy(card->shortname, driver_short_names[chip->driver_type], 2694 sizeof(card->shortname)); 2695 snprintf(card->longname, sizeof(card->longname), 2696 "%s at 0x%lx irq %i", 2697 card->shortname, chip->addr, chip->irq); 2698 2699 *rchip = chip; 2700 return 0; 2699 2701 2700 2702 errout: 2701 2702 2703 azx_free(chip); 2704 return err; 2703 2705 } 2704 2706 … … 2706 2708 { 2707 2709 #ifdef CONFIG_SND_HDA_POWER_SAVE 2708 2709 2710 2711 2712 2713 2714 2710 /* The codecs were powered up in snd_hda_codec_new(). 2711 * Now all initialization done, so turn them down if possible 2712 */ 2713 struct hda_codec *codec; 2714 list_for_each_entry(codec, &chip->bus->codec_list, list, struct hda_codec) { 2715 snd_hda_power_down(codec); 2716 } 2715 2717 #endif 2716 2718 } 2717 2719 2718 2720 static int __devinit azx_probe(struct pci_dev *pci, 2719 2720 { 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2721 const struct pci_device_id *pci_id) 2722 { 2723 static int dev; 2724 struct snd_card *card; 2725 struct azx *chip; 2726 int err; 2727 2728 if (dev >= SNDRV_CARDS) 2729 return -ENODEV; 2730 if (!enable[dev]) { 2731 dev++; 2732 return -ENOENT; 2733 } 2734 2735 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); 2736 if (err < 0) { 2737 snd_printk(KERN_ERR SFX "Error creating card!\n"); 2738 return err; 2739 } 2740 2741 /* set this here since it's referred in snd_hda_load_patch() */ 2742 snd_card_set_dev(card, &pci->dev); 2743 2744 err = azx_create(card, pci, dev, pci_id->driver_data, &chip); 2745 if (err < 0) 2746 goto out_free; 2747 card->private_data = chip; 2746 2748 2747 2749 #ifdef CONFIG_SND_HDA_INPUT_BEEP 2748 2750 chip->beep_mode = beep_mode[dev]; 2749 2751 #endif 2750 2752 2751 2752 2753 2754 2753 /* create codec instances */ 2754 err = azx_codec_create(chip, model[dev]); 2755 if (err < 0) 2756 goto out_free; 2755 2757 #ifdef CONFIG_SND_HDA_PATCH_LOADER 2756 2757 2758 2759 2760 2761 2762 2758 if (patch[dev]) { 2759 snd_printk(KERN_ERR SFX "Applying patch firmware '%s'\n", 2760 patch[dev]); 2761 err = snd_hda_load_patch(chip->bus, patch[dev]); 2762 if (err < 0) 2763 goto out_free; 2764 } 2763 2765 #endif 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2766 if ((probe_only[dev] & 1) == 0) { 2767 err = azx_codec_configure(chip); 2768 if (err < 0) 2769 goto out_free; 2770 } 2771 2772 /* create PCM streams */ 2773 err = snd_hda_build_pcms(chip->bus); 2774 if (err < 0) 2775 goto out_free; 2776 2777 /* create mixer controls */ 2778 err = azx_mixer_create(chip); 2779 if (err < 0) 2780 goto out_free; 2781 2782 err = snd_card_register(card); 2783 if (err < 0) 2784 goto out_free; 2785 2786 pci_set_drvdata(pci, card); 2787 chip->running = 1; 2788 power_down_all_codecs(chip); 2789 azx_notifier_register(chip); 2790 2791 dev++; 2792 return err; 2791 2793 out_free: 2792 2793 2794 snd_card_free(card); 2795 return err; 2794 2796 } 2795 2797 2796 2798 static void __devexit azx_remove(struct pci_dev *pci) 2797 2799 { 2798 2799 2800 snd_card_free(pci_get_drvdata(pci)); 2801 pci_set_drvdata(pci, NULL); 2800 2802 } 2801 2803 2802 2804 /* PCI IDs */ 2803 2805 static DEFINE_PCI_DEVICE_TABLE(azx_ids) = { 2804 /* CPT */ 2805 { PCI_DEVICE(0x8086, 0x1c20), .driver_data = AZX_DRIVER_PCH }, 2806 /* PBG */ 2807 { PCI_DEVICE(0x8086, 0x1d20), .driver_data = AZX_DRIVER_PCH }, 2808 /* SCH */ 2809 { PCI_DEVICE(0x8086, 0x811b), .driver_data = AZX_DRIVER_SCH }, 2810 /* Generic Intel */ 2811 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_ANY_ID), 2812 .class = PCI_CLASS_MULTIMEDIA_HD_AUDIO << 8, 2813 .class_mask = 0xffffff, 2814 .driver_data = AZX_DRIVER_ICH }, 2815 /* ATI SB 450/600 */ 2816 { PCI_DEVICE(0x1002, 0x437b), .driver_data = AZX_DRIVER_ATI }, 2817 { PCI_DEVICE(0x1002, 0x4383), .driver_data = AZX_DRIVER_ATI }, 2818 /* ATI HDMI */ 2819 { PCI_DEVICE(0x1002, 0x793b), .driver_data = AZX_DRIVER_ATIHDMI }, 2820 { PCI_DEVICE(0x1002, 0x7919), .driver_data = AZX_DRIVER_ATIHDMI }, 2821 { PCI_DEVICE(0x1002, 0x960f), .driver_data = AZX_DRIVER_ATIHDMI }, 2822 { PCI_DEVICE(0x1002, 0x970f), .driver_data = AZX_DRIVER_ATIHDMI }, 2823 { PCI_DEVICE(0x1002, 0xaa00), .driver_data = AZX_DRIVER_ATIHDMI }, 2824 { PCI_DEVICE(0x1002, 0xaa08), .driver_data = AZX_DRIVER_ATIHDMI }, 2825 { PCI_DEVICE(0x1002, 0xaa10), .driver_data = AZX_DRIVER_ATIHDMI }, 2826 { PCI_DEVICE(0x1002, 0xaa18), .driver_data = AZX_DRIVER_ATIHDMI }, 2827 { PCI_DEVICE(0x1002, 0xaa20), .driver_data = AZX_DRIVER_ATIHDMI }, 2828 { PCI_DEVICE(0x1002, 0xaa28), .driver_data = AZX_DRIVER_ATIHDMI }, 2829 { PCI_DEVICE(0x1002, 0xaa30), .driver_data = AZX_DRIVER_ATIHDMI }, 2830 { PCI_DEVICE(0x1002, 0xaa38), .driver_data = AZX_DRIVER_ATIHDMI }, 2831 { PCI_DEVICE(0x1002, 0xaa40), .driver_data = AZX_DRIVER_ATIHDMI }, 2832 { PCI_DEVICE(0x1002, 0xaa48), .driver_data = AZX_DRIVER_ATIHDMI }, 2833 /* VIA VT8251/VT8237A */ 2834 { PCI_DEVICE(0x1106, 0x3288), .driver_data = AZX_DRIVER_VIA }, 2835 /* SIS966 */ 2836 { PCI_DEVICE(0x1039, 0x7502), .driver_data = AZX_DRIVER_SIS }, 2837 /* ULI M5461 */ 2838 { PCI_DEVICE(0x10b9, 0x5461), .driver_data = AZX_DRIVER_ULI }, 2839 /* NVIDIA MCP */ 2840 { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID), 2841 .class = PCI_CLASS_MULTIMEDIA_HD_AUDIO << 8, 2842 .class_mask = 0xffffff, 2843 .driver_data = AZX_DRIVER_NVIDIA }, 2844 /* Teradici */ 2845 { PCI_DEVICE(0x6549, 0x1200), .driver_data = AZX_DRIVER_TERA }, 2846 /* Creative X-Fi (CA0110-IBG) */ 2806 /* CPT */ 2807 { PCI_DEVICE(0x8086, 0x1c20), .driver_data = AZX_DRIVER_PCH }, 2808 /* PBG */ 2809 { PCI_DEVICE(0x8086, 0x1d20), .driver_data = AZX_DRIVER_PCH }, 2810 { PCI_DEVICE(0x8086, 0x1e20), .driver_data = AZX_DRIVER_PCH }, 2811 { PCI_DEVICE(0x8086, 0x8c20), .driver_data = AZX_DRIVER_PCH }, 2812 { PCI_DEVICE(0x8086, 0x8d20), .driver_data = AZX_DRIVER_PCH }, 2813 { PCI_DEVICE(0x8086, 0x8d21), .driver_data = AZX_DRIVER_PCH }, 2814 { PCI_DEVICE(0x8086, 0x9c20), .driver_data = AZX_DRIVER_PCH }, 2815 { PCI_DEVICE(0x8086, 0x9c21), .driver_data = AZX_DRIVER_PCH }, 2816 { PCI_DEVICE(0x8086, 0x9ca0), .driver_data = AZX_DRIVER_PCH }, 2817 /* SCH */ 2818 { PCI_DEVICE(0x8086, 0x811b), .driver_data = AZX_DRIVER_SCH }, 2819 /* Generic Intel */ 2820 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_ANY_ID), 2821 .class = PCI_CLASS_MULTIMEDIA_HD_AUDIO << 8, 2822 .class_mask = 0xffffff, 2823 .driver_data = AZX_DRIVER_ICH }, 2824 /* ATI SB 450/600 */ 2825 { PCI_DEVICE(0x1002, 0x437b), .driver_data = AZX_DRIVER_ATI }, 2826 { PCI_DEVICE(0x1002, 0x4383), .driver_data = AZX_DRIVER_ATI }, 2827 /* ATI HDMI */ 2828 { PCI_DEVICE(0x1002, 0x793b), .driver_data = AZX_DRIVER_ATIHDMI }, 2829 { PCI_DEVICE(0x1002, 0x7919), .driver_data = AZX_DRIVER_ATIHDMI }, 2830 { PCI_DEVICE(0x1002, 0x960f), .driver_data = AZX_DRIVER_ATIHDMI }, 2831 { PCI_DEVICE(0x1002, 0x970f), .driver_data = AZX_DRIVER_ATIHDMI }, 2832 { PCI_DEVICE(0x1002, 0xaa00), .driver_data = AZX_DRIVER_ATIHDMI }, 2833 { PCI_DEVICE(0x1002, 0xaa08), .driver_data = AZX_DRIVER_ATIHDMI }, 2834 { PCI_DEVICE(0x1002, 0xaa10), .driver_data = AZX_DRIVER_ATIHDMI }, 2835 { PCI_DEVICE(0x1002, 0xaa18), .driver_data = AZX_DRIVER_ATIHDMI }, 2836 { PCI_DEVICE(0x1002, 0xaa20), .driver_data = AZX_DRIVER_ATIHDMI }, 2837 { PCI_DEVICE(0x1002, 0xaa28), .driver_data = AZX_DRIVER_ATIHDMI }, 2838 { PCI_DEVICE(0x1002, 0xaa30), .driver_data = AZX_DRIVER_ATIHDMI }, 2839 { PCI_DEVICE(0x1002, 0xaa38), .driver_data = AZX_DRIVER_ATIHDMI }, 2840 { PCI_DEVICE(0x1002, 0xaa40), .driver_data = AZX_DRIVER_ATIHDMI }, 2841 { PCI_DEVICE(0x1002, 0xaa48), .driver_data = AZX_DRIVER_ATIHDMI }, 2842 /* VIA VT8251/VT8237A */ 2843 { PCI_DEVICE(0x1106, 0x3288), .driver_data = AZX_DRIVER_VIA }, 2844 /* SIS966 */ 2845 { PCI_DEVICE(0x1039, 0x7502), .driver_data = AZX_DRIVER_SIS }, 2846 /* ULI M5461 */ 2847 { PCI_DEVICE(0x10b9, 0x5461), .driver_data = AZX_DRIVER_ULI }, 2848 /* NVIDIA MCP */ 2849 { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID), 2850 .class = PCI_CLASS_MULTIMEDIA_HD_AUDIO << 8, 2851 .class_mask = 0xffffff, 2852 .driver_data = AZX_DRIVER_NVIDIA }, 2853 /* Teradici */ 2854 { PCI_DEVICE(0x6549, 0x1200), .driver_data = AZX_DRIVER_TERA }, 2855 /* Creative X-Fi (CA0110-IBG) */ 2847 2856 #if !defined(CONFIG_SND_CTXFI) && !defined(CONFIG_SND_CTXFI_MODULE) 2848 2849 2850 2851 2852 2853 2854 2855 2857 /* the following entry conflicts with snd-ctxfi driver, 2858 * as ctxfi driver mutates from HD-audio to native mode with 2859 * a special command sequence. 2860 */ 2861 { PCI_DEVICE(PCI_VENDOR_ID_CREATIVE, PCI_ANY_ID), 2862 .class = PCI_CLASS_MULTIMEDIA_HD_AUDIO << 8, 2863 .class_mask = 0xffffff, 2864 .driver_data = AZX_DRIVER_CTX }, 2856 2865 #else 2857 2858 2866 /* this entry seems still valid -- i.e. without emu20kx chip */ 2867 { PCI_DEVICE(0x1102, 0x0009), .driver_data = AZX_DRIVER_CTX }, 2859 2868 #endif 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2869 /* Vortex86MX */ 2870 { PCI_DEVICE(0x17f3, 0x3010), .driver_data = AZX_DRIVER_GENERIC }, 2871 /* VMware HDAudio */ 2872 { PCI_DEVICE(0x15ad, 0x1977), .driver_data = AZX_DRIVER_GENERIC }, 2873 /* AMD/ATI Generic, PCI class code and Vendor ID for HD Audio */ 2874 { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_ANY_ID), 2875 .class = PCI_CLASS_MULTIMEDIA_HD_AUDIO << 8, 2876 .class_mask = 0xffffff, 2877 .driver_data = AZX_DRIVER_GENERIC }, 2878 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_ANY_ID), 2879 .class = PCI_CLASS_MULTIMEDIA_HD_AUDIO << 8, 2880 .class_mask = 0xffffff, 2881 .driver_data = AZX_DRIVER_GENERIC }, 2882 { 0, } 2874 2883 }; 2875 2884 MODULE_DEVICE_TABLE(pci, azx_ids); … … 2877 2886 /* pci_driver definition */ 2878 2887 static struct pci_driver driver = { 2879 2880 2881 2882 2888 .name = "HDA Intel", 2889 .id_table = azx_ids, 2890 .probe = azx_probe, 2891 .remove = __devexit_p(azx_remove), 2883 2892 #ifdef CONFIG_PM 2884 2885 2893 .suspend = azx_suspend, 2894 .resume = azx_resume, 2886 2895 #endif 2887 2896 }; … … 2889 2898 static int __init alsa_card_azx_init(void) 2890 2899 { 2891 2900 return pci_register_driver(&driver); 2892 2901 } 2893 2902 2894 2903 static void __exit alsa_card_azx_exit(void) 2895 2904 { 2896 2905 pci_unregister_driver(&driver); 2897 2906 } 2898 2907 -
GPL/trunk/drv32/Makefile
r596 r604 48 48 !endif 49 49 50 51 50 #=================================================================== 52 51 # … … 67 66 FILES += end.obj 68 67 69 LIBS = $(ALSA_LIB)\linuxlib.lib $(ALSA_LIB)\core.lib $(ALSA_LIB)\ac97.lib $(ALSA_LIB)\pci.lib $(ALSA_LIB)\ca0106.lib $(ALSA_LIB)\hda.lib $(ALSA_LIB)\sequencer.lib $(ALSA_LIB)\opl3.lib $(ALSA_LIB)\mpu401.lib $(ALSA_LIB)\synth.lib $(ALSA_LIB)\cs46xx.lib $(ALSA_LIB)\cs5535audio.lib $(ALSA_LIB)\emu10k1.lib $(ALSA_LIB)\ymfpci.lib $(ALSA_LIB)\ali5451.lib $(ALSA_LIB)\trident.lib $(ALSA_LIB)\nm256.lib $(ALSA_LIB)\sb.lib $(ALSA_LIB)\core_oss.lib 68 LIBS = $(ALSA_LIB)\linuxlib.lib $(ALSA_LIB)\core.lib $(ALSA_LIB)\ac97.lib $(ALSA_LIB)\pci.lib & 69 $(ALSA_LIB)\ca0106.lib $(ALSA_LIB)\hda.lib $(ALSA_LIB)\sequencer.lib $(ALSA_LIB)\opl3.lib & 70 $(ALSA_LIB)\mpu401.lib $(ALSA_LIB)\synth.lib $(ALSA_LIB)\cs46xx.lib $(ALSA_LIB)\cs5535audio.lib & 71 $(ALSA_LIB)\emu10k1.lib $(ALSA_LIB)\ymfpci.lib $(ALSA_LIB)\ali5451.lib $(ALSA_LIB)\trident.lib & 72 $(ALSA_LIB)\nm256.lib $(ALSA_LIB)\sb.lib $(ALSA_LIB)\core_oss.lib 70 73 WMAPNAME = $(OBJDIR)\$(TARGET).wmap 71 74 … … 100 103 @%write $^@ $(WATCOM)\lib386\os2\clib3r.lib 101 104 @%write $^@ $(WATCOM)\lib386\os2\os2386.lib 105 !ifdef %DRV32KIT 106 @%write $^@ $(%DRV32KIT)\drv32.lib 107 !endif 102 108 @%write $^@ $(DEFFILE) 103 109 !endif -
GPL/trunk/drv32/irq.c
r587 r604 51 51 BOOL ALSA_SetIrq(ULONG ulIrq, ULONG ulSlotNo, BOOL fShared) 52 52 { 53 53 USHORT rc = 1; 54 54 55 if( ulSlotNo >= MAX_IRQ_SLOTS ) { 56 DebugInt3(); 57 return FALSE; 58 } 55 if( ulSlotNo >= MAX_IRQ_SLOTS ) 56 { 57 DebugInt3(); 58 return FALSE; 59 } 59 60 60 if(fShared) 61 { 62 rc = DevIRQSet((WORD16) *pISR[ulSlotNo], 63 (WORD16)ulIrq, 64 1 ); // first try shared shared 65 } 61 if(fShared) 62 { 63 rc = DevIRQSet((WORD16) *pISR[ulSlotNo], (WORD16)ulIrq, 1 ); // first try shared shared 64 } 66 65 67 if (rc != 0) { // If error ... 68 rprintf(("ERROR: RMSetIrq %d %d %x - failed to set shared - trying exclusive!!", ulIrq, fShared, ulSlotNo)); 69 rc = DevIRQSet((WORD16) *pISR[ulSlotNo], 70 (WORD16)ulIrq, 71 0); // failed, so try exclusive instead 72 } 66 if (rc != 0) 67 { // If error ... 68 rprintf(("ERROR: RMSetIrq %d %d %x - failed to set shared - trying exclusive!!", ulIrq, fShared, ulSlotNo)); 69 rc = DevIRQSet((WORD16) *pISR[ulSlotNo], (WORD16)ulIrq, 0); // failed, so try exclusive instead 70 } 73 71 74 if (rc != 0) { // If error ... 75 rprintf(("ERROR: RMSetIrq %d %d %x FAILED shared and exclusive mode!!", ulIrq, fShared, ulSlotNo)); 76 DebugInt3(); 77 return FALSE; 78 } 72 if (rc != 0) 73 { // If error ... 74 rprintf(("ERROR: RMSetIrq %d %d %x FAILED shared and exclusive mode!!", ulIrq, fShared, ulSlotNo)); 75 DebugInt3(); 76 return FALSE; 77 } 79 78 80 79 return TRUE; 81 80 } 82 81 … … 84 83 BOOL ALSA_FreeIrq(ULONG ulIrq) 85 84 { 86 85 return (DevIRQClear((WORD16)ulIrq) == 0); 87 86 } 88 87 … … 91 90 ULONG ALSA_Interrupt(ULONG ulSlotNo) 92 91 { 93 ULONGulIrqNo;92 ULONG ulIrqNo; 94 93 95 // enable interrupts that have higher priority we should 96 // allow higher priority interrupts 97 sti(); 98 if( process_interrupt(ulSlotNo, &ulIrqNo) ) { 99 DbgInt.ulIntServiced[DbgInt.ulState]++; 100 // We've cleared all service requests. 101 // Clear (disable) Interrupts, Send EOI 102 // and clear the carry flag (tells OS/2 kernel that Int was handled). 103 // Note carry flag is handled in setup.asm 104 cli(); 105 DevEOI( (WORD16)ulIrqNo ); 106 return TRUE; 107 } 108 DbgInt.ulIntUnserviced[DbgInt.ulState]++; 109 // Indicate Interrupt not serviced by setting carry flag before 110 // returning to OS/2 kernel. OS/2 will then shut down the interrupt! 111 // NOTE: Make sure interrupts are not turned on again when this irq isn't ours! 112 return FALSE; 94 // enable interrupts that have higher priority we should 95 // allow higher priority interrupts 96 sti(); 97 if( process_interrupt(ulSlotNo, &ulIrqNo) ) 98 { 99 DbgInt.ulIntServiced[DbgInt.ulState]++; 100 // We've cleared all service requests. 101 // Clear (disable) Interrupts, Send EOI 102 // and clear the carry flag (tells OS/2 kernel that Int was handled). 103 // Note carry flag is handled in setup.asm 104 cli(); 105 DevEOI( (WORD16)ulIrqNo ); 106 return TRUE; 107 } 108 DbgInt.ulIntUnserviced[DbgInt.ulState]++; 109 // Indicate Interrupt not serviced by setting carry flag before 110 // returning to OS/2 kernel. OS/2 will then shut down the interrupt! 111 // NOTE: Make sure interrupts are not turned on again when this irq isn't ours! 112 return FALSE; 113 113 } 114 114 -
GPL/trunk/include/linux/pci.h
r598 r604 1 1 /* 2 * 3 * 4 * 2 * PCI defines and function prototypes 3 * Copyright 1994, Drew Eckhardt 4 * Copyright 1997--1999 Martin Mares <mj@atrey.karlin.mff.cuni.cz> 5 5 * 6 * 7 * 6 * For more information, please consult the following manuals (look at 7 * http://www.pcisig.com/ for how to get them): 8 8 * 9 * 10 * 11 * 12 * 9 * PCI BIOS Specification 10 * PCI Local Bus Specification 11 * PCI to PCI Bridge Specification 12 * PCI System Design Guide 13 13 */ 14 14 … … 23 23 * of which the first 64 bytes are standardized as follows: 24 24 */ 25 #define PCI_VENDOR_ID 0x00/* 16 bits */26 #define PCI_DEVICE_ID 0x02/* 16 bits */27 #define PCI_COMMAND 0x04/* 16 bits */28 #define PCI_COMMAND_IO 0x1/* Enable response in I/O space */29 #define PCI_COMMAND_MEMORY 0x2/* Enable response in Memory space */30 #define PCI_COMMAND_MASTER 0x4/* Enable bus mastering */31 #define PCI_COMMAND_SPECIAL 0x8/* Enable response to special cycles */32 #define PCI_COMMAND_INVALIDATE 0x10/* Use memory write and invalidate */33 #define PCI_COMMAND_VGA_PALETTE 0x20 34 #define PCI_COMMAND_PARITY 0x40/* Enable parity checking */35 #define PCI_COMMAND_WAIT 0x80/* Enable address/data stepping */36 #define PCI_COMMAND_SERR 0x100/* Enable SERR */37 #define PCI_COMMAND_FAST_BACK 0x200/* Enable back-to-back writes */38 39 #define PCI_STATUS 0x06/* 16 bits */40 #define PCI_STATUS_CAP_LIST 0x10/* Support Capability List */41 #define PCI_STATUS_66MHZ 0x20/* Support 66 Mhz PCI 2.1 bus */42 #define PCI_STATUS_UDF 0x40/* Support User Definable Features [obsolete] */43 #define PCI_STATUS_FAST_BACK 0x80/* Accept fast-back to back */44 #define PCI_STATUS_PARITY 0x100/* Detected parity error */45 #define PCI_STATUS_DEVSEL_MASK 0x600/* DEVSEL timing */46 #define PCI_STATUS_DEVSEL_FAST 0x00025 #define PCI_VENDOR_ID 0x00 /* 16 bits */ 26 #define PCI_DEVICE_ID 0x02 /* 16 bits */ 27 #define PCI_COMMAND 0x04 /* 16 bits */ 28 #define PCI_COMMAND_IO 0x1 /* Enable response in I/O space */ 29 #define PCI_COMMAND_MEMORY 0x2 /* Enable response in Memory space */ 30 #define PCI_COMMAND_MASTER 0x4 /* Enable bus mastering */ 31 #define PCI_COMMAND_SPECIAL 0x8 /* Enable response to special cycles */ 32 #define PCI_COMMAND_INVALIDATE 0x10 /* Use memory write and invalidate */ 33 #define PCI_COMMAND_VGA_PALETTE 0x20 /* Enable palette snooping */ 34 #define PCI_COMMAND_PARITY 0x40 /* Enable parity checking */ 35 #define PCI_COMMAND_WAIT 0x80 /* Enable address/data stepping */ 36 #define PCI_COMMAND_SERR 0x100 /* Enable SERR */ 37 #define PCI_COMMAND_FAST_BACK 0x200 /* Enable back-to-back writes */ 38 39 #define PCI_STATUS 0x06 /* 16 bits */ 40 #define PCI_STATUS_CAP_LIST 0x10 /* Support Capability List */ 41 #define PCI_STATUS_66MHZ 0x20 /* Support 66 Mhz PCI 2.1 bus */ 42 #define PCI_STATUS_UDF 0x40 /* Support User Definable Features [obsolete] */ 43 #define PCI_STATUS_FAST_BACK 0x80 /* Accept fast-back to back */ 44 #define PCI_STATUS_PARITY 0x100 /* Detected parity error */ 45 #define PCI_STATUS_DEVSEL_MASK 0x600 /* DEVSEL timing */ 46 #define PCI_STATUS_DEVSEL_FAST 0x000 47 47 #define PCI_STATUS_DEVSEL_MEDIUM 0x200 48 48 #define PCI_STATUS_DEVSEL_SLOW 0x400 … … 53 53 #define PCI_STATUS_DETECTED_PARITY 0x8000 /* Set on parity error */ 54 54 55 #define PCI_CLASS_REVISION 0x08/* High 24 bits are class, low 856 55 #define PCI_CLASS_REVISION 0x08 /* High 24 bits are class, low 8 56 revision */ 57 57 #define PCI_REVISION_ID 0x08 /* Revision ID */ 58 58 #define PCI_CLASS_PROG 0x09 /* Reg. Level Programming Interface */ 59 59 #define PCI_CLASS_DEVICE 0x0a /* Device class */ 60 60 61 #define PCI_CACHE_LINE_SIZE 0x0c/* 8 bits */62 #define PCI_LATENCY_TIMER 0x0d/* 8 bits */63 #define PCI_HEADER_TYPE 0x0e/* 8 bits */64 #define PCI_HEADER_TYPE_NORMAL 61 #define PCI_CACHE_LINE_SIZE 0x0c /* 8 bits */ 62 #define PCI_LATENCY_TIMER 0x0d /* 8 bits */ 63 #define PCI_HEADER_TYPE 0x0e /* 8 bits */ 64 #define PCI_HEADER_TYPE_NORMAL 0 65 65 #define PCI_HEADER_TYPE_BRIDGE 1 66 66 #define PCI_HEADER_TYPE_CARDBUS 2 67 67 68 #define PCI_BIST 0x0f/* 8 bits */69 #define PCI_BIST_CODE_MASK 0x0f/* Return result */70 #define PCI_BIST_START 0x40/* 1 to start BIST, 2 secs or less */71 #define PCI_BIST_CAPABLE 0x80/* 1 if BIST capable */68 #define PCI_BIST 0x0f /* 8 bits */ 69 #define PCI_BIST_CODE_MASK 0x0f /* Return result */ 70 #define PCI_BIST_START 0x40 /* 1 to start BIST, 2 secs or less */ 71 #define PCI_BIST_CAPABLE 0x80 /* 1 if BIST capable */ 72 72 73 73 /* … … 77 77 * 1 bits are decoded. 78 78 */ 79 #define PCI_BASE_ADDRESS_0 0x10/* 32 bits */80 #define PCI_BASE_ADDRESS_1 0x14/* 32 bits [htype 0,1 only] */81 #define PCI_BASE_ADDRESS_2 0x18/* 32 bits [htype 0 only] */82 #define PCI_BASE_ADDRESS_3 0x1c/* 32 bits */83 #define PCI_BASE_ADDRESS_4 0x20/* 32 bits */84 #define PCI_BASE_ADDRESS_5 0x24/* 32 bits */85 #define PCI_BASE_ADDRESS_SPACE 0x01/* 0 = memory, 1 = I/O */79 #define PCI_BASE_ADDRESS_0 0x10 /* 32 bits */ 80 #define PCI_BASE_ADDRESS_1 0x14 /* 32 bits [htype 0,1 only] */ 81 #define PCI_BASE_ADDRESS_2 0x18 /* 32 bits [htype 0 only] */ 82 #define PCI_BASE_ADDRESS_3 0x1c /* 32 bits */ 83 #define PCI_BASE_ADDRESS_4 0x20 /* 32 bits */ 84 #define PCI_BASE_ADDRESS_5 0x24 /* 32 bits */ 85 #define PCI_BASE_ADDRESS_SPACE 0x01 /* 0 = memory, 1 = I/O */ 86 86 #define PCI_BASE_ADDRESS_SPACE_IO 0x01 87 87 #define PCI_BASE_ADDRESS_SPACE_MEMORY 0x00 88 88 #define PCI_BASE_ADDRESS_MEM_TYPE_MASK 0x06 89 #define PCI_BASE_ADDRESS_MEM_TYPE_32 0x00/* 32 bit address */90 #define PCI_BASE_ADDRESS_MEM_TYPE_1M 0x02/* Below 1M [obsolete] */91 #define PCI_BASE_ADDRESS_MEM_TYPE_64 0x04/* 64 bit address */92 #define PCI_BASE_ADDRESS_MEM_PREFETCH 0x08/* prefetchable? */93 #define PCI_BASE_ADDRESS_MEM_MASK 94 #define PCI_BASE_ADDRESS_IO_MASK 89 #define PCI_BASE_ADDRESS_MEM_TYPE_32 0x00 /* 32 bit address */ 90 #define PCI_BASE_ADDRESS_MEM_TYPE_1M 0x02 /* Below 1M [obsolete] */ 91 #define PCI_BASE_ADDRESS_MEM_TYPE_64 0x04 /* 64 bit address */ 92 #define PCI_BASE_ADDRESS_MEM_PREFETCH 0x08 /* prefetchable? */ 93 #define PCI_BASE_ADDRESS_MEM_MASK (~0x0fUL) 94 #define PCI_BASE_ADDRESS_IO_MASK (~0x03UL) 95 95 /* bit 1 is reserved if address_space = 1 */ 96 96 97 97 /* Header type 0 (normal devices) */ 98 #define PCI_CARDBUS_CIS 99 #define PCI_SUBSYSTEM_VENDOR_ID 100 #define PCI_SUBSYSTEM_ID 101 #define PCI_ROM_ADDRESS 0x30/* Bits 31..11 are address, 10..1 reserved */102 #define PCI_ROM_ADDRESS_ENABLE 103 #define PCI_ROM_ADDRESS_MASK 104 105 #define PCI_CAPABILITY_LIST 0x34/* Offset of first capability list entry */98 #define PCI_CARDBUS_CIS 0x28 99 #define PCI_SUBSYSTEM_VENDOR_ID 0x2c 100 #define PCI_SUBSYSTEM_ID 0x2e 101 #define PCI_ROM_ADDRESS 0x30 /* Bits 31..11 are address, 10..1 reserved */ 102 #define PCI_ROM_ADDRESS_ENABLE 0x01 103 #define PCI_ROM_ADDRESS_MASK (~0x7ffUL) 104 105 #define PCI_CAPABILITY_LIST 0x34 /* Offset of first capability list entry */ 106 106 107 107 /* 0x35-0x3b are reserved */ 108 #define PCI_INTERRUPT_LINE 0x3c/* 8 bits */109 #define PCI_INTERRUPT_PIN 0x3d/* 8 bits */110 #define PCI_MIN_GNT 0x3e/* 8 bits */111 #define PCI_MAX_LAT 0x3f/* 8 bits */108 #define PCI_INTERRUPT_LINE 0x3c /* 8 bits */ 109 #define PCI_INTERRUPT_PIN 0x3d /* 8 bits */ 110 #define PCI_MIN_GNT 0x3e /* 8 bits */ 111 #define PCI_MAX_LAT 0x3f /* 8 bits */ 112 112 113 113 /* Header type 1 (PCI-to-PCI bridges) */ 114 #define PCI_PRIMARY_BUS 0x18/* Primary bus number */115 #define PCI_SECONDARY_BUS 0x19/* Secondary bus number */116 #define PCI_SUBORDINATE_BUS 0x1a/* Highest bus number behind the bridge */117 #define PCI_SEC_LATENCY_TIMER 0x1b/* Latency timer for secondary interface */118 #define PCI_IO_BASE 0x1c/* I/O range behind the bridge */119 #define PCI_IO_LIMIT 120 #define PCI_IO_RANGE_TYPE_MASK 0x0f/* I/O bridging type */121 #define PCI_IO_RANGE_TYPE_16 122 #define PCI_IO_RANGE_TYPE_32 123 #define PCI_IO_RANGE_MASK 124 #define PCI_SEC_STATUS 0x1e/* Secondary status register, only bit 14 used */125 #define PCI_MEMORY_BASE 0x20/* Memory range behind */126 #define PCI_MEMORY_LIMIT 114 #define PCI_PRIMARY_BUS 0x18 /* Primary bus number */ 115 #define PCI_SECONDARY_BUS 0x19 /* Secondary bus number */ 116 #define PCI_SUBORDINATE_BUS 0x1a /* Highest bus number behind the bridge */ 117 #define PCI_SEC_LATENCY_TIMER 0x1b /* Latency timer for secondary interface */ 118 #define PCI_IO_BASE 0x1c /* I/O range behind the bridge */ 119 #define PCI_IO_LIMIT 0x1d 120 #define PCI_IO_RANGE_TYPE_MASK 0x0f /* I/O bridging type */ 121 #define PCI_IO_RANGE_TYPE_16 0x00 122 #define PCI_IO_RANGE_TYPE_32 0x01 123 #define PCI_IO_RANGE_MASK ~0x0f 124 #define PCI_SEC_STATUS 0x1e /* Secondary status register, only bit 14 used */ 125 #define PCI_MEMORY_BASE 0x20 /* Memory range behind */ 126 #define PCI_MEMORY_LIMIT 0x22 127 127 #define PCI_MEMORY_RANGE_TYPE_MASK 0x0f 128 #define PCI_MEMORY_RANGE_MASK 129 #define PCI_PREF_MEMORY_BASE 0x24/* Prefetchable memory range behind */130 #define PCI_PREF_MEMORY_LIMIT 128 #define PCI_MEMORY_RANGE_MASK ~0x0f 129 #define PCI_PREF_MEMORY_BASE 0x24 /* Prefetchable memory range behind */ 130 #define PCI_PREF_MEMORY_LIMIT 0x26 131 131 #define PCI_PREF_RANGE_TYPE_MASK 0x0f 132 #define PCI_PREF_RANGE_TYPE_32 133 #define PCI_PREF_RANGE_TYPE_64 134 #define PCI_PREF_RANGE_MASK 135 #define PCI_PREF_BASE_UPPER32 0x28/* Upper half of prefetchable memory range */136 #define PCI_PREF_LIMIT_UPPER32 137 #define PCI_IO_BASE_UPPER16 0x30/* Upper half of I/O addresses */138 #define PCI_IO_LIMIT_UPPER16 132 #define PCI_PREF_RANGE_TYPE_32 0x00 133 #define PCI_PREF_RANGE_TYPE_64 0x01 134 #define PCI_PREF_RANGE_MASK ~0x0f 135 #define PCI_PREF_BASE_UPPER32 0x28 /* Upper half of prefetchable memory range */ 136 #define PCI_PREF_LIMIT_UPPER32 0x2c 137 #define PCI_IO_BASE_UPPER16 0x30 /* Upper half of I/O addresses */ 138 #define PCI_IO_LIMIT_UPPER16 0x32 139 139 /* 0x34 same as for htype 0 */ 140 140 /* 0x35-0x3b is reserved */ 141 #define PCI_ROM_ADDRESS1 0x38/* Same as PCI_ROM_ADDRESS, but for htype 1 */141 #define PCI_ROM_ADDRESS1 0x38 /* Same as PCI_ROM_ADDRESS, but for htype 1 */ 142 142 /* 0x3c-0x3d are same as for htype 0 */ 143 #define PCI_BRIDGE_CONTROL 144 #define PCI_BRIDGE_CTL_PARITY 0x01/* Enable parity detection on secondary interface */145 #define PCI_BRIDGE_CTL_SERR 0x02/* The same for SERR forwarding */146 #define PCI_BRIDGE_CTL_NO_ISA 0x04/* Disable bridging of ISA ports */147 #define PCI_BRIDGE_CTL_VGA 0x08/* Forward VGA addresses */143 #define PCI_BRIDGE_CONTROL 0x3e 144 #define PCI_BRIDGE_CTL_PARITY 0x01 /* Enable parity detection on secondary interface */ 145 #define PCI_BRIDGE_CTL_SERR 0x02 /* The same for SERR forwarding */ 146 #define PCI_BRIDGE_CTL_NO_ISA 0x04 /* Disable bridging of ISA ports */ 147 #define PCI_BRIDGE_CTL_VGA 0x08 /* Forward VGA addresses */ 148 148 #define PCI_BRIDGE_CTL_MASTER_ABORT 0x20 /* Report master aborts */ 149 #define PCI_BRIDGE_CTL_BUS_RESET 0x40 150 #define PCI_BRIDGE_CTL_FAST_BACK 0x80 149 #define PCI_BRIDGE_CTL_BUS_RESET 0x40 /* Secondary bus reset */ 150 #define PCI_BRIDGE_CTL_FAST_BACK 0x80 /* Fast Back2Back enabled on secondary interface */ 151 151 152 152 /* Header type 2 (CardBus bridges) */ 153 153 /* 0x14-0x15 reserved */ 154 154 #define PCI_CB_CAPABILITY_LIST 0x14 155 #define PCI_CB_SEC_STATUS 0x16/* Secondary status */156 #define PCI_CB_PRIMARY_BUS 0x18/* PCI bus number */157 #define PCI_CB_CARD_BUS 0x19/* CardBus bus number */158 #define PCI_CB_SUBORDINATE_BUS 0x1a/* Subordinate bus number */159 #define PCI_CB_LATENCY_TIMER 0x1b/* CardBus latency timer */160 #define PCI_CB_MEMORY_BASE_0 161 #define PCI_CB_MEMORY_LIMIT_0 162 #define PCI_CB_MEMORY_BASE_1 163 #define PCI_CB_MEMORY_LIMIT_1 164 #define PCI_CB_IO_BASE_0 165 #define PCI_CB_IO_BASE_0_HI 166 #define PCI_CB_IO_LIMIT_0 167 #define PCI_CB_IO_LIMIT_0_HI 168 #define PCI_CB_IO_BASE_1 169 #define PCI_CB_IO_BASE_1_HI 170 #define PCI_CB_IO_LIMIT_1 171 #define PCI_CB_IO_LIMIT_1_HI 172 #define PCI_CB_IO_RANGE_MASK 155 #define PCI_CB_SEC_STATUS 0x16 /* Secondary status */ 156 #define PCI_CB_PRIMARY_BUS 0x18 /* PCI bus number */ 157 #define PCI_CB_CARD_BUS 0x19 /* CardBus bus number */ 158 #define PCI_CB_SUBORDINATE_BUS 0x1a /* Subordinate bus number */ 159 #define PCI_CB_LATENCY_TIMER 0x1b /* CardBus latency timer */ 160 #define PCI_CB_MEMORY_BASE_0 0x1c 161 #define PCI_CB_MEMORY_LIMIT_0 0x20 162 #define PCI_CB_MEMORY_BASE_1 0x24 163 #define PCI_CB_MEMORY_LIMIT_1 0x28 164 #define PCI_CB_IO_BASE_0 0x2c 165 #define PCI_CB_IO_BASE_0_HI 0x2e 166 #define PCI_CB_IO_LIMIT_0 0x30 167 #define PCI_CB_IO_LIMIT_0_HI 0x32 168 #define PCI_CB_IO_BASE_1 0x34 169 #define PCI_CB_IO_BASE_1_HI 0x36 170 #define PCI_CB_IO_LIMIT_1 0x38 171 #define PCI_CB_IO_LIMIT_1_HI 0x3a 172 #define PCI_CB_IO_RANGE_MASK ~0x03 173 173 /* 0x3c-0x3d are same as for htype 0 */ 174 #define PCI_CB_BRIDGE_CONTROL 175 #define PCI_CB_BRIDGE_CTL_PARITY 0x01/* Similar to standard bridge control register */176 #define PCI_CB_BRIDGE_CTL_SERR 177 #define PCI_CB_BRIDGE_CTL_ISA 178 #define PCI_CB_BRIDGE_CTL_VGA 179 #define PCI_CB_BRIDGE_CTL_MASTER_ABORT 180 #define PCI_CB_BRIDGE_CTL_CB_RESET 0x40/* CardBus reset */181 #define PCI_CB_BRIDGE_CTL_16BIT_INT 0x80/* Enable interrupt for 16-bit cards */182 #define PCI_CB_BRIDGE_CTL_PREFETCH_MEM0 0x100 174 #define PCI_CB_BRIDGE_CONTROL 0x3e 175 #define PCI_CB_BRIDGE_CTL_PARITY 0x01 /* Similar to standard bridge control register */ 176 #define PCI_CB_BRIDGE_CTL_SERR 0x02 177 #define PCI_CB_BRIDGE_CTL_ISA 0x04 178 #define PCI_CB_BRIDGE_CTL_VGA 0x08 179 #define PCI_CB_BRIDGE_CTL_MASTER_ABORT 0x20 180 #define PCI_CB_BRIDGE_CTL_CB_RESET 0x40 /* CardBus reset */ 181 #define PCI_CB_BRIDGE_CTL_16BIT_INT 0x80 /* Enable interrupt for 16-bit cards */ 182 #define PCI_CB_BRIDGE_CTL_PREFETCH_MEM0 0x100 /* Prefetch enable for both memory regions */ 183 183 #define PCI_CB_BRIDGE_CTL_PREFETCH_MEM1 0x200 184 #define PCI_CB_BRIDGE_CTL_POST_WRITES 184 #define PCI_CB_BRIDGE_CTL_POST_WRITES 0x400 185 185 #define PCI_CB_SUBSYSTEM_VENDOR_ID 0x40 186 #define PCI_CB_SUBSYSTEM_ID 187 #define PCI_CB_LEGACY_MODE_BASE 0x44/* 16-bit PC Card legacy mode base address (ExCa) */186 #define PCI_CB_SUBSYSTEM_ID 0x42 187 #define PCI_CB_LEGACY_MODE_BASE 0x44 /* 16-bit PC Card legacy mode base address (ExCa) */ 188 188 /* 0x48-0x7f reserved */ 189 189 190 190 /* Capability lists */ 191 191 192 #define PCI_CAP_LIST_ID 0/* Capability ID */193 #define PCI_CAP_ID_PM 0x01/* Power Management */194 #define PCI_CAP_ID_AGP 0x02/* Accelerated Graphics Port */195 #define PCI_CAP_ID_VPD 0x03/* Vital Product Data */196 #define PCI_CAP_ID_SLOTID 0x04/* Slot Identification */197 #define PCI_CAP_ID_MSI 0x05/* Message Signalled Interrupts */198 #define PCI_CAP_ID_CHSWP 0x06/* CompactPCI HotSwap */199 #define PCI_CAP_LIST_NEXT 1/* Next capability in the list */200 #define PCI_CAP_FLAGS 2/* Capability defined flags (16 bits) */201 #define PCI_CAP_SIZEOF 192 #define PCI_CAP_LIST_ID 0 /* Capability ID */ 193 #define PCI_CAP_ID_PM 0x01 /* Power Management */ 194 #define PCI_CAP_ID_AGP 0x02 /* Accelerated Graphics Port */ 195 #define PCI_CAP_ID_VPD 0x03 /* Vital Product Data */ 196 #define PCI_CAP_ID_SLOTID 0x04 /* Slot Identification */ 197 #define PCI_CAP_ID_MSI 0x05 /* Message Signalled Interrupts */ 198 #define PCI_CAP_ID_CHSWP 0x06 /* CompactPCI HotSwap */ 199 #define PCI_CAP_LIST_NEXT 1 /* Next capability in the list */ 200 #define PCI_CAP_FLAGS 2 /* Capability defined flags (16 bits) */ 201 #define PCI_CAP_SIZEOF 4 202 202 203 203 /* Power Management Registers */ 204 204 #define PCI_PM_PMC 2 /* PM Capabilities Register */ 205 #define PCI_PM_CAP_VER_MASK 0x0007/* Version */206 #define PCI_PM_CAP_PME_CLOCK 0x0008/* PME clock required */207 #define PCI_PM_CAP_AUX_POWER 0x0010/* Auxilliary power support */208 #define PCI_PM_CAP_DSI 0x0020/* Device specific initialization */209 #define PCI_PM_CAP_D1 0x0200/* D1 power state support */210 #define PCI_PM_CAP_D2 0x0400/* D2 power state support */211 #define PCI_PM_CAP_PME 0x0800/* PME pin supported */212 #define PCI_PM_CTRL 4/* PM control and status register */213 #define PCI_PM_CTRL_STATE_MASK 0x0003/* Current power state (D0 to D3) */214 #define PCI_PM_CTRL_PME_ENABLE 0x0100/* PME pin enable */215 #define PCI_PM_CTRL_DATA_SEL_MASK 0x1e00/* Data select (??) */216 #define PCI_PM_CTRL_DATA_SCALE_MASK 0x6000/* Data scale (??) */217 #define PCI_PM_CTRL_PME_STATUS 0x8000/* PME pin status */218 #define PCI_PM_PPB_EXTENSIONS 6/* PPB support extensions (??) */219 #define PCI_PM_PPB_B2_B3 0x40/* Stop clock when in D3hot (??) */220 #define PCI_PM_BPCC_ENABLE 0x80/* Bus power/clock control enable (??) */221 #define PCI_PM_DATA_REGISTER 7/* (??) */222 #define PCI_PM_SIZEOF 205 #define PCI_PM_CAP_VER_MASK 0x0007 /* Version */ 206 #define PCI_PM_CAP_PME_CLOCK 0x0008 /* PME clock required */ 207 #define PCI_PM_CAP_AUX_POWER 0x0010 /* Auxilliary power support */ 208 #define PCI_PM_CAP_DSI 0x0020 /* Device specific initialization */ 209 #define PCI_PM_CAP_D1 0x0200 /* D1 power state support */ 210 #define PCI_PM_CAP_D2 0x0400 /* D2 power state support */ 211 #define PCI_PM_CAP_PME 0x0800 /* PME pin supported */ 212 #define PCI_PM_CTRL 4 /* PM control and status register */ 213 #define PCI_PM_CTRL_STATE_MASK 0x0003 /* Current power state (D0 to D3) */ 214 #define PCI_PM_CTRL_PME_ENABLE 0x0100 /* PME pin enable */ 215 #define PCI_PM_CTRL_DATA_SEL_MASK 0x1e00 /* Data select (??) */ 216 #define PCI_PM_CTRL_DATA_SCALE_MASK 0x6000 /* Data scale (??) */ 217 #define PCI_PM_CTRL_PME_STATUS 0x8000 /* PME pin status */ 218 #define PCI_PM_PPB_EXTENSIONS 6 /* PPB support extensions (??) */ 219 #define PCI_PM_PPB_B2_B3 0x40 /* Stop clock when in D3hot (??) */ 220 #define PCI_PM_BPCC_ENABLE 0x80 /* Bus power/clock control enable (??) */ 221 #define PCI_PM_DATA_REGISTER 7 /* (??) */ 222 #define PCI_PM_SIZEOF 8 223 223 224 224 /* AGP registers */ 225 225 226 #define PCI_AGP_VERSION 2/* BCD version number */227 #define PCI_AGP_RFU 3/* Rest of capability flags */228 #define PCI_AGP_STATUS 4/* Status register */229 #define PCI_AGP_STATUS_RQ_MASK 0xff000000/* Maximum number of requests - 1 */230 #define PCI_AGP_STATUS_SBA 0x0200/* Sideband addressing supported */231 #define PCI_AGP_STATUS_64BIT 0x0020/* 64-bit addressing supported */232 #define PCI_AGP_STATUS_FW 0x0010/* FW transfers supported */233 #define PCI_AGP_STATUS_RATE4 0x0004/* 4x transfer rate supported */234 #define PCI_AGP_STATUS_RATE2 0x0002/* 2x transfer rate supported */235 #define PCI_AGP_STATUS_RATE1 0x0001/* 1x transfer rate supported */236 #define PCI_AGP_COMMAND 8/* Control register */226 #define PCI_AGP_VERSION 2 /* BCD version number */ 227 #define PCI_AGP_RFU 3 /* Rest of capability flags */ 228 #define PCI_AGP_STATUS 4 /* Status register */ 229 #define PCI_AGP_STATUS_RQ_MASK 0xff000000 /* Maximum number of requests - 1 */ 230 #define PCI_AGP_STATUS_SBA 0x0200 /* Sideband addressing supported */ 231 #define PCI_AGP_STATUS_64BIT 0x0020 /* 64-bit addressing supported */ 232 #define PCI_AGP_STATUS_FW 0x0010 /* FW transfers supported */ 233 #define PCI_AGP_STATUS_RATE4 0x0004 /* 4x transfer rate supported */ 234 #define PCI_AGP_STATUS_RATE2 0x0002 /* 2x transfer rate supported */ 235 #define PCI_AGP_STATUS_RATE1 0x0001 /* 1x transfer rate supported */ 236 #define PCI_AGP_COMMAND 8 /* Control register */ 237 237 #define PCI_AGP_COMMAND_RQ_MASK 0xff000000 /* Master: Maximum number of requests */ 238 #define PCI_AGP_COMMAND_SBA 0x0200/* Sideband addressing enabled */239 #define PCI_AGP_COMMAND_AGP 0x0100/* Allow processing of AGP transactions */240 #define PCI_AGP_COMMAND_64BIT 0x0020/* Allow processing of 64-bit addresses */241 #define PCI_AGP_COMMAND_FW 0x0010/* Force FW transfers */242 #define PCI_AGP_COMMAND_RATE4 0x0004/* Use 4x rate */243 #define PCI_AGP_COMMAND_RATE2 0x0002/* Use 4x rate */244 #define PCI_AGP_COMMAND_RATE1 0x0001/* Use 4x rate */245 #define PCI_AGP_SIZEOF 238 #define PCI_AGP_COMMAND_SBA 0x0200 /* Sideband addressing enabled */ 239 #define PCI_AGP_COMMAND_AGP 0x0100 /* Allow processing of AGP transactions */ 240 #define PCI_AGP_COMMAND_64BIT 0x0020 /* Allow processing of 64-bit addresses */ 241 #define PCI_AGP_COMMAND_FW 0x0010 /* Force FW transfers */ 242 #define PCI_AGP_COMMAND_RATE4 0x0004 /* Use 4x rate */ 243 #define PCI_AGP_COMMAND_RATE2 0x0002 /* Use 4x rate */ 244 #define PCI_AGP_COMMAND_RATE1 0x0001 /* Use 4x rate */ 245 #define PCI_AGP_SIZEOF 12 246 246 247 247 /* Slot Identification */ 248 248 249 #define PCI_SID_ESR 2/* Expansion Slot Register */250 #define PCI_SID_ESR_NSLOTS 0x1f/* Number of expansion slots available */251 #define PCI_SID_ESR_FIC 0x20/* First In Chassis Flag */252 #define PCI_SID_CHASSIS_NR 3/* Chassis Number */249 #define PCI_SID_ESR 2 /* Expansion Slot Register */ 250 #define PCI_SID_ESR_NSLOTS 0x1f /* Number of expansion slots available */ 251 #define PCI_SID_ESR_FIC 0x20 /* First In Chassis Flag */ 252 #define PCI_SID_CHASSIS_NR 3 /* Chassis Number */ 253 253 254 254 /* Message Signalled Interrupts registers */ 255 255 256 #define PCI_MSI_FLAGS 2/* Various flags */257 #define PCI_MSI_FLAGS_64BIT 0x80/* 64-bit addresses allowed */258 #define PCI_MSI_FLAGS_QSIZE 0x70/* Message queue size configured */259 #define PCI_MSI_FLAGS_QMASK 0x0e/* Maximum queue size available */260 #define PCI_MSI_FLAGS_ENABLE 0x01/* MSI feature enabled */261 #define PCI_MSI_RFU 3/* Rest of capability flags */262 #define PCI_MSI_ADDRESS_LO 4/* Lower 32 bits */263 #define PCI_MSI_ADDRESS_HI 8/* Upper 32 bits (if PCI_MSI_FLAGS_64BIT set) */264 #define PCI_MSI_DATA_32 8/* 16 bits of data for 32-bit devices */265 #define PCI_MSI_DATA_64 12/* 16 bits of data for 64-bit devices */256 #define PCI_MSI_FLAGS 2 /* Various flags */ 257 #define PCI_MSI_FLAGS_64BIT 0x80 /* 64-bit addresses allowed */ 258 #define PCI_MSI_FLAGS_QSIZE 0x70 /* Message queue size configured */ 259 #define PCI_MSI_FLAGS_QMASK 0x0e /* Maximum queue size available */ 260 #define PCI_MSI_FLAGS_ENABLE 0x01 /* MSI feature enabled */ 261 #define PCI_MSI_RFU 3 /* Rest of capability flags */ 262 #define PCI_MSI_ADDRESS_LO 4 /* Lower 32 bits */ 263 #define PCI_MSI_ADDRESS_HI 8 /* Upper 32 bits (if PCI_MSI_FLAGS_64BIT set) */ 264 #define PCI_MSI_DATA_32 8 /* 16 bits of data for 32-bit devices */ 265 #define PCI_MSI_DATA_64 12 /* 16 bits of data for 64-bit devices */ 266 266 267 267 /* Include the ID list */ … … 274 274 * in a single byte as follows: 275 275 * 276 * 277 * 278 */ 279 #define PCI_DEVFN(slot,func) 280 #define PCI_SLOT(devfn) 281 #define PCI_FUNC(devfn) 276 * 7:3 = slot 277 * 2:0 = function 278 */ 279 #define PCI_DEVFN(slot,func) ((((slot) & 0x1f) << 3) | ((func) & 0x07)) 280 #define PCI_SLOT(devfn) (((devfn) >> 3) & 0x1f) 281 #define PCI_FUNC(devfn) ((devfn) & 0x07) 282 282 283 283 #ifdef __KERNEL__ … … 287 287 288 288 #include <asm/pci.h> 289 #define BUS_ID_SIZE 290 #define DEVICE_COUNT_COMPATIBLE 291 #define DEVICE_COUNT_IRQ 292 #define DEVICE_COUNT_DMA 293 #define DEVICE_COUNT_RESOURCE 289 #define BUS_ID_SIZE 20 290 #define DEVICE_COUNT_COMPATIBLE 4 291 #define DEVICE_COUNT_IRQ 2 292 #define DEVICE_COUNT_DMA 2 293 #define DEVICE_COUNT_RESOURCE 12 294 294 295 295 typedef struct pci_dev; … … 303 303 304 304 typedef struct device { 305 struct pci_dev *pci; 306 struct device* parent;307 struct bus_type * bus;/* type of bus device is on */308 char bus_id[BUS_ID_SIZE];/* position on parent bus */309 void(*release)(struct device * dev);310 unsigned int flags; 305 struct pci_dev *pci; /* for PCI and PCI-SG types */ 306 struct device * parent; 307 struct bus_type * bus; /* type of bus device is on */ 308 char bus_id[BUS_ID_SIZE]; /* position on parent bus */ 309 void (*release)(struct device * dev); 310 unsigned int flags; /* GFP_XXX for continous and ISA types */ 311 311 #ifdef CONFIG_SBUS 312 struct sbus_dev *sbus; 312 struct sbus_dev *sbus; /* for SBUS type */ 313 313 #endif 314 315 316 317 318 319 charbus_id[20];314 void *private_data; 315 void *platform_data; 316 317 struct device_driver *driver; 318 struct pm_dev *pm_dev; 319 char bus_id[20]; 320 320 } device; 321 321 … … 324 324 */ 325 325 struct pci_dev { 326 int active;/* device is active */327 int ro;/* Read/Only */328 329 struct pci_bus *bus;/* bus this device is on */330 struct pci_dev *sibling;/* next device on this bus */331 struct pci_dev *next;/* chain of all devices */332 333 void *sysdata;/* hook for sys-specific extension */334 struct proc_dir_entry *procent;/* device entry in /proc/bus/pci */326 int active; /* device is active */ 327 int ro; /* Read/Only */ 328 329 struct pci_bus *bus; /* bus this device is on */ 330 struct pci_dev *sibling; /* next device on this bus */ 331 struct pci_dev *next; /* chain of all devices */ 332 333 void *sysdata; /* hook for sys-specific extension */ 334 struct proc_dir_entry *procent; /* device entry in /proc/bus/pci */ 335 335 336 336 struct device dev; 337 337 338 unsigned int devfn; /* encoded device & function index */ 339 unsigned short vendor; 340 unsigned short device; 341 unsigned short subsystem_vendor; 342 unsigned short subsystem_device; 343 unsigned int _class; /* 3 bytes: (base,sub,prog-if) */ 344 u8 hdr_type; /* PCI header type (`multi' flag masked out) */ 345 u8 rom_base_reg; /* Which config register controls the ROM */ 346 347 unsigned short regs; 348 349 u32 current_state; /* Current operating state. In ACPI-speak, 350 this is D0-D3, D0 being fully functional, 351 and D3 being off. */ 352 353 /* device is compatible with these IDs */ 354 unsigned short vendor_compatible[DEVICE_COUNT_COMPATIBLE]; 355 unsigned short device_compatible[DEVICE_COUNT_COMPATIBLE]; 356 357 /* 358 * Instead of touching interrupt line and base address registers 359 * directly, use the values stored here. They might be different! 360 */ 361 unsigned int irq; 362 struct resource resource[DEVICE_COUNT_RESOURCE]; /* I/O and memory regions + expansion ROMs */ 363 struct resource dma_resource[DEVICE_COUNT_DMA]; 364 struct resource irq_resource[DEVICE_COUNT_IRQ]; 365 366 char name[48]; /* Device name */ 367 char slot_name[8]; /* Slot name */ 368 369 void *driver_data; 370 unsigned long dma_mask; 371 372 int (*prepare)(struct pci_dev *dev); 373 int (*activate)(struct pci_dev *dev); 374 int (*deactivate)(struct pci_dev *dev); 338 unsigned int devfn; /* encoded device & function index */ 339 unsigned short vendor; 340 unsigned short device; 341 unsigned short subsystem_vendor; 342 unsigned short subsystem_device; 343 unsigned int _class; /* 3 bytes: (base,sub,prog-if) */ 344 u8 hdr_type; /* PCI header type (`multi' flag masked out) */ 345 u8 rom_base_reg; /* Which config register controls the ROM */ 346 347 unsigned short regs; 348 349 u32 current_state; /* Current operating state. In ACPI-speak, 350 this is D0-D3, D0 being fully functional, 351 and D3 being off. */ 352 353 /* device is compatible with these IDs */ 354 unsigned short vendor_compatible[DEVICE_COUNT_COMPATIBLE]; 355 unsigned short device_compatible[DEVICE_COUNT_COMPATIBLE]; 356 357 /* 358 * Instead of touching interrupt line and base address registers 359 * directly, use the values stored here. They might be different! 360 */ 361 unsigned int irq; 362 unsigned char irq_pin; 363 struct resource resource[DEVICE_COUNT_RESOURCE]; /* I/O and memory regions + expansion ROMs */ 364 struct resource dma_resource[DEVICE_COUNT_DMA]; 365 struct resource irq_resource[DEVICE_COUNT_IRQ]; 366 367 char name[48]; /* Device name */ 368 char slot_name[8]; /* Slot name */ 369 370 void *driver_data; 371 unsigned long dma_mask; 372 373 int (*prepare)(struct pci_dev *dev); 374 int (*activate)(struct pci_dev *dev); 375 int (*deactivate)(struct pci_dev *dev); 375 376 #ifdef TARGET_OS2 376 377 378 379 380 377 //DAZ unsigned int picirq; 378 //DAZ unsigned int apicirq; 379 unsigned long hAdapter; 380 unsigned long hDevice; 381 void *pcidriver; 381 382 #endif 382 383 }; … … 385 386 * For PCI devices, the region numbers are assigned this way: 386 387 * 387 * 0-5standard PCI regions388 * 6expansion ROM389 * 7-10bridges: address space assigned to buses behind the bridge388 * 0-5 standard PCI regions 389 * 6 expansion ROM 390 * 7-10 bridges: address space assigned to buses behind the bridge 390 391 */ 391 392 … … 394 395 #define PCI_NUM_RESOURCES 11 395 396 396 #define PCI_REGION_FLAG_MASK 0x0f 397 #define PCI_REGION_FLAG_MASK 0x0f /* These bits of resource flags tell us the PCI region flags */ 397 398 398 399 struct pci_bus { 399 struct pci_bus *parent;/* parent bus this bridge is on */400 struct pci_bus *children;/* chain of P2P bridges on this bus */401 struct pci_bus *next;/* chain of all PCI buses */402 struct pci_ops *ops;/* configuration access functions */403 404 struct pci_dev *self;/* bridge device as seen by parent */405 struct pci_dev *devices;/* devices behind this bridge */406 struct resource *resource[4];/* address space routed to this bus */407 408 void *sysdata;/* hook for sys-specific extension */409 struct proc_dir_entry *procdir;/* directory entry in /proc/bus/pci */410 411 unsigned char number;/* bus number */412 unsigned char primary;/* number of primary bridge */413 unsigned char secondary;/* number of secondary bridge */414 unsigned char subordinate;/* max number of subordinate buses */415 416 charname[48];417 unsigned shortvendor;418 unsigned shortdevice;419 unsigned int serial;/* serial number */420 unsigned char pnpver;/* Plug & Play version */421 unsigned char productver;/* product version */422 unsigned char checksum;/* if zero - checksum passed */423 unsigned charpad1;400 struct pci_bus *parent; /* parent bus this bridge is on */ 401 struct pci_bus *children; /* chain of P2P bridges on this bus */ 402 struct pci_bus *next; /* chain of all PCI buses */ 403 struct pci_ops *ops; /* configuration access functions */ 404 405 struct pci_dev *self; /* bridge device as seen by parent */ 406 struct pci_dev *devices; /* devices behind this bridge */ 407 struct resource *resource[4]; /* address space routed to this bus */ 408 409 void *sysdata; /* hook for sys-specific extension */ 410 struct proc_dir_entry *procdir; /* directory entry in /proc/bus/pci */ 411 412 unsigned char number; /* bus number */ 413 unsigned char primary; /* number of primary bridge */ 414 unsigned char secondary; /* number of secondary bridge */ 415 unsigned char subordinate; /* max number of subordinate buses */ 416 417 char name[48]; 418 unsigned short vendor; 419 unsigned short device; 420 unsigned int serial; /* serial number */ 421 unsigned char pnpver; /* Plug & Play version */ 422 unsigned char productver; /* product version */ 423 unsigned char checksum; /* if zero - checksum passed */ 424 unsigned char pad1; 424 425 }; 425 426 426 //extern struct pci_bus *pci_root;/* root bus */427 //extern struct pci_dev *pci_devices;/* list of all devices */427 //extern struct pci_bus *pci_root; /* root bus */ 428 //extern struct pci_dev *pci_devices; /* list of all devices */ 428 429 429 430 /* 430 431 * Error values that may be returned by PCI functions. 431 432 */ 432 #define PCIBIOS_SUCCESSFUL 433 #define PCIBIOS_FUNC_NOT_SUPPORTED 434 #define PCIBIOS_BAD_VENDOR_ID 435 #define PCIBIOS_DEVICE_NOT_FOUND 436 #define PCIBIOS_BAD_REGISTER_NUMBER 437 #define PCIBIOS_SET_FAILED 438 #define PCIBIOS_BUFFER_TOO_SMALL 433 #define PCIBIOS_SUCCESSFUL 0x00 434 #define PCIBIOS_FUNC_NOT_SUPPORTED 0x81 435 #define PCIBIOS_BAD_VENDOR_ID 0x83 436 #define PCIBIOS_DEVICE_NOT_FOUND 0x86 437 #define PCIBIOS_BAD_REGISTER_NUMBER 0x87 438 #define PCIBIOS_SET_FAILED 0x88 439 #define PCIBIOS_BUFFER_TOO_SMALL 0x89 439 440 440 441 /* Low-level architecture-dependent routines */ 441 442 442 443 struct pci_ops { 443 444 445 446 447 448 444 int (*read_byte)(struct pci_dev *, int where, u8 *val); 445 int (*read_word)(struct pci_dev *, int where, u16 *val); 446 int (*read_dword)(struct pci_dev *, int where, u32 *val); 447 int (*write_byte)(struct pci_dev *, int where, u8 val); 448 int (*write_word)(struct pci_dev *, int where, u16 val); 449 int (*write_dword)(struct pci_dev *, int where, u32 val); 449 450 }; 450 451 … … 455 456 456 457 void pcibios_update_resource(struct pci_dev *, struct resource *, 457 458 struct resource *, int); 458 459 void pcibios_update_irq(struct pci_dev *, int irq); 459 460 … … 463 464 #define pci_present pcibios_present 464 465 int pcibios_read_config_byte (unsigned char bus, unsigned char dev_fn, 465 466 unsigned char where, unsigned char *val); 466 467 int pcibios_read_config_word (unsigned char bus, unsigned char dev_fn, 467 468 unsigned char where, unsigned short *val); 468 469 int pcibios_read_config_dword (unsigned char bus, unsigned char dev_fn, 469 470 unsigned char where, unsigned int *val); 470 471 int pcibios_write_config_byte (unsigned char bus, unsigned char dev_fn, 471 472 unsigned char where, unsigned char val); 472 473 int pcibios_write_config_word (unsigned char bus, unsigned char dev_fn, 473 474 unsigned char where, unsigned short val); 474 475 int pcibios_write_config_dword (unsigned char bus, unsigned char dev_fn, 475 476 unsigned char where, unsigned int val); 476 477 int pcibios_find_class (unsigned int class_code, unsigned short index, unsigned char *bus, unsigned char *dev_fn); 477 478 int pcibios_find_device (unsigned short vendor, unsigned short dev_id, 478 479 479 unsigned short index, unsigned char *bus, 480 unsigned char *dev_fn); 480 481 481 482 /* Generic PCI interface functions */ … … 491 492 struct pci_dev *pci_find_device (unsigned int vendor, unsigned int device, struct pci_dev *from); 492 493 struct pci_dev *pci_find_subsys (unsigned int vendor, unsigned int device, 493 494 494 unsigned int ss_vendor, unsigned int ss_device, 495 struct pci_dev *from); 495 496 struct pci_dev *pci_find_class (unsigned int _class, struct pci_dev *from); 496 497 struct pci_dev *pci_find_slot (unsigned int bus, unsigned int devfn); … … 516 517 void pci_set_bus_ranges(void); 517 518 void pci_fixup_irqs(u8 (*)(struct pci_dev *, u8 *), 518 519 int (*)(struct pci_dev *, u8, u8)); 519 520 520 521 /* … … 524 525 struct pci_simple_probe_entry; 525 526 typedef int (*pci_simple_probe_callback) (struct pci_dev *dev, int match_num, 526 527 527 const struct pci_simple_probe_entry *ent, 528 void *drvr_data); 528 529 529 530 struct pci_simple_probe_entry { 530 unsigned short vendor;/* vendor id, PCI_ANY_ID, or 0 for last entry */531 unsigned short device;/* device id, PCI_ANY_ID, or 0 for last entry */532 533 534 void *dev_data;/* driver-private, entry-specific data */531 unsigned short vendor; /* vendor id, PCI_ANY_ID, or 0 for last entry */ 532 unsigned short device; /* device id, PCI_ANY_ID, or 0 for last entry */ 533 unsigned short subsys_vendor; /* subsystem vendor id, 0 for don't care */ 534 unsigned short subsys_device; /* subsystem device id, 0 for don't care */ 535 void *dev_data; /* driver-private, entry-specific data */ 535 536 }; 536 537 537 538 int pci_simple_probe (const struct pci_simple_probe_entry *list, 538 539 539 size_t match_limit, pci_simple_probe_callback cb, 540 void *drvr_data); 540 541 541 542 … … 554 555 555 556 struct pci_fixup { 556 557 u16 vendor, device;/* You can use PCI_ANY_ID here of course */558 557 int pass; 558 u16 vendor, device; /* You can use PCI_ANY_ID here of course */ 559 void (*hook)(struct pci_dev *dev); 559 560 }; 560 561 561 562 extern struct pci_fixup pcibios_fixups[]; 562 563 563 #define PCI_FIXUP_HEADER 1/* Called immediately after reading configuration header */564 #define PCI_FIXUP_FINAL 2/* Final phase of device fixups */564 #define PCI_FIXUP_HEADER 1 /* Called immediately after reading configuration header */ 565 #define PCI_FIXUP_FINAL 2 /* Final phase of device fixups */ 565 566 566 567 void pci_fixup_device(int pass, struct pci_dev *dev); 567 568 568 569 extern int pci_pci_problems; 569 #define PCIPCI_FAIL 570 #define PCIPCI_TRITON 571 #define PCIPCI_NATOMA 570 #define PCIPCI_FAIL 1 571 #define PCIPCI_TRITON 2 572 #define PCIPCI_NATOMA 4 572 573 573 574 … … 590 591 #else 591 592 struct pci_driver { 592 593 594 595 const struct pci_device_id *id_table;/* NULL if wants all devices */596 597 void (*remove)(struct pci_dev *dev);/* Device removed (NULL if not a hot-plug capable driver) */598 int (*suspend)(struct pci_dev *dev, u32 stgate);/* Device suspended */599 int (*resume)(struct pci_dev *dev);/* Device woken up */593 struct list_head node; 594 struct pci_dev *dev; 595 char *name; 596 const struct pci_device_id *id_table; /* NULL if wants all devices */ 597 int (*probe)(struct pci_dev *dev, const struct pci_device_id *id); /* New device inserted */ 598 void (*remove)(struct pci_dev *dev); /* Device removed (NULL if not a hot-plug capable driver) */ 599 int (*suspend)(struct pci_dev *dev, u32 stgate); /* Device suspended */ 600 int (*resume)(struct pci_dev *dev); /* Device woken up */ 600 601 }; 601 602 #endif … … 619 620 620 621 #define pci_for_each_dev(dev) \ 621 622 for(dev = pci_devices; dev; dev = dev->next) 622 623 623 624 #define pci_resource_start(dev,bar) \ … … 692 693 static inline unsigned char snd_pci_revision(struct pci_dev *pci) 693 694 { 694 695 696 695 unsigned char rev; 696 pci_read_config_byte(pci, PCI_REVISION_ID, &rev); 697 return rev; 697 698 } 698 699 … … 701 702 702 703 /* MSI */ 703 static inline int snd_pci_enable_msi(struct pci_dev *dev) { return -1; } 704 extern int snd_pci_enable_msi(struct pci_dev *dev); 704 705 #undef pci_enable_msi 705 706 #define pci_enable_msi(dev) snd_pci_enable_msi(dev) … … 711 712 static inline void *pci_ioremap_bar(struct pci_dev *pdev, int bar) 712 713 { 713 714 714 return __ioremap(pci_resource_start(pdev, bar), 715 pci_resource_len(pdev, bar),0x010); 715 716 } 716 717 717 #define PCI_VDEVICE(vendor, device) 718 PCI_VENDOR_ID_##vendor, (device),\719 718 #define PCI_VDEVICE(vendor, device) \ 719 PCI_VENDOR_ID_##vendor, (device), \ 720 PCI_ANY_ID, PCI_ANY_ID, 0, 0 720 721 721 722 #define pci_clear_master(x) … … 725 726 */ 726 727 #define DEFINE_PCI_DEVICE_TABLE(_table) \ 727 728 const struct pci_device_id _table[] __devinitdata 728 729 729 730 #endif /* LINUX_PCI_H */ -
GPL/trunk/lib32/Makefile
r598 r604 10 10 !if "$(IBM_BUILD)" == "1" 11 11 CDEFINES += -DIBM_BUILD 12 !endif 13 14 !ifdef %DRV32KIT 15 CDEFINES+= -DUSE_MSI 12 16 !endif 13 17 -
GPL/trunk/lib32/irq.c
r577 r604 42 42 //****************************************************************************** 43 43 44 static IRQ_SLOT 45 static ULONG 44 static IRQ_SLOT arSlots[MAX_IRQ_SLOTS] = { 0 }; 45 static ULONG eoiIrq[255] = {0}; 46 46 47 47 … … 50 50 static IRQ_SLOT *FindSlot(unsigned irq) 51 51 { 52 IRQ_SLOT*pSlot;53 54 55 56 if( pSlot->irqNo == irq )return pSlot;57 58 59 52 IRQ_SLOT *pSlot; 53 54 for( pSlot = arSlots; pSlot != &arSlots[MAX_IRQ_SLOTS]; pSlot++ ) 55 { 56 if( pSlot->irqNo == irq ) return pSlot; 57 } 58 59 return NULL; 60 60 } 61 61 … … 65 65 66 66 int request_irq(unsigned irq, irq_handler_t handler, 67 unsigned long ulSharedFlag, const char *pchName, void *pUserData) 68 { 69 IRQ_SLOT *pSlot = FindSlot(irq & 0xff); 70 unsigned u, uSlotNo = (unsigned)-1; 71 ULONG hRes; 72 73 rprintf(("request_irq: irq %d", irq & 0xff )); 74 if ( !pSlot ) { 75 // find empty slot 76 for( uSlotNo = 0; uSlotNo < MAX_IRQ_SLOTS; uSlotNo++ ) { 77 if( arSlots[uSlotNo].flHandlers == 0 ) { 78 pSlot = &arSlots[uSlotNo]; 79 break; 80 } 81 } 82 } 83 84 if ( pSlot ) { 85 hRes = 0; 86 if (RMRequestIRQ(irq, (ulSharedFlag & SA_SHIRQ) != 0, &hRes) == FALSE) { 87 rprintf(("RMRequestIRQ failed for irq %d", irq)); 88 return 1; 89 } 90 pSlot->irqNo = irq & 0xff; 91 pSlot->hRes = hRes; 92 93 for ( u = 0; u < MAX_SHAREDIRQS; u++ ) { 94 if ( pSlot->irqHandlers[u].handler == NULL ) { 95 pSlot->irqHandlers[u].handler = handler; 96 pSlot->irqHandlers[u].x0 = ulSharedFlag; 97 pSlot->irqHandlers[u].x1 = (char *)pchName; 98 pSlot->irqHandlers[u].x2 = pUserData; 99 100 if( pSlot->flHandlers != 0 || ALSA_SetIrq( irq & 0xff, uSlotNo, (ulSharedFlag & SA_SHIRQ) != 0) ) { 101 pSlot->flHandlers |= 1 << u; 102 return 0; 103 } 104 105 break; 106 } 107 } 108 } 109 110 rprintf(("request_irq: Unable to register irq handler for irq %d", irq & 0xff )); 111 return 1; 67 unsigned long ulSharedFlag, const char *pchName, void *pUserData) 68 { 69 IRQ_SLOT *pSlot = FindSlot(irq & 0xff); 70 unsigned u, uSlotNo = (unsigned)-1; 71 ULONG hRes; 72 73 rprintf(("request_irq: irq %d", irq & 0xff )); 74 if ( !pSlot ) 75 { 76 // find empty slot 77 for( uSlotNo = 0; uSlotNo < MAX_IRQ_SLOTS; uSlotNo++ ) 78 { 79 if( arSlots[uSlotNo].flHandlers == 0 ) 80 { 81 pSlot = &arSlots[uSlotNo]; 82 break; 83 } 84 } 85 } 86 87 if ( pSlot ) 88 { 89 hRes = 0; 90 if (RMRequestIRQ(irq, (ulSharedFlag & SA_SHIRQ) != 0, &hRes) == FALSE) 91 { 92 rprintf(("RMRequestIRQ failed for irq %d", irq)); 93 return 1; 94 } 95 pSlot->irqNo = irq & 0xff; 96 pSlot->hRes = hRes; 97 98 for ( u = 0; u < MAX_SHAREDIRQS; u++ ) 99 { 100 if ( pSlot->irqHandlers[u].handler == NULL ) 101 { 102 pSlot->irqHandlers[u].handler = handler; 103 pSlot->irqHandlers[u].x0 = ulSharedFlag; 104 pSlot->irqHandlers[u].x1 = (char *)pchName; 105 pSlot->irqHandlers[u].x2 = pUserData; 106 107 if( pSlot->flHandlers != 0 || ALSA_SetIrq( irq & 0xff, uSlotNo, (ulSharedFlag & SA_SHIRQ) != 0) ) 108 { 109 pSlot->flHandlers |= 1 << u; 110 return 0; 111 } 112 113 break; 114 } 115 } 116 } 117 118 rprintf(("request_irq: Unable to register irq handler for irq %d", irq & 0xff )); 119 return 1; 112 120 } 113 121 … … 117 125 void free_irq(unsigned int irq, void *userdata) 118 126 { 119 unsignedu;120 IRQ_SLOT*pSlot;121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 127 unsigned u; 128 IRQ_SLOT *pSlot; 129 130 if( (pSlot = FindSlot(irq&0xff)) != NULL ) { 131 for( u = 0; u < MAX_SHAREDIRQS; u++ ) { 132 if( pSlot->irqHandlers[u].x2 == userdata ) { 133 pSlot->flHandlers &= ~(1 << u); 134 if( pSlot->flHandlers == 0 ) { 135 rprintf(("free_irq: irq %d", irq & 0xff )); 136 ALSA_FreeIrq(pSlot->irqNo); 137 pSlot->irqNo = 0; 138 RMDeallocateIRQ(pSlot->hRes); 139 pSlot->hRes = 0; 140 // pSlot->fEOI = 0; 141 } 142 143 pSlot->irqHandlers[u].handler = NULL; 144 pSlot->irqHandlers[u].x0 = 0; 145 pSlot->irqHandlers[u].x1 = NULL; 146 pSlot->irqHandlers[u].x2 = NULL; 147 148 return; 149 150 } 151 } 152 } 145 153 } 146 154 … … 150 158 void eoi_irq(unsigned int irq) 151 159 { 152 153 154 IRQ_SLOT*pSlot = FindSlot(irq);155 156 if( pSlot )pSlot->fEOI = 1;157 158 160 /*(void)irq; */ 161 /* 162 IRQ_SLOT *pSlot = FindSlot(irq); 163 164 if( pSlot ) pSlot->fEOI = 1; 165 */ 166 eoiIrq[irq & 0xff]++; 159 167 } 160 168 … … 164 172 BOOL process_interrupt(ULONG ulSlotNo, ULONG *pulIrq) 165 173 { 166 unsignedu;167 168 IRQ_SLOT*pSlot;169 170 171 172 173 174 175 176 177 178 179 180 174 unsigned u; 175 int rc; 176 IRQ_SLOT *pSlot; 177 178 //dprintf(("enter int proc %d %d",ulSlotNo, *pulIrq)); 179 180 if( ulSlotNo < MAX_IRQ_SLOTS ) 181 { 182 pSlot = &arSlots[ulSlotNo]; 183 184 for( u = 0; u < MAX_SHAREDIRQS; u++ ) 185 { 186 if(pSlot && pSlot->irqHandlers[u].handler ) 187 { 188 fInInterrupt = TRUE; 181 189 #if 0 182 183 190 rc = pSlot->irqHandlers[u].handler(pSlot->irqNo, 191 pSlot->irqHandlers[u].x2, 0); 184 192 #else 185 186 193 rc = pSlot->irqHandlers[u].handler(pSlot->irqNo, 194 pSlot->irqHandlers[u].x2); 187 195 #endif 188 196 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 //pSlot->fEOI = 0;209 210 211 212 213 214 215 216 217 218 219 220 221 197 // HDA Hardware generates controller interrupts and stream interrupts 198 // the uniaud16 driver only cares about stream interrupts. 199 // azx_interrupt in alsa-kernel/pci/hda/hda_intel.c will return rc 2 if 200 // the interrupt is from the controller. There is no need to call uniaud16 201 // for these interrupts 202 if ( rc == 2 ) { 203 fInInterrupt = FALSE; 204 *pulIrq = pSlot->irqNo; 205 eoiIrq[pSlot->irqNo] = 0; 206 return TRUE; 207 } 208 209 if (rc == 1) eoi_irq(pSlot->irqNo); 210 rc = (eoiIrq[pSlot->irqNo] > 0); 211 fInInterrupt = FALSE; 212 213 if( rc /*== 1 || pSlot->fEOI*/ ) { 214 215 *pulIrq = pSlot->irqNo; 216 // pSlot->fEOI = 0; 217 218 //ok, this interrupt was intended for us; notify the 16 bits MMPM/2 driver 219 OSS32_ProcessIRQ(); 220 //dprintf(("exit(1) int proc %d %d",ulSlotNo, *pulIrq)); 221 eoiIrq[pSlot->irqNo] = 0; 222 return TRUE; 223 } 224 } 225 } 226 } 227 //dprintf(("exit(0) int proc %d %d",ulSlotNo, *pulIrq)); 228 229 return FALSE; 222 230 } 223 231 … … 227 235 int in_interrupt() 228 236 { 229 237 return fInInterrupt; 230 238 } 231 239 … … 235 243 void disable_irq(int irq) 236 244 { 237 238 } 239 240 //****************************************************************************** 241 //****************************************************************************** 242 245 dprintf(("disable_irq %d NOT implemented", irq)); 246 } 247 248 //****************************************************************************** 249 //****************************************************************************** 250 -
GPL/trunk/lib32/pci.c
r602 r604 245 245 pcidev->irq_resource[0].start = pcidev->irq_resource[0].end = ulTmp1 & 0xffff; 246 246 pcidev->irq = (u8)ulTmp1; // This is the interrupt used for init time processing 247 pcidev->irq_pin = ulTmp1>>8; 247 248 } 248 249 … … 1015 1016 } 1016 1017 1018 #ifdef USE_MSI 1019 extern int __syscall UniMsiAlloc(USHORT usBusDevFunc, ULONG *pulCount, UCHAR *pucIrq); 1020 int snd_pci_enable_msi(struct pci_dev *dev) 1021 { 1022 ULONG p; 1023 UCHAR irq; 1024 1025 if (dev->irq_pin) 1026 { 1027 p = 1; /* int count */ 1028 if (UniMsiAlloc((dev->bus->number<<8) | dev->devfn, &p, &irq)) return -1; 1029 /* we have an msi interrupt */ 1030 dev->irq = irq; 1031 dev->irq_pin = 0; 1032 } 1033 return 0; 1034 } 1035 #else 1036 int snd_pci_enable_msi(struct pci_dev *dev) 1037 { 1038 return -1; 1039 } 1040 #endif 1041 -
GPL/trunk/lib32/sound.c
r598 r604 976 976 _snd_pcm_hw_param_set(¶ms, SNDRV_PCM_HW_PARAM_RATE, 977 977 pHwParams->ulSampleRate, 0); 978 979 /* Change from Andy. If statement added around 5 statements. 980 * Andy says: TODO: determine why small buffers are a problem for this code 981 * DAZ: This change is questionable. 982 */ 983 if (periodsize > 6 * minperiodsize) 984 { 978 985 _snd_pcm_hw_param_set(¶ms, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 979 986 periodsize, 0); … … 986 993 _snd_pcm_hw_param_set(¶ms, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 987 994 periodbytes*nrperiods, 0); 988 995 } 989 996 990 997 dprintf(("HWP: SR rate %ld, BPS %ld, CH %ld, PRSZ %lx, periods %lx", -
GPL/trunk/lib32/soundmixer.c
r598 r604 41 41 42 42 static struct { 43 44 45 43 char *name; 44 unsigned int index; 45 unsigned int recsrc; 46 46 } ossid[OSS_MIXER_NRDEVICES] = { 47 48 /* OSS_MIXER_BASS*/ { "Tone Control - Bass", 0, -1},49 50 /* OSS_MIXER_SYNTH*/ { "Synth", 0 , OSS32_MIX_RECSRC_SYNTH},51 /* OSS_MIXER_PCM*/ { "PCM", 0 , -1},52 /* OSS_MIXER_PCSPEAKER*/ { "PC Speaker", 0 , -1},53 /* OSS_MIXER_LINE*/ { "Line", 0 , OSS32_MIX_RECSRC_LINE},54 /* OSS_MIXER_MIC*/ { "Mic", 0, OSS32_MIX_RECSRC_MIC},55 /* OSS_MIXER_CD*/ { "CD", 0 , OSS32_MIX_RECSRC_CD},56 /* OSS_MIXER_IMIX*/ { "Monitor Mix", 0 , OSS32_MIX_RECSRC_MIXER},57 /* OSS_MIXER_ALTPCM */ { "PCM",1 , -1},58 59 /* OSS_MIXER_IGAIN*/ { "Capture", 0 , -1},60 /* OSS_MIXER_OGAIN*/ { "Playback", 0 , -1},61 /* OSS_MIXER_LINE1*/ { "Aux", 0 , OSS32_MIX_RECSRC_AUX},62 /* OSS_MIXER_LINE2*/ { "Aux", 1 , -1},63 /* OSS_MIXER_LINE3*/ { "Aux", 2 , -1},64 65 66 67 68 69 /* OSS_MIXER_VIDEO*/ { "Video", 0 , OSS32_MIX_RECSRC_VIDEO},70 /* OSS_MIXER_RADIO*/ { "Radio", 0 , -1},71 72 73 74 /* OSS_MIXER_FRONT*/ { "Front", 0 , -1},75 76 47 /* OSS_MIXER_VOLUME */ { "Master", 0 , -1}, 48 /* OSS_MIXER_BASS */ { "Tone Control - Bass", 0, -1}, 49 /* OSS_MIXER_TREBLE */ { "Tone Control - Treble", 0, -1}, 50 /* OSS_MIXER_SYNTH */ { "Synth", 0 , OSS32_MIX_RECSRC_SYNTH}, 51 /* OSS_MIXER_PCM */ { "PCM", 0 , -1}, 52 /* OSS_MIXER_PCSPEAKER */ { "PC Speaker", 0 , -1}, 53 /* OSS_MIXER_LINE */ { "Line", 0 , OSS32_MIX_RECSRC_LINE}, 54 /* OSS_MIXER_MIC */ { "Mic", 0, OSS32_MIX_RECSRC_MIC}, 55 /* OSS_MIXER_CD */ { "CD", 0 , OSS32_MIX_RECSRC_CD}, 56 /* OSS_MIXER_IMIX */ { "Monitor Mix", 0 , OSS32_MIX_RECSRC_MIXER}, 57 /* OSS_MIXER_ALTPCM */ { "PCM", 1 , -1}, 58 /* OSS_MIXER_RECLEV */ { "-- nothing --", 0 , -1}, 59 /* OSS_MIXER_IGAIN */ { "Capture", 0 , -1}, 60 /* OSS_MIXER_OGAIN */ { "Playback", 0 , -1}, 61 /* OSS_MIXER_LINE1 */ { "Aux", 0 , OSS32_MIX_RECSRC_AUX}, 62 /* OSS_MIXER_LINE2 */ { "Aux", 1 , -1}, 63 /* OSS_MIXER_LINE3 */ { "Aux", 2 , -1}, 64 /* OSS_MIXER_DIGITAL1 */ { "Digital", 0 , -1}, 65 /* OSS_MIXER_DIGITAL2 */ { "Digital", 1 , -1}, 66 /* OSS_MIXER_DIGITAL3 */ { "Digital", 2 , -1}, 67 /* OSS_MIXER_PHONEIN */ { "Phone", 0 , OSS32_MIX_RECSRC_PHONE}, 68 /* OSS_MIXER_PHONEOUT */ { "Phone", 1 , -1}, 69 /* OSS_MIXER_VIDEO */ { "Video", 0 , OSS32_MIX_RECSRC_VIDEO}, 70 /* OSS_MIXER_RADIO */ { "Radio", 0 , -1}, 71 /* OSS_MIXER_MONITOR */ { "Monitor", 0 , -1}, 72 /* OSS_MIXER_3DDEPTH */ { "3D Control - Depth", 0 , -1}, 73 /* OSS_MIXER_3DCENTER */ { "3D Control - Center", 0 , -1}, 74 /* OSS_MIXER_FRONT */ { "Front", 0 , -1}, 75 /* OSS_MIXER_SPEAKER */ { "Speaker", 0 , -1}, 76 /* OSS_MIXER_HEADPHONE */ { "Headphone", 0 , -1}, 77 77 }; 78 78 char *szRecSources[OSS32_MIX_RECSRC_MAX] = { 79 79 "Mic", "CD", "Line", "Video", "Aux", "Mix", "Mix Mono", "Phone", "Synth" 80 80 }; 81 81 82 82 static unsigned char LinToLog[OSS32_MAX_VOLUME+1] = { 83 0, 0, 0, 0, 1, 2, 2,5, 5, 10,84 10, 10, 16, 19, 20, 22, 24,25, 27, 27,85 28, 28, 29, 30, 30, 35, 35,35, 39, 39,86 43, 44, 45, 47, 48, 49, 50,51, 52, 53,87 55, 56, 57, 59, 60, 62, 63,64, 65, 66,88 67, 68, 69, 70, 71, 72, 73,74, 74, 75,89 76, 77, 78, 79, 79, 80, 81,82, 83, 84,90 85, 86, 87, 88, 89, 90, 91,92, 92, 93,91 93, 94, 94, 95, 95, 96, 96,97, 97, 98,92 98, 99, 99, 83 0, 0, 0, 0, 1, 2, 2, 5, 5, 10, 84 10, 10, 16, 19, 20, 22, 24, 25, 27, 27, 85 28, 28, 29, 30, 30, 35, 35, 35, 39, 39, 86 43, 44, 45, 47, 48, 49, 50, 51, 52, 53, 87 55, 56, 57, 59, 60, 62, 63, 64, 65, 66, 88 67, 68, 69, 70, 71, 72, 73, 74, 74, 75, 89 76, 77, 78, 79, 79, 80, 81, 82, 83, 84, 90 85, 86, 87, 88, 89, 90, 91, 92, 92, 93, 91 93, 94, 94, 95, 95, 96, 96, 97, 97, 98, 92 98, 99, 99, 99, 99, 100, 100, 100, 100, 100, 93 93 100 94 94 }; … … 99 99 ULONG ConvertVolume(ULONG ulLinVolume, ULONG ulLogVolMax) 100 100 { 101 102 103 104 105 106 101 if(ulLinVolume > OSS32_MAX_VOLUME) { 102 ulLinVolume = OSS32_MAX_VOLUME; 103 } 104 ulLinVolume = LinToLog[ulLinVolume]; 105 106 return (ulLinVolume * ulLogVolMax) / OSS32_MAX_VOLUME; 107 107 } 108 108 … … 111 111 OSSRET OSS32_MixOpen(ULONG deviceid, OSSSTREAMID *pStreamId) 112 112 { 113 114 intret, i, j, sz;115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 pHandle->file.f_dentry= &pHandle->d_entry;140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 pHandle->list.pids= pHandle->pids;174 175 176 177 178 179 113 mixerhandle *pHandle = NULL; 114 int ret, i, j, sz; 115 116 if(pStreamId == NULL) { 117 DebugInt3(); 118 return OSSERR_INVALID_PARAMETER; 119 } 120 *pStreamId = 0; 121 122 if(alsa_fops == NULL) { 123 ret = OSSERR_NO_DEVICE_AVAILABLE; 124 goto failure; 125 } 126 127 sz = sizeof(mixerhandle); 128 pHandle = kmalloc(sz, GFP_KERNEL); 129 if(pHandle == NULL) { 130 ret = OSSERR_OUT_OF_MEMORY; 131 goto failure; 132 } 133 memset(pHandle, 0, sizeof(mixerhandle)); 134 135 //set operation to non-blocking 136 pHandle->file.f_flags = O_NONBLOCK; 137 138 //setup pointers in file structure (used internally by ALSA) 139 pHandle->file.f_dentry = &pHandle->d_entry; 140 pHandle->file.f_dentry->d_inode = &pHandle->inode; 141 142 pHandle->file.f_mode = FMODE_WRITE; 143 pHandle->inode.i_rdev = SNDRV_MINOR(deviceid, SNDRV_MINOR_CONTROL); 144 145 ret = alsa_fops->open(&pHandle->inode, &pHandle->file); 146 if(ret) { 147 goto failure; 148 } 149 //retrieve mixer information 150 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, 151 SNDRV_CTL_IOCTL_CARD_INFO, 152 (ULONG)&pHandle->info); 153 if(ret) { 154 goto failure; 155 } 156 //get the number of mixer elements 157 pHandle->list.offset = 0; 158 pHandle->list.space = 0; 159 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, 160 SNDRV_CTL_IOCTL_ELEM_LIST, 161 (ULONG)&pHandle->list); 162 if(ret) { 163 goto failure; 164 } 165 //allocate memory for all mixer elements 166 pHandle->pids = (struct snd_ctl_elem_id *)kmalloc(sizeof(struct snd_ctl_elem_id)*pHandle->list.count, GFP_KERNEL); 167 if(pHandle->pids == NULL) { 168 goto failure; 169 } 170 //and retrieve all mixer elements 171 pHandle->list.offset = 0; 172 pHandle->list.space = pHandle->list.count; 173 pHandle->list.pids = pHandle->pids; 174 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, 175 SNDRV_CTL_IOCTL_ELEM_LIST, 176 (ULONG)&pHandle->list); 177 if(ret) { 178 goto failure; 179 } 180 180 181 181 #if 0 182 183 184 185 186 182 dprintf(("Mixer name: %s", pHandle->info.mixername)); 183 dprintf(("List of mixer elements:")); 184 for(i=0;i<pHandle->list.count;i++) { 185 dprintf(("index %d name %s id %d device %d subdevice %d", pHandle->pids[i].index, pHandle->pids[i].name, pHandle->pids[i].numid, pHandle->pids[i].device, pHandle->pids[i].subdevice)); 186 } 187 187 #endif 188 188 189 190 191 192 193 194 pHandle->controls[j].idxVolume= -1;195 pHandle->controls[j].idxMute= -1;196 pHandle->controls[j].idxCustom= -1;197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 pHandle->reccaps|= OSS32_MIX_FLAG(j);285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 pHandle->reccaps|= OSS32_MIX_FLAG(ossid[j].recsrc);303 304 305 306 307 308 309 310 189 //Extract standard mixer controls from array with control names 190 for(j=0;j<OSS_MIXER_NRDEVICES;j++) 191 { 192 int namelen = strlen(ossid[j].name); 193 194 pHandle->controls[j].idxVolume = -1; 195 pHandle->controls[j].idxMute = -1; 196 pHandle->controls[j].idxCustom = -1; 197 pHandle->controls[j].idxCaptureSwitch = -1; 198 199 for(i=0;i<pHandle->list.count;i++) { 200 if (pHandle->pids[i].index == ossid[j].index && strncmp(pHandle->pids[i].name, ossid[j].name, namelen) == 0) { 201 int controlnamelen = strlen(pHandle->pids[i].name); 202 203 if(namelen == controlnamelen) { //control names are identical; found exact match 204 pHandle->controls[j].idxVolume = i; 205 break; 206 } else { //first part of the control name is correct; now find out what is it exactly 207 char *nextword = &pHandle->pids[i].name[namelen]; 208 while(*nextword && *nextword == ' ') nextword++; 209 210 if(strncmp(nextword, MIXER_PLAYBACKVOLUME, sizeof(MIXER_PLAYBACKVOLUME)-1) == 0 || 211 strncmp(nextword, MIXER_VOLUME, sizeof(MIXER_VOLUME)-1) == 0) 212 { //volume control 213 pHandle->controls[j].idxVolume = i; 214 } 215 else 216 if(strncmp(nextword, MIXER_PLAYBACKSWITCH, sizeof(MIXER_PLAYBACKSWITCH)-1) == 0 || 217 strncmp(nextword, MIXER_SWITCH, sizeof(MIXER_SWITCH)-1) == 0) 218 { //mute control 219 pHandle->controls[j].idxMute = i; 220 if (pHandle->controls[j].idxVolume == -1) pHandle->controls[j].idxVolume = i; 221 } 222 else 223 if(strncmp(nextword, MIXER_SOURCE, sizeof(MIXER_SOURCE)-1) == 0) 224 { //source control (e.g. recording source) 225 pHandle->controls[j].idxCustom = i; 226 } 227 else 228 if(strncmp(nextword, MIXER_CAPTUREROUTE, sizeof(MIXER_CAPTUREROUTE)-1) == 0 || 229 strncmp(nextword, MIXER_CAPTURESWITCH, sizeof(MIXER_CAPTURESWITCH)-1) == 0) 230 { //source control for recording (per input) 231 pHandle->controls[j].idxCaptureSwitch = i; 232 } 233 else 234 if(i == OSS_MIXER_MIC) { 235 if(strncmp(nextword, MIXER_BOOST, sizeof(MIXER_BOOST)-1) == 0) { //mic boost switch 236 pHandle->controls[j].idxCustom = i; 237 } 238 } 239 } 240 } 241 } 242 } 243 244 pHandle->reccaps = 0; 245 for (j=0;j<OSS32_MIX_RECSRC_MAX;j++) { 246 pHandle->idxRecCaps[j] = -1; 247 } 248 249 //request information about available capture sources 250 if (pHandle->controls[OSS_MIXER_IGAIN].idxCustom != -1) { 251 struct snd_ctl_elem_info *pElemInfo = NULL; 252 int idx, j; 253 254 idx = pHandle->controls[OSS_MIXER_IGAIN].idxCustom; 255 256 //set operation to non-blocking 257 pHandle->file.f_flags = O_NONBLOCK; 258 259 pHandle->rectype = RECTYPE_SELECTOR; 260 261 //too big to put on the stack 262 pElemInfo = (struct snd_ctl_elem_info *)kmalloc(sizeof(struct snd_ctl_elem_info), GFP_KERNEL); 263 if(pElemInfo == NULL) { 264 DebugInt3(); 265 goto failure; 266 } 267 268 pElemInfo->value.enumerated.items = 1; 269 for(i=0;i<pElemInfo->value.enumerated.items;i++) 270 { 271 pElemInfo->value.enumerated.item = i; 272 pElemInfo->id.numid = pHandle->pids[idx].numid; 273 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_CTL_IOCTL_ELEM_INFO, (ULONG)pElemInfo); 274 if(ret) { 275 DebugInt3(); 276 break; 277 } 278 if(pElemInfo->type != SNDRV_CTL_ELEM_TYPE_ENUMERATED) { 279 DebugInt3(); 280 break; 281 } 282 for(j=0;j<OSS32_MIX_RECSRC_MAX;j++) { 283 if(!strcmp(pElemInfo->value.enumerated.name, szRecSources[j])) { 284 pHandle->reccaps |= OSS32_MIX_FLAG(j); 285 pHandle->idxRecCaps[j] = i; //save alsa index 286 break; 287 } 288 } 289 } 290 kfree(pElemInfo); 291 } 292 else 293 {//This card has no record source selection, but probably route switches for 294 //each input source (SB mixers (also ALS4000), CMedia) 295 pHandle->rectype = RECTYPE_SWITCH; 296 for(j=0;j<OSS32_MIX_RECSRC_MAX;j++) { 297 pHandle->idxRecCaps[j] = -1; 298 } 299 for(j=0;j<OSS_MIXER_NRDEVICES;j++) 300 { 301 if(pHandle->controls[j].idxCaptureSwitch != -1) { 302 pHandle->reccaps |= OSS32_MIX_FLAG(ossid[j].recsrc); 303 pHandle->idxRecCaps[ossid[j].recsrc] = pHandle->controls[j].idxCaptureSwitch; //save alsa index 304 } 305 } 306 } 307 308 pHandle->magic = MAGIC_MIXER_ALSA32; 309 *pStreamId = (ULONG)pHandle; 310 return OSSERR_SUCCESS; 311 311 312 312 failure: 313 314 315 316 317 318 313 if(pHandle) { 314 if(pHandle->pids) kfree(pHandle->pids); 315 kfree(pHandle); 316 } 317 DebugInt3(); 318 return OSSERR_OUT_OF_MEMORY; 319 319 } 320 320 //****************************************************************************** … … 322 322 OSSRET OSS32_MixClose(OSSSTREAMID streamid) 323 323 { 324 325 intret;326 327 328 329 330 331 332 333 334 335 kfree(pHandle);//free handle data336 337 338 339 340 341 324 mixerhandle *pHandle = (mixerhandle *)streamid; 325 int ret; 326 327 if(pHandle == NULL || pHandle->magic != MAGIC_MIXER_ALSA32) { 328 DebugInt3(); 329 return OSSERR_INVALID_STREAMID; 330 } 331 //set operation to non-blocking 332 pHandle->file.f_flags = O_NONBLOCK; 333 ret = pHandle->file.f_op->release(&pHandle->inode, &pHandle->file); 334 kfree(pHandle->pids); //free mixer element array 335 kfree(pHandle); //free handle data 336 337 if(ret) { 338 DebugInt3(); 339 return UNIXToOSSError(ret); 340 } 341 return OSSERR_SUCCESS; 342 342 } 343 343 //****************************************************************************** … … 345 345 OSSRET OSS32_MixGetVolume(OSSSTREAMID streamid, ULONG line, ULONG *pVolume) 346 346 { 347 348 //intret;349 350 351 352 353 354 355 356 357 347 mixerhandle *pHandle = (mixerhandle *)streamid; 348 //int ret; 349 350 if(pHandle == NULL || pHandle->magic != MAGIC_MIXER_ALSA32) { 351 DebugInt3(); 352 return OSSERR_INVALID_STREAMID; 353 } 354 //set operation to non-blocking 355 pHandle->file.f_flags = O_NONBLOCK; 356 357 return OSSERR_NOT_SUPPORTED; 358 358 } 359 359 //****************************************************************************** … … 361 361 OSSRET OSS32_MixSetVolume(OSSSTREAMID streamid, ULONG line, ULONG volume) 362 362 { 363 mixerhandle *pHandle = (mixerhandle *)streamid; 364 struct snd_ctl_elem_value *pElem = NULL; 365 struct snd_ctl_elem_info *pElemInfo; 366 int ret, idx, lVol, rVol = 0, idxMute; 367 //int cnt; 368 369 //dprintf(("OSS32_MixSetVolume line=%d\n", line)); 370 if(pHandle == NULL || pHandle->magic != MAGIC_MIXER_ALSA32) { 371 printk("Invalid handle in OSS32_MixSetVolume\n"); 372 DebugInt3(); 373 return OSSERR_INVALID_STREAMID; 374 } 375 //set operation to non-blocking 376 pHandle->file.f_flags = O_NONBLOCK; 377 378 //too big to put on the stack 379 pElem = (struct snd_ctl_elem_value *)kmalloc(sizeof(struct snd_ctl_elem_value) + sizeof(struct snd_ctl_elem_info), GFP_KERNEL); 380 if(pElem == NULL) { 381 printk("Out of memory in OSS32_MixSetVolume\n"); 382 DebugInt3(); 383 return OSSERR_OUT_OF_MEMORY; 384 } 385 pElemInfo = (struct snd_ctl_elem_info *)(pElem+1); 386 387 switch(line) { 388 case OSS32_MIX_VOLUME_MASTER_FRONT: 389 idx = pHandle->controls[OSS_MIXER_VOLUME].idxVolume; 390 idxMute = pHandle->controls[OSS_MIXER_VOLUME].idxMute; 391 if (idx == -1) 392 { 393 /* HDA codecs workaround */ 394 idx = pHandle->controls[OSS_MIXER_FRONT].idxVolume; 395 idxMute = pHandle->controls[OSS_MIXER_FRONT].idxMute; 396 } 397 break; 398 case OSS32_MIX_VOLUME_MASTER_REAR: //TODO: 399 idx = pHandle->controls[OSS_MIXER_VOLUME].idxVolume; 400 idxMute = pHandle->controls[OSS_MIXER_VOLUME].idxMute; 401 break; 402 case OSS32_MIX_VOLUME_PCM: 403 idx = pHandle->controls[OSS_MIXER_PCM].idxVolume; 404 idxMute = pHandle->controls[OSS_MIXER_PCM].idxMute; 405 if (idx == -1) 406 { 407 /* HDA codecs workaround */ 408 idx = pHandle->controls[OSS_MIXER_FRONT].idxVolume; 409 idxMute = pHandle->controls[OSS_MIXER_FRONT].idxMute; 410 } 411 break; 412 case OSS32_MIX_VOLUME_MIDI: 413 idx = pHandle->controls[OSS_MIXER_SYNTH].idxVolume; 414 idxMute = pHandle->controls[OSS_MIXER_SYNTH].idxMute; 415 break; 416 case OSS32_MIX_VOLUME_LINEIN: 417 idx = pHandle->controls[OSS_MIXER_LINE].idxVolume; 418 idxMute = pHandle->controls[OSS_MIXER_LINE].idxMute; 419 break; 420 case OSS32_MIX_VOLUME_MIC: 421 idx = pHandle->controls[OSS_MIXER_MIC].idxVolume; 422 idxMute = pHandle->controls[OSS_MIXER_MIC].idxMute; 423 break; 424 case OSS32_MIX_VOLUME_CD: 425 idx = pHandle->controls[OSS_MIXER_CD].idxVolume; 426 idxMute = pHandle->controls[OSS_MIXER_CD].idxMute; 427 break; 428 case OSS32_MIX_VOLUME_SPDIF: 429 idx = pHandle->controls[OSS_MIXER_DIGITAL1].idxVolume; 430 idxMute = pHandle->controls[OSS_MIXER_DIGITAL1].idxMute; 431 break; 432 case OSS32_MIX_VOLUME_VIDEO: 433 idx = pHandle->controls[OSS_MIXER_VIDEO].idxVolume; 434 idxMute = pHandle->controls[OSS_MIXER_VIDEO].idxMute; 435 break; 436 case OSS32_MIX_VOLUME_PCSPEAKER: 437 idx = pHandle->controls[OSS_MIXER_PCSPEAKER].idxVolume; 438 idxMute = pHandle->controls[OSS_MIXER_PCSPEAKER].idxMute; 439 break; 440 case OSS32_MIX_VOLUME_PHONE: 441 idx = pHandle->controls[OSS_MIXER_PHONEOUT].idxVolume; 442 idxMute = pHandle->controls[OSS_MIXER_PHONEOUT].idxMute; 443 break; 444 case OSS32_MIX_VOLUME_HEADPHONE: 445 idx = pHandle->controls[OSS_MIXER_HEADPHONE].idxVolume; 446 idxMute = pHandle->controls[OSS_MIXER_HEADPHONE].idxMute; 447 break; 448 case OSS32_MIX_VOLUME_SPEAKER: 449 idx = pHandle->controls[OSS_MIXER_SPEAKER].idxVolume; 450 idxMute = pHandle->controls[OSS_MIXER_SPEAKER].idxMute; 451 break; 452 case OSS32_MIX_VOLUME_AUX: 453 idx = pHandle->controls[OSS_MIXER_LINE1].idxVolume; 454 idxMute = pHandle->controls[OSS_MIXER_LINE1].idxMute; 455 break; 456 case OSS32_MIX_VOLUME_CAPTURE: 457 idx = pHandle->controls[OSS_MIXER_IGAIN].idxVolume; 458 idxMute = pHandle->controls[OSS_MIXER_IGAIN].idxMute; 459 break; 460 461 default: 462 DebugInt3(); 463 ret = OSSERR_INVALID_PARAMETER; 464 goto fail; 465 } 466 if(idx == -1) { 467 rprintf(("Unknown control %d", line)); 468 ret = OSSERR_INVALID_PARAMETER; 469 goto fail; 470 } 471 472 if(idxMute != -1 && volume != 0) { 473 //disable mute 474 pElem->id.numid = pHandle->pids[idxMute].numid; 475 pElem->indirect = 0; 476 477 pElem->value.integer.value[0] = TRUE; //switch, not mute control (inversed) 478 pElem->value.integer.value[1] = TRUE; 479 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_CTL_IOCTL_ELEM_WRITE, (ULONG)pElem); 480 } 481 //request information about mixer control 482 pElemInfo->id.numid = pHandle->pids[idx].numid; 483 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_CTL_IOCTL_ELEM_INFO, (ULONG)pElemInfo); 484 if(ret) { 485 ret = UNIXToOSSError(ret); 486 DebugInt3(); 487 goto fail; 488 } 489 if(pElemInfo->type != SNDRV_CTL_ELEM_TYPE_INTEGER) { 490 ret = OSSERR_INVALID_PARAMETER; 491 DebugInt3(); 492 goto fail; 493 } 494 pElem->id.numid = pHandle->pids[idx].numid; 495 pElem->indirect = 0; 496 497 lVol = ConvertVolume(GET_VOLUME_L(volume), pElemInfo->value.integer.max); 498 pElem->value.integer.value[0] = lVol; 499 500 if(pElemInfo->count > 1) { //stereo 501 rVol = ConvertVolume(GET_VOLUME_R(volume), pElemInfo->value.integer.max); 502 pElem->value.integer.value[1] = rVol; 503 } 504 505 dprintf(("OSS32_MixSetVolume of %s streamid %X to (%d,%d)(%d,%d) caps %d", 506 pHandle->pids[idx].name, (ULONG)pHandle, 507 GET_VOLUME_L(volume), GET_VOLUME_R(volume), lVol, rVol, pElemInfo->value.integer.max)); 363 mixerhandle *pHandle = (mixerhandle *)streamid; 364 struct snd_ctl_elem_value *pElem = NULL; 365 struct snd_ctl_elem_info *pElemInfo; 366 int ret, idx, lVol, rVol = 0, idxMute; 367 //int cnt; 368 369 //dprintf(("OSS32_MixSetVolume line=%d\n", line)); 370 if(pHandle == NULL || pHandle->magic != MAGIC_MIXER_ALSA32) { 371 printk("Invalid handle in OSS32_MixSetVolume\n"); 372 DebugInt3(); 373 return OSSERR_INVALID_STREAMID; 374 } 375 //set operation to non-blocking 376 pHandle->file.f_flags = O_NONBLOCK; 377 378 //too big to put on the stack 379 pElem = (struct snd_ctl_elem_value *)kmalloc(sizeof(struct snd_ctl_elem_value) + sizeof(struct snd_ctl_elem_info), GFP_KERNEL); 380 if(pElem == NULL) { 381 printk("Out of memory in OSS32_MixSetVolume\n"); 382 DebugInt3(); 383 return OSSERR_OUT_OF_MEMORY; 384 } 385 pElemInfo = (struct snd_ctl_elem_info *)(pElem+1); 386 387 switch(line) { 388 case OSS32_MIX_VOLUME_MASTER_FRONT: 389 idx = pHandle->controls[OSS_MIXER_VOLUME].idxVolume; 390 idxMute = pHandle->controls[OSS_MIXER_VOLUME].idxMute; 391 if (idx == -1) 392 { 393 /* HDA codecs workaround */ 394 idx = pHandle->controls[OSS_MIXER_FRONT].idxVolume; 395 idxMute = pHandle->controls[OSS_MIXER_FRONT].idxMute; 396 } 397 break; 398 case OSS32_MIX_VOLUME_MASTER_REAR: //TODO: 399 idx = pHandle->controls[OSS_MIXER_VOLUME].idxVolume; 400 idxMute = pHandle->controls[OSS_MIXER_VOLUME].idxMute; 401 break; 402 case OSS32_MIX_VOLUME_PCM: 403 idx = pHandle->controls[OSS_MIXER_PCM].idxVolume; 404 idxMute = pHandle->controls[OSS_MIXER_PCM].idxMute; 405 if (idx == -1) 406 { 407 /* HDA codecs workaround */ 408 idx = pHandle->controls[OSS_MIXER_FRONT].idxVolume; 409 idxMute = pHandle->controls[OSS_MIXER_FRONT].idxMute; 410 } 411 /* HDA codecs workaround from Andy */ 412 if (idx == -1) 413 { 414 idx = pHandle->controls[OSS_MIXER_SPEAKER].idxVolume; 415 idxMute = pHandle->controls[OSS_MIXER_SPEAKER].idxMute; 416 } 417 /* HDA codecs workaround from Andy */ 418 break; 419 case OSS32_MIX_VOLUME_MIDI: 420 idx = pHandle->controls[OSS_MIXER_SYNTH].idxVolume; 421 idxMute = pHandle->controls[OSS_MIXER_SYNTH].idxMute; 422 break; 423 case OSS32_MIX_VOLUME_LINEIN: 424 idx = pHandle->controls[OSS_MIXER_LINE].idxVolume; 425 idxMute = pHandle->controls[OSS_MIXER_LINE].idxMute; 426 break; 427 case OSS32_MIX_VOLUME_MIC: 428 idx = pHandle->controls[OSS_MIXER_MIC].idxVolume; 429 idxMute = pHandle->controls[OSS_MIXER_MIC].idxMute; 430 break; 431 case OSS32_MIX_VOLUME_CD: 432 idx = pHandle->controls[OSS_MIXER_CD].idxVolume; 433 idxMute = pHandle->controls[OSS_MIXER_CD].idxMute; 434 break; 435 case OSS32_MIX_VOLUME_SPDIF: 436 idx = pHandle->controls[OSS_MIXER_DIGITAL1].idxVolume; 437 idxMute = pHandle->controls[OSS_MIXER_DIGITAL1].idxMute; 438 break; 439 case OSS32_MIX_VOLUME_VIDEO: 440 idx = pHandle->controls[OSS_MIXER_VIDEO].idxVolume; 441 idxMute = pHandle->controls[OSS_MIXER_VIDEO].idxMute; 442 break; 443 case OSS32_MIX_VOLUME_PCSPEAKER: 444 idx = pHandle->controls[OSS_MIXER_PCSPEAKER].idxVolume; 445 idxMute = pHandle->controls[OSS_MIXER_PCSPEAKER].idxMute; 446 break; 447 case OSS32_MIX_VOLUME_PHONE: 448 idx = pHandle->controls[OSS_MIXER_PHONEOUT].idxVolume; 449 idxMute = pHandle->controls[OSS_MIXER_PHONEOUT].idxMute; 450 break; 451 case OSS32_MIX_VOLUME_HEADPHONE: 452 idx = pHandle->controls[OSS_MIXER_HEADPHONE].idxVolume; 453 idxMute = pHandle->controls[OSS_MIXER_HEADPHONE].idxMute; 454 break; 455 case OSS32_MIX_VOLUME_SPEAKER: 456 idx = pHandle->controls[OSS_MIXER_SPEAKER].idxVolume; 457 idxMute = pHandle->controls[OSS_MIXER_SPEAKER].idxMute; 458 break; 459 case OSS32_MIX_VOLUME_AUX: 460 idx = pHandle->controls[OSS_MIXER_LINE1].idxVolume; 461 idxMute = pHandle->controls[OSS_MIXER_LINE1].idxMute; 462 break; 463 case OSS32_MIX_VOLUME_CAPTURE: 464 idx = pHandle->controls[OSS_MIXER_IGAIN].idxVolume; 465 idxMute = pHandle->controls[OSS_MIXER_IGAIN].idxMute; 466 break; 467 468 default: 469 DebugInt3(); 470 ret = OSSERR_INVALID_PARAMETER; 471 goto fail; 472 } 473 if(idx == -1) { 474 rprintf(("Unknown control %d", line)); 475 ret = OSSERR_INVALID_PARAMETER; 476 goto fail; 477 } 478 479 if(idxMute != -1 && volume != 0) { 480 //disable mute 481 pElem->id.numid = pHandle->pids[idxMute].numid; 482 pElem->indirect = 0; 483 484 pElem->value.integer.value[0] = TRUE; //switch, not mute control (inversed) 485 pElem->value.integer.value[1] = TRUE; 486 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_CTL_IOCTL_ELEM_WRITE, (ULONG)pElem); 487 } 488 //request information about mixer control 489 pElemInfo->id.numid = pHandle->pids[idx].numid; 490 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_CTL_IOCTL_ELEM_INFO, (ULONG)pElemInfo); 491 if(ret) { 492 ret = UNIXToOSSError(ret); 493 DebugInt3(); 494 goto fail; 495 } 496 if(pElemInfo->type != SNDRV_CTL_ELEM_TYPE_INTEGER) { 497 ret = OSSERR_INVALID_PARAMETER; 498 DebugInt3(); 499 goto fail; 500 } 501 pElem->id.numid = pHandle->pids[idx].numid; 502 pElem->indirect = 0; 503 504 lVol = ConvertVolume(GET_VOLUME_L(volume), pElemInfo->value.integer.max); 505 pElem->value.integer.value[0] = lVol; 506 507 if(pElemInfo->count > 1) { //stereo 508 rVol = ConvertVolume(GET_VOLUME_R(volume), pElemInfo->value.integer.max); 509 pElem->value.integer.value[1] = rVol; 510 } 511 512 dprintf(("OSS32_MixSetVolume of %s streamid %X to (%d,%d)(%d,%d) caps %d", 513 pHandle->pids[idx].name, (ULONG)pHandle, 514 GET_VOLUME_L(volume), GET_VOLUME_R(volume), lVol, rVol, pElemInfo->value.integer.max)); 508 515 509 516 #if 1 510 517 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_CTL_IOCTL_ELEM_WRITE, (ULONG)pElem); 511 518 #else 512 513 514 515 516 517 518 519 //if (((cnt == 1 && (lVol==0 && rVol==0)) || (lVol>0 && rVol>0)) ||520 521 522 523 524 525 526 527 528 529 530 pElem->value.integer.value[0] = FALSE;//switch, not mute control (inversed)531 532 533 534 535 519 // looking for more, then one opened streams to prevent of muting active stream 520 cnt = 0; 521 for (idx=0; idx < 8*256; idx++) 522 if (opened_handles[idx].handle != 0) 523 cnt++; 524 525 dprintf(("OSS32_MixSetVolume old cnt=%X line=%x lVol=%x rVol=%x", cnt, line, lVol, rVol)); 526 // if (((cnt == 1 && (lVol==0 && rVol==0)) || (lVol>0 && rVol>0)) || 527 if (cnt == 1 || line != OSS32_MIX_VOLUME_PCM) 528 { 529 dprintf(("OSS32_MixSetVolume Ioctl")); 530 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_CTL_IOCTL_ELEM_WRITE, (ULONG)pElem); 531 532 if(idxMute != -1 && volume == 0) { 533 //enable mute 534 pElem->id.numid = pHandle->pids[idxMute].numid; 535 pElem->indirect = 0; 536 537 pElem->value.integer.value[0] = FALSE; //switch, not mute control (inversed) 538 pElem->value.integer.value[1] = FALSE; 539 dprintf(("OSS32_MixSetVolume Ioctl mute")); 540 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_CTL_IOCTL_ELEM_WRITE, (ULONG)pElem); 541 } 542 } 536 543 #endif 537 544 538 539 540 541 542 543 544 545 545 kfree(pElem); 546 pElem = NULL; 547 if(ret) { 548 rprintf(("OSS32_MixSetVolume ret=%x", ret)); 549 DebugInt3(); 550 return UNIXToOSSError(ret); 551 } 552 return OSSERR_SUCCESS; 546 553 547 554 fail: 548 549 555 if(pElem) kfree(pElem); 556 return ret; 550 557 } 551 558 //****************************************************************************** … … 553 560 OSSRET OSS32_MixSetProperty(OSSSTREAMID streamid, ULONG ulLine, ULONG ulValue) 554 561 { 555 mixerhandle*pHandle = (mixerhandle *)streamid;556 557 558 intret, idx = -1, lVol, rVol = 0, j, i;559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 idx= pHandle->idxRecCaps[j];595 596 597 pElemInfo->id.numid= pHandle->pids[idx].numid;598 599 600 601 602 603 604 605 606 607 608 609 610 pElem->id.numid= pHandle->pids[idx].numid;611 pElem->indirect= 0;612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 562 mixerhandle *pHandle = (mixerhandle *)streamid; 563 struct snd_ctl_elem_value *pElem = NULL; 564 struct snd_ctl_elem_info *pElemInfo; 565 int ret, idx = -1, lVol, rVol = 0, j, i; 566 567 if(pHandle == NULL || pHandle->magic != MAGIC_MIXER_ALSA32) { 568 DebugInt3(); 569 return OSSERR_INVALID_STREAMID; 570 } 571 //set operation to non-blocking 572 pHandle->file.f_flags = O_NONBLOCK; 573 574 //too big to put on the stack 575 pElem = (struct snd_ctl_elem_value *)kmalloc(sizeof(struct snd_ctl_elem_value) + sizeof(struct snd_ctl_elem_info), GFP_KERNEL); 576 if(pElem == NULL) { 577 DebugInt3(); 578 return OSSERR_OUT_OF_MEMORY; 579 } 580 pElemInfo = (struct snd_ctl_elem_info *)(pElem+1); 581 582 switch(ulLine) { 583 case OSS32_MIX_INPUTSRC: 584 idx = pHandle->controls[OSS_MIXER_IGAIN].idxCustom; 585 //is this capture source supported by the hardware?? 586 if(!(pHandle->reccaps & OSS32_MIX_FLAG(ulValue))) { 587 DebugInt3(); 588 ret = OSSERR_INVALID_PARAMETER; 589 goto fail; 590 } 591 if(pHandle->rectype == RECTYPE_SELECTOR) {//input source selector 592 //set left and right capture source 593 pElem->value.enumerated.item[0] = pHandle->idxRecCaps[ulValue]; 594 pElem->value.enumerated.item[1] = pHandle->idxRecCaps[ulValue]; 595 } 596 else {//capture switch for each input source 597 //first turn off all capture switches... 598 for(j=0;j<OSS32_MIX_RECSRC_MAX;j++) 599 { 600 if(pHandle->idxRecCaps[j] != -1) { 601 idx = pHandle->idxRecCaps[j]; 602 603 //request information about mixer control 604 pElemInfo->id.numid = pHandle->pids[idx].numid; 605 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_CTL_IOCTL_ELEM_INFO, (ULONG)pElemInfo); 606 if(ret) { 607 ret = UNIXToOSSError(ret); 608 DebugInt3(); 609 goto fail; 610 } 611 if(pElemInfo->type != SNDRV_CTL_ELEM_TYPE_BOOLEAN) { 612 ret = OSSERR_INVALID_PARAMETER; 613 DebugInt3(); 614 goto fail; 615 } 616 617 pElem->id.numid = pHandle->pids[idx].numid; 618 pElem->indirect = 0; 619 for(i=0;i<pElemInfo->count;i++) { 620 pElem->value.integer.value[i] = 0; 621 } 622 623 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_CTL_IOCTL_ELEM_WRITE, (ULONG)pElem); 624 if(ret) { 625 ret = UNIXToOSSError(ret); 626 DebugInt3(); 627 goto fail; 628 } 629 } 630 } 631 //request information about mixer control 632 pElemInfo->id.numid = pHandle->pids[idx].numid; 633 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_CTL_IOCTL_ELEM_INFO, (ULONG)pElemInfo); 634 if(ret) { 635 ret = UNIXToOSSError(ret); 636 DebugInt3(); 637 goto fail; 638 } 639 640 //and enable the capture switch for the selected input source 641 idx = pHandle->idxRecCaps[ulValue]; 642 for(i=0;i<pElemInfo->count;i++) { 643 pElem->value.integer.value[i] = 1; 644 } 645 } 646 647 break; 648 649 case OSS32_MIX_SWITCH_MICBOOST: 650 idx = pHandle->controls[OSS_MIXER_MIC].idxCustom; 651 if(idx == -1) { 652 DebugInt3(); 653 ret = OSSERR_INVALID_PARAMETER; 654 goto fail; 655 } 656 //set mic switch value (on/off) 657 pElem->value.integer.value[0] = ulValue; 658 break; 659 660 case OSS32_MIX_LEVEL_BASS: 661 idx = pHandle->controls[OSS_MIXER_BASS].idxVolume; 662 goto levelcontinue; 663 case OSS32_MIX_LEVEL_TREBLE: 664 idx = pHandle->controls[OSS_MIXER_TREBLE].idxVolume; 665 goto levelcontinue; 666 case OSS32_MIX_LEVEL_3DCENTER: 667 idx = pHandle->controls[OSS_MIXER_3DCENTER].idxVolume; 668 goto levelcontinue; 669 case OSS32_MIX_LEVEL_3DDEPTH: 670 idx = pHandle->controls[OSS_MIXER_3DDEPTH].idxVolume; 664 671 levelcontinue: 665 672 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 673 if(idx == -1) {//supported? 674 DebugInt3(); 675 ret = OSSERR_INVALID_PARAMETER; 676 goto fail; 677 } 678 //request information about mixer control 679 pElemInfo->id.numid = pHandle->pids[idx].numid; 680 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_CTL_IOCTL_ELEM_INFO, (ULONG)pElemInfo); 681 if(ret) { 682 ret = UNIXToOSSError(ret); 683 DebugInt3(); 684 goto fail; 685 } 686 if(pElemInfo->type != SNDRV_CTL_ELEM_TYPE_INTEGER) { 687 ret = OSSERR_INVALID_PARAMETER; 688 DebugInt3(); 689 goto fail; 690 } 691 lVol = ConvertVolume(GET_VOLUME_L(ulValue), pElemInfo->value.integer.max); 692 pElem->value.integer.value[0] = lVol; 693 694 if(pElemInfo->count > 1) { //stereo 695 rVol = ConvertVolume(GET_VOLUME_R(ulValue), pElemInfo->value.integer.max); 696 pElem->value.integer.value[1] = rVol; 697 } 698 break; 699 700 default: 701 DebugInt3(); 702 ret = OSSERR_INVALID_PARAMETER; 703 goto fail; 704 } 705 pElem->id.numid = pHandle->pids[idx].numid; 706 pElem->indirect = 0; 707 708 dprintf(("OSS32_MixSetProperty of %s to %x", pHandle->pids[idx].name, ulValue)); 709 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_CTL_IOCTL_ELEM_WRITE, (ULONG)pElem); 710 711 kfree(pElem); 712 pElem = NULL; 713 if(ret) { 714 DebugInt3(); 715 return UNIXToOSSError(ret); 716 } 717 return OSSERR_SUCCESS; 711 718 712 719 fail: 713 714 720 if(pElem) kfree(pElem); 721 return ret; 715 722 } 716 723 //****************************************************************************** … … 718 725 OSSRET OSS32_MixGetProperty(OSSSTREAMID streamid, ULONG line, ULONG *pValue) 719 726 { 720 721 //intret;722 723 724 725 726 727 728 729 730 727 mixerhandle *pHandle = (mixerhandle *)streamid; 728 //int ret; 729 730 if(pHandle == NULL || pHandle->magic != MAGIC_MIXER_ALSA32) { 731 DebugInt3(); 732 return OSSERR_INVALID_STREAMID; 733 } 734 //set operation to non-blocking 735 pHandle->file.f_flags = O_NONBLOCK; 736 737 return OSSERR_NOT_SUPPORTED; 731 738 } 732 739 //****************************************************************************** … … 734 741 ULONG OSSToALSAVolume(ULONG OSSVolIdx) 735 742 { 736 737 738 743 switch(OSSVolIdx) { 744 case OSS_MIXER_VOLUME: 745 return OSS32_MIX_VOLUME_MASTER_FRONT; 739 746 #if 0 740 741 747 case OSS_MIXER_VOLUME: //TODO: 748 return OSS32_MIX_VOLUME_MASTER_REAR; 742 749 #endif 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 750 case OSS_MIXER_PCM: 751 return OSS32_MIX_VOLUME_PCM; 752 case OSS_MIXER_SYNTH: 753 return OSS32_MIX_VOLUME_MIDI; 754 case OSS_MIXER_LINE: 755 return OSS32_MIX_VOLUME_LINEIN; 756 case OSS_MIXER_MIC: 757 return OSS32_MIX_VOLUME_MIC; 758 case OSS_MIXER_CD: 759 return OSS32_MIX_VOLUME_CD; 760 case OSS_MIXER_DIGITAL1: 761 return OSS32_MIX_VOLUME_SPDIF; 762 case OSS_MIXER_VIDEO: 763 return OSS32_MIX_VOLUME_VIDEO; 764 case OSS_MIXER_PCSPEAKER: 765 return OSS32_MIX_VOLUME_PCSPEAKER; 766 case OSS_MIXER_PHONEOUT: 767 return OSS32_MIX_VOLUME_PHONE; 768 case OSS_MIXER_IGAIN: 769 return OSS32_MIX_VOLUME_CAPTURE; 770 case OSS_MIXER_TREBLE: 771 return OSS32_MIX_LEVEL_TREBLE; 772 case OSS_MIXER_BASS: 773 return OSS32_MIX_LEVEL_BASS; 774 case OSS_MIXER_HEADPHONE: 775 return OSS32_MIX_VOLUME_HEADPHONE; 776 case OSS_MIXER_SPEAKER: 777 return OSS32_MIX_VOLUME_SPEAKER; 778 case OSS_MIXER_LINE1: 779 return OSS32_MIX_VOLUME_AUX; 780 } 781 return -1; 775 782 } 776 783 //****************************************************************************** … … 778 785 OSSRET OSS32_MixQueryCaps(OSSSTREAMID streamid, POSS32_MIXCAPS pCaps) 779 786 { 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 787 mixerhandle *pHandle = (mixerhandle *)streamid; 788 int i; 789 790 if(pHandle == NULL || pHandle->magic != MAGIC_MIXER_ALSA32) { 791 DebugInt3(); 792 return OSSERR_INVALID_STREAMID; 793 } 794 795 strncpy(pCaps->name, pHandle->info.mixername, sizeof(pCaps->name)); 796 pCaps->fuCtrlCaps = 0; 797 pCaps->fuRecCaps = 0; 798 799 for(i=0;i<OSS_MIXER_NRDEVICES;i++) 800 { 801 if(pHandle->controls[i].idxVolume != -1) { 802 ULONG volidx = OSSToALSAVolume(i); 803 if(volidx != -1) 804 pCaps->fuCtrlCaps |= OSS32_MIX_FLAG(volidx); 805 } 806 } 807 808 //if it has a capture source control or the card has capture route switches, 809 //then we support intput source selection 810 if(pHandle->controls[OSS_MIXER_IGAIN].idxCustom != -1 || 811 pHandle->rectype == RECTYPE_SWITCH) 812 { 813 pCaps->fuCtrlCaps |= OSS32_MIX_FLAG(OSS32_MIX_INPUTSRC); 814 pCaps->fuRecCaps = pHandle->reccaps; 815 } 816 return OSSERR_SUCCESS; 810 817 } 811 818 //****************************************************************************** … … 813 820 OSSRET OSS32_MixQueryName(ULONG deviceid, char *pszMixerName, ULONG cbMixerName) 814 821 { 815 816 intret;817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 pHandle->file.f_dentry= &pHandle->d_entry;834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 822 mixerhandle *pHandle = NULL; 823 int ret; 824 //int i, j; 825 826 if(alsa_fops == NULL) 827 return OSSERR_NO_DEVICE_AVAILABLE; 828 829 pHandle = kmalloc(sizeof(mixerhandle), GFP_KERNEL); 830 if(pHandle == NULL) { 831 ret = OSSERR_OUT_OF_MEMORY; 832 goto failure; 833 } 834 memset(pHandle, 0, sizeof(mixerhandle)); 835 836 //set operation to non-blocking 837 pHandle->file.f_flags = O_NONBLOCK; 838 839 //setup pointers in file structure (used internally by ALSA) 840 pHandle->file.f_dentry = &pHandle->d_entry; 841 pHandle->file.f_dentry->d_inode = &pHandle->inode; 842 843 pHandle->file.f_mode = FMODE_WRITE; 844 pHandle->inode.i_rdev = SNDRV_MINOR(deviceid, SNDRV_MINOR_CONTROL); 845 846 ret = alsa_fops->open(&pHandle->inode, &pHandle->file); 847 if(ret) { 848 goto failure; 849 } 850 //retrieve mixer information 851 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, 852 SNDRV_CTL_IOCTL_CARD_INFO, 853 (ULONG)&pHandle->info); 854 if(ret) { 855 goto failure; 856 } 857 858 strncpy(pszMixerName, pHandle->info.mixername, cbMixerName); 859 860 pHandle->file.f_flags = O_NONBLOCK; 861 ret = pHandle->file.f_op->release(&pHandle->inode, &pHandle->file); 862 if(ret) { 863 goto failure; 864 } 865 kfree(pHandle); 866 return OSSERR_SUCCESS; 860 867 861 868 failure: 862 863 864 865 866 869 if(pHandle) { 870 kfree(pHandle); 871 } 872 DebugInt3(); 873 return OSSERR_OUT_OF_MEMORY; 867 874 } 868 875 //****************************************************************************** 869 876 //****************************************************************************** 870 877 OSSRET OSS32_QueryNames(ULONG deviceid, char *pszDeviceName, ULONG cbDeviceName, 871 872 { 873 874 intret;875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 pHandle->file.f_dentry= &pHandle->d_entry;895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 // 925 926 927 928 929 930 931 932 933 878 char *pszMixerName, ULONG cbMixerName, BOOL fLongName) 879 { 880 mixerhandle *pHandle = NULL; 881 int ret; 882 //int i, j; 883 884 if(alsa_fops == NULL) { 885 ret = OSSERR_NO_DEVICE_AVAILABLE; 886 printk("ret = OSSERR_NO_DEVICE_AVAILABLE\n"); 887 goto failure; 888 } 889 890 pHandle = kmalloc(sizeof(mixerhandle), GFP_KERNEL); 891 if(pHandle == NULL) { 892 ret = OSSERR_OUT_OF_MEMORY; 893 goto failure; 894 } 895 memset(pHandle, 0, sizeof(mixerhandle)); 896 897 //set operation to non-blocking 898 pHandle->file.f_flags = O_NONBLOCK; 899 900 //setup pointers in file structure (used internally by ALSA) 901 pHandle->file.f_dentry = &pHandle->d_entry; 902 pHandle->file.f_dentry->d_inode = &pHandle->inode; 903 904 pHandle->file.f_mode = FMODE_WRITE; 905 pHandle->inode.i_rdev = SNDRV_MINOR(deviceid, SNDRV_MINOR_CONTROL); 906 907 ret = alsa_fops->open(&pHandle->inode, &pHandle->file); 908 if(ret) { 909 printk("open ret = %i\n", ret); 910 goto failure; 911 } 912 //retrieve mixer information 913 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, 914 SNDRV_CTL_IOCTL_CARD_INFO, 915 (ULONG)&pHandle->info); 916 if(ret) { 917 printk("ioctl ret = %i\n", ret); 918 goto failure; 919 } 920 921 if(pszDeviceName) { 922 if(fLongName == TRUE) { 923 strncpy(pszDeviceName, pHandle->info.longname, cbDeviceName); 924 } 925 else strncpy(pszDeviceName, pHandle->info.name, cbDeviceName); 926 } 927 if(pszMixerName) { 928 strncpy(pszMixerName, pHandle->info.mixername, cbMixerName); 929 } 930 931 // printk("Card: %s with mixer %s\n",pszDeviceName, pszMixerName); 932 933 pHandle->file.f_flags = O_NONBLOCK; 934 ret = pHandle->file.f_op->release(&pHandle->inode, &pHandle->file); 935 if(ret) { 936 printk("release ret = %i\n", ret); 937 goto failure; 938 } 939 kfree(pHandle); 940 return OSSERR_SUCCESS; 934 941 935 942 failure: 936 937 938 939 940 941 942 } 943 //****************************************************************************** 944 //****************************************************************************** 945 943 if(pHandle) { 944 kfree(pHandle); 945 } 946 DebugInt3(); 947 printk("OSS32_QueryNames() ret = %i\n", ret); 948 return OSSERR_OUT_OF_MEMORY; 949 } 950 //****************************************************************************** 951 //****************************************************************************** 952 -
GPL/trunk/uniaud.inc
r602 r604 2 2 3 3 # Product name 4 PRODUCTNAME = Universal Audio Driver for OS/2 and eComStation4 PRODUCTNAME = Universal Audio Driver for OS/2 5 5 6 6 # Full UNIAUD build version 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 39 BUILDVERSION = 2.02.04 10 10 11 11 # Fixpack version
Note:
See TracChangeset
for help on using the changeset viewer.