提交 f5b974cb 编写于 作者: R Ricardo Cerqueira 提交者: Linus Torvalds

[PATCH] V4L: Fix hotplugging issues with saa7134

- Fixed issue with hotplugging and DMA sound (sound was lost when replugging
  a card)

- Added notifiers to main saa7134 module to let the sound sub-modules know
  when a card has been inserted or removed
Signed-off-by: NRicardo Cerqueira <v4l@cerqueira.org>
Signed-off-by: NMauro Carvalho Chehab <mchehab@brturbo.com.br>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 938606b0
...@@ -58,8 +58,6 @@ static int enable[SNDRV_CARDS] = {1, [1 ... (SNDRV_CARDS - 1)] = 0}; ...@@ -58,8 +58,6 @@ static int enable[SNDRV_CARDS] = {1, [1 ... (SNDRV_CARDS - 1)] = 0};
module_param_array(index, int, NULL, 0444); module_param_array(index, int, NULL, 0444);
MODULE_PARM_DESC(index, "Index value for SAA7134 capture interface(s)."); MODULE_PARM_DESC(index, "Index value for SAA7134 capture interface(s).");
int position;
#define dprintk(fmt, arg...) if (debug) \ #define dprintk(fmt, arg...) if (debug) \
printk(KERN_DEBUG "%s/alsa: " fmt, dev->name , ## arg) printk(KERN_DEBUG "%s/alsa: " fmt, dev->name , ## arg)
...@@ -945,6 +943,8 @@ int alsa_card_saa7134_create(struct saa7134_dev *dev, int devnum) ...@@ -945,6 +943,8 @@ int alsa_card_saa7134_create(struct saa7134_dev *dev, int devnum)
sprintf(card->longname, "%s at 0x%lx irq %d", sprintf(card->longname, "%s at 0x%lx irq %d",
chip->dev->name, chip->iobase, chip->irq); chip->dev->name, chip->iobase, chip->irq);
printk(KERN_INFO "%s/alsa: %s registered as card %d\n",dev->name,card->longname,index[devnum]);
if ((err = snd_card_register(card)) == 0) { if ((err = snd_card_register(card)) == 0) {
snd_saa7134_cards[devnum] = card; snd_saa7134_cards[devnum] = card;
return 0; return 0;
...@@ -955,6 +955,22 @@ int alsa_card_saa7134_create(struct saa7134_dev *dev, int devnum) ...@@ -955,6 +955,22 @@ int alsa_card_saa7134_create(struct saa7134_dev *dev, int devnum)
return err; return err;
} }
static int alsa_device_init(struct saa7134_dev *dev)
{
dev->dmasound.priv_data = dev;
alsa_card_saa7134_create(dev,dev->nr);
return 1;
}
static int alsa_device_exit(struct saa7134_dev *dev)
{
snd_card_free(snd_saa7134_cards[dev->nr]);
snd_saa7134_cards[dev->nr] = NULL;
return 1;
}
/* /*
* Module initializer * Module initializer
* *
...@@ -968,22 +984,21 @@ static int saa7134_alsa_init(void) ...@@ -968,22 +984,21 @@ static int saa7134_alsa_init(void)
struct saa7134_dev *dev = NULL; struct saa7134_dev *dev = NULL;
struct list_head *list; struct list_head *list;
position = 0;
printk(KERN_INFO "saa7134 ALSA driver for DMA sound loaded\n"); printk(KERN_INFO "saa7134 ALSA driver for DMA sound loaded\n");
list_for_each(list,&saa7134_devlist) { list_for_each(list,&saa7134_devlist) {
dev = list_entry(list, struct saa7134_dev, devlist); dev = list_entry(list, struct saa7134_dev, devlist);
if (dev->dmasound.priv_data == NULL) { if (dev->dmasound.priv_data == NULL) {
dev->dmasound.priv_data = dev; alsa_device_init(dev);
alsa_card_saa7134_create(dev,position);
position++;
} else { } else {
printk(KERN_ERR "saa7134 ALSA: DMA sound is being handled by OSS. ignoring %s\n",dev->name); printk(KERN_ERR "saa7134 ALSA: DMA sound is being handled by OSS. ignoring %s\n",dev->name);
return -EBUSY; return -EBUSY;
} }
} }
dmasound_init = alsa_device_init;
dmasound_exit = alsa_device_exit;
if (dev == NULL) if (dev == NULL)
printk(KERN_INFO "saa7134 ALSA: no saa7134 cards found\n"); printk(KERN_INFO "saa7134 ALSA: no saa7134 cards found\n");
......
...@@ -88,6 +88,9 @@ LIST_HEAD(saa7134_devlist); ...@@ -88,6 +88,9 @@ LIST_HEAD(saa7134_devlist);
static LIST_HEAD(mops_list); static LIST_HEAD(mops_list);
static unsigned int saa7134_devcount; static unsigned int saa7134_devcount;
int (*dmasound_init)(struct saa7134_dev *dev);
int (*dmasound_exit)(struct saa7134_dev *dev);
#define dprintk(fmt, arg...) if (core_debug) \ #define dprintk(fmt, arg...) if (core_debug) \
printk(KERN_DEBUG "%s/core: " fmt, dev->name , ## arg) printk(KERN_DEBUG "%s/core: " fmt, dev->name , ## arg)
...@@ -1017,6 +1020,10 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev, ...@@ -1017,6 +1020,10 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
/* check for signal */ /* check for signal */
saa7134_irq_video_intl(dev); saa7134_irq_video_intl(dev);
if (dmasound_init && !dev->dmasound.priv_data) {
dmasound_init(dev);
}
return 0; return 0;
fail4: fail4:
...@@ -1040,6 +1047,11 @@ static void __devexit saa7134_finidev(struct pci_dev *pci_dev) ...@@ -1040,6 +1047,11 @@ static void __devexit saa7134_finidev(struct pci_dev *pci_dev)
struct list_head *item; struct list_head *item;
struct saa7134_mpeg_ops *mops; struct saa7134_mpeg_ops *mops;
/* Release DMA sound modules if present */
if (dmasound_exit && dev->dmasound.priv_data) {
dmasound_exit(dev);
}
/* debugging ... */ /* debugging ... */
if (irq_debug) { if (irq_debug) {
u32 report = saa_readl(SAA7134_IRQ_REPORT); u32 report = saa_readl(SAA7134_IRQ_REPORT);
...@@ -1071,6 +1083,7 @@ static void __devexit saa7134_finidev(struct pci_dev *pci_dev) ...@@ -1071,6 +1083,7 @@ static void __devexit saa7134_finidev(struct pci_dev *pci_dev)
saa7134_i2c_unregister(dev); saa7134_i2c_unregister(dev);
saa7134_unregister_video(dev); saa7134_unregister_video(dev);
/* the DMA sound modules should be unloaded before reaching /* the DMA sound modules should be unloaded before reaching
this, but just in case they are still present... */ this, but just in case they are still present... */
if (dev->dmasound.priv_data != NULL) { if (dev->dmasound.priv_data != NULL) {
...@@ -1078,6 +1091,7 @@ static void __devexit saa7134_finidev(struct pci_dev *pci_dev) ...@@ -1078,6 +1091,7 @@ static void __devexit saa7134_finidev(struct pci_dev *pci_dev)
dev->dmasound.priv_data = NULL; dev->dmasound.priv_data = NULL;
} }
/* release resources */ /* release resources */
free_irq(pci_dev->irq, dev); free_irq(pci_dev->irq, dev);
iounmap(dev->lmmio); iounmap(dev->lmmio);
...@@ -1168,6 +1182,8 @@ EXPORT_SYMBOL(saa7134_boards); ...@@ -1168,6 +1182,8 @@ EXPORT_SYMBOL(saa7134_boards);
/* ----------------- for the DMA sound modules --------------- */ /* ----------------- for the DMA sound modules --------------- */
EXPORT_SYMBOL(dmasound_init);
EXPORT_SYMBOL(dmasound_exit);
EXPORT_SYMBOL(saa7134_pgtable_free); EXPORT_SYMBOL(saa7134_pgtable_free);
EXPORT_SYMBOL(saa7134_pgtable_build); EXPORT_SYMBOL(saa7134_pgtable_build);
EXPORT_SYMBOL(saa7134_pgtable_alloc); EXPORT_SYMBOL(saa7134_pgtable_alloc);
......
...@@ -903,22 +903,22 @@ int saa7134_dsp_create(struct saa7134_dev *dev) ...@@ -903,22 +903,22 @@ int saa7134_dsp_create(struct saa7134_dev *dev)
{ {
int err; int err;
err = dev->dmasound.minor_dsp = err = dev->dmasound.minor_dsp =
register_sound_dsp(&saa7134_dsp_fops, register_sound_dsp(&saa7134_dsp_fops,
dsp_nr[dev->nr]); dsp_nr[dev->nr]);
if (err < 0) { if (err < 0) {
goto fail; goto fail;
} }
printk(KERN_INFO "%s: registered device dsp%d\n", printk(KERN_INFO "%s: registered device dsp%d\n",
dev->name,dev->dmasound.minor_dsp >> 4); dev->name,dev->dmasound.minor_dsp >> 4);
err = dev->dmasound.minor_mixer = err = dev->dmasound.minor_mixer =
register_sound_mixer(&saa7134_mixer_fops, register_sound_mixer(&saa7134_mixer_fops,
mixer_nr[dev->nr]); mixer_nr[dev->nr]);
if (err < 0) if (err < 0)
goto fail; goto fail;
printk(KERN_INFO "%s: registered device mixer%d\n", printk(KERN_INFO "%s: registered device mixer%d\n",
dev->name,dev->dmasound.minor_mixer >> 4); dev->name,dev->dmasound.minor_mixer >> 4);
return 0; return 0;
...@@ -929,6 +929,31 @@ int saa7134_dsp_create(struct saa7134_dev *dev) ...@@ -929,6 +929,31 @@ int saa7134_dsp_create(struct saa7134_dev *dev)
} }
static int oss_device_init(struct saa7134_dev *dev)
{
dev->dmasound.priv_data = dev;
saa7134_oss_init1(dev);
saa7134_dsp_create(dev);
return 1;
}
static int oss_device_exit(struct saa7134_dev *dev)
{
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;
return 1;
}
static int saa7134_oss_init(void) static int saa7134_oss_init(void)
{ {
struct saa7134_dev *dev = NULL; struct saa7134_dev *dev = NULL;
...@@ -939,9 +964,7 @@ static int saa7134_oss_init(void) ...@@ -939,9 +964,7 @@ static int saa7134_oss_init(void)
list_for_each(list,&saa7134_devlist) { list_for_each(list,&saa7134_devlist) {
dev = list_entry(list, struct saa7134_dev, devlist); dev = list_entry(list, struct saa7134_dev, devlist);
if (dev->dmasound.priv_data == NULL) { if (dev->dmasound.priv_data == NULL) {
dev->dmasound.priv_data = dev; oss_device_init(dev);
saa7134_oss_init1(dev);
saa7134_dsp_create(dev);
} else { } else {
printk(KERN_ERR "saa7134 OSS: DMA sound is being handled by ALSA, ignoring %s\n",dev->name); printk(KERN_ERR "saa7134 OSS: DMA sound is being handled by ALSA, ignoring %s\n",dev->name);
return -EBUSY; return -EBUSY;
...@@ -951,6 +974,9 @@ static int saa7134_oss_init(void) ...@@ -951,6 +974,9 @@ static int saa7134_oss_init(void)
if (dev == NULL) if (dev == NULL)
printk(KERN_INFO "saa7134 OSS: no saa7134 cards found\n"); printk(KERN_INFO "saa7134 OSS: no saa7134 cards found\n");
dmasound_init = oss_device_init;
dmasound_exit = oss_device_exit;
return 0; return 0;
} }
...@@ -967,18 +993,7 @@ void saa7134_oss_exit(void) ...@@ -967,18 +993,7 @@ void saa7134_oss_exit(void)
if (!dev->dmasound.minor_dsp) if (!dev->dmasound.minor_dsp)
continue; continue;
unregister_sound_mixer(dev->dmasound.minor_mixer); oss_device_exit(dev);
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"); printk(KERN_INFO "saa7134 OSS driver for DMA sound unloaded\n");
......
...@@ -571,6 +571,10 @@ void saa7134_dma_free(struct saa7134_dev *dev,struct saa7134_buf *buf); ...@@ -571,6 +571,10 @@ void saa7134_dma_free(struct saa7134_dev *dev,struct saa7134_buf *buf);
int saa7134_set_dmabits(struct saa7134_dev *dev); int saa7134_set_dmabits(struct saa7134_dev *dev);
extern int (*dmasound_init)(struct saa7134_dev *dev);
extern int (*dmasound_exit)(struct saa7134_dev *dev);
/* ----------------------------------------------------------- */ /* ----------------------------------------------------------- */
/* saa7134-cards.c */ /* saa7134-cards.c */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册