--- zzzz-none-000/linux-3.10.107/sound/pci/azt3328.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/sound/pci/azt3328.c 2021-02-04 17:41:59.000000000 +0000 @@ -179,7 +179,7 @@ * - use MMIO (memory-mapped I/O)? Slightly faster access, e.g. for gameport. */ -#include +#include #include #include /* WARN_ONCE */ #include @@ -238,61 +238,6 @@ 2>/dev/null */ -#define DEBUG_MISC 0 -#define DEBUG_CALLS 0 -#define DEBUG_MIXER 0 -#define DEBUG_CODEC 0 -#define DEBUG_TIMER 0 -#define DEBUG_GAME 0 -#define DEBUG_PM 0 -#define MIXER_TESTING 0 - -#if DEBUG_MISC -#define snd_azf3328_dbgmisc(format, args...) printk(KERN_DEBUG format, ##args) -#else -#define snd_azf3328_dbgmisc(format, args...) -#endif - -#if DEBUG_CALLS -#define snd_azf3328_dbgcalls(format, args...) printk(format, ##args) -#define snd_azf3328_dbgcallenter() printk(KERN_DEBUG "--> %s\n", __func__) -#define snd_azf3328_dbgcallleave() printk(KERN_DEBUG "<-- %s\n", __func__) -#else -#define snd_azf3328_dbgcalls(format, args...) -#define snd_azf3328_dbgcallenter() -#define snd_azf3328_dbgcallleave() -#endif - -#if DEBUG_MIXER -#define snd_azf3328_dbgmixer(format, args...) printk(KERN_DEBUG format, ##args) -#else -#define snd_azf3328_dbgmixer(format, args...) -#endif - -#if DEBUG_CODEC -#define snd_azf3328_dbgcodec(format, args...) printk(KERN_DEBUG format, ##args) -#else -#define snd_azf3328_dbgcodec(format, args...) -#endif - -#if DEBUG_MISC -#define snd_azf3328_dbgtimer(format, args...) printk(KERN_DEBUG format, ##args) -#else -#define snd_azf3328_dbgtimer(format, args...) -#endif - -#if DEBUG_GAME -#define snd_azf3328_dbggame(format, args...) printk(KERN_DEBUG format, ##args) -#else -#define snd_azf3328_dbggame(format, args...) -#endif - -#if DEBUG_PM -#define snd_azf3328_dbgpm(format, args...) printk(KERN_DEBUG format, ##args) -#else -#define snd_azf3328_dbgpm(format, args...) -#endif - static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ module_param_array(index, int, NULL, 0444); MODULE_PARM_DESC(index, "Index value for AZF3328 soundcard."); @@ -376,7 +321,7 @@ #endif }; -static DEFINE_PCI_DEVICE_TABLE(snd_azf3328_ids) = { +static const struct pci_device_id snd_azf3328_ids[] = { { 0x122D, 0x50DC, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* PCI168/3328 */ { 0x122D, 0x80DA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* 3328 */ { 0, } @@ -475,6 +420,12 @@ return inb(chip->ctrl_io + reg); } +static inline u16 +snd_azf3328_ctrl_inw(const struct snd_azf3328 *chip, unsigned reg) +{ + return inw(chip->ctrl_io + reg); +} + static inline void snd_azf3328_ctrl_outw(const struct snd_azf3328 *chip, unsigned reg, u16 value) { @@ -578,11 +529,12 @@ #ifdef AZF_USE_AC97_LAYER static inline void -snd_azf3328_mixer_ac97_map_unsupported(unsigned short reg, const char *mode) +snd_azf3328_mixer_ac97_map_unsupported(const struct snd_azf3328 *chip, + unsigned short reg, const char *mode) { /* need to add some more or less clever emulation? */ - printk(KERN_WARNING - "azt3328: missing %s emulation for AC97 register 0x%02x!\n", + dev_warn(chip->card->dev, + "missing %s emulation for AC97 register 0x%02x!\n", mode, reg); } @@ -715,14 +667,12 @@ const struct snd_azf3328 *chip = ac97->private_data; unsigned short reg_azf = snd_azf3328_mixer_ac97_map_reg_idx(reg_ac97); unsigned short reg_val = 0; - bool unsupported = 0; + bool unsupported = false; - snd_azf3328_dbgmixer( - "snd_azf3328_mixer_ac97_read reg_ac97 %u\n", - reg_ac97 - ); + dev_dbg(chip->card->dev, "snd_azf3328_mixer_ac97_read reg_ac97 %u\n", + reg_ac97); if (reg_azf & AZF_AC97_REG_UNSUPPORTED) - unsupported = 1; + unsupported = true; else { if (reg_azf & AZF_AC97_REG_REAL_IO_READ) reg_val = snd_azf3328_mixer_inw(chip, @@ -759,13 +709,13 @@ reg_val = azf_emulated_ac97_vendor_id & 0xffff; break; default: - unsupported = 1; + unsupported = true; break; } } } if (unsupported) - snd_azf3328_mixer_ac97_map_unsupported(reg_ac97, "read"); + snd_azf3328_mixer_ac97_map_unsupported(chip, reg_ac97, "read"); return reg_val; } @@ -776,14 +726,13 @@ { const struct snd_azf3328 *chip = ac97->private_data; unsigned short reg_azf = snd_azf3328_mixer_ac97_map_reg_idx(reg_ac97); - bool unsupported = 0; + bool unsupported = false; - snd_azf3328_dbgmixer( + dev_dbg(chip->card->dev, "snd_azf3328_mixer_ac97_write reg_ac97 %u val %u\n", - reg_ac97, val - ); + reg_ac97, val); if (reg_azf & AZF_AC97_REG_UNSUPPORTED) - unsupported = 1; + unsupported = true; else { if (reg_azf & AZF_AC97_REG_REAL_IO_WRITE) snd_azf3328_mixer_outw( @@ -808,13 +757,13 @@ */ break; default: - unsupported = 1; + unsupported = true; break; } } } if (unsupported) - snd_azf3328_mixer_ac97_map_unsupported(reg_ac97, "write"); + snd_azf3328_mixer_ac97_map_unsupported(chip, reg_ac97, "write"); } static int @@ -850,7 +799,7 @@ * due to this card being a very quirky AC97 "lookalike". */ if (rc) - printk(KERN_ERR "azt3328: AC97 init failed, err %d!\n", rc); + dev_err(chip->card->dev, "AC97 init failed, err %d!\n", rc); /* If we return an error here, then snd_card_free() should * free up any ac97 codecs that got created, as well as the bus. @@ -870,8 +819,6 @@ unsigned char curr_vol_left = 0, curr_vol_right = 0; int left_change = 0, right_change = 0; - snd_azf3328_dbgcallenter(); - if (chan_sel & SET_CHAN_LEFT) { curr_vol_left = inb(portbase + 1); @@ -912,7 +859,6 @@ if (delay) mdelay(delay); } while ((left_change) || (right_change)); - snd_azf3328_dbgcallleave(); } /* @@ -990,14 +936,12 @@ { struct azf3328_mixer_reg reg; - snd_azf3328_dbgcallenter(); snd_azf3328_mixer_reg_decode(®, kcontrol->private_value); uinfo->type = reg.mask == 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = reg.stereo + 1; uinfo->value.integer.min = 0; uinfo->value.integer.max = reg.mask; - snd_azf3328_dbgcallleave(); return 0; } @@ -1009,7 +953,6 @@ struct azf3328_mixer_reg reg; u16 oreg, val; - snd_azf3328_dbgcallenter(); snd_azf3328_mixer_reg_decode(®, kcontrol->private_value); oreg = snd_azf3328_mixer_inw(chip, reg.reg); @@ -1023,12 +966,11 @@ val = reg.mask - val; ucontrol->value.integer.value[1] = val; } - snd_azf3328_dbgmixer("get: %02x is %04x -> vol %02lx|%02lx " - "(shift %02d|%02d, mask %02x, inv. %d, stereo %d)\n", + dev_dbg(chip->card->dev, + "get: %02x is %04x -> vol %02lx|%02lx (shift %02d|%02d, mask %02x, inv. %d, stereo %d)\n", reg.reg, oreg, ucontrol->value.integer.value[0], ucontrol->value.integer.value[1], reg.lchan_shift, reg.rchan_shift, reg.mask, reg.invert, reg.stereo); - snd_azf3328_dbgcallleave(); return 0; } @@ -1040,7 +982,6 @@ struct azf3328_mixer_reg reg; u16 oreg, nreg, val; - snd_azf3328_dbgcallenter(); snd_azf3328_mixer_reg_decode(®, kcontrol->private_value); oreg = snd_azf3328_mixer_inw(chip, reg.reg); val = ucontrol->value.integer.value[0] & reg.mask; @@ -1064,12 +1005,11 @@ else snd_azf3328_mixer_outw(chip, reg.reg, nreg); - snd_azf3328_dbgmixer("put: %02x to %02lx|%02lx, " - "oreg %04x; shift %02d|%02d -> nreg %04x; after: %04x\n", + dev_dbg(chip->card->dev, + "put: %02x to %02lx|%02lx, oreg %04x; shift %02d|%02d -> nreg %04x; after: %04x\n", reg.reg, ucontrol->value.integer.value[0], ucontrol->value.integer.value[1], oreg, reg.lchan_shift, reg.rchan_shift, nreg, snd_azf3328_mixer_inw(chip, reg.reg)); - snd_azf3328_dbgcallleave(); return (nreg != oreg); } @@ -1094,11 +1034,6 @@ const char * const *p = NULL; snd_azf3328_mixer_reg_decode(®, kcontrol->private_value); - uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; - uinfo->count = (reg.reg == IDX_MIXER_REC_SELECT) ? 2 : 1; - uinfo->value.enumerated.items = reg.enum_c; - if (uinfo->value.enumerated.item > reg.enum_c - 1U) - uinfo->value.enumerated.item = reg.enum_c - 1U; if (reg.reg == IDX_MIXER_ADVCTL2) { switch(reg.lchan_shift) { case 8: /* modem out sel */ @@ -1111,12 +1046,12 @@ p = texts4; break; } - } else - if (reg.reg == IDX_MIXER_REC_SELECT) + } else if (reg.reg == IDX_MIXER_REC_SELECT) p = texts3; - strcpy(uinfo->value.enumerated.name, p[uinfo->value.enumerated.item]); - return 0; + return snd_ctl_enum_info(uinfo, + (reg.reg == IDX_MIXER_REC_SELECT) ? 2 : 1, + reg.enum_c, p); } static int @@ -1135,7 +1070,8 @@ } else ucontrol->value.enumerated.item[0] = (val >> reg.lchan_shift) & (reg.enum_c - 1); - snd_azf3328_dbgmixer("get_enum: %02x is %04x -> %d|%d (shift %02d, enum_c %d)\n", + dev_dbg(chip->card->dev, + "get_enum: %02x is %04x -> %d|%d (shift %02d, enum_c %d)\n", reg.reg, val, ucontrol->value.enumerated.item[0], ucontrol->value.enumerated.item[1], reg.lchan_shift, reg.enum_c); return 0; @@ -1167,7 +1103,8 @@ snd_azf3328_mixer_outw(chip, reg.reg, val); nreg = val; - snd_azf3328_dbgmixer("put_enum: %02x to %04x, oreg %04x\n", reg.reg, val, oreg); + dev_dbg(chip->card->dev, + "put_enum: %02x to %04x, oreg %04x\n", reg.reg, val, oreg); return (nreg != oreg); } @@ -1253,7 +1190,6 @@ unsigned int idx; int err; - snd_azf3328_dbgcallenter(); if (snd_BUG_ON(!chip || !chip->card)) return -EINVAL; @@ -1279,7 +1215,6 @@ snd_component_add(card, "AZF3328 mixer"); strcpy(card->mixername, "AZF3328 mixer"); - snd_azf3328_dbgcallleave(); return 0; } #endif /* AZF_USE_AC97_LAYER */ @@ -1288,19 +1223,13 @@ snd_azf3328_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { - int res; - snd_azf3328_dbgcallenter(); - res = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); - snd_azf3328_dbgcallleave(); - return res; + return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); } static int snd_azf3328_hw_free(struct snd_pcm_substream *substream) { - snd_azf3328_dbgcallenter(); snd_pcm_lib_free_pages(substream); - snd_azf3328_dbgcallleave(); return 0; } @@ -1315,7 +1244,6 @@ u16 val = 0xff00; u8 freq = 0; - snd_azf3328_dbgcallenter(); switch (bitrate) { case AZF_FREQ_4000: freq = SOUNDFORMAT_FREQ_SUSPECTED_4000; break; case AZF_FREQ_4800: freq = SOUNDFORMAT_FREQ_SUSPECTED_4800; break; @@ -1379,7 +1307,6 @@ ); spin_unlock_irqrestore(codec->lock, flags); - snd_azf3328_dbgcallleave(); } static inline void @@ -1404,15 +1331,16 @@ chip->shadow_reg_ctrl_6AH |= bitmask; else chip->shadow_reg_ctrl_6AH &= ~bitmask; - snd_azf3328_dbgcodec("6AH_update mask 0x%04x do_mask %d: val 0x%04x\n", - bitmask, do_mask, chip->shadow_reg_ctrl_6AH); + dev_dbg(chip->card->dev, + "6AH_update mask 0x%04x do_mask %d: val 0x%04x\n", + bitmask, do_mask, chip->shadow_reg_ctrl_6AH); snd_azf3328_ctrl_outw(chip, IDX_IO_6AH, chip->shadow_reg_ctrl_6AH); } static inline void snd_azf3328_ctrl_enable_codecs(struct snd_azf3328 *chip, bool enable) { - snd_azf3328_dbgcodec("codec_enable %d\n", enable); + dev_dbg(chip->card->dev, "codec_enable %d\n", enable); /* no idea what exactly is being done here, but I strongly assume it's * PM related */ snd_azf3328_ctrl_reg_6AH_update( @@ -1429,7 +1357,7 @@ struct snd_azf3328_codec_data *codec = &chip->codecs[codec_type]; bool need_change = (codec->running != enable); - snd_azf3328_dbgcodec( + dev_dbg(chip->card->dev, "codec_activity: %s codec, enable %d, need_change %d\n", codec->name, enable, need_change ); @@ -1457,8 +1385,8 @@ .running) && (!chip->codecs[peer_codecs[codec_type].other2] .running)); - } - if (call_function) + } + if (call_function) snd_azf3328_ctrl_enable_codecs(chip, enable); /* ...and adjust clock, too @@ -1470,13 +1398,13 @@ } static void -snd_azf3328_codec_setdmaa(struct snd_azf3328_codec_data *codec, - unsigned long addr, - unsigned int period_bytes, - unsigned int buffer_bytes +snd_azf3328_codec_setdmaa(struct snd_azf3328 *chip, + struct snd_azf3328_codec_data *codec, + unsigned long addr, + unsigned int period_bytes, + unsigned int buffer_bytes ) { - snd_azf3328_dbgcallenter(); WARN_ONCE(period_bytes & 1, "odd period length!?\n"); WARN_ONCE(buffer_bytes != 2 * period_bytes, "missed our input expectations! %u vs. %u\n", @@ -1499,7 +1427,7 @@ setup_io.dma_start_1 = addr; setup_io.dma_start_2 = addr+area_length; - snd_azf3328_dbgcodec( + dev_dbg(chip->card->dev, "setdma: buffers %08x[%u] / %08x[%u], %u, %u\n", setup_io.dma_start_1, area_length, setup_io.dma_start_2, area_length, @@ -1522,7 +1450,6 @@ ); spin_unlock_irqrestore(codec->lock, flags); } - snd_azf3328_dbgcallleave(); } static int @@ -1535,8 +1462,6 @@ unsigned int count = snd_pcm_lib_period_bytes(substream); #endif - snd_azf3328_dbgcallenter(); - codec->dma_base = runtime->dma_addr; #if 0 @@ -1544,10 +1469,9 @@ runtime->rate, snd_pcm_format_width(runtime->format), runtime->channels); - snd_azf3328_codec_setdmaa(codec, + snd_azf3328_codec_setdmaa(chip, codec, runtime->dma_addr, count, size); #endif - snd_azf3328_dbgcallleave(); return 0; } @@ -1559,14 +1483,12 @@ struct snd_azf3328_codec_data *codec = runtime->private_data; int result = 0; u16 flags1; - bool previously_muted = 0; + bool previously_muted = false; bool is_main_mixer_playback_codec = (AZF_CODEC_PLAYBACK == codec->type); - snd_azf3328_dbgcalls("snd_azf3328_pcm_trigger cmd %d\n", cmd); - switch (cmd) { case SNDRV_PCM_TRIGGER_START: - snd_azf3328_dbgcodec("START %s\n", codec->name); + dev_dbg(chip->card->dev, "START PCM %s\n", codec->name); if (is_main_mixer_playback_codec) { /* mute WaveOut (avoid clicking during setup) */ @@ -1593,7 +1515,7 @@ snd_azf3328_codec_outw(codec, IDX_IO_CODEC_IRQTYPE, 0xffff); spin_unlock(codec->lock); - snd_azf3328_codec_setdmaa(codec, runtime->dma_addr, + snd_azf3328_codec_setdmaa(chip, codec, runtime->dma_addr, snd_pcm_lib_period_bytes(substream), snd_pcm_lib_buffer_bytes(substream) ); @@ -1633,10 +1555,10 @@ ); } - snd_azf3328_dbgcodec("STARTED %s\n", codec->name); + dev_dbg(chip->card->dev, "PCM STARTED %s\n", codec->name); break; case SNDRV_PCM_TRIGGER_RESUME: - snd_azf3328_dbgcodec("RESUME %s\n", codec->name); + dev_dbg(chip->card->dev, "PCM RESUME %s\n", codec->name); /* resume codec if we were active */ spin_lock(codec->lock); if (codec->running) @@ -1648,7 +1570,7 @@ spin_unlock(codec->lock); break; case SNDRV_PCM_TRIGGER_STOP: - snd_azf3328_dbgcodec("STOP %s\n", codec->name); + dev_dbg(chip->card->dev, "PCM STOP %s\n", codec->name); if (is_main_mixer_playback_codec) { /* mute WaveOut (avoid clicking during setup) */ @@ -1684,10 +1606,10 @@ ); } - snd_azf3328_dbgcodec("STOPPED %s\n", codec->name); + dev_dbg(chip->card->dev, "PCM STOPPED %s\n", codec->name); break; case SNDRV_PCM_TRIGGER_SUSPEND: - snd_azf3328_dbgcodec("SUSPEND %s\n", codec->name); + dev_dbg(chip->card->dev, "PCM SUSPEND %s\n", codec->name); /* make sure codec is stopped */ snd_azf3328_codec_outw(codec, IDX_IO_CODEC_DMA_FLAGS, snd_azf3328_codec_inw( @@ -1696,17 +1618,16 @@ ); break; case SNDRV_PCM_TRIGGER_PAUSE_PUSH: - snd_printk(KERN_ERR "FIXME: SNDRV_PCM_TRIGGER_PAUSE_PUSH NIY!\n"); + WARN(1, "FIXME: SNDRV_PCM_TRIGGER_PAUSE_PUSH NIY!\n"); break; case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: - snd_printk(KERN_ERR "FIXME: SNDRV_PCM_TRIGGER_PAUSE_RELEASE NIY!\n"); + WARN(1, "FIXME: SNDRV_PCM_TRIGGER_PAUSE_RELEASE NIY!\n"); break; default: - snd_printk(KERN_ERR "FIXME: unknown trigger mode!\n"); + WARN(1, "FIXME: unknown trigger mode!\n"); return -EINVAL; } - snd_azf3328_dbgcallleave(); return result; } @@ -1728,8 +1649,8 @@ result -= codec->dma_base; #endif frmres = bytes_to_frames( substream->runtime, result); - snd_azf3328_dbgcodec("%08li %s @ 0x%8lx, frames %8ld\n", - jiffies, codec->name, result, frmres); + dev_dbg(substream->pcm->card->dev, "%08li %s @ 0x%8lx, frames %8ld\n", + jiffies, codec->name, result, frmres); return frmres; } @@ -1792,7 +1713,7 @@ * skeleton handler only * (we do not want axis reading in interrupt handler - too much load!) */ - snd_azf3328_dbggame("gameport irq\n"); + dev_dbg(chip->card->dev, "gameport irq\n"); /* this should ACK the gameport IRQ properly, hopefully. */ snd_azf3328_game_inw(chip, IDX_GAME_AXIS_VALUE); @@ -1804,7 +1725,7 @@ struct snd_azf3328 *chip = gameport_get_port_data(gameport); int res; - snd_azf3328_dbggame("gameport_open, mode %d\n", mode); + dev_dbg(chip->card->dev, "gameport_open, mode %d\n", mode); switch (mode) { case GAMEPORT_MODE_COOKED: case GAMEPORT_MODE_RAW: @@ -1827,7 +1748,7 @@ { struct snd_azf3328 *chip = gameport_get_port_data(gameport); - snd_azf3328_dbggame("gameport_close\n"); + dev_dbg(chip->card->dev, "gameport_close\n"); snd_azf3328_gameport_set_counter_frequency(chip, GAME_HWCFG_ADC_COUNTER_FREQ_1_200); snd_azf3328_gameport_axis_circuit_enable(chip, 0); @@ -1892,9 +1813,8 @@ axes[i] = -1; } - snd_azf3328_dbggame("cooked_read: axes %d %d %d %d buttons %d\n", - axes[0], axes[1], axes[2], axes[3], *buttons - ); + dev_dbg(chip->card->dev, "cooked_read: axes %d %d %d %d buttons %d\n", + axes[0], axes[1], axes[2], axes[3], *buttons); return 0; } @@ -1906,7 +1826,7 @@ chip->gameport = gp = gameport_allocate_port(); if (!gp) { - printk(KERN_ERR "azt3328: cannot alloc memory for gameport\n"); + dev_err(chip->card->dev, "cannot alloc memory for gameport\n"); return -ENOMEM; } @@ -1950,23 +1870,23 @@ static inline void snd_azf3328_gameport_interrupt(struct snd_azf3328 *chip) { - printk(KERN_WARNING "huh, game port IRQ occurred!?\n"); + dev_warn(chip->card->dev, "huh, game port IRQ occurred!?\n"); } #endif /* SUPPORT_GAMEPORT */ /******************************************************************/ static inline void -snd_azf3328_irq_log_unknown_type(u8 which) +snd_azf3328_irq_log_unknown_type(struct snd_azf3328 *chip, u8 which) { - snd_azf3328_dbgcodec( - "azt3328: unknown IRQ type (%x) occurred, please report!\n", - which - ); + dev_dbg(chip->card->dev, + "unknown IRQ type (%x) occurred, please report!\n", + which); } static inline void -snd_azf3328_pcm_interrupt(const struct snd_azf3328_codec_data *first_codec, +snd_azf3328_pcm_interrupt(struct snd_azf3328 *chip, + const struct snd_azf3328_codec_data *first_codec, u8 status ) { @@ -1990,17 +1910,15 @@ if (codec->substream) { snd_pcm_period_elapsed(codec->substream); - snd_azf3328_dbgcodec("%s period done (#%x), @ %x\n", + dev_dbg(chip->card->dev, "%s period done (#%x), @ %x\n", codec->name, which, snd_azf3328_codec_inl( - codec, IDX_IO_CODEC_DMA_CURRPOS - ) - ); + codec, IDX_IO_CODEC_DMA_CURRPOS)); } else - printk(KERN_WARNING "azt3328: irq handler problem!\n"); + dev_warn(chip->card->dev, "irq handler problem!\n"); if (which & IRQ_SOMETHING) - snd_azf3328_irq_log_unknown_type(which); + snd_azf3328_irq_log_unknown_type(chip, which); } } @@ -2009,9 +1927,7 @@ { struct snd_azf3328 *chip = dev_id; u8 status; -#if DEBUG_CODEC static unsigned long irq_count; -#endif status = snd_azf3328_ctrl_inb(chip, IDX_IO_IRQSTATUS); @@ -2022,14 +1938,13 @@ )) return IRQ_NONE; /* must be interrupt for another device */ - snd_azf3328_dbgcodec( + dev_dbg(chip->card->dev, "irq_count %ld! IDX_IO_IRQSTATUS %04x\n", irq_count++ /* debug-only */, - status - ); + status); if (status & IRQ_TIMER) { - /* snd_azf3328_dbgcodec("timer %ld\n", + /* dev_dbg(chip->card->dev, "timer %ld\n", snd_azf3328_codec_inl(chip, IDX_IO_TIMER_VALUE) & TIMER_VALUE_MASK ); */ @@ -2039,11 +1954,11 @@ spin_lock(&chip->reg_lock); snd_azf3328_ctrl_outb(chip, IDX_IO_TIMER_VALUE + 3, 0x07); spin_unlock(&chip->reg_lock); - snd_azf3328_dbgcodec("azt3328: timer IRQ\n"); + dev_dbg(chip->card->dev, "timer IRQ\n"); } if (status & (IRQ_PLAYBACK|IRQ_RECORDING|IRQ_I2S_OUT)) - snd_azf3328_pcm_interrupt(chip->codecs, status); + snd_azf3328_pcm_interrupt(chip, chip->codecs, status); if (status & IRQ_GAMEPORT) snd_azf3328_gameport_interrupt(chip); @@ -2055,7 +1970,7 @@ /* hmm, do we have to ack the IRQ here somehow? * If so, then I don't know how yet... */ - snd_azf3328_dbgcodec("azt3328: MPU401 IRQ\n"); + dev_dbg(chip->card->dev, "MPU401 IRQ\n"); } return IRQ_HANDLED; } @@ -2133,7 +2048,6 @@ struct snd_pcm_runtime *runtime = substream->runtime; struct snd_azf3328_codec_data *codec = &chip->codecs[codec_type]; - snd_azf3328_dbgcallenter(); codec->substream = substream; /* same parameters for all our codecs - at least we think so... */ @@ -2142,7 +2056,6 @@ snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &snd_azf3328_hw_constraints_rates); runtime->private_data = codec; - snd_azf3328_dbgcallleave(); return 0; } @@ -2171,9 +2084,7 @@ struct snd_azf3328_codec_data *codec = substream->runtime->private_data; - snd_azf3328_dbgcallenter(); codec->substream = NULL; - snd_azf3328_dbgcallleave(); return 0; } @@ -2215,13 +2126,12 @@ static int snd_azf3328_pcm(struct snd_azf3328 *chip) { -enum { AZF_PCMDEV_STD, AZF_PCMDEV_I2S_OUT, NUM_AZF_PCMDEVS }; /* pcm devices */ + /* pcm devices */ + enum { AZF_PCMDEV_STD, AZF_PCMDEV_I2S_OUT, NUM_AZF_PCMDEVS }; struct snd_pcm *pcm; int err; - snd_azf3328_dbgcallenter(); - err = snd_pcm_new(chip->card, "AZF3328 DSP", AZF_PCMDEV_STD, 1, 1, &pcm); if (err < 0) @@ -2258,7 +2168,6 @@ snd_dma_pci_data(chip->pci), 64*1024, 64*1024); - snd_azf3328_dbgcallleave(); return 0; } @@ -2281,7 +2190,6 @@ unsigned long flags; unsigned int delay; - snd_azf3328_dbgcallenter(); chip = snd_timer_chip(timer); delay = ((timer->sticks * seqtimer_scaling) - 1) & TIMER_VALUE_MASK; if (delay < 49) { @@ -2289,15 +2197,14 @@ * this timing tweak * (we need to do it to avoid a lockup, though) */ - snd_azf3328_dbgtimer("delay was too low (%d)!\n", delay); + dev_dbg(chip->card->dev, "delay was too low (%d)!\n", delay); delay = 49; /* minimum time is 49 ticks */ } - snd_azf3328_dbgtimer("setting timer countdown value %d\n", delay); + dev_dbg(chip->card->dev, "setting timer countdown value %d\n", delay); delay |= TIMER_COUNTDOWN_ENABLE | TIMER_IRQ_ENABLE; spin_lock_irqsave(&chip->reg_lock, flags); snd_azf3328_ctrl_outl(chip, IDX_IO_TIMER_VALUE, delay); spin_unlock_irqrestore(&chip->reg_lock, flags); - snd_azf3328_dbgcallleave(); return 0; } @@ -2307,7 +2214,6 @@ struct snd_azf3328 *chip; unsigned long flags; - snd_azf3328_dbgcallenter(); chip = snd_timer_chip(timer); spin_lock_irqsave(&chip->reg_lock, flags); /* disable timer countdown and interrupt */ @@ -2319,7 +2225,6 @@ the hardware/ALSA interrupt activity. */ snd_azf3328_ctrl_outb(chip, IDX_IO_TIMER_VALUE + 3, 0x04); spin_unlock_irqrestore(&chip->reg_lock, flags); - snd_azf3328_dbgcallleave(); return 0; } @@ -2328,10 +2233,8 @@ snd_azf3328_timer_precise_resolution(struct snd_timer *timer, unsigned long *num, unsigned long *den) { - snd_azf3328_dbgcallenter(); *num = 1; *den = 1024000 / seqtimer_scaling; - snd_azf3328_dbgcallleave(); return 0; } @@ -2351,7 +2254,6 @@ struct snd_timer_id tid; int err; - snd_azf3328_dbgcallenter(); tid.dev_class = SNDRV_TIMER_CLASS_CARD; tid.dev_sclass = SNDRV_TIMER_SCLASS_NONE; tid.card = chip->card->number; @@ -2376,7 +2278,6 @@ err = 0; out: - snd_azf3328_dbgcallleave(); return err; } @@ -2438,34 +2339,34 @@ static inline void snd_azf3328_debug_show_ports(const struct snd_azf3328 *chip) { -#if DEBUG_MISC u16 tmp; - snd_azf3328_dbgmisc( + dev_dbg(chip->card->dev, "ctrl_io 0x%lx, game_io 0x%lx, mpu_io 0x%lx, " "opl3_io 0x%lx, mixer_io 0x%lx, irq %d\n", chip->ctrl_io, chip->game_io, chip->mpu_io, - chip->opl3_io, chip->mixer_io, chip->irq - ); + chip->opl3_io, chip->mixer_io, chip->irq); - snd_azf3328_dbgmisc("game %02x %02x %02x %02x %02x %02x\n", + dev_dbg(chip->card->dev, + "game %02x %02x %02x %02x %02x %02x\n", snd_azf3328_game_inb(chip, 0), snd_azf3328_game_inb(chip, 1), snd_azf3328_game_inb(chip, 2), snd_azf3328_game_inb(chip, 3), snd_azf3328_game_inb(chip, 4), - snd_azf3328_game_inb(chip, 5) - ); + snd_azf3328_game_inb(chip, 5)); for (tmp = 0; tmp < 0x07; tmp += 1) - snd_azf3328_dbgmisc("mpu_io 0x%04x\n", inb(chip->mpu_io + tmp)); + dev_dbg(chip->card->dev, + "mpu_io 0x%04x\n", inb(chip->mpu_io + tmp)); for (tmp = 0; tmp <= 0x07; tmp += 1) - snd_azf3328_dbgmisc("0x%02x: game200 0x%04x, game208 0x%04x\n", + dev_dbg(chip->card->dev, + "0x%02x: game200 0x%04x, game208 0x%04x\n", tmp, inb(0x200 + tmp), inb(0x208 + tmp)); for (tmp = 0; tmp <= 0x01; tmp += 1) - snd_azf3328_dbgmisc( + dev_dbg(chip->card->dev, "0x%02x: mpu300 0x%04x, mpu310 0x%04x, mpu320 0x%04x, " "mpu330 0x%04x opl388 0x%04x opl38c 0x%04x\n", tmp, @@ -2474,19 +2375,17 @@ inb(0x320 + tmp), inb(0x330 + tmp), inb(0x388 + tmp), - inb(0x38c + tmp) - ); + inb(0x38c + tmp)); for (tmp = 0; tmp < AZF_IO_SIZE_CTRL; tmp += 2) - snd_azf3328_dbgmisc("ctrl 0x%02x: 0x%04x\n", - tmp, snd_azf3328_ctrl_inw(chip, tmp) - ); + dev_dbg(chip->card->dev, + "ctrl 0x%02x: 0x%04x\n", + tmp, snd_azf3328_ctrl_inw(chip, tmp)); for (tmp = 0; tmp < AZF_IO_SIZE_MIXER; tmp += 2) - snd_azf3328_dbgmisc("mixer 0x%02x: 0x%04x\n", - tmp, snd_azf3328_mixer_inw(chip, tmp) - ); -#endif /* DEBUG_MISC */ + dev_dbg(chip->card->dev, + "mixer 0x%02x: 0x%04x\n", + tmp, snd_azf3328_mixer_inw(chip, tmp)); } static int @@ -2521,10 +2420,10 @@ chip->irq = -1; /* check if we can restrict PCI DMA transfers to 24 bits */ - if (pci_set_dma_mask(pci, DMA_BIT_MASK(24)) < 0 || - pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(24)) < 0) { - snd_printk(KERN_ERR "architecture does not support " - "24bit PCI busmaster DMA\n" + if (dma_set_mask(&pci->dev, DMA_BIT_MASK(24)) < 0 || + dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(24)) < 0) { + dev_err(card->dev, + "architecture does not support 24bit PCI busmaster DMA\n" ); err = -ENXIO; goto out_err; @@ -2560,7 +2459,7 @@ if (request_irq(pci->irq, snd_azf3328_interrupt, IRQF_SHARED, KBUILD_MODNAME, chip)) { - snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); + dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq); err = -EBUSY; goto out_err; } @@ -2599,8 +2498,6 @@ spin_unlock_irq(codec->lock); } - snd_card_set_dev(card, &pci->dev); - *rchip = chip; err = 0; @@ -2624,7 +2521,6 @@ struct snd_opl3 *opl3; int err; - snd_azf3328_dbgcallenter(); if (dev >= SNDRV_CARDS) { err = -ENODEV; goto out; @@ -2635,7 +2531,8 @@ goto out; } - err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); + err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, + 0, &card); if (err < 0) goto out; @@ -2657,7 +2554,7 @@ -1, &chip->rmidi ); if (err < 0) { - snd_printk(KERN_ERR "azf3328: no MPU-401 device at 0x%lx?\n", + dev_err(card->dev, "no MPU-401 device at 0x%lx?\n", chip->mpu_io ); goto out_err; @@ -2673,7 +2570,7 @@ if (snd_opl3_create(card, chip->opl3_io, chip->opl3_io+2, OPL3_HW_AUTO, 1, &opl3) < 0) { - snd_printk(KERN_ERR "azf3328: no OPL3 device at 0x%lx-0x%lx?\n", + dev_err(card->dev, "no OPL3 device at 0x%lx-0x%lx?\n", chip->opl3_io, chip->opl3_io+2 ); } else { @@ -2695,12 +2592,15 @@ goto out_err; #ifdef MODULE - printk(KERN_INFO -"azt3328: Sound driver for Aztech AZF3328-based soundcards such as PCI168.\n" -"azt3328: Hardware was completely undocumented, unfortunately.\n" -"azt3328: Feel free to contact andi AT lisas.de for bug reports etc.!\n" -"azt3328: User-scalable sequencer timer set to %dHz (1024000Hz / %d).\n", - 1024000 / seqtimer_scaling, seqtimer_scaling); + dev_info(card->dev, + "Sound driver for Aztech AZF3328-based soundcards such as PCI168.\n"); + dev_info(card->dev, + "Hardware was completely undocumented, unfortunately.\n"); + dev_info(card->dev, + "Feel free to contact andi AT lisas.de for bug reports etc.!\n"); + dev_info(card->dev, + "User-scalable sequencer timer set to %dHz (1024000Hz / %d).\n", + 1024000 / seqtimer_scaling, seqtimer_scaling); #endif snd_azf3328_gameport(chip, dev); @@ -2712,32 +2612,29 @@ goto out; out_err: - snd_printk(KERN_ERR "azf3328: something failed, exiting\n"); + dev_err(card->dev, "something failed, exiting\n"); snd_card_free(card); out: - snd_azf3328_dbgcallleave(); return err; } static void snd_azf3328_remove(struct pci_dev *pci) { - snd_azf3328_dbgcallenter(); snd_card_free(pci_get_drvdata(pci)); - pci_set_drvdata(pci, NULL); - snd_azf3328_dbgcallleave(); } #ifdef CONFIG_PM_SLEEP static inline void -snd_azf3328_suspend_regs(unsigned long io_addr, unsigned count, u32 *saved_regs) +snd_azf3328_suspend_regs(const struct snd_azf3328 *chip, + unsigned long io_addr, unsigned count, u32 *saved_regs) { unsigned reg; for (reg = 0; reg < count; ++reg) { *saved_regs = inl(io_addr); - snd_azf3328_dbgpm("suspend: io 0x%04lx: 0x%08x\n", + dev_dbg(chip->card->dev, "suspend: io 0x%04lx: 0x%08x\n", io_addr, *saved_regs); ++saved_regs; io_addr += sizeof(*saved_regs); @@ -2745,7 +2642,8 @@ } static inline void -snd_azf3328_resume_regs(const u32 *saved_regs, +snd_azf3328_resume_regs(const struct snd_azf3328 *chip, + const u32 *saved_regs, unsigned long io_addr, unsigned count ) @@ -2754,7 +2652,8 @@ for (reg = 0; reg < count; ++reg) { outl(*saved_regs, io_addr); - snd_azf3328_dbgpm("resume: io 0x%04lx: 0x%08x --> 0x%08x\n", + dev_dbg(chip->card->dev, + "resume: io 0x%04lx: 0x%08x --> 0x%08x\n", io_addr, *saved_regs, inl(io_addr)); ++saved_regs; io_addr += sizeof(*saved_regs); @@ -2767,7 +2666,7 @@ #ifdef AZF_USE_AC97_LAYER snd_ac97_suspend(chip->ac97); #else - snd_azf3328_suspend_regs(chip->mixer_io, + snd_azf3328_suspend_regs(chip, chip->mixer_io, ARRAY_SIZE(chip->saved_regs_mixer), chip->saved_regs_mixer); /* make sure to disable master volume etc. to prevent looping sound */ @@ -2782,7 +2681,7 @@ #ifdef AZF_USE_AC97_LAYER snd_ac97_resume(chip->ac97); #else - snd_azf3328_resume_regs(chip->saved_regs_mixer, chip->mixer_io, + snd_azf3328_resume_regs(chip, chip->saved_regs_mixer, chip->mixer_io, ARRAY_SIZE(chip->saved_regs_mixer)); /* unfortunately with 32bit transfers, IDX_MIXER_PLAY_MASTER (0x02) @@ -2796,7 +2695,6 @@ static int snd_azf3328_suspend(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct snd_azf3328 *chip = card->private_data; u16 *saved_regs_ctrl_u16; @@ -2809,53 +2707,38 @@ snd_azf3328_suspend_ac97(chip); - snd_azf3328_suspend_regs(chip->ctrl_io, + snd_azf3328_suspend_regs(chip, chip->ctrl_io, ARRAY_SIZE(chip->saved_regs_ctrl), chip->saved_regs_ctrl); /* manually store the one currently relevant write-only reg, too */ saved_regs_ctrl_u16 = (u16 *)chip->saved_regs_ctrl; saved_regs_ctrl_u16[IDX_IO_6AH / 2] = chip->shadow_reg_ctrl_6AH; - snd_azf3328_suspend_regs(chip->game_io, + snd_azf3328_suspend_regs(chip, chip->game_io, ARRAY_SIZE(chip->saved_regs_game), chip->saved_regs_game); - snd_azf3328_suspend_regs(chip->mpu_io, + snd_azf3328_suspend_regs(chip, chip->mpu_io, ARRAY_SIZE(chip->saved_regs_mpu), chip->saved_regs_mpu); - snd_azf3328_suspend_regs(chip->opl3_io, + snd_azf3328_suspend_regs(chip, chip->opl3_io, ARRAY_SIZE(chip->saved_regs_opl3), chip->saved_regs_opl3); - - pci_disable_device(pci); - pci_save_state(pci); - pci_set_power_state(pci, PCI_D3hot); return 0; } static int snd_azf3328_resume(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); const struct snd_azf3328 *chip = card->private_data; - pci_set_power_state(pci, PCI_D0); - pci_restore_state(pci); - if (pci_enable_device(pci) < 0) { - printk(KERN_ERR "azt3328: pci_enable_device failed, " - "disabling device\n"); - snd_card_disconnect(card); - return -EIO; - } - pci_set_master(pci); - - snd_azf3328_resume_regs(chip->saved_regs_game, chip->game_io, + snd_azf3328_resume_regs(chip, chip->saved_regs_game, chip->game_io, ARRAY_SIZE(chip->saved_regs_game)); - snd_azf3328_resume_regs(chip->saved_regs_mpu, chip->mpu_io, + snd_azf3328_resume_regs(chip, chip->saved_regs_mpu, chip->mpu_io, ARRAY_SIZE(chip->saved_regs_mpu)); - snd_azf3328_resume_regs(chip->saved_regs_opl3, chip->opl3_io, + snd_azf3328_resume_regs(chip, chip->saved_regs_opl3, chip->opl3_io, ARRAY_SIZE(chip->saved_regs_opl3)); snd_azf3328_resume_ac97(chip); - snd_azf3328_resume_regs(chip->saved_regs_ctrl, chip->ctrl_io, + snd_azf3328_resume_regs(chip, chip->saved_regs_ctrl, chip->ctrl_io, ARRAY_SIZE(chip->saved_regs_ctrl)); snd_power_change_state(card, SNDRV_CTL_POWER_D0);