Commit bd15eba3 authored by Ricardo Cerqueira's avatar Ricardo Cerqueira Committed by Linus Torvalds

[PATCH] v4l: 720: alsa support for saa7134 that should work wonderful

- Alsa support for saa7134 that should work.
Signed-off-by: default avatarRicardo Cerqueira <v4l@cerqueira.org>
Signed-off-by: default avatarNickolay V. Shmyrev <nshmyrev@yandex.ru>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@brturbo.com.br>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 2f8d4f51
/* /*
* SAA713x ALSA support for V4L
* Ricardo Cerqueira <v4l@cerqueira.org>
* *
* Support for audio capture
* PCI function #1 of the saa7134
* *
* (c) 2005 Mauro Carvalho Chehab <mchehab@brturbo.com.br> * Caveats:
* (c) 2004 Gerd Knorr <kraxel@bytesex.org> * I still haven't got the mixer settings right.
* (c) 2003 Clemens Ladisch <clemens@ladisch.de> *
* - Volume doesn't work (it's always at max)
* - There's no "memory" of the capture channel. It can be changed,
* but alsamixer doesn't show it after a module restart (rmmod/insmod)
*
* Hotswapping DOES NOT work yet! Please remove the module before
* inserting cardbus cards. pcmcia-cs or pccardd should load it
* properly after insertion, and things will work
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation, version 2
* (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
...@@ -19,525 +25,797 @@ ...@@ -19,525 +25,797 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/ */
#include <linux/module.h>
#include <linux/init.h>
#include <linux/device.h>
#include <linux/interrupt.h>
#include <asm/delay.h>
#include <sound/driver.h> #include <sound/driver.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/time.h>
#include <linux/wait.h>
#include <linux/moduleparam.h>
#include <linux/module.h>
#include <sound/core.h> #include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/control.h> #include <sound/control.h>
#include <sound/pcm.h>
#include <sound/rawmidi.h>
#include <sound/initval.h> #include <sound/initval.h>
#include "saa7134.h" #include "saa7134.h"
#include "saa7134-reg.h" #include "saa7134-reg.h"
#define dprintk(level,fmt, arg...) if (debug >= level) \ static unsigned int alsa_debug = 0;
printk(KERN_DEBUG "%s/1: " fmt, chip->core->name , ## arg) module_param(alsa_debug, int, 0644);
MODULE_PARM_DESC(alsa_debug,"enable debug messages [alsa]");
#define MAX_PCM_DEVICES 1
#define MAX_PCM_SUBSTREAMS 1
/* defaults */
#define MAX_BUFFER_SIZE (256*1024)
#define USE_FORMATS SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE | SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_U16_LE | SNDRV_PCM_FMTBIT_U16_BE
#define USE_RATE SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000
#define USE_RATE_MIN 32000
#define USE_RATE_MAX 48000
#define USE_CHANNELS_MIN 1
#define USE_CHANNELS_MAX 2
#ifndef USE_PERIODS_MIN
#define USE_PERIODS_MIN 2
#endif
#ifndef USE_PERIODS_MAX
#define USE_PERIODS_MAX 1024
#endif
/****************************************************************************
Data type declarations - Can be moded to a header file later
****************************************************************************/
#define ANALOG_CLOCK 1792000 #define dprintk(fmt, arg...) if (alsa_debug) \
#define CLOCK_DIV_MIN 4 printk(KERN_DEBUG "%s/alsa: " fmt, dev->name , ## arg)
#define CLOCK_DIV_MAX 15
#define MAX_PCM_DEVICES 4
#define MAX_PCM_SUBSTREAMS 16
enum { DEVICE_DIGITAL, DEVICE_ANALOG };
/* These can be replaced after done */ static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
#define MIXER_ADDR_LAST MAX_saa7134_INPUT static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
static int enable[SNDRV_CARDS] = {1, [1 ... (SNDRV_CARDS - 1)] = 0};
struct saa7134_audio_dev { #define MIXER_ADDR_TVTUNER 0
struct saa7134_core *core; #define MIXER_ADDR_LINE1 1
struct saa7134_buffer *buf; #define MIXER_ADDR_LINE2 2
struct saa7134_dmaqueue q; #define MIXER_ADDR_LAST 2
/* pci i/o */ typedef struct snd_card_saa7134 {
snd_card_t *card;
spinlock_t mixer_lock;
int mixer_volume[MIXER_ADDR_LAST+1][2];
int capture_source[MIXER_ADDR_LAST+1][2];
struct pci_dev *pci; struct pci_dev *pci;
unsigned char pci_rev,pci_lat; struct saa7134_dev *saadev;
/* audio controls */ unsigned long iobase;
int irq; int irq;
int dig_rate; /* Digital sampling rate */
snd_card_t *card; spinlock_t lock;
} snd_card_saa7134_t;
spinlock_t reg_lock; typedef struct snd_card_saa7134_pcm {
struct saa7134_dev *saadev;
unsigned int dma_size; spinlock_t lock;
unsigned int period_size; unsigned int pcm_size; /* buffer size */
unsigned int pcm_count; /* bytes per period */
unsigned int pcm_bps; /* bytes per second */
snd_pcm_substream_t *substream;
} snd_card_saa7134_pcm_t;
int mixer_volume[MIXER_ADDR_LAST+1][2]; static snd_card_t *snd_saa7134_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
int capture_source[MIXER_ADDR_LAST+1][2];
long opened; static void saa7134_dma_stop(struct saa7134_dev *dev)
snd_pcm_substream_t *substream; {
}; dev->oss.dma_blk = -1;
typedef struct saa7134_audio_dev snd_saa7134_card_t; dev->oss.dma_running = 0;
saa7134_set_dmabits(dev);
}
/**************************************************************************** static void saa7134_dma_start(struct saa7134_dev *dev)
Module global static vars {
****************************************************************************/ dev->oss.dma_blk = 0;
dev->oss.dma_running = 1;
saa7134_set_dmabits(dev);
}
static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ void saa7134_irq_alsa_done(struct saa7134_dev *dev, unsigned long status)
static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ {
static int enable[SNDRV_CARDS] = {1, [1 ... (SNDRV_CARDS - 1)] = 1}; int next_blk, reg = 0;
module_param_array(enable, bool, NULL, 0444); spin_lock(&dev->slock);
MODULE_PARM_DESC(enable, "Enable saa7134x soundcard. default enabled."); if (UNSET == dev->oss.dma_blk) {
dprintk("irq: recording stopped\n");
goto done;
}
if (0 != (status & 0x0f000000))
dprintk("irq: lost %ld\n", (status >> 24) & 0x0f);
if (0 == (status & 0x10000000)) {
/* odd */
if (0 == (dev->oss.dma_blk & 0x01))
reg = SAA7134_RS_BA1(6);
} else {
/* even */
if (1 == (dev->oss.dma_blk & 0x01))
reg = SAA7134_RS_BA2(6);
}
if (0 == reg) {
dprintk("irq: field oops [%s]\n",
(status & 0x10000000) ? "even" : "odd");
goto done;
}
/**************************************************************************** if (dev->oss.read_count >= dev->oss.blksize * (dev->oss.blocks-2)) {
Module macros dprintk("irq: overrun [full=%d/%d] - Blocks in %d\n",dev->oss.read_count,
****************************************************************************/ dev->oss.bufsize, dev->oss.blocks);
saa7134_dma_stop(dev);
goto done;
}
MODULE_DESCRIPTION("ALSA driver module for saa7134 based TV cards"); /* next block addr */
MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@brturbo.com.br>"); next_blk = (dev->oss.dma_blk + 2) % dev->oss.blocks;
MODULE_LICENSE("GPL"); saa_writel(reg,next_blk * dev->oss.blksize);
MODULE_SUPPORTED_DEVICE("{{Philips, saa7131E}," if (alsa_debug > 2)
"{{Philips, saa7134}," dprintk("irq: ok, %s, next_blk=%d, addr=%x, blocks=%u, size=%u, read=%u\n",
"{{Philips, saa7133}"); (status & 0x10000000) ? "even" : "odd ", next_blk,
static unsigned int debug = 0; next_blk * dev->oss.blksize, dev->oss.blocks, dev->oss.blksize, dev->oss.read_count);
module_param(debug,int,0644);
MODULE_PARM_DESC(debug,"enable debug messages");
/****************************************************************************
Module specific funtions
****************************************************************************/
/* /* update status & wake waiting readers */
* BOARD Specific: Sets audio DMA dev->oss.dma_blk = (dev->oss.dma_blk + 1) % dev->oss.blocks;
*/ dev->oss.read_count += dev->oss.blksize;
dev->oss.recording_on = reg;
if (dev->oss.read_count >= snd_pcm_lib_period_bytes(dev->oss.substream)) {
spin_unlock(&dev->slock);
snd_pcm_period_elapsed(dev->oss.substream);
spin_lock(&dev->slock);
}
done:
spin_unlock(&dev->slock);
}
int saa7134_start_audio_dma(snd_saa7134_card_t *chip) static int snd_card_saa7134_capture_trigger(snd_pcm_substream_t * substream,
int cmd)
{ {
struct saa7134_core *core = chip->core; return 0;
}
static int dsp_buffer_conf(struct saa7134_dev *dev, int blksize, int blocks)
{
if (blksize < 0x100)
blksize = 0x100;
if (blksize > 0x10000)
blksize = 0x10000;
if (blocks < 2)
blocks = 2;
if ((blksize * blocks) > 1024*1024)
blocks = 1024*1024 / blksize;
dev->oss.blocks = blocks;
dev->oss.blksize = blksize;
dev->oss.bufsize = blksize * blocks;
dprintk("buffer config: %d blocks / %d bytes, %d kB total\n",
blocks,blksize,blksize * blocks / 1024);
return 0; return 0;
} }
/* static int dsp_buffer_init(struct saa7134_dev *dev)
* BOARD Specific: Resets audio DMA
*/
int saa7134_stop_audio_dma(snd_saa7134_card_t *chip)
{ {
struct saa7134_core *core=chip->core; int err;
if (!dev->oss.bufsize)
BUG();
videobuf_dma_init(&dev->oss.dma);
err = videobuf_dma_init_kernel(&dev->oss.dma, PCI_DMA_FROMDEVICE,
(dev->oss.bufsize + PAGE_SIZE) >> PAGE_SHIFT);
if (0 != err)
return err;
return 0; return 0;
} }
#define MAX_IRQ_LOOP 10
static void saa713401_timeout(unsigned long data) static int snd_card_saa7134_pcm_prepare(snd_pcm_substream_t * substream)
{ {
snd_saa7134_card_t *chip = (snd_saa7134_card_t *)data; snd_pcm_runtime_t *runtime = substream->runtime;
} int err, bswap, sign;
u32 fmt, control;
unsigned long flags;
snd_card_saa7134_t *saa7134 = snd_pcm_substream_chip(substream);
struct saa7134_dev *dev;
snd_card_saa7134_pcm_t *saapcm = runtime->private_data;
unsigned int bps;
unsigned long size;
unsigned count;
size = snd_pcm_lib_buffer_bytes(substream);
count = snd_pcm_lib_period_bytes(substream);
saapcm->saadev->oss.substream = substream;
bps = runtime->rate * runtime->channels;
bps *= snd_pcm_format_width(runtime->format);
bps /= 8;
if (bps <= 0)
return -EINVAL;
saapcm->pcm_bps = bps;
saapcm->pcm_size = snd_pcm_lib_buffer_bytes(substream);
saapcm->pcm_count = snd_pcm_lib_period_bytes(substream);
/* FIXME: Wrong values*/
static char *saa7134_aud_irqs[32] = {
"y_risci1", "u_risci1", "v_risci1", "vbi_risc1",
"y_risci2", "u_risci2", "v_risci2", "vbi_risc2",
"y_oflow", "u_oflow", "v_oflow", "vbi_oflow",
"y_sync", "u_sync", "v_sync", "vbi_sync",
"opc_err", "par_err", "rip_err", "pci_abort",
};
dev=saa7134->saadev;
static void saa713401_aud_irq(snd_saa7134_card_t *chip) dsp_buffer_conf(dev,saapcm->pcm_count,(saapcm->pcm_size/saapcm->pcm_count));
{
struct saa7134_core *core = chip->core;
}
static irqreturn_t saa7134_irq(int irq, void *dev_id, struct pt_regs *regs) err = dsp_buffer_init(dev);
{ if (0 != err)
snd_saa7134_card_t *chip = dev_id; goto fail2;
struct saa7134_core *core = chip->core;
}
/**************************************************************************** /* prepare buffer */
ALSA PCM Interface if (0 != (err = videobuf_dma_pci_map(dev->pci,&dev->oss.dma)))
****************************************************************************/ return err;
if (0 != (err = saa7134_pgtable_alloc(dev->pci,&dev->oss.pt)))
goto fail1;
if (0 != (err = saa7134_pgtable_build(dev->pci,&dev->oss.pt,
dev->oss.dma.sglist,
dev->oss.dma.sglen,
0)))
goto fail2;
switch (runtime->format) {
case SNDRV_PCM_FORMAT_U8:
case SNDRV_PCM_FORMAT_S8:
fmt = 0x00;
break;
case SNDRV_PCM_FORMAT_U16_LE:
case SNDRV_PCM_FORMAT_U16_BE:
case SNDRV_PCM_FORMAT_S16_LE:
case SNDRV_PCM_FORMAT_S16_BE:
fmt = 0x01;
break;
default:
err = -EINVAL;
return 1;
}
/* switch (runtime->format) {
* Digital hardware definition case SNDRV_PCM_FORMAT_S8:
*/ case SNDRV_PCM_FORMAT_S16_LE:
static snd_pcm_hardware_t snd_saa7134_digital_hw = { case SNDRV_PCM_FORMAT_S16_BE:
.info = SNDRV_PCM_INFO_MMAP | sign = 1;
SNDRV_PCM_INFO_INTERLEAVED | break;
SNDRV_PCM_INFO_BLOCK_TRANSFER | default:
SNDRV_PCM_INFO_MMAP_VALID, sign = 0;
.formats = SNDRV_PCM_FMTBIT_S16_LE, break;
.rates = 0, /* set at runtime */ }
.channels_min = 2,
.channels_max = 2, switch (runtime->format) {
.buffer_bytes_max = 255 * 4092, case SNDRV_PCM_FORMAT_U16_BE:
.period_bytes_min = 32, case SNDRV_PCM_FORMAT_S16_BE:
.period_bytes_max = 4092, bswap = 1; break;
.periods_min = 2, default:
.periods_max = 255, bswap = 0; break;
}; }
switch (dev->pci->device) {
case PCI_DEVICE_ID_PHILIPS_SAA7134:
if (1 == runtime->channels)
fmt |= (1 << 3);
if (2 == runtime->channels)
fmt |= (3 << 3);
if (sign)
fmt |= 0x04;
fmt |= (MIXER_ADDR_TVTUNER == dev->oss.input) ? 0xc0 : 0x80;
saa_writeb(SAA7134_NUM_SAMPLES0, ((dev->oss.blksize - 1) & 0x0000ff));
saa_writeb(SAA7134_NUM_SAMPLES1, ((dev->oss.blksize - 1) & 0x00ff00) >> 8);
saa_writeb(SAA7134_NUM_SAMPLES2, ((dev->oss.blksize - 1) & 0xff0000) >> 16);
saa_writeb(SAA7134_AUDIO_FORMAT_CTRL, fmt);
break;
case PCI_DEVICE_ID_PHILIPS_SAA7133:
case PCI_DEVICE_ID_PHILIPS_SAA7135:
if (1 == runtime->channels)
fmt |= (1 << 4);
if (2 == runtime->channels)
fmt |= (2 << 4);
if (!sign)
fmt |= 0x04;
//saa_writel(SAA7133_NUM_SAMPLES, dev->oss.blksize -1);
saa_writel(SAA7133_NUM_SAMPLES, dev->oss.blksize -1);
saa_writel(SAA7133_AUDIO_CHANNEL, 0x543210 | (fmt << 24));
//saa_writel(SAA7133_AUDIO_CHANNEL, 0x543210);
break;
}
dprintk("rec_start: afmt=%d ch=%d => fmt=0x%x swap=%c\n",
runtime->format, runtime->channels, fmt,
bswap ? 'b' : '-');
/* dma: setup channel 6 (= AUDIO) */
control = SAA7134_RS_CONTROL_BURST_16 |
SAA7134_RS_CONTROL_ME |
(dev->oss.pt.dma >> 12);
if (bswap)
control |= SAA7134_RS_CONTROL_BSWAP;
runtime->dma_area = dev->oss.dma.vmalloc;
saa_writel(SAA7134_RS_BA1(6),0);
saa_writel(SAA7134_RS_BA2(6),dev->oss.blksize);
saa_writel(SAA7134_RS_PITCH(6),0);
saa_writel(SAA7134_RS_CONTROL(6),control);
dev->oss.rate = runtime->rate;
/* start dma */
spin_lock_irqsave(&dev->slock,flags);
saa7134_dma_start(dev);
spin_unlock_irqrestore(&dev->slock,flags);
/*
* Sets board to provide digital audio
*/
static int snd_saa7134_set_digital_hw(snd_saa7134_card_t *chip, snd_pcm_runtime_t *runtime)
{
return 0; return 0;
fail2:
saa7134_pgtable_free(dev->pci,&dev->oss.pt);
fail1:
videobuf_dma_pci_unmap(dev->pci,&dev->oss.dma);
return err;
} }
/* static int snd_card_saa7134_capture_prepare(snd_pcm_substream_t * substream)
* audio open callback {
*/ return snd_card_saa7134_pcm_prepare(substream);
static int snd_saa7134_pcm_open(snd_pcm_substream_t *substream) }
static snd_pcm_uframes_t snd_card_saa7134_pointer(snd_pcm_substream_t * substream)
{ {
snd_saa7134_card_t *chip = snd_pcm_substream_chip(substream);
snd_pcm_runtime_t *runtime = substream->runtime; snd_pcm_runtime_t *runtime = substream->runtime;
int err; snd_card_saa7134_pcm_t *saapcm = runtime->private_data;
struct saa7134_dev *dev=saapcm->saadev;
if (test_and_set_bit(0, &chip->opened))
return -EBUSY;
err = snd_saa7134_set_digital_hw(chip, runtime);
if (err < 0) if (dev->oss.read_count) {
goto _error; dev->oss.read_count -= snd_pcm_lib_period_bytes(substream);
dev->oss.read_offset += snd_pcm_lib_period_bytes(substream);
if (dev->oss.read_offset == dev->oss.bufsize)
dev->oss.read_offset = 0;
}
err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); //return bytes_to_frames(runtime, saa_readl(dev->oss.recording_on));
if (err < 0) return bytes_to_frames(runtime, dev->oss.read_offset);
goto _error; }
chip->substream = substream;
return 0;
_error: static snd_pcm_uframes_t snd_card_saa7134_capture_pointer(snd_pcm_substream_t * substream)
clear_bit(0, &chip->opened); {
smp_mb__after_clear_bit(); return snd_card_saa7134_pointer(substream);
return err;
} }
/* static snd_pcm_hardware_t snd_card_saa7134_capture =
* audio close callback
*/
static int snd_saa7134_close(snd_pcm_substream_t *substream)
{ {
snd_saa7134_card_t *chip = snd_pcm_substream_chip(substream); .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
SNDRV_PCM_INFO_BLOCK_TRANSFER |
SNDRV_PCM_INFO_MMAP_VALID),
.formats = USE_FORMATS,
.rates = USE_RATE,
.rate_min = USE_RATE_MIN,
.rate_max = USE_RATE_MAX,
.channels_min = USE_CHANNELS_MIN,
.channels_max = USE_CHANNELS_MAX,
.buffer_bytes_max = MAX_BUFFER_SIZE,
.period_bytes_min = 64,
.period_bytes_max = MAX_BUFFER_SIZE,
.periods_min = USE_PERIODS_MIN,
.periods_max = USE_PERIODS_MAX,
.fifo_size = 0x08070503,
};
chip->substream = NULL; static void snd_card_saa7134_runtime_free(snd_pcm_runtime_t *runtime)
clear_bit(0, &chip->opened); {
smp_mb__after_clear_bit(); snd_card_saa7134_pcm_t *saapcm = runtime->private_data;
return 0;
kfree(saapcm);
} }
/*
* hw_params callback static int snd_card_saa7134_hw_params(snd_pcm_substream_t * substream,
*/
static int snd_saa7134_hw_params(snd_pcm_substream_t * substream,
snd_pcm_hw_params_t * hw_params) snd_pcm_hw_params_t * hw_params)
{ {
return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
} }
/* static int snd_card_saa7134_hw_free(snd_pcm_substream_t * substream)
* hw free callback
*/
static int snd_saa7134_hw_free(snd_pcm_substream_t * substream)
{ {
return snd_pcm_lib_free_pages(substream); return snd_pcm_lib_free_pages(substream);
} }
/* static int dsp_buffer_free(struct saa7134_dev *dev)
* prepare callback {
*/ if (!dev->oss.blksize)
static int snd_saa7134_prepare(snd_pcm_substream_t *substream) BUG();
videobuf_dma_free(&dev->oss.dma);
dev->oss.blocks = 0;
dev->oss.blksize = 0;
dev->oss.bufsize = 0;
return 0;
}
static int saa7134_cap_close(struct saa7134_dev *dev)
{ {
snd_saa7134_card_t *chip = snd_pcm_substream_chip(substream); unsigned long flags;
/* stop dma */
spin_lock_irqsave(&dev->slock,flags);
saa7134_dma_stop(dev);
spin_unlock_irqrestore(&dev->slock,flags);
/* unlock buffer */
saa7134_pgtable_free(dev->pci,&dev->oss.pt);
videobuf_dma_pci_unmap(dev->pci,&dev->oss.dma);
dsp_buffer_free(dev);
return 0; return 0;
} }
/* static int saa7134_cap_open(struct saa7134_dev *dev) {
* trigger callback
*/ down(&dev->oss.lock);
static int snd_saa7134_card_trigger(snd_pcm_substream_t *substream, int cmd)
dev->oss.afmt = SNDRV_PCM_FORMAT_U8;
dev->oss.channels = 2;
dev->oss.read_count = 0;
dev->oss.read_offset = 0;
up(&dev->oss.lock);
return 0;
}
static int snd_card_saa7134_capture_open(snd_pcm_substream_t * substream)
{ {
snd_saa7134_card_t *chip = snd_pcm_substream_chip(substream); snd_pcm_runtime_t *runtime = substream->runtime;
snd_card_saa7134_pcm_t *saapcm;
snd_card_saa7134_t *saa7134 = snd_pcm_substream_chip(substream);
int err;
switch (cmd) { saa7134_cap_open(saa7134->saadev);
case SNDRV_PCM_TRIGGER_START:
return snd_saa7134_start(chip); saapcm = kcalloc(1, sizeof(*saapcm), GFP_KERNEL);
case SNDRV_PCM_TRIGGER_STOP: if (saapcm == NULL)
return snd_saa7134_stop(chip); return -ENOMEM;
default: saapcm->saadev=saa7134->saadev;
return -EINVAL;
} spin_lock_init(&saapcm->lock);
saapcm->substream = substream;
runtime->private_data = saapcm;
runtime->private_free = snd_card_saa7134_runtime_free;
runtime->hw = snd_card_saa7134_capture;
if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0)
return err;
return 0;
} }
/* static int snd_card_saa7134_capture_close(snd_pcm_substream_t * substream)
* pointer callback
*/
static snd_pcm_uframes_t snd_saa7134_pointer(snd_pcm_substream_t *substream)
{ {
// snd_saa7134_card_t *chip = snd_pcm_substream_chip(substream); snd_card_saa7134_t *chip = snd_pcm_substream_chip(substream);
// snd_pcm_runtime_t *runtime = substream->runtime;
// return (snd_pcm_uframes_t)bytes_to_frames(runtime, chip->current_line * chip->line_bytes); saa7134_cap_close(chip->saadev);
return 0;
} }
/* static snd_pcm_ops_t snd_card_saa7134_capture_ops = {
* operators .open = snd_card_saa7134_capture_open,
*/ .close = snd_card_saa7134_capture_close,
static snd_pcm_ops_t snd_saa7134_pcm_ops = {
.open = snd_saa7134_pcm_open,
.close = snd_saa7134_close,
.ioctl = snd_pcm_lib_ioctl, .ioctl = snd_pcm_lib_ioctl,
.hw_params = snd_saa7134_hw_params, .hw_params = snd_card_saa7134_hw_params,
.hw_free = snd_saa7134_hw_free, .hw_free = snd_card_saa7134_hw_free,
.prepare = snd_saa7134_prepare, .prepare = snd_card_saa7134_capture_prepare,
.trigger = snd_saa7134_card_trigger, .trigger = snd_card_saa7134_capture_trigger,
.pointer = snd_saa7134_pointer, .pointer = snd_card_saa7134_capture_pointer,
.page = snd_pcm_sgbuf_ops_page,
}; };
/* static int __init snd_card_saa7134_pcm(snd_card_saa7134_t *saa7134, int device)
* create a PCM device
*/
static int __devinit snd_saa7134_pcm(snd_saa7134_card_t *chip, int device, char *name)
{ {
int err;
snd_pcm_t *pcm; snd_pcm_t *pcm;
int err;
err = snd_pcm_new(chip->card, name, device, 0, 1, &pcm); if ((err = snd_pcm_new(saa7134->card, "SAA7134 PCM", device, 0, 1, &pcm)) < 0)
if (err < 0)
return err; return err;
pcm->private_data = chip; snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_card_saa7134_capture_ops);
strcpy(pcm->name, name); pcm->private_data = saa7134;
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_saa7134_pcm_ops); pcm->info_flags = 0;
return snd_pcm_lib_preallocate_pages_for_all(pcm, strcpy(pcm->name, "SAA7134 PCM");
SNDRV_DMA_TYPE_DEV_SG, snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
snd_dma_pci_data(chip->pci), snd_dma_pci_data(saa7134->pci),
128 * 1024, 128*1024, 256*1024);
(255 * 4092 + 1023) & ~1023); return 0;
} }
/**************************************************************************** #define SAA713x_VOLUME(xname, xindex, addr) \
CONTROL INTERFACE { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
****************************************************************************/ .info = snd_saa7134_volume_info, \
static int snd_saa7134_capture_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *info) .get = snd_saa7134_volume_get, .put = snd_saa7134_volume_put, \
.private_value = addr }
static int snd_saa7134_volume_info(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t * uinfo)
{ {
info->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
info->count = 1; uinfo->count = 2;
info->value.integer.min = 0; uinfo->value.integer.min = 0;
info->value.integer.max = 0x3f; uinfo->value.integer.max = 20;
return 0;
}
static int snd_saa7134_volume_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
{
snd_card_saa7134_t *chip = snd_kcontrol_chip(kcontrol);
unsigned long flags;
int addr = kcontrol->private_value;
spin_lock_irqsave(&chip->mixer_lock, flags);
ucontrol->value.integer.value[0] = chip->mixer_volume[addr][0];
ucontrol->value.integer.value[1] = chip->mixer_volume[addr][1];
spin_unlock_irqrestore(&chip->mixer_lock, flags);
return 0; return 0;
} }
/* OK - TODO: test it */ static int snd_saa7134_volume_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
static int snd_saa7134_capture_volume_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *value)
{ {
snd_saa7134_card_t *chip = snd_kcontrol_chip(kcontrol); snd_card_saa7134_t *chip = snd_kcontrol_chip(kcontrol);
struct saa7134_core *core=chip->core; unsigned long flags;
int change, addr = kcontrol->private_value;
int left, right;
left = ucontrol->value.integer.value[0];
if (left < 0)
left = 0;
if (left > 20)
left = 20;
right = ucontrol->value.integer.value[1];
if (right < 0)
right = 0;
if (right > 20)
right = 20;
spin_lock_irqsave(&chip->mixer_lock, flags);
change = chip->mixer_volume[addr][0] != left ||
chip->mixer_volume[addr][1] != right;
chip->mixer_volume[addr][0] = left;
chip->mixer_volume[addr][1] = right;
spin_unlock_irqrestore(&chip->mixer_lock, flags);
return change;
}
#define SAA713x_CAPSRC(xname, xindex, addr) \
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
.info = snd_saa7134_capsrc_info, \
.get = snd_saa7134_capsrc_get, .put = snd_saa7134_capsrc_put, \
.private_value = addr }
static int snd_saa7134_capsrc_info(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t * uinfo)
{
uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
uinfo->count = 1;
uinfo->value.integer.min = 0;
uinfo->value.integer.max = 1;
return 0; return 0;
} }
/* OK - TODO: test it */ static int snd_saa7134_capsrc_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
static int snd_saa7134_capture_volume_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *value)
{ {
snd_saa7134_card_t *chip = snd_kcontrol_chip(kcontrol); snd_card_saa7134_t *chip = snd_kcontrol_chip(kcontrol);
struct saa7134_core *core=chip->core; unsigned long flags;
int addr = kcontrol->private_value;
spin_lock_irqsave(&chip->mixer_lock, flags);
ucontrol->value.integer.value[0] = chip->capture_source[addr][0];
ucontrol->value.integer.value[1] = chip->capture_source[addr][1];
spin_unlock_irqrestore(&chip->mixer_lock, flags);
return 0; return 0;
} }
static snd_kcontrol_new_t snd_saa7134_capture_volume = { static int snd_saa7134_capsrc_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
.iface = SNDRV_CTL_ELEM_IFACE_MIXER, {
.name = "Capture Volume", snd_card_saa7134_t *chip = snd_kcontrol_chip(kcontrol);
.info = snd_saa7134_capture_volume_info, unsigned long flags;
.get = snd_saa7134_capture_volume_get, int change, addr = kcontrol->private_value;
.put = snd_saa7134_capture_volume_put, int left, right;
}; u32 anabar, xbarin;
int analog_io, rate;
struct saa7134_dev *dev;
dev = chip->saadev;
left = ucontrol->value.integer.value[0] & 1;
right = ucontrol->value.integer.value[1] & 1;
spin_lock_irqsave(&chip->mixer_lock, flags);
change = chip->capture_source[addr][0] != left &&
chip->capture_source[addr][1] != right;
chip->capture_source[addr][0] = left;
chip->capture_source[addr][1] = right;
dev->oss.input=addr;
spin_unlock_irqrestore(&chip->mixer_lock, flags);
switch (dev->pci->device) {
case PCI_DEVICE_ID_PHILIPS_SAA7134:
switch (addr) {
case MIXER_ADDR_TVTUNER:
saa_andorb(SAA7134_AUDIO_FORMAT_CTRL, 0xc0, 0xc0);
saa_andorb(SAA7134_SIF_SAMPLE_FREQ, 0x03, 0x00);
break;
case MIXER_ADDR_LINE1:
case MIXER_ADDR_LINE2:
analog_io = (MIXER_ADDR_LINE1 == addr) ? 0x00 : 0x08;
rate = (32000 == dev->oss.rate) ? 0x01 : 0x03;
saa_andorb(SAA7134_ANALOG_IO_SELECT, 0x08, analog_io);
saa_andorb(SAA7134_AUDIO_FORMAT_CTRL, 0xc0, 0x80);
saa_andorb(SAA7134_SIF_SAMPLE_FREQ, 0x03, rate);
break;
}
/* case PCI_DEVICE_ID_PHILIPS_SAA7133:
*************************************** case PCI_DEVICE_ID_PHILIPS_SAA7135:
*/ xbarin = 0x03; // adc
anabar = 0;
switch (addr) {
case MIXER_ADDR_TVTUNER:
xbarin = 0; // Demodulator
anabar = 2; // DACs
break;
case MIXER_ADDR_LINE1:
anabar = 0; // aux1, aux1
break;
case MIXER_ADDR_LINE2:
anabar = 9; // aux2, aux2
break;
}
/**************************************************************************** /* output xbar always main channel */
Basic Flow for Sound Devices saa_dsp_writel(dev, SAA7133_DIGITAL_OUTPUT_SEL1, 0xbbbb10);
****************************************************************************/
if (left || right) { // We've got data, turn the input on
//saa_dsp_writel(dev, SAA7133_DIGITAL_OUTPUT_SEL2, 0x101010);
saa_dsp_writel(dev, SAA7133_DIGITAL_INPUT_XBAR1, xbarin);
saa_writel(SAA7133_ANALOG_IO_SELECT, anabar);
} else {
//saa_dsp_writel(dev, SAA7133_DIGITAL_OUTPUT_SEL2, 0x101010);
saa_dsp_writel(dev, SAA7133_DIGITAL_INPUT_XBAR1, 0);
saa_writel(SAA7133_ANALOG_IO_SELECT, 0);
}
}
/* return change;
* PCI ID Table - 14f1:8801 and 14f1:8811 means function 1: Audio }
* Only boards with eeprom and byte 1 at eeprom=1 have it
*/
struct pci_device_id saa7134_audio_pci_tbl[] = { static snd_kcontrol_new_t snd_saa7134_controls[] = {
{0x14f1,0x8801,PCI_ANY_ID,PCI_ANY_ID,0,0,0}, SAA713x_VOLUME("Video Volume", 0, MIXER_ADDR_TVTUNER),
{0x14f1,0x8811,PCI_ANY_ID,PCI_ANY_ID,0,0,0}, SAA713x_CAPSRC("Video Capture Switch", 0, MIXER_ADDR_TVTUNER),
{0, } SAA713x_VOLUME("Line Volume", 1, MIXER_ADDR_LINE1),
SAA713x_CAPSRC("Line Capture Switch", 1, MIXER_ADDR_LINE1),
SAA713x_VOLUME("Line Volume", 2, MIXER_ADDR_LINE2),
SAA713x_CAPSRC("Line Capture Switch", 2, MIXER_ADDR_LINE2),
}; };
MODULE_DEVICE_TABLE(pci, saa7134_audio_pci_tbl);
/* static int __init snd_card_saa7134_new_mixer(snd_card_saa7134_t * chip)
* Chip-specific destructor
*/
static int snd_saa7134_free(snd_saa7134_card_t *chip)
{ {
if (chip->irq >= 0) snd_card_t *card = chip->card;
free_irq(chip->irq, chip); unsigned int idx;
int err;
/* free memory */
saa7134_core_put(chip->core,chip->pci);
pci_release_regions(chip->pci); snd_assert(chip != NULL, return -EINVAL);
pci_disable_device(chip->pci); strcpy(card->mixername, "SAA7134 Mixer");
kfree(chip); for (idx = 0; idx < ARRAY_SIZE(snd_saa7134_controls); idx++) {
if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_saa7134_controls[idx], chip))) < 0)
return err;
}
return 0; return 0;
} }
/* static int snd_saa7134_free(snd_card_saa7134_t *chip)
* Component Destructor
*/
static int snd_saa7134_dev_free(snd_device_t *device)
{ {
snd_saa7134_card_t *chip = device->device_data; return 0;
return snd_saa7134_free(chip);
} }
static int snd_saa7134_dev_free(snd_device_t *device)
/*
* Alsa Constructor - Component probe
*/
static int devno=0;
static int __devinit snd_saa7134_create(snd_card_t *card, struct pci_dev *pci,
snd_saa7134_card_t **rchip)
{ {
snd_saa7134_card_t *chip; snd_card_saa7134_t *chip = device->device_data;
struct saa7134_core *core; return snd_saa7134_free(chip);
return 0;
} }
static int __devinit saa7134_audio_initdev(struct pci_dev *pci, int alsa_card_saa7134_create(struct saa7134_dev *saadev)
const struct pci_device_id *pci_id)
{ {
static int dev;
snd_card_t *card; snd_card_t *card;
snd_saa7134_card_t *chip; struct snd_card_saa7134 *chip;
int err; int err;
static snd_device_ops_t ops = {
if (devno >= SNDRV_CARDS) .dev_free = snd_saa7134_dev_free,
return (-ENODEV); };
if (!enable[devno]) { if (dev >= SNDRV_CARDS)
++devno; return -ENODEV;
return (-ENOENT); if (!enable[dev])
return -ENODEV;
card = snd_card_new(index[dev], id[dev], THIS_MODULE,
sizeof(struct snd_card_saa7134));
if (card == NULL)
return -ENOMEM;
strcpy(card->driver, "SAA7134");
/* Card "creation" */
chip = kcalloc(1, sizeof(*chip), GFP_KERNEL);
if (chip == NULL) {
return -ENOMEM;
} }
card = snd_card_new(index[devno], id[devno], THIS_MODULE, 0); spin_lock_init(&chip->lock);
if (!card)
return (-ENOMEM);
err = snd_saa7134_create(card, pci, &chip); chip->saadev = saadev;
if (err < 0)
return (err);
/* chip->card = card;
err = snd_saa7134_pcm(chip, DEVICE_DIGITAL, "saa7134 Digital"); chip->pci = saadev->pci;
if (err < 0) chip->irq = saadev->pci->irq;
goto fail_free; chip->iobase = pci_resource_start(saadev->pci, 0);
*/
err = snd_ctl_add(card, snd_ctl_new1(&snd_saa7134_capture_volume, chip));
if (err < 0) {
snd_card_free(card);
return (err);
}
strcpy (card->driver, "saa7134_ALSA"); if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
sprintf(card->shortname, "Saa7134 %x", pci->device); snd_saa7134_free(chip);
sprintf(card->longname, "%s at %#lx", return err;
card->shortname, pci_resource_start(pci, 0)); }
strcpy (card->mixername, "saa7134");
dprintk (0, "%s/%i: Alsa support for saa7134x boards\n",
card->driver,devno);
err = snd_card_register(card); if ((err = snd_card_saa7134_new_mixer(chip)) < 0)
if (err < 0) { goto __nodev;
snd_card_free(card);
return (err);
}
pci_set_drvdata(pci,card); if ((err = snd_card_saa7134_pcm(chip, 0)) < 0)
goto __nodev;
spin_lock_init(&chip->mixer_lock);
devno++; snd_card_set_dev(card, &chip->pci->dev);
return 0;
}
/*
* ALSA destructor
*/
static void __devexit saa7134_audio_finidev(struct pci_dev *pci)
{
snd_card_free(pci_get_drvdata(pci));
pci_set_drvdata(pci, NULL);
devno--; /* End of "creation" */
}
/* strcpy(card->shortname, "SAA7134");
* PCI driver definition sprintf(card->longname, "%s at 0x%lx irq %d",
*/ card->shortname, chip->iobase, chip->irq);
static struct pci_driver saa7134_audio_pci_driver = {
.name = "saa7134_audio",
.id_table = saa7134_audio_pci_tbl,
.probe = saa7134_audio_initdev,
.remove = saa7134_audio_finidev,
SND_PCI_PM_CALLBACKS
};
/**************************************************************************** if ((err = snd_card_register(card)) == 0) {
LINUX MODULE INIT snd_saa7134_cards[dev] = card;
****************************************************************************/ return 0;
}
/* __nodev:
* module init snd_card_free(card);
*/ kfree(card);
static int saa7134_audio_init(void) return err;
{
printk(KERN_INFO "saa7134x alsa driver version %d.%d.%d loaded\n",
(saa7134_VERSION_CODE >> 16) & 0xff,
(saa7134_VERSION_CODE >> 8) & 0xff,
saa7134_VERSION_CODE & 0xff);
#ifdef SNAPSHOT
printk(KERN_INFO "saa7134x: snapshot date %04d-%02d-%02d\n",
SNAPSHOT/10000, (SNAPSHOT/100)%100, SNAPSHOT%100);
#endif
return pci_module_init(&saa7134_audio_pci_driver);
} }
/* void alsa_card_saa7134_exit(void)
* module remove
*/
static void saa7134_audio_fini(void)
{ {
pci_unregister_driver(&saa7134_audio_pci_driver); int idx;
for (idx = 0; idx < SNDRV_CARDS; idx++) {
snd_card_free(snd_saa7134_cards[idx]);
}
} }
module_init(saa7134_audio_init);
module_exit(saa7134_audio_fini);
/* ----------------------------------------------------------- */
/*
* Local variables:
* c-basic-offset: 8
* End:
*/
...@@ -57,6 +57,10 @@ static unsigned int oss = 0; ...@@ -57,6 +57,10 @@ static unsigned int oss = 0;
module_param(oss, int, 0444); module_param(oss, int, 0444);
MODULE_PARM_DESC(oss,"register oss devices (default: no)"); MODULE_PARM_DESC(oss,"register oss devices (default: no)");
static unsigned int alsa = 0;
module_param(alsa, int, 0444);
MODULE_PARM_DESC(alsa,"register alsa devices (default: no)");
static unsigned int latency = UNSET; static unsigned int latency = UNSET;
module_param(latency, int, 0444); module_param(latency, int, 0444);
MODULE_PARM_DESC(latency,"pci latency timer"); MODULE_PARM_DESC(latency,"pci latency timer");
...@@ -591,13 +595,19 @@ static irqreturn_t saa7134_irq(int irq, void *dev_id, struct pt_regs *regs) ...@@ -591,13 +595,19 @@ static irqreturn_t saa7134_irq(int irq, void *dev_id, struct pt_regs *regs)
card_has_mpeg(dev)) card_has_mpeg(dev))
saa7134_irq_ts_done(dev,status); saa7134_irq_ts_done(dev,status);
if ((report & SAA7134_IRQ_REPORT_DONE_RA3)) if ((report & SAA7134_IRQ_REPORT_DONE_RA3)) {
if (oss) {
saa7134_irq_oss_done(dev,status); saa7134_irq_oss_done(dev,status);
} else if (alsa) {
saa7134_irq_alsa_done(dev,status);
}
}
if ((report & (SAA7134_IRQ_REPORT_GPIO16 | if ((report & (SAA7134_IRQ_REPORT_GPIO16 |
SAA7134_IRQ_REPORT_GPIO18)) && SAA7134_IRQ_REPORT_GPIO18)) &&
dev->remote) dev->remote)
saa7134_input_irq(dev); saa7134_input_irq(dev);
} }
if (10 == loop) { if (10 == loop) {
...@@ -1016,6 +1026,10 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev, ...@@ -1016,6 +1026,10 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
goto fail5; goto fail5;
printk(KERN_INFO "%s: registered device mixer%d\n", printk(KERN_INFO "%s: registered device mixer%d\n",
dev->name,dev->oss.minor_mixer >> 4); dev->name,dev->oss.minor_mixer >> 4);
} else if (alsa) {
alsa_card_saa7134_create(dev);
printk(KERN_INFO "%s: registered ALSA devices\n",
dev->name);
} }
break; break;
} }
...@@ -1043,6 +1057,8 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev, ...@@ -1043,6 +1057,8 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
case PCI_DEVICE_ID_PHILIPS_SAA7135: case PCI_DEVICE_ID_PHILIPS_SAA7135:
if (oss) if (oss)
unregister_sound_dsp(dev->oss.minor_dsp); unregister_sound_dsp(dev->oss.minor_dsp);
else if (alsa)
alsa_card_saa7134_exit();
break; break;
} }
fail4: fail4:
...@@ -1102,7 +1118,8 @@ static void __devexit saa7134_finidev(struct pci_dev *pci_dev) ...@@ -1102,7 +1118,8 @@ static void __devexit saa7134_finidev(struct pci_dev *pci_dev)
if (oss) { if (oss) {
unregister_sound_mixer(dev->oss.minor_mixer); unregister_sound_mixer(dev->oss.minor_mixer);
unregister_sound_dsp(dev->oss.minor_dsp); unregister_sound_dsp(dev->oss.minor_dsp);
} } else if (alsa)
alsa_card_saa7134_exit();
break; break;
} }
saa7134_unregister_video(dev); saa7134_unregister_video(dev);
......
...@@ -44,6 +44,7 @@ MODULE_PARM_DESC(oss_rate,"sample rate (valid are: 32000,48000)"); ...@@ -44,6 +44,7 @@ MODULE_PARM_DESC(oss_rate,"sample rate (valid are: 32000,48000)");
#define dprintk(fmt, arg...) if (oss_debug) \ #define dprintk(fmt, arg...) if (oss_debug) \
printk(KERN_DEBUG "%s/oss: " fmt, dev->name , ## arg) printk(KERN_DEBUG "%s/oss: " fmt, dev->name , ## arg)
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
static int dsp_buffer_conf(struct saa7134_dev *dev, int blksize, int blocks) static int dsp_buffer_conf(struct saa7134_dev *dev, int blksize, int blocks)
...@@ -173,8 +174,8 @@ static int dsp_rec_start(struct saa7134_dev *dev) ...@@ -173,8 +174,8 @@ static int dsp_rec_start(struct saa7134_dev *dev)
fmt |= (2 << 4); fmt |= (2 << 4);
if (!sign) if (!sign)
fmt |= 0x04; fmt |= 0x04;
saa_writel(0x588 >> 2, dev->oss.blksize -4); saa_writel(SAA7133_NUM_SAMPLES, dev->oss.blksize -4);
saa_writel(0x58c >> 2, 0x543210 | (fmt << 24)); saa_writel(SAA7133_AUDIO_CHANNEL, 0x543210 | (fmt << 24));
break; break;
} }
dprintk("rec_start: afmt=%d ch=%d => fmt=0x%x swap=%c\n", dprintk("rec_start: afmt=%d ch=%d => fmt=0x%x swap=%c\n",
......
...@@ -43,6 +43,14 @@ ...@@ -43,6 +43,14 @@
#define SAA7134_FIFO_SIZE (0x2a0 >> 2) #define SAA7134_FIFO_SIZE (0x2a0 >> 2)
#define SAA7134_THRESHOULD (0x2a4 >> 2) #define SAA7134_THRESHOULD (0x2a4 >> 2)
#define SAA7133_NUM_SAMPLES (0x588 >> 2)
#define SAA7133_AUDIO_CHANNEL (0x58c >> 2)
#define SAA7133_AUDIO_FORMAT (0x58f >> 2)
#define SAA7133_DIGITAL_OUTPUT_SEL1 (0x46c >> 2)
#define SAA7133_DIGITAL_OUTPUT_SEL2 (0x470 >> 2)
#define SAA7133_DIGITAL_INPUT_XBAR1 (0x464 >> 2)
#define SAA7133_ANALOG_IO_SELECT (0x594 >> 2)
/* main control */ /* main control */
#define SAA7134_MAIN_CTRL (0x2a8 >> 2) #define SAA7134_MAIN_CTRL (0x2a8 >> 2)
#define SAA7134_MAIN_CTRL_VPLLE (1 << 15) #define SAA7134_MAIN_CTRL_VPLLE (1 << 15)
......
...@@ -45,6 +45,10 @@ ...@@ -45,6 +45,10 @@
#endif #endif
#define UNSET (-1U) #define UNSET (-1U)
#include <sound/driver.h>
#include <sound/core.h>
#include <sound/pcm.h>
/* ----------------------------------------------------------- */ /* ----------------------------------------------------------- */
/* enums */ /* enums */
...@@ -364,6 +368,7 @@ struct saa7134_oss { ...@@ -364,6 +368,7 @@ struct saa7134_oss {
unsigned int dma_blk; unsigned int dma_blk;
unsigned int read_offset; unsigned int read_offset;
unsigned int read_count; unsigned int read_count;
snd_pcm_substream_t *substream;
}; };
/* IR input */ /* IR input */
...@@ -644,6 +649,11 @@ int saa7134_input_init1(struct saa7134_dev *dev); ...@@ -644,6 +649,11 @@ int saa7134_input_init1(struct saa7134_dev *dev);
void saa7134_input_fini(struct saa7134_dev *dev); void saa7134_input_fini(struct saa7134_dev *dev);
void saa7134_input_irq(struct saa7134_dev *dev); void saa7134_input_irq(struct saa7134_dev *dev);
int alsa_card_saa7134_create(struct saa7134_dev *saadev);
void alsa_card_saa7134_exit(void);
void saa7134_irq_alsa_done(struct saa7134_dev *dev, unsigned long status);
/* /*
* Local variables: * Local variables:
* c-basic-offset: 8 * c-basic-offset: 8
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment