⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cs4236.c

📁 linux-2.6.15.6
💻 C
📖 第 1 页 / 共 2 页
字号:
	if (sb_port[dev] != SNDRV_AUTO_PORT)		pnp_resource_change(&cfg->port_resource[2], sb_port[dev], 16);	if (irq[dev] != SNDRV_AUTO_IRQ)		pnp_resource_change(&cfg->irq_resource[0], irq[dev], 1);	if (dma1[dev] != SNDRV_AUTO_DMA)		pnp_resource_change(&cfg->dma_resource[0], dma1[dev], 1);	if (dma2[dev] != SNDRV_AUTO_DMA)		pnp_resource_change(&cfg->dma_resource[1], dma2[dev] < 0 ? 4 : dma2[dev], 1);	err = pnp_manual_config_dev(pdev, cfg, 0);	if (err < 0)		snd_printk(KERN_ERR IDENT " WSS PnP manual resources are invalid, using auto config\n");	err = pnp_activate_dev(pdev);	if (err < 0) {		kfree(cfg);		printk(KERN_ERR IDENT " WSS PnP configure failed for WSS (out of resources?)\n");		return -EBUSY;	}	port[dev] = pnp_port_start(pdev, 0);	if (fm_port[dev] > 0)		fm_port[dev] = pnp_port_start(pdev, 1);	sb_port[dev] = pnp_port_start(pdev, 2);	irq[dev] = pnp_irq(pdev, 0);	dma1[dev] = pnp_dma(pdev, 0);	dma2[dev] = pnp_dma(pdev, 1) == 4 ? -1 : (int)pnp_dma(pdev, 1);	snd_printdd("isapnp WSS: wss port=0x%lx, fm port=0x%lx, sb port=0x%lx\n",			port[dev], fm_port[dev], sb_port[dev]);	snd_printdd("isapnp WSS: irq=%i, dma1=%i, dma2=%i\n",			irq[dev], dma1[dev], dma2[dev]);	/* CTRL initialization */	if (acard->ctrl && cport[dev] > 0) {		pdev = acard->ctrl;		pnp_init_resource_table(cfg);		if (cport[dev] != SNDRV_AUTO_PORT)			pnp_resource_change(&cfg->port_resource[0], cport[dev], 8);		err = pnp_manual_config_dev(pdev, cfg, 0);		if (err < 0)			snd_printk(KERN_ERR IDENT " CTRL PnP manual resources are invalid, using auto config\n");		err = pnp_activate_dev(pdev);		if (err < 0) {			kfree(cfg);			printk(KERN_ERR IDENT " CTRL PnP configure failed for WSS (out of resources?)\n");			return -EBUSY;		}		cport[dev] = pnp_port_start(pdev, 0);		snd_printdd("isapnp CTRL: control port=0x%lx\n", cport[dev]);	}	/* MPU initialization */	if (acard->mpu && mpu_port[dev] > 0) {		pdev = acard->mpu;		pnp_init_resource_table(cfg);		if (mpu_port[dev] != SNDRV_AUTO_PORT)			pnp_resource_change(&cfg->port_resource[0], mpu_port[dev], 2);		if (mpu_irq[dev] != SNDRV_AUTO_IRQ && mpu_irq[dev] >= 0)			pnp_resource_change(&cfg->irq_resource[0], mpu_irq[dev], 1);		err = pnp_manual_config_dev(pdev, cfg, 0);		if (err < 0)			snd_printk(KERN_ERR IDENT " MPU401 PnP manual resources are invalid, using auto config\n");		err = pnp_activate_dev(pdev);		if (err < 0) {			printk(KERN_ERR IDENT " MPU401 PnP configure failed for WSS (out of resources?)\n");			mpu_port[dev] = SNDRV_AUTO_PORT;			mpu_irq[dev] = SNDRV_AUTO_IRQ;		} else {			mpu_port[dev] = pnp_port_start(pdev, 0);			if (mpu_irq[dev] >= 0 &&			    pnp_irq_valid(pdev, 0) && pnp_irq(pdev, 0) >= 0) {				mpu_irq[dev] = pnp_irq(pdev, 0);			} else {				mpu_irq[dev] = -1;	/* disable interrupt */			}		}		snd_printdd("isapnp MPU: port=0x%lx, irq=%i\n", mpu_port[dev], mpu_irq[dev]);	}	kfree(cfg);	return 0;}#endif /* CONFIG_PNP */static void snd_card_cs4236_free(snd_card_t *card){	struct snd_card_cs4236 *acard = (struct snd_card_cs4236 *)card->private_data;	if (acard)		release_and_free_resource(acard->res_sb_port);}#ifdef CONFIG_PNP#define is_isapnp_selected(dev)		isapnp[dev]#else#define is_isapnp_selected(dev)		0#endifstatic int __devinit snd_card_cs423x_probe(int dev, struct pnp_card_link *pcard,					   const struct pnp_card_device_id *pid){	snd_card_t *card;	struct snd_card_cs4236 *acard;	snd_pcm_t *pcm = NULL;	cs4231_t *chip;	opl3_t *opl3;	int err;	if (! is_isapnp_selected(dev)) {		if (port[dev] == SNDRV_AUTO_PORT) {			snd_printk(KERN_ERR "specify port\n");			return -EINVAL;		}		if (cport[dev] == SNDRV_AUTO_PORT) {			snd_printk(KERN_ERR "specify cport\n");			return -EINVAL;		}	}	card = snd_card_new(index[dev], id[dev], THIS_MODULE,			    sizeof(struct snd_card_cs4236));	if (card == NULL)		return -ENOMEM;	acard = (struct snd_card_cs4236 *)card->private_data;	card->private_free = snd_card_cs4236_free;#ifdef CONFIG_PNP	if (isapnp[dev]) {		if ((err = snd_card_cs4236_pnp(dev, acard, pcard, pid))<0) {			printk(KERN_ERR "isapnp detection failed and probing for " IDENT " is not supported\n");			goto _err;		}		snd_card_set_dev(card, &pcard->card->dev);	}#endif	if (sb_port[dev] > 0 && sb_port[dev] != SNDRV_AUTO_PORT)		if ((acard->res_sb_port = request_region(sb_port[dev], 16, IDENT " SB")) == NULL) {			printk(KERN_ERR IDENT ": unable to register SB port at 0x%lx\n", sb_port[dev]);			err = -EBUSY;			goto _err;		}#ifdef CS4232	if ((err = snd_cs4231_create(card,				     port[dev],				     cport[dev],				     irq[dev],				     dma1[dev],				     dma2[dev],				     CS4231_HW_DETECT,				     0,				     &chip)) < 0)		goto _err;	if ((err = snd_cs4231_pcm(chip, 0, &pcm)) < 0)		goto _err;	if ((err = snd_cs4231_mixer(chip)) < 0)		goto _err;#else /* CS4236 */	if ((err = snd_cs4236_create(card,				     port[dev],				     cport[dev],				     irq[dev],				     dma1[dev],				     dma2[dev],				     CS4231_HW_DETECT,				     0,				     &chip)) < 0)		goto _err;	if ((err = snd_cs4236_pcm(chip, 0, &pcm)) < 0)		goto _err;	if ((err = snd_cs4236_mixer(chip)) < 0)		goto _err;#endif	strcpy(card->driver, pcm->name);	strcpy(card->shortname, pcm->name);	sprintf(card->longname, "%s at 0x%lx, irq %i, dma %i",		pcm->name,		chip->port,		irq[dev],		dma1[dev]);	if (dma2[dev] >= 0)		sprintf(card->longname + strlen(card->longname), "&%d", dma2[dev]);	if ((err = snd_cs4231_timer(chip, 0, NULL)) < 0)		goto _err;	if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) {		if (snd_opl3_create(card,				    fm_port[dev], fm_port[dev] + 2,				    OPL3_HW_OPL3_CS, 0, &opl3) < 0) {			printk(KERN_WARNING IDENT ": OPL3 not detected\n");		} else {			if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0)				goto _err;		}	}	if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT) {		if (mpu_irq[dev] == SNDRV_AUTO_IRQ)			mpu_irq[dev] = -1;		if (snd_mpu401_uart_new(card, 0, MPU401_HW_CS4232,					mpu_port[dev], 0,					mpu_irq[dev],					mpu_irq[dev] >= 0 ? SA_INTERRUPT : 0, NULL) < 0)			printk(KERN_WARNING IDENT ": MPU401 not detected\n");	}	if ((err = snd_card_set_generic_dev(card)) < 0)		goto _err;	if ((err = snd_card_register(card)) < 0)		goto _err;	if (pcard)		pnp_set_card_drvdata(pcard, card);	else		snd_cs4236_legacy[dev] = card;	return 0; _err:	snd_card_free(card);	return err;}#ifdef CONFIG_PNPstatic int __devinit snd_cs423x_pnp_detect(struct pnp_card_link *card,					   const struct pnp_card_device_id *id){	static int dev;	int res;	for ( ; dev < SNDRV_CARDS; dev++) {		if (!enable[dev] || !isapnp[dev])			continue;		res = snd_card_cs423x_probe(dev, card, id);		if (res < 0)			return res;		dev++;		return 0;	}	return -ENODEV;}static void __devexit snd_cs423x_pnp_remove(struct pnp_card_link * pcard){	snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard);        	snd_card_disconnect(card);	snd_card_free_in_thread(card);}                        static struct pnp_card_driver cs423x_pnpc_driver = {	.flags = PNP_DRIVER_RES_DISABLE,	.name = "cs423x",	.id_table = snd_cs423x_pnpids,	.probe = snd_cs423x_pnp_detect,	.remove = __devexit_p(snd_cs423x_pnp_remove),};#endif /* CONFIG_PNP */static int __init alsa_card_cs423x_init(void){	int dev, cards = 0;	for (dev = 0; dev < SNDRV_CARDS; dev++) {		if (!enable[dev])			continue;		if (is_isapnp_selected(dev))			continue;		if (snd_card_cs423x_probe(dev, NULL, NULL) >= 0)			cards++;	}#ifdef CONFIG_PNP	cards += pnp_register_card_driver(&cs423x_pnpc_driver);#endif	if (!cards) {#ifdef CONFIG_PNP		pnp_unregister_card_driver(&cs423x_pnpc_driver);#endif#ifdef MODULE		printk(KERN_ERR IDENT " soundcard not found or device busy\n");#endif		return -ENODEV;	}	return 0;}static void __exit alsa_card_cs423x_exit(void){	int idx;#ifdef CONFIG_PNP	/* PnP cards first */	pnp_unregister_card_driver(&cs423x_pnpc_driver);#endif	for (idx = 0; idx < SNDRV_CARDS; idx++)		snd_card_free(snd_cs4236_legacy[idx]);}module_init(alsa_card_cs423x_init)module_exit(alsa_card_cs423x_exit)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -