X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sound%2Fpci%2Fvx222%2Fvx222.c;h=0f1ebb010a5ed2dfa9e775497b196a09e005067c;hb=43bc926fffd92024b46cafaf7350d669ba9ca884;hp=e503e93bff4f666c489f692699b321244b3d0d78;hpb=5273a3df6485dc2ad6aa7ddd441b9a21970f003b;p=linux-2.6.git diff --git a/sound/pci/vx222/vx222.c b/sound/pci/vx222/vx222.c index e503e93bf..0f1ebb010 100644 --- a/sound/pci/vx222/vx222.c +++ b/sound/pci/vx222/vx222.c @@ -23,20 +23,17 @@ #include #include #include +#include #include -#define SNDRV_GET_ID #include #include "vx222.h" -#define chip_t vx_core_t - #define CARD_NAME "VX222" MODULE_AUTHOR("Takashi Iwai "); MODULE_DESCRIPTION("Digigram VX222 V2/Mic"); MODULE_LICENSE("GPL"); -MODULE_CLASSES("{sound}"); -MODULE_DEVICES("{{Digigram," CARD_NAME "}}"); +MODULE_SUPPORTED_DEVICE("{{Digigram," CARD_NAME "}}"); static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ @@ -44,21 +41,16 @@ static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card * static int mic[SNDRV_CARDS]; /* microphone */ static int ibl[SNDRV_CARDS]; /* microphone */ -MODULE_PARM(index, "1-" __MODULE_STRING(SNDRV_CARDS) "i"); +module_param_array(index, int, NULL, 0444); MODULE_PARM_DESC(index, "Index value for Digigram " CARD_NAME " soundcard."); -MODULE_PARM_SYNTAX(index, SNDRV_INDEX_DESC); -MODULE_PARM(id, "1-" __MODULE_STRING(SNDRV_CARDS) "s"); +module_param_array(id, charp, NULL, 0444); MODULE_PARM_DESC(id, "ID string for Digigram " CARD_NAME " soundcard."); -MODULE_PARM_SYNTAX(id, SNDRV_ID_DESC); -MODULE_PARM(enable, "1-" __MODULE_STRING(SNDRV_CARDS) "i"); +module_param_array(enable, bool, NULL, 0444); MODULE_PARM_DESC(enable, "Enable Digigram " CARD_NAME " soundcard."); -MODULE_PARM_SYNTAX(enable, SNDRV_ENABLE_DESC); -MODULE_PARM(mic, "1-" __MODULE_STRING(SNDRV_CARDS) "i"); +module_param_array(mic, bool, NULL, 0444); MODULE_PARM_DESC(mic, "Enable Microphone."); -MODULE_PARM_SYNTAX(mic, SNDRV_ENABLED "," SNDRV_BOOLEAN_FALSE_DESC); -MODULE_PARM(ibl, "1-" __MODULE_STRING(SNDRV_CARDS) "i"); +module_param_array(ibl, int, NULL, 0444); MODULE_PARM_DESC(ibl, "Capture IBL size."); -MODULE_PARM_SYNTAX(ibl, SNDRV_ENABLED); /* */ @@ -68,9 +60,9 @@ enum { VX_PCI_VX222_NEW }; -static struct pci_device_id snd_vx222_ids[] = { - { 0x10b5, 0x9050, PCI_ANY_ID, PCI_ANY_ID, 0, 0, VX_PCI_VX222_OLD, }, /* PLX */ - { 0x10b5, 0x9030, PCI_ANY_ID, PCI_ANY_ID, 0, 0, VX_PCI_VX222_NEW, }, /* PLX */ +static struct pci_device_id snd_vx222_ids[] __devinitdata = { + { 0x10b5, 0x9050, 0x1369, PCI_ANY_ID, 0, 0, VX_PCI_VX222_OLD, }, /* PLX */ + { 0x10b5, 0x9030, 0x1369, PCI_ANY_ID, 0, 0, VX_PCI_VX222_NEW, }, /* PLX */ { 0, } }; @@ -116,38 +108,34 @@ static struct snd_vx_hardware vx222_mic_hw = { /* */ -static int snd_vx222_free(vx_core_t *chip) +static int snd_vx222_free(struct vx_core *chip) { - int i; struct snd_vx222 *vx = (struct snd_vx222 *)chip; if (chip->irq >= 0) free_irq(chip->irq, (void*)chip); - for (i = 0; i < 2; i++) { - if (vx->port_res[i]) { - release_resource(vx->port_res[i]); - kfree_nocheck(vx->port_res[i]); - } - } - snd_magic_kfree(chip); + if (vx->port[0]) + pci_release_regions(vx->pci); + pci_disable_device(vx->pci); + kfree(chip); return 0; } -static int snd_vx222_dev_free(snd_device_t *device) +static int snd_vx222_dev_free(struct snd_device *device) { - vx_core_t *chip = snd_magic_cast(vx_core_t, device->device_data, return -ENXIO); + struct vx_core *chip = device->device_data; return snd_vx222_free(chip); } -static int __devinit snd_vx222_create(snd_card_t *card, struct pci_dev *pci, +static int __devinit snd_vx222_create(struct snd_card *card, struct pci_dev *pci, struct snd_vx_hardware *hw, struct snd_vx222 **rchip) { - vx_core_t *chip; + struct vx_core *chip; struct snd_vx222 *vx; int i, err; - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_vx222_dev_free, }; struct snd_vx_ops *vx_ops; @@ -159,25 +147,20 @@ static int __devinit snd_vx222_create(snd_card_t *card, struct pci_dev *pci, vx_ops = hw->type == VX_TYPE_BOARD ? &vx222_old_ops : &vx222_ops; chip = snd_vx_create(card, hw, vx_ops, - sizeof(struct snd_vx222) - sizeof(vx_core_t)); - if (! chip) + sizeof(struct snd_vx222) - sizeof(struct vx_core)); + if (! chip) { + pci_disable_device(pci); return -ENOMEM; + } vx = (struct snd_vx222 *)chip; + vx->pci = pci; - for (i = 0; i < 2; i++) { - if (!(pci_resource_flags(pci, i + 1) & IORESOURCE_IO)) { - snd_printk(KERN_ERR "invalid i/o resource %d\n", i + 1); - snd_vx222_free(chip); - return -ENOMEM; - } - vx->port[i] = pci_resource_start(pci, i + 1); - if ((vx->port_res[i] = request_region(vx->port[i], 0x60, - CARD_NAME)) == NULL) { - snd_printk(KERN_ERR "unable to grab port 0x%lx\n", vx->port[i]); - snd_vx222_free(chip); - return -EBUSY; - } + if ((err = pci_request_regions(pci, CARD_NAME)) < 0) { + snd_vx222_free(chip); + return err; } + for (i = 0; i < 2; i++) + vx->port[i] = pci_resource_start(pci, i + 1); if (request_irq(pci->irq, snd_vx_irq_handler, SA_INTERRUPT|SA_SHIRQ, CARD_NAME, (void *) chip)) { @@ -203,7 +186,7 @@ static int __devinit snd_vx222_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { static int dev; - snd_card_t *card; + struct snd_card *card; struct snd_vx_hardware *hw; struct snd_vx222 *vx; int err; @@ -235,6 +218,7 @@ static int __devinit snd_vx222_probe(struct pci_dev *pci, snd_card_free(card); return err; } + card->private_data = vx; vx->core.ibl.size = ibl[dev]; sprintf(card->longname, "%s at 0x%lx & 0x%lx, irq %i", @@ -242,7 +226,11 @@ static int __devinit snd_vx222_probe(struct pci_dev *pci, snd_printdd("%s at 0x%lx & 0x%lx, irq %i\n", card->shortname, vx->port[0], vx->port[1], vx->core.irq); - if ((err = snd_vx_hwdep_new(&vx->core)) < 0) { +#ifdef SND_VX_FW_LOADER + vx->core.dev = &pci->dev; +#endif + + if ((err = snd_vx_setup_firmware(&vx->core)) < 0) { snd_card_free(card); return err; } @@ -263,24 +251,47 @@ static void __devexit snd_vx222_remove(struct pci_dev *pci) pci_set_drvdata(pci, NULL); } +#ifdef CONFIG_PM +static int snd_vx222_suspend(struct pci_dev *pci, pm_message_t state) +{ + struct snd_card *card = pci_get_drvdata(pci); + struct snd_vx222 *vx = card->private_data; + int err; + + err = snd_vx_suspend(&vx->core, state); + pci_set_power_state(pci, PCI_D3hot); + pci_disable_device(pci); + pci_save_state(pci); + return err; +} + +static int snd_vx222_resume(struct pci_dev *pci) +{ + struct snd_card *card = pci_get_drvdata(pci); + struct snd_vx222 *vx = card->private_data; + + pci_restore_state(pci); + pci_enable_device(pci); + pci_set_power_state(pci, PCI_D0); + pci_set_master(pci); + return snd_vx_resume(&vx->core); +} +#endif + static struct pci_driver driver = { .name = "Digigram VX222", .id_table = snd_vx222_ids, .probe = snd_vx222_probe, .remove = __devexit_p(snd_vx222_remove), +#ifdef CONFIG_PM + .suspend = snd_vx222_suspend, + .resume = snd_vx222_resume, +#endif }; static int __init alsa_card_vx222_init(void) { - int err; - - if ((err = pci_module_init(&driver)) < 0) { -#ifdef MODULE - printk(KERN_ERR "Digigram VX222 soundcard not found or device busy\n"); -#endif - return err; - } - return 0; + return pci_register_driver(&driver); } static void __exit alsa_card_vx222_exit(void) @@ -290,24 +301,3 @@ static void __exit alsa_card_vx222_exit(void) module_init(alsa_card_vx222_init) module_exit(alsa_card_vx222_exit) - -#ifndef MODULE - -/* format is: snd-vx222=enable,index,id */ - -static int __init alsa_card_vx222_setup(char *str) -{ - static unsigned __initdata nr_dev = 0; - - if (nr_dev >= SNDRV_CARDS) - return 0; - (void)(get_option(&str,&enable[nr_dev]) == 2 && - get_option(&str,&index[nr_dev]) == 2 && - get_id(&str,&id[nr_dev]) == 2); - nr_dev++; - return 1; -} - -__setup("snd-vx222=", alsa_card_vx222_setup); - -#endif /* ifndef MODULE */