X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sound%2Fpci%2Fcs46xx%2Fcs46xx_lib.c;h=69dbf542a6de20a62405c7be4916c17ce7241659;hb=43bc926fffd92024b46cafaf7350d669ba9ca884;hp=9a1758396395b0ee487376ddd3f28802224c2054;hpb=9213980e6a70d8473e0ffd4b39ab5b6caaba9ff5;p=linux-2.6.git diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c index 9a1758396..69dbf542a 100644 --- a/sound/pci/cs46xx/cs46xx_lib.c +++ b/sound/pci/cs46xx/cs46xx_lib.c @@ -53,6 +53,8 @@ #include #include #include +#include + #include #include @@ -66,9 +68,23 @@ #include "cs46xx_lib.h" #include "dsp_spos.h" -static void amp_voyetra(cs46xx_t *chip, int change); +static void amp_voyetra(struct snd_cs46xx *chip, int change); + +#ifdef CONFIG_SND_CS46XX_NEW_DSP +static struct snd_pcm_ops snd_cs46xx_playback_rear_ops; +static struct snd_pcm_ops snd_cs46xx_playback_indirect_rear_ops; +static struct snd_pcm_ops snd_cs46xx_playback_clfe_ops; +static struct snd_pcm_ops snd_cs46xx_playback_indirect_clfe_ops; +static struct snd_pcm_ops snd_cs46xx_playback_iec958_ops; +static struct snd_pcm_ops snd_cs46xx_playback_indirect_iec958_ops; +#endif + +static struct snd_pcm_ops snd_cs46xx_playback_ops; +static struct snd_pcm_ops snd_cs46xx_playback_indirect_ops; +static struct snd_pcm_ops snd_cs46xx_capture_ops; +static struct snd_pcm_ops snd_cs46xx_capture_indirect_ops; -static unsigned short snd_cs46xx_codec_read(cs46xx_t *chip, +static unsigned short snd_cs46xx_codec_read(struct snd_cs46xx *chip, unsigned short reg, int codec_index) { @@ -79,6 +95,8 @@ static unsigned short snd_cs46xx_codec_read(cs46xx_t *chip, (codec_index == CS46XX_SECONDARY_CODEC_INDEX), return -EINVAL); + chip->active_ctrl(chip, 1); + if (codec_index == CS46XX_SECONDARY_CODEC_INDEX) offset = CS46XX_SECONDARY_CODEC_OFFSET; @@ -97,7 +115,7 @@ static unsigned short snd_cs46xx_codec_read(cs46xx_t *chip, if ((tmp & ACCTL_VFRM) == 0) { snd_printk(KERN_WARNING "cs46xx: ACCTL_VFRM not set 0x%x\n",tmp); snd_cs46xx_pokeBA0(chip, BA0_ACCTL, (tmp & (~ACCTL_ESYN)) | ACCTL_VFRM ); - mdelay(50); + msleep(50); tmp = snd_cs46xx_peekBA0(chip, BA0_ACCTL + offset); snd_cs46xx_pokeBA0(chip, BA0_ACCTL, tmp | ACCTL_ESYN | ACCTL_VFRM ); @@ -147,7 +165,7 @@ static unsigned short snd_cs46xx_codec_read(cs46xx_t *chip, goto ok1; } - snd_printk("AC'97 read problem (ACCTL_DCV), reg = 0x%x\n", reg); + snd_printk(KERN_ERR "AC'97 read problem (ACCTL_DCV), reg = 0x%x\n", reg); result = 0xffff; goto end; @@ -166,7 +184,7 @@ static unsigned short snd_cs46xx_codec_read(cs46xx_t *chip, udelay(10); } - snd_printk("AC'97 read problem (ACSTS_VSTS), codec_index %d, reg = 0x%x\n", codec_index, reg); + snd_printk(KERN_ERR "AC'97 read problem (ACSTS_VSTS), codec_index %d, reg = 0x%x\n", codec_index, reg); result = 0xffff; goto end; @@ -184,39 +202,28 @@ static unsigned short snd_cs46xx_codec_read(cs46xx_t *chip, //snd_cs46xx_peekBA0(chip, BA0_ACCAD); result = snd_cs46xx_peekBA0(chip, BA0_ACSDA + offset); end: + chip->active_ctrl(chip, -1); return result; } -static unsigned short snd_cs46xx_ac97_read(ac97_t * ac97, +static unsigned short snd_cs46xx_ac97_read(struct snd_ac97 * ac97, unsigned short reg) { - cs46xx_t *chip = snd_magic_cast(cs46xx_t, ac97->private_data, return -ENXIO); + struct snd_cs46xx *chip = ac97->private_data; unsigned short val; - int codec_index = -1; - - /* UGGLY: nr_ac97_codecs == 0 primery codec detection is in progress */ - if (ac97 == chip->ac97[CS46XX_PRIMARY_CODEC_INDEX] || chip->nr_ac97_codecs == 0) - codec_index = CS46XX_PRIMARY_CODEC_INDEX; - /* UGGLY: nr_ac97_codecs == 1 secondary codec detection is in progress */ - else if (ac97 == chip->ac97[CS46XX_SECONDARY_CODEC_INDEX] || chip->nr_ac97_codecs == 1) - codec_index = CS46XX_SECONDARY_CODEC_INDEX; - else - snd_assert(0, return 0xffff); - chip->active_ctrl(chip, 1); - val = snd_cs46xx_codec_read(chip, reg, codec_index); - chip->active_ctrl(chip, -1); + int codec_index = ac97->num; - /* HACK: voyetra uses EAPD bit in the reverse way. - * we flip the bit to show the mixer status correctly - */ - if (reg == AC97_POWERDOWN && chip->amplifier_ctrl == amp_voyetra) - val ^= 0x8000; + snd_assert(codec_index == CS46XX_PRIMARY_CODEC_INDEX || + codec_index == CS46XX_SECONDARY_CODEC_INDEX, + return 0xffff); + + val = snd_cs46xx_codec_read(chip, reg, codec_index); return val; } -static void snd_cs46xx_codec_write(cs46xx_t *chip, +static void snd_cs46xx_codec_write(struct snd_cs46xx *chip, unsigned short reg, unsigned short val, int codec_index) @@ -227,6 +234,8 @@ static void snd_cs46xx_codec_write(cs46xx_t *chip, (codec_index == CS46XX_SECONDARY_CODEC_INDEX), return); + chip->active_ctrl(chip, 1); + /* * 1. Write ACCAD = Command Address Register = 46Ch for AC97 register address * 2. Write ACCDA = Command Data Register = 470h for data to write to AC97 @@ -271,37 +280,26 @@ static void snd_cs46xx_codec_write(cs46xx_t *chip, * ACCTL = 460h, DCV should be reset by now and 460h = 07h */ if (!(snd_cs46xx_peekBA0(chip, BA0_ACCTL) & ACCTL_DCV)) { - return; + goto end; } } - snd_printk("AC'97 write problem, codec_index = %d, reg = 0x%x, val = 0x%x\n", codec_index, reg, val); + snd_printk(KERN_ERR "AC'97 write problem, codec_index = %d, reg = 0x%x, val = 0x%x\n", codec_index, reg, val); + end: + chip->active_ctrl(chip, -1); } -static void snd_cs46xx_ac97_write(ac97_t *ac97, +static void snd_cs46xx_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short val) { - cs46xx_t *chip = snd_magic_cast(cs46xx_t, ac97->private_data, return); - int codec_index = -1; + struct snd_cs46xx *chip = ac97->private_data; + int codec_index = ac97->num; - /* UGGLY: nr_ac97_codecs == 0 primery codec detection is in progress */ - if (ac97 == chip->ac97[CS46XX_PRIMARY_CODEC_INDEX] || chip->nr_ac97_codecs == 0) - codec_index = CS46XX_PRIMARY_CODEC_INDEX; - /* UGGLY: nr_ac97_codecs == 1 secondary codec detection is in progress */ - else if (ac97 == chip->ac97[CS46XX_SECONDARY_CODEC_INDEX] || chip->nr_ac97_codecs == 1) - codec_index = CS46XX_SECONDARY_CODEC_INDEX; - else - snd_assert(0,return); - - /* HACK: voyetra uses EAPD bit in the reverse way. - * we flip the bit to show the mixer status correctly - */ - if (reg == AC97_POWERDOWN && chip->amplifier_ctrl == amp_voyetra) - val ^= 0x8000; + snd_assert(codec_index == CS46XX_PRIMARY_CODEC_INDEX || + codec_index == CS46XX_SECONDARY_CODEC_INDEX, + return); - chip->active_ctrl(chip, 1); snd_cs46xx_codec_write(chip, reg, val, codec_index); - chip->active_ctrl(chip, -1); } @@ -309,12 +307,12 @@ static void snd_cs46xx_ac97_write(ac97_t *ac97, * Chip initialization */ -int snd_cs46xx_download(cs46xx_t *chip, +int snd_cs46xx_download(struct snd_cs46xx *chip, u32 *src, unsigned long offset, unsigned long len) { - unsigned long dst; + void __iomem *dst; unsigned int bank = offset >> 16; offset = offset & 0xffff; @@ -338,11 +336,11 @@ int snd_cs46xx_download(cs46xx_t *chip, #include "imgs/cwcbinhack.h" #include "imgs/cwcdma.h" -int snd_cs46xx_clear_BA1(cs46xx_t *chip, +int snd_cs46xx_clear_BA1(struct snd_cs46xx *chip, unsigned long offset, unsigned long len) { - unsigned long dst; + void __iomem *dst; unsigned int bank = offset >> 16; offset = offset & 0xffff; @@ -362,7 +360,7 @@ int snd_cs46xx_clear_BA1(cs46xx_t *chip, #include "cs46xx_image.h" -int snd_cs46xx_download_image(cs46xx_t *chip) +int snd_cs46xx_download_image(struct snd_cs46xx *chip) { int idx, err; unsigned long offset = 0; @@ -383,7 +381,7 @@ int snd_cs46xx_download_image(cs46xx_t *chip) * Chip reset */ -static void snd_cs46xx_reset(cs46xx_t *chip) +static void snd_cs46xx_reset(struct snd_cs46xx *chip) { int idx; @@ -412,7 +410,7 @@ static void snd_cs46xx_reset(cs46xx_t *chip) snd_cs46xx_poke(chip, BA1_FRMT, 0xadf); } -static int cs46xx_wait_for_fifo(cs46xx_t * chip,int retry_timeout) +static int cs46xx_wait_for_fifo(struct snd_cs46xx * chip,int retry_timeout) { u32 i, status = 0; /* @@ -436,7 +434,7 @@ static int cs46xx_wait_for_fifo(cs46xx_t * chip,int retry_timeout) return 0; } -static void snd_cs46xx_clear_serial_FIFOs(cs46xx_t *chip) +static void snd_cs46xx_clear_serial_FIFOs(struct snd_cs46xx *chip) { int idx, powerdown = 0; unsigned int tmp; @@ -490,7 +488,7 @@ static void snd_cs46xx_clear_serial_FIFOs(cs46xx_t *chip) snd_cs46xx_pokeBA0(chip, BA0_CLKCR1, tmp); } -static void snd_cs46xx_proc_start(cs46xx_t *chip) +static void snd_cs46xx_proc_start(struct snd_cs46xx *chip) { int cnt; @@ -514,10 +512,10 @@ static void snd_cs46xx_proc_start(cs46xx_t *chip) } if (snd_cs46xx_peek(chip, BA1_SPCR) & SPCR_RUNFR) - snd_printk("SPCR_RUNFR never reset\n"); + snd_printk(KERN_ERR "SPCR_RUNFR never reset\n"); } -static void snd_cs46xx_proc_stop(cs46xx_t *chip) +static void snd_cs46xx_proc_stop(struct snd_cs46xx *chip) { /* * Turn off the run, run at frame, and DMA enable bits in the local copy of @@ -532,7 +530,7 @@ static void snd_cs46xx_proc_stop(cs46xx_t *chip) #define GOF_PER_SEC 200 -static void snd_cs46xx_set_play_sample_rate(cs46xx_t *chip, unsigned int rate) +static void snd_cs46xx_set_play_sample_rate(struct snd_cs46xx *chip, unsigned int rate) { unsigned long flags; unsigned int tmp1, tmp2; @@ -578,7 +576,7 @@ static void snd_cs46xx_set_play_sample_rate(cs46xx_t *chip, unsigned int rate) spin_unlock_irqrestore(&chip->reg_lock, flags); } -static void snd_cs46xx_set_capture_sample_rate(cs46xx_t *chip, unsigned int rate) +static void snd_cs46xx_set_capture_sample_rate(struct snd_cs46xx *chip, unsigned int rate) { unsigned long flags; unsigned int phiIncr, coeffIncr, tmp1, tmp2; @@ -688,92 +686,43 @@ static void snd_cs46xx_set_capture_sample_rate(cs46xx_t *chip, unsigned int rate * PCM part */ -static int snd_cs46xx_playback_transfer(snd_pcm_substream_t *substream) -{ - /* cs46xx_t *chip = snd_pcm_substream_chip(substream); */ - snd_pcm_runtime_t *runtime = substream->runtime; - cs46xx_pcm_t * cpcm = snd_magic_cast(cs46xx_pcm_t, runtime->private_data, return -ENXIO); - snd_pcm_uframes_t appl_ptr = runtime->control->appl_ptr; - snd_pcm_sframes_t diff = appl_ptr - cpcm->appl_ptr; - int buffer_size = runtime->period_size * CS46XX_FRAGS << cpcm->shift; - - if (diff) { - if (diff < -(snd_pcm_sframes_t) (runtime->boundary / 2)) - diff += runtime->boundary; - cpcm->sw_ready += diff * (1 << cpcm->shift); - cpcm->appl_ptr = appl_ptr; - } - while (cpcm->hw_ready < buffer_size && - cpcm->sw_ready > 0) { - size_t hw_to_end = buffer_size - cpcm->hw_data; - size_t sw_to_end = cpcm->sw_bufsize - cpcm->sw_data; - size_t bytes = buffer_size - cpcm->hw_ready; - if (cpcm->sw_ready < (int)bytes) - bytes = cpcm->sw_ready; - if (hw_to_end < bytes) - bytes = hw_to_end; - if (sw_to_end < bytes) - bytes = sw_to_end; - memcpy(cpcm->hw_buf.area + cpcm->hw_data, - runtime->dma_area + cpcm->sw_data, - bytes); - cpcm->hw_data += bytes; - if ((int)cpcm->hw_data == buffer_size) - cpcm->hw_data = 0; - cpcm->sw_data += bytes; - if (cpcm->sw_data == cpcm->sw_bufsize) - cpcm->sw_data = 0; - cpcm->hw_ready += bytes; - cpcm->sw_ready -= bytes; - } +static void snd_cs46xx_pb_trans_copy(struct snd_pcm_substream *substream, + struct snd_pcm_indirect *rec, size_t bytes) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_cs46xx_pcm * cpcm = runtime->private_data; + memcpy(cpcm->hw_buf.area + rec->hw_data, runtime->dma_area + rec->sw_data, bytes); +} + +static int snd_cs46xx_playback_transfer(struct snd_pcm_substream *substream) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_cs46xx_pcm * cpcm = runtime->private_data; + snd_pcm_indirect_playback_transfer(substream, &cpcm->pcm_rec, snd_cs46xx_pb_trans_copy); return 0; } -static int snd_cs46xx_capture_transfer(snd_pcm_substream_t *substream) -{ - cs46xx_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - snd_pcm_uframes_t appl_ptr = runtime->control->appl_ptr; - snd_pcm_sframes_t diff = appl_ptr - chip->capt.appl_ptr; - int buffer_size = runtime->period_size * CS46XX_FRAGS << chip->capt.shift; - - if (diff) { - if (diff < -(snd_pcm_sframes_t) (runtime->boundary / 2)) - diff += runtime->boundary; - chip->capt.sw_ready -= diff * (1 << chip->capt.shift); - chip->capt.appl_ptr = appl_ptr; - } - while (chip->capt.hw_ready > 0 && - chip->capt.sw_ready < (int)chip->capt.sw_bufsize) { - size_t hw_to_end = buffer_size - chip->capt.hw_data; - size_t sw_to_end = chip->capt.sw_bufsize - chip->capt.sw_data; - size_t bytes = chip->capt.sw_bufsize - chip->capt.sw_ready; - if (chip->capt.hw_ready < (int)bytes) - bytes = chip->capt.hw_ready; - if (hw_to_end < bytes) - bytes = hw_to_end; - if (sw_to_end < bytes) - bytes = sw_to_end; - memcpy(runtime->dma_area + chip->capt.sw_data, - chip->capt.hw_buf.area + chip->capt.hw_data, - bytes); - chip->capt.hw_data += bytes; - if ((int)chip->capt.hw_data == buffer_size) - chip->capt.hw_data = 0; - chip->capt.sw_data += bytes; - if (chip->capt.sw_data == chip->capt.sw_bufsize) - chip->capt.sw_data = 0; - chip->capt.hw_ready -= bytes; - chip->capt.sw_ready += bytes; - } +static void snd_cs46xx_cp_trans_copy(struct snd_pcm_substream *substream, + struct snd_pcm_indirect *rec, size_t bytes) +{ + struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + memcpy(runtime->dma_area + rec->sw_data, + chip->capt.hw_buf.area + rec->hw_data, bytes); +} + +static int snd_cs46xx_capture_transfer(struct snd_pcm_substream *substream) +{ + struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); + snd_pcm_indirect_capture_transfer(substream, &chip->capt.pcm_rec, snd_cs46xx_cp_trans_copy); return 0; } -static snd_pcm_uframes_t snd_cs46xx_playback_direct_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_cs46xx_playback_direct_pointer(struct snd_pcm_substream *substream) { - cs46xx_t *chip = snd_pcm_substream_chip(substream); + struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); size_t ptr; - cs46xx_pcm_t *cpcm = snd_magic_cast(cs46xx_pcm_t, substream->runtime->private_data, return -ENXIO); + struct snd_cs46xx_pcm *cpcm = substream->runtime->private_data; snd_assert (cpcm->pcm_channel,return -ENXIO); #ifdef CONFIG_SND_CS46XX_NEW_DSP @@ -785,13 +734,11 @@ static snd_pcm_uframes_t snd_cs46xx_playback_direct_pointer(snd_pcm_substream_t return ptr >> cpcm->shift; } -static snd_pcm_uframes_t snd_cs46xx_playback_indirect_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_cs46xx_playback_indirect_pointer(struct snd_pcm_substream *substream) { - cs46xx_t *chip = snd_pcm_substream_chip(substream); + struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); size_t ptr; - cs46xx_pcm_t *cpcm = snd_magic_cast(cs46xx_pcm_t, substream->runtime->private_data, return -ENXIO); - ssize_t bytes; - int buffer_size = substream->runtime->period_size * CS46XX_FRAGS << cpcm->shift; + struct snd_cs46xx_pcm *cpcm = substream->runtime->private_data; #ifdef CONFIG_SND_CS46XX_NEW_DSP snd_assert (cpcm->pcm_channel,return -ENXIO); @@ -800,60 +747,32 @@ static snd_pcm_uframes_t snd_cs46xx_playback_indirect_pointer(snd_pcm_substream_ ptr = snd_cs46xx_peek(chip, BA1_PBA); #endif ptr -= cpcm->hw_buf.addr; - - bytes = ptr - cpcm->hw_io; - - if (bytes < 0) - bytes += buffer_size; - cpcm->hw_io = ptr; - cpcm->hw_ready -= bytes; - cpcm->sw_io += bytes; - if (cpcm->sw_io >= cpcm->sw_bufsize) - cpcm->sw_io -= cpcm->sw_bufsize; - snd_cs46xx_playback_transfer(substream); - return cpcm->sw_io >> cpcm->shift; + return snd_pcm_indirect_playback_pointer(substream, &cpcm->pcm_rec, ptr); } -static snd_pcm_uframes_t snd_cs46xx_capture_direct_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_cs46xx_capture_direct_pointer(struct snd_pcm_substream *substream) { - cs46xx_t *chip = snd_pcm_substream_chip(substream); + struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); size_t ptr = snd_cs46xx_peek(chip, BA1_CBA) - chip->capt.hw_buf.addr; return ptr >> chip->capt.shift; } -static snd_pcm_uframes_t snd_cs46xx_capture_indirect_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_cs46xx_capture_indirect_pointer(struct snd_pcm_substream *substream) { - cs46xx_t *chip = snd_pcm_substream_chip(substream); + struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); size_t ptr = snd_cs46xx_peek(chip, BA1_CBA) - chip->capt.hw_buf.addr; - ssize_t bytes = ptr - chip->capt.hw_io; - int buffer_size = substream->runtime->period_size * CS46XX_FRAGS << chip->capt.shift; - - if (bytes < 0) - bytes += buffer_size; - chip->capt.hw_io = ptr; - chip->capt.hw_ready += bytes; - chip->capt.sw_io += bytes; - if (chip->capt.sw_io >= chip->capt.sw_bufsize) - chip->capt.sw_io -= chip->capt.sw_bufsize; - snd_cs46xx_capture_transfer(substream); - return chip->capt.sw_io >> chip->capt.shift; + return snd_pcm_indirect_capture_pointer(substream, &chip->capt.pcm_rec, ptr); } -static int snd_cs46xx_playback_trigger(snd_pcm_substream_t * substream, +static int snd_cs46xx_playback_trigger(struct snd_pcm_substream *substream, int cmd) { - cs46xx_t *chip = snd_pcm_substream_chip(substream); - /*snd_pcm_runtime_t *runtime = substream->runtime;*/ + struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); + /*struct snd_pcm_runtime *runtime = substream->runtime;*/ int result = 0; #ifdef CONFIG_SND_CS46XX_NEW_DSP - cs46xx_pcm_t *cpcm = snd_magic_cast(cs46xx_pcm_t, substream->runtime->private_data, return -ENXIO); -#else - spin_lock(&chip->reg_lock); -#endif - -#ifdef CONFIG_SND_CS46XX_NEW_DSP - + struct snd_cs46xx_pcm *cpcm = substream->runtime->private_data; if (! cpcm->pcm_channel) { return -ENXIO; } @@ -872,6 +791,7 @@ static int snd_cs46xx_playback_trigger(snd_pcm_substream_t * substream, if (substream->runtime->periods != CS46XX_FRAGS) snd_cs46xx_playback_transfer(substream); #else + spin_lock(&chip->reg_lock); if (substream->runtime->periods != CS46XX_FRAGS) snd_cs46xx_playback_transfer(substream); { unsigned int tmp; @@ -879,6 +799,7 @@ static int snd_cs46xx_playback_trigger(snd_pcm_substream_t * substream, tmp &= 0x0000ffff; snd_cs46xx_poke(chip, BA1_PCTL, chip->play_ctl | tmp); } + spin_unlock(&chip->reg_lock); #endif break; case SNDRV_PCM_TRIGGER_STOP: @@ -891,11 +812,13 @@ static int snd_cs46xx_playback_trigger(snd_pcm_substream_t * substream, if (!cpcm->pcm_channel->unlinked) cs46xx_dsp_pcm_unlink(chip,cpcm->pcm_channel); #else + spin_lock(&chip->reg_lock); { unsigned int tmp; tmp = snd_cs46xx_peek(chip, BA1_PCTL); tmp &= 0x0000ffff; snd_cs46xx_poke(chip, BA1_PCTL, tmp); } + spin_unlock(&chip->reg_lock); #endif break; default: @@ -903,17 +826,13 @@ static int snd_cs46xx_playback_trigger(snd_pcm_substream_t * substream, break; } -#ifndef CONFIG_SND_CS46XX_NEW_DSP - spin_unlock(&chip->reg_lock); -#endif - return result; } -static int snd_cs46xx_capture_trigger(snd_pcm_substream_t * substream, +static int snd_cs46xx_capture_trigger(struct snd_pcm_substream *substream, int cmd) { - cs46xx_t *chip = snd_pcm_substream_chip(substream); + struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); unsigned int tmp; int result = 0; @@ -941,7 +860,7 @@ static int snd_cs46xx_capture_trigger(snd_pcm_substream_t * substream, } #ifdef CONFIG_SND_CS46XX_NEW_DSP -static int _cs46xx_adjust_sample_rate (cs46xx_t *chip, cs46xx_pcm_t *cpcm, +static int _cs46xx_adjust_sample_rate (struct snd_cs46xx *chip, struct snd_cs46xx_pcm *cpcm, int sample_rate) { @@ -976,38 +895,38 @@ static int _cs46xx_adjust_sample_rate (cs46xx_t *chip, cs46xx_pcm_t *cpcm, #endif -static int snd_cs46xx_playback_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_cs46xx_playback_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - snd_pcm_runtime_t *runtime = substream->runtime; - cs46xx_pcm_t *cpcm; + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_cs46xx_pcm *cpcm; int err; #ifdef CONFIG_SND_CS46XX_NEW_DSP - cs46xx_t *chip = snd_pcm_substream_chip(substream); + struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); int sample_rate = params_rate(hw_params); int period_size = params_period_bytes(hw_params); #endif - cpcm = snd_magic_cast(cs46xx_pcm_t, runtime->private_data, return -ENXIO); + cpcm = runtime->private_data; #ifdef CONFIG_SND_CS46XX_NEW_DSP snd_assert (sample_rate != 0, return -ENXIO); - down (&chip->spos_mutex); + mutex_lock(&chip->spos_mutex); if (_cs46xx_adjust_sample_rate (chip,cpcm,sample_rate)) { - up (&chip->spos_mutex); + mutex_unlock(&chip->spos_mutex); return -ENXIO; } snd_assert (cpcm->pcm_channel != NULL); if (!cpcm->pcm_channel) { - up (&chip->spos_mutex); + mutex_unlock(&chip->spos_mutex); return -ENXIO; } if (cs46xx_dsp_pcm_channel_set_period (chip,cpcm->pcm_channel,period_size)) { - up (&chip->spos_mutex); + mutex_unlock(&chip->spos_mutex); return -EINVAL; } @@ -1048,7 +967,7 @@ static int snd_cs46xx_playback_hw_params(snd_pcm_substream_t * substream, } if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) { #ifdef CONFIG_SND_CS46XX_NEW_DSP - up (&chip->spos_mutex); + mutex_unlock(&chip->spos_mutex); #endif return err; } @@ -1072,19 +991,19 @@ static int snd_cs46xx_playback_hw_params(snd_pcm_substream_t * substream, } #ifdef CONFIG_SND_CS46XX_NEW_DSP - up (&chip->spos_mutex); + mutex_unlock(&chip->spos_mutex); #endif return 0; } -static int snd_cs46xx_playback_hw_free(snd_pcm_substream_t * substream) +static int snd_cs46xx_playback_hw_free(struct snd_pcm_substream *substream) { - /*cs46xx_t *chip = snd_pcm_substream_chip(substream);*/ - snd_pcm_runtime_t *runtime = substream->runtime; - cs46xx_pcm_t *cpcm; + /*struct snd_cs46xx *chip = snd_pcm_substream_chip(substream);*/ + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_cs46xx_pcm *cpcm; - cpcm = snd_magic_cast(cs46xx_pcm_t, runtime->private_data, return -ENXIO); + cpcm = runtime->private_data; /* if play_back open fails, then this function is called and cpcm can actually be NULL here */ @@ -1100,15 +1019,15 @@ static int snd_cs46xx_playback_hw_free(snd_pcm_substream_t * substream) return 0; } -static int snd_cs46xx_playback_prepare(snd_pcm_substream_t * substream) +static int snd_cs46xx_playback_prepare(struct snd_pcm_substream *substream) { unsigned int tmp; unsigned int pfie; - cs46xx_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - cs46xx_pcm_t *cpcm; + struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_cs46xx_pcm *cpcm; - cpcm = snd_magic_cast(cs46xx_pcm_t, runtime->private_data, return -ENXIO); + cpcm = runtime->private_data; #ifdef CONFIG_SND_CS46XX_NEW_DSP snd_assert (cpcm->pcm_channel != NULL, return -ENXIO); @@ -1143,10 +1062,9 @@ static int snd_cs46xx_playback_prepare(snd_pcm_substream_t * substream) pfie |= 0x00004000; } - cpcm->sw_bufsize = snd_pcm_lib_buffer_bytes(substream); - cpcm->sw_data = cpcm->sw_io = cpcm->sw_ready = 0; - cpcm->hw_data = cpcm->hw_io = cpcm->hw_ready = 0; - cpcm->appl_ptr = 0; + memset(&cpcm->pcm_rec, 0, sizeof(cpcm->pcm_rec)); + cpcm->pcm_rec.sw_buffer_size = snd_pcm_lib_buffer_bytes(substream); + cpcm->pcm_rec.hw_buffer_size = runtime->period_size * CS46XX_FRAGS << cpcm->shift; #ifdef CONFIG_SND_CS46XX_NEW_DSP @@ -1171,11 +1089,11 @@ static int snd_cs46xx_playback_prepare(snd_pcm_substream_t * substream) return 0; } -static int snd_cs46xx_capture_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_cs46xx_capture_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - cs46xx_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; int err; #ifdef CONFIG_SND_CS46XX_NEW_DSP @@ -1202,10 +1120,10 @@ static int snd_cs46xx_capture_hw_params(snd_pcm_substream_t * substream, return 0; } -static int snd_cs46xx_capture_hw_free(snd_pcm_substream_t * substream) +static int snd_cs46xx_capture_hw_free(struct snd_pcm_substream *substream) { - cs46xx_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; if (runtime->dma_area != chip->capt.hw_buf.area) snd_pcm_lib_free_pages(substream); @@ -1216,17 +1134,16 @@ static int snd_cs46xx_capture_hw_free(snd_pcm_substream_t * substream) return 0; } -static int snd_cs46xx_capture_prepare(snd_pcm_substream_t * substream) +static int snd_cs46xx_capture_prepare(struct snd_pcm_substream *substream) { - cs46xx_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; snd_cs46xx_poke(chip, BA1_CBA, chip->capt.hw_buf.addr); chip->capt.shift = 2; - chip->capt.sw_bufsize = snd_pcm_lib_buffer_bytes(substream); - chip->capt.sw_data = chip->capt.sw_io = chip->capt.sw_ready = 0; - chip->capt.hw_data = chip->capt.hw_io = chip->capt.hw_ready = 0; - chip->capt.appl_ptr = 0; + memset(&chip->capt.pcm_rec, 0, sizeof(chip->capt.pcm_rec)); + chip->capt.pcm_rec.sw_buffer_size = snd_pcm_lib_buffer_bytes(substream); + chip->capt.pcm_rec.hw_buffer_size = runtime->period_size * CS46XX_FRAGS << 2; snd_cs46xx_set_capture_sample_rate(chip, runtime->rate); return 0; @@ -1234,13 +1151,13 @@ static int snd_cs46xx_capture_prepare(snd_pcm_substream_t * substream) static irqreturn_t snd_cs46xx_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - cs46xx_t *chip = snd_magic_cast(cs46xx_t, dev_id, return IRQ_NONE); + struct snd_cs46xx *chip = dev_id; u32 status1; #ifdef CONFIG_SND_CS46XX_NEW_DSP - dsp_spos_instance_t * ins = chip->dsp_spos_instance; + struct dsp_spos_instance * ins = chip->dsp_spos_instance; u32 status2; int i; - cs46xx_pcm_t *cpcm = NULL; + struct snd_cs46xx_pcm *cpcm = NULL; #endif /* @@ -1265,7 +1182,7 @@ static irqreturn_t snd_cs46xx_interrupt(int irq, void *dev_id, struct pt_regs *r if (ins->pcm_channels[i].active && ins->pcm_channels[i].private_data && !ins->pcm_channels[i].unlinked) { - cpcm = snd_magic_cast(cs46xx_pcm_t, ins->pcm_channels[i].private_data, continue); + cpcm = ins->pcm_channels[i].private_data; snd_pcm_period_elapsed(cpcm->substream); } } @@ -1275,7 +1192,7 @@ static irqreturn_t snd_cs46xx_interrupt(int irq, void *dev_id, struct pt_regs *r if (ins->pcm_channels[i].active && ins->pcm_channels[i].private_data && !ins->pcm_channels[i].unlinked) { - cpcm = snd_magic_cast(cs46xx_pcm_t, ins->pcm_channels[i].private_data, continue); + cpcm = ins->pcm_channels[i].private_data; snd_pcm_period_elapsed(cpcm->substream); } } @@ -1324,12 +1241,12 @@ static irqreturn_t snd_cs46xx_interrupt(int irq, void *dev_id, struct pt_regs *r return IRQ_HANDLED; } -static snd_pcm_hardware_t snd_cs46xx_playback = +static struct snd_pcm_hardware snd_cs46xx_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | - SNDRV_PCM_INFO_BLOCK_TRANSFER | - SNDRV_PCM_INFO_RESUME), + SNDRV_PCM_INFO_BLOCK_TRANSFER /*|*/ + /*SNDRV_PCM_INFO_RESUME*/), .formats = (SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE | SNDRV_PCM_FMTBIT_U16_LE | SNDRV_PCM_FMTBIT_U16_BE), @@ -1346,12 +1263,12 @@ static snd_pcm_hardware_t snd_cs46xx_playback = .fifo_size = 0, }; -static snd_pcm_hardware_t snd_cs46xx_capture = +static struct snd_pcm_hardware snd_cs46xx_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | - SNDRV_PCM_INFO_BLOCK_TRANSFER | - SNDRV_PCM_INFO_RESUME), + SNDRV_PCM_INFO_BLOCK_TRANSFER /*|*/ + /*SNDRV_PCM_INFO_RESUME*/), .formats = SNDRV_PCM_FMTBIT_S16_LE, .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_48000, .rate_min = 5500, @@ -1370,35 +1287,31 @@ static snd_pcm_hardware_t snd_cs46xx_capture = static unsigned int period_sizes[] = { 32, 64, 128, 256, 512, 1024, 2048 }; -#define PERIOD_SIZES sizeof(period_sizes) / sizeof(period_sizes[0]) - -static snd_pcm_hw_constraint_list_t hw_constraints_period_sizes = { - .count = PERIOD_SIZES, +static struct snd_pcm_hw_constraint_list hw_constraints_period_sizes = { + .count = ARRAY_SIZE(period_sizes), .list = period_sizes, .mask = 0 }; #endif -static void snd_cs46xx_pcm_free_substream(snd_pcm_runtime_t *runtime) +static void snd_cs46xx_pcm_free_substream(struct snd_pcm_runtime *runtime) { - cs46xx_pcm_t * cpcm = snd_magic_cast(cs46xx_pcm_t, runtime->private_data, return); - - if (cpcm) - snd_magic_kfree(cpcm); + kfree(runtime->private_data); } -static int _cs46xx_playback_open_channel (snd_pcm_substream_t * substream,int pcm_channel_id) +static int _cs46xx_playback_open_channel (struct snd_pcm_substream *substream,int pcm_channel_id) { - cs46xx_t *chip = snd_pcm_substream_chip(substream); - cs46xx_pcm_t * cpcm; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); + struct snd_cs46xx_pcm * cpcm; + struct snd_pcm_runtime *runtime = substream->runtime; - cpcm = snd_magic_kcalloc(cs46xx_pcm_t, 0, GFP_KERNEL); + cpcm = kzalloc(sizeof(*cpcm), GFP_KERNEL); if (cpcm == NULL) return -ENOMEM; - if (snd_dma_alloc_pages(&chip->dma_dev, PAGE_SIZE, &cpcm->hw_buf) < 0) { - snd_magic_kfree(cpcm); + if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), + PAGE_SIZE, &cpcm->hw_buf) < 0) { + kfree(cpcm); return -ENOMEM; } @@ -1408,7 +1321,7 @@ static int _cs46xx_playback_open_channel (snd_pcm_substream_t * substream,int pc cpcm->substream = substream; #ifdef CONFIG_SND_CS46XX_NEW_DSP - down (&chip->spos_mutex); + mutex_lock(&chip->spos_mutex); cpcm->pcm_channel = NULL; cpcm->pcm_channel_id = pcm_channel_id; @@ -1417,7 +1330,7 @@ static int _cs46xx_playback_open_channel (snd_pcm_substream_t * substream,int pc SNDRV_PCM_HW_PARAM_PERIOD_BYTES, &hw_constraints_period_sizes); - up (&chip->spos_mutex); + mutex_unlock(&chip->spos_mutex); #else chip->playback_pcm = cpcm; /* HACK */ #endif @@ -1429,64 +1342,65 @@ static int _cs46xx_playback_open_channel (snd_pcm_substream_t * substream,int pc return 0; } -static int snd_cs46xx_playback_open(snd_pcm_substream_t * substream) +static int snd_cs46xx_playback_open(struct snd_pcm_substream *substream) { snd_printdd("open front channel\n"); return _cs46xx_playback_open_channel(substream,DSP_PCM_MAIN_CHANNEL); } #ifdef CONFIG_SND_CS46XX_NEW_DSP -static int snd_cs46xx_playback_open_rear(snd_pcm_substream_t * substream) +static int snd_cs46xx_playback_open_rear(struct snd_pcm_substream *substream) { snd_printdd("open rear channel\n"); return _cs46xx_playback_open_channel(substream,DSP_PCM_REAR_CHANNEL); } -static int snd_cs46xx_playback_open_clfe(snd_pcm_substream_t * substream) +static int snd_cs46xx_playback_open_clfe(struct snd_pcm_substream *substream) { snd_printdd("open center - LFE channel\n"); return _cs46xx_playback_open_channel(substream,DSP_PCM_CENTER_LFE_CHANNEL); } -static int snd_cs46xx_playback_open_iec958(snd_pcm_substream_t * substream) +static int snd_cs46xx_playback_open_iec958(struct snd_pcm_substream *substream) { - cs46xx_t *chip = snd_pcm_substream_chip(substream); + struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); snd_printdd("open raw iec958 channel\n"); - down (&chip->spos_mutex); + mutex_lock(&chip->spos_mutex); cs46xx_iec958_pre_open (chip); - up (&chip->spos_mutex); + mutex_unlock(&chip->spos_mutex); return _cs46xx_playback_open_channel(substream,DSP_IEC958_CHANNEL); } -static int snd_cs46xx_playback_close(snd_pcm_substream_t * substream); +static int snd_cs46xx_playback_close(struct snd_pcm_substream *substream); -static int snd_cs46xx_playback_close_iec958(snd_pcm_substream_t * substream) +static int snd_cs46xx_playback_close_iec958(struct snd_pcm_substream *substream) { int err; - cs46xx_t *chip = snd_pcm_substream_chip(substream); + struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); snd_printdd("close raw iec958 channel\n"); err = snd_cs46xx_playback_close(substream); - down (&chip->spos_mutex); + mutex_lock(&chip->spos_mutex); cs46xx_iec958_post_close (chip); - up (&chip->spos_mutex); + mutex_unlock(&chip->spos_mutex); return err; } #endif -static int snd_cs46xx_capture_open(snd_pcm_substream_t * substream) +static int snd_cs46xx_capture_open(struct snd_pcm_substream *substream) { - cs46xx_t *chip = snd_pcm_substream_chip(substream); + struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); - if (snd_dma_alloc_pages(&chip->dma_dev, PAGE_SIZE, &chip->capt.hw_buf) < 0) + if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), + PAGE_SIZE, &chip->capt.hw_buf) < 0) return -ENOMEM; chip->capt.substream = substream; substream->runtime->hw = snd_cs46xx_capture; @@ -1504,48 +1418,48 @@ static int snd_cs46xx_capture_open(snd_pcm_substream_t * substream) return 0; } -static int snd_cs46xx_playback_close(snd_pcm_substream_t * substream) +static int snd_cs46xx_playback_close(struct snd_pcm_substream *substream) { - cs46xx_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - cs46xx_pcm_t * cpcm; + struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_cs46xx_pcm * cpcm; - cpcm = snd_magic_cast(cs46xx_pcm_t, runtime->private_data, return -ENXIO); + cpcm = runtime->private_data; /* when playback_open fails, then cpcm can be NULL */ if (!cpcm) return -ENXIO; #ifdef CONFIG_SND_CS46XX_NEW_DSP - down (&chip->spos_mutex); + mutex_lock(&chip->spos_mutex); if (cpcm->pcm_channel) { cs46xx_dsp_destroy_pcm_channel(chip,cpcm->pcm_channel); cpcm->pcm_channel = NULL; } - up (&chip->spos_mutex); + mutex_unlock(&chip->spos_mutex); #else chip->playback_pcm = NULL; #endif cpcm->substream = NULL; - snd_dma_free_pages(&chip->dma_dev, &cpcm->hw_buf); + snd_dma_free_pages(&cpcm->hw_buf); chip->active_ctrl(chip, -1); return 0; } -static int snd_cs46xx_capture_close(snd_pcm_substream_t * substream) +static int snd_cs46xx_capture_close(struct snd_pcm_substream *substream) { - cs46xx_t *chip = snd_pcm_substream_chip(substream); + struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); chip->capt.substream = NULL; - snd_dma_free_pages(&chip->dma_dev, &chip->capt.hw_buf); + snd_dma_free_pages(&chip->capt.hw_buf); chip->active_ctrl(chip, -1); return 0; } #ifdef CONFIG_SND_CS46XX_NEW_DSP -snd_pcm_ops_t snd_cs46xx_playback_rear_ops = { +static struct snd_pcm_ops snd_cs46xx_playback_rear_ops = { .open = snd_cs46xx_playback_open_rear, .close = snd_cs46xx_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -1556,7 +1470,7 @@ snd_pcm_ops_t snd_cs46xx_playback_rear_ops = { .pointer = snd_cs46xx_playback_direct_pointer, }; -snd_pcm_ops_t snd_cs46xx_playback_indirect_rear_ops = { +static struct snd_pcm_ops snd_cs46xx_playback_indirect_rear_ops = { .open = snd_cs46xx_playback_open_rear, .close = snd_cs46xx_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -1568,7 +1482,7 @@ snd_pcm_ops_t snd_cs46xx_playback_indirect_rear_ops = { .ack = snd_cs46xx_playback_transfer, }; -snd_pcm_ops_t snd_cs46xx_playback_clfe_ops = { +static struct snd_pcm_ops snd_cs46xx_playback_clfe_ops = { .open = snd_cs46xx_playback_open_clfe, .close = snd_cs46xx_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -1579,7 +1493,7 @@ snd_pcm_ops_t snd_cs46xx_playback_clfe_ops = { .pointer = snd_cs46xx_playback_direct_pointer, }; -snd_pcm_ops_t snd_cs46xx_playback_indirect_clfe_ops = { +static struct snd_pcm_ops snd_cs46xx_playback_indirect_clfe_ops = { .open = snd_cs46xx_playback_open_clfe, .close = snd_cs46xx_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -1591,7 +1505,7 @@ snd_pcm_ops_t snd_cs46xx_playback_indirect_clfe_ops = { .ack = snd_cs46xx_playback_transfer, }; -snd_pcm_ops_t snd_cs46xx_playback_iec958_ops = { +static struct snd_pcm_ops snd_cs46xx_playback_iec958_ops = { .open = snd_cs46xx_playback_open_iec958, .close = snd_cs46xx_playback_close_iec958, .ioctl = snd_pcm_lib_ioctl, @@ -1602,7 +1516,7 @@ snd_pcm_ops_t snd_cs46xx_playback_iec958_ops = { .pointer = snd_cs46xx_playback_direct_pointer, }; -snd_pcm_ops_t snd_cs46xx_playback_indirect_iec958_ops = { +static struct snd_pcm_ops snd_cs46xx_playback_indirect_iec958_ops = { .open = snd_cs46xx_playback_open_iec958, .close = snd_cs46xx_playback_close_iec958, .ioctl = snd_pcm_lib_ioctl, @@ -1616,7 +1530,7 @@ snd_pcm_ops_t snd_cs46xx_playback_indirect_iec958_ops = { #endif -snd_pcm_ops_t snd_cs46xx_playback_ops = { +static struct snd_pcm_ops snd_cs46xx_playback_ops = { .open = snd_cs46xx_playback_open, .close = snd_cs46xx_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -1627,7 +1541,7 @@ snd_pcm_ops_t snd_cs46xx_playback_ops = { .pointer = snd_cs46xx_playback_direct_pointer, }; -snd_pcm_ops_t snd_cs46xx_playback_indirect_ops = { +static struct snd_pcm_ops snd_cs46xx_playback_indirect_ops = { .open = snd_cs46xx_playback_open, .close = snd_cs46xx_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -1639,7 +1553,7 @@ snd_pcm_ops_t snd_cs46xx_playback_indirect_ops = { .ack = snd_cs46xx_playback_transfer, }; -snd_pcm_ops_t snd_cs46xx_capture_ops = { +static struct snd_pcm_ops snd_cs46xx_capture_ops = { .open = snd_cs46xx_capture_open, .close = snd_cs46xx_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -1650,7 +1564,7 @@ snd_pcm_ops_t snd_cs46xx_capture_ops = { .pointer = snd_cs46xx_capture_direct_pointer, }; -snd_pcm_ops_t snd_cs46xx_capture_indirect_ops = { +static struct snd_pcm_ops snd_cs46xx_capture_indirect_ops = { .open = snd_cs46xx_capture_open, .close = snd_cs46xx_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -1662,43 +1576,15 @@ snd_pcm_ops_t snd_cs46xx_capture_indirect_ops = { .ack = snd_cs46xx_capture_transfer, }; -static void snd_cs46xx_pcm_free(snd_pcm_t *pcm) -{ - cs46xx_t *chip = snd_magic_cast(cs46xx_t, pcm->private_data, return); - chip->pcm = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - #ifdef CONFIG_SND_CS46XX_NEW_DSP -static void snd_cs46xx_pcm_rear_free(snd_pcm_t *pcm) -{ - cs46xx_t *chip = snd_magic_cast(cs46xx_t, pcm->private_data, return); - chip->pcm_rear = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - -static void snd_cs46xx_pcm_center_lfe_free(snd_pcm_t *pcm) -{ - cs46xx_t *chip = snd_magic_cast(cs46xx_t, pcm->private_data, return); - chip->pcm_center_lfe = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - -static void snd_cs46xx_pcm_iec958_free(snd_pcm_t *pcm) -{ - cs46xx_t *chip = snd_magic_cast(cs46xx_t, pcm->private_data, return); - chip->pcm_iec958 = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - #define MAX_PLAYBACK_CHANNELS (DSP_MAX_PCM_CHANNELS - 1) #else #define MAX_PLAYBACK_CHANNELS 1 #endif -int __devinit snd_cs46xx_pcm(cs46xx_t *chip, int device, snd_pcm_t ** rpcm) +int __devinit snd_cs46xx_pcm(struct snd_cs46xx *chip, int device, struct snd_pcm ** rpcm) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; if (rpcm) @@ -1707,7 +1593,6 @@ int __devinit snd_cs46xx_pcm(cs46xx_t *chip, int device, snd_pcm_t ** rpcm) return err; pcm->private_data = chip; - pcm->private_free = snd_cs46xx_pcm_free; snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_cs46xx_playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_cs46xx_capture_ops); @@ -1728,9 +1613,9 @@ int __devinit snd_cs46xx_pcm(cs46xx_t *chip, int device, snd_pcm_t ** rpcm) #ifdef CONFIG_SND_CS46XX_NEW_DSP -int __devinit snd_cs46xx_pcm_rear(cs46xx_t *chip, int device, snd_pcm_t ** rpcm) +int __devinit snd_cs46xx_pcm_rear(struct snd_cs46xx *chip, int device, struct snd_pcm ** rpcm) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; if (rpcm) @@ -1740,7 +1625,6 @@ int __devinit snd_cs46xx_pcm_rear(cs46xx_t *chip, int device, snd_pcm_t ** rpcm) return err; pcm->private_data = chip; - pcm->private_free = snd_cs46xx_pcm_rear_free; snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_cs46xx_playback_rear_ops); @@ -1758,9 +1642,9 @@ int __devinit snd_cs46xx_pcm_rear(cs46xx_t *chip, int device, snd_pcm_t ** rpcm) return 0; } -int __devinit snd_cs46xx_pcm_center_lfe(cs46xx_t *chip, int device, snd_pcm_t ** rpcm) +int __devinit snd_cs46xx_pcm_center_lfe(struct snd_cs46xx *chip, int device, struct snd_pcm ** rpcm) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; if (rpcm) @@ -1770,7 +1654,6 @@ int __devinit snd_cs46xx_pcm_center_lfe(cs46xx_t *chip, int device, snd_pcm_t ** return err; pcm->private_data = chip; - pcm->private_free = snd_cs46xx_pcm_center_lfe_free; snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_cs46xx_playback_clfe_ops); @@ -1788,9 +1671,9 @@ int __devinit snd_cs46xx_pcm_center_lfe(cs46xx_t *chip, int device, snd_pcm_t ** return 0; } -int __devinit snd_cs46xx_pcm_iec958(cs46xx_t *chip, int device, snd_pcm_t ** rpcm) +int __devinit snd_cs46xx_pcm_iec958(struct snd_cs46xx *chip, int device, struct snd_pcm ** rpcm) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; if (rpcm) @@ -1800,7 +1683,6 @@ int __devinit snd_cs46xx_pcm_iec958(cs46xx_t *chip, int device, snd_pcm_t ** rpc return err; pcm->private_data = chip; - pcm->private_free = snd_cs46xx_pcm_iec958_free; snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_cs46xx_playback_iec958_ops); @@ -1822,16 +1704,16 @@ int __devinit snd_cs46xx_pcm_iec958(cs46xx_t *chip, int device, snd_pcm_t ** rpc /* * Mixer routines */ -static void snd_cs46xx_mixer_free_ac97_bus(ac97_bus_t *bus) +static void snd_cs46xx_mixer_free_ac97_bus(struct snd_ac97_bus *bus) { - cs46xx_t *chip = snd_magic_cast(cs46xx_t, bus->private_data, return); + struct snd_cs46xx *chip = bus->private_data; chip->ac97_bus = NULL; } -static void snd_cs46xx_mixer_free_ac97(ac97_t *ac97) +static void snd_cs46xx_mixer_free_ac97(struct snd_ac97 *ac97) { - cs46xx_t *chip = snd_magic_cast(cs46xx_t, ac97->private_data, return); + struct snd_cs46xx *chip = ac97->private_data; snd_assert ((ac97 == chip->ac97[CS46XX_PRIMARY_CODEC_INDEX]) || (ac97 == chip->ac97[CS46XX_SECONDARY_CODEC_INDEX]), @@ -1845,8 +1727,8 @@ static void snd_cs46xx_mixer_free_ac97(ac97_t *ac97) chip->ac97[CS46XX_SECONDARY_CODEC_INDEX] = NULL; } -static int snd_cs46xx_vol_info(snd_kcontrol_t *kcontrol, - snd_ctl_elem_info_t *uinfo) +static int snd_cs46xx_vol_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; @@ -1855,9 +1737,9 @@ static int snd_cs46xx_vol_info(snd_kcontrol_t *kcontrol, return 0; } -static int snd_cs46xx_vol_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_cs46xx_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - cs46xx_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); int reg = kcontrol->private_value; unsigned int val = snd_cs46xx_peek(chip, reg); ucontrol->value.integer.value[0] = 0xffff - (val >> 16); @@ -1865,9 +1747,9 @@ static int snd_cs46xx_vol_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * return 0; } -static int snd_cs46xx_vol_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_cs46xx_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - cs46xx_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); int reg = kcontrol->private_value; unsigned int val = ((0xffff - ucontrol->value.integer.value[0]) << 16 | (0xffff - ucontrol->value.integer.value[1])); @@ -1883,9 +1765,9 @@ static int snd_cs46xx_vol_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * #ifdef CONFIG_SND_CS46XX_NEW_DSP -static int snd_cs46xx_vol_dac_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_cs46xx_vol_dac_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - cs46xx_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = chip->dsp_spos_instance->dac_volume_left; ucontrol->value.integer.value[1] = chip->dsp_spos_instance->dac_volume_right; @@ -1893,9 +1775,9 @@ static int snd_cs46xx_vol_dac_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ return 0; } -static int snd_cs46xx_vol_dac_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_cs46xx_vol_dac_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - cs46xx_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); int change = 0; if (chip->dsp_spos_instance->dac_volume_right != ucontrol->value.integer.value[0] || @@ -1910,18 +1792,18 @@ static int snd_cs46xx_vol_dac_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ } #if 0 -static int snd_cs46xx_vol_iec958_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_cs46xx_vol_iec958_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - cs46xx_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = chip->dsp_spos_instance->spdif_input_volume_left; ucontrol->value.integer.value[1] = chip->dsp_spos_instance->spdif_input_volume_right; return 0; } -static int snd_cs46xx_vol_iec958_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_cs46xx_vol_iec958_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - cs46xx_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); int change = 0; if (chip->dsp_spos_instance->spdif_input_volume_left != ucontrol->value.integer.value[0] || @@ -1936,8 +1818,8 @@ static int snd_cs46xx_vol_iec958_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_val } #endif -static int snd_mixer_boolean_info(snd_kcontrol_t *kcontrol, - snd_ctl_elem_info_t *uinfo) +static int snd_mixer_boolean_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -1946,10 +1828,10 @@ static int snd_mixer_boolean_info(snd_kcontrol_t *kcontrol, return 0; } -static int snd_cs46xx_iec958_get(snd_kcontrol_t *kcontrol, - snd_ctl_elem_value_t *ucontrol) +static int snd_cs46xx_iec958_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cs46xx_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); int reg = kcontrol->private_value; if (reg == CS46XX_MIXER_SPDIF_OUTPUT_ELEMENT) @@ -1960,15 +1842,15 @@ static int snd_cs46xx_iec958_get(snd_kcontrol_t *kcontrol, return 0; } -static int snd_cs46xx_iec958_put(snd_kcontrol_t *kcontrol, - snd_ctl_elem_value_t *ucontrol) +static int snd_cs46xx_iec958_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cs46xx_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); int change, res; switch (kcontrol->private_value) { case CS46XX_MIXER_SPDIF_OUTPUT_ELEMENT: - down (&chip->spos_mutex); + mutex_lock(&chip->spos_mutex); change = (chip->dsp_spos_instance->spdif_status_out & DSP_SPDIF_STATUS_OUTPUT_ENABLED); if (ucontrol->value.integer.value[0] && !change) cs46xx_dsp_enable_spdif_out(chip); @@ -1976,7 +1858,7 @@ static int snd_cs46xx_iec958_put(snd_kcontrol_t *kcontrol, cs46xx_dsp_disable_spdif_out(chip); res = (change != (chip->dsp_spos_instance->spdif_status_out & DSP_SPDIF_STATUS_OUTPUT_ENABLED)); - up (&chip->spos_mutex); + mutex_unlock(&chip->spos_mutex); break; case CS46XX_MIXER_SPDIF_INPUT_ELEMENT: change = chip->dsp_spos_instance->spdif_status_in; @@ -1997,11 +1879,11 @@ static int snd_cs46xx_iec958_put(snd_kcontrol_t *kcontrol, return res; } -static int snd_cs46xx_adc_capture_get(snd_kcontrol_t *kcontrol, - snd_ctl_elem_value_t *ucontrol) +static int snd_cs46xx_adc_capture_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cs46xx_t *chip = snd_kcontrol_chip(kcontrol); - dsp_spos_instance_t * ins = chip->dsp_spos_instance; + struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); + struct dsp_spos_instance * ins = chip->dsp_spos_instance; if (ins->adc_input != NULL) ucontrol->value.integer.value[0] = 1; @@ -2011,11 +1893,11 @@ static int snd_cs46xx_adc_capture_get(snd_kcontrol_t *kcontrol, return 0; } -static int snd_cs46xx_adc_capture_put(snd_kcontrol_t *kcontrol, - snd_ctl_elem_value_t *ucontrol) +static int snd_cs46xx_adc_capture_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cs46xx_t *chip = snd_kcontrol_chip(kcontrol); - dsp_spos_instance_t * ins = chip->dsp_spos_instance; + struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); + struct dsp_spos_instance * ins = chip->dsp_spos_instance; int change = 0; if (ucontrol->value.integer.value[0] && !ins->adc_input) { @@ -2028,11 +1910,11 @@ static int snd_cs46xx_adc_capture_put(snd_kcontrol_t *kcontrol, return change; } -static int snd_cs46xx_pcm_capture_get(snd_kcontrol_t *kcontrol, - snd_ctl_elem_value_t *ucontrol) +static int snd_cs46xx_pcm_capture_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cs46xx_t *chip = snd_kcontrol_chip(kcontrol); - dsp_spos_instance_t * ins = chip->dsp_spos_instance; + struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); + struct dsp_spos_instance * ins = chip->dsp_spos_instance; if (ins->pcm_input != NULL) ucontrol->value.integer.value[0] = 1; @@ -2043,11 +1925,11 @@ static int snd_cs46xx_pcm_capture_get(snd_kcontrol_t *kcontrol, } -static int snd_cs46xx_pcm_capture_put(snd_kcontrol_t *kcontrol, - snd_ctl_elem_value_t *ucontrol) +static int snd_cs46xx_pcm_capture_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cs46xx_t *chip = snd_kcontrol_chip(kcontrol); - dsp_spos_instance_t * ins = chip->dsp_spos_instance; + struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); + struct dsp_spos_instance * ins = chip->dsp_spos_instance; int change = 0; if (ucontrol->value.integer.value[0] && !ins->pcm_input) { @@ -2061,10 +1943,10 @@ static int snd_cs46xx_pcm_capture_put(snd_kcontrol_t *kcontrol, return change; } -static int snd_herc_spdif_select_get(snd_kcontrol_t *kcontrol, - snd_ctl_elem_value_t *ucontrol) +static int snd_herc_spdif_select_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cs46xx_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); int val1 = snd_cs46xx_peekBA0(chip, BA0_EGPIODR); @@ -2079,10 +1961,10 @@ static int snd_herc_spdif_select_get(snd_kcontrol_t *kcontrol, /* * Game Theatre XP card - EGPIO[0] is used to select SPDIF input optical or coaxial. */ -static int snd_herc_spdif_select_put(snd_kcontrol_t *kcontrol, - snd_ctl_elem_value_t *ucontrol) +static int snd_herc_spdif_select_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cs46xx_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); int val1 = snd_cs46xx_peekBA0(chip, BA0_EGPIODR); int val2 = snd_cs46xx_peekBA0(chip, BA0_EGPIOPTR); @@ -2104,38 +1986,38 @@ static int snd_herc_spdif_select_put(snd_kcontrol_t *kcontrol, } -static int snd_cs46xx_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_cs46xx_spdif_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; uinfo->count = 1; return 0; } -static int snd_cs46xx_spdif_default_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_cs46xx_spdif_default_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cs46xx_t *chip = snd_kcontrol_chip(kcontrol); - dsp_spos_instance_t * ins = chip->dsp_spos_instance; + struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); + struct dsp_spos_instance * ins = chip->dsp_spos_instance; - down (&chip->spos_mutex); + mutex_lock(&chip->spos_mutex); ucontrol->value.iec958.status[0] = _wrap_all_bits((ins->spdif_csuv_default >> 24) & 0xff); ucontrol->value.iec958.status[1] = _wrap_all_bits((ins->spdif_csuv_default >> 16) & 0xff); ucontrol->value.iec958.status[2] = 0; ucontrol->value.iec958.status[3] = _wrap_all_bits((ins->spdif_csuv_default) & 0xff); - up (&chip->spos_mutex); + mutex_unlock(&chip->spos_mutex); return 0; } -static int snd_cs46xx_spdif_default_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_cs46xx_spdif_default_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cs46xx_t * chip = snd_kcontrol_chip(kcontrol); - dsp_spos_instance_t * ins = chip->dsp_spos_instance; + struct snd_cs46xx * chip = snd_kcontrol_chip(kcontrol); + struct dsp_spos_instance * ins = chip->dsp_spos_instance; unsigned int val; int change; - down (&chip->spos_mutex); + mutex_lock(&chip->spos_mutex); val = ((unsigned int)_wrap_all_bits(ucontrol->value.iec958.status[0]) << 24) | ((unsigned int)_wrap_all_bits(ucontrol->value.iec958.status[2]) << 16) | ((unsigned int)_wrap_all_bits(ucontrol->value.iec958.status[3])) | @@ -2149,13 +2031,13 @@ static int snd_cs46xx_spdif_default_put(snd_kcontrol_t * kcontrol, if ( !(ins->spdif_status_out & DSP_SPDIF_STATUS_PLAYBACK_OPEN) ) cs46xx_poke_via_dsp (chip,SP_SPDOUT_CSUV,val); - up (&chip->spos_mutex); + mutex_unlock(&chip->spos_mutex); return change; } -static int snd_cs46xx_spdif_mask_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_cs46xx_spdif_mask_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { ucontrol->value.iec958.status[0] = 0xff; ucontrol->value.iec958.status[1] = 0xff; @@ -2164,31 +2046,31 @@ static int snd_cs46xx_spdif_mask_get(snd_kcontrol_t * kcontrol, return 0; } -static int snd_cs46xx_spdif_stream_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_cs46xx_spdif_stream_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cs46xx_t *chip = snd_kcontrol_chip(kcontrol); - dsp_spos_instance_t * ins = chip->dsp_spos_instance; + struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); + struct dsp_spos_instance * ins = chip->dsp_spos_instance; - down (&chip->spos_mutex); + mutex_lock(&chip->spos_mutex); ucontrol->value.iec958.status[0] = _wrap_all_bits((ins->spdif_csuv_stream >> 24) & 0xff); ucontrol->value.iec958.status[1] = _wrap_all_bits((ins->spdif_csuv_stream >> 16) & 0xff); ucontrol->value.iec958.status[2] = 0; ucontrol->value.iec958.status[3] = _wrap_all_bits((ins->spdif_csuv_stream) & 0xff); - up (&chip->spos_mutex); + mutex_unlock(&chip->spos_mutex); return 0; } -static int snd_cs46xx_spdif_stream_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_cs46xx_spdif_stream_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cs46xx_t * chip = snd_kcontrol_chip(kcontrol); - dsp_spos_instance_t * ins = chip->dsp_spos_instance; + struct snd_cs46xx * chip = snd_kcontrol_chip(kcontrol); + struct dsp_spos_instance * ins = chip->dsp_spos_instance; unsigned int val; int change; - down (&chip->spos_mutex); + mutex_lock(&chip->spos_mutex); val = ((unsigned int)_wrap_all_bits(ucontrol->value.iec958.status[0]) << 24) | ((unsigned int)_wrap_all_bits(ucontrol->value.iec958.status[1]) << 16) | ((unsigned int)_wrap_all_bits(ucontrol->value.iec958.status[3])) | @@ -2202,7 +2084,7 @@ static int snd_cs46xx_spdif_stream_put(snd_kcontrol_t * kcontrol, if ( ins->spdif_status_out & DSP_SPDIF_STATUS_PLAYBACK_OPEN ) cs46xx_poke_via_dsp (chip,SP_SPDOUT_CSUV,val); - up (&chip->spos_mutex); + mutex_unlock(&chip->spos_mutex); return change; } @@ -2211,8 +2093,8 @@ static int snd_cs46xx_spdif_stream_put(snd_kcontrol_t * kcontrol, #ifdef CONFIG_SND_CS46XX_DEBUG_GPIO -static int snd_cs46xx_egpio_select_info(snd_kcontrol_t *kcontrol, - snd_ctl_elem_info_t *uinfo) +static int snd_cs46xx_egpio_select_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 1; @@ -2221,19 +2103,19 @@ static int snd_cs46xx_egpio_select_info(snd_kcontrol_t *kcontrol, return 0; } -static int snd_cs46xx_egpio_select_get(snd_kcontrol_t *kcontrol, - snd_ctl_elem_value_t *ucontrol) +static int snd_cs46xx_egpio_select_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cs46xx_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = chip->current_gpio; return 0; } -static int snd_cs46xx_egpio_select_put(snd_kcontrol_t *kcontrol, - snd_ctl_elem_value_t *ucontrol) +static int snd_cs46xx_egpio_select_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cs46xx_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); int change = (chip->current_gpio != ucontrol->value.integer.value[0]); chip->current_gpio = ucontrol->value.integer.value[0]; @@ -2241,10 +2123,10 @@ static int snd_cs46xx_egpio_select_put(snd_kcontrol_t *kcontrol, } -static int snd_cs46xx_egpio_get(snd_kcontrol_t *kcontrol, - snd_ctl_elem_value_t *ucontrol) +static int snd_cs46xx_egpio_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cs46xx_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); int reg = kcontrol->private_value; snd_printdd ("put: reg = %04x, gpio %02x\n",reg,chip->current_gpio); @@ -2254,10 +2136,10 @@ static int snd_cs46xx_egpio_get(snd_kcontrol_t *kcontrol, return 0; } -static int snd_cs46xx_egpio_put(snd_kcontrol_t *kcontrol, - snd_ctl_elem_value_t *ucontrol) +static int snd_cs46xx_egpio_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cs46xx_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); int reg = kcontrol->private_value; int val = snd_cs46xx_peekBA0(chip, reg); int oldval = val; @@ -2275,7 +2157,7 @@ static int snd_cs46xx_egpio_put(snd_kcontrol_t *kcontrol, } #endif /* CONFIG_SND_CS46XX_DEBUG_GPIO */ -static snd_kcontrol_new_t snd_cs46xx_controls[] __devinitdata = { +static struct snd_kcontrol_new snd_cs46xx_controls[] __devinitdata = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "DAC Volume", @@ -2319,7 +2201,7 @@ static snd_kcontrol_new_t snd_cs46xx_controls[] __devinitdata = { }, { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "IEC958 Output Switch", + .name = SNDRV_CTL_NAME_IEC958("Output ",NONE,SWITCH), .info = snd_mixer_boolean_info, .get = snd_cs46xx_iec958_get, .put = snd_cs46xx_iec958_put, @@ -2327,7 +2209,7 @@ static snd_kcontrol_new_t snd_cs46xx_controls[] __devinitdata = { }, { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "IEC958 Input Switch", + .name = SNDRV_CTL_NAME_IEC958("Input ",NONE,SWITCH), .info = snd_mixer_boolean_info, .get = snd_cs46xx_iec958_get, .put = snd_cs46xx_iec958_put, @@ -2337,7 +2219,7 @@ static snd_kcontrol_new_t snd_cs46xx_controls[] __devinitdata = { /* Input IEC958 volume does not work for the moment. (Benny) */ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "IEC958 Input Volume", + .name = SNDRV_CTL_NAME_IEC958("Input ",NONE,VOLUME), .info = snd_cs46xx_vol_info, .get = snd_cs46xx_vol_iec958_get, .put = snd_cs46xx_vol_iec958_put, @@ -2403,9 +2285,39 @@ static snd_kcontrol_new_t snd_cs46xx_controls[] __devinitdata = { #endif }; +#ifdef CONFIG_SND_CS46XX_NEW_DSP +/* set primary cs4294 codec into Extended Audio Mode */ +static int snd_cs46xx_front_dup_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); + unsigned short val; + val = snd_ac97_read(chip->ac97[CS46XX_PRIMARY_CODEC_INDEX], AC97_CSR_ACMODE); + ucontrol->value.integer.value[0] = (val & 0x200) ? 0 : 1; + return 0; +} + +static int snd_cs46xx_front_dup_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); + return snd_ac97_update_bits(chip->ac97[CS46XX_PRIMARY_CODEC_INDEX], + AC97_CSR_ACMODE, 0x200, + ucontrol->value.integer.value[0] ? 0 : 0x200); +} + +static struct snd_kcontrol_new snd_cs46xx_front_dup_ctl = { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "Duplicate Front", + .info = snd_mixer_boolean_info, + .get = snd_cs46xx_front_dup_get, + .put = snd_cs46xx_front_dup_put, +}; +#endif + #ifdef CONFIG_SND_CS46XX_NEW_DSP /* Only available on the Hercules Game Theater XP soundcard */ -static snd_kcontrol_new_t snd_hercules_controls[] __devinitdata = { +static struct snd_kcontrol_new snd_hercules_controls[] __devinitdata = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Optical/Coaxial SPDIF Input Switch", @@ -2416,20 +2328,19 @@ static snd_kcontrol_new_t snd_hercules_controls[] __devinitdata = { }; -static void snd_cs46xx_codec_reset (ac97_t * ac97) +static void snd_cs46xx_codec_reset (struct snd_ac97 * ac97) { unsigned long end_time; int err; - cs46xx_t * chip = snd_magic_cast(cs46xx_t,ac97->private_data,return /* -ENXIO */); /* reset to defaults */ snd_ac97_write(ac97, AC97_RESET, 0); /* set the desired CODEC mode */ - if (chip->nr_ac97_codecs == 0) { + if (ac97->num == CS46XX_PRIMARY_CODEC_INDEX) { snd_printdd("cs46xx: CODOEC1 mode %04x\n",0x0); snd_cs46xx_ac97_write(ac97,AC97_CSR_ACMODE,0x0); - } else if (chip->nr_ac97_codecs == 1) { + } else if (ac97->num == CS46XX_SECONDARY_CODEC_INDEX) { snd_printdd("cs46xx: CODOEC2 mode %04x\n",0x3); snd_cs46xx_ac97_write(ac97,AC97_CSR_ACMODE,0x3); } else { @@ -2459,105 +2370,84 @@ static void snd_cs46xx_codec_reset (ac97_t * ac97) if ((err = snd_ac97_read(ac97, AC97_REC_GAIN)) == 0x8a05) return; - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(HZ/100); + msleep(10); } while (time_after_eq(end_time, jiffies)); - snd_printk("CS46xx secondary codec dont respond!\n"); + snd_printk(KERN_ERR "CS46xx secondary codec doesn't respond!\n"); } #endif -int __devinit snd_cs46xx_mixer(cs46xx_t *chip) +static int __devinit cs46xx_detect_codec(struct snd_cs46xx *chip, int codec) { - snd_card_t *card = chip->card; - ac97_bus_t bus; - ac97_t ac97; - snd_ctl_elem_id_t id; - int err; - unsigned int idx; - - /* detect primary codec */ - chip->nr_ac97_codecs = 0; - snd_printdd("snd_cs46xx: detecting primary codec\n"); - memset(&bus, 0, sizeof(bus)); - bus.write = snd_cs46xx_ac97_write; - bus.read = snd_cs46xx_ac97_read; -#ifdef CONFIG_SND_CS46XX_NEW_DSP - bus.reset = snd_cs46xx_codec_reset; -#endif - bus.private_data = chip; - bus.private_free = snd_cs46xx_mixer_free_ac97_bus; - if ((err = snd_ac97_bus(card, &bus, &chip->ac97_bus)) < 0) - return err; + int idx, err; + struct snd_ac97_template ac97; memset(&ac97, 0, sizeof(ac97)); ac97.private_data = chip; ac97.private_free = snd_cs46xx_mixer_free_ac97; - chip->ac97[CS46XX_PRIMARY_CODEC_INDEX] = &ac97; + ac97.num = codec; + if (chip->amplifier_ctrl == amp_voyetra) + ac97.scaps = AC97_SCAP_INV_EAPD; - snd_cs46xx_ac97_write(&ac97, AC97_MASTER, 0x8000); - for (idx = 0; idx < 100; ++idx) { - if (snd_cs46xx_ac97_read(&ac97, AC97_MASTER) == 0x8000) - goto _ok; - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(HZ/100); - } - chip->ac97[CS46XX_PRIMARY_CODEC_INDEX] = NULL; - return -ENXIO; - - _ok: - if ((err = snd_ac97_mixer(chip->ac97_bus, &ac97, &chip->ac97[CS46XX_PRIMARY_CODEC_INDEX])) < 0) - return err; - snd_printdd("snd_cs46xx: primary codec phase one\n"); - chip->nr_ac97_codecs = 1; - -#ifdef CONFIG_SND_CS46XX_NEW_DSP - snd_printdd("snd_cs46xx: detecting seconadry codec\n"); - /* try detect a secondary codec */ - memset(&ac97, 0, sizeof(ac97)); - ac97.private_data = chip; - ac97.private_free = snd_cs46xx_mixer_free_ac97; - ac97.num = CS46XX_SECONDARY_CODEC_INDEX; - - snd_cs46xx_ac97_write(&ac97, AC97_RESET, 0); - udelay(10); - - if (snd_cs46xx_ac97_read(&ac97, AC97_RESET) & 0x8000) { - snd_printdd("snd_cs46xx: seconadry codec not present\n"); - goto _no_sec_codec; + if (codec == CS46XX_SECONDARY_CODEC_INDEX) { + snd_cs46xx_codec_write(chip, AC97_RESET, 0, codec); + udelay(10); + if (snd_cs46xx_codec_read(chip, AC97_RESET, codec) & 0x8000) { + snd_printdd("snd_cs46xx: seconadry codec not present\n"); + return -ENXIO; + } } - chip->ac97[CS46XX_SECONDARY_CODEC_INDEX] = &ac97; - snd_cs46xx_ac97_write(&ac97, AC97_MASTER, 0x8000); + snd_cs46xx_codec_write(chip, AC97_MASTER, 0x8000, codec); for (idx = 0; idx < 100; ++idx) { - if (snd_cs46xx_ac97_read(&ac97, AC97_MASTER) == 0x8000) { - goto _ok2; + if (snd_cs46xx_codec_read(chip, AC97_MASTER, codec) == 0x8000) { + err = snd_ac97_mixer(chip->ac97_bus, &ac97, &chip->ac97[codec]); + return err; } - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(HZ/100); + msleep(10); } + snd_printdd("snd_cs46xx: codec %d detection timeout\n", codec); + return -ENXIO; +} - _no_sec_codec: - snd_printdd("snd_cs46xx: secondary codec did not respond ...\n"); +int __devinit snd_cs46xx_mixer(struct snd_cs46xx *chip, int spdif_device) +{ + struct snd_card *card = chip->card; + struct snd_ctl_elem_id id; + int err; + unsigned int idx; + static struct snd_ac97_bus_ops ops = { +#ifdef CONFIG_SND_CS46XX_NEW_DSP + .reset = snd_cs46xx_codec_reset, +#endif + .write = snd_cs46xx_ac97_write, + .read = snd_cs46xx_ac97_read, + }; - chip->ac97[CS46XX_SECONDARY_CODEC_INDEX] = NULL; - chip->nr_ac97_codecs = 1; - - /* well, one codec only ... */ - goto _end; - _ok2: - if ((err = snd_ac97_mixer(chip->ac97_bus, &ac97, &chip->ac97[CS46XX_SECONDARY_CODEC_INDEX])) < 0) + /* detect primary codec */ + chip->nr_ac97_codecs = 0; + snd_printdd("snd_cs46xx: detecting primary codec\n"); + if ((err = snd_ac97_bus(card, 0, &ops, chip, &chip->ac97_bus)) < 0) return err; - chip->nr_ac97_codecs = 2; + chip->ac97_bus->private_free = snd_cs46xx_mixer_free_ac97_bus; - _end: + if (cs46xx_detect_codec(chip, CS46XX_PRIMARY_CODEC_INDEX) < 0) + return -ENXIO; + chip->nr_ac97_codecs = 1; +#ifdef CONFIG_SND_CS46XX_NEW_DSP + snd_printdd("snd_cs46xx: detecting seconadry codec\n"); + /* try detect a secondary codec */ + if (! cs46xx_detect_codec(chip, CS46XX_SECONDARY_CODEC_INDEX)) + chip->nr_ac97_codecs = 2; #endif /* CONFIG_SND_CS46XX_NEW_DSP */ /* add cs4630 mixer controls */ for (idx = 0; idx < ARRAY_SIZE(snd_cs46xx_controls); idx++) { - snd_kcontrol_t *kctl; + struct snd_kcontrol *kctl; kctl = snd_ctl_new1(&snd_cs46xx_controls[idx], chip); + if (kctl && kctl->id.iface == SNDRV_CTL_ELEM_IFACE_PCM) + kctl->id.device = spdif_device; if ((err = snd_ctl_add(card, kctl)) < 0) return err; } @@ -2569,15 +2459,15 @@ int __devinit snd_cs46xx_mixer(cs46xx_t *chip) chip->eapd_switch = snd_ctl_find_id(chip->card, &id); #ifdef CONFIG_SND_CS46XX_NEW_DSP - if (chip->nr_ac97_codecs == 1 && - (snd_cs46xx_codec_read(chip, AC97_VENDOR_ID2, - CS46XX_PRIMARY_CODEC_INDEX) == 0x592b || - snd_cs46xx_codec_read(chip, AC97_VENDOR_ID2, - CS46XX_PRIMARY_CODEC_INDEX) == 0x592d)) { - /* set primary cs4294 codec into Extended Audio Mode */ - snd_printdd("setting EAM bit on cs4294 CODEC\n"); - snd_cs46xx_codec_write(chip, AC97_CSR_ACMODE, 0x200, - CS46XX_PRIMARY_CODEC_INDEX); + if (chip->nr_ac97_codecs == 1) { + unsigned int id2 = chip->ac97[CS46XX_PRIMARY_CODEC_INDEX]->id & 0xffff; + if (id2 == 0x592b || id2 == 0x592d) { + err = snd_ctl_add(card, snd_ctl_new1(&snd_cs46xx_front_dup_ctl, chip)); + if (err < 0) + return err; + snd_ac97_write_cache(chip->ac97[CS46XX_PRIMARY_CODEC_INDEX], + AC97_CSR_ACMODE, 0x200); + } } /* do soundcard specific mixer setup */ if (chip->mixer_init) { @@ -2596,20 +2486,19 @@ int __devinit snd_cs46xx_mixer(cs46xx_t *chip) * RawMIDI interface */ -static void snd_cs46xx_midi_reset(cs46xx_t *chip) +static void snd_cs46xx_midi_reset(struct snd_cs46xx *chip) { snd_cs46xx_pokeBA0(chip, BA0_MIDCR, MIDCR_MRST); udelay(100); snd_cs46xx_pokeBA0(chip, BA0_MIDCR, chip->midcr); } -static int snd_cs46xx_midi_input_open(snd_rawmidi_substream_t * substream) +static int snd_cs46xx_midi_input_open(struct snd_rawmidi_substream *substream) { - unsigned long flags; - cs46xx_t *chip = snd_magic_cast(cs46xx_t, substream->rmidi->private_data, return -ENXIO); + struct snd_cs46xx *chip = substream->rmidi->private_data; chip->active_ctrl(chip, 1); - spin_lock_irqsave(&chip->reg_lock, flags); + spin_lock_irq(&chip->reg_lock); chip->uartm |= CS46XX_MODE_INPUT; chip->midcr |= MIDCR_RXE; chip->midi_input = substream; @@ -2618,16 +2507,15 @@ static int snd_cs46xx_midi_input_open(snd_rawmidi_substream_t * substream) } else { snd_cs46xx_pokeBA0(chip, BA0_MIDCR, chip->midcr); } - spin_unlock_irqrestore(&chip->reg_lock, flags); + spin_unlock_irq(&chip->reg_lock); return 0; } -static int snd_cs46xx_midi_input_close(snd_rawmidi_substream_t * substream) +static int snd_cs46xx_midi_input_close(struct snd_rawmidi_substream *substream) { - unsigned long flags; - cs46xx_t *chip = snd_magic_cast(cs46xx_t, substream->rmidi->private_data, return -ENXIO); + struct snd_cs46xx *chip = substream->rmidi->private_data; - spin_lock_irqsave(&chip->reg_lock, flags); + spin_lock_irq(&chip->reg_lock); chip->midcr &= ~(MIDCR_RXE | MIDCR_RIE); chip->midi_input = NULL; if (!(chip->uartm & CS46XX_MODE_OUTPUT)) { @@ -2636,19 +2524,18 @@ static int snd_cs46xx_midi_input_close(snd_rawmidi_substream_t * substream) snd_cs46xx_pokeBA0(chip, BA0_MIDCR, chip->midcr); } chip->uartm &= ~CS46XX_MODE_INPUT; - spin_unlock_irqrestore(&chip->reg_lock, flags); + spin_unlock_irq(&chip->reg_lock); chip->active_ctrl(chip, -1); return 0; } -static int snd_cs46xx_midi_output_open(snd_rawmidi_substream_t * substream) +static int snd_cs46xx_midi_output_open(struct snd_rawmidi_substream *substream) { - unsigned long flags; - cs46xx_t *chip = snd_magic_cast(cs46xx_t, substream->rmidi->private_data, return -ENXIO); + struct snd_cs46xx *chip = substream->rmidi->private_data; chip->active_ctrl(chip, 1); - spin_lock_irqsave(&chip->reg_lock, flags); + spin_lock_irq(&chip->reg_lock); chip->uartm |= CS46XX_MODE_OUTPUT; chip->midcr |= MIDCR_TXE; chip->midi_output = substream; @@ -2657,16 +2544,15 @@ static int snd_cs46xx_midi_output_open(snd_rawmidi_substream_t * substream) } else { snd_cs46xx_pokeBA0(chip, BA0_MIDCR, chip->midcr); } - spin_unlock_irqrestore(&chip->reg_lock, flags); + spin_unlock_irq(&chip->reg_lock); return 0; } -static int snd_cs46xx_midi_output_close(snd_rawmidi_substream_t * substream) +static int snd_cs46xx_midi_output_close(struct snd_rawmidi_substream *substream) { - unsigned long flags; - cs46xx_t *chip = snd_magic_cast(cs46xx_t, substream->rmidi->private_data, return -ENXIO); + struct snd_cs46xx *chip = substream->rmidi->private_data; - spin_lock_irqsave(&chip->reg_lock, flags); + spin_lock_irq(&chip->reg_lock); chip->midcr &= ~(MIDCR_TXE | MIDCR_TIE); chip->midi_output = NULL; if (!(chip->uartm & CS46XX_MODE_INPUT)) { @@ -2675,15 +2561,15 @@ static int snd_cs46xx_midi_output_close(snd_rawmidi_substream_t * substream) snd_cs46xx_pokeBA0(chip, BA0_MIDCR, chip->midcr); } chip->uartm &= ~CS46XX_MODE_OUTPUT; - spin_unlock_irqrestore(&chip->reg_lock, flags); + spin_unlock_irq(&chip->reg_lock); chip->active_ctrl(chip, -1); return 0; } -static void snd_cs46xx_midi_input_trigger(snd_rawmidi_substream_t * substream, int up) +static void snd_cs46xx_midi_input_trigger(struct snd_rawmidi_substream *substream, int up) { unsigned long flags; - cs46xx_t *chip = snd_magic_cast(cs46xx_t, substream->rmidi->private_data, return); + struct snd_cs46xx *chip = substream->rmidi->private_data; spin_lock_irqsave(&chip->reg_lock, flags); if (up) { @@ -2700,10 +2586,10 @@ static void snd_cs46xx_midi_input_trigger(snd_rawmidi_substream_t * substream, i spin_unlock_irqrestore(&chip->reg_lock, flags); } -static void snd_cs46xx_midi_output_trigger(snd_rawmidi_substream_t * substream, int up) +static void snd_cs46xx_midi_output_trigger(struct snd_rawmidi_substream *substream, int up) { unsigned long flags; - cs46xx_t *chip = snd_magic_cast(cs46xx_t, substream->rmidi->private_data, return); + struct snd_cs46xx *chip = substream->rmidi->private_data; unsigned char byte; spin_lock_irqsave(&chip->reg_lock, flags); @@ -2730,23 +2616,23 @@ static void snd_cs46xx_midi_output_trigger(snd_rawmidi_substream_t * substream, spin_unlock_irqrestore(&chip->reg_lock, flags); } -static snd_rawmidi_ops_t snd_cs46xx_midi_output = +static struct snd_rawmidi_ops snd_cs46xx_midi_output = { .open = snd_cs46xx_midi_output_open, .close = snd_cs46xx_midi_output_close, .trigger = snd_cs46xx_midi_output_trigger, }; -static snd_rawmidi_ops_t snd_cs46xx_midi_input = +static struct snd_rawmidi_ops snd_cs46xx_midi_input = { .open = snd_cs46xx_midi_input_open, .close = snd_cs46xx_midi_input_close, .trigger = snd_cs46xx_midi_input_trigger, }; -int __devinit snd_cs46xx_midi(cs46xx_t *chip, int device, snd_rawmidi_t **rrawmidi) +int __devinit snd_cs46xx_midi(struct snd_cs46xx *chip, int device, struct snd_rawmidi **rrawmidi) { - snd_rawmidi_t *rmidi; + struct snd_rawmidi *rmidi; int err; if (rrawmidi) @@ -2771,37 +2657,28 @@ int __devinit snd_cs46xx_midi(cs46xx_t *chip, int device, snd_rawmidi_t **rrawmi #if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE)) -typedef struct snd_cs46xx_gameport { - struct gameport info; - cs46xx_t *chip; -} cs46xx_gameport_t; - static void snd_cs46xx_gameport_trigger(struct gameport *gameport) { - cs46xx_gameport_t *gp = (cs46xx_gameport_t *)gameport; - cs46xx_t *chip; - snd_assert(gp, return); - chip = snd_magic_cast(cs46xx_t, gp->chip, return); + struct snd_cs46xx *chip = gameport_get_port_data(gameport); + + snd_assert(chip, return); snd_cs46xx_pokeBA0(chip, BA0_JSPT, 0xFF); //outb(gameport->io, 0xFF); } static unsigned char snd_cs46xx_gameport_read(struct gameport *gameport) { - cs46xx_gameport_t *gp = (cs46xx_gameport_t *)gameport; - cs46xx_t *chip; - snd_assert(gp, return 0); - chip = snd_magic_cast(cs46xx_t, gp->chip, return 0); + struct snd_cs46xx *chip = gameport_get_port_data(gameport); + + snd_assert(chip, return 0); return snd_cs46xx_peekBA0(chip, BA0_JSPT); //inb(gameport->io); } static int snd_cs46xx_gameport_cooked_read(struct gameport *gameport, int *axes, int *buttons) { - cs46xx_gameport_t *gp = (cs46xx_gameport_t *)gameport; - cs46xx_t *chip; + struct snd_cs46xx *chip = gameport_get_port_data(gameport); unsigned js1, js2, jst; - - snd_assert(gp, return 0); - chip = snd_magic_cast(cs46xx_t, gp->chip, return 0); + + snd_assert(chip, return 0); js1 = snd_cs46xx_peekBA0(chip, BA0_JSC1); js2 = snd_cs46xx_peekBA0(chip, BA0_JSC2); @@ -2832,52 +2709,64 @@ static int snd_cs46xx_gameport_open(struct gameport *gameport, int mode) return 0; } -void __devinit snd_cs46xx_gameport(cs46xx_t *chip) +int __devinit snd_cs46xx_gameport(struct snd_cs46xx *chip) { - cs46xx_gameport_t *gp; - gp = kmalloc(sizeof(*gp), GFP_KERNEL); - if (! gp) { - snd_printk("cannot allocate gameport area\n"); - return; + struct gameport *gp; + + chip->gameport = gp = gameport_allocate_port(); + if (!gp) { + printk(KERN_ERR "cs46xx: cannot allocate memory for gameport\n"); + return -ENOMEM; } - memset(gp, 0, sizeof(*gp)); - gp->info.open = snd_cs46xx_gameport_open; - gp->info.read = snd_cs46xx_gameport_read; - gp->info.trigger = snd_cs46xx_gameport_trigger; - gp->info.cooked_read = snd_cs46xx_gameport_cooked_read; - gp->chip = chip; - chip->gameport = gp; + + gameport_set_name(gp, "CS46xx Gameport"); + gameport_set_phys(gp, "pci%s/gameport0", pci_name(chip->pci)); + gameport_set_dev_parent(gp, &chip->pci->dev); + gameport_set_port_data(gp, chip); + + gp->open = snd_cs46xx_gameport_open; + gp->read = snd_cs46xx_gameport_read; + gp->trigger = snd_cs46xx_gameport_trigger; + gp->cooked_read = snd_cs46xx_gameport_cooked_read; snd_cs46xx_pokeBA0(chip, BA0_JSIO, 0xFF); // ? snd_cs46xx_pokeBA0(chip, BA0_JSCTL, JSCTL_SP_MEDIUM_SLOW); - gameport_register_port(&gp->info); -} -#else + gameport_register_port(gp); -void __devinit snd_cs46xx_gameport(cs46xx_t *chip) -{ + return 0; } +static inline void snd_cs46xx_remove_gameport(struct snd_cs46xx *chip) +{ + if (chip->gameport) { + gameport_unregister_port(chip->gameport); + chip->gameport = NULL; + } +} +#else +int __devinit snd_cs46xx_gameport(struct snd_cs46xx *chip) { return -ENOSYS; } +static inline void snd_cs46xx_remove_gameport(struct snd_cs46xx *chip) { } #endif /* CONFIG_GAMEPORT */ +#ifdef CONFIG_PROC_FS /* * proc interface */ -static long snd_cs46xx_io_read(snd_info_entry_t *entry, void *file_private_data, - struct file *file, char __user *buf, long count) +static long snd_cs46xx_io_read(struct snd_info_entry *entry, void *file_private_data, + struct file *file, char __user *buf, + unsigned long count, unsigned long pos) { long size; - snd_cs46xx_region_t *region = (snd_cs46xx_region_t *)entry->private_data; + struct snd_cs46xx_region *region = entry->private_data; size = count; - if (file->f_pos + (size_t)size > region->size) - size = region->size - file->f_pos; + if (pos + (size_t)size > region->size) + size = region->size - pos; if (size > 0) { - if (copy_to_user_fromio(buf, region->remap_addr + file->f_pos, size)) + if (copy_to_user_fromio(buf, region->remap_addr + pos, size)) return -EFAULT; - file->f_pos += size; } return size; } @@ -2886,13 +2775,13 @@ static struct snd_info_entry_ops snd_cs46xx_proc_io_ops = { .read = snd_cs46xx_io_read, }; -static int __devinit snd_cs46xx_proc_init(snd_card_t * card, cs46xx_t *chip) +static int __devinit snd_cs46xx_proc_init(struct snd_card *card, struct snd_cs46xx *chip) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; int idx; for (idx = 0; idx < 5; idx++) { - snd_cs46xx_region_t *region = &chip->region.idx[idx]; + struct snd_cs46xx_region *region = &chip->region.idx[idx]; if (! snd_card_proc_new(card, region->name, &entry)) { entry->content = SNDRV_INFO_CONTENT_DATA; entry->private_data = chip; @@ -2907,18 +2796,22 @@ static int __devinit snd_cs46xx_proc_init(snd_card_t * card, cs46xx_t *chip) return 0; } -static int snd_cs46xx_proc_done(cs46xx_t *chip) +static int snd_cs46xx_proc_done(struct snd_cs46xx *chip) { #ifdef CONFIG_SND_CS46XX_NEW_DSP cs46xx_dsp_proc_done(chip); #endif return 0; } +#else /* !CONFIG_PROC_FS */ +#define snd_cs46xx_proc_init(card, chip) +#define snd_cs46xx_proc_done(chip) +#endif /* * stop the h/w */ -static void snd_cs46xx_hw_stop(cs46xx_t *chip) +static void snd_cs46xx_hw_stop(struct snd_cs46xx *chip) { unsigned int tmp; @@ -2965,7 +2858,7 @@ static void snd_cs46xx_hw_stop(cs46xx_t *chip) } -static int snd_cs46xx_free(cs46xx_t *chip) +static int snd_cs46xx_free(struct snd_cs46xx *chip) { int idx; @@ -2974,12 +2867,7 @@ static int snd_cs46xx_free(cs46xx_t *chip) if (chip->active_ctrl) chip->active_ctrl(chip, 1); -#if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE)) - if (chip->gameport) { - gameport_unregister_port(&chip->gameport->info); - kfree(chip->gameport); - } -#endif + snd_cs46xx_remove_gameport(chip); if (chip->amplifier_ctrl) chip->amplifier_ctrl(chip, -chip->amplifier); /* force to off */ @@ -2990,16 +2878,13 @@ static int snd_cs46xx_free(cs46xx_t *chip) snd_cs46xx_hw_stop(chip); for (idx = 0; idx < 5; idx++) { - snd_cs46xx_region_t *region = &chip->region.idx[idx]; + struct snd_cs46xx_region *region = &chip->region.idx[idx]; if (region->remap_addr) - iounmap((void *) region->remap_addr); - if (region->resource) { - release_resource(region->resource); - kfree_nocheck(region->resource); - } + iounmap(region->remap_addr); + release_and_free_resource(region->resource); } if (chip->irq >= 0) - free_irq(chip->irq, (void *)chip); + free_irq(chip->irq, chip); if (chip->active_ctrl) chip->active_ctrl(chip, -chip->amplifier); @@ -3011,20 +2896,21 @@ static int snd_cs46xx_free(cs46xx_t *chip) } #endif - snd_magic_kfree(chip); + pci_disable_device(chip->pci); + kfree(chip); return 0; } -static int snd_cs46xx_dev_free(snd_device_t *device) +static int snd_cs46xx_dev_free(struct snd_device *device) { - cs46xx_t *chip = snd_magic_cast(cs46xx_t, device->device_data, return -ENXIO); + struct snd_cs46xx *chip = device->device_data; return snd_cs46xx_free(chip); } /* * initialize chip */ -static int snd_cs46xx_chip_init(cs46xx_t *chip) +static int snd_cs46xx_chip_init(struct snd_cs46xx *chip) { int timeout; @@ -3104,8 +2990,7 @@ static int snd_cs46xx_chip_init(cs46xx_t *chip) /* * Wait until the PLL has stabilized. */ - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(HZ/10); /* 100ms */ + msleep(100); /* * Turn on clocking of the core so that we can setup the serial ports. @@ -3158,13 +3043,12 @@ static int snd_cs46xx_chip_init(cs46xx_t *chip) */ if (snd_cs46xx_peekBA0(chip, BA0_ACSTS) & ACSTS_CRDY) goto ok1; - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout((HZ+99)/100); + msleep(10); } - snd_printk("create - never read codec ready from AC'97\n"); - snd_printk("it is not probably bug, try to use CS4236 driver\n"); + snd_printk(KERN_ERR "create - never read codec ready from AC'97\n"); + snd_printk(KERN_ERR "it is not probably bug, try to use CS4236 driver\n"); return -EIO; ok1: #ifdef CONFIG_SND_CS46XX_NEW_DSP @@ -3208,22 +3092,21 @@ static int snd_cs46xx_chip_init(cs46xx_t *chip) */ if ((snd_cs46xx_peekBA0(chip, BA0_ACISV) & (ACISV_ISV3 | ACISV_ISV4)) == (ACISV_ISV3 | ACISV_ISV4)) goto ok2; - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout((HZ+99)/100); + msleep(10); } #ifndef CONFIG_SND_CS46XX_NEW_DSP - snd_printk("create - never read ISV3 & ISV4 from AC'97\n"); + snd_printk(KERN_ERR "create - never read ISV3 & ISV4 from AC'97\n"); return -EIO; #else /* This may happen on a cold boot with a Terratec SiXPack 5.1. Reloading the driver may help, if there's other soundcards with the same problem I would like to know. (Benny) */ - snd_printk("ERROR: snd-cs46xx: never read ISV3 & ISV4 from AC'97\n"); - snd_printk(" Try reloading the ALSA driver, if you find something\n"); - snd_printk(" broken or not working on your soundcard upon\n"); - snd_printk(" this message please report to alsa-devel@lists.sourceforge.net\n"); + snd_printk(KERN_ERR "ERROR: snd-cs46xx: never read ISV3 & ISV4 from AC'97\n"); + snd_printk(KERN_ERR " Try reloading the ALSA driver, if you find something\n"); + snd_printk(KERN_ERR " broken or not working on your soundcard upon\n"); + snd_printk(KERN_ERR " this message please report to alsa-devel@lists.sourceforge.net\n"); return -EIO; #endif @@ -3256,7 +3139,7 @@ static int snd_cs46xx_chip_init(cs46xx_t *chip) /* * start and load DSP */ -int __devinit snd_cs46xx_start_dsp(cs46xx_t *chip) +int __devinit snd_cs46xx_start_dsp(struct snd_cs46xx *chip) { unsigned int tmp; /* @@ -3304,7 +3187,7 @@ int __devinit snd_cs46xx_start_dsp(cs46xx_t *chip) #else /* old image */ if (snd_cs46xx_download_image(chip) < 0) { - snd_printk("image download error\n"); + snd_printk(KERN_ERR "image download error\n"); return -EIO; } @@ -3358,12 +3241,12 @@ int __devinit snd_cs46xx_start_dsp(cs46xx_t *chip) * AMP control - null AMP */ -static void amp_none(cs46xx_t *chip, int change) +static void amp_none(struct snd_cs46xx *chip, int change) { } #ifdef CONFIG_SND_CS46XX_NEW_DSP -static int voyetra_setup_eapd_slot(cs46xx_t *chip) +static int voyetra_setup_eapd_slot(struct snd_cs46xx *chip) { u32 idx, valid_slots,tmp,powerdown = 0; @@ -3483,7 +3366,7 @@ static int voyetra_setup_eapd_slot(cs46xx_t *chip) * Crystal EAPD mode */ -static void amp_voyetra(cs46xx_t *chip, int change) +static void amp_voyetra(struct snd_cs46xx *chip, int change) { /* Manage the EAPD bit on the Crystal 4297 and the Analog AD1885 */ @@ -3519,7 +3402,7 @@ static void amp_voyetra(cs46xx_t *chip, int change) #endif } -static void hercules_init(cs46xx_t *chip) +static void hercules_init(struct snd_cs46xx *chip) { /* default: AMP off, and SPDIF input optical */ snd_cs46xx_pokeBA0(chip, BA0_EGPIODR, EGPIODR_GPOE0); @@ -3530,7 +3413,7 @@ static void hercules_init(cs46xx_t *chip) /* * Game Theatre XP card - EGPIO[2] is used to enable the external amp. */ -static void amp_hercules(cs46xx_t *chip, int change) +static void amp_hercules(struct snd_cs46xx *chip, int change) { int old = chip->amplifier; int val1 = snd_cs46xx_peekBA0(chip, BA0_EGPIODR); @@ -3551,7 +3434,7 @@ static void amp_hercules(cs46xx_t *chip, int change) } } -static void voyetra_mixer_init (cs46xx_t *chip) +static void voyetra_mixer_init (struct snd_cs46xx *chip) { snd_printdd ("initializing Voyetra mixer\n"); @@ -3560,12 +3443,12 @@ static void voyetra_mixer_init (cs46xx_t *chip) snd_cs46xx_pokeBA0(chip, BA0_EGPIOPTR, EGPIODR_GPOE0); } -static void hercules_mixer_init (cs46xx_t *chip) +static void hercules_mixer_init (struct snd_cs46xx *chip) { #ifdef CONFIG_SND_CS46XX_NEW_DSP unsigned int idx; int err; - snd_card_t *card = chip->card; + struct snd_card *card = chip->card; #endif /* set EGPIO to default */ @@ -3575,7 +3458,7 @@ static void hercules_mixer_init (cs46xx_t *chip) #ifdef CONFIG_SND_CS46XX_NEW_DSP for (idx = 0 ; idx < ARRAY_SIZE(snd_hercules_controls); idx++) { - snd_kcontrol_t *kctl; + struct snd_kcontrol *kctl; kctl = snd_ctl_new1(&snd_hercules_controls[idx], chip); if ((err = snd_ctl_add(card, kctl)) < 0) { @@ -3592,7 +3475,7 @@ static void hercules_mixer_init (cs46xx_t *chip) * Untested */ -static void amp_voyetra_4294(cs46xx_t *chip, int change) +static void amp_voyetra_4294(struct snd_cs46xx *chip, int change) { chip->amplifier += change; @@ -3613,17 +3496,6 @@ static void amp_voyetra_4294(cs46xx_t *chip, int change) #endif -/* - * piix4 pci ids - */ -#ifndef PCI_VENDOR_ID_INTEL -#define PCI_VENDOR_ID_INTEL 0x8086 -#endif /* PCI_VENDOR_ID_INTEL */ - -#ifndef PCI_DEVICE_ID_INTEL_82371AB_3 -#define PCI_DEVICE_ID_INTEL_82371AB_3 0x7113 -#endif /* PCI_DEVICE_ID_INTEL_82371AB_3 */ - /* * Handle the CLKRUN on a thinkpad. We must disable CLKRUN support * whenever we need to beat on the chip. @@ -3633,11 +3505,11 @@ static void amp_voyetra_4294(cs46xx_t *chip, int change) * enough to make them useful. */ -static void clkrun_hack(cs46xx_t *chip, int change) +static void clkrun_hack(struct snd_cs46xx *chip, int change) { u16 control, nval; - if (chip->acpi_dev == NULL) + if (!chip->acpi_port) return; chip->amplifier += change; @@ -3658,17 +3530,22 @@ static void clkrun_hack(cs46xx_t *chip, int change) /* * detect intel piix4 */ -static void clkrun_init(cs46xx_t *chip) +static void clkrun_init(struct snd_cs46xx *chip) { + struct pci_dev *pdev; u8 pp; - chip->acpi_dev = pci_find_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_3, NULL); - if (chip->acpi_dev == NULL) + chip->acpi_port = 0; + + pdev = pci_get_device(PCI_VENDOR_ID_INTEL, + PCI_DEVICE_ID_INTEL_82371AB_3, NULL); + if (pdev == NULL) return; /* Not a thinkpad thats for sure */ /* Find the control port */ - pci_read_config_byte(chip->acpi_dev, 0x41, &pp); + pci_read_config_byte(pdev, 0x41, &pp); chip->acpi_port = pp << 8; + pci_dev_put(pdev); } @@ -3681,10 +3558,10 @@ struct cs_card_type u16 vendor; u16 id; char *name; - void (*init)(cs46xx_t *); - void (*amp)(cs46xx_t *, int); - void (*active)(cs46xx_t *, int); - void (*mixer_init)(cs46xx_t *); + void (*init)(struct snd_cs46xx *); + void (*amp)(struct snd_cs46xx *, int); + void (*active)(struct snd_cs46xx *, int); + void (*mixer_init)(struct snd_cs46xx *); }; static struct cs_card_type __devinitdata cards[] = { @@ -3784,18 +3661,19 @@ static struct cs_card_type __devinitdata cards[] = { * APM support */ #ifdef CONFIG_PM -static int snd_cs46xx_suspend(snd_card_t *card, unsigned int state) +int snd_cs46xx_suspend(struct pci_dev *pci, pm_message_t state) { - cs46xx_t *chip = snd_magic_cast(cs46xx_t, card->pm_private_data, return -EINVAL); + struct snd_card *card = pci_get_drvdata(pci); + struct snd_cs46xx *chip = card->private_data; int amp_saved; + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); snd_pcm_suspend_all(chip->pcm); // chip->ac97_powerdown = snd_cs46xx_codec_read(chip, AC97_POWER_CONTROL); // chip->ac97_general_purpose = snd_cs46xx_codec_read(chip, BA0_AC97_GENERAL_PURPOSE); snd_ac97_suspend(chip->ac97[CS46XX_PRIMARY_CODEC_INDEX]); - if (chip->ac97[CS46XX_SECONDARY_CODEC_INDEX]) - snd_ac97_suspend(chip->ac97[CS46XX_SECONDARY_CODEC_INDEX]); + snd_ac97_suspend(chip->ac97[CS46XX_SECONDARY_CODEC_INDEX]); amp_saved = chip->amplifier; /* turn off amp */ @@ -3804,16 +3682,20 @@ static int snd_cs46xx_suspend(snd_card_t *card, unsigned int state) /* disable CLKRUN */ chip->active_ctrl(chip, -chip->amplifier); chip->amplifier = amp_saved; /* restore the status */ - snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); + pci_disable_device(pci); + pci_save_state(pci); return 0; } -static int snd_cs46xx_resume(snd_card_t *card, unsigned int state) +int snd_cs46xx_resume(struct pci_dev *pci) { - cs46xx_t *chip = snd_magic_cast(cs46xx_t, card->pm_private_data, return -EINVAL); + struct snd_card *card = pci_get_drvdata(pci); + struct snd_cs46xx *chip = card->private_data; int amp_saved; - pci_enable_device(chip->pci); + pci_restore_state(pci); + pci_enable_device(pci); + pci_set_master(pci); amp_saved = chip->amplifier; chip->amplifier = 0; chip->active_ctrl(chip, 1); /* force to on */ @@ -3832,8 +3714,7 @@ static int snd_cs46xx_resume(snd_card_t *card, unsigned int state) #endif snd_ac97_resume(chip->ac97[CS46XX_PRIMARY_CODEC_INDEX]); - if (chip->ac97[CS46XX_SECONDARY_CODEC_INDEX]) - snd_ac97_resume(chip->ac97[CS46XX_SECONDARY_CODEC_INDEX]); + snd_ac97_resume(chip->ac97[CS46XX_SECONDARY_CODEC_INDEX]); if (amp_saved) chip->amplifier_ctrl(chip, 1); /* turn amp on */ @@ -3849,17 +3730,17 @@ static int snd_cs46xx_resume(snd_card_t *card, unsigned int state) /* */ -int __devinit snd_cs46xx_create(snd_card_t * card, +int __devinit snd_cs46xx_create(struct snd_card *card, struct pci_dev * pci, int external_amp, int thinkpad, - cs46xx_t ** rchip) + struct snd_cs46xx ** rchip) { - cs46xx_t *chip; + struct snd_cs46xx *chip; int err, idx; - snd_cs46xx_region_t *region; + struct snd_cs46xx_region *region; struct cs_card_type *cp; u16 ss_card, ss_vendor; - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_cs46xx_dev_free, }; @@ -3869,12 +3750,14 @@ int __devinit snd_cs46xx_create(snd_card_t * card, if ((err = pci_enable_device(pci)) < 0) return err; - chip = snd_magic_kcalloc(cs46xx_t, 0, GFP_KERNEL); - if (chip == NULL) + chip = kzalloc(sizeof(*chip), GFP_KERNEL); + if (chip == NULL) { + pci_disable_device(pci); return -ENOMEM; + } spin_lock_init(&chip->reg_lock); #ifdef CONFIG_SND_CS46XX_NEW_DSP - init_MUTEX(&chip->spos_mutex); + mutex_init(&chip->spos_mutex); #endif chip->card = card; chip->pci = pci; @@ -3883,7 +3766,8 @@ int __devinit snd_cs46xx_create(snd_card_t * card, chip->ba1_addr = pci_resource_start(pci, 1); if (chip->ba0_addr == 0 || chip->ba0_addr == (unsigned long)~0 || chip->ba1_addr == 0 || chip->ba1_addr == (unsigned long)~0) { - snd_printk("wrong address(es) - ba0 = 0x%lx, ba1 = 0x%lx\n", chip->ba0_addr, chip->ba1_addr); + snd_printk(KERN_ERR "wrong address(es) - ba0 = 0x%lx, ba1 = 0x%lx\n", + chip->ba0_addr, chip->ba1_addr); snd_cs46xx_free(chip); return -ENOMEM; } @@ -3913,10 +3797,6 @@ int __devinit snd_cs46xx_create(snd_card_t * card, region->base = chip->ba1_addr + BA1_SP_REG; region->size = CS46XX_BA1_REG_SIZE; - memset(&chip->dma_dev, 0, sizeof(chip->dma_dev)); - chip->dma_dev.type = SNDRV_DMA_TYPE_DEV; - chip->dma_dev.dev = snd_dma_pci_data(pci); - /* set up amp and clkrun hack */ pci_read_config_word(pci, PCI_SUBSYSTEM_VENDOR_ID, &ss_vendor); pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &ss_card); @@ -3936,12 +3816,12 @@ int __devinit snd_cs46xx_create(snd_card_t * card, } if (external_amp) { - snd_printk("Crystal EAPD support forced on.\n"); + snd_printk(KERN_INFO "Crystal EAPD support forced on.\n"); chip->amplifier_ctrl = amp_voyetra; } if (thinkpad) { - snd_printk("Activating CLKRUN hack for Thinkpad.\n"); + snd_printk(KERN_INFO "Activating CLKRUN hack for Thinkpad.\n"); chip->active_ctrl = clkrun_hack; clkrun_init(chip); } @@ -3957,21 +3837,24 @@ int __devinit snd_cs46xx_create(snd_card_t * card, for (idx = 0; idx < 5; idx++) { region = &chip->region.idx[idx]; - if ((region->resource = request_mem_region(region->base, region->size, region->name)) == NULL) { - snd_printk("unable to request memory region 0x%lx-0x%lx\n", region->base, region->base + region->size - 1); + if ((region->resource = request_mem_region(region->base, region->size, + region->name)) == NULL) { + snd_printk(KERN_ERR "unable to request memory region 0x%lx-0x%lx\n", + region->base, region->base + region->size - 1); snd_cs46xx_free(chip); return -EBUSY; } - region->remap_addr = (unsigned long) ioremap_nocache(region->base, region->size); - if (region->remap_addr == 0) { - snd_printk("%s ioremap problem\n", region->name); + region->remap_addr = ioremap_nocache(region->base, region->size); + if (region->remap_addr == NULL) { + snd_printk(KERN_ERR "%s ioremap problem\n", region->name); snd_cs46xx_free(chip); return -ENOMEM; } } - if (request_irq(pci->irq, snd_cs46xx_interrupt, SA_INTERRUPT|SA_SHIRQ, "CS46XX", (void *) chip)) { - snd_printk("unable to grab IRQ %d\n", pci->irq); + if (request_irq(pci->irq, snd_cs46xx_interrupt, SA_INTERRUPT|SA_SHIRQ, + "CS46XX", chip)) { + snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); snd_cs46xx_free(chip); return -EBUSY; } @@ -3991,15 +3874,13 @@ int __devinit snd_cs46xx_create(snd_card_t * card, return err; } - snd_cs46xx_proc_init(card, chip); - - snd_card_set_pm_callback(card, snd_cs46xx_suspend, snd_cs46xx_resume, chip); - if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { snd_cs46xx_free(chip); return err; } + snd_cs46xx_proc_init(card, chip); + chip->active_ctrl(chip, -1); /* disable CLKRUN */ snd_card_set_dev(card, &pci->dev);