X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=sound%2Fparisc%2Fharmony.c;h=cf603337b321d01bba027480e29fc5abbe593b98;hb=463020ce428e2f00d4f33a383d6f39c7453a6854;hp=d833349ed5185a5aba5334fa87d9ea710231e777;hpb=c7fb577e2a6cb04732541f2dc402bd46747f7558;p=powerpc.git diff --git a/sound/parisc/harmony.c b/sound/parisc/harmony.c index d833349ed5..cf603337b3 100644 --- a/sound/parisc/harmony.c +++ b/sound/parisc/harmony.c @@ -59,6 +59,14 @@ #include "harmony.h" +static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */ +static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */ +module_param(index, int, 0444); +MODULE_PARM_DESC(index, "Index value for Harmony driver."); +module_param(id, charp, 0444); +MODULE_PARM_DESC(id, "ID string for Harmony driver."); + + static struct parisc_device_id snd_harmony_devtable[] = { /* bushmaster / flounder */ { HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x0007A }, @@ -91,32 +99,32 @@ static unsigned int rate_bits[14] = { HARMONY_SR_44KHZ, HARMONY_SR_48KHZ }; -static snd_pcm_hw_constraint_list_t hw_constraint_rates = { +static struct snd_pcm_hw_constraint_list hw_constraint_rates = { .count = ARRAY_SIZE(snd_harmony_rates), .list = snd_harmony_rates, .mask = 0, }; -inline unsigned long -harmony_read(harmony_t *h, unsigned r) +static inline unsigned long +harmony_read(struct snd_harmony *h, unsigned r) { return __raw_readl(h->iobase + r); } -inline void -harmony_write(harmony_t *h, unsigned r, unsigned long v) +static inline void +harmony_write(struct snd_harmony *h, unsigned r, unsigned long v) { __raw_writel(v, h->iobase + r); } -static void -harmony_wait_for_control(harmony_t *h) +static inline void +harmony_wait_for_control(struct snd_harmony *h) { while (harmony_read(h, HARMONY_CNTL) & HARMONY_CNTL_C) ; } -inline void -harmony_reset(harmony_t *h) +static inline void +harmony_reset(struct snd_harmony *h) { harmony_write(h, HARMONY_RESET, 1); mdelay(50); @@ -124,7 +132,7 @@ harmony_reset(harmony_t *h) } static void -harmony_disable_interrupts(harmony_t *h) +harmony_disable_interrupts(struct snd_harmony *h) { u32 dstatus; harmony_wait_for_control(h); @@ -134,7 +142,7 @@ harmony_disable_interrupts(harmony_t *h) } static void -harmony_enable_interrupts(harmony_t *h) +harmony_enable_interrupts(struct snd_harmony *h) { u32 dstatus; harmony_wait_for_control(h); @@ -144,7 +152,7 @@ harmony_enable_interrupts(harmony_t *h) } static void -harmony_mute(harmony_t *h) +harmony_mute(struct snd_harmony *h) { unsigned long flags; @@ -155,7 +163,7 @@ harmony_mute(harmony_t *h) } static void -harmony_unmute(harmony_t *h) +harmony_unmute(struct snd_harmony *h) { unsigned long flags; @@ -166,7 +174,7 @@ harmony_unmute(harmony_t *h) } static void -harmony_set_control(harmony_t *h) +harmony_set_control(struct snd_harmony *h) { u32 ctrl; unsigned long flags; @@ -185,10 +193,10 @@ harmony_set_control(harmony_t *h) } static irqreturn_t -snd_harmony_interrupt(int irq, void *dev, struct pt_regs *regs) +snd_harmony_interrupt(int irq, void *dev) { u32 dstatus; - harmony_t *h = dev; + struct snd_harmony *h = dev; spin_lock(&h->lock); harmony_disable_interrupts(h); @@ -253,7 +261,7 @@ snd_harmony_rate_bits(int rate) return HARMONY_SR_44KHZ; } -static snd_pcm_hardware_t snd_harmony_playback = +static struct snd_pcm_hardware snd_harmony_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_JOINT_DUPLEX | SNDRV_PCM_INFO_MMAP_VALID | @@ -274,7 +282,7 @@ static snd_pcm_hardware_t snd_harmony_playback = .fifo_size = 0, }; -static snd_pcm_hardware_t snd_harmony_capture = +static struct snd_pcm_hardware snd_harmony_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_JOINT_DUPLEX | SNDRV_PCM_INFO_MMAP_VALID | @@ -296,15 +304,14 @@ static snd_pcm_hardware_t snd_harmony_capture = }; static int -snd_harmony_playback_trigger(snd_pcm_substream_t *ss, int cmd) +snd_harmony_playback_trigger(struct snd_pcm_substream *ss, int cmd) { - harmony_t *h = snd_pcm_substream_chip(ss); - unsigned long flags; + struct snd_harmony *h = snd_pcm_substream_chip(ss); if (h->st.capturing) return -EBUSY; - spin_lock_irqsave(&h->lock, flags); + spin_lock(&h->lock); switch (cmd) { case SNDRV_PCM_TRIGGER_START: h->st.playing = 1; @@ -323,25 +330,24 @@ snd_harmony_playback_trigger(snd_pcm_substream_t *ss, int cmd) case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: case SNDRV_PCM_TRIGGER_SUSPEND: default: - spin_unlock_irqrestore(&h->lock, flags); + spin_unlock(&h->lock); snd_BUG(); return -EINVAL; } - spin_unlock_irqrestore(&h->lock, flags); + spin_unlock(&h->lock); return 0; } static int -snd_harmony_capture_trigger(snd_pcm_substream_t *ss, int cmd) +snd_harmony_capture_trigger(struct snd_pcm_substream *ss, int cmd) { - harmony_t *h = snd_pcm_substream_chip(ss); - unsigned long flags; + struct snd_harmony *h = snd_pcm_substream_chip(ss); if (h->st.playing) return -EBUSY; - spin_lock_irqsave(&h->lock, flags); + spin_lock(&h->lock); switch (cmd) { case SNDRV_PCM_TRIGGER_START: h->st.capturing = 1; @@ -360,17 +366,17 @@ snd_harmony_capture_trigger(snd_pcm_substream_t *ss, int cmd) case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: case SNDRV_PCM_TRIGGER_SUSPEND: default: - spin_unlock_irqrestore(&h->lock, flags); + spin_unlock(&h->lock); snd_BUG(); return -EINVAL; } - spin_unlock_irqrestore(&h->lock, flags); + spin_unlock(&h->lock); return 0; } static int -snd_harmony_set_data_format(harmony_t *h, int fmt, int force) +snd_harmony_set_data_format(struct snd_harmony *h, int fmt, int force) { int o = h->st.format; int n; @@ -400,10 +406,10 @@ snd_harmony_set_data_format(harmony_t *h, int fmt, int force) } static int -snd_harmony_playback_prepare(snd_pcm_substream_t *ss) +snd_harmony_playback_prepare(struct snd_pcm_substream *ss) { - harmony_t *h = snd_pcm_substream_chip(ss); - snd_pcm_runtime_t *rt = ss->runtime; + struct snd_harmony *h = snd_pcm_substream_chip(ss); + struct snd_pcm_runtime *rt = ss->runtime; if (h->st.capturing) return -EBUSY; @@ -430,10 +436,10 @@ snd_harmony_playback_prepare(snd_pcm_substream_t *ss) } static int -snd_harmony_capture_prepare(snd_pcm_substream_t *ss) +snd_harmony_capture_prepare(struct snd_pcm_substream *ss) { - harmony_t *h = snd_pcm_substream_chip(ss); - snd_pcm_runtime_t *rt = ss->runtime; + struct snd_harmony *h = snd_pcm_substream_chip(ss); + struct snd_pcm_runtime *rt = ss->runtime; if (h->st.playing) return -EBUSY; @@ -460,10 +466,10 @@ snd_harmony_capture_prepare(snd_pcm_substream_t *ss) } static snd_pcm_uframes_t -snd_harmony_playback_pointer(snd_pcm_substream_t *ss) +snd_harmony_playback_pointer(struct snd_pcm_substream *ss) { - snd_pcm_runtime_t *rt = ss->runtime; - harmony_t *h = snd_pcm_substream_chip(ss); + struct snd_pcm_runtime *rt = ss->runtime; + struct snd_harmony *h = snd_pcm_substream_chip(ss); unsigned long pcuradd; unsigned long played; @@ -489,10 +495,10 @@ snd_harmony_playback_pointer(snd_pcm_substream_t *ss) } static snd_pcm_uframes_t -snd_harmony_capture_pointer(snd_pcm_substream_t *ss) +snd_harmony_capture_pointer(struct snd_pcm_substream *ss) { - snd_pcm_runtime_t *rt = ss->runtime; - harmony_t *h = snd_pcm_substream_chip(ss); + struct snd_pcm_runtime *rt = ss->runtime; + struct snd_harmony *h = snd_pcm_substream_chip(ss); unsigned long rcuradd; unsigned long caught; @@ -518,10 +524,10 @@ snd_harmony_capture_pointer(snd_pcm_substream_t *ss) } static int -snd_harmony_playback_open(snd_pcm_substream_t *ss) +snd_harmony_playback_open(struct snd_pcm_substream *ss) { - harmony_t *h = snd_pcm_substream_chip(ss); - snd_pcm_runtime_t *rt = ss->runtime; + struct snd_harmony *h = snd_pcm_substream_chip(ss); + struct snd_pcm_runtime *rt = ss->runtime; int err; h->psubs = ss; @@ -537,10 +543,10 @@ snd_harmony_playback_open(snd_pcm_substream_t *ss) } static int -snd_harmony_capture_open(snd_pcm_substream_t *ss) +snd_harmony_capture_open(struct snd_pcm_substream *ss) { - harmony_t *h = snd_pcm_substream_chip(ss); - snd_pcm_runtime_t *rt = ss->runtime; + struct snd_harmony *h = snd_pcm_substream_chip(ss); + struct snd_pcm_runtime *rt = ss->runtime; int err; h->csubs = ss; @@ -556,27 +562,27 @@ snd_harmony_capture_open(snd_pcm_substream_t *ss) } static int -snd_harmony_playback_close(snd_pcm_substream_t *ss) +snd_harmony_playback_close(struct snd_pcm_substream *ss) { - harmony_t *h = snd_pcm_substream_chip(ss); + struct snd_harmony *h = snd_pcm_substream_chip(ss); h->psubs = NULL; return 0; } static int -snd_harmony_capture_close(snd_pcm_substream_t *ss) +snd_harmony_capture_close(struct snd_pcm_substream *ss) { - harmony_t *h = snd_pcm_substream_chip(ss); + struct snd_harmony *h = snd_pcm_substream_chip(ss); h->csubs = NULL; return 0; } static int -snd_harmony_hw_params(snd_pcm_substream_t *ss, - snd_pcm_hw_params_t *hw) +snd_harmony_hw_params(struct snd_pcm_substream *ss, + struct snd_pcm_hw_params *hw) { int err; - harmony_t *h = snd_pcm_substream_chip(ss); + struct snd_harmony *h = snd_pcm_substream_chip(ss); err = snd_pcm_lib_malloc_pages(ss, params_buffer_bytes(hw)); if (err > 0 && h->dma.type == SNDRV_DMA_TYPE_CONTINUOUS) @@ -586,12 +592,12 @@ snd_harmony_hw_params(snd_pcm_substream_t *ss, } static int -snd_harmony_hw_free(snd_pcm_substream_t *ss) +snd_harmony_hw_free(struct snd_pcm_substream *ss) { return snd_pcm_lib_free_pages(ss); } -static snd_pcm_ops_t snd_harmony_playback_ops = { +static struct snd_pcm_ops snd_harmony_playback_ops = { .open = snd_harmony_playback_open, .close = snd_harmony_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -602,7 +608,7 @@ static snd_pcm_ops_t snd_harmony_playback_ops = { .pointer = snd_harmony_playback_pointer, }; -static snd_pcm_ops_t snd_harmony_capture_ops = { +static struct snd_pcm_ops snd_harmony_capture_ops = { .open = snd_harmony_capture_open, .close = snd_harmony_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -614,9 +620,9 @@ static snd_pcm_ops_t snd_harmony_capture_ops = { }; static int -snd_harmony_pcm_init(harmony_t *h) +snd_harmony_pcm_init(struct snd_harmony *h) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; harmony_disable_interrupts(h); @@ -677,15 +683,15 @@ snd_harmony_pcm_init(harmony_t *h) } static void -snd_harmony_set_new_gain(harmony_t *h) +snd_harmony_set_new_gain(struct snd_harmony *h) { harmony_wait_for_control(h); harmony_write(h, HARMONY_GAINCTL, h->st.gain); } static int -snd_harmony_mixercontrol_info(snd_kcontrol_t *kc, - snd_ctl_elem_info_t *uinfo) +snd_harmony_mixercontrol_info(struct snd_kcontrol *kc, + struct snd_ctl_elem_info *uinfo) { int mask = (kc->private_value >> 16) & 0xff; int left_shift = (kc->private_value) & 0xff; @@ -701,18 +707,17 @@ snd_harmony_mixercontrol_info(snd_kcontrol_t *kc, } static int -snd_harmony_volume_get(snd_kcontrol_t *kc, - snd_ctl_elem_value_t *ucontrol) +snd_harmony_volume_get(struct snd_kcontrol *kc, + struct snd_ctl_elem_value *ucontrol) { - harmony_t *h = snd_kcontrol_chip(kc); + struct snd_harmony *h = snd_kcontrol_chip(kc); int shift_left = (kc->private_value) & 0xff; int shift_right = (kc->private_value >> 8) & 0xff; int mask = (kc->private_value >> 16) & 0xff; int invert = (kc->private_value >> 24) & 0xff; int left, right; - unsigned long flags; - spin_lock_irqsave(&h->mixer_lock, flags); + spin_lock_irq(&h->mixer_lock); left = (h->st.gain >> shift_left) & mask; right = (h->st.gain >> shift_right) & mask; @@ -725,25 +730,24 @@ snd_harmony_volume_get(snd_kcontrol_t *kc, if (shift_left != shift_right) ucontrol->value.integer.value[1] = right; - spin_unlock_irqrestore(&h->mixer_lock, flags); + spin_unlock_irq(&h->mixer_lock); return 0; } static int -snd_harmony_volume_put(snd_kcontrol_t *kc, - snd_ctl_elem_value_t *ucontrol) +snd_harmony_volume_put(struct snd_kcontrol *kc, + struct snd_ctl_elem_value *ucontrol) { - harmony_t *h = snd_kcontrol_chip(kc); + struct snd_harmony *h = snd_kcontrol_chip(kc); int shift_left = (kc->private_value) & 0xff; int shift_right = (kc->private_value >> 8) & 0xff; int mask = (kc->private_value >> 16) & 0xff; int invert = (kc->private_value >> 24) & 0xff; int left, right; int old_gain = h->st.gain; - unsigned long flags; - spin_lock_irqsave(&h->mixer_lock, flags); + spin_lock_irq(&h->mixer_lock); left = ucontrol->value.integer.value[0] & mask; if (invert) @@ -761,14 +765,14 @@ snd_harmony_volume_put(snd_kcontrol_t *kc, snd_harmony_set_new_gain(h); - spin_unlock_irqrestore(&h->mixer_lock, flags); + spin_unlock_irq(&h->mixer_lock); return h->st.gain != old_gain; } static int -snd_harmony_captureroute_info(snd_kcontrol_t *kc, - snd_ctl_elem_info_t *uinfo) +snd_harmony_captureroute_info(struct snd_kcontrol *kc, + struct snd_ctl_elem_info *uinfo) { static char *texts[2] = { "Line", "Mic" }; uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; @@ -782,33 +786,31 @@ snd_harmony_captureroute_info(snd_kcontrol_t *kc, } static int -snd_harmony_captureroute_get(snd_kcontrol_t *kc, - snd_ctl_elem_value_t *ucontrol) +snd_harmony_captureroute_get(struct snd_kcontrol *kc, + struct snd_ctl_elem_value *ucontrol) { - harmony_t *h = snd_kcontrol_chip(kc); + struct snd_harmony *h = snd_kcontrol_chip(kc); int value; - unsigned long flags; - spin_lock_irqsave(&h->mixer_lock, flags); + spin_lock_irq(&h->mixer_lock); value = (h->st.gain >> HARMONY_GAIN_IS_SHIFT) & 1; ucontrol->value.enumerated.item[0] = value; - spin_unlock_irqrestore(&h->mixer_lock, flags); + spin_unlock_irq(&h->mixer_lock); return 0; } static int -snd_harmony_captureroute_put(snd_kcontrol_t *kc, - snd_ctl_elem_value_t *ucontrol) +snd_harmony_captureroute_put(struct snd_kcontrol *kc, + struct snd_ctl_elem_value *ucontrol) { - harmony_t *h = snd_kcontrol_chip(kc); + struct snd_harmony *h = snd_kcontrol_chip(kc); int value; int old_gain = h->st.gain; - unsigned long flags; - spin_lock_irqsave(&h->mixer_lock, flags); + spin_lock_irq(&h->mixer_lock); value = ucontrol->value.enumerated.item[0] & 1; h->st.gain &= ~HARMONY_GAIN_IS_MASK; @@ -816,13 +818,12 @@ snd_harmony_captureroute_put(snd_kcontrol_t *kc, snd_harmony_set_new_gain(h); - spin_unlock_irqrestore(&h->mixer_lock, flags); + spin_unlock_irq(&h->mixer_lock); return h->st.gain != old_gain; } -#define HARMONY_CONTROLS (sizeof(snd_harmony_controls)/ \ - sizeof(snd_kcontrol_new_t)) +#define HARMONY_CONTROLS ARRAY_SIZE(snd_harmony_controls) #define HARMONY_VOLUME(xname, left_shift, right_shift, mask, invert) \ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ @@ -831,7 +832,7 @@ snd_harmony_captureroute_put(snd_kcontrol_t *kc, .private_value = ((left_shift) | ((right_shift) << 8) | \ ((mask) << 16) | ((invert) << 24)) } -static snd_kcontrol_new_t snd_harmony_controls[] = { +static struct snd_kcontrol_new snd_harmony_controls[] = { HARMONY_VOLUME("Master Playback Volume", HARMONY_GAIN_LO_SHIFT, HARMONY_GAIN_RO_SHIFT, HARMONY_GAIN_OUT, 1), HARMONY_VOLUME("Capture Volume", HARMONY_GAIN_LI_SHIFT, @@ -854,7 +855,7 @@ static snd_kcontrol_new_t snd_harmony_controls[] = { }; static void __init -snd_harmony_mixer_reset(harmony_t *h) +snd_harmony_mixer_reset(struct snd_harmony *h) { harmony_mute(h); harmony_reset(h); @@ -863,9 +864,9 @@ snd_harmony_mixer_reset(harmony_t *h) } static int __init -snd_harmony_mixer_init(harmony_t *h) +snd_harmony_mixer_init(struct snd_harmony *h) { - snd_card_t *card = h->card; + struct snd_card *card = h->card; int idx, err; snd_assert(h != NULL, return -EINVAL); @@ -884,7 +885,7 @@ snd_harmony_mixer_init(harmony_t *h) } static int -snd_harmony_free(harmony_t *h) +snd_harmony_free(struct snd_harmony *h) { if (h->gdma.addr) snd_dma_free_pages(&h->gdma); @@ -904,38 +905,33 @@ snd_harmony_free(harmony_t *h) } static int -snd_harmony_dev_free(snd_device_t *dev) +snd_harmony_dev_free(struct snd_device *dev) { - harmony_t *h = dev->device_data; + struct snd_harmony *h = dev->device_data; return snd_harmony_free(h); } static int __devinit -snd_harmony_create(snd_card_t *card, +snd_harmony_create(struct snd_card *card, struct parisc_device *padev, - harmony_t **rchip) + struct snd_harmony **rchip) { int err; - harmony_t *h; - static snd_device_ops_t ops = { + struct snd_harmony *h; + static struct snd_device_ops ops = { .dev_free = snd_harmony_dev_free, }; *rchip = NULL; - h = kmalloc(sizeof(*h), GFP_KERNEL); + h = kzalloc(sizeof(*h), GFP_KERNEL); if (h == NULL) return -ENOMEM; - memset(&h->st, 0, sizeof(h->st)); - memset(&h->stats, 0, sizeof(h->stats)); - memset(&h->pbuf, 0, sizeof(h->pbuf)); - memset(&h->cbuf, 0, sizeof(h->cbuf)); - h->hpa = padev->hpa.start; h->card = card; h->dev = padev; - h->irq = padev->irq; + h->irq = -1; h->iobase = ioremap_nocache(padev->hpa.start, HARMONY_SIZE); if (h->iobase == NULL) { printk(KERN_ERR PFX "unable to remap hpa 0x%lx\n", @@ -944,13 +940,14 @@ snd_harmony_create(snd_card_t *card, goto free_and_ret; } - err = request_irq(h->irq, snd_harmony_interrupt, 0, + err = request_irq(padev->irq, snd_harmony_interrupt, 0, "harmony", h); if (err) { printk(KERN_ERR PFX "could not obtain interrupt %d", - h->irq); + padev->irq); goto free_and_ret; } + h->irq = padev->irq; spin_lock_init(&h->mixer_lock); spin_lock_init(&h->lock); @@ -975,35 +972,24 @@ static int __devinit snd_harmony_probe(struct parisc_device *padev) { int err; - static int dev; - snd_card_t *card; - harmony_t *h; - static int index = SNDRV_DEFAULT_IDX1; - static char *id = SNDRV_DEFAULT_STR1; - - h = parisc_get_drvdata(padev); - if (h != NULL) { - return -ENODEV; - } + struct snd_card *card; + struct snd_harmony *h; card = snd_card_new(index, id, THIS_MODULE, 0); if (card == NULL) return -ENOMEM; err = snd_harmony_create(card, padev, &h); - if (err < 0) { + if (err < 0) goto free_and_ret; - } err = snd_harmony_pcm_init(h); - if (err < 0) { + if (err < 0) goto free_and_ret; - } err = snd_harmony_mixer_init(h); - if (err < 0) { + if (err < 0) goto free_and_ret; - } strcpy(card->driver, "harmony"); strcpy(card->shortname, "Harmony"); @@ -1011,13 +997,10 @@ snd_harmony_probe(struct parisc_device *padev) card->shortname, h->hpa, h->irq); err = snd_card_register(card); - if (err < 0) { + if (err < 0) goto free_and_ret; - } - - dev++; - parisc_set_drvdata(padev, h); + parisc_set_drvdata(padev, card); return 0; free_and_ret: @@ -1028,8 +1011,8 @@ free_and_ret: static int __devexit snd_harmony_remove(struct parisc_device *padev) { - harmony_t *h = parisc_get_drvdata(padev); - snd_card_free(h->card); + snd_card_free(parisc_get_drvdata(padev)); + parisc_set_drvdata(padev, NULL); return 0; } @@ -1043,28 +1026,13 @@ static struct parisc_driver snd_harmony_driver = { static int __init alsa_harmony_init(void) { - int err; - - err = register_parisc_driver(&snd_harmony_driver); - if (err < 0) { - printk(KERN_ERR PFX "device not found\n"); - return err; - } - - return 0; + return register_parisc_driver(&snd_harmony_driver); } static void __exit alsa_harmony_fini(void) { - int err; - - err = unregister_parisc_driver(&snd_harmony_driver); - if (err < 0) { - printk(KERN_ERR PFX "failed to unregister\n"); - } - - return; + unregister_parisc_driver(&snd_harmony_driver); } MODULE_LICENSE("GPL");