Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Driver for Sound Core PDAudioCF soundcard
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (c) 2003 by Jaroslav Kysela <perex@perex.cz>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <sound/core.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <pcmcia/ciscode.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <pcmcia/cisreg.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include "pdaudiocf.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <sound/initval.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #define CARD_NAME	"PDAudio-CF"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) MODULE_DESCRIPTION("Sound Core " CARD_NAME);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) MODULE_SUPPORTED_DEVICE("{{Sound Core," CARD_NAME "}}");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;	/* Index 0-MAX */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;	/* ID for this card */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;	/* Enable switches */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) module_param_array(index, int, NULL, 0444);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) MODULE_PARM_DESC(index, "Index value for " CARD_NAME " soundcard.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) module_param_array(id, charp, NULL, 0444);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) MODULE_PARM_DESC(id, "ID string for " CARD_NAME " soundcard.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) module_param_array(enable, bool, NULL, 0444);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) MODULE_PARM_DESC(enable, "Enable " CARD_NAME " soundcard.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) static struct snd_card *card_list[SNDRV_CARDS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44)  * prototypes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) static int pdacf_config(struct pcmcia_device *link);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) static void snd_pdacf_detach(struct pcmcia_device *p_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) static void pdacf_release(struct pcmcia_device *link)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	free_irq(link->irq, link->priv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	pcmcia_disable_device(link);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56)  * destructor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) static int snd_pdacf_free(struct snd_pdacf *pdacf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	struct pcmcia_device *link = pdacf->p_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	pdacf_release(link);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	card_list[pdacf->index] = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	pdacf->card = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	kfree(pdacf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) static int snd_pdacf_dev_free(struct snd_device *device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	struct snd_pdacf *chip = device->device_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	return snd_pdacf_free(chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78)  * snd_pdacf_attach - attach callback for cs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) static int snd_pdacf_probe(struct pcmcia_device *link)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	int i, err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	struct snd_pdacf *pdacf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	struct snd_card *card;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	static const struct snd_device_ops ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 		.dev_free =	snd_pdacf_dev_free,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	snd_printdd(KERN_DEBUG "pdacf_attach called\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	/* find an empty slot from the card list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	for (i = 0; i < SNDRV_CARDS; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 		if (! card_list[i])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	if (i >= SNDRV_CARDS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 		snd_printk(KERN_ERR "pdacf: too many cards found\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	if (! enable[i])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 		return -ENODEV; /* disabled explicitly */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	/* ok, create a card instance */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	err = snd_card_new(&link->dev, index[i], id[i], THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 			   0, &card);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	if (err < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 		snd_printk(KERN_ERR "pdacf: cannot create a card instance\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 		return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	pdacf = snd_pdacf_create(card);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	if (!pdacf) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 		snd_card_free(card);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, pdacf, &ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	if (err < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 		kfree(pdacf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 		snd_card_free(card);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 		return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	pdacf->index = i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	card_list[i] = card;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	pdacf->p_dev = link;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	link->priv = pdacf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	link->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	link->resource[0]->end = 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	link->config_flags = CONF_ENABLE_IRQ | CONF_ENABLE_PULSE_IRQ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	link->config_index = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	link->config_regs = PRESENT_OPTION;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	return pdacf_config(link);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)  * snd_pdacf_assign_resources - initialize the hardware and card instance.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)  * @pdacf: context
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)  * @port: i/o port for the card
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)  * @irq: irq number for the card
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)  * this function assigns the specified port and irq, boot the card,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)  * create pcm and control instances, and initialize the rest hardware.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)  * returns 0 if successful, or a negative error code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) static int snd_pdacf_assign_resources(struct snd_pdacf *pdacf, int port, int irq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	struct snd_card *card = pdacf->card;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	snd_printdd(KERN_DEBUG "pdacf assign resources: port = 0x%x, irq = %d\n", port, irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	pdacf->port = port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	pdacf->irq = irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	pdacf->chip_status |= PDAUDIOCF_STAT_IS_CONFIGURED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	err = snd_pdacf_ak4117_create(pdacf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	if (err < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 		return err;	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	strcpy(card->driver, "PDAudio-CF");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	sprintf(card->shortname, "Core Sound %s", card->driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	sprintf(card->longname, "%s at 0x%x, irq %i",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 		card->shortname, port, irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	err = snd_pdacf_pcm_new(pdacf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	if (err < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 		return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	if ((err = snd_card_register(card)) < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 		return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)  * snd_pdacf_detach - detach callback for cs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) static void snd_pdacf_detach(struct pcmcia_device *link)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	struct snd_pdacf *chip = link->priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	snd_printdd(KERN_DEBUG "pdacf_detach called\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	if (chip->chip_status & PDAUDIOCF_STAT_IS_CONFIGURED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 		snd_pdacf_powerdown(chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	chip->chip_status |= PDAUDIOCF_STAT_IS_STALE; /* to be sure */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	snd_card_disconnect(chip->card);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	snd_card_free_when_closed(chip->card);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)  * configuration callback
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) static int pdacf_config(struct pcmcia_device *link)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	struct snd_pdacf *pdacf = link->priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	snd_printdd(KERN_DEBUG "pdacf_config called\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	link->config_index = 0x5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	link->config_flags |= CONF_ENABLE_IRQ | CONF_ENABLE_PULSE_IRQ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	ret = pcmcia_request_io(link);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 		goto failed_preirq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	ret = request_threaded_irq(link->irq, pdacf_interrupt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 				   pdacf_threaded_irq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 				   IRQF_SHARED, link->devname, link->priv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 		goto failed_preirq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	ret = pcmcia_enable_device(link);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 		goto failed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	if (snd_pdacf_assign_resources(pdacf, link->resource[0]->start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 					link->irq) < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 		goto failed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	pdacf->card->sync_irq = link->irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231)  failed:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	free_irq(link->irq, link->priv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) failed_preirq:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	pcmcia_disable_device(link);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) #ifdef CONFIG_PM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) static int pdacf_suspend(struct pcmcia_device *link)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	struct snd_pdacf *chip = link->priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	snd_printdd(KERN_DEBUG "SUSPEND\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	if (chip) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 		snd_printdd(KERN_DEBUG "snd_pdacf_suspend calling\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 		snd_pdacf_suspend(chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) static int pdacf_resume(struct pcmcia_device *link)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	struct snd_pdacf *chip = link->priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 	snd_printdd(KERN_DEBUG "RESUME\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 	if (pcmcia_dev_present(link)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 		if (chip) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 			snd_printdd(KERN_DEBUG "calling snd_pdacf_resume\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 			snd_pdacf_resume(chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 	snd_printdd(KERN_DEBUG "resume done!\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272)  * Module entry points
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) static const struct pcmcia_device_id snd_pdacf_ids[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 	/* this is too general PCMCIA_DEVICE_MANF_CARD(0x015d, 0x4c45), */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	PCMCIA_DEVICE_PROD_ID12("Core Sound","PDAudio-CF",0x396d19d2,0x71717b49),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 	PCMCIA_DEVICE_NULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) MODULE_DEVICE_TABLE(pcmcia, snd_pdacf_ids);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) static struct pcmcia_driver pdacf_cs_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 	.owner		= THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 	.name		= "snd-pdaudiocf",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	.probe		= snd_pdacf_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	.remove		= snd_pdacf_detach,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 	.id_table	= snd_pdacf_ids,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) #ifdef CONFIG_PM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 	.suspend	= pdacf_suspend,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 	.resume		= pdacf_resume,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) module_pcmcia_driver(pdacf_cs_driver);