aboutsummaryrefslogtreecommitdiff
path: root/sound/pci/ca0106
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pci/ca0106')
-rw-r--r--sound/pci/ca0106/ca0106.h55
-rw-r--r--sound/pci/ca0106/ca0106_main.c390
-rw-r--r--sound/pci/ca0106/ca0106_mixer.c500
-rw-r--r--sound/pci/ca0106/ca0106_proc.c63
-rw-r--r--sound/pci/ca0106/ca_midi.c49
-rw-r--r--sound/pci/ca0106/ca_midi.h25
6 files changed, 465 insertions, 617 deletions
diff --git a/sound/pci/ca0106/ca0106.h b/sound/pci/ca0106/ca0106.h
index 9a4b6406f7a..c8131ea92ed 100644
--- a/sound/pci/ca0106/ca0106.h
+++ b/sound/pci/ca0106/ca0106.h
@@ -554,37 +554,36 @@
#include "ca_midi.h"
-typedef struct snd_ca0106_channel ca0106_channel_t;
-typedef struct snd_ca0106 ca0106_t;
-typedef struct snd_ca0106_pcm ca0106_pcm_t;
+struct snd_ca0106;
struct snd_ca0106_channel {
- ca0106_t *emu;
+ struct snd_ca0106 *emu;
int number;
int use;
- void (*interrupt)(ca0106_t *emu, ca0106_channel_t *channel);
- ca0106_pcm_t *epcm;
+ void (*interrupt)(struct snd_ca0106 *emu, struct snd_ca0106_channel *channel);
+ struct snd_ca0106_pcm *epcm;
};
struct snd_ca0106_pcm {
- ca0106_t *emu;
- snd_pcm_substream_t *substream;
+ struct snd_ca0106 *emu;
+ struct snd_pcm_substream *substream;
int channel_id;
unsigned short running;
};
-typedef struct {
+struct snd_ca0106_details {
u32 serial;
char * name;
int ac97;
int gpio_type;
int i2c_adc;
-} ca0106_details_t;
+ int spi_dac;
+};
// definition of the chip-specific record
struct snd_ca0106 {
- snd_card_t *card;
- ca0106_details_t *details;
+ struct snd_card *card;
+ struct snd_ca0106_details *details;
struct pci_dev *pci;
unsigned long port;
@@ -597,11 +596,11 @@ struct snd_ca0106 {
spinlock_t emu_lock;
- ac97_t *ac97;
- snd_pcm_t *pcm;
+ struct snd_ac97 *ac97;
+ struct snd_pcm *pcm;
- ca0106_channel_t playback_channels[4];
- ca0106_channel_t capture_channels[4];
+ struct snd_ca0106_channel playback_channels[4];
+ struct snd_ca0106_channel capture_channels[4];
u32 spdif_bits[4]; /* s/pdif out setup */
int spdif_enable;
int capture_source;
@@ -609,22 +608,22 @@ struct snd_ca0106 {
struct snd_dma_buffer buffer;
- ca_midi_t midi;
- ca_midi_t midi2;
+ struct snd_ca_midi midi;
+ struct snd_ca_midi midi2;
};
-int __devinit snd_ca0106_mixer(ca0106_t *emu);
-int __devinit snd_ca0106_proc_init(ca0106_t * emu);
+int snd_ca0106_mixer(struct snd_ca0106 *emu);
+int snd_ca0106_proc_init(struct snd_ca0106 * emu);
-unsigned int snd_ca0106_ptr_read(ca0106_t * emu,
- unsigned int reg,
- unsigned int chn);
+unsigned int snd_ca0106_ptr_read(struct snd_ca0106 * emu,
+ unsigned int reg,
+ unsigned int chn);
-void snd_ca0106_ptr_write(ca0106_t *emu,
- unsigned int reg,
- unsigned int chn,
- unsigned int data);
+void snd_ca0106_ptr_write(struct snd_ca0106 *emu,
+ unsigned int reg,
+ unsigned int chn,
+ unsigned int data);
-int snd_ca0106_i2c_write(ca0106_t *emu, u32 reg, u32 value);
+int snd_ca0106_i2c_write(struct snd_ca0106 *emu, u32 reg, u32 value);
diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c
index 389d967c97f..6ed7c0bfa09 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]",
@@ -183,6 +183,17 @@ static ca0106_details_t 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]",
@@ -201,13 +212,14 @@ 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 |
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,
@@ -220,13 +232,14 @@ 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 |
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,
@@ -239,7 +252,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)
{
@@ -255,7 +268,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)
@@ -271,16 +284,47 @@ 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_spi_write(struct snd_ca0106 * emu,
+ unsigned int data)
+{
+ 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_i2c_write(struct snd_ca0106 *emu,
u32 reg,
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 +336,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 +344,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;
}
@@ -327,7 +368,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;
@@ -338,7 +379,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;
@@ -350,18 +391,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);
@@ -380,10 +422,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)
@@ -392,43 +434,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);
@@ -448,10 +491,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);
@@ -461,70 +504,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);
@@ -593,8 +636,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));
@@ -621,11 +664,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;
@@ -692,16 +735,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;
@@ -745,12 +788,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;
@@ -774,11 +817,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;
@@ -801,11 +844,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;
@@ -823,7 +866,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,
@@ -834,7 +877,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,
@@ -845,7 +888,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,
@@ -856,7 +899,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,
@@ -867,7 +910,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,
@@ -878,7 +921,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,
@@ -889,7 +932,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,
@@ -900,7 +943,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,
@@ -912,10 +955,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;
@@ -926,10 +969,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);
@@ -938,12 +981,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,
};
@@ -958,7 +1001,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
@@ -991,9 +1034,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);
}
@@ -1002,19 +1045,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;
-
- spin_lock(&chip->emu_lock);
+ struct snd_ca0106_channel *pchannel;
status = inl(chip->port + IPR);
-
- // call updater, unlock before it
- spin_unlock(&chip->emu_lock);
-
if (! status)
return IRQ_NONE;
@@ -1024,11 +1061,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 +1075,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 +1088,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,22 +1100,13 @@ 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;
}
-static void snd_ca0106_pcm_free(snd_pcm_t *pcm)
+static int __devinit snd_ca0106_pcm(struct snd_ca0106 *emu, int device, struct snd_pcm **rpcm)
{
- 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;
- snd_pcm_substream_t *substream;
+ struct snd_pcm *pcm;
+ struct snd_pcm_substream *substream;
int err;
if (rpcm)
@@ -1088,7 +1115,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:
@@ -1140,15 +1166,39 @@ 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 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,
- 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,
};
@@ -1210,8 +1260,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",
@@ -1320,6 +1371,13 @@ static int __devinit snd_ca0106_create(snd_card_t *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. */
+ 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,
chip, &ops)) < 0) {
@@ -1331,43 +1389,44 @@ 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;
- 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;
@@ -1416,8 +1475,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)
@@ -1471,7 +1530,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);
@@ -1507,12 +1568,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
diff --git a/sound/pci/ca0106/ca0106_mixer.c b/sound/pci/ca0106/ca0106_mixer.c
index c10e4a54301..06fe055674f 100644
--- a/sound/pci/ca0106/ca0106_mixer.c
+++ b/sound/pci/ca0106/ca0106_mixer.c
@@ -73,7 +73,8 @@
#include "ca0106.h"
-static int snd_ca0106_shared_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_ca0106_shared_spdif_info(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_info *uinfo)
{
uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
uinfo->count = 1;
@@ -82,19 +83,19 @@ static int snd_ca0106_shared_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_i
return 0;
}
-static int snd_ca0106_shared_spdif_get(snd_kcontrol_t * kcontrol,
- snd_ctl_elem_value_t * ucontrol)
+static int snd_ca0106_shared_spdif_get(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
{
- ca0106_t *emu = snd_kcontrol_chip(kcontrol);
+ struct snd_ca0106 *emu = snd_kcontrol_chip(kcontrol);
ucontrol->value.enumerated.item[0] = emu->spdif_enable;
return 0;
}
-static int snd_ca0106_shared_spdif_put(snd_kcontrol_t * kcontrol,
- snd_ctl_elem_value_t * ucontrol)
+static int snd_ca0106_shared_spdif_put(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
{
- ca0106_t *emu = snd_kcontrol_chip(kcontrol);
+ struct snd_ca0106 *emu = snd_kcontrol_chip(kcontrol);
unsigned int val;
int change = 0;
u32 mask;
@@ -125,18 +126,12 @@ static int snd_ca0106_shared_spdif_put(snd_kcontrol_t * kcontrol,
return change;
}
-static snd_kcontrol_new_t snd_ca0106_shared_spdif __devinitdata =
+static int snd_ca0106_capture_source_info(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_info *uinfo)
{
- .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
- .name = "SPDIF Out",
- .info = snd_ca0106_shared_spdif_info,
- .get = snd_ca0106_shared_spdif_get,
- .put = snd_ca0106_shared_spdif_put
-};
-
-static int snd_ca0106_capture_source_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
-{
- static char *texts[6] = { "SPDIF out", "i2s mixer out", "SPDIF in", "i2s in", "AC97 in", "SRC out" };
+ static char *texts[6] = {
+ "IEC958 out", "i2s mixer out", "IEC958 in", "i2s in", "AC97 in", "SRC out"
+ };
uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
uinfo->count = 1;
@@ -147,19 +142,19 @@ static int snd_ca0106_capture_source_info(snd_kcontrol_t *kcontrol, snd_ctl_elem
return 0;
}
-static int snd_ca0106_capture_source_get(snd_kcontrol_t * kcontrol,
- snd_ctl_elem_value_t * ucontrol)
+static int snd_ca0106_capture_source_get(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
{
- ca0106_t *emu = snd_kcontrol_chip(kcontrol);
+ struct snd_ca0106 *emu = snd_kcontrol_chip(kcontrol);
ucontrol->value.enumerated.item[0] = emu->capture_source;
return 0;
}
-static int snd_ca0106_capture_source_put(snd_kcontrol_t * kcontrol,
- snd_ctl_elem_value_t * ucontrol)
+static int snd_ca0106_capture_source_put(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
{
- ca0106_t *emu = snd_kcontrol_chip(kcontrol);
+ struct snd_ca0106 *emu = snd_kcontrol_chip(kcontrol);
unsigned int val;
int change = 0;
u32 mask;
@@ -176,16 +171,8 @@ static int snd_ca0106_capture_source_put(snd_kcontrol_t * kcontrol,
return change;
}
-static snd_kcontrol_new_t snd_ca0106_capture_source __devinitdata =
-{
- .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
- .name = "Capture Source",
- .info = snd_ca0106_capture_source_info,
- .get = snd_ca0106_capture_source_get,
- .put = snd_ca0106_capture_source_put
-};
-
-static int snd_ca0106_capture_mic_line_in_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_ca0106_capture_mic_line_in_info(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_info *uinfo)
{
static char *texts[2] = { "Line in", "Mic in" };
@@ -198,19 +185,19 @@ static int snd_ca0106_capture_mic_line_in_info(snd_kcontrol_t *kcontrol, snd_ctl
return 0;
}
-static int snd_ca0106_capture_mic_line_in_get(snd_kcontrol_t * kcontrol,
- snd_ctl_elem_value_t * ucontrol)
+static int snd_ca0106_capture_mic_line_in_get(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
{
- ca0106_t *emu = snd_kcontrol_chip(kcontrol);
+ struct snd_ca0106 *emu = snd_kcontrol_chip(kcontrol);
ucontrol->value.enumerated.item[0] = emu->capture_mic_line_in;
return 0;
}
-static int snd_ca0106_capture_mic_line_in_put(snd_kcontrol_t * kcontrol,
- snd_ctl_elem_value_t * ucontrol)
+static int snd_ca0106_capture_mic_line_in_put(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
{
- ca0106_t *emu = snd_kcontrol_chip(kcontrol);
+ struct snd_ca0106 *emu = snd_kcontrol_chip(kcontrol);
unsigned int val;
int change = 0;
u32 tmp;
@@ -235,7 +222,7 @@ static int snd_ca0106_capture_mic_line_in_put(snd_kcontrol_t * kcontrol,
return change;
}
-static snd_kcontrol_new_t snd_ca0106_capture_mic_line_in __devinitdata =
+static struct snd_kcontrol_new snd_ca0106_capture_mic_line_in __devinitdata =
{
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "Mic/Line in Capture",
@@ -244,17 +231,18 @@ static snd_kcontrol_new_t snd_ca0106_capture_mic_line_in __devinitdata =
.put = snd_ca0106_capture_mic_line_in_put
};
-static int snd_ca0106_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_ca0106_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_ca0106_spdif_get(snd_kcontrol_t * kcontrol,
- snd_ctl_elem_value_t * ucontrol)
+static int snd_ca0106_spdif_get(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
{
- ca0106_t *emu = snd_kcontrol_chip(kcontrol);
+ struct snd_ca0106 *emu = snd_kcontrol_chip(kcontrol);
unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
ucontrol->value.iec958.status[0] = (emu->spdif_bits[idx] >> 0) & 0xff;
@@ -264,8 +252,8 @@ static int snd_ca0106_spdif_get(snd_kcontrol_t * kcontrol,
return 0;
}
-static int snd_ca0106_spdif_get_mask(snd_kcontrol_t * kcontrol,
- snd_ctl_elem_value_t * ucontrol)
+static int snd_ca0106_spdif_get_mask(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
{
ucontrol->value.iec958.status[0] = 0xff;
ucontrol->value.iec958.status[1] = 0xff;
@@ -274,10 +262,10 @@ static int snd_ca0106_spdif_get_mask(snd_kcontrol_t * kcontrol,
return 0;
}
-static int snd_ca0106_spdif_put(snd_kcontrol_t * kcontrol,
- snd_ctl_elem_value_t * ucontrol)
+static int snd_ca0106_spdif_put(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
{
- ca0106_t *emu = snd_kcontrol_chip(kcontrol);
+ struct snd_ca0106 *emu = snd_kcontrol_chip(kcontrol);
unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
int change;
unsigned int val;
@@ -294,27 +282,8 @@ static int snd_ca0106_spdif_put(snd_kcontrol_t * kcontrol,
return change;
}
-static snd_kcontrol_new_t snd_ca0106_spdif_mask_control =
-{
- .access = SNDRV_CTL_ELEM_ACCESS_READ,
- .iface = SNDRV_CTL_ELEM_IFACE_PCM,
- .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,MASK),
- .count = 4,
- .info = snd_ca0106_spdif_info,
- .get = snd_ca0106_spdif_get_mask
-};
-
-static snd_kcontrol_new_t snd_ca0106_spdif_control =
-{
- .iface = SNDRV_CTL_ELEM_IFACE_PCM,
- .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT),
- .count = 4,
- .info = snd_ca0106_spdif_info,
- .get = snd_ca0106_spdif_get,
- .put = snd_ca0106_spdif_put
-};
-
-static int snd_ca0106_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_ca0106_volume_info(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_info *uinfo)
{
uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
uinfo->count = 2;
@@ -323,11 +292,15 @@ static int snd_ca0106_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t
return 0;
}
-static int snd_ca0106_volume_get(snd_kcontrol_t * kcontrol,
- snd_ctl_elem_value_t * ucontrol, int reg, int channel_id)
+static int snd_ca0106_volume_get(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
{
- ca0106_t *emu = snd_kcontrol_chip(kcontrol);
+ struct snd_ca0106 *emu = snd_kcontrol_chip(kcontrol);
unsigned int value;
+ int channel_id, reg;
+
+ channel_id = (kcontrol->private_value >> 8) & 0xff;
+ reg = kcontrol->private_value & 0xff;
value = snd_ca0106_ptr_read(emu, reg, channel_id);
ucontrol->value.integer.value[0] = 0xff - ((value >> 24) & 0xff); /* Left */
@@ -335,237 +308,103 @@ static int snd_ca0106_volume_get(snd_kcontrol_t * kcontrol,
return 0;
}
-static int snd_ca0106_volume_get_spdif_front(snd_kcontrol_t * kcontrol,
- snd_ctl_elem_value_t * ucontrol)
-{
- int channel_id = CONTROL_FRONT_CHANNEL;
- int reg = PLAYBACK_VOLUME1;
- return snd_ca0106_volume_get(kcontrol, ucontrol, reg, channel_id);
-}
-
-static int snd_ca0106_volume_get_spdif_center_lfe(snd_kcontrol_t * kcontrol,
- snd_ctl_elem_value_t * ucontrol)
-{
- int channel_id = CONTROL_CENTER_LFE_CHANNEL;
- int reg = PLAYBACK_VOLUME1;
- return snd_ca0106_volume_get(kcontrol, ucontrol, reg, channel_id);
-}
-static int snd_ca0106_volume_get_spdif_unknown(snd_kcontrol_t * kcontrol,
- snd_ctl_elem_value_t * ucontrol)
-{
- int channel_id = CONTROL_UNKNOWN_CHANNEL;
- int reg = PLAYBACK_VOLUME1;
- return snd_ca0106_volume_get(kcontrol, ucontrol, reg, channel_id);
-}
-static int snd_ca0106_volume_get_spdif_rear(snd_kcontrol_t * kcontrol,
- snd_ctl_elem_value_t * ucontrol)
-{
- int channel_id = CONTROL_REAR_CHANNEL;
- int reg = PLAYBACK_VOLUME1;
- return snd_ca0106_volume_get(kcontrol, ucontrol, reg, channel_id);
-}
-static int snd_ca0106_volume_get_analog_front(snd_kcontrol_t * kcontrol,
- snd_ctl_elem_value_t * ucontrol)
+static int snd_ca0106_volume_put(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
{
- int channel_id = CONTROL_FRONT_CHANNEL;
- int reg = PLAYBACK_VOLUME2;
- return snd_ca0106_volume_get(kcontrol, ucontrol, reg, channel_id);
-}
+ struct snd_ca0106 *emu = snd_kcontrol_chip(kcontrol);
+ unsigned int oval, nval;
+ int channel_id, reg;
-static int snd_ca0106_volume_get_analog_center_lfe(snd_kcontrol_t * kcontrol,
- snd_ctl_elem_value_t * ucontrol)
-{
- int channel_id = CONTROL_CENTER_LFE_CHANNEL;
- int reg = PLAYBACK_VOLUME2;
- return snd_ca0106_volume_get(kcontrol, ucontrol, reg, channel_id);
-}
-static int snd_ca0106_volume_get_analog_unknown(snd_kcontrol_t * kcontrol,
- snd_ctl_elem_value_t * ucontrol)
-{
- int channel_id = CONTROL_UNKNOWN_CHANNEL;
- int reg = PLAYBACK_VOLUME2;
- return snd_ca0106_volume_get(kcontrol, ucontrol, reg, channel_id);
-}
-static int snd_ca0106_volume_get_analog_rear(snd_kcontrol_t * kcontrol,
- snd_ctl_elem_value_t * ucontrol)
-{
- int channel_id = CONTROL_REAR_CHANNEL;
- int reg = PLAYBACK_VOLUME2;
- return snd_ca0106_volume_get(kcontrol, ucontrol, reg, channel_id);
-}
+ channel_id = (kcontrol->private_value >> 8) & 0xff;
+ reg = kcontrol->private_value & 0xff;
-static int snd_ca0106_volume_get_feedback(snd_kcontrol_t * kcontrol,
- snd_ctl_elem_value_t * ucontrol)
-{
- int channel_id = 1;
- int reg = CAPTURE_CONTROL;
- return snd_ca0106_volume_get(kcontrol, ucontrol, reg, channel_id);
-}
-
-static int snd_ca0106_volume_put(snd_kcontrol_t * kcontrol,
- snd_ctl_elem_value_t * ucontrol, int reg, int channel_id)
-{
- ca0106_t *emu = snd_kcontrol_chip(kcontrol);
- unsigned int value;
- //value = snd_ca0106_ptr_read(emu, reg, channel_id);
- //value = value & 0xffff;
- value = ((0xff - ucontrol->value.integer.value[0]) << 24) | ((0xff - ucontrol->value.integer.value[1]) << 16);
- value = value | ((0xff - ucontrol->value.integer.value[0]) << 8) | ((0xff - ucontrol->value.integer.value[1]) );
- snd_ca0106_ptr_write(emu, reg, channel_id, value);
- return 1;
-}
-static int snd_ca0106_volume_put_spdif_front(snd_kcontrol_t * kcontrol,
- snd_ctl_elem_value_t * ucontrol)
-{
- int channel_id = CONTROL_FRONT_CHANNEL;
- int reg = PLAYBACK_VOLUME1;
- return snd_ca0106_volume_put(kcontrol, ucontrol, reg, channel_id);
-}
-static int snd_ca0106_volume_put_spdif_center_lfe(snd_kcontrol_t * kcontrol,
- snd_ctl_elem_value_t * ucontrol)
-{
- int channel_id = CONTROL_CENTER_LFE_CHANNEL;
- int reg = PLAYBACK_VOLUME1;
- return snd_ca0106_volume_put(kcontrol, ucontrol, reg, channel_id);
-}
-static int snd_ca0106_volume_put_spdif_unknown(snd_kcontrol_t * kcontrol,
- snd_ctl_elem_value_t * ucontrol)
-{
- int channel_id = CONTROL_UNKNOWN_CHANNEL;
- int reg = PLAYBACK_VOLUME1;
- return snd_ca0106_volume_put(kcontrol, ucontrol, reg, channel_id);
-}
-static int snd_ca0106_volume_put_spdif_rear(snd_kcontrol_t * kcontrol,
- snd_ctl_elem_value_t * ucontrol)
-{
- int channel_id = CONTROL_REAR_CHANNEL;
- int reg = PLAYBACK_VOLUME1;
- return snd_ca0106_volume_put(kcontrol, ucontrol, reg, channel_id);
-}
-static int snd_ca0106_volume_put_analog_front(snd_kcontrol_t * kcontrol,
- snd_ctl_elem_value_t * ucontrol)
-{
- int channel_id = CONTROL_FRONT_CHANNEL;
- int reg = PLAYBACK_VOLUME2;
- return snd_ca0106_volume_put(kcontrol, ucontrol, reg, channel_id);
-}
-static int snd_ca0106_volume_put_analog_center_lfe(snd_kcontrol_t * kcontrol,
- snd_ctl_elem_value_t * ucontrol)
-{
- int channel_id = CONTROL_CENTER_LFE_CHANNEL;
- int reg = PLAYBACK_VOLUME2;
- return snd_ca0106_volume_put(kcontrol, ucontrol, reg, channel_id);
-}
-static int snd_ca0106_volume_put_analog_unknown(snd_kcontrol_t * kcontrol,
- snd_ctl_elem_value_t * ucontrol)
-{
- int channel_id = CONTROL_UNKNOWN_CHANNEL;
- int reg = PLAYBACK_VOLUME2;
- return snd_ca0106_volume_put(kcontrol, ucontrol, reg, channel_id);
-}
-static int snd_ca0106_volume_put_analog_rear(snd_kcontrol_t * kcontrol,
- snd_ctl_elem_value_t * ucontrol)
-{
- int channel_id = CONTROL_REAR_CHANNEL;
- int reg = PLAYBACK_VOLUME2;
- return snd_ca0106_volume_put(kcontrol, ucontrol, reg, channel_id);
-}
-
-static int snd_ca0106_volume_put_feedback(snd_kcontrol_t * kcontrol,
- snd_ctl_elem_value_t * ucontrol)
-{
- int channel_id = 1;
- int reg = CAPTURE_CONTROL;
- return snd_ca0106_volume_put(kcontrol, ucontrol, reg, channel_id);
-}
-
-static snd_kcontrol_new_t snd_ca0106_volume_control_analog_front =
-{
- .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
- .name = "Analog Front Playback Volume",
- .info = snd_ca0106_volume_info,
- .get = snd_ca0106_volume_get_analog_front,
- .put = snd_ca0106_volume_put_analog_front
-};
-static snd_kcontrol_new_t snd_ca0106_volume_control_analog_center_lfe =
-{
- .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
- .name = "Analog Center/LFE Playback Volume",
- .info = snd_ca0106_volume_info,
- .get = snd_ca0106_volume_get_analog_center_lfe,
- .put = snd_ca0106_volume_put_analog_center_lfe
-};
-static snd_kcontrol_new_t snd_ca0106_volume_control_analog_unknown =
-{
- .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
- .name = "Analog Side Playback Volume",
- .info = snd_ca0106_volume_info,
- .get = snd_ca0106_volume_get_analog_unknown,
- .put = snd_ca0106_volume_put_analog_unknown
-};
-static snd_kcontrol_new_t snd_ca0106_volume_control_analog_rear =
-{
- .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
- .name = "Analog Rear Playback Volume",
- .info = snd_ca0106_volume_info,
- .get = snd_ca0106_volume_get_analog_rear,
- .put = snd_ca0106_volume_put_analog_rear
-};
-static snd_kcontrol_new_t snd_ca0106_volume_control_spdif_front =
-{
- .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
- .name = "SPDIF Front Playback Volume",
- .info = snd_ca0106_volume_info,
- .get = snd_ca0106_volume_get_spdif_front,
- .put = snd_ca0106_volume_put_spdif_front
-};
-static snd_kcontrol_new_t snd_ca0106_volume_control_spdif_center_lfe =
-{
- .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
- .name = "SPDIF Center/LFE Playback Volume",
- .info = snd_ca0106_volume_info,
- .get = snd_ca0106_volume_get_spdif_center_lfe,
- .put = snd_ca0106_volume_put_spdif_center_lfe
-};
-static snd_kcontrol_new_t snd_ca0106_volume_control_spdif_unknown =
-{
- .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
- .name = "SPDIF Unknown Playback Volume",
- .info = snd_ca0106_volume_info,
- .get = snd_ca0106_volume_get_spdif_unknown,
- .put = snd_ca0106_volume_put_spdif_unknown
-};
-static snd_kcontrol_new_t snd_ca0106_volume_control_spdif_rear =
-{
- .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
- .name = "SPDIF Rear Playback Volume",
- .info = snd_ca0106_volume_info,
- .get = snd_ca0106_volume_get_spdif_rear,
- .put = snd_ca0106_volume_put_spdif_rear
-};
-
-static snd_kcontrol_new_t snd_ca0106_volume_control_feedback =
-{
- .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
- .name = "CAPTURE feedback Playback Volume",
- .info = snd_ca0106_volume_info,
- .get = snd_ca0106_volume_get_feedback,
- .put = snd_ca0106_volume_put_feedback
+ oval = snd_ca0106_ptr_read(emu, reg, channel_id);
+ nval = ((0xff - ucontrol->value.integer.value[0]) << 24) |
+ ((0xff - ucontrol->value.integer.value[1]) << 16);
+ nval |= ((0xff - ucontrol->value.integer.value[0]) << 8) |
+ ((0xff - ucontrol->value.integer.value[1]) );
+ if (oval == nval)
+ return 0;
+ snd_ca0106_ptr_write(emu, reg, channel_id, nval);
+ return 1;
+}
+
+#define CA_VOLUME(xname,chid,reg) \
+{ \
+ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
+ .info = snd_ca0106_volume_info, \
+ .get = snd_ca0106_volume_get, \
+ .put = snd_ca0106_volume_put, \
+ .private_value = ((chid) << 8) | (reg) \
+}
+
+
+static struct snd_kcontrol_new snd_ca0106_volume_ctls[] __devinitdata = {
+ CA_VOLUME("Analog Front Playback Volume",
+ CONTROL_FRONT_CHANNEL, PLAYBACK_VOLUME2),
+ CA_VOLUME("Analog Rear Playback Volume",
+ CONTROL_REAR_CHANNEL, PLAYBACK_VOLUME2),
+ CA_VOLUME("Analog Center/LFE Playback Volume",
+ CONTROL_CENTER_LFE_CHANNEL, PLAYBACK_VOLUME2),
+ CA_VOLUME("Analog Side Playback Volume",
+ CONTROL_UNKNOWN_CHANNEL, PLAYBACK_VOLUME2),
+
+ CA_VOLUME("IEC958 Front Playback Volume",
+ CONTROL_FRONT_CHANNEL, PLAYBACK_VOLUME1),
+ CA_VOLUME("IEC958 Rear Playback Volume",
+ CONTROL_REAR_CHANNEL, PLAYBACK_VOLUME1),
+ CA_VOLUME("IEC958 Center/LFE Playback Volume",
+ CONTROL_CENTER_LFE_CHANNEL, PLAYBACK_VOLUME1),
+ CA_VOLUME("IEC958 Unknown Playback Volume",
+ CONTROL_UNKNOWN_CHANNEL, PLAYBACK_VOLUME1),
+
+ CA_VOLUME("CAPTURE feedback Playback Volume",
+ 1, CAPTURE_CONTROL),
+
+ {
+ .access = SNDRV_CTL_ELEM_ACCESS_READ,
+ .iface = SNDRV_CTL_ELEM_IFACE_PCM,
+ .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,MASK),
+ .count = 4,
+ .info = snd_ca0106_spdif_info,
+ .get = snd_ca0106_spdif_get_mask
+ },
+ {
+ .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+ .name = "IEC958 Playback Switch",
+ .info = snd_ca0106_shared_spdif_info,
+ .get = snd_ca0106_shared_spdif_get,
+ .put = snd_ca0106_shared_spdif_put
+ },
+ {
+ .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+ .name = "Capture Source",
+ .info = snd_ca0106_capture_source_info,
+ .get = snd_ca0106_capture_source_get,
+ .put = snd_ca0106_capture_source_put
+ },
+ {
+ .iface = SNDRV_CTL_ELEM_IFACE_PCM,
+ .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT),
+ .count = 4,
+ .info = snd_ca0106_spdif_info,
+ .get = snd_ca0106_spdif_get,
+ .put = snd_ca0106_spdif_put
+ },
};
-
-static int remove_ctl(snd_card_t *card, const char *name)
+static int __devinit remove_ctl(struct snd_card *card, const char *name)
{
- snd_ctl_elem_id_t id;
+ struct snd_ctl_elem_id id;
memset(&id, 0, sizeof(id));
strcpy(id.name, name);
id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
return snd_ctl_remove_id(card, &id);
}
-static snd_kcontrol_t *ctl_find(snd_card_t *card, const char *name)
+static struct snd_kcontrol __devinit *ctl_find(struct snd_card *card, const char *name)
{
- snd_ctl_elem_id_t sid;
+ struct snd_ctl_elem_id sid;
memset(&sid, 0, sizeof(sid));
/* FIXME: strcpy is bad. */
strcpy(sid.name, name);
@@ -573,9 +412,9 @@ static snd_kcontrol_t *ctl_find(snd_card_t *card, const char *name)
return snd_ctl_find_id(card, &sid);
}
-static int rename_ctl(snd_card_t *card, const char *src, const char *dst)
+static int __devinit rename_ctl(struct snd_card *card, const char *src, const char *dst)
{
- snd_kcontrol_t *kctl = ctl_find(card, src);
+ struct snd_kcontrol *kctl = ctl_find(card, src);
if (kctl) {
strcpy(kctl->id.name, dst);
return 0;
@@ -583,11 +422,10 @@ static int rename_ctl(snd_card_t *card, const char *src, const char *dst)
return -ENOENT;
}
-int __devinit snd_ca0106_mixer(ca0106_t *emu)
+int __devinit snd_ca0106_mixer(struct snd_ca0106 *emu)
{
- int err;
- snd_kcontrol_t *kctl;
- snd_card_t *card = emu->card;
+ int i, err;
+ struct snd_card *card = emu->card;
char **c;
static char *ca0106_remove_ctls[] = {
"Master Mono Playback Switch",
@@ -627,70 +465,22 @@ int __devinit snd_ca0106_mixer(ca0106_t *emu)
NULL
};
#if 1
- for (c=ca0106_remove_ctls; *c; c++)
+ for (c = ca0106_remove_ctls; *c; c++)
remove_ctl(card, *c);
- for (c=ca0106_rename_ctls; *c; c += 2)
+ for (c = ca0106_rename_ctls; *c; c += 2)
rename_ctl(card, c[0], c[1]);
#endif
- if ((kctl = snd_ctl_new1(&snd_ca0106_volume_control_analog_front, emu)) == NULL)
- return -ENOMEM;
- if ((err = snd_ctl_add(card, kctl)))
- return err;
- if ((kctl = snd_ctl_new1(&snd_ca0106_volume_control_analog_rear, emu)) == NULL)
- return -ENOMEM;
- if ((err = snd_ctl_add(card, kctl)))
- return err;
- if ((kctl = snd_ctl_new1(&snd_ca0106_volume_control_analog_center_lfe, emu)) == NULL)
- return -ENOMEM;
- if ((err = snd_ctl_add(card, kctl)))
- return err;
- if ((kctl = snd_ctl_new1(&snd_ca0106_volume_control_analog_unknown, emu)) == NULL)
- return -ENOMEM;
- if ((err = snd_ctl_add(card, kctl)))
- return err;
- if ((kctl = snd_ctl_new1(&snd_ca0106_volume_control_spdif_front, emu)) == NULL)
- return -ENOMEM;
- if ((err = snd_ctl_add(card, kctl)))
- return err;
- if ((kctl = snd_ctl_new1(&snd_ca0106_volume_control_spdif_rear, emu)) == NULL)
- return -ENOMEM;
- if ((err = snd_ctl_add(card, kctl)))
- return err;
- if ((kctl = snd_ctl_new1(&snd_ca0106_volume_control_spdif_center_lfe, emu)) == NULL)
- return -ENOMEM;
- if ((err = snd_ctl_add(card, kctl)))
- return err;
- if ((kctl = snd_ctl_new1(&snd_ca0106_volume_control_spdif_unknown, emu)) == NULL)
- return -ENOMEM;
- if ((err = snd_ctl_add(card, kctl)))
- return err;
- if ((kctl = snd_ctl_new1(&snd_ca0106_volume_control_feedback, emu)) == NULL)
- return -ENOMEM;
- if ((err = snd_ctl_add(card, kctl)))
- return err;
- if ((kctl = snd_ctl_new1(&snd_ca0106_spdif_mask_control, emu)) == NULL)
- return -ENOMEM;
- if ((err = snd_ctl_add(card, kctl)))
- return err;
- if ((kctl = snd_ctl_new1(&snd_ca0106_shared_spdif, emu)) == NULL)
- return -ENOMEM;
- if ((err = snd_ctl_add(card, kctl)))
- return err;
- if ((kctl = snd_ctl_new1(&snd_ca0106_capture_source, emu)) == NULL)
- return -ENOMEM;
- if ((err = snd_ctl_add(card, kctl)))
- return err;
+ for (i = 0; i < ARRAY_SIZE(snd_ca0106_volume_ctls); i++) {
+ err = snd_ctl_add(card, snd_ctl_new1(&snd_ca0106_volume_ctls[i], emu));
+ if (err < 0)
+ return err;
+ }
if (emu->details->i2c_adc == 1) {
- if ((kctl = snd_ctl_new1(&snd_ca0106_capture_mic_line_in, emu)) == NULL)
- return -ENOMEM;
- if ((err = snd_ctl_add(card, kctl)))
+ err = snd_ctl_add(card, snd_ctl_new1(&snd_ca0106_capture_mic_line_in, emu));
+ if (err < 0)
return err;
}
- if ((kctl = snd_ctl_new1(&snd_ca0106_spdif_control, emu)) == NULL)
- return -ENOMEM;
- if ((err = snd_ctl_add(card, kctl)))
- return err;
return 0;
}
diff --git a/sound/pci/ca0106/ca0106_proc.c b/sound/pci/ca0106/ca0106_proc.c
index 1c9cc821d1b..63757273bfb 100644
--- a/sound/pci/ca0106/ca0106_proc.c
+++ b/sound/pci/ca0106/ca0106_proc.c
@@ -77,6 +77,8 @@
#include "ca0106.h"
+#ifdef CONFIG_PROC_FS
+
struct snd_ca0106_category_str {
int val;
const char *name;
@@ -97,7 +99,7 @@ static struct snd_ca0106_category_str snd_ca0106_con_category[] = {
};
-static void snd_ca0106_proc_dump_iec958( snd_info_buffer_t *buffer, u32 value)
+static void snd_ca0106_proc_dump_iec958( struct snd_info_buffer *buffer, u32 value)
{
int i;
u32 status[4];
@@ -271,10 +273,10 @@ static void snd_ca0106_proc_dump_iec958( snd_info_buffer_t *buffer, u32 value)
}
}
-static void snd_ca0106_proc_iec958(snd_info_entry_t *entry,
- snd_info_buffer_t * buffer)
+static void snd_ca0106_proc_iec958(struct snd_info_entry *entry,
+ struct snd_info_buffer *buffer)
{
- ca0106_t *emu = entry->private_data;
+ struct snd_ca0106 *emu = entry->private_data;
u32 value;
value = snd_ca0106_ptr_read(emu, SAMPLE_RATE_TRACKER_STATUS, 0);
@@ -293,10 +295,10 @@ static void snd_ca0106_proc_iec958(snd_info_entry_t *entry,
snd_iprintf(buffer, "\n");
}
-static void snd_ca0106_proc_reg_write32(snd_info_entry_t *entry,
- snd_info_buffer_t * buffer)
+static void snd_ca0106_proc_reg_write32(struct snd_info_entry *entry,
+ struct snd_info_buffer *buffer)
{
- ca0106_t *emu = entry->private_data;
+ struct snd_ca0106 *emu = entry->private_data;
unsigned long flags;
char line[64];
u32 reg, val;
@@ -311,10 +313,10 @@ static void snd_ca0106_proc_reg_write32(snd_info_entry_t *entry,
}
}
-static void snd_ca0106_proc_reg_read32(snd_info_entry_t *entry,
- snd_info_buffer_t * buffer)
+static void snd_ca0106_proc_reg_read32(struct snd_info_entry *entry,
+ struct snd_info_buffer *buffer)
{
- ca0106_t *emu = entry->private_data;
+ struct snd_ca0106 *emu = entry->private_data;
unsigned long value;
unsigned long flags;
int i;
@@ -327,10 +329,10 @@ static void snd_ca0106_proc_reg_read32(snd_info_entry_t *entry,
}
}
-static void snd_ca0106_proc_reg_read16(snd_info_entry_t *entry,
- snd_info_buffer_t * buffer)
+static void snd_ca0106_proc_reg_read16(struct snd_info_entry *entry,
+ struct snd_info_buffer *buffer)
{
- ca0106_t *emu = entry->private_data;
+ struct snd_ca0106 *emu = entry->private_data;
unsigned int value;
unsigned long flags;
int i;
@@ -343,10 +345,10 @@ static void snd_ca0106_proc_reg_read16(snd_info_entry_t *entry,
}
}
-static void snd_ca0106_proc_reg_read8(snd_info_entry_t *entry,
- snd_info_buffer_t * buffer)
+static void snd_ca0106_proc_reg_read8(struct snd_info_entry *entry,
+ struct snd_info_buffer *buffer)
{
- ca0106_t *emu = entry->private_data;
+ struct snd_ca0106 *emu = entry->private_data;
unsigned int value;
unsigned long flags;
int i;
@@ -359,10 +361,10 @@ static void snd_ca0106_proc_reg_read8(snd_info_entry_t *entry,
}
}
-static void snd_ca0106_proc_reg_read1(snd_info_entry_t *entry,
- snd_info_buffer_t * buffer)
+static void snd_ca0106_proc_reg_read1(struct snd_info_entry *entry,
+ struct snd_info_buffer *buffer)
{
- ca0106_t *emu = entry->private_data;
+ struct snd_ca0106 *emu = entry->private_data;
unsigned long value;
int i,j;
@@ -377,10 +379,10 @@ static void snd_ca0106_proc_reg_read1(snd_info_entry_t *entry,
}
}
-static void snd_ca0106_proc_reg_read2(snd_info_entry_t *entry,
- snd_info_buffer_t * buffer)
+static void snd_ca0106_proc_reg_read2(struct snd_info_entry *entry,
+ struct snd_info_buffer *buffer)
{
- ca0106_t *emu = entry->private_data;
+ struct snd_ca0106 *emu = entry->private_data;
unsigned long value;
int i,j;
@@ -395,10 +397,10 @@ static void snd_ca0106_proc_reg_read2(snd_info_entry_t *entry,
}
}
-static void snd_ca0106_proc_reg_write(snd_info_entry_t *entry,
- snd_info_buffer_t * buffer)
+static void snd_ca0106_proc_reg_write(struct snd_info_entry *entry,
+ struct snd_info_buffer *buffer)
{
- ca0106_t *emu = entry->private_data;
+ struct snd_ca0106 *emu = entry->private_data;
char line[64];
unsigned int reg, channel_id , val;
while (!snd_info_get_line(buffer, line, sizeof(line))) {
@@ -409,10 +411,10 @@ static void snd_ca0106_proc_reg_write(snd_info_entry_t *entry,
}
}
-static void snd_ca0106_proc_i2c_write(snd_info_entry_t *entry,
- snd_info_buffer_t * buffer)
+static void snd_ca0106_proc_i2c_write(struct snd_info_entry *entry,
+ struct snd_info_buffer *buffer)
{
- ca0106_t *emu = entry->private_data;
+ struct snd_ca0106 *emu = entry->private_data;
char line[64];
unsigned int reg, val;
while (!snd_info_get_line(buffer, line, sizeof(line))) {
@@ -424,9 +426,9 @@ static void snd_ca0106_proc_i2c_write(snd_info_entry_t *entry,
}
}
-int __devinit snd_ca0106_proc_init(ca0106_t * emu)
+int __devinit snd_ca0106_proc_init(struct snd_ca0106 * emu)
{
- snd_info_entry_t *entry;
+ struct snd_info_entry *entry;
if(! snd_card_proc_new(emu->card, "iec958", &entry))
snd_info_set_text_ops(entry, emu, 1024, snd_ca0106_proc_iec958);
@@ -459,3 +461,4 @@ int __devinit snd_ca0106_proc_init(ca0106_t * emu)
return 0;
}
+#endif /* CONFIG_PROC_FS */
diff --git a/sound/pci/ca0106/ca_midi.c b/sound/pci/ca0106/ca_midi.c
index 2e08b27b834..2e6eab1f118 100644
--- a/sound/pci/ca0106/ca_midi.c
+++ b/sound/pci/ca0106/ca_midi.c
@@ -40,18 +40,20 @@
#define ca_midi_input_avail(midi) (!(ca_midi_read_stat(midi) & midi->input_avail))
#define ca_midi_output_ready(midi) (!(ca_midi_read_stat(midi) & midi->output_ready))
-static void ca_midi_clear_rx(ca_midi_t *midi)
+static void ca_midi_clear_rx(struct snd_ca_midi *midi)
{
int timeout = 100000;
for (; timeout > 0 && ca_midi_input_avail(midi); timeout--)
ca_midi_read_data(midi);
#ifdef CONFIG_SND_DEBUG
if (timeout <= 0)
- snd_printk(KERN_ERR "ca_midi_clear_rx: timeout (status = 0x%x)\n", ca_midi_read_stat(midi));
+ snd_printk(KERN_ERR "ca_midi_clear_rx: timeout (status = 0x%x)\n",
+ ca_midi_read_stat(midi));
#endif
}
-static void ca_midi_interrupt(ca_midi_t *midi, unsigned int status) {
+static void ca_midi_interrupt(struct snd_ca_midi *midi, unsigned int status)
+{
unsigned char byte;
if (midi->rmidi == NULL) {
@@ -86,7 +88,7 @@ static void ca_midi_interrupt(ca_midi_t *midi, unsigned int status) {
}
-static void ca_midi_cmd(ca_midi_t *midi, unsigned char cmd, int ack)
+static void ca_midi_cmd(struct snd_ca_midi *midi, unsigned char cmd, int ack)
{
unsigned long flags;
int timeout, ok;
@@ -119,9 +121,9 @@ static void ca_midi_cmd(ca_midi_t *midi, unsigned char cmd, int ack)
ca_midi_read_data(midi));
}
-static int ca_midi_input_open(snd_rawmidi_substream_t * substream)
+static int ca_midi_input_open(struct snd_rawmidi_substream *substream)
{
- ca_midi_t *midi = (ca_midi_t *)substream->rmidi->private_data;
+ struct snd_ca_midi *midi = substream->rmidi->private_data;
unsigned long flags;
snd_assert(midi->dev_id, return -ENXIO);
@@ -138,9 +140,9 @@ static int ca_midi_input_open(snd_rawmidi_substream_t * substream)
return 0;
}
-static int ca_midi_output_open(snd_rawmidi_substream_t * substream)
+static int ca_midi_output_open(struct snd_rawmidi_substream *substream)
{
- ca_midi_t *midi = (ca_midi_t *)substream->rmidi->private_data;
+ struct snd_ca_midi *midi = substream->rmidi->private_data;
unsigned long flags;
snd_assert(midi->dev_id, return -ENXIO);
@@ -157,9 +159,9 @@ static int ca_midi_output_open(snd_rawmidi_substream_t * substream)
return 0;
}
-static int ca_midi_input_close(snd_rawmidi_substream_t * substream)
+static int ca_midi_input_close(struct snd_rawmidi_substream *substream)
{
- ca_midi_t *midi = (ca_midi_t *)substream->rmidi->private_data;
+ struct snd_ca_midi *midi = substream->rmidi->private_data;
unsigned long flags;
snd_assert(midi->dev_id, return -ENXIO);
@@ -176,9 +178,9 @@ static int ca_midi_input_close(snd_rawmidi_substream_t * substream)
return 0;
}
-static int ca_midi_output_close(snd_rawmidi_substream_t * substream)
+static int ca_midi_output_close(struct snd_rawmidi_substream *substream)
{
- ca_midi_t *midi = (ca_midi_t *)substream->rmidi->private_data;
+ struct snd_ca_midi *midi = substream->rmidi->private_data;
unsigned long flags;
snd_assert(midi->dev_id, return -ENXIO);
@@ -197,9 +199,9 @@ static int ca_midi_output_close(snd_rawmidi_substream_t * substream)
return 0;
}
-static void ca_midi_input_trigger(snd_rawmidi_substream_t * substream, int up)
+static void ca_midi_input_trigger(struct snd_rawmidi_substream *substream, int up)
{
- ca_midi_t *midi = (ca_midi_t *)substream->rmidi->private_data;
+ struct snd_ca_midi *midi = substream->rmidi->private_data;
snd_assert(midi->dev_id, return);
if (up) {
@@ -209,9 +211,9 @@ static void ca_midi_input_trigger(snd_rawmidi_substream_t * substream, int up)
}
}
-static void ca_midi_output_trigger(snd_rawmidi_substream_t * substream, int up)
+static void ca_midi_output_trigger(struct snd_rawmidi_substream *substream, int up)
{
- ca_midi_t *midi = (ca_midi_t *)substream->rmidi->private_data;
+ struct snd_ca_midi *midi = substream->rmidi->private_data;
unsigned long flags;
snd_assert(midi->dev_id, return);
@@ -246,21 +248,22 @@ static void ca_midi_output_trigger(snd_rawmidi_substream_t * substream, int up)
}
}
-static snd_rawmidi_ops_t ca_midi_output =
+static struct snd_rawmidi_ops ca_midi_output =
{
.open = ca_midi_output_open,
.close = ca_midi_output_close,
.trigger = ca_midi_output_trigger,
};
-static snd_rawmidi_ops_t ca_midi_input =
+static struct snd_rawmidi_ops ca_midi_input =
{
.open = ca_midi_input_open,
.close = ca_midi_input_close,
.trigger = ca_midi_input_trigger,
};
-static void ca_midi_free(ca_midi_t *midi) {
+static void ca_midi_free(struct snd_ca_midi *midi)
+{
midi->interrupt = NULL;
midi->interrupt_enable = NULL;
midi->interrupt_disable = NULL;
@@ -271,14 +274,14 @@ static void ca_midi_free(ca_midi_t *midi) {
midi->rmidi = NULL;
}
-static void ca_rmidi_free(snd_rawmidi_t *rmidi)
+static void ca_rmidi_free(struct snd_rawmidi *rmidi)
{
- ca_midi_free((ca_midi_t *)rmidi->private_data);
+ ca_midi_free(rmidi->private_data);
}
-int __devinit ca_midi_init(void *dev_id, ca_midi_t *midi, int device, char *name)
+int __devinit ca_midi_init(void *dev_id, struct snd_ca_midi *midi, int device, char *name)
{
- snd_rawmidi_t *rmidi;
+ struct snd_rawmidi *rmidi;
int err;
if ((err = snd_rawmidi_new(midi->get_dev_id_card(midi->dev_id), name, device, 1, 1, &rmidi)) < 0)
diff --git a/sound/pci/ca0106/ca_midi.h b/sound/pci/ca0106/ca_midi.h
index b452cec2bf5..b72c0933bd2 100644
--- a/sound/pci/ca0106/ca_midi.h
+++ b/sound/pci/ca0106/ca_midi.h
@@ -29,12 +29,11 @@
#define CA_MIDI_MODE_INPUT MPU401_MODE_INPUT
#define CA_MIDI_MODE_OUTPUT MPU401_MODE_OUTPUT
-typedef struct ca_midi ca_midi_t;
-struct ca_midi {
+struct snd_ca_midi {
- snd_rawmidi_t *rmidi;
- snd_rawmidi_substream_t *substream_input;
- snd_rawmidi_substream_t *substream_output;
+ struct snd_rawmidi *rmidi;
+ struct snd_rawmidi_substream *substream_input;
+ struct snd_rawmidi_substream *substream_output;
void *dev_id;
@@ -52,18 +51,16 @@ struct ca_midi {
int input_avail, output_ready;
int ack, reset, enter_uart;
- void (*interrupt)(ca_midi_t *midi, unsigned int status);
- void (*interrupt_enable)(ca_midi_t *midi, int intr);
- void (*interrupt_disable)(ca_midi_t *midi, int intr);
+ void (*interrupt)(struct snd_ca_midi *midi, unsigned int status);
+ void (*interrupt_enable)(struct snd_ca_midi *midi, int intr);
+ void (*interrupt_disable)(struct snd_ca_midi *midi, int intr);
- unsigned char (*read)(ca_midi_t *midi, int idx);
- void (*write)(ca_midi_t *midi, int data, int idx);
+ unsigned char (*read)(struct snd_ca_midi *midi, int idx);
+ void (*write)(struct snd_ca_midi *midi, int data, int idx);
/* get info from dev_id */
- snd_card_t *(*get_dev_id_card)(void *dev_id);
+ struct snd_card *(*get_dev_id_card)(void *dev_id);
int (*get_dev_id_port)(void *dev_id);
};
-int __devinit ca_midi_init(void *card, ca_midi_t *midi, int device, char *name);
-
-
+int ca_midi_init(void *card, struct snd_ca_midi *midi, int device, char *name);