diff options
Diffstat (limited to 'sound/pci/emu10k1/emu10k1x.c')
| -rw-r--r-- | sound/pci/emu10k1/emu10k1x.c | 110 | 
1 files changed, 63 insertions, 47 deletions
diff --git a/sound/pci/emu10k1/emu10k1x.c b/sound/pci/emu10k1/emu10k1x.c index df47f738098..efe01752697 100644 --- a/sound/pci/emu10k1/emu10k1x.c +++ b/sound/pci/emu10k1/emu10k1x.c @@ -34,7 +34,7 @@  #include <linux/pci.h>  #include <linux/dma-mapping.h>  #include <linux/slab.h> -#include <linux/moduleparam.h> +#include <linux/module.h>  #include <sound/core.h>  #include <sound/initval.h>  #include <sound/pcm.h> @@ -50,7 +50,7 @@ MODULE_SUPPORTED_DEVICE("{{Dell Creative Labs,SB Live!}");  // module parameters (see "Module Parameters")  static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;  static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; -static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; +static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;  module_param_array(index, int, NULL, 0444);  MODULE_PARM_DESC(index, "Index value for the EMU10K1X soundcard."); @@ -114,7 +114,7 @@ MODULE_PARM_DESC(enable, "Enable the EMU10K1X soundcard.");  						 */  #define PLAYBACK_LIST_SIZE	0x01		/* Size of list in bytes << 16. E.g. 8 periods -> 0x00380000  */  #define PLAYBACK_LIST_PTR	0x02		/* Pointer to the current period being played */ -#define PLAYBACK_DMA_ADDR	0x04		/* Playback DMA addresss */ +#define PLAYBACK_DMA_ADDR	0x04		/* Playback DMA address */  #define PLAYBACK_PERIOD_SIZE	0x05		/* Playback period size */  #define PLAYBACK_POINTER	0x06		/* Playback period pointer. Sample currently in DAC */  #define PLAYBACK_UNKNOWN1       0x07 @@ -369,7 +369,8 @@ static void snd_emu10k1x_pcm_interrupt(struct emu10k1x *emu, struct emu10k1x_voi  	if (epcm->substream == NULL)  		return;  #if 0 -	snd_printk(KERN_INFO "IRQ: position = 0x%x, period = 0x%x, size = 0x%x\n", +	dev_info(emu->card->dev, +		 "IRQ: position = 0x%x, period = 0x%x, size = 0x%x\n",  		   epcm->substream->ops->pointer(epcm->substream),  		   snd_pcm_lib_period_bytes(epcm->substream),  		   snd_pcm_lib_buffer_bytes(epcm->substream)); @@ -487,7 +488,11 @@ static int snd_emu10k1x_pcm_trigger(struct snd_pcm_substream *substream,  	int channel = epcm->voice->number;  	int result = 0; -//	snd_printk(KERN_INFO "trigger - emu10k1x = 0x%x, cmd = %i, pointer = %d\n", (int)emu, cmd, (int)substream->ops->pointer(substream)); +	/* +	dev_dbg(emu->card->dev, +		"trigger - emu10k1x = 0x%x, cmd = %i, pointer = %d\n", +		(int)emu, cmd, (int)substream->ops->pointer(substream)); +	*/  	switch (cmd) {  	case SNDRV_PCM_TRIGGER_START: @@ -826,13 +831,26 @@ static irqreturn_t snd_emu10k1x_interrupt(int irq, void *dev_id)  	// acknowledge the interrupt if necessary  	outl(status, chip->port + IPR); -	// snd_printk(KERN_INFO "interrupt %08x\n", status); +	/* dev_dbg(chip->card->dev, "interrupt %08x\n", status); */  	return IRQ_HANDLED;  } -static int __devinit snd_emu10k1x_pcm(struct emu10k1x *emu, int device, struct snd_pcm **rpcm) +static const struct snd_pcm_chmap_elem surround_map[] = { +	{ .channels = 2, +	  .map = { SNDRV_CHMAP_RL, SNDRV_CHMAP_RR } }, +	{ } +}; + +static const struct snd_pcm_chmap_elem clfe_map[] = { +	{ .channels = 2, +	  .map = { SNDRV_CHMAP_FC, SNDRV_CHMAP_LFE } }, +	{ } +}; + +static int snd_emu10k1x_pcm(struct emu10k1x *emu, int device, struct snd_pcm **rpcm)  {  	struct snd_pcm *pcm; +	const struct snd_pcm_chmap_elem *map = NULL;  	int err;  	int capture = 0; @@ -861,12 +879,15 @@ static int __devinit snd_emu10k1x_pcm(struct emu10k1x *emu, int device, struct s  	switch(device) {  	case 0:  		strcpy(pcm->name, "EMU10K1X Front"); +		map = snd_pcm_std_chmaps;  		break;  	case 1:  		strcpy(pcm->name, "EMU10K1X Rear"); +		map = surround_map;  		break;  	case 2:  		strcpy(pcm->name, "EMU10K1X Center/LFE"); +		map = clfe_map;  		break;  	}  	emu->pcm = pcm; @@ -875,15 +896,20 @@ static int __devinit snd_emu10k1x_pcm(struct emu10k1x *emu, int device, struct s  					      snd_dma_pci_data(emu->pci),   					      32*1024, 32*1024); +	err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, map, 2, +				     1 << 2, NULL); +	if (err < 0) +		return err; +  	if (rpcm)  		*rpcm = pcm;  	return 0;  } -static int __devinit snd_emu10k1x_create(struct snd_card *card, -					 struct pci_dev *pci, -					 struct emu10k1x **rchip) +static int snd_emu10k1x_create(struct snd_card *card, +			       struct pci_dev *pci, +			       struct emu10k1x **rchip)  {  	struct emu10k1x *chip;  	int err; @@ -898,7 +924,7 @@ static int __devinit snd_emu10k1x_create(struct snd_card *card,  		return err;  	if (pci_set_dma_mask(pci, DMA_BIT_MASK(28)) < 0 ||  	    pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(28)) < 0) { -		snd_printk(KERN_ERR "error to set 28bit mask DMA\n"); +		dev_err(card->dev, "error to set 28bit mask DMA\n");  		pci_disable_device(pci);  		return -ENXIO;  	} @@ -919,14 +945,15 @@ static int __devinit snd_emu10k1x_create(struct snd_card *card,  	chip->port = pci_resource_start(pci, 0);  	if ((chip->res_port = request_region(chip->port, 8,  					     "EMU10K1X")) == NULL) {  -		snd_printk(KERN_ERR "emu10k1x: cannot allocate the port 0x%lx\n", chip->port); +		dev_err(card->dev, "cannot allocate the port 0x%lx\n", +			chip->port);  		snd_emu10k1x_free(chip);  		return -EBUSY;  	}  	if (request_irq(pci->irq, snd_emu10k1x_interrupt, -			IRQF_SHARED, "EMU10K1X", chip)) { -		snd_printk(KERN_ERR "emu10k1x: cannot grab irq %d\n", pci->irq); +			IRQF_SHARED, KBUILD_MODNAME, chip)) { +		dev_err(card->dev, "cannot grab irq %d\n", pci->irq);  		snd_emu10k1x_free(chip);  		return -EBUSY;  	} @@ -943,7 +970,7 @@ static int __devinit snd_emu10k1x_create(struct snd_card *card,  	chip->revision = pci->revision;  	pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &chip->serial);  	pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &chip->model); -	snd_printk(KERN_INFO "Model %04x Rev %08x Serial %08x\n", chip->model, +	dev_info(card->dev, "Model %04x Rev %08x Serial %08x\n", chip->model,  		   chip->revision, chip->serial);  	outl(0, chip->port + INTE);	 @@ -1045,7 +1072,7 @@ static void snd_emu10k1x_proc_reg_write(struct snd_info_entry *entry,  	}  } -static int __devinit snd_emu10k1x_proc_init(struct emu10k1x * emu) +static int snd_emu10k1x_proc_init(struct emu10k1x *emu)  {  	struct snd_info_entry *entry; @@ -1094,7 +1121,7 @@ static int snd_emu10k1x_shared_spdif_put(struct snd_kcontrol *kcontrol,  	return change;  } -static struct snd_kcontrol_new snd_emu10k1x_shared_spdif __devinitdata = +static struct snd_kcontrol_new snd_emu10k1x_shared_spdif =  {  	.iface =	SNDRV_CTL_ELEM_IFACE_MIXER,  	.name =		"Analog/Digital Output Jack", @@ -1173,7 +1200,7 @@ static struct snd_kcontrol_new snd_emu10k1x_spdif_control =  	.put =          snd_emu10k1x_spdif_put  }; -static int __devinit snd_emu10k1x_mixer(struct emu10k1x *emu) +static int snd_emu10k1x_mixer(struct emu10k1x *emu)  {  	int err;  	struct snd_kcontrol *kctl; @@ -1227,7 +1254,9 @@ static void mpu401_clear_rx(struct emu10k1x *emu, struct emu10k1x_midi *mpu)  		mpu401_read_data(emu, mpu);  #ifdef CONFIG_SND_DEBUG  	if (timeout <= 0) -		snd_printk(KERN_ERR "cmd: clear rx timeout (status = 0x%x)\n", mpu401_read_stat(emu, mpu)); +		dev_err(emu->card->dev, +			"cmd: clear rx timeout (status = 0x%x)\n", +			mpu401_read_stat(emu, mpu));  #endif  } @@ -1301,7 +1330,8 @@ static int snd_emu10k1x_midi_cmd(struct emu10k1x * emu,  	}  	spin_unlock_irqrestore(&midi->input_lock, flags);  	if (!ok) { -		snd_printk(KERN_ERR "midi_cmd: 0x%x failed at 0x%lx (status = 0x%x, data = 0x%x)!!!\n", +		dev_err(emu->card->dev, +			"midi_cmd: 0x%x failed at 0x%lx (status = 0x%x, data = 0x%x)!!!\n",  			   cmd, emu->port,  			   mpu401_read_stat(emu, midi),  			   mpu401_read_data(emu, midi)); @@ -1486,8 +1516,9 @@ static void snd_emu10k1x_midi_free(struct snd_rawmidi *rmidi)  	midi->rmidi = NULL;  } -static int __devinit emu10k1x_midi_init(struct emu10k1x *emu, -					struct emu10k1x_midi *midi, int device, char *name) +static int emu10k1x_midi_init(struct emu10k1x *emu, +			      struct emu10k1x_midi *midi, int device, +			      char *name)  {  	struct snd_rawmidi *rmidi;  	int err; @@ -1510,7 +1541,7 @@ static int __devinit emu10k1x_midi_init(struct emu10k1x *emu,  	return 0;  } -static int __devinit snd_emu10k1x_midi(struct emu10k1x *emu) +static int snd_emu10k1x_midi(struct emu10k1x *emu)  {  	struct emu10k1x_midi *midi = &emu->midi;  	int err; @@ -1527,8 +1558,8 @@ static int __devinit snd_emu10k1x_midi(struct emu10k1x *emu)  	return 0;  } -static int __devinit snd_emu10k1x_probe(struct pci_dev *pci, -					const struct pci_device_id *pci_id) +static int snd_emu10k1x_probe(struct pci_dev *pci, +			      const struct pci_device_id *pci_id)  {  	static int dev;  	struct snd_card *card; @@ -1542,7 +1573,8 @@ static int __devinit snd_emu10k1x_probe(struct pci_dev *pci,  		return -ENOENT;  	} -	err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); +	err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, +			   0, &card);  	if (err < 0)  		return err; @@ -1586,8 +1618,6 @@ static int __devinit snd_emu10k1x_probe(struct pci_dev *pci,  	sprintf(card->longname, "%s at 0x%lx irq %i",  		card->shortname, chip->port, chip->irq); -	snd_card_set_dev(card, &pci->dev); -  	if ((err = snd_card_register(card)) < 0) {  		snd_card_free(card);  		return err; @@ -1598,10 +1628,9 @@ static int __devinit snd_emu10k1x_probe(struct pci_dev *pci,  	return 0;  } -static void __devexit snd_emu10k1x_remove(struct pci_dev *pci) +static void snd_emu10k1x_remove(struct pci_dev *pci)  {  	snd_card_free(pci_get_drvdata(pci)); -	pci_set_drvdata(pci, NULL);  }  // PCI IDs @@ -1612,24 +1641,11 @@ static DEFINE_PCI_DEVICE_TABLE(snd_emu10k1x_ids) = {  MODULE_DEVICE_TABLE(pci, snd_emu10k1x_ids);  // pci_driver definition -static struct pci_driver driver = { -	.name = "EMU10K1X", +static struct pci_driver emu10k1x_driver = { +	.name = KBUILD_MODNAME,  	.id_table = snd_emu10k1x_ids,  	.probe = snd_emu10k1x_probe, -	.remove = __devexit_p(snd_emu10k1x_remove), +	.remove = snd_emu10k1x_remove,  }; -// initialization of the module -static int __init alsa_card_emu10k1x_init(void) -{ -	return pci_register_driver(&driver); -} - -// clean up the module -static void __exit alsa_card_emu10k1x_exit(void) -{ -	pci_unregister_driver(&driver); -} - -module_init(alsa_card_emu10k1x_init) -module_exit(alsa_card_emu10k1x_exit) +module_pci_driver(emu10k1x_driver);  | 
