2009-09-13 14:30:11 +00:00
|
|
|
/*
|
|
|
|
* Driver for the Conexant CX25821 PCIe bridge
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009 Conexant Systems Inc.
|
|
|
|
* Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com>
|
|
|
|
* Based on SAA713x ALSA driver and CX88 driver
|
|
|
|
*
|
|
|
|
* 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, version 2
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2009-09-15 14:33:54 +00:00
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/device.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/vmalloc.h>
|
|
|
|
#include <linux/dma-mapping.h>
|
|
|
|
#include <linux/pci.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 08:04:11 +00:00
|
|
|
#include <linux/slab.h>
|
2009-09-15 14:33:54 +00:00
|
|
|
|
2010-03-14 15:44:37 +00:00
|
|
|
#include <linux/delay.h>
|
2009-09-15 14:33:54 +00:00
|
|
|
#include <sound/core.h>
|
|
|
|
#include <sound/pcm.h>
|
|
|
|
#include <sound/pcm_params.h>
|
|
|
|
#include <sound/control.h>
|
|
|
|
#include <sound/initval.h>
|
|
|
|
#include <sound/tlv.h>
|
|
|
|
|
|
|
|
#include "cx25821.h"
|
|
|
|
#include "cx25821-reg.h"
|
|
|
|
|
|
|
|
#define AUDIO_SRAM_CHANNEL SRAM_CH08
|
|
|
|
|
2010-03-14 15:44:37 +00:00
|
|
|
#define dprintk(level, fmt, arg...) if (debug >= level) \
|
2009-09-15 14:33:54 +00:00
|
|
|
printk(KERN_INFO "%s/1: " fmt, chip->dev->name , ## arg)
|
|
|
|
|
2010-03-14 15:44:37 +00:00
|
|
|
#define dprintk_core(level, fmt, arg...) if (debug >= level) \
|
2009-09-15 14:33:54 +00:00
|
|
|
printk(KERN_DEBUG "%s/1: " fmt, chip->dev->name , ## arg)
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
Data type declarations - Can be moded to a header file later
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static struct snd_card *snd_cx25821_cards[SNDRV_CARDS];
|
|
|
|
static int devno;
|
|
|
|
|
2010-05-11 13:36:31 +00:00
|
|
|
struct cx25821_audio_buffer {
|
|
|
|
unsigned int bpl;
|
|
|
|
struct btcx_riscmem risc;
|
|
|
|
struct videobuf_dmabuf dma;
|
|
|
|
};
|
|
|
|
|
2009-09-15 14:33:54 +00:00
|
|
|
struct cx25821_audio_dev {
|
2009-09-13 14:30:11 +00:00
|
|
|
struct cx25821_dev *dev;
|
|
|
|
struct cx25821_dmaqueue q;
|
2009-09-15 14:33:54 +00:00
|
|
|
|
|
|
|
/* pci i/o */
|
2009-09-13 14:30:11 +00:00
|
|
|
struct pci_dev *pci;
|
2009-09-15 14:33:54 +00:00
|
|
|
|
|
|
|
/* audio controls */
|
2009-09-13 14:30:11 +00:00
|
|
|
int irq;
|
2009-09-15 14:33:54 +00:00
|
|
|
|
2009-09-13 14:30:11 +00:00
|
|
|
struct snd_card *card;
|
2009-09-15 14:33:54 +00:00
|
|
|
|
|
|
|
unsigned long iobase;
|
2009-09-13 14:30:11 +00:00
|
|
|
spinlock_t reg_lock;
|
|
|
|
atomic_t count;
|
2009-09-15 14:33:54 +00:00
|
|
|
|
2009-09-13 14:30:11 +00:00
|
|
|
unsigned int dma_size;
|
|
|
|
unsigned int period_size;
|
|
|
|
unsigned int num_periods;
|
2009-09-15 14:33:54 +00:00
|
|
|
|
2009-09-13 14:30:11 +00:00
|
|
|
struct videobuf_dmabuf *dma_risc;
|
2009-09-15 14:33:54 +00:00
|
|
|
|
2010-05-11 13:36:31 +00:00
|
|
|
struct cx25821_audio_buffer *buf;
|
2009-09-15 14:33:54 +00:00
|
|
|
|
2009-09-13 14:30:11 +00:00
|
|
|
struct snd_pcm_substream *substream;
|
2009-09-15 14:33:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
Module global static vars
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
|
|
|
|
static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
|
2010-03-14 15:44:37 +00:00
|
|
|
static int enable[SNDRV_CARDS] = { 1, [1 ... (SNDRV_CARDS - 1)] = 1 };
|
2009-09-15 14:33:54 +00:00
|
|
|
|
|
|
|
module_param_array(enable, bool, NULL, 0444);
|
|
|
|
MODULE_PARM_DESC(enable, "Enable cx25821 soundcard. default enabled.");
|
|
|
|
|
|
|
|
module_param_array(index, int, NULL, 0444);
|
|
|
|
MODULE_PARM_DESC(index, "Index value for cx25821 capture interface(s).");
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
Module macros
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
MODULE_DESCRIPTION("ALSA driver module for cx25821 based capture cards");
|
|
|
|
MODULE_AUTHOR("Hiep Huynh");
|
|
|
|
MODULE_LICENSE("GPL");
|
2010-03-14 15:44:37 +00:00
|
|
|
MODULE_SUPPORTED_DEVICE("{{Conexant,25821}"); /* "{{Conexant,23881}," */
|
2009-09-15 14:33:54 +00:00
|
|
|
|
|
|
|
static unsigned int debug;
|
2009-09-13 14:30:11 +00:00
|
|
|
module_param(debug, int, 0644);
|
|
|
|
MODULE_PARM_DESC(debug, "enable debug messages");
|
2009-09-15 14:33:54 +00:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
Module specific funtions
|
|
|
|
****************************************************************************/
|
|
|
|
/* Constants taken from cx88-reg.h */
|
|
|
|
#define AUD_INT_DN_RISCI1 (1 << 0)
|
|
|
|
#define AUD_INT_UP_RISCI1 (1 << 1)
|
|
|
|
#define AUD_INT_RDS_DN_RISCI1 (1 << 2)
|
2009-09-13 14:30:11 +00:00
|
|
|
#define AUD_INT_DN_RISCI2 (1 << 4) /* yes, 3 is skipped */
|
2009-09-15 14:33:54 +00:00
|
|
|
#define AUD_INT_UP_RISCI2 (1 << 5)
|
|
|
|
#define AUD_INT_RDS_DN_RISCI2 (1 << 6)
|
|
|
|
#define AUD_INT_DN_SYNC (1 << 12)
|
|
|
|
#define AUD_INT_UP_SYNC (1 << 13)
|
|
|
|
#define AUD_INT_RDS_DN_SYNC (1 << 14)
|
|
|
|
#define AUD_INT_OPC_ERR (1 << 16)
|
|
|
|
#define AUD_INT_BER_IRQ (1 << 20)
|
|
|
|
#define AUD_INT_MCHG_IRQ (1 << 21)
|
|
|
|
#define GP_COUNT_CONTROL_RESET 0x3
|
|
|
|
|
|
|
|
#define PCI_MSK_AUD_EXT (1 << 4)
|
|
|
|
#define PCI_MSK_AUD_INT (1 << 3)
|
|
|
|
/*
|
|
|
|
* BOARD Specific: Sets audio DMA
|
|
|
|
*/
|
|
|
|
|
2010-03-14 15:44:37 +00:00
|
|
|
static int _cx25821_start_audio_dma(struct cx25821_audio_dev *chip)
|
2009-09-15 14:33:54 +00:00
|
|
|
{
|
2010-05-11 13:36:31 +00:00
|
|
|
struct cx25821_audio_buffer *buf = chip->buf;
|
2009-09-13 14:30:11 +00:00
|
|
|
struct cx25821_dev *dev = chip->dev;
|
|
|
|
struct sram_channel *audio_ch =
|
|
|
|
&cx25821_sram_channels[AUDIO_SRAM_CHANNEL];
|
2009-09-15 14:33:54 +00:00
|
|
|
u32 tmp = 0;
|
|
|
|
|
2010-03-14 15:44:37 +00:00
|
|
|
/* enable output on the GPIO 0 for the MCLK ADC (Audio) */
|
2009-09-13 14:30:11 +00:00
|
|
|
cx25821_set_gpiopin_direction(chip->dev, 0, 0);
|
2009-09-15 14:33:54 +00:00
|
|
|
|
|
|
|
/* Make sure RISC/FIFO are off before changing FIFO/RISC settings */
|
2009-09-13 14:30:11 +00:00
|
|
|
cx_clear(AUD_INT_DMA_CTL,
|
|
|
|
FLD_AUD_DST_A_RISC_EN | FLD_AUD_DST_A_FIFO_EN);
|
2009-09-15 14:33:54 +00:00
|
|
|
|
|
|
|
/* setup fifo + format - out channel */
|
2009-09-13 14:30:11 +00:00
|
|
|
cx25821_sram_channel_setup_audio(chip->dev, audio_ch, buf->bpl,
|
|
|
|
buf->risc.dma);
|
2009-09-15 14:33:54 +00:00
|
|
|
|
|
|
|
/* sets bpl size */
|
|
|
|
cx_write(AUD_A_LNGTH, buf->bpl);
|
|
|
|
|
|
|
|
/* reset counter */
|
2010-03-14 15:44:37 +00:00
|
|
|
/* GP_COUNT_CONTROL_RESET = 0x3 */
|
|
|
|
cx_write(AUD_A_GPCNT_CTL, GP_COUNT_CONTROL_RESET);
|
2009-09-15 14:33:54 +00:00
|
|
|
atomic_set(&chip->count, 0);
|
|
|
|
|
2010-03-14 15:44:37 +00:00
|
|
|
/* Set the input mode to 16-bit */
|
2009-09-13 14:30:11 +00:00
|
|
|
tmp = cx_read(AUD_A_CFG);
|
|
|
|
cx_write(AUD_A_CFG,
|
|
|
|
tmp | FLD_AUD_DST_PK_MODE | FLD_AUD_DST_ENABLE |
|
|
|
|
FLD_AUD_CLK_ENABLE);
|
2009-09-15 14:33:54 +00:00
|
|
|
|
2010-03-14 15:44:37 +00:00
|
|
|
/* printk(KERN_INFO "DEBUG: Start audio DMA, %d B/line,"
|
|
|
|
"cmds_start(0x%x)= %d lines/FIFO, %d periods, "
|
|
|
|
"%d byte buffer\n", buf->bpl,
|
|
|
|
audio_ch->cmds_start,
|
|
|
|
cx_read(audio_ch->cmds_start + 12)>>1,
|
|
|
|
chip->num_periods, buf->bpl *chip->num_periods);
|
|
|
|
*/
|
2009-09-15 14:33:54 +00:00
|
|
|
|
|
|
|
/* Enables corresponding bits at AUD_INT_STAT */
|
2009-09-13 14:30:11 +00:00
|
|
|
cx_write(AUD_A_INT_MSK,
|
|
|
|
FLD_AUD_DST_RISCI1 | FLD_AUD_DST_OF | FLD_AUD_DST_SYNC |
|
|
|
|
FLD_AUD_DST_OPC_ERR);
|
2009-09-15 14:33:54 +00:00
|
|
|
|
|
|
|
/* Clean any pending interrupt bits already set */
|
|
|
|
cx_write(AUD_A_INT_STAT, ~0);
|
|
|
|
|
|
|
|
/* enable audio irqs */
|
|
|
|
cx_set(PCI_INT_MSK, chip->dev->pci_irqmask | PCI_MSK_AUD_INT);
|
|
|
|
|
2010-03-14 15:44:37 +00:00
|
|
|
/* Turn on audio downstream fifo and risc enable 0x101 */
|
2009-09-13 14:30:11 +00:00
|
|
|
tmp = cx_read(AUD_INT_DMA_CTL);
|
|
|
|
cx_set(AUD_INT_DMA_CTL,
|
|
|
|
tmp | (FLD_AUD_DST_A_RISC_EN | FLD_AUD_DST_A_FIFO_EN));
|
2009-09-15 14:33:54 +00:00
|
|
|
|
|
|
|
mdelay(100);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* BOARD Specific: Resets audio DMA
|
|
|
|
*/
|
2010-03-14 15:44:37 +00:00
|
|
|
static int _cx25821_stop_audio_dma(struct cx25821_audio_dev *chip)
|
2009-09-15 14:33:54 +00:00
|
|
|
{
|
|
|
|
struct cx25821_dev *dev = chip->dev;
|
|
|
|
|
|
|
|
/* stop dma */
|
2009-09-13 14:30:11 +00:00
|
|
|
cx_clear(AUD_INT_DMA_CTL,
|
|
|
|
FLD_AUD_DST_A_RISC_EN | FLD_AUD_DST_A_FIFO_EN);
|
2009-09-15 14:33:54 +00:00
|
|
|
|
|
|
|
/* disable irqs */
|
|
|
|
cx_clear(PCI_INT_MSK, PCI_MSK_AUD_INT);
|
2009-09-13 14:30:11 +00:00
|
|
|
cx_clear(AUD_A_INT_MSK,
|
|
|
|
AUD_INT_OPC_ERR | AUD_INT_DN_SYNC | AUD_INT_DN_RISCI2 |
|
|
|
|
AUD_INT_DN_RISCI1);
|
2009-09-15 14:33:54 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define MAX_IRQ_LOOP 50
|
|
|
|
|
|
|
|
/*
|
|
|
|
* BOARD Specific: IRQ dma bits
|
|
|
|
*/
|
|
|
|
static char *cx25821_aud_irqs[32] = {
|
2009-09-13 14:30:11 +00:00
|
|
|
"dn_risci1", "up_risci1", "rds_dn_risc1", /* 0-2 */
|
|
|
|
NULL, /* reserved */
|
|
|
|
"dn_risci2", "up_risci2", "rds_dn_risc2", /* 4-6 */
|
|
|
|
NULL, /* reserved */
|
|
|
|
"dnf_of", "upf_uf", "rds_dnf_uf", /* 8-10 */
|
|
|
|
NULL, /* reserved */
|
|
|
|
"dn_sync", "up_sync", "rds_dn_sync", /* 12-14 */
|
|
|
|
NULL, /* reserved */
|
|
|
|
"opc_err", "par_err", "rip_err", /* 16-18 */
|
|
|
|
"pci_abort", "ber_irq", "mchg_irq" /* 19-21 */
|
2009-09-15 14:33:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* BOARD Specific: Threats IRQ audio specific calls
|
|
|
|
*/
|
2010-03-14 15:44:37 +00:00
|
|
|
static void cx25821_aud_irq(struct cx25821_audio_dev *chip, u32 status,
|
|
|
|
u32 mask)
|
2009-09-15 14:33:54 +00:00
|
|
|
{
|
|
|
|
struct cx25821_dev *dev = chip->dev;
|
|
|
|
|
2010-03-14 15:44:37 +00:00
|
|
|
if (0 == (status & mask))
|
2009-09-15 14:33:54 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
cx_write(AUD_A_INT_STAT, status);
|
2009-09-13 14:30:11 +00:00
|
|
|
if (debug > 1 || (status & mask & ~0xff))
|
2009-09-15 14:33:54 +00:00
|
|
|
cx25821_print_irqbits(dev->name, "irq aud",
|
2009-09-13 14:30:11 +00:00
|
|
|
cx25821_aud_irqs,
|
|
|
|
ARRAY_SIZE(cx25821_aud_irqs), status,
|
|
|
|
mask);
|
2009-09-15 14:33:54 +00:00
|
|
|
|
|
|
|
/* risc op code error */
|
|
|
|
if (status & AUD_INT_OPC_ERR) {
|
2009-09-13 14:30:11 +00:00
|
|
|
printk(KERN_WARNING "WARNING %s/1: Audio risc op code error\n",
|
|
|
|
dev->name);
|
|
|
|
|
|
|
|
cx_clear(AUD_INT_DMA_CTL,
|
|
|
|
FLD_AUD_DST_A_RISC_EN | FLD_AUD_DST_A_FIFO_EN);
|
|
|
|
cx25821_sram_channel_dump_audio(dev,
|
|
|
|
&cx25821_sram_channels
|
|
|
|
[AUDIO_SRAM_CHANNEL]);
|
2009-09-15 14:33:54 +00:00
|
|
|
}
|
|
|
|
if (status & AUD_INT_DN_SYNC) {
|
2009-09-13 14:30:11 +00:00
|
|
|
printk(KERN_WARNING "WARNING %s: Downstream sync error!\n",
|
|
|
|
dev->name);
|
2009-09-15 14:33:54 +00:00
|
|
|
cx_write(AUD_A_GPCNT_CTL, GP_COUNT_CONTROL_RESET);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* risc1 downstream */
|
|
|
|
if (status & AUD_INT_DN_RISCI1) {
|
|
|
|
atomic_set(&chip->count, cx_read(AUD_A_GPCNT));
|
|
|
|
snd_pcm_period_elapsed(chip->substream);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* BOARD Specific: Handles IRQ calls
|
|
|
|
*/
|
|
|
|
static irqreturn_t cx25821_irq(int irq, void *dev_id)
|
|
|
|
{
|
2010-03-14 15:44:37 +00:00
|
|
|
struct cx25821_audio_dev *chip = dev_id;
|
2009-09-15 14:33:54 +00:00
|
|
|
struct cx25821_dev *dev = chip->dev;
|
|
|
|
u32 status, pci_status;
|
|
|
|
u32 audint_status, audint_mask;
|
|
|
|
int loop, handled = 0;
|
|
|
|
int audint_count = 0;
|
|
|
|
|
|
|
|
audint_status = cx_read(AUD_A_INT_STAT);
|
2009-09-13 14:30:11 +00:00
|
|
|
audint_mask = cx_read(AUD_A_INT_MSK);
|
2009-09-15 14:33:54 +00:00
|
|
|
audint_count = cx_read(AUD_A_GPCNT);
|
|
|
|
status = cx_read(PCI_INT_STAT);
|
|
|
|
|
2009-09-13 14:30:11 +00:00
|
|
|
for (loop = 0; loop < 1; loop++) {
|
2009-09-15 14:33:54 +00:00
|
|
|
status = cx_read(PCI_INT_STAT);
|
2009-09-13 14:30:11 +00:00
|
|
|
if (0 == status) {
|
2009-09-15 14:33:54 +00:00
|
|
|
status = cx_read(PCI_INT_STAT);
|
|
|
|
audint_status = cx_read(AUD_A_INT_STAT);
|
|
|
|
audint_mask = cx_read(AUD_A_INT_MSK);
|
|
|
|
|
2009-09-13 14:30:11 +00:00
|
|
|
if (status) {
|
2009-09-15 14:33:54 +00:00
|
|
|
handled = 1;
|
|
|
|
cx_write(PCI_INT_STAT, status);
|
|
|
|
|
2009-09-13 14:30:11 +00:00
|
|
|
cx25821_aud_irq(chip, audint_status,
|
|
|
|
audint_mask);
|
2009-09-15 14:33:54 +00:00
|
|
|
break;
|
2009-09-13 14:30:11 +00:00
|
|
|
} else
|
2009-09-15 14:33:54 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
handled = 1;
|
|
|
|
cx_write(PCI_INT_STAT, status);
|
|
|
|
|
|
|
|
cx25821_aud_irq(chip, audint_status, audint_mask);
|
|
|
|
}
|
|
|
|
|
|
|
|
pci_status = cx_read(PCI_INT_STAT);
|
|
|
|
|
|
|
|
if (handled)
|
|
|
|
cx_write(PCI_INT_STAT, pci_status);
|
|
|
|
|
2010-03-14 15:44:37 +00:00
|
|
|
out:
|
2009-09-15 14:33:54 +00:00
|
|
|
return IRQ_RETVAL(handled);
|
|
|
|
}
|
|
|
|
|
2010-03-14 15:44:37 +00:00
|
|
|
static int dsp_buffer_free(struct cx25821_audio_dev *chip)
|
2009-09-15 14:33:54 +00:00
|
|
|
{
|
|
|
|
BUG_ON(!chip->dma_size);
|
|
|
|
|
2009-09-13 14:30:11 +00:00
|
|
|
dprintk(2, "Freeing buffer\n");
|
2010-05-11 13:36:30 +00:00
|
|
|
videobuf_dma_unmap(&chip->pci->dev, chip->dma_risc);
|
2009-09-15 14:33:54 +00:00
|
|
|
videobuf_dma_free(chip->dma_risc);
|
2009-09-13 14:30:11 +00:00
|
|
|
btcx_riscmem_free(chip->pci, &chip->buf->risc);
|
2009-09-15 14:33:54 +00:00
|
|
|
kfree(chip->buf);
|
|
|
|
|
|
|
|
chip->dma_risc = NULL;
|
|
|
|
chip->dma_size = 0;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
ALSA PCM Interface
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Digital hardware definition
|
|
|
|
*/
|
|
|
|
#define DEFAULT_FIFO_SIZE 384
|
|
|
|
static struct snd_pcm_hardware snd_cx25821_digital_hw = {
|
|
|
|
.info = SNDRV_PCM_INFO_MMAP |
|
2009-09-13 14:30:11 +00:00
|
|
|
SNDRV_PCM_INFO_INTERLEAVED |
|
|
|
|
SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_MMAP_VALID,
|
2009-09-15 14:33:54 +00:00
|
|
|
.formats = SNDRV_PCM_FMTBIT_S16_LE,
|
|
|
|
|
2009-09-13 14:30:11 +00:00
|
|
|
.rates = SNDRV_PCM_RATE_48000,
|
|
|
|
.rate_min = 48000,
|
|
|
|
.rate_max = 48000,
|
2009-09-15 14:33:54 +00:00
|
|
|
.channels_min = 2,
|
|
|
|
.channels_max = 2,
|
|
|
|
/* Analog audio output will be full of clicks and pops if there
|
|
|
|
are not exactly four lines in the SRAM FIFO buffer. */
|
2009-09-13 14:30:11 +00:00
|
|
|
.period_bytes_min = DEFAULT_FIFO_SIZE / 3,
|
|
|
|
.period_bytes_max = DEFAULT_FIFO_SIZE / 3,
|
2009-09-15 14:33:54 +00:00
|
|
|
.periods_min = 1,
|
|
|
|
.periods_max = AUDIO_LINE_SIZE,
|
2010-03-14 15:44:37 +00:00
|
|
|
/* 128 * 128 = 16384 = 1024 * 16 */
|
|
|
|
.buffer_bytes_max = (AUDIO_LINE_SIZE * AUDIO_LINE_SIZE),
|
2009-09-15 14:33:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* audio pcm capture open callback
|
|
|
|
*/
|
|
|
|
static int snd_cx25821_pcm_open(struct snd_pcm_substream *substream)
|
|
|
|
{
|
2010-03-14 15:44:37 +00:00
|
|
|
struct cx25821_audio_dev *chip = snd_pcm_substream_chip(substream);
|
2009-09-15 14:33:54 +00:00
|
|
|
struct snd_pcm_runtime *runtime = substream->runtime;
|
|
|
|
int err;
|
|
|
|
unsigned int bpl = 0;
|
|
|
|
|
|
|
|
if (!chip) {
|
|
|
|
printk(KERN_ERR "DEBUG: cx25821 can't find device struct."
|
2009-09-13 14:30:11 +00:00
|
|
|
" Can't proceed with open\n");
|
2009-09-15 14:33:54 +00:00
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
2009-09-13 14:30:11 +00:00
|
|
|
err =
|
|
|
|
snd_pcm_hw_constraint_pow2(runtime, 0, SNDRV_PCM_HW_PARAM_PERIODS);
|
2009-09-15 14:33:54 +00:00
|
|
|
if (err < 0)
|
|
|
|
goto _error;
|
|
|
|
|
|
|
|
chip->substream = substream;
|
|
|
|
|
|
|
|
runtime->hw = snd_cx25821_digital_hw;
|
|
|
|
|
2009-09-13 14:30:11 +00:00
|
|
|
if (cx25821_sram_channels[AUDIO_SRAM_CHANNEL].fifo_size !=
|
|
|
|
DEFAULT_FIFO_SIZE) {
|
2010-03-14 15:44:37 +00:00
|
|
|
/* since there are 3 audio Clusters */
|
|
|
|
bpl = cx25821_sram_channels[AUDIO_SRAM_CHANNEL].fifo_size / 3;
|
2009-09-13 14:30:11 +00:00
|
|
|
bpl &= ~7; /* must be multiple of 8 */
|
2009-09-15 14:33:54 +00:00
|
|
|
|
2010-03-14 15:44:37 +00:00
|
|
|
if (bpl > AUDIO_LINE_SIZE)
|
2009-09-15 14:33:54 +00:00
|
|
|
bpl = AUDIO_LINE_SIZE;
|
2010-03-14 15:44:37 +00:00
|
|
|
|
2009-09-15 14:33:54 +00:00
|
|
|
runtime->hw.period_bytes_min = bpl;
|
|
|
|
runtime->hw.period_bytes_max = bpl;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2010-03-14 15:44:37 +00:00
|
|
|
_error:
|
2009-09-13 14:30:11 +00:00
|
|
|
dprintk(1, "Error opening PCM!\n");
|
2009-09-15 14:33:54 +00:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* audio close callback
|
|
|
|
*/
|
|
|
|
static int snd_cx25821_close(struct snd_pcm_substream *substream)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* hw_params callback
|
|
|
|
*/
|
2009-09-13 14:30:11 +00:00
|
|
|
static int snd_cx25821_hw_params(struct snd_pcm_substream *substream,
|
|
|
|
struct snd_pcm_hw_params *hw_params)
|
2009-09-15 14:33:54 +00:00
|
|
|
{
|
2010-03-14 15:44:37 +00:00
|
|
|
struct cx25821_audio_dev *chip = snd_pcm_substream_chip(substream);
|
2009-09-15 14:33:54 +00:00
|
|
|
struct videobuf_dmabuf *dma;
|
|
|
|
|
2010-05-11 13:36:31 +00:00
|
|
|
struct cx25821_audio_buffer *buf;
|
2009-09-15 14:33:54 +00:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (substream->runtime->dma_area) {
|
|
|
|
dsp_buffer_free(chip);
|
|
|
|
substream->runtime->dma_area = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
chip->period_size = params_period_bytes(hw_params);
|
|
|
|
chip->num_periods = params_periods(hw_params);
|
|
|
|
chip->dma_size = chip->period_size * params_periods(hw_params);
|
|
|
|
|
|
|
|
BUG_ON(!chip->dma_size);
|
2009-09-13 14:30:11 +00:00
|
|
|
BUG_ON(chip->num_periods & (chip->num_periods - 1));
|
2009-09-15 14:33:54 +00:00
|
|
|
|
2010-05-11 13:36:31 +00:00
|
|
|
buf = kzalloc(sizeof(*buf), GFP_KERNEL);
|
2009-09-15 14:33:54 +00:00
|
|
|
if (NULL == buf)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2010-03-14 15:44:37 +00:00
|
|
|
if (chip->period_size > AUDIO_LINE_SIZE)
|
2009-09-15 14:33:54 +00:00
|
|
|
chip->period_size = AUDIO_LINE_SIZE;
|
|
|
|
|
2009-09-13 14:30:11 +00:00
|
|
|
buf->bpl = chip->period_size;
|
2009-09-15 14:33:54 +00:00
|
|
|
|
2010-05-11 13:36:31 +00:00
|
|
|
dma = &buf->dma;
|
2009-09-15 14:33:54 +00:00
|
|
|
videobuf_dma_init(dma);
|
|
|
|
ret = videobuf_dma_init_kernel(dma, PCI_DMA_FROMDEVICE,
|
2010-05-11 13:36:31 +00:00
|
|
|
(PAGE_ALIGN(chip->dma_size) >>
|
2009-09-13 14:30:11 +00:00
|
|
|
PAGE_SHIFT));
|
2009-09-15 14:33:54 +00:00
|
|
|
if (ret < 0)
|
|
|
|
goto error;
|
|
|
|
|
2010-05-11 13:36:30 +00:00
|
|
|
ret = videobuf_dma_map(&chip->pci->dev, dma);
|
2009-09-15 14:33:54 +00:00
|
|
|
if (ret < 0)
|
|
|
|
goto error;
|
|
|
|
|
2009-09-13 14:30:11 +00:00
|
|
|
ret =
|
|
|
|
cx25821_risc_databuffer_audio(chip->pci, &buf->risc, dma->sglist,
|
2010-05-11 13:36:31 +00:00
|
|
|
chip->period_size, chip->num_periods,
|
|
|
|
1);
|
2009-09-13 14:30:11 +00:00
|
|
|
if (ret < 0) {
|
|
|
|
printk(KERN_INFO
|
2010-03-14 15:44:37 +00:00
|
|
|
"DEBUG: ERROR after cx25821_risc_databuffer_audio()\n");
|
2009-09-15 14:33:54 +00:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Loop back to start of program */
|
2009-09-13 14:30:11 +00:00
|
|
|
buf->risc.jmp[0] = cpu_to_le32(RISC_JUMP | RISC_IRQ1 | RISC_CNT_INC);
|
2009-09-15 14:33:54 +00:00
|
|
|
buf->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
|
2009-09-13 14:30:11 +00:00
|
|
|
buf->risc.jmp[2] = cpu_to_le32(0); /* bits 63-32 */
|
2009-09-15 14:33:54 +00:00
|
|
|
|
|
|
|
chip->buf = buf;
|
|
|
|
chip->dma_risc = dma;
|
|
|
|
|
2010-05-11 13:36:34 +00:00
|
|
|
substream->runtime->dma_area = chip->dma_risc->vaddr;
|
2009-09-15 14:33:54 +00:00
|
|
|
substream->runtime->dma_bytes = chip->dma_size;
|
|
|
|
substream->runtime->dma_addr = 0;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
2010-03-14 15:44:37 +00:00
|
|
|
error:
|
2009-09-15 14:33:54 +00:00
|
|
|
kfree(buf);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* hw free callback
|
|
|
|
*/
|
2009-09-13 14:30:11 +00:00
|
|
|
static int snd_cx25821_hw_free(struct snd_pcm_substream *substream)
|
2009-09-15 14:33:54 +00:00
|
|
|
{
|
2010-03-14 15:44:37 +00:00
|
|
|
struct cx25821_audio_dev *chip = snd_pcm_substream_chip(substream);
|
2009-09-15 14:33:54 +00:00
|
|
|
|
|
|
|
if (substream->runtime->dma_area) {
|
|
|
|
dsp_buffer_free(chip);
|
|
|
|
substream->runtime->dma_area = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* prepare callback
|
|
|
|
*/
|
|
|
|
static int snd_cx25821_prepare(struct snd_pcm_substream *substream)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* trigger callback
|
|
|
|
*/
|
2009-09-13 14:30:11 +00:00
|
|
|
static int snd_cx25821_card_trigger(struct snd_pcm_substream *substream,
|
|
|
|
int cmd)
|
2009-09-15 14:33:54 +00:00
|
|
|
{
|
2010-03-14 15:44:37 +00:00
|
|
|
struct cx25821_audio_dev *chip = snd_pcm_substream_chip(substream);
|
2009-09-15 14:33:54 +00:00
|
|
|
int err = 0;
|
|
|
|
|
|
|
|
/* Local interrupts are already disabled by ALSA */
|
|
|
|
spin_lock(&chip->reg_lock);
|
|
|
|
|
2009-09-13 14:30:11 +00:00
|
|
|
switch (cmd) {
|
|
|
|
case SNDRV_PCM_TRIGGER_START:
|
|
|
|
err = _cx25821_start_audio_dma(chip);
|
|
|
|
break;
|
|
|
|
case SNDRV_PCM_TRIGGER_STOP:
|
|
|
|
err = _cx25821_stop_audio_dma(chip);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
err = -EINVAL;
|
|
|
|
break;
|
2009-09-15 14:33:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
spin_unlock(&chip->reg_lock);
|
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* pointer callback
|
|
|
|
*/
|
2009-09-13 14:30:11 +00:00
|
|
|
static snd_pcm_uframes_t snd_cx25821_pointer(struct snd_pcm_substream
|
|
|
|
*substream)
|
2009-09-15 14:33:54 +00:00
|
|
|
{
|
2010-03-14 15:44:37 +00:00
|
|
|
struct cx25821_audio_dev *chip = snd_pcm_substream_chip(substream);
|
2009-09-15 14:33:54 +00:00
|
|
|
struct snd_pcm_runtime *runtime = substream->runtime;
|
|
|
|
u16 count;
|
|
|
|
|
|
|
|
count = atomic_read(&chip->count);
|
|
|
|
|
2009-09-13 14:30:11 +00:00
|
|
|
return runtime->period_size * (count & (runtime->periods - 1));
|
2009-09-15 14:33:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* page callback (needed for mmap)
|
|
|
|
*/
|
|
|
|
static struct page *snd_cx25821_page(struct snd_pcm_substream *substream,
|
2009-09-13 14:30:11 +00:00
|
|
|
unsigned long offset)
|
2009-09-15 14:33:54 +00:00
|
|
|
{
|
|
|
|
void *pageptr = substream->runtime->dma_area + offset;
|
|
|
|
|
|
|
|
return vmalloc_to_page(pageptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* operators
|
|
|
|
*/
|
|
|
|
static struct snd_pcm_ops snd_cx25821_pcm_ops = {
|
|
|
|
.open = snd_cx25821_pcm_open,
|
|
|
|
.close = snd_cx25821_close,
|
|
|
|
.ioctl = snd_pcm_lib_ioctl,
|
|
|
|
.hw_params = snd_cx25821_hw_params,
|
|
|
|
.hw_free = snd_cx25821_hw_free,
|
|
|
|
.prepare = snd_cx25821_prepare,
|
|
|
|
.trigger = snd_cx25821_card_trigger,
|
|
|
|
.pointer = snd_cx25821_pointer,
|
|
|
|
.page = snd_cx25821_page,
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
2010-03-14 15:44:37 +00:00
|
|
|
* ALSA create a PCM device: Called when initializing the board.
|
|
|
|
* Sets up the name and hooks up the callbacks
|
2009-09-15 14:33:54 +00:00
|
|
|
*/
|
2010-03-14 15:44:37 +00:00
|
|
|
static int snd_cx25821_pcm(struct cx25821_audio_dev *chip, int device,
|
|
|
|
char *name)
|
2009-09-15 14:33:54 +00:00
|
|
|
{
|
|
|
|
struct snd_pcm *pcm;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
err = snd_pcm_new(chip->card, name, device, 0, 1, &pcm);
|
2009-09-13 14:30:11 +00:00
|
|
|
if (err < 0) {
|
|
|
|
printk(KERN_INFO "ERROR: FAILED snd_pcm_new() in %s\n",
|
|
|
|
__func__);
|
2009-09-15 14:33:54 +00:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
pcm->private_data = chip;
|
|
|
|
pcm->info_flags = 0;
|
|
|
|
strcpy(pcm->name, name);
|
|
|
|
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_cx25821_pcm_ops);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
Basic Flow for Sound Devices
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* PCI ID Table - 14f1:8801 and 14f1:8811 means function 1: Audio
|
|
|
|
* Only boards with eeprom and byte 1 at eeprom=1 have it
|
|
|
|
*/
|
|
|
|
|
|
|
|
static struct pci_device_id cx25821_audio_pci_tbl[] __devinitdata = {
|
2009-09-13 14:30:11 +00:00
|
|
|
{0x14f1, 0x0920, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
|
|
|
|
{0,}
|
2009-09-15 14:33:54 +00:00
|
|
|
};
|
2009-09-13 14:30:11 +00:00
|
|
|
|
2009-09-15 14:33:54 +00:00
|
|
|
MODULE_DEVICE_TABLE(pci, cx25821_audio_pci_tbl);
|
|
|
|
|
2009-09-13 14:30:11 +00:00
|
|
|
/*
|
|
|
|
* Not used in the function snd_cx25821_dev_free so removing
|
|
|
|
* from the file.
|
|
|
|
*/
|
2009-09-15 14:33:54 +00:00
|
|
|
/*
|
2010-03-14 15:44:37 +00:00
|
|
|
static int snd_cx25821_free(struct cx25821_audio_dev *chip)
|
2009-09-15 14:33:54 +00:00
|
|
|
{
|
|
|
|
if (chip->irq >= 0)
|
|
|
|
free_irq(chip->irq, chip);
|
|
|
|
|
|
|
|
cx25821_dev_unregister(chip->dev);
|
|
|
|
pci_disable_device(chip->pci);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2009-09-13 14:30:11 +00:00
|
|
|
*/
|
2009-09-15 14:33:54 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Component Destructor
|
|
|
|
*/
|
2009-09-13 14:30:11 +00:00
|
|
|
static void snd_cx25821_dev_free(struct snd_card *card)
|
2009-09-15 14:33:54 +00:00
|
|
|
{
|
2010-03-14 15:44:37 +00:00
|
|
|
struct cx25821_audio_dev *chip = card->private_data;
|
2009-09-15 14:33:54 +00:00
|
|
|
|
2010-03-14 15:44:37 +00:00
|
|
|
/* snd_cx25821_free(chip); */
|
2009-09-15 14:33:54 +00:00
|
|
|
snd_card_free(chip->card);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Alsa Constructor - Component probe
|
|
|
|
*/
|
|
|
|
static int cx25821_audio_initdev(struct cx25821_dev *dev)
|
|
|
|
{
|
2009-09-13 14:30:11 +00:00
|
|
|
struct snd_card *card;
|
2010-03-14 15:44:37 +00:00
|
|
|
struct cx25821_audio_dev *chip;
|
2009-09-13 14:30:11 +00:00
|
|
|
int err;
|
2009-09-15 14:33:54 +00:00
|
|
|
|
2009-09-13 14:30:11 +00:00
|
|
|
if (devno >= SNDRV_CARDS) {
|
|
|
|
printk(KERN_INFO "DEBUG ERROR: devno >= SNDRV_CARDS %s\n",
|
|
|
|
__func__);
|
2010-03-14 15:44:37 +00:00
|
|
|
return -ENODEV;
|
2009-09-15 14:33:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!enable[devno]) {
|
|
|
|
++devno;
|
|
|
|
printk(KERN_INFO "DEBUG ERROR: !enable[devno] %s\n", __func__);
|
2010-03-14 15:44:37 +00:00
|
|
|
return -ENOENT;
|
2009-09-15 14:33:54 +00:00
|
|
|
}
|
|
|
|
|
2009-09-13 14:39:12 +00:00
|
|
|
err = snd_card_create(index[devno], id[devno], THIS_MODULE,
|
2010-03-14 15:44:37 +00:00
|
|
|
sizeof(struct cx25821_audio_dev), &card);
|
2009-09-13 14:39:12 +00:00
|
|
|
if (err < 0) {
|
2009-09-13 14:30:11 +00:00
|
|
|
printk(KERN_INFO
|
|
|
|
"DEBUG ERROR: cannot create snd_card_new in %s\n",
|
|
|
|
__func__);
|
2009-09-13 14:39:12 +00:00
|
|
|
return err;
|
2009-09-15 14:33:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
strcpy(card->driver, "cx25821");
|
|
|
|
|
|
|
|
/* Card "creation" */
|
|
|
|
card->private_free = snd_cx25821_dev_free;
|
2010-07-12 20:50:10 +00:00
|
|
|
chip = card->private_data;
|
2009-09-15 14:33:54 +00:00
|
|
|
spin_lock_init(&chip->reg_lock);
|
|
|
|
|
|
|
|
chip->dev = dev;
|
|
|
|
chip->card = card;
|
|
|
|
chip->pci = dev->pci;
|
|
|
|
chip->iobase = pci_resource_start(dev->pci, 0);
|
|
|
|
|
|
|
|
chip->irq = dev->pci->irq;
|
|
|
|
|
|
|
|
err = request_irq(dev->pci->irq, cx25821_irq,
|
|
|
|
IRQF_SHARED | IRQF_DISABLED, chip->dev->name, chip);
|
|
|
|
|
|
|
|
if (err < 0) {
|
2009-09-13 14:30:11 +00:00
|
|
|
printk(KERN_ERR "ERROR %s: can't get IRQ %d for ALSA\n",
|
|
|
|
chip->dev->name, dev->pci->irq);
|
2009-09-15 14:33:54 +00:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2010-04-28 17:17:00 +00:00
|
|
|
err = snd_cx25821_pcm(chip, 0, "cx25821 Digital");
|
|
|
|
if (err < 0) {
|
2009-09-13 14:30:11 +00:00
|
|
|
printk(KERN_INFO
|
|
|
|
"DEBUG ERROR: cannot create snd_cx25821_pcm %s\n",
|
|
|
|
__func__);
|
2009-09-15 14:33:54 +00:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
snd_card_set_dev(card, &chip->pci->dev);
|
|
|
|
|
|
|
|
strcpy(card->shortname, "cx25821");
|
2009-09-13 14:30:11 +00:00
|
|
|
sprintf(card->longname, "%s at 0x%lx irq %d", chip->dev->name,
|
|
|
|
chip->iobase, chip->irq);
|
|
|
|
strcpy(card->mixername, "CX25821");
|
2009-09-15 14:33:54 +00:00
|
|
|
|
2009-09-13 14:30:11 +00:00
|
|
|
printk(KERN_INFO "%s/%i: ALSA support for cx25821 boards\n",
|
|
|
|
card->driver, devno);
|
2009-09-15 14:33:54 +00:00
|
|
|
|
|
|
|
err = snd_card_register(card);
|
2009-09-13 14:30:11 +00:00
|
|
|
if (err < 0) {
|
|
|
|
printk(KERN_INFO "DEBUG ERROR: cannot register sound card %s\n",
|
|
|
|
__func__);
|
2009-09-15 14:33:54 +00:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
snd_cx25821_cards[devno] = card;
|
|
|
|
|
|
|
|
devno++;
|
|
|
|
return 0;
|
|
|
|
|
2010-03-14 15:44:37 +00:00
|
|
|
error:
|
2009-09-15 14:33:54 +00:00
|
|
|
snd_card_free(card);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
LINUX MODULE INIT
|
|
|
|
****************************************************************************/
|
|
|
|
static void cx25821_audio_fini(void)
|
|
|
|
{
|
|
|
|
snd_card_free(snd_cx25821_cards[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Module initializer
|
|
|
|
*
|
|
|
|
* Loops through present saa7134 cards, and assigns an ALSA device
|
|
|
|
* to each one
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static int cx25821_alsa_init(void)
|
|
|
|
{
|
|
|
|
struct cx25821_dev *dev = NULL;
|
|
|
|
struct list_head *list;
|
|
|
|
|
2009-09-13 14:30:11 +00:00
|
|
|
list_for_each(list, &cx25821_devlist) {
|
2009-09-15 14:33:54 +00:00
|
|
|
dev = list_entry(list, struct cx25821_dev, devlist);
|
|
|
|
cx25821_audio_initdev(dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dev == NULL)
|
2009-09-13 14:30:11 +00:00
|
|
|
printk(KERN_INFO
|
|
|
|
"cx25821 ERROR ALSA: no cx25821 cards found\n");
|
2009-09-15 14:33:54 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
late_initcall(cx25821_alsa_init);
|
|
|
|
module_exit(cx25821_audio_fini);
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------- */
|
|
|
|
/*
|
|
|
|
* Local variables:
|
|
|
|
* c-basic-offset: 8
|
|
|
|
* End:
|
|
|
|
*/
|