diff options
Diffstat (limited to 'sound/pci/emu10k1')
-rw-r--r-- | sound/pci/emu10k1/emu10k1.c | 154 | ||||
-rw-r--r-- | sound/pci/emu10k1/emu10k1_callback.c | 105 | ||||
-rw-r--r-- | sound/pci/emu10k1/emu10k1_main.c | 589 | ||||
-rw-r--r-- | sound/pci/emu10k1/emu10k1_patch.c | 13 | ||||
-rw-r--r-- | sound/pci/emu10k1/emu10k1_synth.c | 19 | ||||
-rw-r--r-- | sound/pci/emu10k1/emu10k1_synth_local.h | 15 | ||||
-rw-r--r-- | sound/pci/emu10k1/emu10k1x.c | 406 | ||||
-rw-r--r-- | sound/pci/emu10k1/emufx.c | 375 | ||||
-rw-r--r-- | sound/pci/emu10k1/emumixer.c | 245 | ||||
-rw-r--r-- | sound/pci/emu10k1/emumpu401.c | 72 | ||||
-rw-r--r-- | sound/pci/emu10k1/emupcm.c | 405 | ||||
-rw-r--r-- | sound/pci/emu10k1/emuproc.c | 115 | ||||
-rw-r--r-- | sound/pci/emu10k1/io.c | 78 | ||||
-rw-r--r-- | sound/pci/emu10k1/irq.c | 8 | ||||
-rw-r--r-- | sound/pci/emu10k1/memory.c | 94 | ||||
-rw-r--r-- | sound/pci/emu10k1/p16v.c | 564 | ||||
-rw-r--r-- | sound/pci/emu10k1/timer.c | 18 | ||||
-rw-r--r-- | sound/pci/emu10k1/tina2.h | 36 | ||||
-rw-r--r-- | sound/pci/emu10k1/voice.c | 13 |
19 files changed, 1899 insertions, 1425 deletions
diff --git a/sound/pci/emu10k1/emu10k1.c b/sound/pci/emu10k1/emu10k1.c index 78270f8710f..2dfa932f782 100644 --- a/sound/pci/emu10k1/emu10k1.c +++ b/sound/pci/emu10k1/emu10k1.c @@ -101,10 +101,10 @@ static int __devinit snd_card_emu10k1_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { static int dev; - snd_card_t *card; - emu10k1_t *emu; + struct snd_card *card; + struct snd_emu10k1 *emu; #ifdef ENABLE_SYNTH - snd_seq_device_t *wave = NULL; + struct snd_seq_device *wave = NULL; #endif int err; @@ -125,72 +125,50 @@ static int __devinit snd_card_emu10k1_probe(struct pci_dev *pci, if ((err = snd_emu10k1_create(card, pci, extin[dev], extout[dev], (long)max_buffer_size[dev] * 1024 * 1024, enable_ir[dev], subsystem[dev], - &emu)) < 0) { - snd_card_free(card); - return err; - } - if ((err = snd_emu10k1_pcm(emu, 0, NULL)) < 0) { - snd_card_free(card); - return err; - } - if ((err = snd_emu10k1_pcm_mic(emu, 1, NULL)) < 0) { - snd_card_free(card); - return err; - } - if ((err = snd_emu10k1_pcm_efx(emu, 2, NULL)) < 0) { - snd_card_free(card); - return err; - } + &emu)) < 0) + goto error; + card->private_data = emu; + if ((err = snd_emu10k1_pcm(emu, 0, NULL)) < 0) + goto error; + if ((err = snd_emu10k1_pcm_mic(emu, 1, NULL)) < 0) + goto error; + if ((err = snd_emu10k1_pcm_efx(emu, 2, NULL)) < 0) + goto error; /* This stores the periods table. */ if (emu->card_capabilities->ca0151_chip) { /* P16V */ - if(snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), 1024, &emu->p16v_buffer) < 0) { - snd_p16v_free(emu); - return -ENOMEM; - } + if ((err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), + 1024, &emu->p16v_buffer)) < 0) + goto error; } - if ((err = snd_emu10k1_mixer(emu, 0, 3)) < 0) { - snd_card_free(card); - return err; - } + if ((err = snd_emu10k1_mixer(emu, 0, 3)) < 0) + goto error; - if ((err = snd_emu10k1_timer(emu, 0)) < 0) { - snd_card_free(card); - return err; - } + if ((err = snd_emu10k1_timer(emu, 0)) < 0) + goto error; - if ((err = snd_emu10k1_pcm_multi(emu, 3, NULL)) < 0) { - snd_card_free(card); - return err; - } - if (emu->card_capabilities->ca0151_chip) { /* P16V */ - if ((err = snd_p16v_pcm(emu, 4, NULL)) < 0) { - snd_card_free(card); - return err; - } + if ((err = snd_emu10k1_pcm_multi(emu, 3, NULL)) < 0) + goto error; + if (emu->card_capabilities->ca0151_chip) { /* P16V */ + if ((err = snd_p16v_pcm(emu, 4, NULL)) < 0) + goto error; } if (emu->audigy) { - if ((err = snd_emu10k1_audigy_midi(emu)) < 0) { - snd_card_free(card); - return err; - } + if ((err = snd_emu10k1_audigy_midi(emu)) < 0) + goto error; } else { - if ((err = snd_emu10k1_midi(emu)) < 0) { - snd_card_free(card); - return err; - } - } - if ((err = snd_emu10k1_fx8010_new(emu, 0, NULL)) < 0) { - snd_card_free(card); - return err; + if ((err = snd_emu10k1_midi(emu)) < 0) + goto error; } + if ((err = snd_emu10k1_fx8010_new(emu, 0, NULL)) < 0) + goto error; #ifdef ENABLE_SYNTH if (snd_seq_device_new(card, 1, SNDRV_SEQ_DEV_ID_EMU10K1_SYNTH, - sizeof(snd_emu10k1_synth_arg_t), &wave) < 0 || + sizeof(struct snd_emu10k1_synth_arg), &wave) < 0 || wave == NULL) { snd_printk(KERN_WARNING "can't initialize Emu10k1 wavetable synth\n"); } else { - snd_emu10k1_synth_arg_t *arg; + struct snd_emu10k1_synth_arg *arg; arg = SNDRV_SEQ_DEVICE_ARGPTR(wave); strcpy(wave->name, "Emu-10k1 Synth"); arg->hwptr = emu; @@ -206,13 +184,16 @@ static int __devinit snd_card_emu10k1_probe(struct pci_dev *pci, "%s (rev.%d, serial:0x%x) at 0x%lx, irq %i", card->shortname, emu->revision, emu->serial, emu->port, emu->irq); - if ((err = snd_card_register(card)) < 0) { - snd_card_free(card); - return err; - } + if ((err = snd_card_register(card)) < 0) + goto error; + pci_set_drvdata(pci, card); dev++; return 0; + + error: + snd_card_free(card); + return err; } static void __devexit snd_card_emu10k1_remove(struct pci_dev *pci) @@ -221,11 +202,68 @@ static void __devexit snd_card_emu10k1_remove(struct pci_dev *pci) pci_set_drvdata(pci, NULL); } + +#ifdef CONFIG_PM +static int snd_emu10k1_suspend(struct pci_dev *pci, pm_message_t state) +{ + struct snd_card *card = pci_get_drvdata(pci); + struct snd_emu10k1 *emu = card->private_data; + + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); + + snd_pcm_suspend_all(emu->pcm); + snd_pcm_suspend_all(emu->pcm_mic); + snd_pcm_suspend_all(emu->pcm_efx); + snd_pcm_suspend_all(emu->pcm_multi); + snd_pcm_suspend_all(emu->pcm_p16v); + + snd_ac97_suspend(emu->ac97); + + snd_emu10k1_efx_suspend(emu); + snd_emu10k1_suspend_regs(emu); + if (emu->card_capabilities->ca0151_chip) + snd_p16v_suspend(emu); + + snd_emu10k1_done(emu); + + pci_set_power_state(pci, PCI_D3hot); + pci_disable_device(pci); + pci_save_state(pci); + return 0; +} + +int snd_emu10k1_resume(struct pci_dev *pci) +{ + struct snd_card *card = pci_get_drvdata(pci); + struct snd_emu10k1 *emu = card->private_data; + + pci_restore_state(pci); + pci_enable_device(pci); + pci_set_power_state(pci, PCI_D0); + pci_set_master(pci); + + snd_emu10k1_resume_init(emu); + snd_emu10k1_efx_resume(emu); + snd_ac97_resume(emu->ac97); + snd_emu10k1_resume_regs(emu); + + if (emu->card_capabilities->ca0151_chip) + snd_p16v_resume(emu); + + snd_power_change_state(card, SNDRV_CTL_POWER_D0); + return 0; +} +#endif + static struct pci_driver driver = { .name = "EMU10K1_Audigy", .id_table = snd_emu10k1_ids, .probe = snd_card_emu10k1_probe, .remove = __devexit_p(snd_card_emu10k1_remove), +#ifdef CONFIG_PM + .suspend = snd_emu10k1_suspend, + .resume = snd_emu10k1_resume, +#endif }; static int __init alsa_card_emu10k1_init(void) diff --git a/sound/pci/emu10k1/emu10k1_callback.c b/sound/pci/emu10k1/emu10k1_callback.c index 6589bf24abc..01965bd9996 100644 --- a/sound/pci/emu10k1/emu10k1_callback.c +++ b/sound/pci/emu10k1/emu10k1_callback.c @@ -27,26 +27,28 @@ enum { }; /* Keeps track of what we are finding */ -typedef struct best_voice { +struct best_voice { unsigned int time; int voice; -} best_voice_t; +}; /* * prototypes */ -static void lookup_voices(snd_emux_t *emu, emu10k1_t *hw, best_voice_t *best, int active_only); -static snd_emux_voice_t *get_voice(snd_emux_t *emu, snd_emux_port_t *port); -static int start_voice(snd_emux_voice_t *vp); -static void trigger_voice(snd_emux_voice_t *vp); -static void release_voice(snd_emux_voice_t *vp); -static void update_voice(snd_emux_voice_t *vp, int update); -static void terminate_voice(snd_emux_voice_t *vp); -static void free_voice(snd_emux_voice_t *vp); - -static void set_fmmod(emu10k1_t *hw, snd_emux_voice_t *vp); -static void set_fm2frq2(emu10k1_t *hw, snd_emux_voice_t *vp); -static void set_filterQ(emu10k1_t *hw, snd_emux_voice_t *vp); +static void lookup_voices(struct snd_emux *emu, struct snd_emu10k1 *hw, + struct best_voice *best, int active_only); +static struct snd_emux_voice *get_voice(struct snd_emux *emu, + struct snd_emux_port *port); +static int start_voice(struct snd_emux_voice *vp); +static void trigger_voice(struct snd_emux_voice *vp); +static void release_voice(struct snd_emux_voice *vp); +static void update_voice(struct snd_emux_voice *vp, int update); +static void terminate_voice(struct snd_emux_voice *vp); +static void free_voice(struct snd_emux_voice *vp); + +static void set_fmmod(struct snd_emu10k1 *hw, struct snd_emux_voice *vp); +static void set_fm2frq2(struct snd_emu10k1 *hw, struct snd_emux_voice *vp); +static void set_filterQ(struct snd_emu10k1 *hw, struct snd_emux_voice *vp); /* * Ensure a value is between two points @@ -59,7 +61,7 @@ static void set_filterQ(emu10k1_t *hw, snd_emux_voice_t *vp); /* * set up operators */ -static snd_emux_operators_t emu10k1_ops = { +static struct snd_emux_operators emu10k1_ops = { .owner = THIS_MODULE, .get_voice = get_voice, .prepare = start_voice, @@ -73,7 +75,7 @@ static snd_emux_operators_t emu10k1_ops = { }; void -snd_emu10k1_ops_setup(snd_emux_t *emu) +snd_emu10k1_ops_setup(struct snd_emux *emu) { emu->ops = emu10k1_ops; } @@ -85,11 +87,11 @@ snd_emu10k1_ops_setup(snd_emux_t *emu) * terminate most inactive voice and give it as a pcm voice. */ int -snd_emu10k1_synth_get_voice(emu10k1_t *hw) +snd_emu10k1_synth_get_voice(struct snd_emu10k1 *hw) { - snd_emux_t *emu; - snd_emux_voice_t *vp; - best_voice_t best[V_END]; + struct snd_emux *emu; + struct snd_emux_voice *vp; + struct best_voice best[V_END]; unsigned long flags; int i; @@ -123,10 +125,10 @@ snd_emu10k1_synth_get_voice(emu10k1_t *hw) * turn off the voice (not terminated) */ static void -release_voice(snd_emux_voice_t *vp) +release_voice(struct snd_emux_voice *vp) { int dcysusv; - emu10k1_t *hw; + struct snd_emu10k1 *hw; hw = vp->hw; dcysusv = 0x8000 | (unsigned char)vp->reg.parm.modrelease; @@ -140,16 +142,16 @@ release_voice(snd_emux_voice_t *vp) * terminate the voice */ static void -terminate_voice(snd_emux_voice_t *vp) +terminate_voice(struct snd_emux_voice *vp) { - emu10k1_t *hw; + struct snd_emu10k1 *hw; snd_assert(vp, return); hw = vp->hw; snd_emu10k1_ptr_write(hw, DCYSUSV, vp->ch, 0x807f | DCYSUSV_CHANNELENABLE_MASK); if (vp->block) { - emu10k1_memblk_t *emem; - emem = (emu10k1_memblk_t *)vp->block; + struct snd_emu10k1_memblk *emem; + emem = (struct snd_emu10k1_memblk *)vp->block; if (emem->map_locked > 0) emem->map_locked--; } @@ -159,9 +161,9 @@ terminate_voice(snd_emux_voice_t *vp) * release the voice to system */ static void -free_voice(snd_emux_voice_t *vp) +free_voice(struct snd_emux_voice *vp) { - emu10k1_t *hw; + struct snd_emu10k1 *hw; hw = vp->hw; if (vp->ch >= 0) { @@ -181,9 +183,9 @@ free_voice(snd_emux_voice_t *vp) * update registers */ static void -update_voice(snd_emux_voice_t *vp, int update) +update_voice(struct snd_emux_voice *vp, int update) { - emu10k1_t *hw; + struct snd_emu10k1 *hw; hw = vp->hw; if (update & SNDRV_EMUX_UPDATE_VOLUME) @@ -210,10 +212,11 @@ update_voice(snd_emux_voice_t *vp, int update) */ /* spinlock held! */ static void -lookup_voices(snd_emux_t *emu, emu10k1_t *hw, best_voice_t *best, int active_only) +lookup_voices(struct snd_emux *emu, struct snd_emu10k1 *hw, + struct best_voice *best, int active_only) { - snd_emux_voice_t *vp; - best_voice_t *bp; + struct snd_emux_voice *vp; + struct best_voice *bp; int i; for (i = 0; i < V_END; i++) { @@ -274,12 +277,12 @@ lookup_voices(snd_emux_t *emu, emu10k1_t *hw, best_voice_t *best, int active_onl * * emu->voice_lock is already held. */ -static snd_emux_voice_t * -get_voice(snd_emux_t *emu, snd_emux_port_t *port) +static struct snd_emux_voice * +get_voice(struct snd_emux *emu, struct snd_emux_port *port) { - emu10k1_t *hw; - snd_emux_voice_t *vp; - best_voice_t best[V_END]; + struct snd_emu10k1 *hw; + struct snd_emux_voice *vp; + struct best_voice best[V_END]; int i; hw = emu->hw; @@ -290,7 +293,7 @@ get_voice(snd_emux_t *emu, snd_emux_port_t *port) vp = &emu->voices[best[i].voice]; if (vp->ch < 0) { /* allocate a voice */ - emu10k1_voice_t *hwvoice; + struct snd_emu10k1_voice *hwvoice; if (snd_emu10k1_voice_alloc(hw, EMU10K1_SYNTH, 1, &hwvoice) < 0 || hwvoice == NULL) continue; vp->ch = hwvoice->number; @@ -308,21 +311,21 @@ get_voice(snd_emux_t *emu, snd_emux_port_t *port) * prepare envelopes and LFOs */ static int -start_voice(snd_emux_voice_t *vp) +start_voice(struct snd_emux_voice *vp) { unsigned int temp; int ch; unsigned int addr, mapped_offset; - snd_midi_channel_t *chan; - emu10k1_t *hw; - emu10k1_memblk_t *emem; + struct snd_midi_channel *chan; + struct snd_emu10k1 *hw; + struct snd_emu10k1_memblk *emem; hw = vp->hw; ch = vp->ch; snd_assert(ch >= 0, return -EINVAL); chan = vp->chan; - emem = (emu10k1_memblk_t *)vp->block; + emem = (struct snd_emu10k1_memblk *)vp->block; if (emem == NULL) return -EINVAL; emem->map_locked++; @@ -463,15 +466,15 @@ start_voice(snd_emux_voice_t *vp) * Start envelope */ static void -trigger_voice(snd_emux_voice_t *vp) +trigger_voice(struct snd_emux_voice *vp) { unsigned int temp, ptarget; - emu10k1_t *hw; - emu10k1_memblk_t *emem; + struct snd_emu10k1 *hw; + struct snd_emu10k1_memblk *emem; hw = vp->hw; - emem = (emu10k1_memblk_t *)vp->block; + emem = (struct snd_emu10k1_memblk *)vp->block; if (! emem || emem->mapped_page < 0) return; /* not mapped */ @@ -495,7 +498,7 @@ trigger_voice(snd_emux_voice_t *vp) /* set lfo1 modulation height and cutoff */ static void -set_fmmod(emu10k1_t *hw, snd_emux_voice_t *vp) +set_fmmod(struct snd_emu10k1 *hw, struct snd_emux_voice *vp) { unsigned short fmmod; short pitch; @@ -513,7 +516,7 @@ set_fmmod(emu10k1_t *hw, snd_emux_voice_t *vp) /* set lfo2 pitch & frequency */ static void -set_fm2frq2(emu10k1_t *hw, snd_emux_voice_t *vp) +set_fm2frq2(struct snd_emu10k1 *hw, struct snd_emux_voice *vp) { unsigned short fm2frq2; short pitch; @@ -531,7 +534,7 @@ set_fm2frq2(emu10k1_t *hw, snd_emux_voice_t *vp) /* set filterQ */ static void -set_filterQ(emu10k1_t *hw, snd_emux_voice_t *vp) +set_filterQ(struct snd_emu10k1 *hw, struct snd_emux_voice *vp) { unsigned int val; val = snd_emu10k1_ptr_read(hw, CCCA, vp->ch) & ~CCCA_RESONANCE; diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c index 53aeff0b783..3c7043b7d4c 100644 --- a/sound/pci/emu10k1/emu10k1_main.c +++ b/sound/pci/emu10k1/emu10k1_main.c @@ -40,18 +40,14 @@ #include <sound/core.h> #include <sound/emu10k1.h> #include "p16v.h" +#include "tina2.h" -#if 0 -MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>, Creative Labs, Inc."); -MODULE_DESCRIPTION("Routines for control of EMU10K1 chips"); -MODULE_LICENSE("GPL"); -#endif /************************************************************************* * EMU10K1 init / done *************************************************************************/ -void snd_emu10k1_voice_init(emu10k1_t * emu, int ch) +void snd_emu10k1_voice_init(struct snd_emu10k1 * emu, int ch) { snd_emu10k1_ptr_write(emu, DCYSUSV, ch, 0); snd_emu10k1_ptr_write(emu, IP, ch, 0); @@ -96,17 +92,38 @@ void snd_emu10k1_voice_init(emu10k1_t * emu, int ch) } } -static int __devinit snd_emu10k1_init(emu10k1_t * emu, int enable_ir) +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 snd_emu10k1_init(struct snd_emu10k1 *emu, int enable_ir, int resume) { - int ch, idx, err; unsigned int silent_page; - - emu->fx8010.itram_size = (16 * 1024)/2; - emu->fx8010.etram_pages.area = NULL; - emu->fx8010.etram_pages.bytes = 0; + int ch; /* disable audio and lock cache */ - outl(HCFG_LOCKSOUNDCACHE | HCFG_LOCKTANKCACHE_MASK | HCFG_MUTEBUTTONENABLE, emu->port + HCFG); + outl(HCFG_LOCKSOUNDCACHE | HCFG_LOCKTANKCACHE_MASK | HCFG_MUTEBUTTONENABLE, + emu->port + HCFG); /* reset recording buffers */ snd_emu10k1_ptr_write(emu, MICBS, 0, ADCBS_BUFSIZE_NONE); @@ -127,48 +144,17 @@ static int __devinit snd_emu10k1_init(emu10k1_t * emu, int enable_ir) /* set SPDIF bypass mode */ snd_emu10k1_ptr_write(emu, SPBYPASS, 0, SPBYPASS_FORMAT); /* enable rear left + rear right AC97 slots */ - snd_emu10k1_ptr_write(emu, AC97SLOT, 0, AC97SLOT_REAR_RIGHT | AC97SLOT_REAR_LEFT); + snd_emu10k1_ptr_write(emu, AC97SLOT, 0, AC97SLOT_REAR_RIGHT | + AC97SLOT_REAR_LEFT); } /* init envelope engine */ - for (ch = 0; ch < NUM_G; ch++) { - emu->voices[ch].emu = emu; - emu->voices[ch].number = ch; + for (ch = 0; ch < NUM_G; ch++) snd_emu10k1_voice_init(emu, ch); - } - /* - * Init to 0x02109204 : - * Clock accuracy = 0 (1000ppm) - * Sample Rate = 2 (48kHz) - * Audio Channel = 1 (Left of 2) - * Source Number = 0 (Unspecified) - * Generation Status = 1 (Original for Cat Code 12) - * Cat Code = 12 (Digital Signal Mixer) - * Mode = 0 (Mode 0) - * Emphasis = 0 (None) - * CP = 1 (Copyright unasserted) - * AN = 0 (Audio data) - * P = 0 (Consumer) - */ - snd_emu10k1_ptr_write(emu, SPCS0, 0, - emu->spdif_bits[0] = - SPCS_CLKACCY_1000PPM | SPCS_SAMPLERATE_48 | - SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC | - SPCS_GENERATIONSTATUS | 0x00001200 | - 0x00000000 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT); - snd_emu10k1_ptr_write(emu, SPCS1, 0, - emu->spdif_bits[1] = - SPCS_CLKACCY_1000PPM | SPCS_SAMPLERATE_48 | - SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC | - SPCS_GENERATIONSTATUS | 0x00001200 | - 0x00000000 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT); - snd_emu10k1_ptr_write(emu, SPCS2, 0, - emu->spdif_bits[2] = - SPCS_CLKACCY_1000PPM | SPCS_SAMPLERATE_48 | - SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC | - SPCS_GENERATIONSTATUS | 0x00001200 | - 0x00000000 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT); + snd_emu10k1_ptr_write(emu, SPCS0, 0, emu->spdif_bits[0]); + snd_emu10k1_ptr_write(emu, SPCS1, 0, emu->spdif_bits[1]); + snd_emu10k1_ptr_write(emu, SPCS2, 0, emu->spdif_bits[2]); if (emu->card_capabilities->ca0151_chip) { /* audigy2 */ /* Hacks for Alice3 to work independent of haP16V driver */ @@ -195,7 +181,7 @@ static int __devinit snd_emu10k1_init(emu10k1_t * emu, int enable_ir) /* Hacks for Alice3 to work independent of haP16V driver */ u32 tmp; - snd_printk(KERN_ERR "Audigy2 value:Special config.\n"); + snd_printk(KERN_INFO "Audigy2 value: Special config.\n"); //Setup SRCMulti_I2S SamplingRate tmp = snd_emu10k1_ptr_read(emu, A_SPDIF_SAMPLERATE, 0); tmp &= 0xfffff1ff; @@ -219,15 +205,28 @@ static int __devinit snd_emu10k1_init(emu10k1_t * emu, int enable_ir) tmp = inl(emu->port + A_IOCFG) & ~0x8; /* Clear bit 3 */ outl(tmp, emu->port + A_IOCFG); } + if (emu->card_capabilities->spi_dac) { /* Audigy 2 ZS Notebook with DAC Wolfson WM8768/WM8568 */ + int size, n; + + size = ARRAY_SIZE(spi_dac_init); + for (n=0; n < size; n++) + snd_emu10k1_spi_write(emu, spi_dac_init[n]); + + snd_emu10k1_ptr20_write(emu, 0x60, 0, 0x10); + /* Enable GPIOs + * GPIO0: Unknown + * GPIO1: Speakers-enabled. + * GPIO2: Unknown + * GPIO3: Unknown + * GPIO4: IEC958 Output on. + * GPIO5: Unknown + * GPIO6: Unknown + * GPIO7: Unknown + */ + outl(0x76, emu->port + A_IOCFG); /* Windows uses 0x3f76 */ - - /* - * Clear page with silence & setup all pointers to this page - */ - memset(emu->silent_page.area, 0, PAGE_SIZE); - silent_page = emu->silent_page.addr << 1; - for (idx = 0; idx < MAXPAGES; idx++) - ((u32 *)emu->ptb_pages.area)[idx] = cpu_to_le32(silent_page | idx); + } + snd_emu10k1_ptr_write(emu, PTB, 0, emu->ptb_pages.addr); snd_emu10k1_ptr_write(emu, TCB, 0, 0); /* taken from original driver */ snd_emu10k1_ptr_write(emu, TCBS, 0, 4); /* taken from original driver */ @@ -264,7 +263,9 @@ static int __devinit snd_emu10k1_init(emu10k1_t * emu, int enable_ir) outl(HCFG_LOCKTANKCACHE_MASK | HCFG_AUTOMUTE | HCFG_JOYENABLE, emu->port + HCFG); if (enable_ir) { /* enable IR for SB Live */ - if (emu->audigy) { + if ( emu->card_capabilities->emu1212m) { + ; /* Disable all access to A_IOCFG for the emu1212m */ + } else if (emu->audigy) { unsigned int reg = inl(emu->port + A_IOCFG); outl(reg | A_IOCFG_GPOUT2, emu->port + A_IOCFG); udelay(500); @@ -281,24 +282,27 @@ static int __devinit snd_emu10k1_init(emu10k1_t * emu, int enable_ir) } } - if (emu->audigy) { /* enable analog output */ + if ( emu->card_capabilities->emu1212m) { + ; /* Disable all access to A_IOCFG for the emu1212m */ + } else if (emu->audigy) { /* enable analog output */ unsigned int reg = inl(emu->port + A_IOCFG); outl(reg | A_IOCFG_GPOUT0, emu->port + A_IOCFG); } - /* - * Initialize the effect engine - */ - if ((err = snd_emu10k1_init_efx(emu)) < 0) - return err; + return 0; +} +static void snd_emu10k1_audio_enable(struct snd_emu10k1 *emu) +{ /* * Enable the audio bit */ outl(inl(emu->port + HCFG) | HCFG_AUDIOENABLE, emu->port + HCFG); /* Enable analog/digital outs on audigy */ - if (emu->audigy) { + if ( emu->card_capabilities->emu1212m) { + ; /* Disable all access to A_IOCFG for the emu1212m */ + } else if (emu->audigy) { outl(inl(emu->port + A_IOCFG) & ~0x44, emu->port + A_IOCFG); if (emu->card_capabilities->ca0151_chip) { /* audigy2 */ @@ -334,15 +338,9 @@ static int __devinit snd_emu10k1_init(emu10k1_t * emu, int enable_ir) #endif snd_emu10k1_intr_enable(emu, INTE_PCIERRORENABLE); - - emu->reserved_page = (emu10k1_memblk_t *)snd_emu10k1_synth_alloc(emu, 4096); - if (emu->reserved_page) - emu->reserved_page->map_locked = 1; - - return 0; } -static int snd_emu10k1_done(emu10k1_t * emu) +int snd_emu10k1_done(struct snd_emu10k1 * emu) { int ch; @@ -381,18 +379,10 @@ static int snd_emu10k1_done(emu10k1_t * emu) snd_emu10k1_ptr_write(emu, SOLEL, 0, 0); snd_emu10k1_ptr_write(emu, SOLEH, 0, 0); - /* remove reserved page */ - if (emu->reserved_page != NULL) { - snd_emu10k1_synth_free(emu, (snd_util_memblk_t *)emu->reserved_page); - emu->reserved_page = NULL; - } - /* disable audio and lock cache */ outl(HCFG_LOCKSOUNDCACHE | HCFG_LOCKTANKCACHE_MASK | HCFG_MUTEBUTTONENABLE, emu->port + HCFG); snd_emu10k1_ptr_write(emu, PTB, 0, 0); - snd_emu10k1_free_efx(emu); - return 0; } @@ -473,7 +463,7 @@ static int snd_emu10k1_done(emu10k1_t * emu) * register. */ -static void snd_emu10k1_ecard_write(emu10k1_t * emu, unsigned int value) +static void snd_emu10k1_ecard_write(struct snd_emu10k1 * emu, unsigned int value) { unsigned short count; unsigned int data; @@ -511,7 +501,7 @@ static void snd_emu10k1_ecard_write(emu10k1_t * emu, unsigned int value) * channel. */ -static void snd_emu10k1_ecard_setadcgain(emu10k1_t * emu, +static void snd_emu10k1_ecard_setadcgain(struct snd_emu10k1 * emu, unsigned short gain) { unsigned int bit; @@ -539,7 +529,7 @@ static void snd_emu10k1_ecard_setadcgain(emu10k1_t * emu, snd_emu10k1_ecard_write(emu, emu->ecard_ctrl); } -static int __devinit snd_emu10k1_ecard_init(emu10k1_t * emu) +static int __devinit snd_emu10k1_ecard_init(struct snd_emu10k1 * emu) { unsigned int hc_value; @@ -579,7 +569,7 @@ static int __devinit snd_emu10k1_ecard_init(emu10k1_t * emu) return 0; } -static int __devinit snd_emu10k1_cardbus_init(emu10k1_t * emu) +static int __devinit snd_emu10k1_cardbus_init(struct snd_emu10k1 * emu) { unsigned long special_port; unsigned int value; @@ -600,18 +590,160 @@ static int __devinit snd_emu10k1_cardbus_init(emu10k1_t * emu) outl(0x0090007f, special_port); value = inl(special_port); + snd_emu10k1_ptr20_write(emu, TINA2_VOLUME, 0, 0xfefefefe); /* Defaults to 0x30303030 */ + return 0; +} + +static int snd_emu1212m_fpga_write(struct snd_emu10k1 * emu, int reg, int value) +{ + if (reg<0 || reg>0x3f) + return 1; + reg+=0x40; /* 0x40 upwards are registers. */ + if (value<0 || value>0x3f) /* 0 to 0x3f are values */ + return 1; + outl(reg, emu->port + A_IOCFG); + outl(reg | 0x80, emu->port + A_IOCFG); /* High bit clocks the value into the fpga. */ + outl(value, emu->port + A_IOCFG); + outl(value | 0x80 , emu->port + A_IOCFG); /* High bit clocks the value into the fpga. */ + return 0; } +static int snd_emu1212m_fpga_read(struct snd_emu10k1 * emu, int reg, int *value) +{ + if (reg<0 || reg>0x3f) + return 1; + reg+=0x40; /* 0x40 upwards are registers. */ + outl(reg, emu->port + A_IOCFG); + outl(reg | 0x80, emu->port + A_IOCFG); /* High bit clocks the value into the fpga. */ + *value = inl(emu->port + A_IOCFG); + + return 0; +} + +static int snd_emu1212m_fpga_netlist_write(struct snd_emu10k1 * emu, int reg, int value) +{ + snd_emu1212m_fpga_write(emu, 0x00, ((reg >> 8) & 0x3f) ); + snd_emu1212m_fpga_write(emu, 0x01, (reg & 0x3f) ); + snd_emu1212m_fpga_write(emu, 0x02, ((value >> 8) & 0x3f) ); + snd_emu1212m_fpga_write(emu, 0x03, (value & 0x3f) ); + + return 0; +} + +static int __devinit snd_emu10k1_emu1212m_init(struct snd_emu10k1 * emu) +{ + unsigned int i; + int tmp; + + snd_printk(KERN_ERR "emu1212m: Special config.\n"); + outl(0x0005a00c, emu->port + HCFG); + outl(0x0005a004, emu->port + HCFG); + outl(0x0005a000, emu->port + HCFG); + outl(0x0005a000, emu->port + HCFG); + + snd_emu1212m_fpga_read(emu, 0x22, &tmp ); + snd_emu1212m_fpga_read(emu, 0x23, &tmp ); + snd_emu1212m_fpga_read(emu, 0x24, &tmp ); + snd_emu1212m_fpga_write(emu, 0x04, 0x01 ); + snd_emu1212m_fpga_read(emu, 0x0b, &tmp ); + snd_emu1212m_fpga_write(emu, 0x0b, 0x01 ); + snd_emu1212m_fpga_read(emu, 0x10, &tmp ); + snd_emu1212m_fpga_write(emu, 0x10, 0x00 ); + snd_emu1212m_fpga_read(emu, 0x11, &tmp ); + snd_emu1212m_fpga_write(emu, 0x11, 0x30 ); + snd_emu1212m_fpga_read(emu, 0x13, &tmp ); + snd_emu1212m_fpga_write(emu, 0x13, 0x0f ); + snd_emu1212m_fpga_read(emu, 0x11, &tmp ); + snd_emu1212m_fpga_write(emu, 0x11, 0x30 ); + snd_emu1212m_fpga_read(emu, 0x0a, &tmp ); + snd_emu1212m_fpga_write(emu, 0x0a, 0x10 ); + snd_emu1212m_fpga_write(emu, 0x0c, 0x19 ); + snd_emu1212m_fpga_write(emu, 0x12, 0x0c ); + snd_emu1212m_fpga_write(emu, 0x09, 0x0f ); + snd_emu1212m_fpga_write(emu, 0x06, 0x00 ); + snd_emu1212m_fpga_write(emu, 0x05, 0x00 ); + snd_emu1212m_fpga_write(emu, 0x0e, 0x12 ); + snd_emu1212m_fpga_netlist_write(emu, 0x0000, 0x0200); + snd_emu1212m_fpga_netlist_write(emu, 0x0001, 0x0201); + snd_emu1212m_fpga_netlist_write(emu, 0x0002, 0x0500); + snd_emu1212m_fpga_netlist_write(emu, 0x0003, 0x0501); + snd_emu1212m_fpga_netlist_write(emu, 0x0004, 0x0400); + snd_emu1212m_fpga_netlist_write(emu, 0x0005, 0x0401); + snd_emu1212m_fpga_netlist_write(emu, 0x0006, 0x0402); + snd_emu1212m_fpga_netlist_write(emu, 0x0007, 0x0403); + snd_emu1212m_fpga_netlist_write(emu, 0x0008, 0x0404); + snd_emu1212m_fpga_netlist_write(emu, 0x0009, 0x0405); + snd_emu1212m_fpga_netlist_write(emu, 0x000a, 0x0406); + snd_emu1212m_fpga_netlist_write(emu, 0x000b, 0x0407); + snd_emu1212m_fpga_netlist_write(emu, 0x000c, 0x0100); + snd_emu1212m_fpga_netlist_write(emu, 0x000d, 0x0104); + snd_emu1212m_fpga_netlist_write(emu, 0x000e, 0x0200); + snd_emu1212m_fpga_netlist_write(emu, 0x000f, 0x0201); + for (i=0;i < 0x20;i++) { + snd_emu1212m_fpga_netlist_write(emu, 0x0100+i, 0x0000); + } + for (i=0;i < 4;i++) { + snd_emu1212m_fpga_netlist_write(emu, 0x0200+i, 0x0000); + } + for (i=0;i < 7;i++) { + snd_emu1212m_fpga_netlist_write(emu, 0x0300+i, 0x0000); + } + for (i=0;i < 7;i++) { + snd_emu1212m_fpga_netlist_write(emu, 0x0400+i, 0x0000); + } + snd_emu1212m_fpga_netlist_write(emu, 0x0500, 0x0108); + snd_emu1212m_fpga_netlist_write(emu, 0x0501, 0x010c); + snd_emu1212m_fpga_netlist_write(emu, 0x0600, 0x0110); + snd_emu1212m_fpga_netlist_write(emu, 0x0601, 0x0114); + snd_emu1212m_fpga_netlist_write(emu, 0x0700, 0x0118); + snd_emu1212m_fpga_netlist_write(emu, 0x0701, 0x011c); + snd_emu1212m_fpga_write(emu, 0x07, 0x01 ); + + snd_emu1212m_fpga_read(emu, 0x21, &tmp ); + + outl(0x0000a000, emu->port + HCFG); + outl(0x0000a001, emu->port + HCFG); + /* Initial boot complete. Now patches */ + + snd_emu1212m_fpga_read(emu, 0x21, &tmp ); + snd_emu1212m_fpga_write(emu, 0x0c, 0x19 ); + snd_emu1212m_fpga_write(emu, 0x12, 0x0c ); + snd_emu1212m_fpga_write(emu, 0x0c, 0x19 ); + snd_emu1212m_fpga_write(emu, 0x12, 0x0c ); + snd_emu1212m_fpga_read(emu, 0x0a, &tmp ); + snd_emu1212m_fpga_write(emu, 0x0a, 0x10 ); + + snd_emu1212m_fpga_read(emu, 0x20, &tmp ); + snd_emu1212m_fpga_read(emu, 0x21, &tmp ); + + snd_emu1212m_fpga_netlist_write(emu, 0x0300, 0x0312); + snd_emu1212m_fpga_netlist_write(emu, 0x0301, 0x0313); + snd_emu1212m_fpga_netlist_write(emu, 0x0200, 0x0302); + snd_emu1212m_fpga_netlist_write(emu, 0x0201, 0x0303); + + return 0; +} /* * Create the EMU10K1 instance */ -static int snd_emu10k1_free(emu10k1_t *emu) +#ifdef CONFIG_PM +static int alloc_pm_buffer(struct snd_emu10k1 *emu); +static void free_pm_buffer(struct snd_emu10k1 *emu); +#endif + +static int snd_emu10k1_free(struct snd_emu10k1 *emu) { if (emu->port) { /* avoid access to already used hardware */ snd_emu10k1_fx8010_tram_setup(emu, 0); snd_emu10k1_done(emu); + /* remove reserved page */ + if (emu->reserved_page) { + snd_emu10k1_synth_free(emu, (struct snd_util_memblk *)emu->reserved_page); + emu->reserved_page = NULL; + } + snd_emu10k1_free_efx(emu); } if (emu->memhdr) snd_util_memhdr_free(emu->memhdr); @@ -621,26 +753,35 @@ static int snd_emu10k1_free(emu10k1_t *emu) snd_dma_free_pages(&emu->ptb_pages); vfree(emu->page_ptr_table); vfree(emu->page_addr_table); +#ifdef CONFIG_PM + free_pm_buffer(emu); +#endif if (emu->irq >= 0) free_irq(emu->irq, (void *)emu); if (emu->port) pci_release_regions(emu->pci); - pci_disable_device(emu->pci); if (emu->card_capabilities->ca0151_chip) /* P16V */ snd_p16v_free(emu); + pci_disable_device(emu->pci); kfree(emu); return 0; } -static int snd_emu10k1_dev_free(snd_device_t *device) +static int snd_emu10k1_dev_free(struct snd_device *device) { - emu10k1_t *emu = device->device_data; + struct snd_emu10k1 *emu = device->device_data; return snd_emu10k1_free(emu); } -static emu_chip_details_t emu_chip_details[] = { +static struct snd_emu_chip_details emu_chip_details[] = { /* Audigy 2 Value AC3 out does not work yet. Need to find out how to turn off interpolators.*/ /* Tested by James@superbug.co.uk 3rd July 2005 */ + /* DSP: CA0108-IAT + * DAC: CS4382-KQ + * ADC: Philips 1361T + * AC97: STAC9750 + * CA0151: None + */ {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x10011102, .driver = "Audigy2", .name = "Audigy 2 Value [SB0400]", .id = "Audigy2", @@ -649,14 +790,24 @@ static emu_chip_details_t emu_chip_details[] = { .spk71 = 1, .ac97_chip = 1} , /* Audigy 2 ZS Notebook Cardbus card.*/ - /* Tested by James@superbug.co.uk 30th October 2005 */ - /* Not working yet, but progressing. */ + /* Tested by James@superbug.co.uk 22th December 2005 */ + /* Audio output 7.1/Headphones working. + * Digital output working. (AC3 not checked, only PCM) + * Audio inputs not tested. + */ + /* DSP: Tiny2 + * DAC: Wolfson WM8768/WM8568 + * ADC: Wolfson WM8775 + * AC97: None + * CA0151: None + */ {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x20011102, .driver = "Audigy2", .name = "Audigy 2 ZS Notebook [SB0530]", .id = "Audigy2", .emu10k2_chip = 1, .ca0108_chip = 1, .ca_cardbus_chip = 1, + .spi_dac = 1, .spk71 = 1} , {.vendor = 0x1102, .device = 0x0008, .driver = "Audigy2", .name = "Audigy 2 Value [Unknown]", @@ -670,7 +821,7 @@ static emu_chip_details_t emu_chip_details[] = { .id = "EMU1212m", .emu10k2_chip = 1, .ca0102_chip = 1, - .ecard = 1} , + .emu1212m = 1} , /* Tested by James@superbug.co.uk 3rd July 2005 */ {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20071102, .driver = "Audigy2", .name = "Audigy 4 PRO [SB0380]", @@ -681,6 +832,16 @@ static emu_chip_details_t emu_chip_details[] = { .spk71 = 1, .spdif_bug = 1, .ac97_chip = 1} , + /* Tested by shane-alsa@cm.nu 5th Nov 2005 */ + {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20061102, + .driver = "Audigy2", .name = "Audigy 2 [2006]", + .id = "Audigy2", + .emu10k2_chip = 1, + .ca0102_chip = 1, + .ca0151_chip = 1, + .spk71 = 1, + .spdif_bug = 1, + .ac97_chip = 1} , {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20021102, .driver = "Audigy2", .name = "Audigy 2 ZS [SB0350]", .id = "Audigy2", @@ -699,6 +860,14 @@ static emu_chip_details_t emu_chip_details[] = { .spk71 = 1, .spdif_bug = 1, .ac97_chip = 1} , + /* Audigy 2 */ + /* Tested by James@superbug.co.uk 3rd July 2005 */ + /* DSP: CA0102-IAT + * DAC: CS4382-KQ + * ADC: Philips 1361T + * AC97: STAC9721 + * CA0151: Yes + */ {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10071102, .driver = "Audigy2", .name = "Audigy 2 [SB0240]", .id = "Audigy2", @@ -714,6 +883,7 @@ static emu_chip_details_t emu_chip_details[] = { .emu10k2_chip = 1, .ca0102_chip = 1, .ca0151_chip = 1, + .spk71 = 1, .spdif_bug = 1} , {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10021102, .driver = "Audigy2", .name = "Audigy 2 Platinum [SB0240P]", @@ -775,6 +945,14 @@ static emu_chip_details_t emu_chip_details[] = { .emu10k1_chip = 1, .ac97_chip = 1, .sblive51 = 1} , + /* Tested by ALSA bug#1680 26th December 2005 */ + /* note: It really has SB0220 written on the card. */ + {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80661102, + .driver = "EMU10K1", .name = "SB Live 5.1 Dell OEM [SB0220]", + .id = "Live", + .emu10k1_chip = 1, + .ac97_chip = 1, + .sblive51 = 1} , /* Tested by Thomas Zehetbauer 27th Aug 2005 */ {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80651102, .driver = "EMU10K1", .name = "SB Live 5.1 [SB0220]", @@ -782,6 +960,12 @@ static emu_chip_details_t emu_chip_details[] = { .emu10k1_chip = 1, .ac97_chip = 1, .sblive51 = 1} , + {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x100a1102, + .driver = "EMU10K1", .name = "SB Live 5.1 [SB0220]", + .id = "Live", + .emu10k1_chip = 1, + .ac97_chip = 1, + .sblive51 = 1} , {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80641102, .driver = "EMU10K1", .name = "SB Live 5.1", .id = "Live", @@ -877,21 +1061,22 @@ static emu_chip_details_t emu_chip_details[] = { { } /* terminator */ }; -int __devinit snd_emu10k1_create(snd_card_t * card, +int __devinit snd_emu10k1_create(struct snd_card *card, struct pci_dev * pci, unsigned short extin_mask, unsigned short extout_mask, long max_cache_bytes, int enable_ir, uint subsystem, - emu10k1_t ** remu) + struct snd_emu10k1 ** remu) { - emu10k1_t *emu; - int err; + struct snd_emu10k1 *emu; + int idx, err; int is_audigy; unsigned char revision; - const emu_chip_details_t *c; - static snd_device_ops_t ops = { + unsigned int silent_page; + const struct snd_emu_chip_details *c; + static struct snd_device_ops ops = { .dev_free = snd_emu10k1_dev_free, }; @@ -999,36 +1184,37 @@ int __devinit snd_emu10k1_create(snd_card_t * card, emu->port = pci_resource_start(pci, 0); if (request_irq(pci->irq, snd_emu10k1_interrupt, SA_INTERRUPT|SA_SHIRQ, "EMU10K1", (void *)emu)) { - snd_emu10k1_free(emu); - return -EBUSY; + err = -EBUSY; + goto error; } emu->irq = pci->irq; emu->max_cache_pages = max_cache_bytes >> PAGE_SHIFT; if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), 32 * 1024, &emu->ptb_pages) < 0) { - snd_emu10k1_free(emu); - return -ENOMEM; + err = -ENOMEM; + goto error; } emu->page_ptr_table = (void **)vmalloc(emu->max_cache_pages * sizeof(void*)); emu->page_addr_table = (unsigned long*)vmalloc(emu->max_cache_pages * sizeof(unsigned long)); if (emu->page_ptr_table == NULL || emu->page_addr_table == NULL) { - snd_emu10k1_free(emu); - return -ENOMEM; + err = -ENOMEM; + goto error; } if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), EMUPAGESIZE, &emu->silent_page) < 0) { - snd_emu10k1_free(emu); - return -ENOMEM; + err = -ENOMEM; + goto error; } emu->memhdr = snd_util_memhdr_new(emu->max_cache_pages * PAGE_SIZE); if (emu->memhdr == NULL) { - snd_emu10k1_free(emu); - return -ENOMEM; + err = -ENOMEM; + goto error; } - emu->memhdr->block_extra_size = sizeof(emu10k1_memblk_t) - sizeof(snd_util_memblk_t); + emu->memhdr->block_extra_size = sizeof(struct snd_emu10k1_memblk) - + sizeof(struct snd_util_memblk); pci_set_master(pci); @@ -1039,40 +1225,191 @@ int __devinit snd_emu10k1_create(snd_card_t * card, extout_mask = 0x7fff; emu->fx8010.extin_mask = extin_mask; emu->fx8010.extout_mask = extout_mask; + emu->enable_ir = enable_ir; if (emu->card_capabilities->ecard) { - if ((err = snd_emu10k1_ecard_init(emu)) < 0) { - snd_emu10k1_free(emu); - return err; - } + if ((err = snd_emu10k1_ecard_init(emu)) < 0) + goto error; } else if (emu->card_capabilities->ca_cardbus_chip) { - if ((err = snd_emu10k1_cardbus_init(emu)) < 0) { - snd_emu10k1_free(emu); - return err; - } + if ((err = snd_emu10k1_cardbus_init(emu)) < 0) + goto error; + } else if (emu->card_capabilities->emu1212m) { + if ((err = snd_emu10k1_emu1212m_init(emu)) < 0) { + snd_emu10k1_free(emu); + return err; + } } else { /* 5.1: Enable the additional AC97 Slots. If the emu10k1 version does not support this, it shouldn't do any harm */ snd_emu10k1_ptr_write(emu, AC97SLOT, 0, AC97SLOT_CNTR|AC97SLOT_LFE); } - if ((err = snd_emu10k1_init(emu, enable_ir)) < 0) { - snd_emu10k1_free(emu); - return err; - } + /* initialize TRAM setup */ + emu->fx8010.itram_size = (16 * 1024)/2; + emu->fx8010.etram_pages.area = NULL; + emu->fx8010.etram_pages.bytes = 0; - if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, emu, &ops)) < 0) { - snd_emu10k1_free(emu); - return err; + /* + * Init to 0x02109204 : + * Clock accuracy = 0 (1000ppm) + * Sample Rate = 2 (48kHz) + * Audio Channel = 1 (Left of 2) + * Source Number = 0 (Unspecified) + * Generation Status = 1 (Original for Cat Code 12) + * Cat Code = 12 (Digital Signal Mixer) + * Mode = 0 (Mode 0) + * Emphasis = 0 (None) + * CP = 1 (Copyright unasserted) + * AN = 0 (Audio data) + * P = 0 (Consumer) + */ + emu->spdif_bits[0] = emu->spdif_bits[1] = + emu->spdif_bits[2] = SPCS_CLKACCY_1000PPM | SPCS_SAMPLERATE_48 | + SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC | + SPCS_GENERATIONSTATUS | 0x00001200 | + 0x00000000 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT; + + emu->reserved_page = (struct snd_emu10k1_memblk *) + snd_emu10k1_synth_alloc(emu, 4096); + if (emu->reserved_page) + emu->reserved_page->map_locked = 1; + + /* Clear silent pages and set up pointers */ + memset(emu->silent_page.area, 0, PAGE_SIZE); + silent_page = emu->silent_page.addr << 1; + for (idx = 0; idx < MAXPAGES; idx++) + ((u32 *)emu->ptb_pages.area)[idx] = cpu_to_le32(silent_page | idx); + + /* set up voice indices */ + for (idx = 0; idx < NUM_G; idx++) { + emu->voices[idx].emu = emu; + emu->voices[idx].number = idx; } + if ((err = snd_emu10k1_init(emu, enable_ir, 0)) < 0) + goto error; +#ifdef CONFIG_PM + if ((err = alloc_pm_buffer(emu)) < 0) + goto error; +#endif + + /* Initialize the effect engine */ + if ((err = snd_emu10k1_init_efx(emu)) < 0) + goto error; + snd_emu10k1_audio_enable(emu); + + if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, emu, &ops)) < 0) + goto error; + +#ifdef CONFIG_PROC_FS snd_emu10k1_proc_init(emu); +#endif snd_card_set_dev(card, &pci->dev); *remu = emu; return 0; + + error: + snd_emu10k1_free(emu); + return err; } +#ifdef CONFIG_PM +static unsigned char saved_regs[] = { + CPF, PTRX, CVCF, VTFT, Z1, Z2, PSST, DSL, CCCA, CCR, CLP, + FXRT, MAPA, MAPB, ENVVOL, ATKHLDV, DCYSUSV, LFOVAL1, ENVVAL, + ATKHLDM, DCYSUSM, LFOVAL2, IP, IFATN, PEFE, FMMOD, TREMFRQ, FM2FRQ2, + TEMPENV, ADCCR, FXWC, MICBA, ADCBA, FXBA, + MICBS, ADCBS, FXBS, CDCS, GPSCS, SPCS0, SPCS1, SPCS2, + SPBYPASS, AC97SLOT, CDSRCS, GPSRCS, ZVSRCS, MICIDX, ADCIDX, FXIDX, + 0xff /* end */ +}; +static unsigned char saved_regs_audigy[] = { + A_ADCIDX, A_MICIDX, A_FXWC1, A_FXWC2, A_SAMPLE_RATE, + A_FXRT2, A_SENDAMOUNTS, A_FXRT1, + 0xff /* end */ +}; + +static int __devinit alloc_pm_buffer(struct snd_emu10k1 *emu) +{ + int size; + + size = ARRAY_SIZE(saved_regs); + if (emu->audigy) + size += ARRAY_SIZE(saved_regs_audigy); + emu->saved_ptr = vmalloc(4 * NUM_G * size); + if (! emu->saved_ptr) + return -ENOMEM; + if (snd_emu10k1_efx_alloc_pm_buffer(emu) < 0) + return -ENOMEM; + if (emu->card_capabilities->ca0151_chip && + snd_p16v_alloc_pm_buffer(emu) < 0) + return -ENOMEM; + return 0; +} + +static void free_pm_buffer(struct snd_emu10k1 *emu) +{ + vfree(emu->saved_ptr); + snd_emu10k1_efx_free_pm_buffer(emu); + if (emu->card_capabilities->ca0151_chip) + snd_p16v_free_pm_buffer(emu); +} + +void snd_emu10k1_suspend_regs(struct snd_emu10k1 *emu) +{ + int i; + unsigned char *reg; + unsigned int *val; + + val = emu->saved_ptr; + for (reg = saved_regs; *reg != 0xff; reg++) + for (i = 0; i < NUM_G; i++, val++) + *val = snd_emu10k1_ptr_read(emu, *reg, i); + if (emu->audigy) { + for (reg = saved_regs_audigy; *reg != 0xff; reg++) + for (i = 0; i < NUM_G; i++, val++) + *val = snd_emu10k1_ptr_read(emu, *reg, i); + } + if (emu->audigy) + emu->saved_a_iocfg = inl(emu->port + A_IOCFG); + emu->saved_hcfg = inl(emu->port + HCFG); +} + +void snd_emu10k1_resume_init(struct snd_emu10k1 *emu) +{ + if (emu->card_capabilities->ecard) + snd_emu10k1_ecard_init(emu); + else + snd_emu10k1_ptr_write(emu, AC97SLOT, 0, AC97SLOT_CNTR|AC97SLOT_LFE); + snd_emu10k1_init(emu, emu->enable_ir, 1); +} + +void snd_emu10k1_resume_regs(struct snd_emu10k1 *emu) +{ + int i; + unsigned char *reg; + unsigned int *val; + + snd_emu10k1_audio_enable(emu); + + /* resore for spdif */ + if (emu->audigy) + outl(emu->port + A_IOCFG, emu->saved_a_iocfg); + outl(emu->port + HCFG, emu->saved_hcfg); + + val = emu->saved_ptr; + for (reg = saved_regs; *reg != 0xff; reg++) + for (i = 0; i < NUM_G; i++, val++) + snd_emu10k1_ptr_write(emu, *reg, i, *val); + if (emu->audigy) { + for (reg = saved_regs_audigy; *reg != 0xff; reg++) + for (i = 0; i < NUM_G; i++, val++) + snd_emu10k1_ptr_write(emu, *reg, i, *val); + } +} +#endif + /* memory.c */ EXPORT_SYMBOL(snd_emu10k1_synth_alloc); EXPORT_SYMBOL(snd_emu10k1_synth_free); diff --git a/sound/pci/emu10k1/emu10k1_patch.c b/sound/pci/emu10k1/emu10k1_patch.c index 4df668eb32b..42bae6f7e9a 100644 --- a/sound/pci/emu10k1/emu10k1_patch.c +++ b/sound/pci/emu10k1/emu10k1_patch.c @@ -35,14 +35,15 @@ * allocate a sample block and copy data from userspace */ int -snd_emu10k1_sample_new(snd_emux_t *rec, snd_sf_sample_t *sp, - snd_util_memhdr_t *hdr, const void __user *data, long count) +snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp, + struct snd_util_memhdr *hdr, + const void __user *data, long count) { int offset; int truesize, size, loopsize, blocksize; int loopend, sampleend; unsigned int start_addr; - emu10k1_t *emu; + struct snd_emu10k1 *emu; emu = rec->hw; snd_assert(sp != NULL, return -EINVAL); @@ -205,10 +206,10 @@ snd_emu10k1_sample_new(snd_emux_t *rec, snd_sf_sample_t *sp, * free a sample block */ int -snd_emu10k1_sample_free(snd_emux_t *rec, snd_sf_sample_t *sp, - snd_util_memhdr_t *hdr) +snd_emu10k1_sample_free(struct snd_emux *rec, struct snd_sf_sample *sp, + struct snd_util_memhdr *hdr) { - emu10k1_t *emu; + struct snd_emu10k1 *emu; emu = rec->hw; snd_assert(sp != NULL, return -EINVAL); diff --git a/sound/pci/emu10k1/emu10k1_synth.c b/sound/pci/emu10k1/emu10k1_synth.c index 8bd58d1dcc2..1fa393f22a9 100644 --- a/sound/pci/emu10k1/emu10k1_synth.c +++ b/sound/pci/emu10k1/emu10k1_synth.c @@ -28,11 +28,11 @@ MODULE_LICENSE("GPL"); /* * create a new hardware dependent device for Emu10k1 */ -static int snd_emu10k1_synth_new_device(snd_seq_device_t *dev) +static int snd_emu10k1_synth_new_device(struct snd_seq_device *dev) { - snd_emux_t *emu; - emu10k1_t *hw; - snd_emu10k1_synth_arg_t *arg; + struct snd_emux *emu; + struct snd_emu10k1 *hw; + struct snd_emu10k1_synth_arg *arg; unsigned long flags; arg = SNDRV_SEQ_DEVICE_ARGPTR(dev); @@ -76,10 +76,10 @@ static int snd_emu10k1_synth_new_device(snd_seq_device_t *dev) return 0; } -static int snd_emu10k1_synth_delete_device(snd_seq_device_t *dev) +static int snd_emu10k1_synth_delete_device(struct snd_seq_device *dev) { - snd_emux_t *emu; - emu10k1_t *hw; + struct snd_emux *emu; + struct snd_emu10k1 *hw; unsigned long flags; if (dev->driver_data == NULL) @@ -104,11 +104,12 @@ static int snd_emu10k1_synth_delete_device(snd_seq_device_t *dev) static int __init alsa_emu10k1_synth_init(void) { - static snd_seq_dev_ops_t ops = { + static struct snd_seq_dev_ops ops = { snd_emu10k1_synth_new_device, snd_emu10k1_synth_delete_device, }; - return snd_seq_device_register_driver(SNDRV_SEQ_DEV_ID_EMU10K1_SYNTH, &ops, sizeof(snd_emu10k1_synth_arg_t)); + return snd_seq_device_register_driver(SNDRV_SEQ_DEV_ID_EMU10K1_SYNTH, &ops, + sizeof(struct snd_emu10k1_synth_arg)); } static void __exit alsa_emu10k1_synth_exit(void) diff --git a/sound/pci/emu10k1/emu10k1_synth_local.h b/sound/pci/emu10k1/emu10k1_synth_local.h index 7f50b01ddb7..308ddc84bb4 100644 --- a/sound/pci/emu10k1/emu10k1_synth_local.h +++ b/sound/pci/emu10k1/emu10k1_synth_local.h @@ -26,13 +26,18 @@ #include <sound/emu10k1_synth.h> /* emu10k1_patch.c */ -int snd_emu10k1_sample_new(snd_emux_t *private_data, snd_sf_sample_t *sp, snd_util_memhdr_t *hdr, const void __user *_data, long count); -int snd_emu10k1_sample_free(snd_emux_t *private_data, snd_sf_sample_t *sp, snd_util_memhdr_t *hdr); -int snd_emu10k1_memhdr_init(snd_emux_t *emu); +int snd_emu10k1_sample_new(struct snd_emux *private_data, + struct snd_sf_sample *sp, + struct snd_util_memhdr *hdr, + const void __user *_data, long count); +int snd_emu10k1_sample_free(struct snd_emux *private_data, + struct snd_sf_sample *sp, + struct snd_util_memhdr *hdr); +int snd_emu10k1_memhdr_init(struct snd_emux *emu); /* emu10k1_callback.c */ -void snd_emu10k1_ops_setup(snd_emux_t *emu); -int snd_emu10k1_synth_get_voice(emu10k1_t *hw); +void snd_emu10k1_ops_setup(struct snd_emux *emu); +int snd_emu10k1_synth_get_voice(struct snd_emu10k1 *hw); #endif /* __EMU10K1_SYNTH_LOCAL_H */ diff --git a/sound/pci/emu10k1/emu10k1x.c b/sound/pci/emu10k1/emu10k1x.c index 795577716a5..1107c8ec7f7 100644 --- a/sound/pci/emu10k1/emu10k1x.c +++ b/sound/pci/emu10k1/emu10k1x.c @@ -195,30 +195,26 @@ MODULE_PARM_DESC(enable, "Enable the EMU10K1X soundcard."); * playback. */ -typedef struct snd_emu10k1x_voice emu10k1x_voice_t; -typedef struct snd_emu10k1x emu10k1x_t; -typedef struct snd_emu10k1x_pcm emu10k1x_pcm_t; - -struct snd_emu10k1x_voice { - emu10k1x_t *emu; +struct emu10k1x_voice { + struct emu10k1x *emu; int number; int use; - emu10k1x_pcm_t *epcm; + struct emu10k1x_pcm *epcm; }; -struct snd_emu10k1x_pcm { - emu10k1x_t *emu; - snd_pcm_substream_t *substream; - emu10k1x_voice_t *voice; +struct emu10k1x_pcm { + struct emu10k1x *emu; + struct snd_pcm_substream *substream; + struct emu10k1x_voice *voice; unsigned short running; }; -typedef struct { - struct snd_emu10k1x *emu; - snd_rawmidi_t *rmidi; - snd_rawmidi_substream_t *substream_input; - snd_rawmidi_substream_t *substream_output; +struct emu10k1x_midi { + struct emu10k1x *emu; + struct snd_rawmidi *rmidi; + struct snd_rawmidi_substream *substream_input; + struct snd_rawmidi_substream *substream_output; unsigned int midi_mode; spinlock_t input_lock; spinlock_t output_lock; @@ -226,12 +222,12 @@ typedef struct { int tx_enable, rx_enable; int port; int ipr_tx, ipr_rx; - void (*interrupt)(emu10k1x_t *emu, unsigned int status); -} emu10k1x_midi_t; + void (*interrupt)(struct emu10k1x *emu, unsigned int status); +}; // definition of the chip-specific record -struct snd_emu10k1x { - snd_card_t *card; +struct emu10k1x { + struct snd_card *card; struct pci_dev *pci; unsigned long port; @@ -245,20 +241,20 @@ struct snd_emu10k1x { spinlock_t emu_lock; spinlock_t voice_lock; - ac97_t *ac97; - snd_pcm_t *pcm; + struct snd_ac97 *ac97; + struct snd_pcm *pcm; - emu10k1x_voice_t voices[3]; - emu10k1x_voice_t capture_voice; + struct emu10k1x_voice voices[3]; + struct emu10k1x_voice capture_voice; u32 spdif_bits[3]; // SPDIF out setup struct snd_dma_buffer dma_buffer; - emu10k1x_midi_t midi; + struct emu10k1x_midi midi; }; /* hardware definition */ -static snd_pcm_hardware_t snd_emu10k1x_playback_hw = { +static struct snd_pcm_hardware snd_emu10k1x_playback_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -277,7 +273,7 @@ static snd_pcm_hardware_t snd_emu10k1x_playback_hw = { .fifo_size = 0, }; -static snd_pcm_hardware_t snd_emu10k1x_capture_hw = { +static struct snd_pcm_hardware snd_emu10k1x_capture_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -296,7 +292,7 @@ static snd_pcm_hardware_t snd_emu10k1x_capture_hw = { .fifo_size = 0, }; -static unsigned int snd_emu10k1x_ptr_read(emu10k1x_t * emu, +static unsigned int snd_emu10k1x_ptr_read(struct emu10k1x * emu, unsigned int reg, unsigned int chn) { @@ -312,7 +308,7 @@ static unsigned int snd_emu10k1x_ptr_read(emu10k1x_t * emu, return val; } -static void snd_emu10k1x_ptr_write(emu10k1x_t *emu, +static void snd_emu10k1x_ptr_write(struct emu10k1x *emu, unsigned int reg, unsigned int chn, unsigned int data) @@ -328,7 +324,7 @@ static void snd_emu10k1x_ptr_write(emu10k1x_t *emu, spin_unlock_irqrestore(&emu->emu_lock, flags); } -static void snd_emu10k1x_intr_enable(emu10k1x_t *emu, unsigned int intrenb) +static void snd_emu10k1x_intr_enable(struct emu10k1x *emu, unsigned int intrenb) { unsigned long flags; unsigned int enable; @@ -339,7 +335,7 @@ static void snd_emu10k1x_intr_enable(emu10k1x_t *emu, unsigned int intrenb) spin_unlock_irqrestore(&emu->emu_lock, flags); } -static void snd_emu10k1x_intr_disable(emu10k1x_t *emu, unsigned int intrenb) +static void snd_emu10k1x_intr_disable(struct emu10k1x *emu, unsigned int intrenb) { unsigned long flags; unsigned int enable; @@ -350,7 +346,7 @@ static void snd_emu10k1x_intr_disable(emu10k1x_t *emu, unsigned int intrenb) spin_unlock_irqrestore(&emu->emu_lock, flags); } -static void snd_emu10k1x_gpio_write(emu10k1x_t *emu, unsigned int value) +static void snd_emu10k1x_gpio_write(struct emu10k1x *emu, unsigned int value) { unsigned long flags; @@ -359,14 +355,14 @@ static void snd_emu10k1x_gpio_write(emu10k1x_t *emu, unsigned int value) spin_unlock_irqrestore(&emu->emu_lock, flags); } -static void snd_emu10k1x_pcm_free_substream(snd_pcm_runtime_t *runtime) +static void snd_emu10k1x_pcm_free_substream(struct snd_pcm_runtime *runtime) { kfree(runtime->private_data); } -static void snd_emu10k1x_pcm_interrupt(emu10k1x_t *emu, emu10k1x_voice_t *voice) +static void snd_emu10k1x_pcm_interrupt(struct emu10k1x *emu, struct emu10k1x_voice *voice) { - emu10k1x_pcm_t *epcm; + struct emu10k1x_pcm *epcm; if ((epcm = voice->epcm) == NULL) return; @@ -382,11 +378,11 @@ static void snd_emu10k1x_pcm_interrupt(emu10k1x_t *emu, emu10k1x_voice_t *voice) } /* open callback */ -static int snd_emu10k1x_playback_open(snd_pcm_substream_t *substream) +static int snd_emu10k1x_playback_open(struct snd_pcm_substream *substream) { - emu10k1x_t *chip = snd_pcm_substream_chip(substream); - emu10k1x_pcm_t *epcm; - snd_pcm_runtime_t *runtime = substream->runtime; + struct emu10k1x *chip = snd_pcm_substream_chip(substream); + struct emu10k1x_pcm *epcm; + struct snd_pcm_runtime *runtime = substream->runtime; int err; if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0) { @@ -410,17 +406,17 @@ static int snd_emu10k1x_playback_open(snd_pcm_substream_t *substream) } /* close callback */ -static int snd_emu10k1x_playback_close(snd_pcm_substream_t *substream) +static int snd_emu10k1x_playback_close(struct snd_pcm_substream *substream) { return 0; } /* hw_params callback */ -static int snd_emu10k1x_pcm_hw_params(snd_pcm_substream_t *substream, - snd_pcm_hw_params_t * hw_params) +static int snd_emu10k1x_pcm_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1x_pcm_t *epcm = runtime->private_data; + struct snd_pcm_runtime *runtime = substream->runtime; + struct emu10k1x_pcm *epcm = runtime->private_data; if (! epcm->voice) { epcm->voice = &epcm->emu->voices[substream->pcm->device]; @@ -433,10 +429,10 @@ static int snd_emu10k1x_pcm_hw_params(snd_pcm_substream_t *substream, } /* hw_free callback */ -static int snd_emu10k1x_pcm_hw_free(snd_pcm_substream_t *substream) +static int snd_emu10k1x_pcm_hw_free(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1x_pcm_t *epcm; + struct snd_pcm_runtime *runtime = substream->runtime; + struct emu10k1x_pcm *epcm; if (runtime->private_data == NULL) return 0; @@ -453,11 +449,11 @@ static int snd_emu10k1x_pcm_hw_free(snd_pcm_substream_t *substream) } /* prepare callback */ -static int snd_emu10k1x_pcm_prepare(snd_pcm_substream_t *substream) +static int snd_emu10k1x_pcm_prepare(struct snd_pcm_substream *substream) { - emu10k1x_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1x_pcm_t *epcm = runtime->private_data; + struct emu10k1x *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct emu10k1x_pcm *epcm = runtime->private_data; int voice = epcm->voice->number; u32 *table_base = (u32 *)(emu->dma_buffer.area+1024*voice); u32 period_size_bytes = frames_to_bytes(runtime, runtime->period_size); @@ -482,12 +478,12 @@ static int snd_emu10k1x_pcm_prepare(snd_pcm_substream_t *substream) } /* trigger callback */ -static int snd_emu10k1x_pcm_trigger(snd_pcm_substream_t *substream, +static int snd_emu10k1x_pcm_trigger(struct snd_pcm_substream *substream, int cmd) { - emu10k1x_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1x_pcm_t *epcm = runtime->private_data; + struct emu10k1x *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct emu10k1x_pcm *epcm = runtime->private_data; int channel = epcm->voice->number; int result = 0; @@ -516,11 +512,11 @@ static int snd_emu10k1x_pcm_trigger(snd_pcm_substream_t *substream, /* pointer callback */ static snd_pcm_uframes_t -snd_emu10k1x_pcm_pointer(snd_pcm_substream_t *substream) +snd_emu10k1x_pcm_pointer(struct snd_pcm_substream *substream) { - emu10k1x_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1x_pcm_t *epcm = runtime->private_data; + struct emu10k1x *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct emu10k1x_pcm *epcm = runtime->private_data; int channel = epcm->voice->number; snd_pcm_uframes_t ptr = 0, ptr1 = 0, ptr2= 0,ptr3 = 0,ptr4 = 0; @@ -547,7 +543,7 @@ snd_emu10k1x_pcm_pointer(snd_pcm_substream_t *substream) } /* operators */ -static snd_pcm_ops_t snd_emu10k1x_playback_ops = { +static struct snd_pcm_ops snd_emu10k1x_playback_ops = { .open = snd_emu10k1x_playback_open, .close = snd_emu10k1x_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -559,11 +555,11 @@ static snd_pcm_ops_t snd_emu10k1x_playback_ops = { }; /* open_capture callback */ -static int snd_emu10k1x_pcm_open_capture(snd_pcm_substream_t *substream) +static int snd_emu10k1x_pcm_open_capture(struct snd_pcm_substream *substream) { - emu10k1x_t *chip = snd_pcm_substream_chip(substream); - emu10k1x_pcm_t *epcm; - snd_pcm_runtime_t *runtime = substream->runtime; + struct emu10k1x *chip = snd_pcm_substream_chip(substream); + struct emu10k1x_pcm *epcm; + struct snd_pcm_runtime *runtime = substream->runtime; int err; if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0) @@ -587,17 +583,17 @@ static int snd_emu10k1x_pcm_open_capture(snd_pcm_substream_t *substream) } /* close callback */ -static int snd_emu10k1x_pcm_close_capture(snd_pcm_substream_t *substream) +static int snd_emu10k1x_pcm_close_capture(struct snd_pcm_substream *substream) { return 0; } /* hw_params callback */ -static int snd_emu10k1x_pcm_hw_params_capture(snd_pcm_substream_t *substream, - snd_pcm_hw_params_t * hw_params) +static int snd_emu10k1x_pcm_hw_params_capture(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1x_pcm_t *epcm = runtime->private_data; + struct snd_pcm_runtime *runtime = substream->runtime; + struct emu10k1x_pcm *epcm = runtime->private_data; if (! epcm->voice) { if (epcm->emu->capture_voice.use) @@ -612,11 +608,11 @@ static int snd_emu10k1x_pcm_hw_params_capture(snd_pcm_substream_t *substream, } /* hw_free callback */ -static int snd_emu10k1x_pcm_hw_free_capture(snd_pcm_substream_t *substream) +static int snd_emu10k1x_pcm_hw_free_capture(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; - emu10k1x_pcm_t *epcm; + struct emu10k1x_pcm *epcm; if (runtime->private_data == NULL) return 0; @@ -632,10 +628,10 @@ static int snd_emu10k1x_pcm_hw_free_capture(snd_pcm_substream_t *substream) } /* prepare capture callback */ -static int snd_emu10k1x_pcm_prepare_capture(snd_pcm_substream_t *substream) +static int snd_emu10k1x_pcm_prepare_capture(struct snd_pcm_substream *substream) { - emu10k1x_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct emu10k1x *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; snd_emu10k1x_ptr_write(emu, CAPTURE_DMA_ADDR, 0, runtime->dma_addr); snd_emu10k1x_ptr_write(emu, CAPTURE_BUFFER_SIZE, 0, frames_to_bytes(runtime, runtime->buffer_size)<<16); // buffer size in bytes @@ -646,12 +642,12 @@ static int snd_emu10k1x_pcm_prepare_capture(snd_pcm_substream_t *substream) } /* trigger_capture callback */ -static int snd_emu10k1x_pcm_trigger_capture(snd_pcm_substream_t *substream, +static int snd_emu10k1x_pcm_trigger_capture(struct snd_pcm_substream *substream, int cmd) { - emu10k1x_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1x_pcm_t *epcm = runtime->private_data; + struct emu10k1x *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct emu10k1x_pcm *epcm = runtime->private_data; int result = 0; switch (cmd) { @@ -676,11 +672,11 @@ static int snd_emu10k1x_pcm_trigger_capture(snd_pcm_substream_t *substream, /* pointer_capture callback */ static snd_pcm_uframes_t -snd_emu10k1x_pcm_pointer_capture(snd_pcm_substream_t *substream) +snd_emu10k1x_pcm_pointer_capture(struct snd_pcm_substream *substream) { - emu10k1x_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1x_pcm_t *epcm = runtime->private_data; + struct emu10k1x *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct emu10k1x_pcm *epcm = runtime->private_data; snd_pcm_uframes_t ptr; if (!epcm->running) @@ -693,7 +689,7 @@ snd_emu10k1x_pcm_pointer_capture(snd_pcm_substream_t *substream) return ptr; } -static snd_pcm_ops_t snd_emu10k1x_capture_ops = { +static struct snd_pcm_ops snd_emu10k1x_capture_ops = { .open = snd_emu10k1x_pcm_open_capture, .close = snd_emu10k1x_pcm_close_capture, .ioctl = snd_pcm_lib_ioctl, @@ -704,10 +700,10 @@ static snd_pcm_ops_t snd_emu10k1x_capture_ops = { .pointer = snd_emu10k1x_pcm_pointer_capture, }; -static unsigned short snd_emu10k1x_ac97_read(ac97_t *ac97, +static unsigned short snd_emu10k1x_ac97_read(struct snd_ac97 *ac97, unsigned short reg) { - emu10k1x_t *emu = ac97->private_data; + struct emu10k1x *emu = ac97->private_data; unsigned long flags; unsigned short val; @@ -718,10 +714,10 @@ static unsigned short snd_emu10k1x_ac97_read(ac97_t *ac97, return val; } -static void snd_emu10k1x_ac97_write(ac97_t *ac97, +static void snd_emu10k1x_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short val) { - emu10k1x_t *emu = ac97->private_data; + struct emu10k1x *emu = ac97->private_data; unsigned long flags; spin_lock_irqsave(&emu->emu_lock, flags); @@ -730,12 +726,12 @@ static void snd_emu10k1x_ac97_write(ac97_t *ac97, spin_unlock_irqrestore(&emu->emu_lock, flags); } -static int snd_emu10k1x_ac97(emu10k1x_t *chip) +static int snd_emu10k1x_ac97(struct emu10k1x *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_emu10k1x_ac97_write, .read = snd_emu10k1x_ac97_read, }; @@ -750,7 +746,7 @@ static int snd_emu10k1x_ac97(emu10k1x_t *chip) return snd_ac97_mixer(pbus, &ac97, &chip->ac97); } -static int snd_emu10k1x_free(emu10k1x_t *chip) +static int snd_emu10k1x_free(struct emu10k1x *chip) { snd_emu10k1x_ptr_write(chip, TRIGGER_CHANNEL, 0, 0); // disable interrupts @@ -777,9 +773,9 @@ static int snd_emu10k1x_free(emu10k1x_t *chip) return 0; } -static int snd_emu10k1x_dev_free(snd_device_t *device) +static int snd_emu10k1x_dev_free(struct snd_device *device) { - emu10k1x_t *chip = device->device_data; + struct emu10k1x *chip = device->device_data; return snd_emu10k1x_free(chip); } @@ -788,64 +784,56 @@ static irqreturn_t snd_emu10k1x_interrupt(int irq, void *dev_id, { unsigned int status; - emu10k1x_t *chip = dev_id; - emu10k1x_voice_t *pvoice = chip->voices; + struct emu10k1x *chip = dev_id; + struct emu10k1x_voice *pvoice = chip->voices; int i; int mask; status = inl(chip->port + IPR); - if(status) { - // capture interrupt - if(status & (IPR_CAP_0_LOOP | IPR_CAP_0_HALF_LOOP)) { - emu10k1x_voice_t *pvoice = &chip->capture_voice; - if(pvoice->use) - snd_emu10k1x_pcm_interrupt(chip, pvoice); - else - snd_emu10k1x_intr_disable(chip, - INTE_CAP_0_LOOP | - INTE_CAP_0_HALF_LOOP); - } - - mask = IPR_CH_0_LOOP|IPR_CH_0_HALF_LOOP; - for(i = 0; i < 3; i++) { - if(status & mask) { - if(pvoice->use) - snd_emu10k1x_pcm_interrupt(chip, pvoice); - else - snd_emu10k1x_intr_disable(chip, mask); - } - pvoice++; - mask <<= 1; - } + if (! status) + return IRQ_NONE; + + // capture interrupt + if (status & (IPR_CAP_0_LOOP | IPR_CAP_0_HALF_LOOP)) { + struct emu10k1x_voice *pvoice = &chip->capture_voice; + if (pvoice->use) + snd_emu10k1x_pcm_interrupt(chip, pvoice); + else + snd_emu10k1x_intr_disable(chip, + INTE_CAP_0_LOOP | + INTE_CAP_0_HALF_LOOP); + } - if (status & (IPR_MIDITRANSBUFEMPTY|IPR_MIDIRECVBUFEMPTY)) { - if (chip->midi.interrupt) - chip->midi.interrupt(chip, status); - else - snd_emu10k1x_intr_disable(chip, INTE_MIDITXENABLE|INTE_MIDIRXENABLE); + mask = IPR_CH_0_LOOP|IPR_CH_0_HALF_LOOP; + for (i = 0; i < 3; i++) { + if (status & mask) { + if (pvoice->use) + snd_emu10k1x_pcm_interrupt(chip, pvoice); + else + snd_emu10k1x_intr_disable(chip, mask); } + pvoice++; + mask <<= 1; + } - // acknowledge the interrupt if necessary - if(status) - outl(status, chip->port+IPR); - -// snd_printk(KERN_INFO "interrupt %08x\n", status); + if (status & (IPR_MIDITRANSBUFEMPTY|IPR_MIDIRECVBUFEMPTY)) { + if (chip->midi.interrupt) + chip->midi.interrupt(chip, status); + else + snd_emu10k1x_intr_disable(chip, INTE_MIDITXENABLE|INTE_MIDIRXENABLE); } + + // acknowledge the interrupt if necessary + outl(status, chip->port + IPR); + // snd_printk(KERN_INFO "interrupt %08x\n", status); return IRQ_HANDLED; } -static void snd_emu10k1x_pcm_free(snd_pcm_t *pcm) -{ - emu10k1x_t *emu = pcm->private_data; - emu->pcm = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - -static int __devinit snd_emu10k1x_pcm(emu10k1x_t *emu, int device, snd_pcm_t **rpcm) +static int __devinit snd_emu10k1x_pcm(struct emu10k1x *emu, int device, struct snd_pcm **rpcm) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; int capture = 0; @@ -858,7 +846,6 @@ static int __devinit snd_emu10k1x_pcm(emu10k1x_t *emu, int device, snd_pcm_t **r return err; pcm->private_data = emu; - pcm->private_free = snd_emu10k1x_pcm_free; switch(device) { case 0: @@ -896,14 +883,14 @@ static int __devinit snd_emu10k1x_pcm(emu10k1x_t *emu, int device, snd_pcm_t **r return 0; } -static int __devinit snd_emu10k1x_create(snd_card_t *card, +static int __devinit snd_emu10k1x_create(struct snd_card *card, struct pci_dev *pci, - emu10k1x_t **rchip) + struct emu10k1x **rchip) { - emu10k1x_t *chip; + struct emu10k1x *chip; int err; int ch; - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_emu10k1x_dev_free, }; @@ -1017,10 +1004,10 @@ static int __devinit snd_emu10k1x_create(snd_card_t *card, return 0; } -static void snd_emu10k1x_proc_reg_read(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_emu10k1x_proc_reg_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - emu10k1x_t *emu = entry->private_data; + struct emu10k1x *emu = entry->private_data; unsigned long value,value1,value2; unsigned long flags; int i; @@ -1045,10 +1032,10 @@ static void snd_emu10k1x_proc_reg_read(snd_info_entry_t *entry, } } -static void snd_emu10k1x_proc_reg_write(snd_info_entry_t *entry, - snd_info_buffer_t *buffer) +static void snd_emu10k1x_proc_reg_write(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - emu10k1x_t *emu = entry->private_data; + struct emu10k1x *emu = entry->private_data; char line[64]; unsigned int reg, channel_id , val; @@ -1062,9 +1049,9 @@ static void snd_emu10k1x_proc_reg_write(snd_info_entry_t *entry, } } -static int __devinit snd_emu10k1x_proc_init(emu10k1x_t * emu) +static int __devinit snd_emu10k1x_proc_init(struct emu10k1x * emu) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; if(! snd_card_proc_new(emu->card, "emu10k1x_regs", &entry)) { snd_info_set_text_ops(entry, emu, 1024, snd_emu10k1x_proc_reg_read); @@ -1077,7 +1064,7 @@ static int __devinit snd_emu10k1x_proc_init(emu10k1x_t * emu) return 0; } -static int snd_emu10k1x_shared_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_emu10k1x_shared_spdif_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -1086,20 +1073,20 @@ static int snd_emu10k1x_shared_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem return 0; } -static int snd_emu10k1x_shared_spdif_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1x_shared_spdif_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - emu10k1x_t *emu = snd_kcontrol_chip(kcontrol); + struct emu10k1x *emu = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = (snd_emu10k1x_ptr_read(emu, SPDIF_SELECT, 0) == 0x700) ? 0 : 1; return 0; } -static int snd_emu10k1x_shared_spdif_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1x_shared_spdif_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - emu10k1x_t *emu = snd_kcontrol_chip(kcontrol); + struct emu10k1x *emu = snd_kcontrol_chip(kcontrol); unsigned int val; int change = 0; @@ -1119,7 +1106,7 @@ static int snd_emu10k1x_shared_spdif_put(snd_kcontrol_t * kcontrol, return change; } -static snd_kcontrol_new_t snd_emu10k1x_shared_spdif __devinitdata = +static struct snd_kcontrol_new snd_emu10k1x_shared_spdif __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Analog/Digital Output Jack", @@ -1128,17 +1115,17 @@ static snd_kcontrol_new_t snd_emu10k1x_shared_spdif __devinitdata = .put = snd_emu10k1x_shared_spdif_put }; -static int snd_emu10k1x_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_emu10k1x_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_emu10k1x_spdif_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1x_spdif_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - emu10k1x_t *emu = snd_kcontrol_chip(kcontrol); + struct emu10k1x *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; @@ -1148,8 +1135,8 @@ static int snd_emu10k1x_spdif_get(snd_kcontrol_t * kcontrol, return 0; } -static int snd_emu10k1x_spdif_get_mask(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1x_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; @@ -1158,10 +1145,10 @@ static int snd_emu10k1x_spdif_get_mask(snd_kcontrol_t * kcontrol, return 0; } -static int snd_emu10k1x_spdif_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1x_spdif_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - emu10k1x_t *emu = snd_kcontrol_chip(kcontrol); + struct emu10k1x *emu = snd_kcontrol_chip(kcontrol); unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); int change; unsigned int val; @@ -1178,7 +1165,7 @@ static int snd_emu10k1x_spdif_put(snd_kcontrol_t * kcontrol, return change; } -static snd_kcontrol_new_t snd_emu10k1x_spdif_mask_control = +static struct snd_kcontrol_new snd_emu10k1x_spdif_mask_control = { .access = SNDRV_CTL_ELEM_ACCESS_READ, .iface = SNDRV_CTL_ELEM_IFACE_PCM, @@ -1188,7 +1175,7 @@ static snd_kcontrol_new_t snd_emu10k1x_spdif_mask_control = .get = snd_emu10k1x_spdif_get_mask }; -static snd_kcontrol_new_t snd_emu10k1x_spdif_control = +static struct snd_kcontrol_new snd_emu10k1x_spdif_control = { .iface = SNDRV_CTL_ELEM_IFACE_PCM, .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT), @@ -1198,11 +1185,11 @@ static snd_kcontrol_new_t snd_emu10k1x_spdif_control = .put = snd_emu10k1x_spdif_put }; -static int __devinit snd_emu10k1x_mixer(emu10k1x_t *emu) +static int __devinit snd_emu10k1x_mixer(struct emu10k1x *emu) { int err; - snd_kcontrol_t *kctl; - snd_card_t *card = emu->card; + struct snd_kcontrol *kctl; + struct snd_card *card = emu->card; if ((kctl = snd_ctl_new1(&snd_emu10k1x_spdif_mask_control, emu)) == NULL) return -ENOMEM; @@ -1223,12 +1210,12 @@ static int __devinit snd_emu10k1x_mixer(emu10k1x_t *emu) #define EMU10K1X_MIDI_MODE_INPUT (1<<0) #define EMU10K1X_MIDI_MODE_OUTPUT (1<<1) -static inline unsigned char mpu401_read(emu10k1x_t *emu, emu10k1x_midi_t *mpu, int idx) +static inline unsigned char mpu401_read(struct emu10k1x *emu, struct emu10k1x_midi *mpu, int idx) { return (unsigned char)snd_emu10k1x_ptr_read(emu, mpu->port + idx, 0); } -static inline void mpu401_write(emu10k1x_t *emu, emu10k1x_midi_t *mpu, int data, int idx) +static inline void mpu401_write(struct emu10k1x *emu, struct emu10k1x_midi *mpu, int data, int idx) { snd_emu10k1x_ptr_write(emu, mpu->port + idx, 0, data); } @@ -1245,7 +1232,7 @@ static inline void mpu401_write(emu10k1x_t *emu, emu10k1x_midi_t *mpu, int data, #define MPU401_ENTER_UART 0x3f #define MPU401_ACK 0xfe -static void mpu401_clear_rx(emu10k1x_t *emu, emu10k1x_midi_t *mpu) +static void mpu401_clear_rx(struct emu10k1x *emu, struct emu10k1x_midi *mpu) { int timeout = 100000; for (; timeout > 0 && mpu401_input_avail(emu, mpu); timeout--) @@ -1260,7 +1247,8 @@ static void mpu401_clear_rx(emu10k1x_t *emu, emu10k1x_midi_t *mpu) */ -static void do_emu10k1x_midi_interrupt(emu10k1x_t *emu, emu10k1x_midi_t *midi, unsigned int status) +static void do_emu10k1x_midi_interrupt(struct emu10k1x *emu, + struct emu10k1x_midi *midi, unsigned int status) { unsigned char byte; @@ -1293,12 +1281,13 @@ static void do_emu10k1x_midi_interrupt(emu10k1x_t *emu, emu10k1x_midi_t *midi, u spin_unlock(&midi->output_lock); } -static void snd_emu10k1x_midi_interrupt(emu10k1x_t *emu, unsigned int status) +static void snd_emu10k1x_midi_interrupt(struct emu10k1x *emu, unsigned int status) { do_emu10k1x_midi_interrupt(emu, &emu->midi, status); } -static void snd_emu10k1x_midi_cmd(emu10k1x_t * emu, emu10k1x_midi_t *midi, unsigned char cmd, int ack) +static void snd_emu10k1x_midi_cmd(struct emu10k1x * emu, + struct emu10k1x_midi *midi, unsigned char cmd, int ack) { unsigned long flags; int timeout, ok; @@ -1330,10 +1319,10 @@ static void snd_emu10k1x_midi_cmd(emu10k1x_t * emu, emu10k1x_midi_t *midi, unsig mpu401_read_data(emu, midi)); } -static int snd_emu10k1x_midi_input_open(snd_rawmidi_substream_t * substream) +static int snd_emu10k1x_midi_input_open(struct snd_rawmidi_substream *substream) { - emu10k1x_t *emu; - emu10k1x_midi_t *midi = (emu10k1x_midi_t *)substream->rmidi->private_data; + struct emu10k1x *emu; + struct emu10k1x_midi *midi = substream->rmidi->private_data; unsigned long flags; emu = midi->emu; @@ -1351,10 +1340,10 @@ static int snd_emu10k1x_midi_input_open(snd_rawmidi_substream_t * substream) return 0; } -static int snd_emu10k1x_midi_output_open(snd_rawmidi_substream_t * substream) +static int snd_emu10k1x_midi_output_open(struct snd_rawmidi_substream *substream) { - emu10k1x_t *emu; - emu10k1x_midi_t *midi = (emu10k1x_midi_t *)substream->rmidi->private_data; + struct emu10k1x *emu; + struct emu10k1x_midi *midi = substream->rmidi->private_data; unsigned long flags; emu = midi->emu; @@ -1372,10 +1361,10 @@ static int snd_emu10k1x_midi_output_open(snd_rawmidi_substream_t * substream) return 0; } -static int snd_emu10k1x_midi_input_close(snd_rawmidi_substream_t * substream) +static int snd_emu10k1x_midi_input_close(struct snd_rawmidi_substream *substream) { - emu10k1x_t *emu; - emu10k1x_midi_t *midi = (emu10k1x_midi_t *)substream->rmidi->private_data; + struct emu10k1x *emu; + struct emu10k1x_midi *midi = substream->rmidi->private_data; unsigned long flags; emu = midi->emu; @@ -1393,10 +1382,10 @@ static int snd_emu10k1x_midi_input_close(snd_rawmidi_substream_t * substream) return 0; } -static int snd_emu10k1x_midi_output_close(snd_rawmidi_substream_t * substream) +static int snd_emu10k1x_midi_output_close(struct snd_rawmidi_substream *substream) { - emu10k1x_t *emu; - emu10k1x_midi_t *midi = (emu10k1x_midi_t *)substream->rmidi->private_data; + struct emu10k1x *emu; + struct emu10k1x_midi *midi = substream->rmidi->private_data; unsigned long flags; emu = midi->emu; @@ -1414,10 +1403,10 @@ static int snd_emu10k1x_midi_output_close(snd_rawmidi_substream_t * substream) return 0; } -static void snd_emu10k1x_midi_input_trigger(snd_rawmidi_substream_t * substream, int up) +static void snd_emu10k1x_midi_input_trigger(struct snd_rawmidi_substream *substream, int up) { - emu10k1x_t *emu; - emu10k1x_midi_t *midi = (emu10k1x_midi_t *)substream->rmidi->private_data; + struct emu10k1x *emu; + struct emu10k1x_midi *midi = substream->rmidi->private_data; emu = midi->emu; snd_assert(emu, return); @@ -1427,10 +1416,10 @@ static void snd_emu10k1x_midi_input_trigger(snd_rawmidi_substream_t * substream, snd_emu10k1x_intr_disable(emu, midi->rx_enable); } -static void snd_emu10k1x_midi_output_trigger(snd_rawmidi_substream_t * substream, int up) +static void snd_emu10k1x_midi_output_trigger(struct snd_rawmidi_substream *substream, int up) { - emu10k1x_t *emu; - emu10k1x_midi_t *midi = (emu10k1x_midi_t *)substream->rmidi->private_data; + struct emu10k1x *emu; + struct emu10k1x_midi *midi = substream->rmidi->private_data; unsigned long flags; emu = midi->emu; @@ -1467,30 +1456,31 @@ static void snd_emu10k1x_midi_output_trigger(snd_rawmidi_substream_t * substream */ -static snd_rawmidi_ops_t snd_emu10k1x_midi_output = +static struct snd_rawmidi_ops snd_emu10k1x_midi_output = { .open = snd_emu10k1x_midi_output_open, .close = snd_emu10k1x_midi_output_close, .trigger = snd_emu10k1x_midi_output_trigger, }; -static snd_rawmidi_ops_t snd_emu10k1x_midi_input = +static struct snd_rawmidi_ops snd_emu10k1x_midi_input = { .open = snd_emu10k1x_midi_input_open, .close = snd_emu10k1x_midi_input_close, .trigger = snd_emu10k1x_midi_input_trigger, }; -static void snd_emu10k1x_midi_free(snd_rawmidi_t *rmidi) +static void snd_emu10k1x_midi_free(struct snd_rawmidi *rmidi) { - emu10k1x_midi_t *midi = (emu10k1x_midi_t *)rmidi->private_data; + struct emu10k1x_midi *midi = rmidi->private_data; midi->interrupt = NULL; midi->rmidi = NULL; } -static int __devinit emu10k1x_midi_init(emu10k1x_t *emu, emu10k1x_midi_t *midi, int device, char *name) +static int __devinit emu10k1x_midi_init(struct emu10k1x *emu, + struct emu10k1x_midi *midi, int device, char *name) { - snd_rawmidi_t *rmidi; + struct snd_rawmidi *rmidi; int err; if ((err = snd_rawmidi_new(emu->card, name, device, 1, 1, &rmidi)) < 0) @@ -1511,9 +1501,9 @@ static int __devinit emu10k1x_midi_init(emu10k1x_t *emu, emu10k1x_midi_t *midi, return 0; } -static int __devinit snd_emu10k1x_midi(emu10k1x_t *emu) +static int __devinit snd_emu10k1x_midi(struct emu10k1x *emu) { - emu10k1x_midi_t *midi = &emu->midi; + struct emu10k1x_midi *midi = &emu->midi; int err; if ((err = emu10k1x_midi_init(emu, midi, 0, "EMU10K1X MPU-401 (UART)")) < 0) @@ -1532,8 +1522,8 @@ static int __devinit snd_emu10k1x_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { static int dev; - snd_card_t *card; - emu10k1x_t *chip; + struct snd_card *card; + struct emu10k1x *chip; int err; if (dev >= SNDRV_CARDS) diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c index 03e8c167895..1a903390ad6 100644 --- a/sound/pci/emu10k1/emufx.c +++ b/sound/pci/emu10k1/emufx.c @@ -29,6 +29,7 @@ #include <linux/pci.h> #include <linux/delay.h> #include <linux/slab.h> +#include <linux/vmalloc.h> #include <linux/init.h> #include <sound/core.h> #include <sound/emu10k1.h> @@ -309,9 +310,10 @@ static inline void snd_leave_user(mm_segment_t fs) * controls */ -static int snd_emu10k1_gpr_ctl_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_emu10k1_gpr_ctl_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { - snd_emu10k1_fx8010_ctl_t *ctl = (snd_emu10k1_fx8010_ctl_t *)kcontrol->private_value; + struct snd_emu10k1_fx8010_ctl *ctl = + (struct snd_emu10k1_fx8010_ctl *) kcontrol->private_value; if (ctl->min == 0 && ctl->max == 1) uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; @@ -323,10 +325,11 @@ static int snd_emu10k1_gpr_ctl_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_ return 0; } -static int snd_emu10k1_gpr_ctl_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1_gpr_ctl_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); - snd_emu10k1_fx8010_ctl_t *ctl = (snd_emu10k1_fx8010_ctl_t *)kcontrol->private_value; + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1_fx8010_ctl *ctl = + (struct snd_emu10k1_fx8010_ctl *) kcontrol->private_value; unsigned long flags; unsigned int i; @@ -337,10 +340,11 @@ static int snd_emu10k1_gpr_ctl_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value return 0; } -static int snd_emu10k1_gpr_ctl_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1_gpr_ctl_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); - snd_emu10k1_fx8010_ctl_t *ctl = (snd_emu10k1_fx8010_ctl_t *)kcontrol->private_value; + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1_fx8010_ctl *ctl = + (struct snd_emu10k1_fx8010_ctl *) kcontrol->private_value; unsigned long flags; unsigned int nval, val; unsigned int i, j; @@ -393,9 +397,9 @@ static int snd_emu10k1_gpr_ctl_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value * Interrupt handler */ -static void snd_emu10k1_fx8010_interrupt(emu10k1_t *emu) +static void snd_emu10k1_fx8010_interrupt(struct snd_emu10k1 *emu) { - snd_emu10k1_fx8010_irq_t *irq, *nirq; + struct snd_emu10k1_fx8010_irq *irq, *nirq; irq = emu->fx8010.irq_handlers; while (irq) { @@ -409,13 +413,13 @@ static void snd_emu10k1_fx8010_interrupt(emu10k1_t *emu) } } -int snd_emu10k1_fx8010_register_irq_handler(emu10k1_t *emu, - snd_fx8010_irq_handler_t *handler, - unsigned char gpr_running, - void *private_data, - snd_emu10k1_fx8010_irq_t **r_irq) +int snd_emu10k1_fx8010_register_irq_handler(struct snd_emu10k1 *emu, + snd_fx8010_irq_handler_t *handler, + unsigned char gpr_running, + void *private_data, + struct snd_emu10k1_fx8010_irq **r_irq) { - snd_emu10k1_fx8010_irq_t *irq; + struct snd_emu10k1_fx8010_irq *irq; unsigned long flags; irq = kmalloc(sizeof(*irq), GFP_ATOMIC); @@ -440,10 +444,10 @@ int snd_emu10k1_fx8010_register_irq_handler(emu10k1_t *emu, return 0; } -int snd_emu10k1_fx8010_unregister_irq_handler(emu10k1_t *emu, - snd_emu10k1_fx8010_irq_t *irq) +int snd_emu10k1_fx8010_unregister_irq_handler(struct snd_emu10k1 *emu, + struct snd_emu10k1_fx8010_irq *irq) { - snd_emu10k1_fx8010_irq_t *tmp; + struct snd_emu10k1_fx8010_irq *tmp; unsigned long flags; spin_lock_irqsave(&emu->fx8010.irq_lock, flags); @@ -468,7 +472,8 @@ int snd_emu10k1_fx8010_unregister_irq_handler(emu10k1_t *emu, * EMU10K1 effect manager *************************************************************************/ -static void snd_emu10k1_write_op(emu10k1_fx8010_code_t *icode, unsigned int *ptr, +static void snd_emu10k1_write_op(struct snd_emu10k1_fx8010_code *icode, + unsigned int *ptr, u32 op, u32 r, u32 a, u32 x, u32 y) { u_int32_t *code; @@ -483,7 +488,8 @@ static void snd_emu10k1_write_op(emu10k1_fx8010_code_t *icode, unsigned int *ptr #define OP(icode, ptr, op, r, a, x, y) \ snd_emu10k1_write_op(icode, ptr, op, r, a, x, y) -static void snd_emu10k1_audigy_write_op(emu10k1_fx8010_code_t *icode, unsigned int *ptr, +static void snd_emu10k1_audigy_write_op(struct snd_emu10k1_fx8010_code *icode, + unsigned int *ptr, u32 op, u32 r, u32 a, u32 x, u32 y) { u_int32_t *code; @@ -498,19 +504,20 @@ static void snd_emu10k1_audigy_write_op(emu10k1_fx8010_code_t *icode, unsigned i #define A_OP(icode, ptr, op, r, a, x, y) \ snd_emu10k1_audigy_write_op(icode, ptr, op, r, a, x, y) -static void snd_emu10k1_efx_write(emu10k1_t *emu, unsigned int pc, unsigned int data) +static void snd_emu10k1_efx_write(struct snd_emu10k1 *emu, unsigned int pc, unsigned int data) { pc += emu->audigy ? A_MICROCODEBASE : MICROCODEBASE; snd_emu10k1_ptr_write(emu, pc, 0, data); } -unsigned int snd_emu10k1_efx_read(emu10k1_t *emu, unsigned int pc) +unsigned int snd_emu10k1_efx_read(struct snd_emu10k1 *emu, unsigned int pc) { pc += emu->audigy ? A_MICROCODEBASE : MICROCODEBASE; return snd_emu10k1_ptr_read(emu, pc, 0); } -static int snd_emu10k1_gpr_poke(emu10k1_t *emu, emu10k1_fx8010_code_t *icode) +static int snd_emu10k1_gpr_poke(struct snd_emu10k1 *emu, + struct snd_emu10k1_fx8010_code *icode) { int gpr; u32 val; @@ -525,7 +532,8 @@ static int snd_emu10k1_gpr_poke(emu10k1_t *emu, emu10k1_fx8010_code_t *icode) return 0; } -static int snd_emu10k1_gpr_peek(emu10k1_t *emu, emu10k1_fx8010_code_t *icode) +static int snd_emu10k1_gpr_peek(struct snd_emu10k1 *emu, + struct snd_emu10k1_fx8010_code *icode) { int gpr; u32 val; @@ -539,7 +547,8 @@ static int snd_emu10k1_gpr_peek(emu10k1_t *emu, emu10k1_fx8010_code_t *icode) return 0; } -static int snd_emu10k1_tram_poke(emu10k1_t *emu, emu10k1_fx8010_code_t *icode) +static int snd_emu10k1_tram_poke(struct snd_emu10k1 *emu, + struct snd_emu10k1_fx8010_code *icode) { int tram; u32 addr, val; @@ -561,7 +570,8 @@ static int snd_emu10k1_tram_poke(emu10k1_t *emu, emu10k1_fx8010_code_t *icode) return 0; } -static int snd_emu10k1_tram_peek(emu10k1_t *emu, emu10k1_fx8010_code_t *icode) +static int snd_emu10k1_tram_peek(struct snd_emu10k1 *emu, + struct snd_emu10k1_fx8010_code *icode) { int tram; u32 val, addr; @@ -583,7 +593,8 @@ static int snd_emu10k1_tram_peek(emu10k1_t *emu, emu10k1_fx8010_code_t *icode) return 0; } -static int snd_emu10k1_code_poke(emu10k1_t *emu, emu10k1_fx8010_code_t *icode) +static int snd_emu10k1_code_poke(struct snd_emu10k1 *emu, + struct snd_emu10k1_fx8010_code *icode) { u32 pc, lo, hi; @@ -599,7 +610,8 @@ static int snd_emu10k1_code_poke(emu10k1_t *emu, emu10k1_fx8010_code_t *icode) return 0; } -static int snd_emu10k1_code_peek(emu10k1_t *emu, emu10k1_fx8010_code_t *icode) +static int snd_emu10k1_code_peek(struct snd_emu10k1 *emu, + struct snd_emu10k1_fx8010_code *icode) { u32 pc; @@ -614,10 +626,11 @@ static int snd_emu10k1_code_peek(emu10k1_t *emu, emu10k1_fx8010_code_t *icode) return 0; } -static snd_emu10k1_fx8010_ctl_t *snd_emu10k1_look_for_ctl(emu10k1_t *emu, snd_ctl_elem_id_t *id) +static struct snd_emu10k1_fx8010_ctl * +snd_emu10k1_look_for_ctl(struct snd_emu10k1 *emu, struct snd_ctl_elem_id *id) { - snd_emu10k1_fx8010_ctl_t *ctl; - snd_kcontrol_t *kcontrol; + struct snd_emu10k1_fx8010_ctl *ctl; + struct snd_kcontrol *kcontrol; struct list_head *list; list_for_each(list, &emu->fx8010.gpr_ctl) { @@ -631,13 +644,14 @@ static snd_emu10k1_fx8010_ctl_t *snd_emu10k1_look_for_ctl(emu10k1_t *emu, snd_ct return NULL; } -static int snd_emu10k1_verify_controls(emu10k1_t *emu, emu10k1_fx8010_code_t *icode) +static int snd_emu10k1_verify_controls(struct snd_emu10k1 *emu, + struct snd_emu10k1_fx8010_code *icode) { unsigned int i; - snd_ctl_elem_id_t __user *_id; - snd_ctl_elem_id_t id; - emu10k1_fx8010_control_gpr_t __user *_gctl; - emu10k1_fx8010_control_gpr_t *gctl; + struct snd_ctl_elem_id __user *_id; + struct snd_ctl_elem_id id; + struct snd_emu10k1_fx8010_control_gpr __user *_gctl; + struct snd_emu10k1_fx8010_control_gpr *gctl; int err; for (i = 0, _id = icode->gpr_del_controls; @@ -685,28 +699,29 @@ static int snd_emu10k1_verify_controls(emu10k1_t *emu, emu10k1_fx8010_code_t *ic return err; } -static void snd_emu10k1_ctl_private_free(snd_kcontrol_t *kctl) +static void snd_emu10k1_ctl_private_free(struct snd_kcontrol *kctl) { - snd_emu10k1_fx8010_ctl_t *ctl; + struct snd_emu10k1_fx8010_ctl *ctl; - ctl = (snd_emu10k1_fx8010_ctl_t *)kctl->private_value; + ctl = (struct snd_emu10k1_fx8010_ctl *) kctl->private_value; kctl->private_value = 0; list_del(&ctl->list); kfree(ctl); } -static int snd_emu10k1_add_controls(emu10k1_t *emu, emu10k1_fx8010_code_t *icode) +static int snd_emu10k1_add_controls(struct snd_emu10k1 *emu, + struct snd_emu10k1_fx8010_code *icode) { unsigned int i, j; - emu10k1_fx8010_control_gpr_t __user *_gctl; - emu10k1_fx8010_control_gpr_t *gctl; - snd_emu10k1_fx8010_ctl_t *ctl, *nctl; - snd_kcontrol_new_t knew; - snd_kcontrol_t *kctl; - snd_ctl_elem_value_t *val; + struct snd_emu10k1_fx8010_control_gpr __user *_gctl; + struct snd_emu10k1_fx8010_control_gpr *gctl; + struct snd_emu10k1_fx8010_ctl *ctl, *nctl; + struct snd_kcontrol_new knew; + struct snd_kcontrol *kctl; + struct snd_ctl_elem_value *val; int err = 0; - val = (snd_ctl_elem_value_t *)kmalloc(sizeof(*val), GFP_KERNEL); + val = kmalloc(sizeof(*val), GFP_KERNEL); gctl = kmalloc(sizeof(*gctl), GFP_KERNEL); nctl = kmalloc(sizeof(*nctl), GFP_KERNEL); if (!val || !gctl || !nctl) { @@ -751,7 +766,7 @@ static int snd_emu10k1_add_controls(emu10k1_t *emu, emu10k1_fx8010_code_t *icode nctl->max = gctl->max; nctl->translation = gctl->translation; if (ctl == NULL) { - ctl = (snd_emu10k1_fx8010_ctl_t *)kmalloc(sizeof(*ctl), GFP_KERNEL); + ctl = kmalloc(sizeof(*ctl), GFP_KERNEL); if (ctl == NULL) { err = -ENOMEM; goto __error; @@ -782,13 +797,14 @@ static int snd_emu10k1_add_controls(emu10k1_t *emu, emu10k1_fx8010_code_t *icode return err; } -static int snd_emu10k1_del_controls(emu10k1_t *emu, emu10k1_fx8010_code_t *icode) +static int snd_emu10k1_del_controls(struct snd_emu10k1 *emu, + struct snd_emu10k1_fx8010_code *icode) { unsigned int i; - snd_ctl_elem_id_t id; - snd_ctl_elem_id_t __user *_id; - snd_emu10k1_fx8010_ctl_t *ctl; - snd_card_t *card = emu->card; + struct snd_ctl_elem_id id; + struct snd_ctl_elem_id __user *_id; + struct snd_emu10k1_fx8010_ctl *ctl; + struct snd_card *card = emu->card; for (i = 0, _id = icode->gpr_del_controls; i < icode->gpr_del_control_count; i++, _id++) { @@ -803,14 +819,15 @@ static int snd_emu10k1_del_controls(emu10k1_t *emu, emu10k1_fx8010_code_t *icode return 0; } -static int snd_emu10k1_list_controls(emu10k1_t *emu, emu10k1_fx8010_code_t *icode) +static int snd_emu10k1_list_controls(struct snd_emu10k1 *emu, + struct snd_emu10k1_fx8010_code *icode) { unsigned int i = 0, j; unsigned int total = 0; - emu10k1_fx8010_control_gpr_t *gctl; - emu10k1_fx8010_control_gpr_t __user *_gctl; - snd_emu10k1_fx8010_ctl_t *ctl; - snd_ctl_elem_id_t *id; + struct snd_emu10k1_fx8010_control_gpr *gctl; + struct snd_emu10k1_fx8010_control_gpr __user *_gctl; + struct snd_emu10k1_fx8010_ctl *ctl; + struct snd_ctl_elem_id *id; struct list_head *list; gctl = kmalloc(sizeof(*gctl), GFP_KERNEL); @@ -851,7 +868,8 @@ static int snd_emu10k1_list_controls(emu10k1_t *emu, emu10k1_fx8010_code_t *icod return 0; } -static int snd_emu10k1_icode_poke(emu10k1_t *emu, emu10k1_fx8010_code_t *icode) +static int snd_emu10k1_icode_poke(struct snd_emu10k1 *emu, + struct snd_emu10k1_fx8010_code *icode) { int err = 0; @@ -882,7 +900,8 @@ static int snd_emu10k1_icode_poke(emu10k1_t *emu, emu10k1_fx8010_code_t *icode) return err; } -static int snd_emu10k1_icode_peek(emu10k1_t *emu, emu10k1_fx8010_code_t *icode) +static int snd_emu10k1_icode_peek(struct snd_emu10k1 *emu, + struct snd_emu10k1_fx8010_code *icode) { int err; @@ -900,11 +919,12 @@ static int snd_emu10k1_icode_peek(emu10k1_t *emu, emu10k1_fx8010_code_t *icode) return err; } -static int snd_emu10k1_ipcm_poke(emu10k1_t *emu, emu10k1_fx8010_pcm_t *ipcm) +static int snd_emu10k1_ipcm_poke(struct snd_emu10k1 *emu, + struct snd_emu10k1_fx8010_pcm_rec *ipcm) { unsigned int i; int err = 0; - snd_emu10k1_fx8010_pcm_t *pcm; + struct snd_emu10k1_fx8010_pcm *pcm; if (ipcm->substream >= EMU10K1_FX8010_PCM_COUNT) return -EINVAL; @@ -945,11 +965,12 @@ static int snd_emu10k1_ipcm_poke(emu10k1_t *emu, emu10k1_fx8010_pcm_t *ipcm) return err; } -static int snd_emu10k1_ipcm_peek(emu10k1_t *emu, emu10k1_fx8010_pcm_t *ipcm) +static int snd_emu10k1_ipcm_peek(struct snd_emu10k1 *emu, + struct snd_emu10k1_fx8010_pcm_rec *ipcm) { unsigned int i; int err = 0; - snd_emu10k1_fx8010_pcm_t *pcm; + struct snd_emu10k1_fx8010_pcm *pcm; if (ipcm->substream >= EMU10K1_FX8010_PCM_COUNT) return -EINVAL; @@ -979,7 +1000,9 @@ static int snd_emu10k1_ipcm_peek(emu10k1_t *emu, emu10k1_fx8010_pcm_t *ipcm) #define SND_EMU10K1_PLAYBACK_CHANNELS 8 #define SND_EMU10K1_CAPTURE_CHANNELS 4 -static void __devinit snd_emu10k1_init_mono_control(emu10k1_fx8010_control_gpr_t *ctl, const char *name, int gpr, int defval) +static void __devinit +snd_emu10k1_init_mono_control(struct snd_emu10k1_fx8010_control_gpr *ctl, + const char *name, int gpr, int defval) { ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; strcpy(ctl->id.name, name); @@ -990,7 +1013,9 @@ static void __devinit snd_emu10k1_init_mono_control(emu10k1_fx8010_control_gpr_t ctl->translation = EMU10K1_GPR_TRANSLATION_TABLE100; } -static void __devinit snd_emu10k1_init_stereo_control(emu10k1_fx8010_control_gpr_t *ctl, const char *name, int gpr, int defval) +static void __devinit +snd_emu10k1_init_stereo_control(struct snd_emu10k1_fx8010_control_gpr *ctl, + const char *name, int gpr, int defval) { ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; strcpy(ctl->id.name, name); @@ -1002,7 +1027,9 @@ static void __devinit snd_emu10k1_init_stereo_control(emu10k1_fx8010_control_gpr ctl->translation = EMU10K1_GPR_TRANSLATION_TABLE100; } -static void __devinit snd_emu10k1_init_mono_onoff_control(emu10k1_fx8010_control_gpr_t *ctl, const char *name, int gpr, int defval) +static void __devinit +snd_emu10k1_init_mono_onoff_control(struct snd_emu10k1_fx8010_control_gpr *ctl, + const char *name, int gpr, int defval) { ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; strcpy(ctl->id.name, name); @@ -1013,7 +1040,9 @@ static void __devinit snd_emu10k1_init_mono_onoff_control(emu10k1_fx8010_control ctl->translation = EMU10K1_GPR_TRANSLATION_ONOFF; } -static void __devinit snd_emu10k1_init_stereo_onoff_control(emu10k1_fx8010_control_gpr_t *ctl, const char *name, int gpr, int defval) +static void __devinit +snd_emu10k1_init_stereo_onoff_control(struct snd_emu10k1_fx8010_control_gpr *ctl, + const char *name, int gpr, int defval) { ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; strcpy(ctl->id.name, name); @@ -1030,7 +1059,7 @@ static void __devinit snd_emu10k1_init_stereo_onoff_control(emu10k1_fx8010_contr * initial DSP configuration for Audigy */ -static int __devinit _snd_emu10k1_audigy_init_efx(emu10k1_t *emu) +static int __devinit _snd_emu10k1_audigy_init_efx(struct snd_emu10k1 *emu) { int err, i, z, gpr, nctl; const int playback = 10; @@ -1038,17 +1067,17 @@ static int __devinit _snd_emu10k1_audigy_init_efx(emu10k1_t *emu) const int stereo_mix = capture + 2; const int tmp = 0x88; u32 ptr; - emu10k1_fx8010_code_t *icode = NULL; - emu10k1_fx8010_control_gpr_t *controls = NULL, *ctl; + struct snd_emu10k1_fx8010_code *icode = NULL; + struct snd_emu10k1_fx8010_control_gpr *controls = NULL, *ctl; u32 *gpr_map; mm_segment_t seg; - spin_lock_init(&emu->fx8010.irq_lock); - INIT_LIST_HEAD(&emu->fx8010.gpr_ctl); - if ((icode = kzalloc(sizeof(*icode), GFP_KERNEL)) == NULL || - (icode->gpr_map = (u_int32_t __user *)kcalloc(512 + 256 + 256 + 2 * 1024, sizeof(u_int32_t), GFP_KERNEL)) == NULL || - (controls = kcalloc(SND_EMU10K1_GPR_CONTROLS, sizeof(*controls), GFP_KERNEL)) == NULL) { + (icode->gpr_map = (u_int32_t __user *) + kcalloc(512 + 256 + 256 + 2 * 1024, sizeof(u_int32_t), + GFP_KERNEL)) == NULL || + (controls = kcalloc(SND_EMU10K1_GPR_CONTROLS, + sizeof(*controls), GFP_KERNEL)) == NULL) { err = -ENOMEM; goto __err; } @@ -1074,6 +1103,14 @@ static int __devinit _snd_emu10k1_audigy_init_efx(emu10k1_t *emu) /* stop FX processor */ snd_emu10k1_ptr_write(emu, A_DBG, 0, (emu->fx8010.dbg = 0) | A_DBG_SINGLE_STEP); +#if 0 + /* FIX: jcd test */ + for (z = 0; z < 80; z=z+2) { + A_OP(icode, &ptr, iACC3, A_EXTOUT(z), A_FXBUS(FXBUS_PCM_LEFT_FRONT), A_C_00000000, A_C_00000000); /* left */ + A_OP(icode, &ptr, iACC3, A_EXTOUT(z+1), A_FXBUS(FXBUS_PCM_RIGHT_FRONT), A_C_00000000, A_C_00000000); /* right */ + } +#endif /* jcd test */ +#if 1 /* PCM front Playback Volume (independent from stereo mix) */ A_OP(icode, &ptr, iMAC0, A_GPR(playback), A_C_00000000, A_GPR(gpr), A_FXBUS(FXBUS_PCM_LEFT_FRONT)); A_OP(icode, &ptr, iMAC0, A_GPR(playback+1), A_C_00000000, A_GPR(gpr+1), A_FXBUS(FXBUS_PCM_RIGHT_FRONT)); @@ -1419,6 +1456,7 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input)) A_OP(icode, &ptr, iACC3, A_FXBUS2(z), A_C_00000000, A_C_00000000, A_EXTIN(z)); } +#endif /* JCD test */ /* * ok, set up done.. */ @@ -1434,7 +1472,7 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input)) seg = snd_enter_user(); icode->gpr_add_control_count = nctl; - icode->gpr_add_controls = (emu10k1_fx8010_control_gpr_t __user *)controls; + icode->gpr_add_controls = (struct snd_emu10k1_fx8010_control_gpr __user *)controls; err = snd_emu10k1_icode_poke(emu, icode); snd_leave_user(seg); @@ -1454,14 +1492,14 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input)) /* when volume = max, then copy only to avoid volume modification */ /* with iMAC0 (negative values) */ -static void __devinit _volume(emu10k1_fx8010_code_t *icode, u32 *ptr, u32 dst, u32 src, u32 vol) +static void __devinit _volume(struct snd_emu10k1_fx8010_code *icode, u32 *ptr, u32 dst, u32 src, u32 vol) { OP(icode, ptr, iMAC0, dst, C_00000000, src, vol); OP(icode, ptr, iANDXOR, C_00000000, vol, C_ffffffff, C_7fffffff); OP(icode, ptr, iSKIP, GPR_COND, GPR_COND, CC_REG_NONZERO, C_00000001); OP(icode, ptr, iACC3, dst, src, C_00000000, C_00000000); } -static void __devinit _volume_add(emu10k1_fx8010_code_t *icode, u32 *ptr, u32 dst, u32 src, u32 vol) +static void __devinit _volume_add(struct snd_emu10k1_fx8010_code *icode, u32 *ptr, u32 dst, u32 src, u32 vol) { OP(icode, ptr, iANDXOR, C_00000000, vol, C_ffffffff, C_7fffffff); OP(icode, ptr, iSKIP, GPR_COND, GPR_COND, CC_REG_NONZERO, C_00000002); @@ -1469,7 +1507,7 @@ static void __devinit _volume_add(emu10k1_fx8010_code_t *icode, u32 *ptr, u32 ds OP(icode, ptr, iSKIP, C_00000000, C_7fffffff, C_7fffffff, C_00000001); OP(icode, ptr, iMAC0, dst, dst, src, vol); } -static void __devinit _volume_out(emu10k1_fx8010_code_t *icode, u32 *ptr, u32 dst, u32 src, u32 vol) +static void __devinit _volume_out(struct snd_emu10k1_fx8010_code *icode, u32 *ptr, u32 dst, u32 src, u32 vol) { OP(icode, ptr, iANDXOR, C_00000000, vol, C_ffffffff, C_7fffffff); OP(icode, ptr, iSKIP, GPR_COND, GPR_COND, CC_REG_NONZERO, C_00000002); @@ -1500,23 +1538,24 @@ static void __devinit _volume_out(emu10k1_fx8010_code_t *icode, u32 *ptr, u32 ds _SWITCH_NEG(icode, ptr, GPR(dst), GPR(src)) -static int __devinit _snd_emu10k1_init_efx(emu10k1_t *emu) +static int __devinit _snd_emu10k1_init_efx(struct snd_emu10k1 *emu) { int err, i, z, gpr, tmp, playback, capture; u32 ptr; - emu10k1_fx8010_code_t *icode; - emu10k1_fx8010_pcm_t *ipcm = NULL; - emu10k1_fx8010_control_gpr_t *controls = NULL, *ctl; + struct snd_emu10k1_fx8010_code *icode; + struct snd_emu10k1_fx8010_pcm_rec *ipcm = NULL; + struct snd_emu10k1_fx8010_control_gpr *controls = NULL, *ctl; u32 *gpr_map; mm_segment_t seg; - spin_lock_init(&emu->fx8010.irq_lock); - INIT_LIST_HEAD(&emu->fx8010.gpr_ctl); - if ((icode = kzalloc(sizeof(*icode), GFP_KERNEL)) == NULL) return -ENOMEM; - if ((icode->gpr_map = (u_int32_t __user *)kcalloc(256 + 160 + 160 + 2 * 512, sizeof(u_int32_t), GFP_KERNEL)) == NULL || - (controls = kcalloc(SND_EMU10K1_GPR_CONTROLS, sizeof(emu10k1_fx8010_control_gpr_t), GFP_KERNEL)) == NULL || + if ((icode->gpr_map = (u_int32_t __user *) + kcalloc(256 + 160 + 160 + 2 * 512, sizeof(u_int32_t), + GFP_KERNEL)) == NULL || + (controls = kcalloc(SND_EMU10K1_GPR_CONTROLS, + sizeof(struct snd_emu10k1_fx8010_control_gpr), + GFP_KERNEL)) == NULL || (ipcm = kzalloc(sizeof(*ipcm), GFP_KERNEL)) == NULL) { err = -ENOMEM; goto __err; @@ -2050,7 +2089,7 @@ static int __devinit _snd_emu10k1_init_efx(emu10k1_t *emu) goto __err; seg = snd_enter_user(); icode->gpr_add_control_count = i; - icode->gpr_add_controls = (emu10k1_fx8010_control_gpr_t __user *)controls; + icode->gpr_add_controls = (struct snd_emu10k1_fx8010_control_gpr __user *)controls; err = snd_emu10k1_icode_poke(emu, icode); snd_leave_user(seg); if (err >= 0) @@ -2065,15 +2104,17 @@ static int __devinit _snd_emu10k1_init_efx(emu10k1_t *emu) return err; } -int __devinit snd_emu10k1_init_efx(emu10k1_t *emu) +int __devinit snd_emu10k1_init_efx(struct snd_emu10k1 *emu) { + spin_lock_init(&emu->fx8010.irq_lock); + INIT_LIST_HEAD(&emu->fx8010.gpr_ctl); if (emu->audigy) return _snd_emu10k1_audigy_init_efx(emu); else return _snd_emu10k1_init_efx(emu); } -void snd_emu10k1_free_efx(emu10k1_t *emu) +void snd_emu10k1_free_efx(struct snd_emu10k1 *emu) { /* stop processor */ if (emu->audigy) @@ -2083,7 +2124,7 @@ void snd_emu10k1_free_efx(emu10k1_t *emu) } #if 0 // FIXME: who use them? -int snd_emu10k1_fx8010_tone_control_activate(emu10k1_t *emu, int output) +int snd_emu10k1_fx8010_tone_control_activate(struct snd_emu10k1 *emu, int output) { if (output < 0 || output >= 6) return -EINVAL; @@ -2091,7 +2132,7 @@ int snd_emu10k1_fx8010_tone_control_activate(emu10k1_t *emu, int output) return 0; } -int snd_emu10k1_fx8010_tone_control_deactivate(emu10k1_t *emu, int output) +int snd_emu10k1_fx8010_tone_control_deactivate(struct snd_emu10k1 *emu, int output) { if (output < 0 || output >= 6) return -EINVAL; @@ -2100,7 +2141,7 @@ int snd_emu10k1_fx8010_tone_control_deactivate(emu10k1_t *emu, int output) } #endif -int snd_emu10k1_fx8010_tram_setup(emu10k1_t *emu, u32 size) +int snd_emu10k1_fx8010_tram_setup(struct snd_emu10k1 *emu, u32 size) { u8 size_reg = 0; @@ -2136,13 +2177,13 @@ int snd_emu10k1_fx8010_tram_setup(emu10k1_t *emu, u32 size) snd_emu10k1_ptr_write(emu, TCBS, 0, size_reg); spin_lock_irq(&emu->emu_lock); outl(inl(emu->port + HCFG) & ~HCFG_LOCKTANKCACHE_MASK, emu->port + HCFG); - spin_unlock_irq(&emu->emu_lock); + spin_unlock_irq(&emu->emu_lock); } return 0; } -static int snd_emu10k1_fx8010_open(snd_hwdep_t * hw, struct file *file) +static int snd_emu10k1_fx8010_open(struct snd_hwdep * hw, struct file *file) { return 0; } @@ -2155,7 +2196,8 @@ static void copy_string(char *dst, char *src, char *null, int idx) strcpy(dst, src); } -static int snd_emu10k1_fx8010_info(emu10k1_t *emu, emu10k1_fx8010_info_t *info) +static int snd_emu10k1_fx8010_info(struct snd_emu10k1 *emu, + struct snd_emu10k1_fx8010_info *info) { char **fxbus, **extin, **extout; unsigned short fxbus_mask, extin_mask, extout_mask; @@ -2181,19 +2223,19 @@ static int snd_emu10k1_fx8010_info(emu10k1_t *emu, emu10k1_fx8010_info_t *info) return 0; } -static int snd_emu10k1_fx8010_ioctl(snd_hwdep_t * hw, struct file *file, unsigned int cmd, unsigned long arg) +static int snd_emu10k1_fx8010_ioctl(struct snd_hwdep * hw, struct file *file, unsigned int cmd, unsigned long arg) { - emu10k1_t *emu = hw->private_data; - emu10k1_fx8010_info_t *info; - emu10k1_fx8010_code_t *icode; - emu10k1_fx8010_pcm_t *ipcm; + struct snd_emu10k1 *emu = hw->private_data; + struct snd_emu10k1_fx8010_info *info; + struct snd_emu10k1_fx8010_code *icode; + struct snd_emu10k1_fx8010_pcm_rec *ipcm; unsigned int addr; void __user *argp = (void __user *)arg; int res; switch (cmd) { case SNDRV_EMU10K1_IOCTL_INFO: - info = (emu10k1_fx8010_info_t *)kmalloc(sizeof(*info), GFP_KERNEL); + info = kmalloc(sizeof(*info), GFP_KERNEL); if (!info) return -ENOMEM; if ((res = snd_emu10k1_fx8010_info(emu, info)) < 0) { @@ -2209,7 +2251,7 @@ static int snd_emu10k1_fx8010_ioctl(snd_hwdep_t * hw, struct file *file, unsigne case SNDRV_EMU10K1_IOCTL_CODE_POKE: if (!capable(CAP_SYS_ADMIN)) return -EPERM; - icode = (emu10k1_fx8010_code_t *)kmalloc(sizeof(*icode), GFP_KERNEL); + icode = kmalloc(sizeof(*icode), GFP_KERNEL); if (icode == NULL) return -ENOMEM; if (copy_from_user(icode, argp, sizeof(*icode))) { @@ -2220,7 +2262,7 @@ static int snd_emu10k1_fx8010_ioctl(snd_hwdep_t * hw, struct file *file, unsigne kfree(icode); return res; case SNDRV_EMU10K1_IOCTL_CODE_PEEK: - icode = (emu10k1_fx8010_code_t *)kmalloc(sizeof(*icode), GFP_KERNEL); + icode = kmalloc(sizeof(*icode), GFP_KERNEL); if (icode == NULL) return -ENOMEM; if (copy_from_user(icode, argp, sizeof(*icode))) { @@ -2235,7 +2277,7 @@ static int snd_emu10k1_fx8010_ioctl(snd_hwdep_t * hw, struct file *file, unsigne kfree(icode); return res; case SNDRV_EMU10K1_IOCTL_PCM_POKE: - ipcm = (emu10k1_fx8010_pcm_t *)kmalloc(sizeof(*ipcm), GFP_KERNEL); + ipcm = kmalloc(sizeof(*ipcm), GFP_KERNEL); if (ipcm == NULL) return -ENOMEM; if (copy_from_user(ipcm, argp, sizeof(*ipcm))) { @@ -2327,14 +2369,14 @@ static int snd_emu10k1_fx8010_ioctl(snd_hwdep_t * hw, struct file *file, unsigne return -ENOTTY; } -static int snd_emu10k1_fx8010_release(snd_hwdep_t * hw, struct file *file) +static int snd_emu10k1_fx8010_release(struct snd_hwdep * hw, struct file *file) { return 0; } -int __devinit snd_emu10k1_fx8010_new(emu10k1_t *emu, int device, snd_hwdep_t ** rhwdep) +int __devinit snd_emu10k1_fx8010_new(struct snd_emu10k1 *emu, int device, struct snd_hwdep ** rhwdep) { - snd_hwdep_t *hw; + struct snd_hwdep *hw; int err; if (rhwdep) @@ -2351,3 +2393,114 @@ int __devinit snd_emu10k1_fx8010_new(emu10k1_t *emu, int device, snd_hwdep_t ** *rhwdep = hw; return 0; } + +#ifdef CONFIG_PM +int __devinit snd_emu10k1_efx_alloc_pm_buffer(struct snd_emu10k1 *emu) +{ + int len; + + len = emu->audigy ? 0x200 : 0x100; + emu->saved_gpr = kmalloc(len * 4, GFP_KERNEL); + if (! emu->saved_gpr) + return -ENOMEM; + len = emu->audigy ? 0x100 : 0xa0; + emu->tram_val_saved = kmalloc(len * 4, GFP_KERNEL); + emu->tram_addr_saved = kmalloc(len * 4, GFP_KERNEL); + if (! emu->tram_val_saved || ! emu->tram_addr_saved) + return -ENOMEM; + len = emu->audigy ? 2 * 1024 : 2 * 512; + emu->saved_icode = vmalloc(len * 4); + if (! emu->saved_icode) + return -ENOMEM; + return 0; +} + +void snd_emu10k1_efx_free_pm_buffer(struct snd_emu10k1 *emu) +{ + kfree(emu->saved_gpr); + kfree(emu->tram_val_saved); + kfree(emu->tram_addr_saved); + vfree(emu->saved_icode); +} + +/* + * save/restore GPR, TRAM and codes + */ +void snd_emu10k1_efx_suspend(struct snd_emu10k1 *emu) +{ + int i, len; + + len = emu->audigy ? 0x200 : 0x100; + for (i = 0; i < len; i++) + emu->saved_gpr[i] = snd_emu10k1_ptr_read(emu, emu->gpr_base + i, 0); + + len = emu->audigy ? 0x100 : 0xa0; + for (i = 0; i < len; i++) { + emu->tram_val_saved[i] = snd_emu10k1_ptr_read(emu, TANKMEMDATAREGBASE + i, 0); + emu->tram_addr_saved[i] = snd_emu10k1_ptr_read(emu, TANKMEMADDRREGBASE + i, 0); + if (emu->audigy) { + emu->tram_addr_saved[i] >>= 12; + emu->tram_addr_saved[i] |= + snd_emu10k1_ptr_read(emu, A_TANKMEMCTLREGBASE + i, 0) << 20; + } + } + + len = emu->audigy ? 2 * 1024 : 2 * 512; + for (i = 0; i < len; i++) + emu->saved_icode[i] = snd_emu10k1_efx_read(emu, i); +} + +void snd_emu10k1_efx_resume(struct snd_emu10k1 *emu) +{ + int i, len; + + /* set up TRAM */ + if (emu->fx8010.etram_pages.bytes > 0) { + unsigned size, size_reg = 0; + size = emu->fx8010.etram_pages.bytes / 2; + size = (size - 1) >> 13; + while (size) { + size >>= 1; + size_reg++; + } + outl(HCFG_LOCKTANKCACHE_MASK | inl(emu->port + HCFG), emu->port + HCFG); + snd_emu10k1_ptr_write(emu, TCB, 0, emu->fx8010.etram_pages.addr); + snd_emu10k1_ptr_write(emu, TCBS, 0, size_reg); + outl(inl(emu->port + HCFG) & ~HCFG_LOCKTANKCACHE_MASK, emu->port + HCFG); + } + + if (emu->audigy) + snd_emu10k1_ptr_write(emu, A_DBG, 0, emu->fx8010.dbg | A_DBG_SINGLE_STEP); + else + snd_emu10k1_ptr_write(emu, DBG, 0, emu->fx8010.dbg | EMU10K1_DBG_SINGLE_STEP); + + len = emu->audigy ? 0x200 : 0x100; + for (i = 0; i < len; i++) + snd_emu10k1_ptr_write(emu, emu->gpr_base + i, 0, emu->saved_gpr[i]); + + len = emu->audigy ? 0x100 : 0xa0; + for (i = 0; i < len; i++) { + snd_emu10k1_ptr_write(emu, TANKMEMDATAREGBASE + i, 0, + emu->tram_val_saved[i]); + if (! emu->audigy) + snd_emu10k1_ptr_write(emu, TANKMEMADDRREGBASE + i, 0, + emu->tram_addr_saved[i]); + else { + snd_emu10k1_ptr_write(emu, TANKMEMADDRREGBASE + i, 0, + emu->tram_addr_saved[i] << 12); + snd_emu10k1_ptr_write(emu, TANKMEMADDRREGBASE + i, 0, + emu->tram_addr_saved[i] >> 20); + } + } + + len = emu->audigy ? 2 * 1024 : 2 * 512; + for (i = 0; i < len; i++) + snd_emu10k1_efx_write(emu, i, emu->saved_icode[i]); + + /* start FX processor when the DSP code is updated */ + if (emu->audigy) + snd_emu10k1_ptr_write(emu, A_DBG, 0, emu->fx8010.dbg); + else + snd_emu10k1_ptr_write(emu, DBG, 0, emu->fx8010.dbg); +} +#endif diff --git a/sound/pci/emu10k1/emumixer.c b/sound/pci/emu10k1/emumixer.c index 7cc831ccd0c..2e86a901a0a 100644 --- a/sound/pci/emu10k1/emumixer.c +++ b/sound/pci/emu10k1/emumixer.c @@ -35,17 +35,17 @@ #define AC97_ID_STAC9758 0x83847658 -static int snd_emu10k1_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_emu10k1_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_emu10k1_spdif_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1_spdif_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); unsigned long flags; @@ -58,8 +58,8 @@ static int snd_emu10k1_spdif_get(snd_kcontrol_t * kcontrol, return 0; } -static int snd_emu10k1_spdif_get_mask(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1_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; @@ -69,7 +69,7 @@ static int snd_emu10k1_spdif_get_mask(snd_kcontrol_t * kcontrol, } #if 0 -static int snd_audigy_spdif_output_rate_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_audigy_spdif_output_rate_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[] = {"44100", "48000", "96000"}; @@ -82,10 +82,10 @@ static int snd_audigy_spdif_output_rate_info(snd_kcontrol_t *kcontrol, snd_ctl_e return 0; } -static int snd_audigy_spdif_output_rate_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_audigy_spdif_output_rate_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); unsigned int tmp; unsigned long flags; @@ -109,10 +109,10 @@ static int snd_audigy_spdif_output_rate_get(snd_kcontrol_t * kcontrol, return 0; } -static int snd_audigy_spdif_output_rate_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_audigy_spdif_output_rate_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); int change; unsigned int reg, val, tmp; unsigned long flags; @@ -143,7 +143,7 @@ static int snd_audigy_spdif_output_rate_put(snd_kcontrol_t * kcontrol, return change; } -static snd_kcontrol_new_t snd_audigy_spdif_output_rate = +static struct snd_kcontrol_new snd_audigy_spdif_output_rate = { .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, .iface = SNDRV_CTL_ELEM_IFACE_MIXER, @@ -155,10 +155,10 @@ static snd_kcontrol_new_t snd_audigy_spdif_output_rate = }; #endif -static int snd_emu10k1_spdif_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1_spdif_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); int change; unsigned int val; @@ -178,7 +178,7 @@ static int snd_emu10k1_spdif_put(snd_kcontrol_t * kcontrol, return change; } -static snd_kcontrol_new_t snd_emu10k1_spdif_mask_control = +static struct snd_kcontrol_new snd_emu10k1_spdif_mask_control = { .access = SNDRV_CTL_ELEM_ACCESS_READ, .iface = SNDRV_CTL_ELEM_IFACE_PCM, @@ -188,7 +188,7 @@ static snd_kcontrol_new_t snd_emu10k1_spdif_mask_control = .get = snd_emu10k1_spdif_get_mask }; -static snd_kcontrol_new_t snd_emu10k1_spdif_control = +static struct snd_kcontrol_new snd_emu10k1_spdif_control = { .iface = SNDRV_CTL_ELEM_IFACE_PCM, .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT), @@ -199,7 +199,7 @@ static snd_kcontrol_new_t snd_emu10k1_spdif_control = }; -static void update_emu10k1_fxrt(emu10k1_t *emu, int voice, unsigned char *route) +static void update_emu10k1_fxrt(struct snd_emu10k1 *emu, int voice, unsigned char *route) { if (emu->audigy) { snd_emu10k1_ptr_write(emu, A_FXRT1, voice, @@ -212,7 +212,7 @@ static void update_emu10k1_fxrt(emu10k1_t *emu, int voice, unsigned char *route) } } -static void update_emu10k1_send_volume(emu10k1_t *emu, int voice, unsigned char *volume) +static void update_emu10k1_send_volume(struct snd_emu10k1 *emu, int voice, unsigned char *volume) { snd_emu10k1_ptr_write(emu, PTRX_FXSENDAMOUNT_A, voice, volume[0]); snd_emu10k1_ptr_write(emu, PTRX_FXSENDAMOUNT_B, voice, volume[1]); @@ -229,9 +229,9 @@ static void update_emu10k1_send_volume(emu10k1_t *emu, int voice, unsigned char /* PCM stream controls */ -static int snd_emu10k1_send_routing_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_emu10k1_send_routing_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = emu->audigy ? 3*8 : 3*4; uinfo->value.integer.min = 0; @@ -239,12 +239,13 @@ static int snd_emu10k1_send_routing_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_ return 0; } -static int snd_emu10k1_send_routing_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1_send_routing_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { unsigned long flags; - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); - emu10k1_pcm_mixer_t *mix = &emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1_pcm_mixer *mix = + &emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; int voice, idx; int num_efx = emu->audigy ? 8 : 4; int mask = emu->audigy ? 0x3f : 0x0f; @@ -258,12 +259,13 @@ static int snd_emu10k1_send_routing_get(snd_kcontrol_t * kcontrol, return 0; } -static int snd_emu10k1_send_routing_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1_send_routing_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { unsigned long flags; - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); - emu10k1_pcm_mixer_t *mix = &emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1_pcm_mixer *mix = + &emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; int change = 0, voice, idx, val; int num_efx = emu->audigy ? 8 : 4; int mask = emu->audigy ? 0x3f : 0x0f; @@ -292,7 +294,7 @@ static int snd_emu10k1_send_routing_put(snd_kcontrol_t * kcontrol, return change; } -static snd_kcontrol_new_t snd_emu10k1_send_routing_control = +static struct snd_kcontrol_new snd_emu10k1_send_routing_control = { .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_INACTIVE, .iface = SNDRV_CTL_ELEM_IFACE_PCM, @@ -303,9 +305,9 @@ static snd_kcontrol_new_t snd_emu10k1_send_routing_control = .put = snd_emu10k1_send_routing_put }; -static int snd_emu10k1_send_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_emu10k1_send_volume_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = emu->audigy ? 3*8 : 3*4; uinfo->value.integer.min = 0; @@ -313,12 +315,13 @@ static int snd_emu10k1_send_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_i return 0; } -static int snd_emu10k1_send_volume_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1_send_volume_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { unsigned long flags; - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); - emu10k1_pcm_mixer_t *mix = &emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1_pcm_mixer *mix = + &emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; int idx; int num_efx = emu->audigy ? 8 : 4; @@ -329,12 +332,13 @@ static int snd_emu10k1_send_volume_get(snd_kcontrol_t * kcontrol, return 0; } -static int snd_emu10k1_send_volume_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1_send_volume_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { unsigned long flags; - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); - emu10k1_pcm_mixer_t *mix = &emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1_pcm_mixer *mix = + &emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; int change = 0, idx, val; int num_efx = emu->audigy ? 8 : 4; @@ -361,7 +365,7 @@ static int snd_emu10k1_send_volume_put(snd_kcontrol_t * kcontrol, return change; } -static snd_kcontrol_new_t snd_emu10k1_send_volume_control = +static struct snd_kcontrol_new snd_emu10k1_send_volume_control = { .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_INACTIVE, .iface = SNDRV_CTL_ELEM_IFACE_PCM, @@ -372,7 +376,7 @@ static snd_kcontrol_new_t snd_emu10k1_send_volume_control = .put = snd_emu10k1_send_volume_put }; -static int snd_emu10k1_attn_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_emu10k1_attn_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 3; @@ -381,11 +385,12 @@ static int snd_emu10k1_attn_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * return 0; } -static int snd_emu10k1_attn_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1_attn_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); - emu10k1_pcm_mixer_t *mix = &emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1_pcm_mixer *mix = + &emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; unsigned long flags; int idx; @@ -396,12 +401,13 @@ static int snd_emu10k1_attn_get(snd_kcontrol_t * kcontrol, return 0; } -static int snd_emu10k1_attn_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1_attn_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { unsigned long flags; - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); - emu10k1_pcm_mixer_t *mix = &emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1_pcm_mixer *mix = + &emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; int change = 0, idx, val; spin_lock_irqsave(&emu->reg_lock, flags); @@ -424,7 +430,7 @@ static int snd_emu10k1_attn_put(snd_kcontrol_t * kcontrol, return change; } -static snd_kcontrol_new_t snd_emu10k1_attn_control = +static struct snd_kcontrol_new snd_emu10k1_attn_control = { .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_INACTIVE, .iface = SNDRV_CTL_ELEM_IFACE_PCM, @@ -437,9 +443,9 @@ static snd_kcontrol_new_t snd_emu10k1_attn_control = /* Mutichannel PCM stream controls */ -static int snd_emu10k1_efx_send_routing_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_emu10k1_efx_send_routing_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = emu->audigy ? 8 : 4; uinfo->value.integer.min = 0; @@ -447,12 +453,13 @@ static int snd_emu10k1_efx_send_routing_info(snd_kcontrol_t *kcontrol, snd_ctl_e return 0; } -static int snd_emu10k1_efx_send_routing_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1_efx_send_routing_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { unsigned long flags; - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); - emu10k1_pcm_mixer_t *mix = &emu->efx_pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1_pcm_mixer *mix = + &emu->efx_pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; int idx; int num_efx = emu->audigy ? 8 : 4; int mask = emu->audigy ? 0x3f : 0x0f; @@ -465,13 +472,13 @@ static int snd_emu10k1_efx_send_routing_get(snd_kcontrol_t * kcontrol, return 0; } -static int snd_emu10k1_efx_send_routing_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1_efx_send_routing_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { unsigned long flags; - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); int ch = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); - emu10k1_pcm_mixer_t *mix = &emu->efx_pcm_mixer[ch]; + struct snd_emu10k1_pcm_mixer *mix = &emu->efx_pcm_mixer[ch]; int change = 0, idx, val; int num_efx = emu->audigy ? 8 : 4; int mask = emu->audigy ? 0x3f : 0x0f; @@ -495,7 +502,7 @@ static int snd_emu10k1_efx_send_routing_put(snd_kcontrol_t * kcontrol, return change; } -static snd_kcontrol_new_t snd_emu10k1_efx_send_routing_control = +static struct snd_kcontrol_new snd_emu10k1_efx_send_routing_control = { .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_INACTIVE, .iface = SNDRV_CTL_ELEM_IFACE_PCM, @@ -506,9 +513,9 @@ static snd_kcontrol_new_t snd_emu10k1_efx_send_routing_control = .put = snd_emu10k1_efx_send_routing_put }; -static int snd_emu10k1_efx_send_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_emu10k1_efx_send_volume_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = emu->audigy ? 8 : 4; uinfo->value.integer.min = 0; @@ -516,12 +523,13 @@ static int snd_emu10k1_efx_send_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_el return 0; } -static int snd_emu10k1_efx_send_volume_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1_efx_send_volume_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { unsigned long flags; - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); - emu10k1_pcm_mixer_t *mix = &emu->efx_pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1_pcm_mixer *mix = + &emu->efx_pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; int idx; int num_efx = emu->audigy ? 8 : 4; @@ -532,13 +540,13 @@ static int snd_emu10k1_efx_send_volume_get(snd_kcontrol_t * kcontrol, return 0; } -static int snd_emu10k1_efx_send_volume_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1_efx_send_volume_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { unsigned long flags; - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); int ch = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); - emu10k1_pcm_mixer_t *mix = &emu->efx_pcm_mixer[ch]; + struct snd_emu10k1_pcm_mixer *mix = &emu->efx_pcm_mixer[ch]; int change = 0, idx, val; int num_efx = emu->audigy ? 8 : 4; @@ -561,7 +569,7 @@ static int snd_emu10k1_efx_send_volume_put(snd_kcontrol_t * kcontrol, } -static snd_kcontrol_new_t snd_emu10k1_efx_send_volume_control = +static struct snd_kcontrol_new snd_emu10k1_efx_send_volume_control = { .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_INACTIVE, .iface = SNDRV_CTL_ELEM_IFACE_PCM, @@ -572,7 +580,7 @@ static snd_kcontrol_new_t snd_emu10k1_efx_send_volume_control = .put = snd_emu10k1_efx_send_volume_put }; -static int snd_emu10k1_efx_attn_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_emu10k1_efx_attn_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 1; @@ -581,11 +589,12 @@ static int snd_emu10k1_efx_attn_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info return 0; } -static int snd_emu10k1_efx_attn_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1_efx_attn_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); - emu10k1_pcm_mixer_t *mix = &emu->efx_pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1_pcm_mixer *mix = + &emu->efx_pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; unsigned long flags; spin_lock_irqsave(&emu->reg_lock, flags); @@ -594,13 +603,13 @@ static int snd_emu10k1_efx_attn_get(snd_kcontrol_t * kcontrol, return 0; } -static int snd_emu10k1_efx_attn_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1_efx_attn_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { unsigned long flags; - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); int ch = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); - emu10k1_pcm_mixer_t *mix = &emu->efx_pcm_mixer[ch]; + struct snd_emu10k1_pcm_mixer *mix = &emu->efx_pcm_mixer[ch]; int change = 0, val; spin_lock_irqsave(&emu->reg_lock, flags); @@ -618,7 +627,7 @@ static int snd_emu10k1_efx_attn_put(snd_kcontrol_t * kcontrol, return change; } -static snd_kcontrol_new_t snd_emu10k1_efx_attn_control = +static struct snd_kcontrol_new snd_emu10k1_efx_attn_control = { .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_INACTIVE, .iface = SNDRV_CTL_ELEM_IFACE_PCM, @@ -629,7 +638,7 @@ static snd_kcontrol_new_t snd_emu10k1_efx_attn_control = .put = snd_emu10k1_efx_attn_put }; -static int snd_emu10k1_shared_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_emu10k1_shared_spdif_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -638,10 +647,10 @@ static int snd_emu10k1_shared_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_ return 0; } -static int snd_emu10k1_shared_spdif_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1_shared_spdif_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); if (emu->audigy) ucontrol->value.integer.value[0] = inl(emu->port + A_IOCFG) & A_IOCFG_GPOUT0 ? 1 : 0; @@ -650,11 +659,11 @@ static int snd_emu10k1_shared_spdif_get(snd_kcontrol_t * kcontrol, return 0; } -static int snd_emu10k1_shared_spdif_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1_shared_spdif_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { unsigned long flags; - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); unsigned int reg, val; int change = 0; @@ -681,7 +690,7 @@ static int snd_emu10k1_shared_spdif_put(snd_kcontrol_t * kcontrol, return change; } -static snd_kcontrol_new_t snd_emu10k1_shared_spdif __devinitdata = +static struct snd_kcontrol_new snd_emu10k1_shared_spdif __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "SB Live Analog/Digital Output Jack", @@ -690,7 +699,7 @@ static snd_kcontrol_new_t snd_emu10k1_shared_spdif __devinitdata = .put = snd_emu10k1_shared_spdif_put }; -static snd_kcontrol_new_t snd_audigy_shared_spdif __devinitdata = +static struct snd_kcontrol_new snd_audigy_shared_spdif __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Audigy Analog/Digital Output Jack", @@ -701,35 +710,35 @@ static snd_kcontrol_new_t snd_audigy_shared_spdif __devinitdata = /* */ -static void snd_emu10k1_mixer_free_ac97(ac97_t *ac97) +static void snd_emu10k1_mixer_free_ac97(struct snd_ac97 *ac97) { - emu10k1_t *emu = ac97->private_data; + struct snd_emu10k1 *emu = ac97->private_data; emu->ac97 = NULL; } /* */ -static int remove_ctl(snd_card_t *card, const char *name) +static int 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 *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)); strcpy(sid.name, name); sid.iface = SNDRV_CTL_ELEM_IFACE_MIXER; return snd_ctl_find_id(card, &sid); } -static int rename_ctl(snd_card_t *card, const char *src, const char *dst) +static int 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; @@ -737,12 +746,12 @@ static int rename_ctl(snd_card_t *card, const char *src, const char *dst) return -ENOENT; } -int __devinit snd_emu10k1_mixer(emu10k1_t *emu, +int __devinit snd_emu10k1_mixer(struct snd_emu10k1 *emu, int pcm_device, int multi_device) { int err, pcm; - snd_kcontrol_t *kctl; - snd_card_t *card = emu->card; + struct snd_kcontrol *kctl; + struct snd_card *card = emu->card; char **c; static char *emu10k1_remove_ctls[] = { /* no AC97 mono, surround, center/lfe */ @@ -795,9 +804,9 @@ int __devinit snd_emu10k1_mixer(emu10k1_t *emu, }; if (emu->card_capabilities->ac97_chip) { - ac97_bus_t *pbus; - ac97_template_t ac97; - static ac97_bus_ops_t ops = { + struct snd_ac97_bus *pbus; + struct snd_ac97_template ac97; + static struct snd_ac97_bus_ops ops = { .write = snd_emu10k1_ac97_write, .read = snd_emu10k1_ac97_read, }; @@ -857,7 +866,17 @@ int __devinit snd_emu10k1_mixer(emu10k1_t *emu, c = emu10k1_rename_ctls; for (; *c; c += 2) rename_ctl(card, c[0], c[1]); - + if (emu->card_capabilities->subsystem == 0x20071102) { /* Audigy 4 Pro */ + rename_ctl(card, "Line2 Capture Volume", "Line1/Mic Capture Volume"); + rename_ctl(card, "Analog Mix Capture Volume", "Line2 Capture Volume"); + rename_ctl(card, "Aux2 Capture Volume", "Line3 Capture Volume"); + rename_ctl(card, "Mic Capture Volume", "Unknown1 Capture Volume"); + remove_ctl(card, "Headphone Playback Switch"); + remove_ctl(card, "Headphone Playback Volume"); + remove_ctl(card, "3D Control - Center"); + remove_ctl(card, "3D Control - Depth"); + remove_ctl(card, "3D Control - Switch"); + } if ((kctl = emu->ctl_send_routing = snd_ctl_new1(&snd_emu10k1_send_routing_control, emu)) == NULL) return -ENOMEM; kctl->id.device = pcm_device; @@ -894,7 +913,7 @@ int __devinit snd_emu10k1_mixer(emu10k1_t *emu, /* initialize the routing and volume table for each pcm playback stream */ for (pcm = 0; pcm < 32; pcm++) { - emu10k1_pcm_mixer_t *mix; + struct snd_emu10k1_pcm_mixer *mix; int v; mix = &emu->pcm_mixer[pcm]; @@ -914,7 +933,7 @@ int __devinit snd_emu10k1_mixer(emu10k1_t *emu, /* initialize the routing and volume table for the multichannel playback stream */ for (pcm = 0; pcm < NUM_EFX_PLAYBACK; pcm++) { - emu10k1_pcm_mixer_t *mix; + struct snd_emu10k1_pcm_mixer *mix; int v; mix = &emu->efx_pcm_mixer[pcm]; @@ -950,7 +969,9 @@ int __devinit snd_emu10k1_mixer(emu10k1_t *emu, return err; } - if (emu->audigy) { + if ( emu->card_capabilities->emu1212m) { + ; /* Disable the snd_audigy_spdif_shared_spdif */ + } else if (emu->audigy) { if ((kctl = snd_ctl_new1(&snd_audigy_shared_spdif, emu)) == NULL) return -ENOMEM; if ((err = snd_ctl_add(card, kctl))) diff --git a/sound/pci/emu10k1/emumpu401.c b/sound/pci/emu10k1/emumpu401.c index eb57458a966..d96eb455103 100644 --- a/sound/pci/emu10k1/emumpu401.c +++ b/sound/pci/emu10k1/emumpu401.c @@ -28,7 +28,8 @@ #define EMU10K1_MIDI_MODE_INPUT (1<<0) #define EMU10K1_MIDI_MODE_OUTPUT (1<<1) -static inline unsigned char mpu401_read(emu10k1_t *emu, emu10k1_midi_t *mpu, int idx) +static inline unsigned char mpu401_read(struct snd_emu10k1 *emu, + struct snd_emu10k1_midi *mpu, int idx) { if (emu->audigy) return (unsigned char)snd_emu10k1_ptr_read(emu, mpu->port + idx, 0); @@ -36,7 +37,8 @@ static inline unsigned char mpu401_read(emu10k1_t *emu, emu10k1_midi_t *mpu, int return inb(emu->port + mpu->port + idx); } -static inline void mpu401_write(emu10k1_t *emu, emu10k1_midi_t *mpu, int data, int idx) +static inline void mpu401_write(struct snd_emu10k1 *emu, + struct snd_emu10k1_midi *mpu, int data, int idx) { if (emu->audigy) snd_emu10k1_ptr_write(emu, mpu->port + idx, 0, data); @@ -56,7 +58,7 @@ static inline void mpu401_write(emu10k1_t *emu, emu10k1_midi_t *mpu, int data, i #define MPU401_ENTER_UART 0x3f #define MPU401_ACK 0xfe -static void mpu401_clear_rx(emu10k1_t *emu, emu10k1_midi_t *mpu) +static void mpu401_clear_rx(struct snd_emu10k1 *emu, struct snd_emu10k1_midi *mpu) { int timeout = 100000; for (; timeout > 0 && mpu401_input_avail(emu, mpu); timeout--) @@ -71,7 +73,7 @@ static void mpu401_clear_rx(emu10k1_t *emu, emu10k1_midi_t *mpu) */ -static void do_emu10k1_midi_interrupt(emu10k1_t *emu, emu10k1_midi_t *midi, unsigned int status) +static void do_emu10k1_midi_interrupt(struct snd_emu10k1 *emu, struct snd_emu10k1_midi *midi, unsigned int status) { unsigned char byte; @@ -104,17 +106,17 @@ static void do_emu10k1_midi_interrupt(emu10k1_t *emu, emu10k1_midi_t *midi, unsi spin_unlock(&midi->output_lock); } -static void snd_emu10k1_midi_interrupt(emu10k1_t *emu, unsigned int status) +static void snd_emu10k1_midi_interrupt(struct snd_emu10k1 *emu, unsigned int status) { do_emu10k1_midi_interrupt(emu, &emu->midi, status); } -static void snd_emu10k1_midi_interrupt2(emu10k1_t *emu, unsigned int status) +static void snd_emu10k1_midi_interrupt2(struct snd_emu10k1 *emu, unsigned int status) { do_emu10k1_midi_interrupt(emu, &emu->midi2, status); } -static void snd_emu10k1_midi_cmd(emu10k1_t * emu, emu10k1_midi_t *midi, unsigned char cmd, int ack) +static void snd_emu10k1_midi_cmd(struct snd_emu10k1 * emu, struct snd_emu10k1_midi *midi, unsigned char cmd, int ack) { unsigned long flags; int timeout, ok; @@ -146,10 +148,10 @@ static void snd_emu10k1_midi_cmd(emu10k1_t * emu, emu10k1_midi_t *midi, unsigned mpu401_read_data(emu, midi)); } -static int snd_emu10k1_midi_input_open(snd_rawmidi_substream_t * substream) +static int snd_emu10k1_midi_input_open(struct snd_rawmidi_substream *substream) { - emu10k1_t *emu; - emu10k1_midi_t *midi = (emu10k1_midi_t *)substream->rmidi->private_data; + struct snd_emu10k1 *emu; + struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; unsigned long flags; emu = midi->emu; @@ -167,10 +169,10 @@ static int snd_emu10k1_midi_input_open(snd_rawmidi_substream_t * substream) return 0; } -static int snd_emu10k1_midi_output_open(snd_rawmidi_substream_t * substream) +static int snd_emu10k1_midi_output_open(struct snd_rawmidi_substream *substream) { - emu10k1_t *emu; - emu10k1_midi_t *midi = (emu10k1_midi_t *)substream->rmidi->private_data; + struct snd_emu10k1 *emu; + struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; unsigned long flags; emu = midi->emu; @@ -188,10 +190,10 @@ static int snd_emu10k1_midi_output_open(snd_rawmidi_substream_t * substream) return 0; } -static int snd_emu10k1_midi_input_close(snd_rawmidi_substream_t * substream) +static int snd_emu10k1_midi_input_close(struct snd_rawmidi_substream *substream) { - emu10k1_t *emu; - emu10k1_midi_t *midi = (emu10k1_midi_t *)substream->rmidi->private_data; + struct snd_emu10k1 *emu; + struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; unsigned long flags; emu = midi->emu; @@ -209,10 +211,10 @@ static int snd_emu10k1_midi_input_close(snd_rawmidi_substream_t * substream) return 0; } -static int snd_emu10k1_midi_output_close(snd_rawmidi_substream_t * substream) +static int snd_emu10k1_midi_output_close(struct snd_rawmidi_substream *substream) { - emu10k1_t *emu; - emu10k1_midi_t *midi = (emu10k1_midi_t *)substream->rmidi->private_data; + struct snd_emu10k1 *emu; + struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; unsigned long flags; emu = midi->emu; @@ -230,10 +232,10 @@ static int snd_emu10k1_midi_output_close(snd_rawmidi_substream_t * substream) return 0; } -static void snd_emu10k1_midi_input_trigger(snd_rawmidi_substream_t * substream, int up) +static void snd_emu10k1_midi_input_trigger(struct snd_rawmidi_substream *substream, int up) { - emu10k1_t *emu; - emu10k1_midi_t *midi = (emu10k1_midi_t *)substream->rmidi->private_data; + struct snd_emu10k1 *emu; + struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; emu = midi->emu; snd_assert(emu, return); @@ -243,10 +245,10 @@ static void snd_emu10k1_midi_input_trigger(snd_rawmidi_substream_t * substream, snd_emu10k1_intr_disable(emu, midi->rx_enable); } -static void snd_emu10k1_midi_output_trigger(snd_rawmidi_substream_t * substream, int up) +static void snd_emu10k1_midi_output_trigger(struct snd_rawmidi_substream *substream, int up) { - emu10k1_t *emu; - emu10k1_midi_t *midi = (emu10k1_midi_t *)substream->rmidi->private_data; + struct snd_emu10k1 *emu; + struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; unsigned long flags; emu = midi->emu; @@ -283,30 +285,30 @@ static void snd_emu10k1_midi_output_trigger(snd_rawmidi_substream_t * substream, */ -static snd_rawmidi_ops_t snd_emu10k1_midi_output = +static struct snd_rawmidi_ops snd_emu10k1_midi_output = { .open = snd_emu10k1_midi_output_open, .close = snd_emu10k1_midi_output_close, .trigger = snd_emu10k1_midi_output_trigger, }; -static snd_rawmidi_ops_t snd_emu10k1_midi_input = +static struct snd_rawmidi_ops snd_emu10k1_midi_input = { .open = snd_emu10k1_midi_input_open, .close = snd_emu10k1_midi_input_close, .trigger = snd_emu10k1_midi_input_trigger, }; -static void snd_emu10k1_midi_free(snd_rawmidi_t *rmidi) +static void snd_emu10k1_midi_free(struct snd_rawmidi *rmidi) { - emu10k1_midi_t *midi = (emu10k1_midi_t *)rmidi->private_data; + struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)rmidi->private_data; midi->interrupt = NULL; midi->rmidi = NULL; } -static int __devinit emu10k1_midi_init(emu10k1_t *emu, emu10k1_midi_t *midi, int device, char *name) +static int __devinit emu10k1_midi_init(struct snd_emu10k1 *emu, struct snd_emu10k1_midi *midi, int device, char *name) { - snd_rawmidi_t *rmidi; + struct snd_rawmidi *rmidi; int err; if ((err = snd_rawmidi_new(emu->card, name, device, 1, 1, &rmidi)) < 0) @@ -327,9 +329,9 @@ static int __devinit emu10k1_midi_init(emu10k1_t *emu, emu10k1_midi_t *midi, int return 0; } -int __devinit snd_emu10k1_midi(emu10k1_t *emu) +int __devinit snd_emu10k1_midi(struct snd_emu10k1 *emu) { - emu10k1_midi_t *midi = &emu->midi; + struct snd_emu10k1_midi *midi = &emu->midi; int err; if ((err = emu10k1_midi_init(emu, midi, 0, "EMU10K1 MPU-401 (UART)")) < 0) @@ -344,9 +346,9 @@ int __devinit snd_emu10k1_midi(emu10k1_t *emu) return 0; } -int __devinit snd_emu10k1_audigy_midi(emu10k1_t *emu) +int __devinit snd_emu10k1_audigy_midi(struct snd_emu10k1 *emu) { - emu10k1_midi_t *midi; + struct snd_emu10k1_midi *midi; int err; midi = &emu->midi; diff --git a/sound/pci/emu10k1/emupcm.c b/sound/pci/emu10k1/emupcm.c index bf7490dae09..717e92ec9e0 100644 --- a/sound/pci/emu10k1/emupcm.c +++ b/sound/pci/emu10k1/emupcm.c @@ -35,9 +35,10 @@ #include <sound/core.h> #include <sound/emu10k1.h> -static void snd_emu10k1_pcm_interrupt(emu10k1_t *emu, emu10k1_voice_t *voice) +static void snd_emu10k1_pcm_interrupt(struct snd_emu10k1 *emu, + struct snd_emu10k1_voice *voice) { - emu10k1_pcm_t *epcm; + struct snd_emu10k1_pcm *epcm; if ((epcm = voice->epcm) == NULL) return; @@ -52,7 +53,8 @@ static void snd_emu10k1_pcm_interrupt(emu10k1_t *emu, emu10k1_voice_t *voice) snd_pcm_period_elapsed(epcm->substream); } -static void snd_emu10k1_pcm_ac97adc_interrupt(emu10k1_t *emu, unsigned int status) +static void snd_emu10k1_pcm_ac97adc_interrupt(struct snd_emu10k1 *emu, + unsigned int status) { #if 0 if (status & IPR_ADCBUFHALFFULL) { @@ -63,7 +65,8 @@ static void snd_emu10k1_pcm_ac97adc_interrupt(emu10k1_t *emu, unsigned int statu snd_pcm_period_elapsed(emu->pcm_capture_substream); } -static void snd_emu10k1_pcm_ac97mic_interrupt(emu10k1_t *emu, unsigned int status) +static void snd_emu10k1_pcm_ac97mic_interrupt(struct snd_emu10k1 *emu, + unsigned int status) { #if 0 if (status & IPR_MICBUFHALFFULL) { @@ -74,7 +77,8 @@ static void snd_emu10k1_pcm_ac97mic_interrupt(emu10k1_t *emu, unsigned int statu snd_pcm_period_elapsed(emu->pcm_capture_mic_substream); } -static void snd_emu10k1_pcm_efx_interrupt(emu10k1_t *emu, unsigned int status) +static void snd_emu10k1_pcm_efx_interrupt(struct snd_emu10k1 *emu, + unsigned int status) { #if 0 if (status & IPR_EFXBUFHALFFULL) { @@ -85,11 +89,11 @@ static void snd_emu10k1_pcm_efx_interrupt(emu10k1_t *emu, unsigned int status) snd_pcm_period_elapsed(emu->pcm_capture_efx_substream); } -static snd_pcm_uframes_t snd_emu10k1_efx_playback_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_emu10k1_efx_playback_pointer(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1_pcm_t *epcm = runtime->private_data; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_emu10k1_pcm *epcm = runtime->private_data; unsigned int ptr; if (!epcm->running) @@ -102,7 +106,7 @@ static snd_pcm_uframes_t snd_emu10k1_efx_playback_pointer(snd_pcm_substream_t * return ptr; } -static int snd_emu10k1_pcm_channel_alloc(emu10k1_pcm_t * epcm, int voices) +static int snd_emu10k1_pcm_channel_alloc(struct snd_emu10k1_pcm * epcm, int voices) { int err, i; @@ -167,7 +171,7 @@ static unsigned int capture_period_sizes[31] = { 384*128,448*128,512*128 }; -static snd_pcm_hw_constraint_list_t hw_constraints_capture_period_sizes = { +static struct snd_pcm_hw_constraint_list hw_constraints_capture_period_sizes = { .count = 31, .list = capture_period_sizes, .mask = 0 @@ -177,7 +181,7 @@ static unsigned int capture_rates[8] = { 8000, 11025, 16000, 22050, 24000, 32000, 44100, 48000 }; -static snd_pcm_hw_constraint_list_t hw_constraints_capture_rates = { +static struct snd_pcm_hw_constraint_list hw_constraints_capture_rates = { .count = 8, .list = capture_rates, .mask = 0 @@ -271,15 +275,15 @@ static inline int emu10k1_ccis(int stereo, int w_16) } } -static void snd_emu10k1_pcm_init_voice(emu10k1_t *emu, +static void snd_emu10k1_pcm_init_voice(struct snd_emu10k1 *emu, int master, int extra, - emu10k1_voice_t *evoice, + struct snd_emu10k1_voice *evoice, unsigned int start_addr, unsigned int end_addr, - emu10k1_pcm_mixer_t *mix) + struct snd_emu10k1_pcm_mixer *mix) { - snd_pcm_substream_t *substream = evoice->epcm->substream; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_substream *substream = evoice->epcm->substream; + struct snd_pcm_runtime *runtime = substream->runtime; unsigned int silent_page, tmp; int voice, stereo, w_16; unsigned char attn, send_amount[8]; @@ -392,12 +396,12 @@ static void snd_emu10k1_pcm_init_voice(emu10k1_t *emu, spin_unlock_irqrestore(&emu->reg_lock, flags); } -static int snd_emu10k1_playback_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_emu10k1_playback_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1_pcm_t *epcm = runtime->private_data; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_emu10k1_pcm *epcm = runtime->private_data; int err; if ((err = snd_emu10k1_pcm_channel_alloc(epcm, params_channels(hw_params))) < 0) @@ -405,24 +409,26 @@ static int snd_emu10k1_playback_hw_params(snd_pcm_substream_t * substream, if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) return err; if (err > 0) { /* change */ - snd_util_memblk_t *memblk; + int mapped; if (epcm->memblk != NULL) snd_emu10k1_free_pages(emu, epcm->memblk); - memblk = snd_emu10k1_alloc_pages(emu, substream); - if ((epcm->memblk = memblk) == NULL || ((emu10k1_memblk_t *)memblk)->mapped_page < 0) { - epcm->start_addr = 0; + epcm->memblk = snd_emu10k1_alloc_pages(emu, substream); + epcm->start_addr = 0; + if (! epcm->memblk) return -ENOMEM; - } - epcm->start_addr = ((emu10k1_memblk_t *)memblk)->mapped_page << PAGE_SHIFT; + mapped = ((struct snd_emu10k1_memblk *)epcm->memblk)->mapped_page; + if (mapped < 0) + return -ENOMEM; + epcm->start_addr = mapped << PAGE_SHIFT; } return 0; } -static int snd_emu10k1_playback_hw_free(snd_pcm_substream_t * substream) +static int snd_emu10k1_playback_hw_free(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1_pcm_t *epcm; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_emu10k1_pcm *epcm; if (runtime->private_data == NULL) return 0; @@ -448,11 +454,11 @@ static int snd_emu10k1_playback_hw_free(snd_pcm_substream_t * substream) return 0; } -static int snd_emu10k1_efx_playback_hw_free(snd_pcm_substream_t * substream) +static int snd_emu10k1_efx_playback_hw_free(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1_pcm_t *epcm; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_emu10k1_pcm *epcm; int i; if (runtime->private_data == NULL) @@ -477,11 +483,11 @@ static int snd_emu10k1_efx_playback_hw_free(snd_pcm_substream_t * substream) return 0; } -static int snd_emu10k1_playback_prepare(snd_pcm_substream_t * substream) +static int snd_emu10k1_playback_prepare(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1_pcm_t *epcm = runtime->private_data; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_emu10k1_pcm *epcm = runtime->private_data; unsigned int start_addr, end_addr; start_addr = epcm->start_addr; @@ -505,11 +511,11 @@ static int snd_emu10k1_playback_prepare(snd_pcm_substream_t * substream) return 0; } -static int snd_emu10k1_efx_playback_prepare(snd_pcm_substream_t * substream) +static int snd_emu10k1_efx_playback_prepare(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1_pcm_t *epcm = runtime->private_data; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_emu10k1_pcm *epcm = runtime->private_data; unsigned int start_addr, end_addr; unsigned int channel_size; int i; @@ -541,10 +547,11 @@ static int snd_emu10k1_efx_playback_prepare(snd_pcm_substream_t * substream) return 0; } -static snd_pcm_hardware_t snd_emu10k1_efx_playback = +static struct snd_pcm_hardware snd_emu10k1_efx_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_NONINTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | + SNDRV_PCM_INFO_RESUME | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_PAUSE), .formats = SNDRV_PCM_FMTBIT_S16_LE, .rates = SNDRV_PCM_RATE_48000, @@ -560,22 +567,22 @@ static snd_pcm_hardware_t snd_emu10k1_efx_playback = .fifo_size = 0, }; -static int snd_emu10k1_capture_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_emu10k1_capture_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); } -static int snd_emu10k1_capture_hw_free(snd_pcm_substream_t * substream) +static int snd_emu10k1_capture_hw_free(struct snd_pcm_substream *substream) { return snd_pcm_lib_free_pages(substream); } -static int snd_emu10k1_capture_prepare(snd_pcm_substream_t * substream) +static int snd_emu10k1_capture_prepare(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1_pcm_t *epcm = runtime->private_data; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_emu10k1_pcm *epcm = runtime->private_data; int idx; /* zeroing the buffer size will stop capture */ @@ -618,9 +625,9 @@ static int snd_emu10k1_capture_prepare(snd_pcm_substream_t * substream) return 0; } -static void snd_emu10k1_playback_invalidate_cache(emu10k1_t *emu, int extra, emu10k1_voice_t *evoice) +static void snd_emu10k1_playback_invalidate_cache(struct snd_emu10k1 *emu, int extra, struct snd_emu10k1_voice *evoice) { - snd_pcm_runtime_t *runtime; + struct snd_pcm_runtime *runtime; unsigned int voice, stereo, i, ccis, cra = 64, cs, sample; if (evoice == NULL) @@ -653,12 +660,12 @@ static void snd_emu10k1_playback_invalidate_cache(emu10k1_t *emu, int extra, emu } } -static void snd_emu10k1_playback_prepare_voice(emu10k1_t *emu, emu10k1_voice_t *evoice, +static void snd_emu10k1_playback_prepare_voice(struct snd_emu10k1 *emu, struct snd_emu10k1_voice *evoice, int master, int extra, - emu10k1_pcm_mixer_t *mix) + struct snd_emu10k1_pcm_mixer *mix) { - snd_pcm_substream_t *substream; - snd_pcm_runtime_t *runtime; + struct snd_pcm_substream *substream; + struct snd_pcm_runtime *runtime; unsigned int attn, vattn; unsigned int voice, tmp; @@ -678,10 +685,10 @@ static void snd_emu10k1_playback_prepare_voice(emu10k1_t *emu, emu10k1_voice_t * snd_emu10k1_voice_clear_loop_stop(emu, voice); } -static void snd_emu10k1_playback_trigger_voice(emu10k1_t *emu, emu10k1_voice_t *evoice, int master, int extra) +static void snd_emu10k1_playback_trigger_voice(struct snd_emu10k1 *emu, struct snd_emu10k1_voice *evoice, int master, int extra) { - snd_pcm_substream_t *substream; - snd_pcm_runtime_t *runtime; + struct snd_pcm_substream *substream; + struct snd_pcm_runtime *runtime; unsigned int voice, pitch, pitch_target; if (evoice == NULL) /* skip second voice for mono */ @@ -700,7 +707,7 @@ static void snd_emu10k1_playback_trigger_voice(emu10k1_t *emu, emu10k1_voice_t * snd_emu10k1_voice_intr_enable(emu, voice); } -static void snd_emu10k1_playback_stop_voice(emu10k1_t *emu, emu10k1_voice_t *evoice) +static void snd_emu10k1_playback_stop_voice(struct snd_emu10k1 *emu, struct snd_emu10k1_voice *evoice) { unsigned int voice; @@ -716,13 +723,13 @@ static void snd_emu10k1_playback_stop_voice(emu10k1_t *emu, emu10k1_voice_t *evo snd_emu10k1_ptr_write(emu, IP, voice, 0); } -static int snd_emu10k1_playback_trigger(snd_pcm_substream_t * substream, +static int snd_emu10k1_playback_trigger(struct snd_pcm_substream *substream, int cmd) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1_pcm_t *epcm = runtime->private_data; - emu10k1_pcm_mixer_t *mix; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_emu10k1_pcm *epcm = runtime->private_data; + struct snd_emu10k1_pcm_mixer *mix; int result = 0; // printk("trigger - emu10k1 = 0x%x, cmd = %i, pointer = %i\n", (int)emu, cmd, substream->ops->pointer(substream)); @@ -733,6 +740,7 @@ static int snd_emu10k1_playback_trigger(snd_pcm_substream_t * substream, snd_emu10k1_playback_invalidate_cache(emu, 0, epcm->voices[0]); /* follow thru */ case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: + case SNDRV_PCM_TRIGGER_RESUME: mix = &emu->pcm_mixer[substream->number]; snd_emu10k1_playback_prepare_voice(emu, epcm->voices[0], 1, 0, mix); snd_emu10k1_playback_prepare_voice(emu, epcm->voices[1], 0, 0, mix); @@ -744,6 +752,7 @@ static int snd_emu10k1_playback_trigger(snd_pcm_substream_t * substream, break; case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_PAUSE_PUSH: + case SNDRV_PCM_TRIGGER_SUSPEND: epcm->running = 0; snd_emu10k1_playback_stop_voice(emu, epcm->voices[0]); snd_emu10k1_playback_stop_voice(emu, epcm->voices[1]); @@ -757,17 +766,18 @@ static int snd_emu10k1_playback_trigger(snd_pcm_substream_t * substream, return result; } -static int snd_emu10k1_capture_trigger(snd_pcm_substream_t * substream, +static int snd_emu10k1_capture_trigger(struct snd_pcm_substream *substream, int cmd) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1_pcm_t *epcm = runtime->private_data; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_emu10k1_pcm *epcm = runtime->private_data; int result = 0; spin_lock(&emu->reg_lock); switch (cmd) { case SNDRV_PCM_TRIGGER_START: + case SNDRV_PCM_TRIGGER_RESUME: // hmm this should cause full and half full interrupt to be raised? outl(epcm->capture_ipr, emu->port + IPR); snd_emu10k1_intr_enable(emu, epcm->capture_inte); @@ -791,6 +801,7 @@ static int snd_emu10k1_capture_trigger(snd_pcm_substream_t * substream, epcm->first_ptr = 1; break; case SNDRV_PCM_TRIGGER_STOP: + case SNDRV_PCM_TRIGGER_SUSPEND: epcm->running = 0; snd_emu10k1_intr_disable(emu, epcm->capture_inte); outl(epcm->capture_ipr, emu->port + IPR); @@ -817,11 +828,11 @@ static int snd_emu10k1_capture_trigger(snd_pcm_substream_t * substream, return result; } -static snd_pcm_uframes_t snd_emu10k1_playback_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_emu10k1_playback_pointer(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1_pcm_t *epcm = runtime->private_data; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_emu10k1_pcm *epcm = runtime->private_data; unsigned int ptr; if (!epcm->running) @@ -845,12 +856,12 @@ static snd_pcm_uframes_t snd_emu10k1_playback_pointer(snd_pcm_substream_t * subs } -static int snd_emu10k1_efx_playback_trigger(snd_pcm_substream_t * substream, +static int snd_emu10k1_efx_playback_trigger(struct snd_pcm_substream *substream, int cmd) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1_pcm_t *epcm = runtime->private_data; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_emu10k1_pcm *epcm = runtime->private_data; int i; int result = 0; @@ -865,6 +876,7 @@ static int snd_emu10k1_efx_playback_trigger(snd_pcm_substream_t * substream, /* follow thru */ case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: + case SNDRV_PCM_TRIGGER_RESUME: snd_emu10k1_playback_prepare_voice(emu, epcm->extra, 1, 1, NULL); snd_emu10k1_playback_prepare_voice(emu, epcm->voices[0], 0, 0, &emu->efx_pcm_mixer[0]); @@ -877,6 +889,7 @@ static int snd_emu10k1_efx_playback_trigger(snd_pcm_substream_t * substream, snd_emu10k1_playback_trigger_voice(emu, epcm->voices[i], 0, 0); epcm->running = 1; break; + case SNDRV_PCM_TRIGGER_SUSPEND: case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_PAUSE_PUSH: epcm->running = 0; @@ -894,11 +907,11 @@ static int snd_emu10k1_efx_playback_trigger(snd_pcm_substream_t * substream, } -static snd_pcm_uframes_t snd_emu10k1_capture_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_emu10k1_capture_pointer(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1_pcm_t *epcm = runtime->private_data; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_emu10k1_pcm *epcm = runtime->private_data; unsigned int ptr; if (!epcm->running) @@ -915,10 +928,11 @@ static snd_pcm_uframes_t snd_emu10k1_capture_pointer(snd_pcm_substream_t * subst * Playback support device description */ -static snd_pcm_hardware_t snd_emu10k1_playback = +static struct snd_pcm_hardware snd_emu10k1_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | + SNDRV_PCM_INFO_RESUME | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_PAUSE), .formats = SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE, .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_96000, @@ -938,10 +952,11 @@ static snd_pcm_hardware_t snd_emu10k1_playback = * Capture support device description */ -static snd_pcm_hardware_t snd_emu10k1_capture = +static struct snd_pcm_hardware snd_emu10k1_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | + SNDRV_PCM_INFO_RESUME | SNDRV_PCM_INFO_MMAP_VALID), .formats = SNDRV_PCM_FMTBIT_S16_LE, .rates = SNDRV_PCM_RATE_8000_48000, @@ -961,9 +976,9 @@ static snd_pcm_hardware_t snd_emu10k1_capture = * */ -static void snd_emu10k1_pcm_mixer_notify1(emu10k1_t *emu, snd_kcontrol_t *kctl, int idx, int activate) +static void snd_emu10k1_pcm_mixer_notify1(struct snd_emu10k1 *emu, struct snd_kcontrol *kctl, int idx, int activate) { - snd_ctl_elem_id_t id; + struct snd_ctl_elem_id id; if (! kctl) return; @@ -976,29 +991,29 @@ static void snd_emu10k1_pcm_mixer_notify1(emu10k1_t *emu, snd_kcontrol_t *kctl, snd_ctl_build_ioff(&id, kctl, idx)); } -static void snd_emu10k1_pcm_mixer_notify(emu10k1_t *emu, int idx, int activate) +static void snd_emu10k1_pcm_mixer_notify(struct snd_emu10k1 *emu, int idx, int activate) { snd_emu10k1_pcm_mixer_notify1(emu, emu->ctl_send_routing, idx, activate); snd_emu10k1_pcm_mixer_notify1(emu, emu->ctl_send_volume, idx, activate); snd_emu10k1_pcm_mixer_notify1(emu, emu->ctl_attn, idx, activate); } -static void snd_emu10k1_pcm_efx_mixer_notify(emu10k1_t *emu, int idx, int activate) +static void snd_emu10k1_pcm_efx_mixer_notify(struct snd_emu10k1 *emu, int idx, int activate) { snd_emu10k1_pcm_mixer_notify1(emu, emu->ctl_efx_send_routing, idx, activate); snd_emu10k1_pcm_mixer_notify1(emu, emu->ctl_efx_send_volume, idx, activate); snd_emu10k1_pcm_mixer_notify1(emu, emu->ctl_efx_attn, idx, activate); } -static void snd_emu10k1_pcm_free_substream(snd_pcm_runtime_t *runtime) +static void snd_emu10k1_pcm_free_substream(struct snd_pcm_runtime *runtime) { kfree(runtime->private_data); } -static int snd_emu10k1_efx_playback_close(snd_pcm_substream_t * substream) +static int snd_emu10k1_efx_playback_close(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - emu10k1_pcm_mixer_t *mix; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_emu10k1_pcm_mixer *mix; int i; for (i=0; i < NUM_EFX_PLAYBACK; i++) { @@ -1009,12 +1024,12 @@ static int snd_emu10k1_efx_playback_close(snd_pcm_substream_t * substream) return 0; } -static int snd_emu10k1_efx_playback_open(snd_pcm_substream_t * substream) +static int snd_emu10k1_efx_playback_open(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - emu10k1_pcm_t *epcm; - emu10k1_pcm_mixer_t *mix; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_emu10k1_pcm *epcm; + struct snd_emu10k1_pcm_mixer *mix; + struct snd_pcm_runtime *runtime = substream->runtime; int i; epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); @@ -1042,12 +1057,12 @@ static int snd_emu10k1_efx_playback_open(snd_pcm_substream_t * substream) return 0; } -static int snd_emu10k1_playback_open(snd_pcm_substream_t * substream) +static int snd_emu10k1_playback_open(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - emu10k1_pcm_t *epcm; - emu10k1_pcm_mixer_t *mix; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_emu10k1_pcm *epcm; + struct snd_emu10k1_pcm_mixer *mix; + struct snd_pcm_runtime *runtime = substream->runtime; int i, err; epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); @@ -1079,21 +1094,21 @@ static int snd_emu10k1_playback_open(snd_pcm_substream_t * substream) return 0; } -static int snd_emu10k1_playback_close(snd_pcm_substream_t * substream) +static int snd_emu10k1_playback_close(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - emu10k1_pcm_mixer_t *mix = &emu->pcm_mixer[substream->number]; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_emu10k1_pcm_mixer *mix = &emu->pcm_mixer[substream->number]; mix->epcm = NULL; snd_emu10k1_pcm_mixer_notify(emu, substream->number, 0); return 0; } -static int snd_emu10k1_capture_open(snd_pcm_substream_t * substream) +static int snd_emu10k1_capture_open(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1_pcm_t *epcm; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_emu10k1_pcm *epcm; epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); if (epcm == NULL) @@ -1116,20 +1131,20 @@ static int snd_emu10k1_capture_open(snd_pcm_substream_t * substream) return 0; } -static int snd_emu10k1_capture_close(snd_pcm_substream_t * substream) +static int snd_emu10k1_capture_close(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); emu->capture_interrupt = NULL; emu->pcm_capture_substream = NULL; return 0; } -static int snd_emu10k1_capture_mic_open(snd_pcm_substream_t * substream) +static int snd_emu10k1_capture_mic_open(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - emu10k1_pcm_t *epcm; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_emu10k1_pcm *epcm; + struct snd_pcm_runtime *runtime = substream->runtime; epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); if (epcm == NULL) @@ -1154,20 +1169,20 @@ static int snd_emu10k1_capture_mic_open(snd_pcm_substream_t * substream) return 0; } -static int snd_emu10k1_capture_mic_close(snd_pcm_substream_t * substream) +static int snd_emu10k1_capture_mic_close(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); emu->capture_interrupt = NULL; emu->pcm_capture_mic_substream = NULL; return 0; } -static int snd_emu10k1_capture_efx_open(snd_pcm_substream_t * substream) +static int snd_emu10k1_capture_efx_open(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - emu10k1_pcm_t *epcm; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_emu10k1_pcm *epcm; + struct snd_pcm_runtime *runtime = substream->runtime; int nefx = emu->audigy ? 64 : 32; int idx; @@ -1204,16 +1219,16 @@ static int snd_emu10k1_capture_efx_open(snd_pcm_substream_t * substream) return 0; } -static int snd_emu10k1_capture_efx_close(snd_pcm_substream_t * substream) +static int snd_emu10k1_capture_efx_close(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); emu->capture_interrupt = NULL; emu->pcm_capture_efx_substream = NULL; return 0; } -static snd_pcm_ops_t snd_emu10k1_playback_ops = { +static struct snd_pcm_ops snd_emu10k1_playback_ops = { .open = snd_emu10k1_playback_open, .close = snd_emu10k1_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -1225,7 +1240,7 @@ static snd_pcm_ops_t snd_emu10k1_playback_ops = { .page = snd_pcm_sgbuf_ops_page, }; -static snd_pcm_ops_t snd_emu10k1_capture_ops = { +static struct snd_pcm_ops snd_emu10k1_capture_ops = { .open = snd_emu10k1_capture_open, .close = snd_emu10k1_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -1237,7 +1252,7 @@ static snd_pcm_ops_t snd_emu10k1_capture_ops = { }; /* EFX playback */ -static snd_pcm_ops_t snd_emu10k1_efx_playback_ops = { +static struct snd_pcm_ops snd_emu10k1_efx_playback_ops = { .open = snd_emu10k1_efx_playback_open, .close = snd_emu10k1_efx_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -1249,17 +1264,10 @@ static snd_pcm_ops_t snd_emu10k1_efx_playback_ops = { .page = snd_pcm_sgbuf_ops_page, }; -static void snd_emu10k1_pcm_free(snd_pcm_t *pcm) +int __devinit snd_emu10k1_pcm(struct snd_emu10k1 * emu, int device, struct snd_pcm ** rpcm) { - emu10k1_t *emu = pcm->private_data; - emu->pcm = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - -int __devinit snd_emu10k1_pcm(emu10k1_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) @@ -1269,7 +1277,6 @@ int __devinit snd_emu10k1_pcm(emu10k1_t * emu, int device, snd_pcm_t ** rpcm) return err; pcm->private_data = emu; - pcm->private_free = snd_emu10k1_pcm_free; snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_emu10k1_playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_emu10k1_capture_ops); @@ -1292,10 +1299,10 @@ int __devinit snd_emu10k1_pcm(emu10k1_t * emu, int device, snd_pcm_t ** rpcm) return 0; } -int __devinit snd_emu10k1_pcm_multi(emu10k1_t * emu, int device, snd_pcm_t ** rpcm) +int __devinit snd_emu10k1_pcm_multi(struct snd_emu10k1 * 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) @@ -1305,14 +1312,13 @@ int __devinit snd_emu10k1_pcm_multi(emu10k1_t * emu, int device, snd_pcm_t ** rp return err; pcm->private_data = emu; - pcm->private_free = snd_emu10k1_pcm_free; snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_emu10k1_efx_playback_ops); pcm->info_flags = 0; pcm->dev_subclass = SNDRV_PCM_SUBCLASS_GENERIC_MIX; strcpy(pcm->name, "Multichannel Playback"); - emu->pcm = pcm; + emu->pcm_multi = pcm; for (substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; substream = substream->next) if ((err = snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV_SG, snd_dma_pci_data(emu->pci), 64*1024, 64*1024)) < 0) @@ -1325,7 +1331,7 @@ int __devinit snd_emu10k1_pcm_multi(emu10k1_t * emu, int device, snd_pcm_t ** rp } -static snd_pcm_ops_t snd_emu10k1_capture_mic_ops = { +static struct snd_pcm_ops snd_emu10k1_capture_mic_ops = { .open = snd_emu10k1_capture_mic_open, .close = snd_emu10k1_capture_mic_close, .ioctl = snd_pcm_lib_ioctl, @@ -1336,16 +1342,9 @@ static snd_pcm_ops_t snd_emu10k1_capture_mic_ops = { .pointer = snd_emu10k1_capture_pointer, }; -static void snd_emu10k1_pcm_mic_free(snd_pcm_t *pcm) +int __devinit snd_emu10k1_pcm_mic(struct snd_emu10k1 * emu, int device, struct snd_pcm ** rpcm) { - emu10k1_t *emu = pcm->private_data; - emu->pcm_mic = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - -int __devinit snd_emu10k1_pcm_mic(emu10k1_t * emu, int device, snd_pcm_t ** rpcm) -{ - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; if (rpcm) @@ -1355,7 +1354,6 @@ int __devinit snd_emu10k1_pcm_mic(emu10k1_t * emu, int device, snd_pcm_t ** rpcm return err; pcm->private_data = emu; - pcm->private_free = snd_emu10k1_pcm_mic_free; snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_emu10k1_capture_mic_ops); @@ -1370,9 +1368,9 @@ int __devinit snd_emu10k1_pcm_mic(emu10k1_t * emu, int device, snd_pcm_t ** rpcm return 0; } -static int snd_emu10k1_pcm_efx_voices_mask_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_emu10k1_pcm_efx_voices_mask_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); int nefx = emu->audigy ? 64 : 32; uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = nefx; @@ -1381,9 +1379,9 @@ static int snd_emu10k1_pcm_efx_voices_mask_info(snd_kcontrol_t *kcontrol, snd_ct return 0; } -static int snd_emu10k1_pcm_efx_voices_mask_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1_pcm_efx_voices_mask_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); int nefx = emu->audigy ? 64 : 32; int idx; @@ -1394,9 +1392,9 @@ static int snd_emu10k1_pcm_efx_voices_mask_get(snd_kcontrol_t * kcontrol, snd_ct return 0; } -static int snd_emu10k1_pcm_efx_voices_mask_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1_pcm_efx_voices_mask_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); unsigned int nval[2], bits; int nefx = emu->audigy ? 64 : 32; int nefxb = emu->audigy ? 7 : 6; @@ -1425,7 +1423,7 @@ static int snd_emu10k1_pcm_efx_voices_mask_put(snd_kcontrol_t * kcontrol, snd_ct return change; } -static snd_kcontrol_new_t snd_emu10k1_pcm_efx_voices_mask = { +static struct snd_kcontrol_new snd_emu10k1_pcm_efx_voices_mask = { .iface = SNDRV_CTL_ELEM_IFACE_PCM, .name = "Captured FX8010 Outputs", .info = snd_emu10k1_pcm_efx_voices_mask_info, @@ -1433,7 +1431,7 @@ static snd_kcontrol_new_t snd_emu10k1_pcm_efx_voices_mask = { .put = snd_emu10k1_pcm_efx_voices_mask_put }; -static snd_pcm_ops_t snd_emu10k1_capture_efx_ops = { +static struct snd_pcm_ops snd_emu10k1_capture_efx_ops = { .open = snd_emu10k1_capture_efx_open, .close = snd_emu10k1_capture_efx_close, .ioctl = snd_pcm_lib_ioctl, @@ -1450,9 +1448,9 @@ static snd_pcm_ops_t snd_emu10k1_capture_efx_ops = { #define INITIAL_TRAM_SHIFT 14 #define INITIAL_TRAM_POS(size) ((((size) / 2) - INITIAL_TRAM_SHIFT) - 1) -static void snd_emu10k1_fx8010_playback_irq(emu10k1_t *emu, void *private_data) +static void snd_emu10k1_fx8010_playback_irq(struct snd_emu10k1 *emu, void *private_data) { - snd_pcm_substream_t *substream = private_data; + struct snd_pcm_substream *substream = private_data; snd_pcm_period_elapsed(substream); } @@ -1476,11 +1474,11 @@ static void snd_emu10k1_fx8010_playback_tram_poke1(unsigned short *dst_left, } } -static void fx8010_pb_trans_copy(snd_pcm_substream_t *substream, - snd_pcm_indirect_t *rec, size_t bytes) +static void fx8010_pb_trans_copy(struct snd_pcm_substream *substream, + struct snd_pcm_indirect *rec, size_t bytes) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_emu10k1_fx8010_pcm_t *pcm = &emu->fx8010.pcm[substream->number]; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number]; unsigned int tram_size = pcm->buffer_size; unsigned short *src = (unsigned short *)(substream->runtime->dma_area + rec->sw_data); unsigned int frames = bytes >> 2, count; @@ -1505,25 +1503,25 @@ static void fx8010_pb_trans_copy(snd_pcm_substream_t *substream, pcm->tram_shift = tram_shift; } -static int snd_emu10k1_fx8010_playback_transfer(snd_pcm_substream_t *substream) +static int snd_emu10k1_fx8010_playback_transfer(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_emu10k1_fx8010_pcm_t *pcm = &emu->fx8010.pcm[substream->number]; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number]; snd_pcm_indirect_playback_transfer(substream, &pcm->pcm_rec, fx8010_pb_trans_copy); return 0; } -static int snd_emu10k1_fx8010_playback_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_emu10k1_fx8010_playback_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); } -static int snd_emu10k1_fx8010_playback_hw_free(snd_pcm_substream_t * substream) +static int snd_emu10k1_fx8010_playback_hw_free(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_emu10k1_fx8010_pcm_t *pcm = &emu->fx8010.pcm[substream->number]; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number]; unsigned int i; for (i = 0; i < pcm->channels; i++) @@ -1532,11 +1530,11 @@ static int snd_emu10k1_fx8010_playback_hw_free(snd_pcm_substream_t * substream) return 0; } -static int snd_emu10k1_fx8010_playback_prepare(snd_pcm_substream_t * substream) +static int snd_emu10k1_fx8010_playback_prepare(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - snd_emu10k1_fx8010_pcm_t *pcm = &emu->fx8010.pcm[substream->number]; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number]; unsigned int i; // printk("prepare: etram_pages = 0x%p, dma_area = 0x%x, buffer_size = 0x%x (0x%x)\n", emu->fx8010.etram_pages, runtime->dma_area, runtime->buffer_size, runtime->buffer_size << 2); @@ -1556,10 +1554,10 @@ static int snd_emu10k1_fx8010_playback_prepare(snd_pcm_substream_t * substream) return 0; } -static int snd_emu10k1_fx8010_playback_trigger(snd_pcm_substream_t * substream, int cmd) +static int snd_emu10k1_fx8010_playback_trigger(struct snd_pcm_substream *substream, int cmd) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_emu10k1_fx8010_pcm_t *pcm = &emu->fx8010.pcm[substream->number]; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number]; int result = 0; spin_lock(&emu->reg_lock); @@ -1567,6 +1565,7 @@ static int snd_emu10k1_fx8010_playback_trigger(snd_pcm_substream_t * substream, case SNDRV_PCM_TRIGGER_START: /* follow thru */ case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: + case SNDRV_PCM_TRIGGER_RESUME: #ifdef EMU10K1_SET_AC3_IEC958 { int i; @@ -1587,6 +1586,7 @@ static int snd_emu10k1_fx8010_playback_trigger(snd_pcm_substream_t * substream, break; case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_PAUSE_PUSH: + case SNDRV_PCM_TRIGGER_SUSPEND: snd_emu10k1_fx8010_unregister_irq_handler(emu, pcm->irq); pcm->irq = NULL; snd_emu10k1_ptr_write(emu, emu->gpr_base + pcm->gpr_trigger, 0, 0); pcm->tram_pos = INITIAL_TRAM_POS(pcm->buffer_size); @@ -1601,10 +1601,10 @@ static int snd_emu10k1_fx8010_playback_trigger(snd_pcm_substream_t * substream, return result; } -static snd_pcm_uframes_t snd_emu10k1_fx8010_playback_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_emu10k1_fx8010_playback_pointer(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_emu10k1_fx8010_pcm_t *pcm = &emu->fx8010.pcm[substream->number]; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number]; size_t ptr; /* byte pointer */ if (!snd_emu10k1_ptr_read(emu, emu->gpr_base + pcm->gpr_trigger, 0)) @@ -1613,9 +1613,10 @@ static snd_pcm_uframes_t snd_emu10k1_fx8010_playback_pointer(snd_pcm_substream_t return snd_pcm_indirect_playback_pointer(substream, &pcm->pcm_rec, ptr); } -static snd_pcm_hardware_t snd_emu10k1_fx8010_playback = +static struct snd_pcm_hardware snd_emu10k1_fx8010_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | + SNDRV_PCM_INFO_RESUME | /* SNDRV_PCM_INFO_MMAP_VALID | */ SNDRV_PCM_INFO_PAUSE), .formats = SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE, .rates = SNDRV_PCM_RATE_48000, @@ -1631,11 +1632,11 @@ static snd_pcm_hardware_t snd_emu10k1_fx8010_playback = .fifo_size = 0, }; -static int snd_emu10k1_fx8010_playback_open(snd_pcm_substream_t * substream) +static int snd_emu10k1_fx8010_playback_open(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - snd_emu10k1_fx8010_pcm_t *pcm = &emu->fx8010.pcm[substream->number]; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number]; runtime->hw = snd_emu10k1_fx8010_playback; runtime->hw.channels_min = runtime->hw.channels_max = pcm->channels; @@ -1650,10 +1651,10 @@ static int snd_emu10k1_fx8010_playback_open(snd_pcm_substream_t * substream) return 0; } -static int snd_emu10k1_fx8010_playback_close(snd_pcm_substream_t * substream) +static int snd_emu10k1_fx8010_playback_close(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_emu10k1_fx8010_pcm_t *pcm = &emu->fx8010.pcm[substream->number]; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number]; spin_lock_irq(&emu->reg_lock); pcm->opened = 0; @@ -1661,7 +1662,7 @@ static int snd_emu10k1_fx8010_playback_close(snd_pcm_substream_t * substream) return 0; } -static snd_pcm_ops_t snd_emu10k1_fx8010_playback_ops = { +static struct snd_pcm_ops snd_emu10k1_fx8010_playback_ops = { .open = snd_emu10k1_fx8010_playback_open, .close = snd_emu10k1_fx8010_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -1673,17 +1674,10 @@ static snd_pcm_ops_t snd_emu10k1_fx8010_playback_ops = { .ack = snd_emu10k1_fx8010_playback_transfer, }; -static void snd_emu10k1_pcm_efx_free(snd_pcm_t *pcm) -{ - emu10k1_t *emu = pcm->private_data; - emu->pcm_efx = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - -int __devinit snd_emu10k1_pcm_efx(emu10k1_t * emu, int device, snd_pcm_t ** rpcm) +int __devinit snd_emu10k1_pcm_efx(struct snd_emu10k1 * emu, int device, struct snd_pcm ** rpcm) { - snd_pcm_t *pcm; - snd_kcontrol_t *kctl; + struct snd_pcm *pcm; + struct snd_kcontrol *kctl; int err; if (rpcm) @@ -1693,7 +1687,6 @@ int __devinit snd_emu10k1_pcm_efx(emu10k1_t * emu, int device, snd_pcm_t ** rpcm return err; pcm->private_data = emu; - pcm->private_free = snd_emu10k1_pcm_efx_free; snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_emu10k1_fx8010_playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_emu10k1_capture_efx_ops); diff --git a/sound/pci/emu10k1/emuproc.c b/sound/pci/emu10k1/emuproc.c index cc22707c91f..90f1c52703a 100644 --- a/sound/pci/emu10k1/emuproc.c +++ b/sound/pci/emu10k1/emuproc.c @@ -32,8 +32,9 @@ #include <sound/emu10k1.h> #include "p16v.h" -static void snd_emu10k1_proc_spdif_status(emu10k1_t * emu, - snd_info_buffer_t * buffer, +#ifdef CONFIG_PROC_FS +static void snd_emu10k1_proc_spdif_status(struct snd_emu10k1 * emu, + struct snd_info_buffer *buffer, char *title, int status_reg, int rate_reg) @@ -75,8 +76,8 @@ static void snd_emu10k1_proc_spdif_status(emu10k1_t * emu, } -static void snd_emu10k1_proc_read(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_emu10k1_proc_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { /* FIXME - output names are in emufx.c too */ static char *creative_outs[32] = { @@ -181,7 +182,7 @@ static void snd_emu10k1_proc_read(snd_info_entry_t *entry, /* 63 */ "FXBUS2_31" }; - emu10k1_t *emu = entry->private_data; + struct snd_emu10k1 *emu = entry->private_data; unsigned int val, val1; int nefx = emu->audigy ? 64 : 32; char **outputs = emu->audigy ? audigy_outs : creative_outs; @@ -232,10 +233,10 @@ static void snd_emu10k1_proc_read(snd_info_entry_t *entry, snd_iprintf(buffer, " Output %02i [%s]\n", idx, outputs[idx]); } -static void snd_emu10k1_proc_spdif_read(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_emu10k1_proc_spdif_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - emu10k1_t *emu = entry->private_data; + struct snd_emu10k1 *emu = entry->private_data; snd_emu10k1_proc_spdif_status(emu, buffer, "CD-ROM S/PDIF In", CDCS, CDSRCS); snd_emu10k1_proc_spdif_status(emu, buffer, "Optical or Coax S/PDIF In", GPSCS, GPSRCS); #if 0 @@ -246,11 +247,11 @@ static void snd_emu10k1_proc_spdif_read(snd_info_entry_t *entry, #endif } -static void snd_emu10k1_proc_rates_read(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_emu10k1_proc_rates_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { static int samplerate[8] = { 44100, 48000, 96000, 192000, 4, 5, 6, 7 }; - emu10k1_t *emu = entry->private_data; + struct snd_emu10k1 *emu = entry->private_data; unsigned int val, tmp, n; val = snd_emu10k1_ptr20_read(emu, CAPTURE_RATE_STATUS, 0); tmp = (val >> 16) & 0x8; @@ -261,11 +262,11 @@ static void snd_emu10k1_proc_rates_read(snd_info_entry_t *entry, } } -static void snd_emu10k1_proc_acode_read(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_emu10k1_proc_acode_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { u32 pc; - emu10k1_t *emu = entry->private_data; + struct snd_emu10k1 *emu = entry->private_data; snd_iprintf(buffer, "FX8010 Instruction List '%s'\n", emu->fx8010.name); snd_iprintf(buffer, " Code dump :\n"); @@ -304,12 +305,13 @@ static void snd_emu10k1_proc_acode_read(snd_info_entry_t *entry, #define TOTAL_SIZE_CODE (0x200*8) #define A_TOTAL_SIZE_CODE (0x400*8) -static long snd_emu10k1_fx8010_read(snd_info_entry_t *entry, void *file_private_data, +static long snd_emu10k1_fx8010_read(struct snd_info_entry *entry, + void *file_private_data, struct file *file, char __user *buf, unsigned long count, unsigned long pos) { long size; - emu10k1_t *emu = entry->private_data; + struct snd_emu10k1 *emu = entry->private_data; unsigned int offset; int tram_addr = 0; @@ -349,11 +351,11 @@ static long snd_emu10k1_fx8010_read(snd_info_entry_t *entry, void *file_private_ return 0; } -static void snd_emu10k1_proc_voices_read(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_emu10k1_proc_voices_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - emu10k1_t *emu = entry->private_data; - emu10k1_voice_t *voice; + struct snd_emu10k1 *emu = entry->private_data; + struct snd_emu10k1_voice *voice; int idx; snd_iprintf(buffer, "ch\tuse\tpcm\tefx\tsynth\tmidi\n"); @@ -370,10 +372,10 @@ static void snd_emu10k1_proc_voices_read(snd_info_entry_t *entry, } #ifdef CONFIG_SND_DEBUG -static void snd_emu_proc_io_reg_read(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_emu_proc_io_reg_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - emu10k1_t *emu = entry->private_data; + struct snd_emu10k1 *emu = entry->private_data; unsigned long value; unsigned long flags; int i; @@ -386,10 +388,10 @@ static void snd_emu_proc_io_reg_read(snd_info_entry_t *entry, } } -static void snd_emu_proc_io_reg_write(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_emu_proc_io_reg_write(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - emu10k1_t *emu = entry->private_data; + struct snd_emu10k1 *emu = entry->private_data; unsigned long flags; char line[64]; u32 reg, val; @@ -404,7 +406,7 @@ static void snd_emu_proc_io_reg_write(snd_info_entry_t *entry, } } -static unsigned int snd_ptr_read(emu10k1_t * emu, +static unsigned int snd_ptr_read(struct snd_emu10k1 * emu, unsigned int iobase, unsigned int reg, unsigned int chn) @@ -421,7 +423,7 @@ static unsigned int snd_ptr_read(emu10k1_t * emu, return val; } -static void snd_ptr_write(emu10k1_t *emu, +static void snd_ptr_write(struct snd_emu10k1 *emu, unsigned int iobase, unsigned int reg, unsigned int chn, @@ -439,13 +441,13 @@ static void snd_ptr_write(emu10k1_t *emu, } -static void snd_emu_proc_ptr_reg_read(snd_info_entry_t *entry, - snd_info_buffer_t * buffer, int iobase, int offset, int length, int voices) +static void snd_emu_proc_ptr_reg_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer, int iobase, int offset, int length, int voices) { - emu10k1_t *emu = entry->private_data; + struct snd_emu10k1 *emu = entry->private_data; unsigned long value; int i,j; - if (offset+length > 0x80) { + if (offset+length > 0xa0) { snd_iprintf(buffer, "Input values out of range\n"); return; } @@ -463,65 +465,71 @@ static void snd_emu_proc_ptr_reg_read(snd_info_entry_t *entry, } } -static void snd_emu_proc_ptr_reg_write(snd_info_entry_t *entry, - snd_info_buffer_t * buffer, int iobase) +static void snd_emu_proc_ptr_reg_write(struct snd_info_entry *entry, + struct snd_info_buffer *buffer, int iobase) { - emu10k1_t *emu = entry->private_data; + struct snd_emu10k1 *emu = entry->private_data; char line[64]; unsigned int reg, channel_id , val; while (!snd_info_get_line(buffer, line, sizeof(line))) { if (sscanf(line, "%x %x %x", ®, &channel_id, &val) != 3) continue; - if ((reg < 0x80) && (reg >=0) && (val <= 0xffffffff) && (channel_id >=0) && (channel_id <= 3) ) + if ((reg < 0xa0) && (reg >=0) && (val <= 0xffffffff) && (channel_id >=0) && (channel_id <= 3) ) snd_ptr_write(emu, iobase, reg, channel_id, val); } } -static void snd_emu_proc_ptr_reg_write00(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_emu_proc_ptr_reg_write00(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { snd_emu_proc_ptr_reg_write(entry, buffer, 0); } -static void snd_emu_proc_ptr_reg_write20(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_emu_proc_ptr_reg_write20(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { snd_emu_proc_ptr_reg_write(entry, buffer, 0x20); } -static void snd_emu_proc_ptr_reg_read00a(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_emu_proc_ptr_reg_read00a(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { snd_emu_proc_ptr_reg_read(entry, buffer, 0, 0, 0x40, 64); } -static void snd_emu_proc_ptr_reg_read00b(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_emu_proc_ptr_reg_read00b(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { snd_emu_proc_ptr_reg_read(entry, buffer, 0, 0x40, 0x40, 64); } -static void snd_emu_proc_ptr_reg_read20a(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_emu_proc_ptr_reg_read20a(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { snd_emu_proc_ptr_reg_read(entry, buffer, 0x20, 0, 0x40, 4); } -static void snd_emu_proc_ptr_reg_read20b(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_emu_proc_ptr_reg_read20b(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { snd_emu_proc_ptr_reg_read(entry, buffer, 0x20, 0x40, 0x40, 4); } + +static void snd_emu_proc_ptr_reg_read20c(struct snd_info_entry *entry, + struct snd_info_buffer * buffer) +{ + snd_emu_proc_ptr_reg_read(entry, buffer, 0x20, 0x80, 0x20, 4); +} #endif static struct snd_info_entry_ops snd_emu10k1_proc_ops_fx8010 = { .read = snd_emu10k1_fx8010_read, }; -int __devinit snd_emu10k1_proc_init(emu10k1_t * emu) +int __devinit snd_emu10k1_proc_init(struct snd_emu10k1 * emu) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; #ifdef CONFIG_SND_DEBUG if (! snd_card_proc_new(emu->card, "io_regs", &entry)) { snd_info_set_text_ops(entry, emu, 1024, snd_emu_proc_io_reg_read); @@ -553,6 +561,12 @@ int __devinit snd_emu10k1_proc_init(emu10k1_t * emu) entry->c.text.write = snd_emu_proc_ptr_reg_write20; entry->mode |= S_IWUSR; } + if (! snd_card_proc_new(emu->card, "ptr_regs20c", &entry)) { + snd_info_set_text_ops(entry, emu, 65536, snd_emu_proc_ptr_reg_read20c); + entry->c.text.write_size = 64; + entry->c.text.write = snd_emu_proc_ptr_reg_write20; + entry->mode |= S_IWUSR; + } #endif if (! snd_card_proc_new(emu->card, "emu10k1", &entry)) @@ -607,3 +621,4 @@ int __devinit snd_emu10k1_proc_init(emu10k1_t * emu) } return 0; } +#endif /* CONFIG_PROC_FS */ diff --git a/sound/pci/emu10k1/io.c b/sound/pci/emu10k1/io.c index b9d3ae0dcab..ef5304df8c1 100644 --- a/sound/pci/emu10k1/io.c +++ b/sound/pci/emu10k1/io.c @@ -29,8 +29,9 @@ #include <linux/time.h> #include <sound/core.h> #include <sound/emu10k1.h> +#include <linux/delay.h> -unsigned int snd_emu10k1_ptr_read(emu10k1_t * emu, unsigned int reg, unsigned int chn) +unsigned int snd_emu10k1_ptr_read(struct snd_emu10k1 * emu, unsigned int reg, unsigned int chn) { unsigned long flags; unsigned int regptr, val; @@ -61,7 +62,7 @@ unsigned int snd_emu10k1_ptr_read(emu10k1_t * emu, unsigned int reg, unsigned in } } -void snd_emu10k1_ptr_write(emu10k1_t *emu, unsigned int reg, unsigned int chn, unsigned int data) +void snd_emu10k1_ptr_write(struct snd_emu10k1 *emu, unsigned int reg, unsigned int chn, unsigned int data) { unsigned int regptr; unsigned long flags; @@ -91,7 +92,7 @@ void snd_emu10k1_ptr_write(emu10k1_t *emu, unsigned int reg, unsigned int chn, u } } -unsigned int snd_emu10k1_ptr20_read(emu10k1_t * emu, +unsigned int snd_emu10k1_ptr20_read(struct snd_emu10k1 * emu, unsigned int reg, unsigned int chn) { @@ -107,7 +108,7 @@ unsigned int snd_emu10k1_ptr20_read(emu10k1_t * emu, return val; } -void snd_emu10k1_ptr20_write(emu10k1_t *emu, +void snd_emu10k1_ptr20_write(struct snd_emu10k1 *emu, unsigned int reg, unsigned int chn, unsigned int data) @@ -123,7 +124,46 @@ void snd_emu10k1_ptr20_write(emu10k1_t *emu, spin_unlock_irqrestore(&emu->emu_lock, flags); } -void snd_emu10k1_intr_enable(emu10k1_t *emu, unsigned int intrenb) +int snd_emu10k1_spi_write(struct snd_emu10k1 * emu, + unsigned int data) +{ + unsigned int reset, set; + unsigned int reg, tmp; + int n, result; + if (emu->card_capabilities->ca0108_chip) + reg = 0x3c; /* PTR20, reg 0x3c */ + else { + /* For other chip types the SPI register + * is currently unknown. */ + return 1; + } + if (data > 0xffff) /* Only 16bit values allowed */ + return 1; + + tmp = snd_emu10k1_ptr20_read(emu, reg, 0); + reset = (tmp & ~0x3ffff) | 0x20000; /* Set xxx20000 */ + set = reset | 0x10000; /* Set xxx1xxxx */ + snd_emu10k1_ptr20_write(emu, reg, 0, reset | data); + tmp = snd_emu10k1_ptr20_read(emu, reg, 0); /* write post */ + snd_emu10k1_ptr20_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_emu10k1_ptr20_read(emu, reg, 0); + if (!(tmp & 0x10000)) { + result = 0; + break; + } + } + if (result) /* Timed out */ + return 1; + snd_emu10k1_ptr20_write(emu, reg, 0, reset | data); + tmp = snd_emu10k1_ptr20_read(emu, reg, 0); /* Write post */ + return 0; +} + +void snd_emu10k1_intr_enable(struct snd_emu10k1 *emu, unsigned int intrenb) { unsigned long flags; unsigned int enable; @@ -134,7 +174,7 @@ void snd_emu10k1_intr_enable(emu10k1_t *emu, unsigned int intrenb) spin_unlock_irqrestore(&emu->emu_lock, flags); } -void snd_emu10k1_intr_disable(emu10k1_t *emu, unsigned int intrenb) +void snd_emu10k1_intr_disable(struct snd_emu10k1 *emu, unsigned int intrenb) { unsigned long flags; unsigned int enable; @@ -145,7 +185,7 @@ void snd_emu10k1_intr_disable(emu10k1_t *emu, unsigned int intrenb) spin_unlock_irqrestore(&emu->emu_lock, flags); } -void snd_emu10k1_voice_intr_enable(emu10k1_t *emu, unsigned int voicenum) +void snd_emu10k1_voice_intr_enable(struct snd_emu10k1 *emu, unsigned int voicenum) { unsigned long flags; unsigned int val; @@ -165,7 +205,7 @@ void snd_emu10k1_voice_intr_enable(emu10k1_t *emu, unsigned int voicenum) spin_unlock_irqrestore(&emu->emu_lock, flags); } -void snd_emu10k1_voice_intr_disable(emu10k1_t *emu, unsigned int voicenum) +void snd_emu10k1_voice_intr_disable(struct snd_emu10k1 *emu, unsigned int voicenum) { unsigned long flags; unsigned int val; @@ -185,7 +225,7 @@ void snd_emu10k1_voice_intr_disable(emu10k1_t *emu, unsigned int voicenum) spin_unlock_irqrestore(&emu->emu_lock, flags); } -void snd_emu10k1_voice_intr_ack(emu10k1_t *emu, unsigned int voicenum) +void snd_emu10k1_voice_intr_ack(struct snd_emu10k1 *emu, unsigned int voicenum) { unsigned long flags; @@ -202,7 +242,7 @@ void snd_emu10k1_voice_intr_ack(emu10k1_t *emu, unsigned int voicenum) spin_unlock_irqrestore(&emu->emu_lock, flags); } -void snd_emu10k1_voice_half_loop_intr_enable(emu10k1_t *emu, unsigned int voicenum) +void snd_emu10k1_voice_half_loop_intr_enable(struct snd_emu10k1 *emu, unsigned int voicenum) { unsigned long flags; unsigned int val; @@ -222,7 +262,7 @@ void snd_emu10k1_voice_half_loop_intr_enable(emu10k1_t *emu, unsigned int voicen spin_unlock_irqrestore(&emu->emu_lock, flags); } -void snd_emu10k1_voice_half_loop_intr_disable(emu10k1_t *emu, unsigned int voicenum) +void snd_emu10k1_voice_half_loop_intr_disable(struct snd_emu10k1 *emu, unsigned int voicenum) { unsigned long flags; unsigned int val; @@ -242,7 +282,7 @@ void snd_emu10k1_voice_half_loop_intr_disable(emu10k1_t *emu, unsigned int voice spin_unlock_irqrestore(&emu->emu_lock, flags); } -void snd_emu10k1_voice_half_loop_intr_ack(emu10k1_t *emu, unsigned int voicenum) +void snd_emu10k1_voice_half_loop_intr_ack(struct snd_emu10k1 *emu, unsigned int voicenum) { unsigned long flags; @@ -259,7 +299,7 @@ void snd_emu10k1_voice_half_loop_intr_ack(emu10k1_t *emu, unsigned int voicenum) spin_unlock_irqrestore(&emu->emu_lock, flags); } -void snd_emu10k1_voice_set_loop_stop(emu10k1_t *emu, unsigned int voicenum) +void snd_emu10k1_voice_set_loop_stop(struct snd_emu10k1 *emu, unsigned int voicenum) { unsigned long flags; unsigned int sol; @@ -279,7 +319,7 @@ void snd_emu10k1_voice_set_loop_stop(emu10k1_t *emu, unsigned int voicenum) spin_unlock_irqrestore(&emu->emu_lock, flags); } -void snd_emu10k1_voice_clear_loop_stop(emu10k1_t *emu, unsigned int voicenum) +void snd_emu10k1_voice_clear_loop_stop(struct snd_emu10k1 *emu, unsigned int voicenum) { unsigned long flags; unsigned int sol; @@ -299,7 +339,7 @@ void snd_emu10k1_voice_clear_loop_stop(emu10k1_t *emu, unsigned int voicenum) spin_unlock_irqrestore(&emu->emu_lock, flags); } -void snd_emu10k1_wait(emu10k1_t *emu, unsigned int wait) +void snd_emu10k1_wait(struct snd_emu10k1 *emu, unsigned int wait) { volatile unsigned count; unsigned int newtime = 0, curtime; @@ -318,9 +358,9 @@ void snd_emu10k1_wait(emu10k1_t *emu, unsigned int wait) } } -unsigned short snd_emu10k1_ac97_read(ac97_t *ac97, unsigned short reg) +unsigned short snd_emu10k1_ac97_read(struct snd_ac97 *ac97, unsigned short reg) { - emu10k1_t *emu = ac97->private_data; + struct snd_emu10k1 *emu = ac97->private_data; unsigned long flags; unsigned short val; @@ -331,9 +371,9 @@ unsigned short snd_emu10k1_ac97_read(ac97_t *ac97, unsigned short reg) return val; } -void snd_emu10k1_ac97_write(ac97_t *ac97, unsigned short reg, unsigned short data) +void snd_emu10k1_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short data) { - emu10k1_t *emu = ac97->private_data; + struct snd_emu10k1 *emu = ac97->private_data; unsigned long flags; spin_lock_irqsave(&emu->emu_lock, flags); diff --git a/sound/pci/emu10k1/irq.c b/sound/pci/emu10k1/irq.c index 594ea063b14..a8b31286b6d 100644 --- a/sound/pci/emu10k1/irq.c +++ b/sound/pci/emu10k1/irq.c @@ -32,7 +32,7 @@ irqreturn_t snd_emu10k1_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - emu10k1_t *emu = dev_id; + struct snd_emu10k1 *emu = dev_id; unsigned int status, status2, orig_status, orig_status2; int handled = 0; @@ -56,7 +56,7 @@ irqreturn_t snd_emu10k1_interrupt(int irq, void *dev_id, struct pt_regs *regs) int voice; int voice_max = status & IPR_CHANNELNUMBERMASK; u32 val; - emu10k1_voice_t *pvoice = emu->voices; + struct snd_emu10k1_voice *pvoice = emu->voices; val = snd_emu10k1_ptr_read(emu, CLIPL, 0); for (voice = 0; voice <= voice_max; voice++) { @@ -150,8 +150,8 @@ irqreturn_t snd_emu10k1_interrupt(int irq, void *dev_id, struct pt_regs *regs) if (status & IPR_P16V) { while ((status2 = inl(emu->port + IPR2)) != 0) { u32 mask = INTE2_PLAYBACK_CH_0_LOOP; /* Full Loop */ - emu10k1_voice_t *pvoice = &(emu->p16v_voices[0]); - emu10k1_voice_t *cvoice = &(emu->p16v_capture_voice); + struct snd_emu10k1_voice *pvoice = &(emu->p16v_voices[0]); + struct snd_emu10k1_voice *cvoice = &(emu->p16v_capture_voice); //printk(KERN_INFO "status2=0x%x\n", status2); orig_status2 = status2; diff --git a/sound/pci/emu10k1/memory.c b/sound/pci/emu10k1/memory.c index d42e4aeaa73..68c795c0310 100644 --- a/sound/pci/emu10k1/memory.c +++ b/sound/pci/emu10k1/memory.c @@ -48,7 +48,7 @@ #define set_silent_ptb(emu,page) __set_ptb_entry(emu,page,emu->silent_page.addr) #else /* fill PTB entries -- we need to fill UNIT_PAGES entries */ -static inline void set_ptb_entry(emu10k1_t *emu, int page, dma_addr_t addr) +static inline void set_ptb_entry(struct snd_emu10k1 *emu, int page, dma_addr_t addr) { int i; page *= UNIT_PAGES; @@ -57,7 +57,7 @@ static inline void set_ptb_entry(emu10k1_t *emu, int page, dma_addr_t addr) addr += EMUPAGESIZE; } } -static inline void set_silent_ptb(emu10k1_t *emu, int page) +static inline void set_silent_ptb(struct snd_emu10k1 *emu, int page) { int i; page *= UNIT_PAGES; @@ -70,14 +70,14 @@ static inline void set_silent_ptb(emu10k1_t *emu, int page) /* */ -static int synth_alloc_pages(emu10k1_t *hw, emu10k1_memblk_t *blk); -static int synth_free_pages(emu10k1_t *hw, emu10k1_memblk_t *blk); +static int synth_alloc_pages(struct snd_emu10k1 *hw, struct snd_emu10k1_memblk *blk); +static int synth_free_pages(struct snd_emu10k1 *hw, struct snd_emu10k1_memblk *blk); -#define get_emu10k1_memblk(l,member) list_entry(l, emu10k1_memblk_t, member) +#define get_emu10k1_memblk(l,member) list_entry(l, struct snd_emu10k1_memblk, member) /* initialize emu10k1 part */ -static void emu10k1_memblk_init(emu10k1_memblk_t *blk) +static void emu10k1_memblk_init(struct snd_emu10k1_memblk *blk) { blk->mapped_page = -1; INIT_LIST_HEAD(&blk->mapped_link); @@ -96,7 +96,7 @@ static void emu10k1_memblk_init(emu10k1_memblk_t *blk) * in nextp * if not found, return a negative error code. */ -static int search_empty_map_area(emu10k1_t *emu, int npages, struct list_head **nextp) +static int search_empty_map_area(struct snd_emu10k1 *emu, int npages, struct list_head **nextp) { int page = 0, found_page = -ENOMEM; int max_size = npages; @@ -105,7 +105,7 @@ static int search_empty_map_area(emu10k1_t *emu, int npages, struct list_head ** struct list_head *pos; list_for_each (pos, &emu->mapped_link_head) { - emu10k1_memblk_t *blk = get_emu10k1_memblk(pos, mapped_link); + struct snd_emu10k1_memblk *blk = get_emu10k1_memblk(pos, mapped_link); snd_assert(blk->mapped_page >= 0, continue); size = blk->mapped_page - page; if (size == npages) { @@ -134,7 +134,7 @@ static int search_empty_map_area(emu10k1_t *emu, int npages, struct list_head ** * * call with memblk_lock held */ -static int map_memblk(emu10k1_t *emu, emu10k1_memblk_t *blk) +static int map_memblk(struct snd_emu10k1 *emu, struct snd_emu10k1_memblk *blk) { int page, pg; struct list_head *next; @@ -161,11 +161,11 @@ static int map_memblk(emu10k1_t *emu, emu10k1_memblk_t *blk) * * call with memblk_lock held */ -static int unmap_memblk(emu10k1_t *emu, emu10k1_memblk_t *blk) +static int unmap_memblk(struct snd_emu10k1 *emu, struct snd_emu10k1_memblk *blk) { int start_page, end_page, mpage, pg; struct list_head *p; - emu10k1_memblk_t *q; + struct snd_emu10k1_memblk *q; /* calculate the expected size of empty region */ if ((p = blk->mapped_link.prev) != &emu->mapped_link_head) { @@ -197,11 +197,11 @@ static int unmap_memblk(emu10k1_t *emu, emu10k1_memblk_t *blk) * * unlike synth_alloc the memory block is aligned to the page start */ -static emu10k1_memblk_t * -search_empty(emu10k1_t *emu, int size) +static struct snd_emu10k1_memblk * +search_empty(struct snd_emu10k1 *emu, int size) { struct list_head *p; - emu10k1_memblk_t *blk; + struct snd_emu10k1_memblk *blk; int page, psize; psize = get_aligned_page(size + PAGE_SIZE -1); @@ -217,7 +217,7 @@ search_empty(emu10k1_t *emu, int size) __found_pages: /* create a new memory block */ - blk = (emu10k1_memblk_t *)__snd_util_memblk_new(emu->memhdr, psize << PAGE_SHIFT, p->prev); + blk = (struct snd_emu10k1_memblk *)__snd_util_memblk_new(emu->memhdr, psize << PAGE_SHIFT, p->prev); if (blk == NULL) return NULL; blk->mem.offset = aligned_page_offset(page); /* set aligned offset */ @@ -229,7 +229,7 @@ __found_pages: /* * check if the given pointer is valid for pages */ -static int is_valid_page(emu10k1_t *emu, dma_addr_t addr) +static int is_valid_page(struct snd_emu10k1 *emu, dma_addr_t addr) { if (addr & ~emu->dma_mask) { snd_printk(KERN_ERR "max memory size is 0x%lx (addr = 0x%lx)!!\n", emu->dma_mask, (unsigned long)addr); @@ -248,12 +248,12 @@ static int is_valid_page(emu10k1_t *emu, dma_addr_t addr) * if no empty pages are found, tries to release unsed memory blocks * and retry the mapping. */ -int snd_emu10k1_memblk_map(emu10k1_t *emu, emu10k1_memblk_t *blk) +int snd_emu10k1_memblk_map(struct snd_emu10k1 *emu, struct snd_emu10k1_memblk *blk) { int err; int size; struct list_head *p, *nextp; - emu10k1_memblk_t *deleted; + struct snd_emu10k1_memblk *deleted; unsigned long flags; spin_lock_irqsave(&emu->memblk_lock, flags); @@ -288,13 +288,13 @@ int snd_emu10k1_memblk_map(emu10k1_t *emu, emu10k1_memblk_t *blk) /* * page allocation for DMA */ -snd_util_memblk_t * -snd_emu10k1_alloc_pages(emu10k1_t *emu, snd_pcm_substream_t *substream) +struct snd_util_memblk * +snd_emu10k1_alloc_pages(struct snd_emu10k1 *emu, struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; struct snd_sg_buf *sgbuf = snd_pcm_substream_sgbuf(substream); - snd_util_memhdr_t *hdr; - emu10k1_memblk_t *blk; + struct snd_util_memhdr *hdr; + struct snd_emu10k1_memblk *blk; int page, err, idx; snd_assert(emu, return NULL); @@ -336,19 +336,19 @@ snd_emu10k1_alloc_pages(emu10k1_t *emu, snd_pcm_substream_t *substream) blk->map_locked = 1; /* do not unmap this block! */ err = snd_emu10k1_memblk_map(emu, blk); if (err < 0) { - __snd_util_mem_free(hdr, (snd_util_memblk_t *)blk); + __snd_util_mem_free(hdr, (struct snd_util_memblk *)blk); up(&hdr->block_mutex); return NULL; } up(&hdr->block_mutex); - return (snd_util_memblk_t *)blk; + return (struct snd_util_memblk *)blk; } /* * release DMA buffer from page table */ -int snd_emu10k1_free_pages(emu10k1_t *emu, snd_util_memblk_t *blk) +int snd_emu10k1_free_pages(struct snd_emu10k1 *emu, struct snd_util_memblk *blk) { snd_assert(emu && blk, return -EINVAL); return snd_emu10k1_synth_free(emu, blk); @@ -363,26 +363,26 @@ int snd_emu10k1_free_pages(emu10k1_t *emu, snd_util_memblk_t *blk) /* * allocate a synth sample area */ -snd_util_memblk_t * -snd_emu10k1_synth_alloc(emu10k1_t *hw, unsigned int size) +struct snd_util_memblk * +snd_emu10k1_synth_alloc(struct snd_emu10k1 *hw, unsigned int size) { - emu10k1_memblk_t *blk; - snd_util_memhdr_t *hdr = hw->memhdr; + struct snd_emu10k1_memblk *blk; + struct snd_util_memhdr *hdr = hw->memhdr; down(&hdr->block_mutex); - blk = (emu10k1_memblk_t *)__snd_util_mem_alloc(hdr, size); + blk = (struct snd_emu10k1_memblk *)__snd_util_mem_alloc(hdr, size); if (blk == NULL) { up(&hdr->block_mutex); return NULL; } if (synth_alloc_pages(hw, blk)) { - __snd_util_mem_free(hdr, (snd_util_memblk_t *)blk); + __snd_util_mem_free(hdr, (struct snd_util_memblk *)blk); up(&hdr->block_mutex); return NULL; } snd_emu10k1_memblk_map(hw, blk); up(&hdr->block_mutex); - return (snd_util_memblk_t *)blk; + return (struct snd_util_memblk *)blk; } @@ -390,10 +390,10 @@ snd_emu10k1_synth_alloc(emu10k1_t *hw, unsigned int size) * free a synth sample area */ int -snd_emu10k1_synth_free(emu10k1_t *emu, snd_util_memblk_t *memblk) +snd_emu10k1_synth_free(struct snd_emu10k1 *emu, struct snd_util_memblk *memblk) { - snd_util_memhdr_t *hdr = emu->memhdr; - emu10k1_memblk_t *blk = (emu10k1_memblk_t *)memblk; + struct snd_util_memhdr *hdr = emu->memhdr; + struct snd_emu10k1_memblk *blk = (struct snd_emu10k1_memblk *)memblk; unsigned long flags; down(&hdr->block_mutex); @@ -409,10 +409,12 @@ snd_emu10k1_synth_free(emu10k1_t *emu, snd_util_memblk_t *memblk) /* check new allocation range */ -static void get_single_page_range(snd_util_memhdr_t *hdr, emu10k1_memblk_t *blk, int *first_page_ret, int *last_page_ret) +static void get_single_page_range(struct snd_util_memhdr *hdr, + struct snd_emu10k1_memblk *blk, + int *first_page_ret, int *last_page_ret) { struct list_head *p; - emu10k1_memblk_t *q; + struct snd_emu10k1_memblk *q; int first_page, last_page; first_page = blk->first_page; if ((p = blk->mem.list.prev) != &hdr->block) { @@ -433,7 +435,7 @@ static void get_single_page_range(snd_util_memhdr_t *hdr, emu10k1_memblk_t *blk, /* * allocate kernel pages */ -static int synth_alloc_pages(emu10k1_t *emu, emu10k1_memblk_t *blk) +static int synth_alloc_pages(struct snd_emu10k1 *emu, struct snd_emu10k1_memblk *blk) { int page, first_page, last_page; struct snd_dma_buffer dmab; @@ -472,7 +474,7 @@ __fail: /* * free pages */ -static int synth_free_pages(emu10k1_t *emu, emu10k1_memblk_t *blk) +static int synth_free_pages(struct snd_emu10k1 *emu, struct snd_emu10k1_memblk *blk) { int page, first_page, last_page; struct snd_dma_buffer dmab; @@ -495,7 +497,7 @@ static int synth_free_pages(emu10k1_t *emu, emu10k1_memblk_t *blk) } /* calculate buffer pointer from offset address */ -static inline void *offset_ptr(emu10k1_t *emu, int page, int offset) +static inline void *offset_ptr(struct snd_emu10k1 *emu, int page, int offset) { char *ptr; snd_assert(page >= 0 && page < emu->max_cache_pages, return NULL); @@ -511,11 +513,12 @@ static inline void *offset_ptr(emu10k1_t *emu, int page, int offset) /* * bzero(blk + offset, size) */ -int snd_emu10k1_synth_bzero(emu10k1_t *emu, snd_util_memblk_t *blk, int offset, int size) +int snd_emu10k1_synth_bzero(struct snd_emu10k1 *emu, struct snd_util_memblk *blk, + int offset, int size) { int page, nextofs, end_offset, temp, temp1; void *ptr; - emu10k1_memblk_t *p = (emu10k1_memblk_t *)blk; + struct snd_emu10k1_memblk *p = (struct snd_emu10k1_memblk *)blk; offset += blk->offset & (PAGE_SIZE - 1); end_offset = offset + size; @@ -538,11 +541,12 @@ int snd_emu10k1_synth_bzero(emu10k1_t *emu, snd_util_memblk_t *blk, int offset, /* * copy_from_user(blk + offset, data, size) */ -int snd_emu10k1_synth_copy_from_user(emu10k1_t *emu, snd_util_memblk_t *blk, int offset, const char __user *data, int size) +int snd_emu10k1_synth_copy_from_user(struct snd_emu10k1 *emu, struct snd_util_memblk *blk, + int offset, const char __user *data, int size) { int page, nextofs, end_offset, temp, temp1; void *ptr; - emu10k1_memblk_t *p = (emu10k1_memblk_t *)blk; + struct snd_emu10k1_memblk *p = (struct snd_emu10k1_memblk *)blk; offset += blk->offset & (PAGE_SIZE - 1); end_offset = offset + size; diff --git a/sound/pci/emu10k1/p16v.c b/sound/pci/emu10k1/p16v.c index e27ebb9bb74..9905651935f 100644 --- a/sound/pci/emu10k1/p16v.c +++ b/sound/pci/emu10k1/p16v.c @@ -93,6 +93,7 @@ #include <linux/interrupt.h> #include <linux/pci.h> #include <linux/slab.h> +#include <linux/vmalloc.h> #include <linux/moduleparam.h> #include <sound/core.h> #include <sound/initval.h> @@ -106,11 +107,11 @@ #define PCM_FRONT_CHANNEL 0 #define PCM_REAR_CHANNEL 1 #define PCM_CENTER_LFE_CHANNEL 2 -#define PCM_UNKNOWN_CHANNEL 3 +#define PCM_SIDE_CHANNEL 3 #define CONTROL_FRONT_CHANNEL 0 #define CONTROL_REAR_CHANNEL 3 #define CONTROL_CENTER_LFE_CHANNEL 1 -#define CONTROL_UNKNOWN_CHANNEL 2 +#define CONTROL_SIDE_CHANNEL 2 /* Card IDs: * Class 0401: 1102:0004 (rev 04) Subsystem: 1102:2002 -> Audigy2 ZS 7.1 Model:SB0350 @@ -121,10 +122,11 @@ */ /* hardware definition */ -static snd_pcm_hardware_t snd_p16v_playback_hw = { +static struct snd_pcm_hardware snd_p16v_playback_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | + SNDRV_PCM_INFO_RESUME | SNDRV_PCM_INFO_MMAP_VALID), .formats = SNDRV_PCM_FMTBIT_S32_LE, /* Only supports 24-bit samples padded to 32 bits. */ .rates = SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_44100, @@ -140,10 +142,11 @@ static snd_pcm_hardware_t snd_p16v_playback_hw = { .fifo_size = 0, }; -static snd_pcm_hardware_t snd_p16v_capture_hw = { +static struct snd_pcm_hardware snd_p16v_capture_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | + SNDRV_PCM_INFO_RESUME | SNDRV_PCM_INFO_MMAP_VALID), .formats = SNDRV_PCM_FMTBIT_S32_LE, .rates = SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_44100, @@ -159,9 +162,9 @@ static snd_pcm_hardware_t snd_p16v_capture_hw = { .fifo_size = 0, }; -static void snd_p16v_pcm_free_substream(snd_pcm_runtime_t *runtime) +static void snd_p16v_pcm_free_substream(struct snd_pcm_runtime *runtime) { - emu10k1_pcm_t *epcm = runtime->private_data; + struct snd_emu10k1_pcm *epcm = runtime->private_data; if (epcm) { //snd_printk("epcm free: %p\n", epcm); @@ -170,12 +173,12 @@ static void snd_p16v_pcm_free_substream(snd_pcm_runtime_t *runtime) } /* open_playback callback */ -static int snd_p16v_pcm_open_playback_channel(snd_pcm_substream_t *substream, int channel_id) +static int snd_p16v_pcm_open_playback_channel(struct snd_pcm_substream *substream, int channel_id) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - emu10k1_voice_t *channel = &(emu->p16v_voices[channel_id]); - emu10k1_pcm_t *epcm; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_emu10k1_voice *channel = &(emu->p16v_voices[channel_id]); + struct snd_emu10k1_pcm *epcm; + struct snd_pcm_runtime *runtime = substream->runtime; int err; epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); @@ -206,12 +209,12 @@ static int snd_p16v_pcm_open_playback_channel(snd_pcm_substream_t *substream, in return 0; } /* open_capture callback */ -static int snd_p16v_pcm_open_capture_channel(snd_pcm_substream_t *substream, int channel_id) +static int snd_p16v_pcm_open_capture_channel(struct snd_pcm_substream *substream, int channel_id) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - emu10k1_voice_t *channel = &(emu->p16v_capture_voice); - emu10k1_pcm_t *epcm; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_emu10k1_voice *channel = &(emu->p16v_capture_voice); + struct snd_emu10k1_pcm *epcm; + struct snd_pcm_runtime *runtime = substream->runtime; int err; epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); @@ -244,41 +247,41 @@ static int snd_p16v_pcm_open_capture_channel(snd_pcm_substream_t *substream, int /* close callback */ -static int snd_p16v_pcm_close_playback(snd_pcm_substream_t *substream) +static int snd_p16v_pcm_close_playback(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - //snd_pcm_runtime_t *runtime = substream->runtime; - //emu10k1_pcm_t *epcm = runtime->private_data; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + //struct snd_pcm_runtime *runtime = substream->runtime; + //struct snd_emu10k1_pcm *epcm = runtime->private_data; emu->p16v_voices[substream->pcm->device - emu->p16v_device_offset].use=0; /* FIXME: maybe zero others */ return 0; } /* close callback */ -static int snd_p16v_pcm_close_capture(snd_pcm_substream_t *substream) +static int snd_p16v_pcm_close_capture(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - //snd_pcm_runtime_t *runtime = substream->runtime; - //emu10k1_pcm_t *epcm = runtime->private_data; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + //struct snd_pcm_runtime *runtime = substream->runtime; + //struct snd_emu10k1_pcm *epcm = runtime->private_data; emu->p16v_capture_voice.use=0; /* FIXME: maybe zero others */ return 0; } -static int snd_p16v_pcm_open_playback_front(snd_pcm_substream_t *substream) +static int snd_p16v_pcm_open_playback_front(struct snd_pcm_substream *substream) { return snd_p16v_pcm_open_playback_channel(substream, PCM_FRONT_CHANNEL); } -static int snd_p16v_pcm_open_capture(snd_pcm_substream_t *substream) +static int snd_p16v_pcm_open_capture(struct snd_pcm_substream *substream) { // Only using channel 0 for now, but the card has 2 channels. return snd_p16v_pcm_open_capture_channel(substream, 0); } /* hw_params callback */ -static int snd_p16v_pcm_hw_params_playback(snd_pcm_substream_t *substream, - snd_pcm_hw_params_t * hw_params) +static int snd_p16v_pcm_hw_params_playback(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { int result; result = snd_pcm_lib_malloc_pages(substream, @@ -287,8 +290,8 @@ static int snd_p16v_pcm_hw_params_playback(snd_pcm_substream_t *substream, } /* hw_params callback */ -static int snd_p16v_pcm_hw_params_capture(snd_pcm_substream_t *substream, - snd_pcm_hw_params_t * hw_params) +static int snd_p16v_pcm_hw_params_capture(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { int result; result = snd_pcm_lib_malloc_pages(substream, @@ -298,7 +301,7 @@ static int snd_p16v_pcm_hw_params_capture(snd_pcm_substream_t *substream, /* hw_free callback */ -static int snd_p16v_pcm_hw_free_playback(snd_pcm_substream_t *substream) +static int snd_p16v_pcm_hw_free_playback(struct snd_pcm_substream *substream) { int result; result = snd_pcm_lib_free_pages(substream); @@ -306,7 +309,7 @@ static int snd_p16v_pcm_hw_free_playback(snd_pcm_substream_t *substream) } /* hw_free callback */ -static int snd_p16v_pcm_hw_free_capture(snd_pcm_substream_t *substream) +static int snd_p16v_pcm_hw_free_capture(struct snd_pcm_substream *substream) { int result; result = snd_pcm_lib_free_pages(substream); @@ -315,10 +318,10 @@ static int snd_p16v_pcm_hw_free_capture(snd_pcm_substream_t *substream) /* prepare playback callback */ -static int snd_p16v_pcm_prepare_playback(snd_pcm_substream_t *substream) +static int snd_p16v_pcm_prepare_playback(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; int channel = substream->pcm->device - emu->p16v_device_offset; u32 *table_base = (u32 *)(emu->p16v_buffer.area+(8*16*channel)); u32 period_size_bytes = frames_to_bytes(runtime, runtime->period_size); @@ -364,10 +367,10 @@ static int snd_p16v_pcm_prepare_playback(snd_pcm_substream_t *substream) } /* prepare capture callback */ -static int snd_p16v_pcm_prepare_capture(snd_pcm_substream_t *substream) +static int snd_p16v_pcm_prepare_capture(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; int channel = substream->pcm->device - emu->p16v_device_offset; u32 tmp; //printk("prepare capture:channel_number=%d, rate=%d, format=0x%x, channels=%d, buffer_size=%ld, period_size=%ld, frames_to_bytes=%d\n",channel, runtime->rate, runtime->format, runtime->channels, runtime->buffer_size, runtime->period_size, frames_to_bytes(runtime, 1)); @@ -398,7 +401,7 @@ static int snd_p16v_pcm_prepare_capture(snd_pcm_substream_t *substream) return 0; } -static void snd_p16v_intr_enable(emu10k1_t *emu, unsigned int intrenb) +static void snd_p16v_intr_enable(struct snd_emu10k1 *emu, unsigned int intrenb) { unsigned long flags; unsigned int enable; @@ -409,7 +412,7 @@ static void snd_p16v_intr_enable(emu10k1_t *emu, unsigned int intrenb) spin_unlock_irqrestore(&emu->emu_lock, flags); } -static void snd_p16v_intr_disable(emu10k1_t *emu, unsigned int intrenb) +static void snd_p16v_intr_disable(struct snd_emu10k1 *emu, unsigned int intrenb) { unsigned long flags; unsigned int disable; @@ -421,16 +424,16 @@ static void snd_p16v_intr_disable(emu10k1_t *emu, unsigned int intrenb) } /* trigger_playback callback */ -static int snd_p16v_pcm_trigger_playback(snd_pcm_substream_t *substream, +static int snd_p16v_pcm_trigger_playback(struct snd_pcm_substream *substream, int cmd) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime; - emu10k1_pcm_t *epcm; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime; + struct snd_emu10k1_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 inte = 0; int running=0; @@ -474,12 +477,12 @@ static int snd_p16v_pcm_trigger_playback(snd_pcm_substream_t *substream, } /* trigger_capture callback */ -static int snd_p16v_pcm_trigger_capture(snd_pcm_substream_t *substream, +static int snd_p16v_pcm_trigger_capture(struct snd_pcm_substream *substream, int cmd) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1_pcm_t *epcm = runtime->private_data; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_emu10k1_pcm *epcm = runtime->private_data; int channel = 0; int result = 0; u32 inte = INTE2_CAPTURE_CH_0_LOOP | INTE2_CAPTURE_CH_0_HALF_LOOP; @@ -505,11 +508,11 @@ static int snd_p16v_pcm_trigger_capture(snd_pcm_substream_t *substream, /* pointer_playback callback */ static snd_pcm_uframes_t -snd_p16v_pcm_pointer_playback(snd_pcm_substream_t *substream) +snd_p16v_pcm_pointer_playback(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1_pcm_t *epcm = runtime->private_data; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_emu10k1_pcm *epcm = runtime->private_data; snd_pcm_uframes_t ptr, ptr1, ptr2,ptr3,ptr4 = 0; int channel = substream->pcm->device - emu->p16v_device_offset; if (!epcm->running) @@ -530,11 +533,11 @@ snd_p16v_pcm_pointer_playback(snd_pcm_substream_t *substream) /* pointer_capture callback */ static snd_pcm_uframes_t -snd_p16v_pcm_pointer_capture(snd_pcm_substream_t *substream) +snd_p16v_pcm_pointer_capture(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1_pcm_t *epcm = runtime->private_data; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_emu10k1_pcm *epcm = runtime->private_data; snd_pcm_uframes_t ptr, ptr1, ptr2 = 0; int channel = 0; @@ -554,7 +557,7 @@ snd_p16v_pcm_pointer_capture(snd_pcm_substream_t *substream) } /* operators */ -static snd_pcm_ops_t snd_p16v_playback_front_ops = { +static struct snd_pcm_ops snd_p16v_playback_front_ops = { .open = snd_p16v_pcm_open_playback_front, .close = snd_p16v_pcm_close_playback, .ioctl = snd_pcm_lib_ioctl, @@ -565,7 +568,7 @@ static snd_pcm_ops_t snd_p16v_playback_front_ops = { .pointer = snd_p16v_pcm_pointer_playback, }; -static snd_pcm_ops_t snd_p16v_capture_ops = { +static struct snd_pcm_ops snd_p16v_capture_ops = { .open = snd_p16v_pcm_open_capture, .close = snd_p16v_pcm_close_capture, .ioctl = snd_pcm_lib_ioctl, @@ -577,7 +580,7 @@ static snd_pcm_ops_t snd_p16v_capture_ops = { }; -int snd_p16v_free(emu10k1_t *chip) +int snd_p16v_free(struct snd_emu10k1 *chip) { // release the data if (chip->p16v_buffer.area) { @@ -587,18 +590,10 @@ int snd_p16v_free(emu10k1_t *chip) return 0; } -static void snd_p16v_pcm_free(snd_pcm_t *pcm) +int __devinit snd_p16v_pcm(struct snd_emu10k1 *emu, int device, struct snd_pcm **rpcm) { - emu10k1_t *emu = pcm->private_data; - //snd_printk("snd_p16v_pcm_free pcm: called\n"); - snd_pcm_lib_preallocate_free_for_all(pcm); - emu->pcm = NULL; -} - -int snd_p16v_pcm(emu10k1_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; int capture=1; @@ -611,7 +606,6 @@ int snd_p16v_pcm(emu10k1_t *emu, int device, snd_pcm_t **rpcm) return err; pcm->private_data = emu; - pcm->private_free = snd_p16v_pcm_free; // Single playback 8 channel device. // Single capture 2 channel device. snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_p16v_playback_front_ops); @@ -620,7 +614,7 @@ int snd_p16v_pcm(emu10k1_t *emu, int device, snd_pcm_t **rpcm) pcm->info_flags = 0; pcm->dev_subclass = SNDRV_PCM_SUBCLASS_GENERIC_MIX; strcpy(pcm->name, "p16v"); - emu->pcm = pcm; + emu->pcm_p16v = pcm; for(substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; @@ -650,7 +644,8 @@ int snd_p16v_pcm(emu10k1_t *emu, int device, snd_pcm_t **rpcm) return 0; } -static int snd_p16v_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_p16v_volume_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; @@ -659,241 +654,57 @@ static int snd_p16v_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * return 0; } -static int snd_p16v_volume_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol, int reg, int high_low) +static int snd_p16v_volume_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); - u32 value; + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); + int high_low = (kcontrol->private_value >> 8) & 0xff; + int reg = kcontrol->private_value & 0xff; + u32 value; - value = snd_emu10k1_ptr20_read(emu, reg, high_low); - if (high_low == 1) { - ucontrol->value.integer.value[0] = 0xff - ((value >> 24) & 0xff); /* Left */ - ucontrol->value.integer.value[1] = 0xff - ((value >> 16) & 0xff); /* Right */ + value = snd_emu10k1_ptr20_read(emu, reg, high_low); + if (high_low) { + ucontrol->value.integer.value[0] = 0xff - ((value >> 24) & 0xff); /* Left */ + ucontrol->value.integer.value[1] = 0xff - ((value >> 16) & 0xff); /* Right */ } else { - ucontrol->value.integer.value[0] = 0xff - ((value >> 8) & 0xff); /* Left */ - ucontrol->value.integer.value[1] = 0xff - ((value >> 0) & 0xff); /* Right */ + ucontrol->value.integer.value[0] = 0xff - ((value >> 8) & 0xff); /* Left */ + ucontrol->value.integer.value[1] = 0xff - ((value >> 0) & 0xff); /* Right */ } - return 0; -} - -static int snd_p16v_volume_get_spdif_front(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) -{ - int high_low = 0; - int reg = PLAYBACK_VOLUME_MIXER7; - return snd_p16v_volume_get(kcontrol, ucontrol, reg, high_low); -} - -static int snd_p16v_volume_get_spdif_center_lfe(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) -{ - int high_low = 1; - int reg = PLAYBACK_VOLUME_MIXER7; - return snd_p16v_volume_get(kcontrol, ucontrol, reg, high_low); -} -static int snd_p16v_volume_get_spdif_unknown(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) -{ - int high_low = 0; - int reg = PLAYBACK_VOLUME_MIXER8; - return snd_p16v_volume_get(kcontrol, ucontrol, reg, high_low); -} -static int snd_p16v_volume_get_spdif_rear(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) -{ - int high_low = 1; - int reg = PLAYBACK_VOLUME_MIXER8; - return snd_p16v_volume_get(kcontrol, ucontrol, reg, high_low); -} - -static int snd_p16v_volume_get_analog_front(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) -{ - int high_low = 0; - int reg = PLAYBACK_VOLUME_MIXER9; - return snd_p16v_volume_get(kcontrol, ucontrol, reg, high_low); -} - -static int snd_p16v_volume_get_analog_center_lfe(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) -{ - int high_low = 1; - int reg = PLAYBACK_VOLUME_MIXER9; - return snd_p16v_volume_get(kcontrol, ucontrol, reg, high_low); -} -static int snd_p16v_volume_get_analog_rear(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) -{ - int high_low = 1; - int reg = PLAYBACK_VOLUME_MIXER10; - return snd_p16v_volume_get(kcontrol, ucontrol, reg, high_low); + return 0; } -static int snd_p16v_volume_get_analog_unknown(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_p16v_volume_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - int high_low = 0; - int reg = PLAYBACK_VOLUME_MIXER10; - return snd_p16v_volume_get(kcontrol, ucontrol, reg, high_low); -} + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); + int high_low = (kcontrol->private_value >> 8) & 0xff; + int reg = kcontrol->private_value & 0xff; + u32 value, oval; -static int snd_p16v_volume_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol, int reg, int high_low) -{ - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); - u32 value; - value = snd_emu10k1_ptr20_read(emu, reg, 0); - //value = value & 0xffff; + oval = value = snd_emu10k1_ptr20_read(emu, reg, 0); if (high_low == 1) { value &= 0xffff; - value = value | ((0xff - ucontrol->value.integer.value[0]) << 24) | ((0xff - ucontrol->value.integer.value[1]) << 16); + value |= ((0xff - ucontrol->value.integer.value[0]) << 24) | + ((0xff - ucontrol->value.integer.value[1]) << 16); } else { value &= 0xffff0000; - value = value | ((0xff - ucontrol->value.integer.value[0]) << 8) | ((0xff - ucontrol->value.integer.value[1]) ); + value |= ((0xff - ucontrol->value.integer.value[0]) << 8) | + ((0xff - ucontrol->value.integer.value[1]) ); } - snd_emu10k1_ptr20_write(emu, reg, 0, value); - return 1; -} - -static int snd_p16v_volume_put_spdif_front(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) -{ - int high_low = 0; - int reg = PLAYBACK_VOLUME_MIXER7; - return snd_p16v_volume_put(kcontrol, ucontrol, reg, high_low); -} - -static int snd_p16v_volume_put_spdif_center_lfe(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) -{ - int high_low = 1; - int reg = PLAYBACK_VOLUME_MIXER7; - return snd_p16v_volume_put(kcontrol, ucontrol, reg, high_low); -} - -static int snd_p16v_volume_put_spdif_unknown(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) -{ - int high_low = 0; - int reg = PLAYBACK_VOLUME_MIXER8; - return snd_p16v_volume_put(kcontrol, ucontrol, reg, high_low); -} - -static int snd_p16v_volume_put_spdif_rear(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) -{ - int high_low = 1; - int reg = PLAYBACK_VOLUME_MIXER8; - return snd_p16v_volume_put(kcontrol, ucontrol, reg, high_low); -} - -static int snd_p16v_volume_put_analog_front(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) -{ - int high_low = 0; - int reg = PLAYBACK_VOLUME_MIXER9; - return snd_p16v_volume_put(kcontrol, ucontrol, reg, high_low); -} - -static int snd_p16v_volume_put_analog_center_lfe(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) -{ - int high_low = 1; - int reg = PLAYBACK_VOLUME_MIXER9; - return snd_p16v_volume_put(kcontrol, ucontrol, reg, high_low); -} - -static int snd_p16v_volume_put_analog_rear(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) -{ - int high_low = 1; - int reg = PLAYBACK_VOLUME_MIXER10; - return snd_p16v_volume_put(kcontrol, ucontrol, reg, high_low); -} - -static int snd_p16v_volume_put_analog_unknown(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) -{ - int high_low = 0; - int reg = PLAYBACK_VOLUME_MIXER10; - return snd_p16v_volume_put(kcontrol, ucontrol, reg, high_low); + if (value != oval) { + snd_emu10k1_ptr20_write(emu, reg, 0, value); + return 1; + } + return 0; } -static snd_kcontrol_new_t snd_p16v_volume_control_analog_front = +static int snd_p16v_capture_source_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "HD Analog Front Playback Volume", - .info = snd_p16v_volume_info, - .get = snd_p16v_volume_get_analog_front, - .put = snd_p16v_volume_put_analog_front -}; - -static snd_kcontrol_new_t snd_p16v_volume_control_analog_center_lfe = -{ - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "HD Analog Center/LFE Playback Volume", - .info = snd_p16v_volume_info, - .get = snd_p16v_volume_get_analog_center_lfe, - .put = snd_p16v_volume_put_analog_center_lfe -}; - -static snd_kcontrol_new_t snd_p16v_volume_control_analog_unknown = -{ - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "HD Analog Unknown Playback Volume", - .info = snd_p16v_volume_info, - .get = snd_p16v_volume_get_analog_unknown, - .put = snd_p16v_volume_put_analog_unknown -}; - -static snd_kcontrol_new_t snd_p16v_volume_control_analog_rear = -{ - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "HD Analog Rear Playback Volume", - .info = snd_p16v_volume_info, - .get = snd_p16v_volume_get_analog_rear, - .put = snd_p16v_volume_put_analog_rear -}; - -static snd_kcontrol_new_t snd_p16v_volume_control_spdif_front = -{ - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "HD SPDIF Front Playback Volume", - .info = snd_p16v_volume_info, - .get = snd_p16v_volume_get_spdif_front, - .put = snd_p16v_volume_put_spdif_front -}; - -static snd_kcontrol_new_t snd_p16v_volume_control_spdif_center_lfe = -{ - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "HD SPDIF Center/LFE Playback Volume", - .info = snd_p16v_volume_info, - .get = snd_p16v_volume_get_spdif_center_lfe, - .put = snd_p16v_volume_put_spdif_center_lfe -}; - -static snd_kcontrol_new_t snd_p16v_volume_control_spdif_unknown = -{ - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "HD SPDIF Unknown Playback Volume", - .info = snd_p16v_volume_info, - .get = snd_p16v_volume_get_spdif_unknown, - .put = snd_p16v_volume_put_spdif_unknown -}; - -static snd_kcontrol_new_t snd_p16v_volume_control_spdif_rear = -{ - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "HD SPDIF Rear Playback Volume", - .info = snd_p16v_volume_info, - .get = snd_p16v_volume_get_spdif_rear, - .put = snd_p16v_volume_put_spdif_rear -}; - -static int snd_p16v_capture_source_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) -{ - static char *texts[8] = { "SPDIF", "I2S", "SRC48", "SRCMulti_SPDIF", "SRCMulti_I2S", "CDIF", "FX", "AC97" }; + static char *texts[8] = { + "SPDIF", "I2S", "SRC48", "SRCMulti_SPDIF", "SRCMulti_I2S", + "CDIF", "FX", "AC97" + }; uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; uinfo->count = 1; @@ -904,19 +715,19 @@ static int snd_p16v_capture_source_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_i return 0; } -static int snd_p16v_capture_source_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_p16v_capture_source_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); ucontrol->value.enumerated.item[0] = emu->p16v_capture_source; return 0; } -static int snd_p16v_capture_source_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_p16v_capture_source_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); unsigned int val; int change = 0; u32 mask; @@ -933,16 +744,8 @@ static int snd_p16v_capture_source_put(snd_kcontrol_t * kcontrol, return change; } -static snd_kcontrol_new_t snd_p16v_capture_source __devinitdata = -{ - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "HD source Capture", - .info = snd_p16v_capture_source_info, - .get = snd_p16v_capture_source_get, - .put = snd_p16v_capture_source_put -}; - -static int snd_p16v_capture_channel_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_p16v_capture_channel_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { static char *texts[4] = { "0", "1", "2", "3", }; @@ -955,19 +758,19 @@ static int snd_p16v_capture_channel_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_ return 0; } -static int snd_p16v_capture_channel_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_p16v_capture_channel_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); ucontrol->value.enumerated.item[0] = emu->p16v_capture_channel; return 0; } -static int snd_p16v_capture_channel_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_p16v_capture_channel_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); unsigned int val; int change = 0; u32 tmp; @@ -982,60 +785,89 @@ static int snd_p16v_capture_channel_put(snd_kcontrol_t * kcontrol, return change; } -static snd_kcontrol_new_t snd_p16v_capture_channel __devinitdata = -{ - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "HD channel Capture", - .info = snd_p16v_capture_channel_info, - .get = snd_p16v_capture_channel_get, - .put = snd_p16v_capture_channel_put +#define P16V_VOL(xname,xreg,xhl) { \ + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ + .info = snd_p16v_volume_info, \ + .get = snd_p16v_volume_get, \ + .put = snd_p16v_volume_put, \ + .private_value = ((xreg) | ((xhl) << 8)) \ +} + +static struct snd_kcontrol_new p16v_mixer_controls[] __devinitdata = { + P16V_VOL("HD Analog Front Playback Volume", PLAYBACK_VOLUME_MIXER9, 0), + P16V_VOL("HD Analog Rear Playback Volume", PLAYBACK_VOLUME_MIXER10, 1), + P16V_VOL("HD Analog Center/LFE Playback Volume", PLAYBACK_VOLUME_MIXER9, 1), + P16V_VOL("HD Analog Side Playback Volume", PLAYBACK_VOLUME_MIXER10, 0), + P16V_VOL("HD SPDIF Front Playback Volume", PLAYBACK_VOLUME_MIXER7, 0), + P16V_VOL("HD SPDIF Rear Playback Volume", PLAYBACK_VOLUME_MIXER8, 1), + P16V_VOL("HD SPDIF Center/LFE Playback Volume", PLAYBACK_VOLUME_MIXER7, 1), + P16V_VOL("HD SPDIF Side Playback Volume", PLAYBACK_VOLUME_MIXER8, 0), + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "HD source Capture", + .info = snd_p16v_capture_source_info, + .get = snd_p16v_capture_source_get, + .put = snd_p16v_capture_source_put + }, + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "HD channel Capture", + .info = snd_p16v_capture_channel_info, + .get = snd_p16v_capture_channel_get, + .put = snd_p16v_capture_channel_put + }, }; -int snd_p16v_mixer(emu10k1_t *emu) + +int __devinit snd_p16v_mixer(struct snd_emu10k1 *emu) { - int err; - snd_kcontrol_t *kctl; - snd_card_t *card = emu->card; - if ((kctl = snd_ctl_new1(&snd_p16v_volume_control_analog_front, emu)) == NULL) - return -ENOMEM; - if ((err = snd_ctl_add(card, kctl))) - return err; - if ((kctl = snd_ctl_new1(&snd_p16v_volume_control_analog_rear, emu)) == NULL) - return -ENOMEM; - if ((err = snd_ctl_add(card, kctl))) - return err; - if ((kctl = snd_ctl_new1(&snd_p16v_volume_control_analog_center_lfe, emu)) == NULL) - return -ENOMEM; - if ((err = snd_ctl_add(card, kctl))) - return err; - if ((kctl = snd_ctl_new1(&snd_p16v_volume_control_analog_unknown, emu)) == NULL) - return -ENOMEM; - if ((err = snd_ctl_add(card, kctl))) - return err; - if ((kctl = snd_ctl_new1(&snd_p16v_volume_control_spdif_front, emu)) == NULL) - return -ENOMEM; - if ((err = snd_ctl_add(card, kctl))) - return err; - if ((kctl = snd_ctl_new1(&snd_p16v_volume_control_spdif_rear, emu)) == NULL) - return -ENOMEM; - if ((err = snd_ctl_add(card, kctl))) - return err; - if ((kctl = snd_ctl_new1(&snd_p16v_volume_control_spdif_center_lfe, emu)) == NULL) - return -ENOMEM; - if ((err = snd_ctl_add(card, kctl))) - return err; - if ((kctl = snd_ctl_new1(&snd_p16v_volume_control_spdif_unknown, emu)) == NULL) - return -ENOMEM; - if ((err = snd_ctl_add(card, kctl))) - return err; - if ((kctl = snd_ctl_new1(&snd_p16v_capture_source, emu)) == NULL) - return -ENOMEM; - if ((err = snd_ctl_add(card, kctl))) - return err; - if ((kctl = snd_ctl_new1(&snd_p16v_capture_channel, emu)) == NULL) - return -ENOMEM; - if ((err = snd_ctl_add(card, kctl))) - return err; + int i, err; + struct snd_card *card = emu->card; + + for (i = 0; i < ARRAY_SIZE(p16v_mixer_controls); i++) { + if ((err = snd_ctl_add(card, snd_ctl_new1(&p16v_mixer_controls[i], + emu))) < 0) + return err; + } return 0; } +#ifdef CONFIG_PM + +#define NUM_CHS 1 /* up to 4, but only first channel is used */ + +int __devinit snd_p16v_alloc_pm_buffer(struct snd_emu10k1 *emu) +{ + emu->p16v_saved = vmalloc(NUM_CHS * 4 * 0x80); + if (! emu->p16v_saved) + return -ENOMEM; + return 0; +} + +void snd_p16v_free_pm_buffer(struct snd_emu10k1 *emu) +{ + vfree(emu->p16v_saved); +} + +void snd_p16v_suspend(struct snd_emu10k1 *emu) +{ + int i, ch; + unsigned int *val; + + val = emu->p16v_saved; + for (ch = 0; ch < NUM_CHS; ch++) + for (i = 0; i < 0x80; i++, val++) + *val = snd_emu10k1_ptr20_read(emu, i, ch); +} + +void snd_p16v_resume(struct snd_emu10k1 *emu) +{ + int i, ch; + unsigned int *val; + + val = emu->p16v_saved; + for (ch = 0; ch < NUM_CHS; ch++) + for (i = 0; i < 0x80; i++, val++) + snd_emu10k1_ptr20_write(emu, i, ch, *val); +} +#endif diff --git a/sound/pci/emu10k1/timer.c b/sound/pci/emu10k1/timer.c index d2e364607c1..6295b2dca78 100644 --- a/sound/pci/emu10k1/timer.c +++ b/sound/pci/emu10k1/timer.c @@ -30,9 +30,9 @@ #include <sound/core.h> #include <sound/emu10k1.h> -static int snd_emu10k1_timer_start(snd_timer_t *timer) +static int snd_emu10k1_timer_start(struct snd_timer *timer) { - emu10k1_t *emu; + struct snd_emu10k1 *emu; unsigned long flags; unsigned int delay; @@ -47,9 +47,9 @@ static int snd_emu10k1_timer_start(snd_timer_t *timer) return 0; } -static int snd_emu10k1_timer_stop(snd_timer_t *timer) +static int snd_emu10k1_timer_stop(struct snd_timer *timer) { - emu10k1_t *emu; + struct snd_emu10k1 *emu; unsigned long flags; emu = snd_timer_chip(timer); @@ -59,7 +59,7 @@ static int snd_emu10k1_timer_stop(snd_timer_t *timer) return 0; } -static int snd_emu10k1_timer_precise_resolution(snd_timer_t *timer, +static int snd_emu10k1_timer_precise_resolution(struct snd_timer *timer, unsigned long *num, unsigned long *den) { *num = 1; @@ -67,7 +67,7 @@ static int snd_emu10k1_timer_precise_resolution(snd_timer_t *timer, return 0; } -static struct _snd_timer_hardware snd_emu10k1_timer_hw = { +static struct snd_timer_hardware snd_emu10k1_timer_hw = { .flags = SNDRV_TIMER_HW_AUTO, .resolution = 20833, /* 1 sample @ 48KHZ = 20.833...us */ .ticks = 1024, @@ -76,10 +76,10 @@ static struct _snd_timer_hardware snd_emu10k1_timer_hw = { .precise_resolution = snd_emu10k1_timer_precise_resolution, }; -int __devinit snd_emu10k1_timer(emu10k1_t *emu, int device) +int __devinit snd_emu10k1_timer(struct snd_emu10k1 *emu, int device) { - snd_timer_t *timer = NULL; - snd_timer_id_t tid; + struct snd_timer *timer = NULL; + struct snd_timer_id tid; int err; tid.dev_class = SNDRV_TIMER_CLASS_CARD; diff --git a/sound/pci/emu10k1/tina2.h b/sound/pci/emu10k1/tina2.h new file mode 100644 index 00000000000..5c43abf03e8 --- /dev/null +++ b/sound/pci/emu10k1/tina2.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) by James Courtier-Dutton <James@superbug.demon.co.uk> + * Driver p16v chips + * Version: 0.21 + * + * + * This code was initally based on code from ALSA's emu10k1x.c which is: + * Copyright (c) by Francisco Moraes <fmoraes@nc.rr.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +/********************************************************************************************************/ +/* Audigy2 Tina2 (notebook) pointer-offset register set, accessed through the PTR2 and DATA2 registers */ +/********************************************************************************************************/ + +#define TINA2_VOLUME 0x71 /* Attenuate playback volume to prevent distortion. */ + /* The windows driver does not use this register, + * so it must use some other attenuation method. + * Without this, the output is 12dB too loud, + * resulting in distortion. + */ + diff --git a/sound/pci/emu10k1/voice.c b/sound/pci/emu10k1/voice.c index d251d3440ee..56ffb7dc3ee 100644 --- a/sound/pci/emu10k1/voice.c +++ b/sound/pci/emu10k1/voice.c @@ -45,9 +45,10 @@ * --rlrevell */ -static int voice_alloc(emu10k1_t *emu, emu10k1_voice_type_t type, int number, emu10k1_voice_t **rvoice) +static int voice_alloc(struct snd_emu10k1 *emu, int type, int number, + struct snd_emu10k1_voice **rvoice) { - emu10k1_voice_t *voice; + struct snd_emu10k1_voice *voice; int i, j, k, first_voice, last_voice, skip; *rvoice = NULL; @@ -105,7 +106,8 @@ static int voice_alloc(emu10k1_t *emu, emu10k1_voice_type_t type, int number, em return 0; } -int snd_emu10k1_voice_alloc(emu10k1_t *emu, emu10k1_voice_type_t type, int number, emu10k1_voice_t **rvoice) +int snd_emu10k1_voice_alloc(struct snd_emu10k1 *emu, int type, int number, + struct snd_emu10k1_voice **rvoice) { unsigned long flags; int result; @@ -123,7 +125,7 @@ int snd_emu10k1_voice_alloc(emu10k1_t *emu, emu10k1_voice_type_t type, int numbe if (emu->get_synth_voice) { result = emu->get_synth_voice(emu); if (result >= 0) { - emu10k1_voice_t *pvoice = &emu->voices[result]; + struct snd_emu10k1_voice *pvoice = &emu->voices[result]; pvoice->interrupt = NULL; pvoice->use = pvoice->pcm = pvoice->synth = pvoice->midi = pvoice->efx = 0; pvoice->epcm = NULL; @@ -137,7 +139,8 @@ int snd_emu10k1_voice_alloc(emu10k1_t *emu, emu10k1_voice_type_t type, int numbe return result; } -int snd_emu10k1_voice_free(emu10k1_t *emu, emu10k1_voice_t *pvoice) +int snd_emu10k1_voice_free(struct snd_emu10k1 *emu, + struct snd_emu10k1_voice *pvoice) { unsigned long flags; |