From c3e6f7d8763fa0400d28c57633eb323515ba05fc Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 16 Nov 2005 18:43:35 +0100 Subject: [ALSA] Remove superfluous pcm_free callbacks Remove superflous pcm_free callbacks. Signed-off-by: Takashi Iwai --- sound/pci/ca0106/ca0106_main.c | 8 -------- 1 file changed, 8 deletions(-) (limited to 'sound/pci/ca0106/ca0106_main.c') diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c index 389d967c97f4..a89eed255098 100644 --- a/sound/pci/ca0106/ca0106_main.c +++ b/sound/pci/ca0106/ca0106_main.c @@ -1069,13 +1069,6 @@ static irqreturn_t snd_ca0106_interrupt(int irq, void *dev_id, return IRQ_HANDLED; } -static void snd_ca0106_pcm_free(snd_pcm_t *pcm) -{ - ca0106_t *emu = pcm->private_data; - emu->pcm = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - static int __devinit snd_ca0106_pcm(ca0106_t *emu, int device, snd_pcm_t **rpcm) { snd_pcm_t *pcm; @@ -1088,7 +1081,6 @@ static int __devinit snd_ca0106_pcm(ca0106_t *emu, int device, snd_pcm_t **rpcm) return err; pcm->private_data = emu; - pcm->private_free = snd_ca0106_pcm_free; switch (device) { case 0: -- cgit v1.2.3 From 95a98265eb7b112b3268761053d643635171e219 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 10:40:18 +0100 Subject: [ALSA] ca0106 - Code clean up Modules: CA0106 driver Clean up snd-ca0106 driver code: - Fix spaces and indents - Remove unnecessary spinlocks - Clean up the mixer callbacks using private_value - Clean up mixer constructors using an array Signed-off-by: Takashi Iwai --- sound/pci/ca0106/ca0106_main.c | 74 +++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 44 deletions(-) (limited to 'sound/pci/ca0106/ca0106_main.c') diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c index a89eed255098..0120c4683c79 100644 --- a/sound/pci/ca0106/ca0106_main.c +++ b/sound/pci/ca0106/ca0106_main.c @@ -207,7 +207,8 @@ static snd_pcm_hardware_t snd_ca0106_playback_hw = { SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_MMAP_VALID), .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE, - .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000, + .rates = (SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 | + SNDRV_PCM_RATE_192000), .rate_min = 48000, .rate_max = 192000, .channels_min = 2, //1, @@ -226,7 +227,8 @@ static snd_pcm_hardware_t snd_ca0106_capture_hw = { SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_MMAP_VALID), .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE, - .rates = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000, + .rates = (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 | + SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000), .rate_min = 44100, .rate_max = 192000, .channels_min = 2, @@ -276,11 +278,10 @@ int snd_ca0106_i2c_write(ca0106_t *emu, u32 value) { u32 tmp; - int timeout=0; + int timeout = 0; int status; int retry; - if ((reg > 0x7f) || (value > 0x1ff)) - { + if ((reg > 0x7f) || (value > 0x1ff)) { snd_printk(KERN_ERR "i2c_write: invalid values.\n"); return -EINVAL; } @@ -292,8 +293,7 @@ int snd_ca0106_i2c_write(ca0106_t *emu, /* This controls the I2C connected to the WM8775 ADC Codec */ snd_ca0106_ptr_write(emu, I2C_D1, 0, tmp); - for(retry=0;retry<10;retry++) - { + for (retry = 0; retry < 10; retry++) { /* Send the data to i2c */ tmp = snd_ca0106_ptr_read(emu, I2C_A, 0); tmp = tmp & ~(I2C_A_ADC_READ|I2C_A_ADC_LAST|I2C_A_ADC_START|I2C_A_ADC_ADD_MASK); @@ -301,24 +301,22 @@ int snd_ca0106_i2c_write(ca0106_t *emu, snd_ca0106_ptr_write(emu, I2C_A, 0, tmp); /* Wait till the transaction ends */ - while(1) - { + while (1) { status = snd_ca0106_ptr_read(emu, I2C_A, 0); //snd_printk("I2C:status=0x%x\n", status); timeout++; - if((status & I2C_A_ADC_START)==0) + if ((status & I2C_A_ADC_START) == 0) break; - if(timeout>1000) + if (timeout > 1000) break; } //Read back and see if the transaction is successful - if((status & I2C_A_ADC_ABORT)==0) + if ((status & I2C_A_ADC_ABORT) == 0) break; } - if(retry==10) - { + if (retry == 10) { snd_printk(KERN_ERR "Writing to ADC failed!\n"); return -EINVAL; } @@ -380,10 +378,10 @@ static int snd_ca0106_pcm_open_playback_channel(snd_pcm_substream_t *substream, channel->emu = chip; channel->number = channel_id; - channel->use=1; + channel->use = 1; //printk("open:channel_id=%d, chip=%p, channel=%p\n",channel_id, chip, channel); //channel->interrupt = snd_ca0106_pcm_channel_interrupt; - channel->epcm=epcm; + channel->epcm = epcm; if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0) return err; if ((err = snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 64)) < 0) @@ -448,10 +446,10 @@ static int snd_ca0106_pcm_open_capture_channel(snd_pcm_substream_t *substream, i channel->emu = chip; channel->number = channel_id; - channel->use=1; + channel->use = 1; //printk("open:channel_id=%d, chip=%p, channel=%p\n",channel_id, chip, channel); //channel->interrupt = snd_ca0106_pcm_channel_interrupt; - channel->epcm=epcm; + channel->epcm = epcm; if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0) return err; //snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, &hw_constraints_capture_period_sizes); @@ -593,8 +591,8 @@ static int snd_ca0106_pcm_prepare_playback(snd_pcm_substream_t *substream) /* FIXME: Check emu->buffer.size before actually writing to it. */ for(i=0; i < runtime->periods; i++) { - table_base[i*2]=runtime->dma_addr+(i*period_size_bytes); - table_base[(i*2)+1]=period_size_bytes<<16; + table_base[i*2] = runtime->dma_addr + (i * period_size_bytes); + table_base[i*2+1] = period_size_bytes << 16; } snd_ca0106_ptr_write(emu, PLAYBACK_LIST_ADDR, channel, emu->buffer.addr+(8*16*channel)); @@ -1008,13 +1006,8 @@ static irqreturn_t snd_ca0106_interrupt(int irq, void *dev_id, unsigned int stat76; ca0106_channel_t *pchannel; - spin_lock(&chip->emu_lock); - status = inl(chip->port + IPR); - // call updater, unlock before it - spin_unlock(&chip->emu_lock); - if (! status) return IRQ_NONE; @@ -1024,11 +1017,11 @@ static irqreturn_t snd_ca0106_interrupt(int irq, void *dev_id, mask = 0x11; /* 0x1 for one half, 0x10 for the other half period. */ for(i = 0; i < 4; i++) { pchannel = &(chip->playback_channels[i]); - if(stat76 & mask) { + if (stat76 & mask) { /* FIXME: Select the correct substream for period elapsed */ if(pchannel->use) { - snd_pcm_period_elapsed(pchannel->epcm->substream); - //printk(KERN_INFO "interrupt [%d] used\n", i); + snd_pcm_period_elapsed(pchannel->epcm->substream); + //printk(KERN_INFO "interrupt [%d] used\n", i); } } //printk(KERN_INFO "channel=%p\n",pchannel); @@ -1038,11 +1031,11 @@ static irqreturn_t snd_ca0106_interrupt(int irq, void *dev_id, mask = 0x110000; /* 0x1 for one half, 0x10 for the other half period. */ for(i = 0; i < 4; i++) { pchannel = &(chip->capture_channels[i]); - if(stat76 & mask) { + if (stat76 & mask) { /* FIXME: Select the correct substream for period elapsed */ if(pchannel->use) { - snd_pcm_period_elapsed(pchannel->epcm->substream); - //printk(KERN_INFO "interrupt [%d] used\n", i); + snd_pcm_period_elapsed(pchannel->epcm->substream); + //printk(KERN_INFO "interrupt [%d] used\n", i); } } //printk(KERN_INFO "channel=%p\n",pchannel); @@ -1051,10 +1044,9 @@ static irqreturn_t snd_ca0106_interrupt(int irq, void *dev_id, } snd_ca0106_ptr_write(chip, EXTENDED_INT, 0, stat76); - spin_lock(&chip->emu_lock); if (chip->midi.dev_id && - (status & (chip->midi.ipr_tx|chip->midi.ipr_rx))) { + (status & (chip->midi.ipr_tx|chip->midi.ipr_rx))) { if (chip->midi.interrupt) chip->midi.interrupt(&chip->midi, status); else @@ -1064,8 +1056,6 @@ static irqreturn_t snd_ca0106_interrupt(int irq, void *dev_id, // acknowledge the interrupt if necessary outl(status, chip->port+IPR); - spin_unlock(&chip->emu_lock); - return IRQ_HANDLED; } @@ -1202,8 +1192,9 @@ static int __devinit snd_ca0106_create(snd_card_t *card, strcpy(card->driver, "CA0106"); strcpy(card->shortname, "CA0106"); - for (c=ca0106_chip_details; c->serial; c++) { - if (c->serial == chip->serial) break; + for (c = ca0106_chip_details; c->serial; c++) { + if (c->serial == chip->serial) + break; } chip->details = c; sprintf(card->longname, "%s at 0x%lx irq %i", @@ -1359,7 +1350,7 @@ static int __devinit snd_ca0106_midi(ca0106_t *chip, unsigned int channel) char *name; int err; - if(channel==CA0106_MIDI_CHAN_B) { + if (channel == CA0106_MIDI_CHAN_B) { name = "CA0106 MPU-401 (UART) B"; midi = &chip->midi2; midi->tx_enable = INTE_MIDI_TX_B; @@ -1499,12 +1490,7 @@ static struct pci_driver driver = { // initialization of the module static int __init alsa_card_ca0106_init(void) { - int err; - - if ((err = pci_register_driver(&driver)) > 0) - return err; - - return 0; + return pci_register_driver(&driver); } // clean up the module -- cgit v1.2.3 From e4a3d145455159955d6ac1df976b2ed2a135b858 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 14:55:40 +0100 Subject: [ALSA] Remove xxx_t typedefs: PCI CA0106 Modules: CA0106 driver Remove xxx_t typedefs from the PCI CA0106 driver. Signed-off-by: Takashi Iwai --- sound/pci/ca0106/ca0106_main.c | 234 +++++++++++++++++++++-------------------- 1 file changed, 118 insertions(+), 116 deletions(-) (limited to 'sound/pci/ca0106/ca0106_main.c') diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c index 0120c4683c79..744f97183723 100644 --- a/sound/pci/ca0106/ca0106_main.c +++ b/sound/pci/ca0106/ca0106_main.c @@ -164,7 +164,7 @@ MODULE_PARM_DESC(enable, "Enable the CA0106 soundcard."); #include "ca0106.h" -static ca0106_details_t ca0106_chip_details[] = { +static struct snd_ca0106_details ca0106_chip_details[] = { /* AudigyLS[SB0310] */ { .serial = 0x10021102, .name = "AudigyLS [SB0310]", @@ -201,7 +201,7 @@ static ca0106_details_t ca0106_chip_details[] = { }; /* hardware definition */ -static snd_pcm_hardware_t snd_ca0106_playback_hw = { +static struct snd_pcm_hardware snd_ca0106_playback_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -221,7 +221,7 @@ static snd_pcm_hardware_t snd_ca0106_playback_hw = { .fifo_size = 0, }; -static snd_pcm_hardware_t snd_ca0106_capture_hw = { +static struct snd_pcm_hardware snd_ca0106_capture_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -241,7 +241,7 @@ static snd_pcm_hardware_t snd_ca0106_capture_hw = { .fifo_size = 0, }; -unsigned int snd_ca0106_ptr_read(ca0106_t * emu, +unsigned int snd_ca0106_ptr_read(struct snd_ca0106 * emu, unsigned int reg, unsigned int chn) { @@ -257,7 +257,7 @@ unsigned int snd_ca0106_ptr_read(ca0106_t * emu, return val; } -void snd_ca0106_ptr_write(ca0106_t *emu, +void snd_ca0106_ptr_write(struct snd_ca0106 *emu, unsigned int reg, unsigned int chn, unsigned int data) @@ -273,7 +273,7 @@ void snd_ca0106_ptr_write(ca0106_t *emu, spin_unlock_irqrestore(&emu->emu_lock, flags); } -int snd_ca0106_i2c_write(ca0106_t *emu, +int snd_ca0106_i2c_write(struct snd_ca0106 *emu, u32 reg, u32 value) { @@ -325,7 +325,7 @@ int snd_ca0106_i2c_write(ca0106_t *emu, } -static void snd_ca0106_intr_enable(ca0106_t *emu, unsigned int intrenb) +static void snd_ca0106_intr_enable(struct snd_ca0106 *emu, unsigned int intrenb) { unsigned long flags; unsigned int enable; @@ -336,7 +336,7 @@ static void snd_ca0106_intr_enable(ca0106_t *emu, unsigned int intrenb) spin_unlock_irqrestore(&emu->emu_lock, flags); } -static void snd_ca0106_intr_disable(ca0106_t *emu, unsigned int intrenb) +static void snd_ca0106_intr_disable(struct snd_ca0106 *emu, unsigned int intrenb) { unsigned long flags; unsigned int enable; @@ -348,18 +348,19 @@ static void snd_ca0106_intr_disable(ca0106_t *emu, unsigned int intrenb) } -static void snd_ca0106_pcm_free_substream(snd_pcm_runtime_t *runtime) +static void snd_ca0106_pcm_free_substream(struct snd_pcm_runtime *runtime) { kfree(runtime->private_data); } /* open_playback callback */ -static int snd_ca0106_pcm_open_playback_channel(snd_pcm_substream_t *substream, int channel_id) +static int snd_ca0106_pcm_open_playback_channel(struct snd_pcm_substream *substream, + int channel_id) { - ca0106_t *chip = snd_pcm_substream_chip(substream); - ca0106_channel_t *channel = &(chip->playback_channels[channel_id]); - ca0106_pcm_t *epcm; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_ca0106 *chip = snd_pcm_substream_chip(substream); + struct snd_ca0106_channel *channel = &(chip->playback_channels[channel_id]); + struct snd_ca0106_pcm *epcm; + struct snd_pcm_runtime *runtime = substream->runtime; int err; epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); @@ -390,43 +391,44 @@ static int snd_ca0106_pcm_open_playback_channel(snd_pcm_substream_t *substream, } /* close callback */ -static int snd_ca0106_pcm_close_playback(snd_pcm_substream_t *substream) +static int snd_ca0106_pcm_close_playback(struct snd_pcm_substream *substream) { - ca0106_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - ca0106_pcm_t *epcm = runtime->private_data; - chip->playback_channels[epcm->channel_id].use=0; -/* FIXME: maybe zero others */ + struct snd_ca0106 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_ca0106_pcm *epcm = runtime->private_data; + chip->playback_channels[epcm->channel_id].use = 0; + /* FIXME: maybe zero others */ return 0; } -static int snd_ca0106_pcm_open_playback_front(snd_pcm_substream_t *substream) +static int snd_ca0106_pcm_open_playback_front(struct snd_pcm_substream *substream) { return snd_ca0106_pcm_open_playback_channel(substream, PCM_FRONT_CHANNEL); } -static int snd_ca0106_pcm_open_playback_center_lfe(snd_pcm_substream_t *substream) +static int snd_ca0106_pcm_open_playback_center_lfe(struct snd_pcm_substream *substream) { return snd_ca0106_pcm_open_playback_channel(substream, PCM_CENTER_LFE_CHANNEL); } -static int snd_ca0106_pcm_open_playback_unknown(snd_pcm_substream_t *substream) +static int snd_ca0106_pcm_open_playback_unknown(struct snd_pcm_substream *substream) { return snd_ca0106_pcm_open_playback_channel(substream, PCM_UNKNOWN_CHANNEL); } -static int snd_ca0106_pcm_open_playback_rear(snd_pcm_substream_t *substream) +static int snd_ca0106_pcm_open_playback_rear(struct snd_pcm_substream *substream) { return snd_ca0106_pcm_open_playback_channel(substream, PCM_REAR_CHANNEL); } /* open_capture callback */ -static int snd_ca0106_pcm_open_capture_channel(snd_pcm_substream_t *substream, int channel_id) +static int snd_ca0106_pcm_open_capture_channel(struct snd_pcm_substream *substream, + int channel_id) { - ca0106_t *chip = snd_pcm_substream_chip(substream); - ca0106_channel_t *channel = &(chip->capture_channels[channel_id]); - ca0106_pcm_t *epcm; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_ca0106 *chip = snd_pcm_substream_chip(substream); + struct snd_ca0106_channel *channel = &(chip->capture_channels[channel_id]); + struct snd_ca0106_pcm *epcm; + struct snd_pcm_runtime *runtime = substream->runtime; int err; epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); @@ -449,7 +451,7 @@ static int snd_ca0106_pcm_open_capture_channel(snd_pcm_substream_t *substream, i channel->use = 1; //printk("open:channel_id=%d, chip=%p, channel=%p\n",channel_id, chip, channel); //channel->interrupt = snd_ca0106_pcm_channel_interrupt; - channel->epcm = epcm; + channel->epcm = epcm; if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0) return err; //snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, &hw_constraints_capture_period_sizes); @@ -459,70 +461,70 @@ static int snd_ca0106_pcm_open_capture_channel(snd_pcm_substream_t *substream, i } /* close callback */ -static int snd_ca0106_pcm_close_capture(snd_pcm_substream_t *substream) +static int snd_ca0106_pcm_close_capture(struct snd_pcm_substream *substream) { - ca0106_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - ca0106_pcm_t *epcm = runtime->private_data; - chip->capture_channels[epcm->channel_id].use=0; -/* FIXME: maybe zero others */ + struct snd_ca0106 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_ca0106_pcm *epcm = runtime->private_data; + chip->capture_channels[epcm->channel_id].use = 0; + /* FIXME: maybe zero others */ return 0; } -static int snd_ca0106_pcm_open_0_capture(snd_pcm_substream_t *substream) +static int snd_ca0106_pcm_open_0_capture(struct snd_pcm_substream *substream) { return snd_ca0106_pcm_open_capture_channel(substream, 0); } -static int snd_ca0106_pcm_open_1_capture(snd_pcm_substream_t *substream) +static int snd_ca0106_pcm_open_1_capture(struct snd_pcm_substream *substream) { return snd_ca0106_pcm_open_capture_channel(substream, 1); } -static int snd_ca0106_pcm_open_2_capture(snd_pcm_substream_t *substream) +static int snd_ca0106_pcm_open_2_capture(struct snd_pcm_substream *substream) { return snd_ca0106_pcm_open_capture_channel(substream, 2); } -static int snd_ca0106_pcm_open_3_capture(snd_pcm_substream_t *substream) +static int snd_ca0106_pcm_open_3_capture(struct snd_pcm_substream *substream) { return snd_ca0106_pcm_open_capture_channel(substream, 3); } /* hw_params callback */ -static int snd_ca0106_pcm_hw_params_playback(snd_pcm_substream_t *substream, - snd_pcm_hw_params_t * hw_params) +static int snd_ca0106_pcm_hw_params_playback(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); } /* hw_free callback */ -static int snd_ca0106_pcm_hw_free_playback(snd_pcm_substream_t *substream) +static int snd_ca0106_pcm_hw_free_playback(struct snd_pcm_substream *substream) { return snd_pcm_lib_free_pages(substream); } /* hw_params callback */ -static int snd_ca0106_pcm_hw_params_capture(snd_pcm_substream_t *substream, - snd_pcm_hw_params_t * hw_params) +static int snd_ca0106_pcm_hw_params_capture(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); } /* hw_free callback */ -static int snd_ca0106_pcm_hw_free_capture(snd_pcm_substream_t *substream) +static int snd_ca0106_pcm_hw_free_capture(struct snd_pcm_substream *substream) { return snd_pcm_lib_free_pages(substream); } /* prepare playback callback */ -static int snd_ca0106_pcm_prepare_playback(snd_pcm_substream_t *substream) +static int snd_ca0106_pcm_prepare_playback(struct snd_pcm_substream *substream) { - ca0106_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - ca0106_pcm_t *epcm = runtime->private_data; + struct snd_ca0106 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_ca0106_pcm *epcm = runtime->private_data; int channel = epcm->channel_id; u32 *table_base = (u32 *)(emu->buffer.area+(8*16*channel)); u32 period_size_bytes = frames_to_bytes(runtime, runtime->period_size); @@ -619,11 +621,11 @@ static int snd_ca0106_pcm_prepare_playback(snd_pcm_substream_t *substream) } /* prepare capture callback */ -static int snd_ca0106_pcm_prepare_capture(snd_pcm_substream_t *substream) +static int snd_ca0106_pcm_prepare_capture(struct snd_pcm_substream *substream) { - ca0106_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - ca0106_pcm_t *epcm = runtime->private_data; + struct snd_ca0106 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_ca0106_pcm *epcm = runtime->private_data; int channel = epcm->channel_id; u32 hcfg_mask = HCFG_CAPTURE_S32_LE; u32 hcfg_set = 0x00000000; @@ -690,16 +692,16 @@ static int snd_ca0106_pcm_prepare_capture(snd_pcm_substream_t *substream) } /* trigger_playback callback */ -static int snd_ca0106_pcm_trigger_playback(snd_pcm_substream_t *substream, +static int snd_ca0106_pcm_trigger_playback(struct snd_pcm_substream *substream, int cmd) { - ca0106_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime; - ca0106_pcm_t *epcm; + struct snd_ca0106 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime; + struct snd_ca0106_pcm *epcm; int channel; int result = 0; struct list_head *pos; - snd_pcm_substream_t *s; + struct snd_pcm_substream *s; u32 basic = 0; u32 extended = 0; int running=0; @@ -743,12 +745,12 @@ static int snd_ca0106_pcm_trigger_playback(snd_pcm_substream_t *substream, } /* trigger_capture callback */ -static int snd_ca0106_pcm_trigger_capture(snd_pcm_substream_t *substream, +static int snd_ca0106_pcm_trigger_capture(struct snd_pcm_substream *substream, int cmd) { - ca0106_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - ca0106_pcm_t *epcm = runtime->private_data; + struct snd_ca0106 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_ca0106_pcm *epcm = runtime->private_data; int channel = epcm->channel_id; int result = 0; @@ -772,11 +774,11 @@ static int snd_ca0106_pcm_trigger_capture(snd_pcm_substream_t *substream, /* pointer_playback callback */ static snd_pcm_uframes_t -snd_ca0106_pcm_pointer_playback(snd_pcm_substream_t *substream) +snd_ca0106_pcm_pointer_playback(struct snd_pcm_substream *substream) { - ca0106_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - ca0106_pcm_t *epcm = runtime->private_data; + struct snd_ca0106 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_ca0106_pcm *epcm = runtime->private_data; snd_pcm_uframes_t ptr, ptr1, ptr2,ptr3,ptr4 = 0; int channel = epcm->channel_id; @@ -799,11 +801,11 @@ snd_ca0106_pcm_pointer_playback(snd_pcm_substream_t *substream) /* pointer_capture callback */ static snd_pcm_uframes_t -snd_ca0106_pcm_pointer_capture(snd_pcm_substream_t *substream) +snd_ca0106_pcm_pointer_capture(struct snd_pcm_substream *substream) { - ca0106_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - ca0106_pcm_t *epcm = runtime->private_data; + struct snd_ca0106 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_ca0106_pcm *epcm = runtime->private_data; snd_pcm_uframes_t ptr, ptr1, ptr2 = 0; int channel = channel=epcm->channel_id; @@ -821,7 +823,7 @@ snd_ca0106_pcm_pointer_capture(snd_pcm_substream_t *substream) } /* operators */ -static snd_pcm_ops_t snd_ca0106_playback_front_ops = { +static struct snd_pcm_ops snd_ca0106_playback_front_ops = { .open = snd_ca0106_pcm_open_playback_front, .close = snd_ca0106_pcm_close_playback, .ioctl = snd_pcm_lib_ioctl, @@ -832,7 +834,7 @@ static snd_pcm_ops_t snd_ca0106_playback_front_ops = { .pointer = snd_ca0106_pcm_pointer_playback, }; -static snd_pcm_ops_t snd_ca0106_capture_0_ops = { +static struct snd_pcm_ops snd_ca0106_capture_0_ops = { .open = snd_ca0106_pcm_open_0_capture, .close = snd_ca0106_pcm_close_capture, .ioctl = snd_pcm_lib_ioctl, @@ -843,7 +845,7 @@ static snd_pcm_ops_t snd_ca0106_capture_0_ops = { .pointer = snd_ca0106_pcm_pointer_capture, }; -static snd_pcm_ops_t snd_ca0106_capture_1_ops = { +static struct snd_pcm_ops snd_ca0106_capture_1_ops = { .open = snd_ca0106_pcm_open_1_capture, .close = snd_ca0106_pcm_close_capture, .ioctl = snd_pcm_lib_ioctl, @@ -854,7 +856,7 @@ static snd_pcm_ops_t snd_ca0106_capture_1_ops = { .pointer = snd_ca0106_pcm_pointer_capture, }; -static snd_pcm_ops_t snd_ca0106_capture_2_ops = { +static struct snd_pcm_ops snd_ca0106_capture_2_ops = { .open = snd_ca0106_pcm_open_2_capture, .close = snd_ca0106_pcm_close_capture, .ioctl = snd_pcm_lib_ioctl, @@ -865,7 +867,7 @@ static snd_pcm_ops_t snd_ca0106_capture_2_ops = { .pointer = snd_ca0106_pcm_pointer_capture, }; -static snd_pcm_ops_t snd_ca0106_capture_3_ops = { +static struct snd_pcm_ops snd_ca0106_capture_3_ops = { .open = snd_ca0106_pcm_open_3_capture, .close = snd_ca0106_pcm_close_capture, .ioctl = snd_pcm_lib_ioctl, @@ -876,7 +878,7 @@ static snd_pcm_ops_t snd_ca0106_capture_3_ops = { .pointer = snd_ca0106_pcm_pointer_capture, }; -static snd_pcm_ops_t snd_ca0106_playback_center_lfe_ops = { +static struct snd_pcm_ops snd_ca0106_playback_center_lfe_ops = { .open = snd_ca0106_pcm_open_playback_center_lfe, .close = snd_ca0106_pcm_close_playback, .ioctl = snd_pcm_lib_ioctl, @@ -887,7 +889,7 @@ static snd_pcm_ops_t snd_ca0106_playback_center_lfe_ops = { .pointer = snd_ca0106_pcm_pointer_playback, }; -static snd_pcm_ops_t snd_ca0106_playback_unknown_ops = { +static struct snd_pcm_ops snd_ca0106_playback_unknown_ops = { .open = snd_ca0106_pcm_open_playback_unknown, .close = snd_ca0106_pcm_close_playback, .ioctl = snd_pcm_lib_ioctl, @@ -898,7 +900,7 @@ static snd_pcm_ops_t snd_ca0106_playback_unknown_ops = { .pointer = snd_ca0106_pcm_pointer_playback, }; -static snd_pcm_ops_t snd_ca0106_playback_rear_ops = { +static struct snd_pcm_ops snd_ca0106_playback_rear_ops = { .open = snd_ca0106_pcm_open_playback_rear, .close = snd_ca0106_pcm_close_playback, .ioctl = snd_pcm_lib_ioctl, @@ -910,10 +912,10 @@ static snd_pcm_ops_t snd_ca0106_playback_rear_ops = { }; -static unsigned short snd_ca0106_ac97_read(ac97_t *ac97, +static unsigned short snd_ca0106_ac97_read(struct snd_ac97 *ac97, unsigned short reg) { - ca0106_t *emu = ac97->private_data; + struct snd_ca0106 *emu = ac97->private_data; unsigned long flags; unsigned short val; @@ -924,10 +926,10 @@ static unsigned short snd_ca0106_ac97_read(ac97_t *ac97, return val; } -static void snd_ca0106_ac97_write(ac97_t *ac97, +static void snd_ca0106_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short val) { - ca0106_t *emu = ac97->private_data; + struct snd_ca0106 *emu = ac97->private_data; unsigned long flags; spin_lock_irqsave(&emu->emu_lock, flags); @@ -936,12 +938,12 @@ static void snd_ca0106_ac97_write(ac97_t *ac97, spin_unlock_irqrestore(&emu->emu_lock, flags); } -static int snd_ca0106_ac97(ca0106_t *chip) +static int snd_ca0106_ac97(struct snd_ca0106 *chip) { - ac97_bus_t *pbus; - ac97_template_t ac97; + struct snd_ac97_bus *pbus; + struct snd_ac97_template ac97; int err; - static ac97_bus_ops_t ops = { + static struct snd_ac97_bus_ops ops = { .write = snd_ca0106_ac97_write, .read = snd_ca0106_ac97_read, }; @@ -956,7 +958,7 @@ static int snd_ca0106_ac97(ca0106_t *chip) return snd_ac97_mixer(pbus, &ac97, &chip->ac97); } -static int snd_ca0106_free(ca0106_t *chip) +static int snd_ca0106_free(struct snd_ca0106 *chip) { if (chip->res_port != NULL) { /* avoid access to already used hardware */ // disable interrupts @@ -989,9 +991,9 @@ static int snd_ca0106_free(ca0106_t *chip) return 0; } -static int snd_ca0106_dev_free(snd_device_t *device) +static int snd_ca0106_dev_free(struct snd_device *device) { - ca0106_t *chip = device->device_data; + struct snd_ca0106 *chip = device->device_data; return snd_ca0106_free(chip); } @@ -1000,14 +1002,13 @@ static irqreturn_t snd_ca0106_interrupt(int irq, void *dev_id, { unsigned int status; - ca0106_t *chip = dev_id; + struct snd_ca0106 *chip = dev_id; int i; int mask; unsigned int stat76; - ca0106_channel_t *pchannel; + struct snd_ca0106_channel *pchannel; status = inl(chip->port + IPR); - if (! status) return IRQ_NONE; @@ -1059,10 +1060,10 @@ static irqreturn_t snd_ca0106_interrupt(int irq, void *dev_id, return IRQ_HANDLED; } -static int __devinit snd_ca0106_pcm(ca0106_t *emu, int device, snd_pcm_t **rpcm) +static int __devinit snd_ca0106_pcm(struct snd_ca0106 *emu, int device, struct snd_pcm **rpcm) { - snd_pcm_t *pcm; - snd_pcm_substream_t *substream; + struct snd_pcm *pcm; + struct snd_pcm_substream *substream; int err; if (rpcm) @@ -1122,15 +1123,15 @@ static int __devinit snd_ca0106_pcm(ca0106_t *emu, int device, snd_pcm_t **rpcm) return 0; } -static int __devinit snd_ca0106_create(snd_card_t *card, +static int __devinit snd_ca0106_create(struct snd_card *card, struct pci_dev *pci, - ca0106_t **rchip) + struct snd_ca0106 **rchip) { - ca0106_t *chip; - ca0106_details_t *c; + struct snd_ca0106 *chip; + struct snd_ca0106_details *c; int err; int ch; - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_ca0106_dev_free, }; @@ -1314,39 +1315,40 @@ static int __devinit snd_ca0106_create(snd_card_t *card, } -static void ca0106_midi_interrupt_enable(ca_midi_t *midi, int intr) +static void ca0106_midi_interrupt_enable(struct snd_ca_midi *midi, int intr) { - snd_ca0106_intr_enable((ca0106_t *)(midi->dev_id), intr); + snd_ca0106_intr_enable((struct snd_ca0106 *)(midi->dev_id), intr); } -static void ca0106_midi_interrupt_disable(ca_midi_t *midi, int intr) +static void ca0106_midi_interrupt_disable(struct snd_ca_midi *midi, int intr) { - snd_ca0106_intr_disable((ca0106_t *)(midi->dev_id), intr); + snd_ca0106_intr_disable((struct snd_ca0106 *)(midi->dev_id), intr); } -static unsigned char ca0106_midi_read(ca_midi_t *midi, int idx) +static unsigned char ca0106_midi_read(struct snd_ca_midi *midi, int idx) { - return (unsigned char)snd_ca0106_ptr_read((ca0106_t *)(midi->dev_id), midi->port + idx, 0); + return (unsigned char)snd_ca0106_ptr_read((struct snd_ca0106 *)(midi->dev_id), + midi->port + idx, 0); } -static void ca0106_midi_write(ca_midi_t *midi, int data, int idx) +static void ca0106_midi_write(struct snd_ca_midi *midi, int data, int idx) { - snd_ca0106_ptr_write((ca0106_t *)(midi->dev_id), midi->port + idx, 0, data); + snd_ca0106_ptr_write((struct snd_ca0106 *)(midi->dev_id), midi->port + idx, 0, data); } -static snd_card_t *ca0106_dev_id_card(void *dev_id) +static struct snd_card *ca0106_dev_id_card(void *dev_id) { - return ((ca0106_t *)dev_id)->card; + return ((struct snd_ca0106 *)dev_id)->card; } static int ca0106_dev_id_port(void *dev_id) { - return ((ca0106_t *)dev_id)->port; + return ((struct snd_ca0106 *)dev_id)->port; } -static int __devinit snd_ca0106_midi(ca0106_t *chip, unsigned int channel) +static int __devinit snd_ca0106_midi(struct snd_ca0106 *chip, unsigned int channel) { - ca_midi_t *midi; + struct snd_ca_midi *midi; char *name; int err; @@ -1399,8 +1401,8 @@ static int __devinit snd_ca0106_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { static int dev; - snd_card_t *card; - ca0106_t *chip; + struct snd_card *card; + struct snd_ca0106 *chip; int err; if (dev >= SNDRV_CARDS) -- cgit v1.2.3 From adf1b3d25e50dbab48fdd21006bea2dd5a4cb3a8 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 1 Dec 2005 10:49:58 +0100 Subject: [ALSA] Optimize for config without PROC_FS (pci drivers) Optimize the code when compiled without CONFIG_PROC_FS for some pci drivers. Signed-off-by: Takashi Iwai --- sound/pci/ca0106/ca0106_main.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'sound/pci/ca0106/ca0106_main.c') diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c index 744f97183723..5964cdc93f73 100644 --- a/sound/pci/ca0106/ca0106_main.c +++ b/sound/pci/ca0106/ca0106_main.c @@ -1456,7 +1456,9 @@ static int __devinit snd_ca0106_probe(struct pci_dev *pci, } snd_printdd(" done.\n"); +#ifdef CONFIG_PROC_FS snd_ca0106_proc_init(chip); +#endif if ((err = snd_card_register(card)) < 0) { snd_card_free(card); -- cgit v1.2.3 From a5875159dd6cec0ec743971343aee8dceac281d7 Mon Sep 17 00:00:00 2001 From: James Courtier-Dutton Date: Tue, 20 Dec 2005 22:30:49 +0100 Subject: [ALSA] snd-ca0106: Fixes sound output for Creative Audigy SE aka.SB0570. Modules: CA0106 driver Fixes ALSA bug#1636 Signed-off-by: James Courtier-Dutton --- sound/pci/ca0106/ca0106_main.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'sound/pci/ca0106/ca0106_main.c') diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c index 5964cdc93f73..1cf6f1fa98b1 100644 --- a/sound/pci/ca0106/ca0106_main.c +++ b/sound/pci/ca0106/ca0106_main.c @@ -183,6 +183,17 @@ static struct snd_ca0106_details ca0106_chip_details[] = { .name = "Live! 7.1 24bit [SB0413]", .gpio_type = 1, .i2c_adc = 1 } , + /* New Audigy SE. Has a different DAC. */ + /* SB0570: + * CTRL:CA0106-DAT + * ADC: WM8768GEDS + * DAC: WM8775EDS + */ + { .serial = 0x100a1102, + .name = "Audigy SE [SB0570]", + .gpio_type = 1, + .i2c_adc = 1, + .spi_dac = 1 } , /* MSI K8N Diamond Motherboard with onboard SB Live 24bit without AC97 */ { .serial = 0x10091462, .name = "MSI K8N Diamond MB [SB0438]", @@ -273,6 +284,20 @@ void snd_ca0106_ptr_write(struct snd_ca0106 *emu, spin_unlock_irqrestore(&emu->emu_lock, flags); } +int snd_ca0106_spi_write(struct snd_ca0106 *emu, + u32 value) +{ + snd_ca0106_ptr_write(emu, SPI, 0, value); + return 0; +} + +int snd_ca0106_spi_read(struct snd_ca0106 *emu, + u32 *value) +{ + *value = snd_ca0106_ptr_read(emu, SPI, 0); + return 0; +} + int snd_ca0106_i2c_write(struct snd_ca0106 *emu, u32 reg, u32 value) @@ -1304,6 +1329,13 @@ static int __devinit snd_ca0106_create(struct snd_card *card, if (chip->details->i2c_adc == 1) { /* The SB0410 and SB0413 use I2C to control ADC. */ snd_ca0106_i2c_write(chip, ADC_MUX, ADC_MUX_LINEIN); /* Enable Line-in capture. MIC in currently untested. */ } + if (chip->details->spi_dac == 1) { /* The SB0570 use SPI to control DAC. */ + u32 tmp; + snd_ca0106_spi_write(chip, 0xf0622); /* Enable speakers output. */ + snd_ca0106_spi_read(chip, &tmp); /* Read the value. */ + snd_ca0106_spi_write(chip, 0xe1400); + snd_ca0106_spi_read(chip, &tmp); /* Read the value. */ + } if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { -- cgit v1.2.3 From aad9095322c0c7d9637f29b71167458c36a4cdf6 Mon Sep 17 00:00:00 2001 From: James Courtier-Dutton Date: Wed, 21 Dec 2005 22:26:26 +0100 Subject: [ALSA] snd-ca0106: Fix SPI driver code. Fixes speaker output. Modules: CA0106 driver Signed-off-by: James Courtier-Dutton --- sound/pci/ca0106/ca0106_main.c | 72 +++++++++++++++++++++++++++++++++--------- 1 file changed, 57 insertions(+), 15 deletions(-) (limited to 'sound/pci/ca0106/ca0106_main.c') diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c index 1cf6f1fa98b1..6ed7c0bfa091 100644 --- a/sound/pci/ca0106/ca0106_main.c +++ b/sound/pci/ca0106/ca0106_main.c @@ -284,20 +284,38 @@ void snd_ca0106_ptr_write(struct snd_ca0106 *emu, spin_unlock_irqrestore(&emu->emu_lock, flags); } -int snd_ca0106_spi_write(struct snd_ca0106 *emu, - u32 value) +int snd_ca0106_spi_write(struct snd_ca0106 * emu, + unsigned int data) { - snd_ca0106_ptr_write(emu, SPI, 0, value); + unsigned int reset, set; + unsigned int reg, tmp; + int n, result; + reg = SPI; + if (data > 0xffff) /* Only 16bit values allowed */ + return 1; + tmp = snd_ca0106_ptr_read(emu, reg, 0); + reset = (tmp & ~0x3ffff) | 0x20000; /* Set xxx20000 */ + set = reset | 0x10000; /* Set xxx1xxxx */ + snd_ca0106_ptr_write(emu, reg, 0, reset | data); + tmp = snd_ca0106_ptr_read(emu, reg, 0); /* write post */ + snd_ca0106_ptr_write(emu, reg, 0, set | data); + result = 1; + /* Wait for status bit to return to 0 */ + for (n = 0; n < 100; n++) { + udelay(10); + tmp = snd_ca0106_ptr_read(emu, reg, 0); + if (!(tmp & 0x10000)) { + result = 0; + break; + } + } + if (result) /* Timed out */ + return 1; + snd_ca0106_ptr_write(emu, reg, 0, reset | data); + tmp = snd_ca0106_ptr_read(emu, reg, 0); /* Write post */ return 0; } -int snd_ca0106_spi_read(struct snd_ca0106 *emu, - u32 *value) -{ - *value = snd_ca0106_ptr_read(emu, SPI, 0); - return 0; -} - int snd_ca0106_i2c_write(struct snd_ca0106 *emu, u32 reg, u32 value) @@ -1148,6 +1166,30 @@ static int __devinit snd_ca0106_pcm(struct snd_ca0106 *emu, int device, struct s return 0; } +static unsigned int spi_dac_init[] = { + 0x00ff, + 0x02ff, + 0x0400, + 0x0520, + 0x0600, + 0x08ff, + 0x0aff, + 0x0cff, + 0x0eff, + 0x10ff, + 0x1200, + 0x1400, + 0x1480, + 0x1800, + 0x1aff, + 0x1cff, + 0x1e00, + 0x0530, + 0x0602, + 0x0622, + 0x1400, +}; + static int __devinit snd_ca0106_create(struct snd_card *card, struct pci_dev *pci, struct snd_ca0106 **rchip) @@ -1330,11 +1372,11 @@ static int __devinit snd_ca0106_create(struct snd_card *card, snd_ca0106_i2c_write(chip, ADC_MUX, ADC_MUX_LINEIN); /* Enable Line-in capture. MIC in currently untested. */ } if (chip->details->spi_dac == 1) { /* The SB0570 use SPI to control DAC. */ - u32 tmp; - snd_ca0106_spi_write(chip, 0xf0622); /* Enable speakers output. */ - snd_ca0106_spi_read(chip, &tmp); /* Read the value. */ - snd_ca0106_spi_write(chip, 0xe1400); - snd_ca0106_spi_read(chip, &tmp); /* Read the value. */ + int size, n; + + size = ARRAY_SIZE(spi_dac_init); + for (n=0; n < size; n++) + snd_ca0106_spi_write(chip, spi_dac_init[n]); } if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, -- cgit v1.2.3