2005-11-17 02:12:23 -07:00
|
|
|
/*
|
2006-04-28 06:34:49 -06:00
|
|
|
* Driver for audio on multifunction CS5535/6 companion device
|
2005-11-17 02:12:23 -07:00
|
|
|
* Copyright (C) Jaya Kumar
|
|
|
|
*
|
|
|
|
* Based on Jaroslav Kysela and Takashi Iwai's examples.
|
|
|
|
* This work was sponsored by CIS(M) Sdn Bhd.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <linux/slab.h>
|
2011-07-15 11:13:37 -06:00
|
|
|
#include <linux/module.h>
|
2005-11-17 02:12:23 -07:00
|
|
|
#include <asm/io.h>
|
|
|
|
#include <sound/core.h>
|
|
|
|
#include <sound/control.h>
|
|
|
|
#include <sound/pcm.h>
|
|
|
|
#include <sound/rawmidi.h>
|
|
|
|
#include <sound/ac97_codec.h>
|
|
|
|
#include <sound/initval.h>
|
|
|
|
#include <sound/asoundef.h>
|
|
|
|
#include "cs5535audio.h"
|
|
|
|
|
|
|
|
#define DRIVER_NAME "cs5535audio"
|
|
|
|
|
2006-04-28 06:34:49 -06:00
|
|
|
static char *ac97_quirk;
|
|
|
|
module_param(ac97_quirk, charp, 0444);
|
|
|
|
MODULE_PARM_DESC(ac97_quirk, "AC'97 board specific workarounds.");
|
|
|
|
|
|
|
|
static struct ac97_quirk ac97_quirks[] __devinitdata = {
|
|
|
|
#if 0 /* Not yet confirmed if all 5536 boards are HP only */
|
|
|
|
{
|
|
|
|
.subvendor = PCI_VENDOR_ID_AMD,
|
|
|
|
.subdevice = PCI_DEVICE_ID_AMD_CS5536_AUDIO,
|
|
|
|
.name = "AMD RDK",
|
|
|
|
.type = AC97_TUNE_HP_ONLY
|
|
|
|
},
|
|
|
|
#endif
|
|
|
|
{}
|
|
|
|
};
|
2005-11-17 02:12:23 -07:00
|
|
|
|
2006-05-23 05:24:30 -06:00
|
|
|
static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
|
|
|
|
static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
|
2011-12-14 20:19:36 -07:00
|
|
|
static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
|
2005-11-17 02:12:23 -07:00
|
|
|
|
2006-05-23 05:24:30 -06:00
|
|
|
module_param_array(index, int, NULL, 0444);
|
2006-05-02 10:31:31 -06:00
|
|
|
MODULE_PARM_DESC(index, "Index value for " DRIVER_NAME);
|
2006-05-23 05:24:30 -06:00
|
|
|
module_param_array(id, charp, NULL, 0444);
|
2006-05-02 10:31:31 -06:00
|
|
|
MODULE_PARM_DESC(id, "ID string for " DRIVER_NAME);
|
2006-05-23 05:24:30 -06:00
|
|
|
module_param_array(enable, bool, NULL, 0444);
|
|
|
|
MODULE_PARM_DESC(enable, "Enable " DRIVER_NAME);
|
2006-05-02 10:31:31 -06:00
|
|
|
|
2010-02-05 15:21:03 -07:00
|
|
|
static DEFINE_PCI_DEVICE_TABLE(snd_cs5535audio_ids) = {
|
2006-04-28 06:34:49 -06:00
|
|
|
{ PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_CS5535_AUDIO) },
|
|
|
|
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_AUDIO) },
|
2005-11-17 02:12:23 -07:00
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
MODULE_DEVICE_TABLE(pci, snd_cs5535audio_ids);
|
|
|
|
|
2005-11-17 06:56:21 -07:00
|
|
|
static void wait_till_cmd_acked(struct cs5535audio *cs5535au, unsigned long timeout)
|
2005-11-17 02:12:23 -07:00
|
|
|
{
|
2005-11-17 02:15:37 -07:00
|
|
|
unsigned int tmp;
|
2005-11-17 02:12:23 -07:00
|
|
|
do {
|
|
|
|
tmp = cs_readl(cs5535au, ACC_CODEC_CNTL);
|
|
|
|
if (!(tmp & CMD_NEW))
|
|
|
|
break;
|
2006-03-03 10:01:57 -07:00
|
|
|
udelay(1);
|
2005-11-17 02:12:23 -07:00
|
|
|
} while (--timeout);
|
|
|
|
if (!timeout)
|
|
|
|
snd_printk(KERN_ERR "Failure writing to cs5535 codec\n");
|
|
|
|
}
|
|
|
|
|
2005-11-17 06:56:21 -07:00
|
|
|
static unsigned short snd_cs5535audio_codec_read(struct cs5535audio *cs5535au,
|
|
|
|
unsigned short reg)
|
2005-11-17 02:12:23 -07:00
|
|
|
{
|
2005-11-17 02:15:37 -07:00
|
|
|
unsigned int regdata;
|
2005-11-17 06:56:21 -07:00
|
|
|
unsigned int timeout;
|
2005-11-17 02:15:37 -07:00
|
|
|
unsigned int val;
|
2005-11-17 02:12:23 -07:00
|
|
|
|
2005-11-17 02:15:37 -07:00
|
|
|
regdata = ((unsigned int) reg) << 24;
|
2005-11-17 02:12:23 -07:00
|
|
|
regdata |= ACC_CODEC_CNTL_RD_CMD;
|
|
|
|
regdata |= CMD_NEW;
|
|
|
|
|
|
|
|
cs_writel(cs5535au, ACC_CODEC_CNTL, regdata);
|
2006-03-03 10:01:57 -07:00
|
|
|
wait_till_cmd_acked(cs5535au, 50);
|
2005-11-17 02:12:23 -07:00
|
|
|
|
|
|
|
timeout = 50;
|
|
|
|
do {
|
|
|
|
val = cs_readl(cs5535au, ACC_CODEC_STATUS);
|
2005-11-17 02:15:37 -07:00
|
|
|
if ((val & STS_NEW) && reg == (val >> 24))
|
2005-11-17 02:12:23 -07:00
|
|
|
break;
|
2006-03-03 10:01:57 -07:00
|
|
|
udelay(1);
|
2005-11-17 02:12:23 -07:00
|
|
|
} while (--timeout);
|
|
|
|
if (!timeout)
|
2006-06-13 04:01:14 -06:00
|
|
|
snd_printk(KERN_ERR "Failure reading codec reg 0x%x,"
|
|
|
|
"Last value=0x%x\n", reg, val);
|
2005-11-17 02:12:23 -07:00
|
|
|
|
2005-11-17 02:15:37 -07:00
|
|
|
return (unsigned short) val;
|
2005-11-17 02:12:23 -07:00
|
|
|
}
|
|
|
|
|
2005-11-17 06:56:21 -07:00
|
|
|
static void snd_cs5535audio_codec_write(struct cs5535audio *cs5535au,
|
|
|
|
unsigned short reg, unsigned short val)
|
2005-11-17 02:12:23 -07:00
|
|
|
{
|
2005-11-17 02:15:37 -07:00
|
|
|
unsigned int regdata;
|
2005-11-17 02:12:23 -07:00
|
|
|
|
2005-11-17 02:15:37 -07:00
|
|
|
regdata = ((unsigned int) reg) << 24;
|
|
|
|
regdata |= val;
|
2005-11-17 02:12:23 -07:00
|
|
|
regdata &= CMD_MASK;
|
|
|
|
regdata |= CMD_NEW;
|
|
|
|
regdata &= ACC_CODEC_CNTL_WR_CMD;
|
|
|
|
|
|
|
|
cs_writel(cs5535au, ACC_CODEC_CNTL, regdata);
|
|
|
|
wait_till_cmd_acked(cs5535au, 50);
|
|
|
|
}
|
|
|
|
|
2005-11-17 06:56:21 -07:00
|
|
|
static void snd_cs5535audio_ac97_codec_write(struct snd_ac97 *ac97,
|
|
|
|
unsigned short reg, unsigned short val)
|
2005-11-17 02:12:23 -07:00
|
|
|
{
|
2005-11-17 06:56:21 -07:00
|
|
|
struct cs5535audio *cs5535au = ac97->private_data;
|
2005-11-17 02:12:23 -07:00
|
|
|
snd_cs5535audio_codec_write(cs5535au, reg, val);
|
|
|
|
}
|
|
|
|
|
2005-11-17 06:56:21 -07:00
|
|
|
static unsigned short snd_cs5535audio_ac97_codec_read(struct snd_ac97 *ac97,
|
|
|
|
unsigned short reg)
|
2005-11-17 02:12:23 -07:00
|
|
|
{
|
2005-11-17 06:56:21 -07:00
|
|
|
struct cs5535audio *cs5535au = ac97->private_data;
|
2005-11-17 02:12:23 -07:00
|
|
|
return snd_cs5535audio_codec_read(cs5535au, reg);
|
|
|
|
}
|
|
|
|
|
2008-01-23 03:52:06 -07:00
|
|
|
static int __devinit snd_cs5535audio_mixer(struct cs5535audio *cs5535au)
|
2005-11-17 02:12:23 -07:00
|
|
|
{
|
2005-11-17 06:56:21 -07:00
|
|
|
struct snd_card *card = cs5535au->card;
|
|
|
|
struct snd_ac97_bus *pbus;
|
|
|
|
struct snd_ac97_template ac97;
|
2005-11-17 02:12:23 -07:00
|
|
|
int err;
|
2005-11-17 06:56:21 -07:00
|
|
|
static struct snd_ac97_bus_ops ops = {
|
2005-11-17 02:12:23 -07:00
|
|
|
.write = snd_cs5535audio_ac97_codec_write,
|
|
|
|
.read = snd_cs5535audio_ac97_codec_read,
|
|
|
|
};
|
|
|
|
|
|
|
|
if ((err = snd_ac97_bus(card, 0, &ops, NULL, &pbus)) < 0)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
memset(&ac97, 0, sizeof(ac97));
|
2008-11-05 15:30:08 -07:00
|
|
|
ac97.scaps = AC97_SCAP_AUDIO | AC97_SCAP_SKIP_MODEM
|
|
|
|
| AC97_SCAP_POWER_SAVE;
|
2005-11-17 02:12:23 -07:00
|
|
|
ac97.private_data = cs5535au;
|
|
|
|
ac97.pci = cs5535au->pci;
|
|
|
|
|
2008-11-06 14:44:08 -07:00
|
|
|
/* set any OLPC-specific scaps */
|
|
|
|
olpc_prequirks(card, &ac97);
|
|
|
|
|
2005-11-17 02:12:23 -07:00
|
|
|
if ((err = snd_ac97_mixer(pbus, &ac97, &cs5535au->ac97)) < 0) {
|
2005-11-17 02:15:37 -07:00
|
|
|
snd_printk(KERN_ERR "mixer failed\n");
|
2005-11-17 02:12:23 -07:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2006-04-28 06:34:49 -06:00
|
|
|
snd_ac97_tune_hardware(cs5535au->ac97, ac97_quirks, ac97_quirk);
|
|
|
|
|
2008-11-06 14:43:34 -07:00
|
|
|
err = olpc_quirks(card, cs5535au->ac97);
|
|
|
|
if (err < 0) {
|
|
|
|
snd_printk(KERN_ERR "olpc quirks failed\n");
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2005-11-17 02:12:23 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 06:56:21 -07:00
|
|
|
static void process_bm0_irq(struct cs5535audio *cs5535au)
|
2005-11-17 02:12:23 -07:00
|
|
|
{
|
|
|
|
u8 bm_stat;
|
|
|
|
spin_lock(&cs5535au->reg_lock);
|
|
|
|
bm_stat = cs_readb(cs5535au, ACC_BM0_STATUS);
|
|
|
|
spin_unlock(&cs5535au->reg_lock);
|
|
|
|
if (bm_stat & EOP) {
|
2005-11-17 06:56:21 -07:00
|
|
|
struct cs5535audio_dma *dma;
|
2005-11-17 02:12:23 -07:00
|
|
|
dma = cs5535au->playback_substream->runtime->private_data;
|
|
|
|
snd_pcm_period_elapsed(cs5535au->playback_substream);
|
|
|
|
} else {
|
|
|
|
snd_printk(KERN_ERR "unexpected bm0 irq src, bm_stat=%x\n",
|
|
|
|
bm_stat);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-11-17 06:56:21 -07:00
|
|
|
static void process_bm1_irq(struct cs5535audio *cs5535au)
|
2005-11-17 02:12:23 -07:00
|
|
|
{
|
|
|
|
u8 bm_stat;
|
|
|
|
spin_lock(&cs5535au->reg_lock);
|
|
|
|
bm_stat = cs_readb(cs5535au, ACC_BM1_STATUS);
|
|
|
|
spin_unlock(&cs5535au->reg_lock);
|
|
|
|
if (bm_stat & EOP) {
|
2005-11-17 06:56:21 -07:00
|
|
|
struct cs5535audio_dma *dma;
|
2005-11-17 02:12:23 -07:00
|
|
|
dma = cs5535au->capture_substream->runtime->private_data;
|
|
|
|
snd_pcm_period_elapsed(cs5535au->capture_substream);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 07:55:46 -06:00
|
|
|
static irqreturn_t snd_cs5535audio_interrupt(int irq, void *dev_id)
|
2005-11-17 02:12:23 -07:00
|
|
|
{
|
|
|
|
u16 acc_irq_stat;
|
|
|
|
unsigned char count;
|
2005-11-17 06:56:21 -07:00
|
|
|
struct cs5535audio *cs5535au = dev_id;
|
2005-11-17 02:12:23 -07:00
|
|
|
|
|
|
|
if (cs5535au == NULL)
|
|
|
|
return IRQ_NONE;
|
|
|
|
|
|
|
|
acc_irq_stat = cs_readw(cs5535au, ACC_IRQ_STATUS);
|
|
|
|
|
|
|
|
if (!acc_irq_stat)
|
|
|
|
return IRQ_NONE;
|
2007-09-03 07:43:43 -06:00
|
|
|
for (count = 0; count < 4; count++) {
|
2005-11-17 02:15:37 -07:00
|
|
|
if (acc_irq_stat & (1 << count)) {
|
2005-11-17 02:12:23 -07:00
|
|
|
switch (count) {
|
|
|
|
case IRQ_STS:
|
|
|
|
cs_readl(cs5535au, ACC_GPIO_STATUS);
|
|
|
|
break;
|
|
|
|
case WU_IRQ_STS:
|
|
|
|
cs_readl(cs5535au, ACC_GPIO_STATUS);
|
|
|
|
break;
|
|
|
|
case BM0_IRQ_STS:
|
|
|
|
process_bm0_irq(cs5535au);
|
|
|
|
break;
|
|
|
|
case BM1_IRQ_STS:
|
|
|
|
process_bm1_irq(cs5535au);
|
|
|
|
break;
|
|
|
|
default:
|
2007-09-03 07:43:43 -06:00
|
|
|
snd_printk(KERN_ERR "Unexpected irq src: "
|
|
|
|
"0x%x\n", acc_irq_stat);
|
2005-11-17 02:12:23 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
2005-11-17 06:56:21 -07:00
|
|
|
static int snd_cs5535audio_free(struct cs5535audio *cs5535au)
|
2005-11-17 02:12:23 -07:00
|
|
|
{
|
|
|
|
synchronize_irq(cs5535au->irq);
|
|
|
|
pci_set_power_state(cs5535au->pci, 3);
|
|
|
|
|
|
|
|
if (cs5535au->irq >= 0)
|
|
|
|
free_irq(cs5535au->irq, cs5535au);
|
|
|
|
|
|
|
|
pci_release_regions(cs5535au->pci);
|
|
|
|
pci_disable_device(cs5535au->pci);
|
|
|
|
kfree(cs5535au);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 06:56:21 -07:00
|
|
|
static int snd_cs5535audio_dev_free(struct snd_device *device)
|
2005-11-17 02:12:23 -07:00
|
|
|
{
|
2005-11-17 06:56:21 -07:00
|
|
|
struct cs5535audio *cs5535au = device->device_data;
|
2005-11-17 02:12:23 -07:00
|
|
|
return snd_cs5535audio_free(cs5535au);
|
|
|
|
}
|
|
|
|
|
2005-11-17 06:56:21 -07:00
|
|
|
static int __devinit snd_cs5535audio_create(struct snd_card *card,
|
|
|
|
struct pci_dev *pci,
|
|
|
|
struct cs5535audio **rcs5535au)
|
2005-11-17 02:12:23 -07:00
|
|
|
{
|
2005-11-17 06:56:21 -07:00
|
|
|
struct cs5535audio *cs5535au;
|
2005-11-17 02:12:23 -07:00
|
|
|
|
|
|
|
int err;
|
2005-11-17 06:56:21 -07:00
|
|
|
static struct snd_device_ops ops = {
|
2005-11-17 02:12:23 -07:00
|
|
|
.dev_free = snd_cs5535audio_dev_free,
|
|
|
|
};
|
|
|
|
|
|
|
|
*rcs5535au = NULL;
|
|
|
|
if ((err = pci_enable_device(pci)) < 0)
|
|
|
|
return err;
|
|
|
|
|
2009-04-06 20:01:15 -06:00
|
|
|
if (pci_set_dma_mask(pci, DMA_BIT_MASK(32)) < 0 ||
|
|
|
|
pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(32)) < 0) {
|
2005-11-17 02:12:23 -07:00
|
|
|
printk(KERN_WARNING "unable to get 32bit dma\n");
|
|
|
|
err = -ENXIO;
|
|
|
|
goto pcifail;
|
|
|
|
}
|
|
|
|
|
|
|
|
cs5535au = kzalloc(sizeof(*cs5535au), GFP_KERNEL);
|
|
|
|
if (cs5535au == NULL) {
|
|
|
|
err = -ENOMEM;
|
|
|
|
goto pcifail;
|
|
|
|
}
|
|
|
|
|
|
|
|
spin_lock_init(&cs5535au->reg_lock);
|
|
|
|
cs5535au->card = card;
|
|
|
|
cs5535au->pci = pci;
|
|
|
|
cs5535au->irq = -1;
|
|
|
|
|
|
|
|
if ((err = pci_request_regions(pci, "CS5535 Audio")) < 0) {
|
|
|
|
kfree(cs5535au);
|
|
|
|
goto pcifail;
|
|
|
|
}
|
|
|
|
|
|
|
|
cs5535au->port = pci_resource_start(pci, 0);
|
|
|
|
|
|
|
|
if (request_irq(pci->irq, snd_cs5535audio_interrupt,
|
2011-06-10 08:36:37 -06:00
|
|
|
IRQF_SHARED, KBUILD_MODNAME, cs5535au)) {
|
2009-02-05 08:11:31 -07:00
|
|
|
snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
|
2005-11-17 02:12:23 -07:00
|
|
|
err = -EBUSY;
|
|
|
|
goto sndfail;
|
|
|
|
}
|
|
|
|
|
|
|
|
cs5535au->irq = pci->irq;
|
|
|
|
pci_set_master(pci);
|
|
|
|
|
|
|
|
if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL,
|
2005-11-17 06:56:21 -07:00
|
|
|
cs5535au, &ops)) < 0)
|
2005-11-17 02:12:23 -07:00
|
|
|
goto sndfail;
|
|
|
|
|
|
|
|
snd_card_set_dev(card, &pci->dev);
|
|
|
|
|
|
|
|
*rcs5535au = cs5535au;
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
sndfail: /* leave the device alive, just kill the snd */
|
|
|
|
snd_cs5535audio_free(cs5535au);
|
|
|
|
return err;
|
|
|
|
|
|
|
|
pcifail:
|
|
|
|
pci_disable_device(pci);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __devinit snd_cs5535audio_probe(struct pci_dev *pci,
|
2005-11-17 06:56:21 -07:00
|
|
|
const struct pci_device_id *pci_id)
|
2005-11-17 02:12:23 -07:00
|
|
|
{
|
|
|
|
static int dev;
|
2005-11-17 06:56:21 -07:00
|
|
|
struct snd_card *card;
|
|
|
|
struct cs5535audio *cs5535au;
|
2005-11-17 02:12:23 -07:00
|
|
|
int err;
|
|
|
|
|
|
|
|
if (dev >= SNDRV_CARDS)
|
|
|
|
return -ENODEV;
|
2006-05-23 05:24:30 -06:00
|
|
|
if (!enable[dev]) {
|
|
|
|
dev++;
|
|
|
|
return -ENOENT;
|
|
|
|
}
|
2005-11-17 02:12:23 -07:00
|
|
|
|
2008-12-28 08:44:30 -07:00
|
|
|
err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
2005-11-17 02:12:23 -07:00
|
|
|
|
|
|
|
if ((err = snd_cs5535audio_create(card, pci, &cs5535au)) < 0)
|
|
|
|
goto probefail_out;
|
|
|
|
|
2006-04-28 06:34:49 -06:00
|
|
|
card->private_data = cs5535au;
|
|
|
|
|
2005-11-17 02:12:23 -07:00
|
|
|
if ((err = snd_cs5535audio_mixer(cs5535au)) < 0)
|
|
|
|
goto probefail_out;
|
|
|
|
|
|
|
|
if ((err = snd_cs5535audio_pcm(cs5535au)) < 0)
|
|
|
|
goto probefail_out;
|
|
|
|
|
|
|
|
strcpy(card->driver, DRIVER_NAME);
|
|
|
|
|
|
|
|
strcpy(card->shortname, "CS5535 Audio");
|
|
|
|
sprintf(card->longname, "%s %s at 0x%lx, irq %i",
|
|
|
|
card->shortname, card->driver,
|
|
|
|
cs5535au->port, cs5535au->irq);
|
|
|
|
|
|
|
|
if ((err = snd_card_register(card)) < 0)
|
|
|
|
goto probefail_out;
|
|
|
|
|
|
|
|
pci_set_drvdata(pci, card);
|
|
|
|
dev++;
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
probefail_out:
|
|
|
|
snd_card_free(card);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __devexit snd_cs5535audio_remove(struct pci_dev *pci)
|
|
|
|
{
|
2009-12-14 19:00:36 -07:00
|
|
|
olpc_quirks_cleanup();
|
2005-11-17 02:12:23 -07:00
|
|
|
snd_card_free(pci_get_drvdata(pci));
|
|
|
|
pci_set_drvdata(pci, NULL);
|
|
|
|
}
|
|
|
|
|
2012-04-24 04:25:00 -06:00
|
|
|
static struct pci_driver cs5535audio_driver = {
|
2011-06-10 08:20:20 -06:00
|
|
|
.name = KBUILD_MODNAME,
|
2005-11-17 02:12:23 -07:00
|
|
|
.id_table = snd_cs5535audio_ids,
|
|
|
|
.probe = snd_cs5535audio_probe,
|
|
|
|
.remove = __devexit_p(snd_cs5535audio_remove),
|
2012-08-14 10:12:04 -06:00
|
|
|
#ifdef CONFIG_PM_SLEEP
|
2012-07-02 07:20:37 -06:00
|
|
|
.driver = {
|
|
|
|
.pm = &snd_cs5535audio_pm,
|
|
|
|
},
|
2006-04-28 06:34:49 -06:00
|
|
|
#endif
|
2005-11-17 02:12:23 -07:00
|
|
|
};
|
|
|
|
|
2012-04-24 04:25:00 -06:00
|
|
|
module_pci_driver(cs5535audio_driver);
|
2005-11-17 02:12:23 -07:00
|
|
|
|
|
|
|
MODULE_AUTHOR("Jaya Kumar");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
MODULE_DESCRIPTION("CS5535 Audio");
|
|
|
|
MODULE_SUPPORTED_DEVICE("CS5535 Audio");
|