summaryrefslogtreecommitdiff
path: root/linux/drivers
diff options
context:
space:
mode:
authorRicardo Cerqueira <devnull@localhost>2005-11-09 03:33:33 +0000
committerRicardo Cerqueira <devnull@localhost>2005-11-09 03:33:33 +0000
commit7c193cbbeba19ca648dfaf3f8f456883b4c48179 (patch)
tree8002de7245b18e12a86d9ebf368f2a57b0798fc7 /linux/drivers
parentd1bf97514d0d973acd720439564cb09ee92a025c (diff)
downloadmediapointer-dvb-s2-7c193cbbeba19ca648dfaf3f8f456883b4c48179.tar.gz
mediapointer-dvb-s2-7c193cbbeba19ca648dfaf3f8f456883b4c48179.tar.bz2
Finish split of DMA sound code from main saa7134 module
From: - saa7134-oss is now a standalone module as well - remaining DMA sound code has been removed from core the module - Lots of small cleanups and variable renames to get more consistency between the OSS and ALSA drivers Signed-off-by: Ricardo Cerqueira <v4l@cerqueira.org>
Diffstat (limited to 'linux/drivers')
-rw-r--r--linux/drivers/media/video/saa7134/Makefile6
-rw-r--r--linux/drivers/media/video/saa7134/saa7134-alsa.c82
-rw-r--r--linux/drivers/media/video/saa7134/saa7134-core.c124
-rw-r--r--linux/drivers/media/video/saa7134/saa7134-oss.c162
-rw-r--r--linux/drivers/media/video/saa7134/saa7134.h3
5 files changed, 233 insertions, 144 deletions
diff --git a/linux/drivers/media/video/saa7134/Makefile b/linux/drivers/media/video/saa7134/Makefile
index 23b251ae7..fe11e4feb 100644
--- a/linux/drivers/media/video/saa7134/Makefile
+++ b/linux/drivers/media/video/saa7134/Makefile
@@ -1,10 +1,10 @@
saa7134-objs := saa7134-cards.o saa7134-core.o saa7134-i2c.o \
- saa7134-oss.o saa7134-ts.o saa7134-tvaudio.o \
- saa7134-vbi.o saa7134-video.o saa7134-input.o \
- saa7134-alsa.o
+ saa7134-ts.o saa7134-tvaudio.o saa7134-vbi.o \
+ saa7134-video.o saa7134-input.o
obj-$(CONFIG_VIDEO_SAA7134) += saa7134.o saa7134-empress.o saa6752hs.o
+obj-$(CONFIG_VIDEO_SAA7134) += saa7134-alsa.o saa7134-oss.o
obj-$(CONFIG_VIDEO_SAA7134_DVB) += saa7134-dvb.o
EXTRA_CFLAGS += -I$(src)/..
diff --git a/linux/drivers/media/video/saa7134/saa7134-alsa.c b/linux/drivers/media/video/saa7134/saa7134-alsa.c
index 861cfbf65..9f0b4eee5 100644
--- a/linux/drivers/media/video/saa7134/saa7134-alsa.c
+++ b/linux/drivers/media/video/saa7134/saa7134-alsa.c
@@ -1,7 +1,7 @@
/*
* SAA713x ALSA support for V4L
*
- * $Id: saa7134-alsa.c,v 1.21 2005/11/08 21:07:27 rmcc Exp $
+ * $Id: saa7134-alsa.c,v 1.22 2005/11/09 03:33:33 rmcc Exp $
*
* Caveats:
* - Volume doesn't work (it's always at max)
@@ -83,7 +83,7 @@ typedef struct snd_card_saa7134 {
int mixer_volume[MIXER_ADDR_LAST+1][2];
int capture_source[MIXER_ADDR_LAST+1][2];
struct pci_dev *pci;
- struct saa7134_dev *saadev;
+ struct saa7134_dev *dev;
unsigned long iobase;
int irq;
@@ -101,7 +101,7 @@ typedef struct snd_card_saa7134 {
*/
typedef struct snd_card_saa7134_pcm {
- struct saa7134_dev *saadev;
+ struct saa7134_dev *dev;
spinlock_t lock;
unsigned int pcm_size; /* buffer size */
@@ -223,8 +223,9 @@ void saa7134_irq_alsa_done(struct saa7134_dev *dev, unsigned long status)
static irqreturn_t saa7134_alsa_irq(int irq, void *dev_id, struct pt_regs *regs)
{
- snd_card_saa7134_t *saa7134 = dev_id;
- struct saa7134_dev *dev = saa7134->saadev;
+ struct saa7134_dmasound *dmasound = dev_id;
+ struct saa7134_dev *dev = dmasound->priv_data;
+
unsigned long report, status;
int loop, handled = 0;
@@ -264,7 +265,7 @@ static int snd_card_saa7134_capture_trigger(snd_pcm_substream_t * substream,
{
snd_pcm_runtime_t *runtime = substream->runtime;
snd_card_saa7134_pcm_t *saapcm = runtime->private_data;
- struct saa7134_dev *dev=saapcm->saadev;
+ struct saa7134_dev *dev=saapcm->dev;
int err = 0;
spin_lock_irq(&dev->slock);
@@ -330,8 +331,8 @@ static int dsp_buffer_init(struct saa7134_dev *dev)
{
int err;
- if (!dev->dmasound.bufsize)
- BUG();
+ BUG_ON(!dev->dmasound.bufsize);
+
videobuf_dma_init(&dev->dmasound.dma);
err = videobuf_dma_init_kernel(&dev->dmasound.dma, PCI_DMA_FROMDEVICE,
(dev->dmasound.bufsize + PAGE_SIZE) >> PAGE_SHIFT);
@@ -367,7 +368,7 @@ static int snd_card_saa7134_capture_prepare(snd_pcm_substream_t * substream)
size = snd_pcm_lib_buffer_bytes(substream);
count = snd_pcm_lib_period_bytes(substream);
- saapcm->saadev->dmasound.substream = substream;
+ saapcm->dev->dmasound.substream = substream;
bps = runtime->rate * runtime->channels;
bps *= snd_pcm_format_width(runtime->format);
bps /= 8;
@@ -378,7 +379,7 @@ static int snd_card_saa7134_capture_prepare(snd_pcm_substream_t * substream)
saapcm->pcm_count = snd_pcm_lib_period_bytes(substream);
- dev=saa7134->saadev;
+ dev=saa7134->dev;
dsp_buffer_conf(dev,saapcm->pcm_count,(saapcm->pcm_size/saapcm->pcm_count));
@@ -512,7 +513,7 @@ static snd_pcm_uframes_t snd_card_saa7134_capture_pointer(snd_pcm_substream_t *
{
snd_pcm_runtime_t *runtime = substream->runtime;
snd_card_saa7134_pcm_t *saapcm = runtime->private_data;
- struct saa7134_dev *dev=saapcm->saadev;
+ struct saa7134_dev *dev=saapcm->dev;
@@ -629,7 +630,7 @@ static int dsp_buffer_free(struct saa7134_dev *dev)
static int snd_card_saa7134_capture_close(snd_pcm_substream_t * substream)
{
snd_card_saa7134_t *chip = snd_pcm_substream_chip(substream);
- struct saa7134_dev *dev = chip->saadev;
+ struct saa7134_dev *dev = chip->dev;
/* unlock buffer */
saa7134_pgtable_free(dev->pci,&dev->dmasound.pt);
@@ -654,7 +655,7 @@ static int snd_card_saa7134_capture_open(snd_pcm_substream_t * substream)
snd_pcm_runtime_t *runtime = substream->runtime;
snd_card_saa7134_pcm_t *saapcm;
snd_card_saa7134_t *saa7134 = snd_pcm_substream_chip(substream);
- struct saa7134_dev *dev = saa7134->saadev;
+ struct saa7134_dev *dev = saa7134->dev;
int err;
down(&dev->dmasound.lock);
@@ -669,7 +670,7 @@ static int snd_card_saa7134_capture_open(snd_pcm_substream_t * substream)
saapcm = kzalloc(sizeof(*saapcm), GFP_KERNEL);
if (saapcm == NULL)
return -ENOMEM;
- saapcm->saadev=saa7134->saadev;
+ saapcm->dev=saa7134->dev;
spin_lock_init(&saapcm->lock);
@@ -809,7 +810,7 @@ static int snd_saa7134_capsrc_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_
int analog_io, rate;
struct saa7134_dev *dev;
- dev = chip->saadev;
+ dev = chip->dev;
left = ucontrol->value.integer.value[0] & 1;
right = ucontrol->value.integer.value[1] & 1;
@@ -919,11 +920,16 @@ static int snd_saa7134_dev_free(snd_device_t *device)
{
snd_card_saa7134_t *chip = device->device_data;
+ if (chip->dev->dmasound.priv_data == NULL)
+ return 0;
+
if (chip->irq >= 0) {
synchronize_irq(chip->irq);
- free_irq(chip->irq, (void *) chip);
+ free_irq(chip->irq, &chip->dev->dmasound);
}
+ chip->dev->dmasound.priv_data = NULL;
+
return 0;
}
@@ -935,7 +941,7 @@ static int snd_saa7134_dev_free(snd_device_t *device)
*
*/
-int alsa_card_saa7134_create(struct saa7134_dev *saadev, int dev)
+int alsa_card_saa7134_create(struct saa7134_dev *dev, int devnum)
{
snd_card_t *card;
@@ -946,12 +952,12 @@ int alsa_card_saa7134_create(struct saa7134_dev *saadev, int dev)
};
- if (dev >= SNDRV_CARDS)
+ if (devnum >= SNDRV_CARDS)
return -ENODEV;
- if (!enable[dev])
+ if (!enable[devnum])
return -ENODEV;
- card = snd_card_new(index[dev], id[dev], THIS_MODULE, sizeof(snd_card_saa7134_t));
+ card = snd_card_new(index[devnum], id[devnum], THIS_MODULE, sizeof(snd_card_saa7134_t));
if (card == NULL)
return -ENOMEM;
@@ -966,20 +972,22 @@ int alsa_card_saa7134_create(struct saa7134_dev *saadev, int dev)
spin_lock_init(&chip->lock);
spin_lock_init(&chip->mixer_lock);
- chip->saadev = saadev;
+ chip->dev = dev;
chip->card = card;
- chip->pci = saadev->pci;
- chip->irq = saadev->pci->irq;
- chip->iobase = pci_resource_start(saadev->pci, 0);
+ chip->pci = dev->pci;
+ chip->irq = dev->pci->irq;
+ chip->iobase = pci_resource_start(dev->pci, 0);
+
- err = request_irq(saadev->pci->irq, saa7134_alsa_irq,
- SA_SHIRQ | SA_INTERRUPT, saadev->name, (void *)chip);
+ err = request_irq(dev->pci->irq, saa7134_alsa_irq,
+ SA_SHIRQ | SA_INTERRUPT, dev->name,
+ (void*) &dev->dmasound);
if (err < 0) {
printk(KERN_ERR "%s: can't get IRQ %d for ALSA\n",
- saadev->name, saadev->pci->irq);
+ dev->name, dev->pci->irq);
goto __nodev;
}
@@ -999,10 +1007,10 @@ int alsa_card_saa7134_create(struct saa7134_dev *saadev, int dev)
strcpy(card->shortname, "SAA7134");
sprintf(card->longname, "%s at 0x%lx irq %d",
- chip->saadev->name, chip->iobase, chip->irq);
+ chip->dev->name, chip->iobase, chip->irq);
if ((err = snd_card_register(card)) == 0) {
- snd_saa7134_cards[dev] = card;
+ snd_saa7134_cards[devnum] = card;
return 0;
}
@@ -1021,7 +1029,7 @@ __nodev:
static int saa7134_alsa_init(void)
{
- struct saa7134_dev *saadev = NULL;
+ struct saa7134_dev *dev = NULL;
struct list_head *list;
position = 0;
@@ -1029,12 +1037,18 @@ static int saa7134_alsa_init(void)
printk(KERN_INFO "saa7134 ALSA driver for DMA sound loaded\n");
list_for_each(list,&saa7134_devlist) {
- saadev = list_entry(list, struct saa7134_dev, devlist);
- alsa_card_saa7134_create(saadev,position);
- position++;
+ dev = list_entry(list, struct saa7134_dev, devlist);
+ if (dev->dmasound.priv_data == NULL) {
+ dev->dmasound.priv_data = dev;
+ alsa_card_saa7134_create(dev,position);
+ position++;
+ } else {
+ printk(KERN_ERR "saa7134 ALSA: DMA sound is being handled by OSS. ignoring %s\n",dev->name);
+ return -EBUSY;
+ }
}
- if (saadev == NULL)
+ if (dev == NULL)
printk(KERN_INFO "saa7134 ALSA: no saa7134 cards found\n");
return 0;
diff --git a/linux/drivers/media/video/saa7134/saa7134-core.c b/linux/drivers/media/video/saa7134/saa7134-core.c
index 71148b484..efa935195 100644
--- a/linux/drivers/media/video/saa7134/saa7134-core.c
+++ b/linux/drivers/media/video/saa7134/saa7134-core.c
@@ -1,5 +1,5 @@
/*
- * $Id: saa7134-core.c,v 1.53 2005/11/08 16:37:02 rmcc Exp $
+ * $Id: saa7134-core.c,v 1.54 2005/11/09 03:33:33 rmcc Exp $
*
* device driver for philips saa7134 based TV cards
* driver core
@@ -55,13 +55,13 @@ static unsigned int gpio_tracking = 0;
module_param(gpio_tracking, int, 0644);
MODULE_PARM_DESC(gpio_tracking,"enable debug messages [gpio]");
-static unsigned int oss = 0;
-module_param(oss, int, 0444);
-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)");
+module_param(alsa, int, 0644);
+MODULE_PARM_DESC(alsa,"enable ALSA DMA sound [dmasound]");
+
+static unsigned int oss = 0;
+module_param(oss, int, 0644);
+MODULE_PARM_DESC(oss,"enable OSS DMA sound [dmasound]");
static unsigned int latency = UNSET;
module_param(latency, int, 0444);
@@ -70,8 +70,6 @@ MODULE_PARM_DESC(latency,"pci latency timer");
static unsigned int video_nr[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
static unsigned int vbi_nr[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
static unsigned int radio_nr[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
-static unsigned int dsp_nr[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
-static unsigned int mixer_nr[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
static unsigned int tuner[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
static unsigned int card[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
@@ -80,8 +78,6 @@ static unsigned int card[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
MODULE_PARM(video_nr,"1-" __stringify(SAA7134_MAXBOARDS) "i");
MODULE_PARM(vbi_nr,"1-" __stringify(SAA7134_MAXBOARDS) "i");
MODULE_PARM(radio_nr,"1-" __stringify(SAA7134_MAXBOARDS) "i");
-MODULE_PARM(dsp_nr,"1-" __stringify(SAA7134_MAXBOARDS) "i");
-MODULE_PARM(mixer_nr,"1-" __stringify(SAA7134_MAXBOARDS) "i");
MODULE_PARM(tuner_nr,"1-" __stringify(SAA7134_MAXBOARDS) "i");
MODULE_PARM(card,"1-" __stringify(SAA7134_MAXBOARDS) "i");
#else
@@ -90,16 +86,12 @@ static int dummy;
module_param_array(video_nr, int, dummy, 0444);
module_param_array(vbi_nr, int, dummy, 0444);
module_param_array(radio_nr, int, dummy, 0444);
-module_param_array(dsp_nr, int, dummy, 0444);
-module_param_array(mixer_nr, int, dummy, 0444);
module_param_array(tuner, int, dummy, 0444);
module_param_array(card, int, dummy, 0444);
#else
module_param_array(video_nr, int, NULL, 0444);
module_param_array(vbi_nr, int, NULL, 0444);
module_param_array(radio_nr, int, NULL, 0444);
-module_param_array(dsp_nr, int, NULL, 0444);
-module_param_array(mixer_nr, int, NULL, 0444);
module_param_array(tuner, int, NULL, 0444);
module_param_array(card, int, NULL, 0444);
#endif
@@ -108,8 +100,6 @@ module_param_array(card, int, NULL, 0444);
MODULE_PARM_DESC(video_nr, "video device number");
MODULE_PARM_DESC(vbi_nr, "vbi device number");
MODULE_PARM_DESC(radio_nr, "radio device number");
-MODULE_PARM_DESC(dsp_nr, "oss dsp device number");
-MODULE_PARM_DESC(mixer_nr, "oss mixer device number");
MODULE_PARM_DESC(tuner, "tuner type");
MODULE_PARM_DESC(card, "card type");
@@ -258,6 +248,7 @@ static void dump_statusregs(struct saa7134_dev *dev)
static int need_empress;
static int need_dvb;
static int need_alsa;
+static int need_oss;
static int pending_registered=0;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
@@ -276,6 +267,8 @@ static int pending_call(struct notifier_block *self, unsigned long state,
request_module("saa7134-dvb");
if (need_alsa)
request_module("saa7134-alsa");
+ if (need_oss)
+ request_module("saa7134-oss");
return NOTIFY_DONE;
}
@@ -285,10 +278,11 @@ static struct notifier_block pending_notifier = {
static void request_module_depend(char *name, int *flag)
{
+ int err;
switch (THIS_MODULE->state) {
case MODULE_STATE_COMING:
if (!pending_registered) {
- register_module_notifier(&pending_notifier);
+ err = register_module_notifier(&pending_notifier);
pending_registered = 1;
}
*flag = 1;
@@ -646,12 +640,14 @@ static irqreturn_t saa7134_irq(int irq, void *dev_id, struct pt_regs *regs)
goto out;
}
- /* If alsa support is active and we get a sound report, exit
- and let the saa7134-alsa module deal with it */
+ /* If dmasound support is active and we get a sound report, exit
+ and let the saa7134-alsa/oss module deal with it */
- if ((report & SAA7134_IRQ_REPORT_DONE_RA3) && alsa) {
+ if ((report & SAA7134_IRQ_REPORT_DONE_RA3) &&
+ (dev->dmasound.priv_data != NULL) )
+ {
if (irq_debug > 1)
- printk(KERN_DEBUG "%s/irq: ignoring interrupt for ALSA\n",
+ printk(KERN_DEBUG "%s/irq: ignoring interrupt for DMA sound\n",
dev->name);
goto out;
}
@@ -681,12 +677,6 @@ static irqreturn_t saa7134_irq(int irq, void *dev_id, struct pt_regs *regs)
card_has_mpeg(dev))
saa7134_irq_ts_done(dev,status);
- if ((report & SAA7134_IRQ_REPORT_DONE_RA3)) {
- if (oss) {
- saa7134_irq_oss_done(dev,status);
- }
- }
-
if ((report & (SAA7134_IRQ_REPORT_GPIO16 |
SAA7134_IRQ_REPORT_GPIO18)) &&
dev->remote)
@@ -761,14 +751,6 @@ static int saa7134_hwinit1(struct saa7134_dev *dev)
* audio will not work.
*/
- switch (dev->pci->device) {
- case PCI_DEVICE_ID_PHILIPS_SAA7134:
- case PCI_DEVICE_ID_PHILIPS_SAA7133:
- case PCI_DEVICE_ID_PHILIPS_SAA7135:
- saa7134_oss_init1(dev);
- break;
- }
-
/* enable peripheral devices */
saa_writeb(SAA7134_SPECIAL_MODE, 0x01);
@@ -812,13 +794,6 @@ static int saa7134_hwfini(struct saa7134_dev *dev)
{
dprintk("hwfini\n");
- switch (dev->pci->device) {
- case PCI_DEVICE_ID_PHILIPS_SAA7134:
- case PCI_DEVICE_ID_PHILIPS_SAA7133:
- case PCI_DEVICE_ID_PHILIPS_SAA7135:
- saa7134_oss_fini(dev);
- break;
- }
if (card_has_mpeg(dev))
saa7134_ts_fini(dev);
saa7134_input_fini(dev);
@@ -1058,11 +1033,12 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
if (card_is_dvb(dev))
request_module_depend("saa7134-dvb",&need_dvb);
- if (!oss && alsa) {
- dprintk("Requesting ALSA module\n");
+
+ if (alsa)
request_module_depend("saa7134-alsa",&need_alsa);
- }
+ if (oss)
+ request_module_depend("saa7134-oss",&need_oss);
v4l2_prio_init(&dev->prio);
@@ -1096,32 +1072,6 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
dev->name,dev->radio_dev->minor & 0x1f);
}
- /* register oss devices */
- switch (dev->pci->device) {
- case PCI_DEVICE_ID_PHILIPS_SAA7134:
- case PCI_DEVICE_ID_PHILIPS_SAA7133:
- case PCI_DEVICE_ID_PHILIPS_SAA7135:
- if (oss) {
- err = dev->dmasound.minor_dsp =
- register_sound_dsp(&saa7134_dsp_fops,
- dsp_nr[dev->nr]);
- if (err < 0) {
- goto fail4;
- }
- printk(KERN_INFO "%s: registered device dsp%d\n",
- dev->name,dev->dmasound.minor_dsp >> 4);
-
- err = dev->dmasound.minor_mixer =
- register_sound_mixer(&saa7134_mixer_fops,
- mixer_nr[dev->nr]);
- if (err < 0)
- goto fail5;
- printk(KERN_INFO "%s: registered device mixer%d\n",
- dev->name,dev->dmasound.minor_mixer >> 4);
- }
- break;
- }
-
/* everything worked */
pci_set_drvdata(pci_dev,dev);
saa7134_devcount++;
@@ -1139,15 +1089,6 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
return 0;
- fail5:
- switch (dev->pci->device) {
- case PCI_DEVICE_ID_PHILIPS_SAA7134:
- case PCI_DEVICE_ID_PHILIPS_SAA7133:
- case PCI_DEVICE_ID_PHILIPS_SAA7135:
- if (oss)
- unregister_sound_dsp(dev->dmasound.minor_dsp);
- break;
- }
fail4:
saa7134_unregister_video(dev);
saa7134_i2c_unregister(dev);
@@ -1198,19 +1139,16 @@ static void __devexit saa7134_finidev(struct pci_dev *pci_dev)
saa7134_devcount--;
saa7134_i2c_unregister(dev);
- switch (dev->pci->device) {
- case PCI_DEVICE_ID_PHILIPS_SAA7134:
- case PCI_DEVICE_ID_PHILIPS_SAA7133:
- case PCI_DEVICE_ID_PHILIPS_SAA7135:
- if (oss) {
- unregister_sound_mixer(dev->dmasound.minor_mixer);
- unregister_sound_dsp(dev->dmasound.minor_dsp);
- }
- break;
- }
saa7134_unregister_video(dev);
- /* release ressources */
+ /* the DMA sound modules should be unloaded before reaching
+ this, but just in case they are still present... */
+ if (dev->dmasound.priv_data != NULL) {
+ free_irq(pci_dev->irq, &dev->dmasound);
+ dev->dmasound.priv_data = NULL;
+ }
+
+ /* release resources */
free_irq(pci_dev->irq, dev);
iounmap(dev->lmmio);
release_mem_region(pci_resource_start(pci_dev,0),
@@ -1303,7 +1241,7 @@ EXPORT_SYMBOL(saa7134_i2c_call_clients);
EXPORT_SYMBOL(saa7134_devlist);
EXPORT_SYMBOL(saa7134_boards);
-/* ----------------- For ALSA -------------------------------- */
+/* ----------------- for the DMA sound modules --------------- */
EXPORT_SYMBOL(saa7134_pgtable_free);
EXPORT_SYMBOL(saa7134_pgtable_build);
diff --git a/linux/drivers/media/video/saa7134/saa7134-oss.c b/linux/drivers/media/video/saa7134/saa7134-oss.c
index b6b647421..3efd192c3 100644
--- a/linux/drivers/media/video/saa7134/saa7134-oss.c
+++ b/linux/drivers/media/video/saa7134/saa7134-oss.c
@@ -1,10 +1,12 @@
/*
- * $Id: saa7134-oss.c,v 1.21 2005/11/07 20:22:20 rmcc Exp $
+ * $Id: saa7134-oss.c,v 1.22 2005/11/09 03:33:33 rmcc Exp $
*
* device driver for philips saa7134 based TV cards
* oss dsp interface
*
* (c) 2001,02 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
+ * 2005 conversion to standalone module:
+ * Ricardo Cerqueira <v4l@cerqueira.org>
*
* 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
@@ -27,6 +29,7 @@
#include <linux/moduleparam.h>
#include <linux/kernel.h>
#include <linux/slab.h>
+#include <linux/sound.h>
#include <linux/soundcard.h>
#include "compat.h"
@@ -35,15 +38,23 @@
/* ------------------------------------------------------------------ */
-static unsigned int oss_debug = 0;
-module_param(oss_debug, int, 0644);
-MODULE_PARM_DESC(oss_debug,"enable debug messages [oss]");
+static unsigned int debug = 0;
+module_param(debug, int, 0644);
+MODULE_PARM_DESC(debug,"enable debug messages [oss]");
-static unsigned int oss_rate = 0;
-module_param(oss_rate, int, 0444);
-MODULE_PARM_DESC(oss_rate,"sample rate (valid are: 32000,48000)");
+static unsigned int rate = 0;
+module_param(rate, int, 0444);
+MODULE_PARM_DESC(rate,"sample rate (valid are: 32000,48000)");
-#define dprintk(fmt, arg...) if (oss_debug) \
+static unsigned int dsp_nr[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
+MODULE_PARM_DESC(dsp_nr, "device numbers for SAA7134 capture interface(s).");
+module_param_array(dsp_nr, int, NULL, 0444);
+
+static unsigned int mixer_nr[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
+MODULE_PARM_DESC(mixer_nr, "mixer numbers for SAA7134 capture interface(s).");
+module_param_array(mixer_nr, int, NULL, 0444);
+
+#define dprintk(fmt, arg...) if (debug) \
printk(KERN_DEBUG "%s/oss: " fmt, dev->name , ## arg)
@@ -371,7 +382,7 @@ static int dsp_ioctl(struct inode *inode, struct file *file,
int __user *p = argp;
int val = 0;
- if (oss_debug > 1)
+ if (debug > 1)
saa7134_print_ioctl(dev->name,cmd);
switch (cmd) {
case OSS_GETVERSION:
@@ -667,7 +678,7 @@ static int mixer_ioctl(struct inode *inode, struct file *file,
void __user *argp = (void __user *) arg;
int __user *p = argp;
- if (oss_debug > 1)
+ if (debug > 1)
saa7134_print_ioctl(dev->name,cmd);
switch (cmd) {
case OSS_GETVERSION:
@@ -770,8 +781,41 @@ struct file_operations saa7134_mixer_fops = {
/* ------------------------------------------------------------------ */
+static irqreturn_t saa7134_oss_irq(int irq, void *dev_id, struct pt_regs *regs)
+{
+ struct saa7134_dmasound *dmasound = dev_id;
+ struct saa7134_dev *dev = dmasound->priv_data;
+ unsigned long report, status;
+ int loop, handled = 0;
+
+ for (loop = 0; loop < 10; loop++) {
+ report = saa_readl(SAA7134_IRQ_REPORT);
+ status = saa_readl(SAA7134_IRQ_STATUS);
+
+ if (report & SAA7134_IRQ_REPORT_DONE_RA3) {
+ handled = 1;
+ saa_writel(SAA7134_IRQ_REPORT,report);
+ saa7134_irq_oss_done(dev, status);
+ } else {
+ goto out;
+ }
+ }
+
+ if (loop == 10) {
+ dprintk("error! looping IRQ!");
+ }
+out:
+ return IRQ_RETVAL(handled);
+}
+
int saa7134_oss_init1(struct saa7134_dev *dev)
{
+
+ if ((request_irq(dev->pci->irq, saa7134_oss_irq,
+ SA_SHIRQ | SA_INTERRUPT, dev->name,
+ (void*) &dev->dmasound)) < 0)
+ return -1;
+
/* general */
init_MUTEX(&dev->dmasound.lock);
init_waitqueue_head(&dev->dmasound.wq);
@@ -787,8 +831,8 @@ int saa7134_oss_init1(struct saa7134_dev *dev)
/* dsp */
dev->dmasound.rate = 32000;
- if (oss_rate)
- dev->dmasound.rate = oss_rate;
+ if (rate)
+ dev->dmasound.rate = rate;
dev->dmasound.rate = (dev->dmasound.rate > 40000) ? 48000 : 32000;
/* mixer */
@@ -842,7 +886,7 @@ void saa7134_irq_oss_done(struct saa7134_dev *dev, unsigned long status)
/* next block addr */
next_blk = (dev->dmasound.dma_blk + 2) % dev->dmasound.blocks;
saa_writel(reg,next_blk * dev->dmasound.blksize);
- if (oss_debug > 2)
+ if (debug > 2)
dprintk("irq: ok, %s, next_blk=%d, addr=%x\n",
(status & 0x10000000) ? "even" : "odd ", next_blk,
next_blk * dev->dmasound.blksize);
@@ -856,6 +900,98 @@ void saa7134_irq_oss_done(struct saa7134_dev *dev, unsigned long status)
spin_unlock(&dev->slock);
}
+int saa7134_dsp_create(struct saa7134_dev *dev)
+{
+ int err;
+
+ err = dev->dmasound.minor_dsp =
+ register_sound_dsp(&saa7134_dsp_fops,
+ dsp_nr[dev->nr]);
+ if (err < 0) {
+ goto fail;
+ }
+ printk(KERN_INFO "%s: registered device dsp%d\n",
+ dev->name,dev->dmasound.minor_dsp >> 4);
+
+ err = dev->dmasound.minor_mixer =
+ register_sound_mixer(&saa7134_mixer_fops,
+ mixer_nr[dev->nr]);
+ if (err < 0)
+ goto fail;
+ printk(KERN_INFO "%s: registered device mixer%d\n",
+ dev->name,dev->dmasound.minor_mixer >> 4);
+
+ return 0;
+
+fail:
+ unregister_sound_dsp(dev->dmasound.minor_dsp);
+ return 0;
+
+
+}
+
+static int saa7134_oss_init(void)
+{
+ struct saa7134_dev *dev = NULL;
+ struct list_head *list;
+
+ printk(KERN_INFO "saa7134 OSS driver for DMA sound loaded\n");
+
+ list_for_each(list,&saa7134_devlist) {
+ dev = list_entry(list, struct saa7134_dev, devlist);
+ if (dev->dmasound.priv_data == NULL) {
+ dev->dmasound.priv_data = dev;
+ saa7134_oss_init1(dev);
+ saa7134_dsp_create(dev);
+ } else {
+ printk(KERN_ERR "saa7134 OSS: DMA sound is being handled by ALSA, ignoring %s\n",dev->name);
+ return -EBUSY;
+ }
+ }
+
+ if (dev == NULL)
+ printk(KERN_INFO "saa7134 OSS: no saa7134 cards found\n");
+
+ return 0;
+
+}
+
+void saa7134_oss_exit(void)
+{
+ struct saa7134_dev *dev = NULL;
+ struct list_head *list;
+
+ list_for_each(list,&saa7134_devlist) {
+ dev = list_entry(list, struct saa7134_dev, devlist);
+
+ /* Device isn't registered by OSS, probably ALSA's */
+ if (!dev->dmasound.minor_dsp)
+ continue;
+
+ unregister_sound_mixer(dev->dmasound.minor_mixer);
+ unregister_sound_dsp(dev->dmasound.minor_dsp);
+
+ saa7134_oss_fini(dev);
+
+ if (dev->pci->irq > 0) {
+ synchronize_irq(dev->pci->irq);
+ free_irq(dev->pci->irq,&dev->dmasound);
+ }
+
+ dev->dmasound.priv_data = NULL;
+
+ }
+
+ printk(KERN_INFO "saa7134 OSS driver for DMA sound unloaded\n");
+
+ return;
+}
+
+module_init(saa7134_oss_init);
+module_exit(saa7134_oss_exit);
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
+
/* ----------------------------------------------------------- */
/*
* Local variables:
diff --git a/linux/drivers/media/video/saa7134/saa7134.h b/linux/drivers/media/video/saa7134/saa7134.h
index b4cf84ebf..1f46d7e4b 100644
--- a/linux/drivers/media/video/saa7134/saa7134.h
+++ b/linux/drivers/media/video/saa7134/saa7134.h
@@ -1,5 +1,5 @@
/*
- * $Id: saa7134.h,v 1.79 2005/11/07 20:22:20 rmcc Exp $
+ * $Id: saa7134.h,v 1.80 2005/11/09 03:33:33 rmcc Exp $
*
* v4l2 device driver for philips saa7134 based TV cards
*
@@ -390,6 +390,7 @@ struct saa7134_dmasound {
unsigned int dma_blk;
unsigned int read_offset;
unsigned int read_count;
+ void * priv_data;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
snd_pcm_substream_t *substream;
#endif