/* * event callback */ static int vxpocket_event(event_t event, int priority, event_callback_args_t *args) { dev_link_t *link = args->client_data; vx_core_t *chip = link->priv; switch (event) { case CS_EVENT_CARD_REMOVAL: snd_printdd(KERN_DEBUG "CARD_REMOVAL..\n"); link->state &= ~DEV_PRESENT; if (link->state & DEV_CONFIG) chip->chip_status |= VX_STAT_IS_STALE; break; case CS_EVENT_CARD_INSERTION: snd_printdd(KERN_DEBUG "CARD_INSERTION..\n"); link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; vxpocket_config(link); break; #ifdef CONFIG_PM case CS_EVENT_PM_SUSPEND: snd_printdd(KERN_DEBUG "SUSPEND\n"); link->state |= DEV_SUSPEND; if (chip && chip->card->pm_suspend) { snd_printdd(KERN_DEBUG "snd_vx_suspend calling\n"); chip->card->pm_suspend(chip->card, PMSG_SUSPEND); } /* Fall through... */ case CS_EVENT_RESET_PHYSICAL: snd_printdd(KERN_DEBUG "RESET_PHYSICAL\n"); if (link->state & DEV_CONFIG) pcmcia_release_configuration(link->handle); break; case CS_EVENT_PM_RESUME: snd_printdd(KERN_DEBUG "RESUME\n"); link->state &= ~DEV_SUSPEND; /* Fall through... */ case CS_EVENT_CARD_RESET: snd_printdd(KERN_DEBUG "CARD_RESET\n"); if (DEV_OK(link)) { //struct snd_vxpocket *vxp = (struct snd_vxpocket *)chip; snd_printdd(KERN_DEBUG "requestconfig...\n"); pcmcia_request_configuration(link->handle, &link->conf); if (chip && chip->card->pm_resume) { snd_printdd(KERN_DEBUG "calling snd_vx_resume\n"); chip->card->pm_resume(chip->card); } } snd_printdd(KERN_DEBUG "resume done!\n"); break; #endif } return 0; }
static int vxpocket_attach(struct pcmcia_device *p_dev) { struct snd_card *card; struct snd_vxpocket *vxp; int i, err; /* find an empty slot from the card list */ for (i = 0; i < SNDRV_CARDS; i++) { if (!(card_alloc & (1 << i))) break; } if (i >= SNDRV_CARDS) { snd_printk(KERN_ERR "vxpocket: too many cards found\n"); return -EINVAL; } if (! enable[i]) return -ENODEV; /* disabled explicitly */ /* ok, create a card instance */ err = snd_card_create(index[i], id[i], THIS_MODULE, 0, &card); if (err < 0) { snd_printk(KERN_ERR "vxpocket: cannot create a card instance\n"); return err; } vxp = snd_vxpocket_new(card, ibl[i]); if (! vxp) { snd_card_free(card); return -ENODEV; } card->private_data = vxp; vxp->index = i; card_alloc |= 1 << i; /* Chain drivers */ vxp->link.next = NULL; vxp->link.handle = p_dev; vxp->link.state |= DEV_PRESENT | DEV_CONFIG_PENDING; p_dev->instance = &vxp->link; vxpocket_config(&vxp->link); return 0; }
static int vxpocket_probe(struct pcmcia_device *p_dev) { struct snd_card *card; struct snd_vxpocket *vxp; int i, err; /* find an empty slot from the card list */ for (i = 0; i < SNDRV_CARDS; i++) { if (!(card_alloc & (1 << i))) break; } if (i >= SNDRV_CARDS) { snd_printk(KERN_ERR "vxpocket: too many cards found\n"); return -EINVAL; } if (! enable[i]) return -ENODEV; /* disabled explicitly */ /* ok, create a card instance */ err = snd_card_new(&p_dev->dev, index[i], id[i], THIS_MODULE, 0, &card); if (err < 0) { snd_printk(KERN_ERR "vxpocket: cannot create a card instance\n"); return err; } err = snd_vxpocket_new(card, ibl[i], p_dev, &vxp); if (err < 0) { snd_card_free(card); return err; } card->private_data = vxp; vxp->index = i; card_alloc |= 1 << i; vxp->p_dev = p_dev; return vxpocket_config(p_dev); }