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

📄 aedsp16.c

📁 iis s3c2410-uda1341语音系统的 开发
💻 C
📖 第 1 页 / 共 3 页
字号:
		return FALSE;#endif#endif	return TRUE;}static int __init aedsp16_stdcfg(int port) {	if (aedsp16_write(port, WRITE_MDIRQ_CFG)) {		printk("[AEDSP16] CMD 0x%x: failed!\n", WRITE_MDIRQ_CFG);		return FALSE;	}	/*	 * 0x0A == (IRQ 7, DMA 1, MIRQ 0)	 */	if (aedsp16_write(port, 0x0A)) {		printk("[AEDSP16] aedsp16_stdcfg: failed!\n");		return FALSE;	}	return TRUE;}static int __init aedsp16_dsp_version(int port){	int             len = 0;	int             ret;	DBG(("Get DSP Version:\n"));	if (aedsp16_write(ae_config.base_io, GET_DSP_VERSION)) {		printk("[AEDSP16] CMD 0x%x: failed!\n", GET_DSP_VERSION);		DBG(("failed.\n"));		return FALSE;	}	do {		if ((ret = aedsp16_read(port)) == -1) {			DBG(("failed.\n"));			return FALSE;		}	/*	 * We already know how many int are stored (2), so we know when the	 * string is finished.	 */		ver[len++] = ret;	  } while (len < CARDVERLEN);	sprintf(DSPVersion, "%d.%d", ver[0], ver[1]);	DBG(("success.\n"));	return TRUE;}static int __init aedsp16_dsp_copyright(int port){	int             len = 0;	int             ret;	DBG(("Get DSP Copyright:\n"));	if (aedsp16_write(ae_config.base_io, GET_DSP_COPYRIGHT)) {		printk("[AEDSP16] CMD 0x%x: failed!\n", GET_DSP_COPYRIGHT);		DBG(("failed.\n"));		return FALSE;	}	do {		if ((ret = aedsp16_read(port)) == -1) {	/*	 * If no more data available, return to the caller, no error if len>0.	 * We have no other way to know when the string is finished.	 */			if (len)				break;			else {				DBG(("failed.\n"));				return FALSE;			}		}		DSPCopyright[len++] = ret;	  } while (len < CARDNAMELEN);	DBG(("success.\n"));	return TRUE;}static void __init aedsp16_init_tables(void){	int i = 0;	memset(DSPCopyright, 0, CARDNAMELEN + 1);	memset(DSPVersion, 0, CARDVERLEN + 1);	for (i = 0; orIRQ[i].or; i++)		if (orIRQ[i].val == ae_config.irq) {			soft_cfg |= orIRQ[i].or;			soft_cfg_mss |= orIRQ[i].or;		}	for (i = 0; orMIRQ[i].or; i++)		if (orMIRQ[i].or == ae_config.mpu_irq)			soft_cfg |= orMIRQ[i].or;	for (i = 0; orDMA[i].or; i++)		if (orDMA[i].val == ae_config.dma) {			soft_cfg |= orDMA[i].or;			soft_cfg_mss |= orDMA[i].or;		}}static int __init aedsp16_init_board(void){	aedsp16_init_tables();	if (aedsp16_dsp_reset(ae_config.base_io) == FALSE) {		printk("[AEDSP16] aedsp16_dsp_reset: failed!\n");		return FALSE;	}	if (aedsp16_dsp_copyright(ae_config.base_io) == FALSE) {		printk("[AEDSP16] aedsp16_dsp_copyright: failed!\n");		return FALSE;	}	/*	 * My AEDSP16 card return SC-6000 in DSPCopyright, so	 * if we have something different, we have to be warned.	 */	if (strcmp("SC-6000", DSPCopyright))		printk("[AEDSP16] Warning: non SC-6000 audio card!\n");	if (aedsp16_dsp_version(ae_config.base_io) == FALSE) {		printk("[AEDSP16] aedsp16_dsp_version: failed!\n");		return FALSE;	}	if (aedsp16_stdcfg(ae_config.base_io) == FALSE) {		printk("[AEDSP16] aedsp16_stdcfg: failed!\n");		return FALSE;	}#if defined(CONFIG_SC6600)	if (aedsp16_hard_read(ae_config.base_io) == FALSE) {		printk("[AEDSP16] aedsp16_hard_read: failed!\n");		return FALSE;	}	aedsp16_hard_decode();	aedsp16_hard_encode();	if (aedsp16_hard_write(ae_config.base_io) == FALSE) {		printk("[AEDSP16] aedsp16_hard_write: failed!\n");		return FALSE;	}	if (aedsp16_ext_cfg_write(ae_config.base_io) == FALSE) {		printk("[AEDSP16] aedsp16_ext_cfg_write: failed!\n");		return FALSE;	}#endif /* CONFIG_SC6600 */	if (aedsp16_setup_board(ae_config.base_io) == FALSE) {		printk("[AEDSP16] aedsp16_setup_board: failed!\n");		return FALSE;	}	if (ae_config.mss_base != -1) {		if (ae_config.init & INIT_MSS) {			if (aedsp16_init_mss(ae_config.base_io) == FALSE) {				printk("[AEDSP16] Can not initialize"				       "Microsoft Sound System mode.\n");				return FALSE;			}		}	}#if !defined(MODULE) || defined(AEDSP16_INFO) || defined(AEDSP16_DEBUG)	printk("Audio Excel DSP 16 init v%s (%s %s) [",		VERSION, DSPCopyright,		DSPVersion);	if (ae_config.mpu_base != -1) {		if (ae_config.init & INIT_MPU401) {			printk("MPU401");			if ((ae_config.init & INIT_MSS) ||			    (ae_config.init & INIT_SBPRO))				printk(" ");		}	}	if (ae_config.mss_base == -1) {		if (ae_config.init & INIT_SBPRO) {			printk("SBPro");			if (ae_config.init & INIT_MSS)				printk(" ");		}	}	if (ae_config.mss_base != -1)		if (ae_config.init & INIT_MSS)			printk("MSS");	printk("]\n");#endif /* MODULE || AEDSP16_INFO || AEDSP16_DEBUG */	mdelay(10);	return TRUE;}static int __init init_aedsp16_sb(void){	DBG(("init_aedsp16_sb: "));/* * If the card is already init'ed MSS, we can not init it to SBPRO too * because the board can not emulate simultaneously MSS and SBPRO. */	if (ae_config.init & INIT_MSS)		return FALSE;	if (ae_config.init & INIT_SBPRO)		return FALSE;	ae_config.init |= INIT_SBPRO;	DBG(("done.\n"));	return TRUE;}static void __init uninit_aedsp16_sb(void){	DBG(("uninit_aedsp16_sb: "));	ae_config.init &= ~INIT_SBPRO;	DBG(("done.\n"));}static int __init init_aedsp16_mss(void){	DBG(("init_aedsp16_mss: "));/* * If the card is already init'ed SBPRO, we can not init it to MSS too * because the board can not emulate simultaneously MSS and SBPRO. */	if (ae_config.init & INIT_SBPRO)		return FALSE;	if (ae_config.init & INIT_MSS)		return FALSE;/* * We must allocate the CONFIG_AEDSP16_BASE region too because these are the  * I/O ports to access card's control registers. */	if (!(ae_config.init & INIT_MPU401)) {		if (!request_region(ae_config.base_io, IOBASE_REGION_SIZE,				"aedsp16 (base)")) {			printk(			"AEDSP16 BASE I/O port region is already in use.\n");			return FALSE;		}	}	ae_config.init |= INIT_MSS;	DBG(("done.\n"));	return TRUE;}static void __init uninit_aedsp16_mss(void){	DBG(("uninit_aedsp16_mss: "));	if ((!(ae_config.init & INIT_MPU401)) &&	   (ae_config.init & INIT_MSS)) {		release_region(ae_config.base_io, IOBASE_REGION_SIZE);		DBG(("AEDSP16 base region released.\n"));	}	ae_config.init &= ~INIT_MSS;	DBG(("done.\n"));}static int __init init_aedsp16_mpu(void){	DBG(("init_aedsp16_mpu: "));	if (ae_config.init & INIT_MPU401)		return FALSE;/* * We must request the CONFIG_AEDSP16_BASE region too because these are the I/O  * ports to access card's control registers. */	if (!(ae_config.init & (INIT_MSS | INIT_SBPRO))) {		if (!request_region(ae_config.base_io, IOBASE_REGION_SIZE,					"aedsp16 (base)")) {			printk(			"AEDSP16 BASE I/O port region is already in use.\n");			return FALSE;		}	}	ae_config.init |= INIT_MPU401;	DBG(("done.\n"));	return TRUE;}static void __init uninit_aedsp16_mpu(void){	DBG(("uninit_aedsp16_mpu: "));	if ((!(ae_config.init & (INIT_MSS | INIT_SBPRO))) &&	   (ae_config.init & INIT_MPU401)) {		release_region(ae_config.base_io, IOBASE_REGION_SIZE);		DBG(("AEDSP16 base region released.\n"));	}	ae_config.init &= ~INIT_MPU401;	DBG(("done.\n"));}int __init init_aedsp16(void){	int initialized = FALSE;	DBG(("Initializing BASE[0x%x] IRQ[%d] DMA[%d] MIRQ[%d]\n",	     ae_config.base_io,ae_config.irq,ae_config.dma,ae_config.mpu_irq));	if (ae_config.mss_base == -1) {		if (init_aedsp16_sb() == FALSE) {			uninit_aedsp16_sb();		} else {			initialized = TRUE;		}	}	if (ae_config.mpu_base != -1) {		if (init_aedsp16_mpu() == FALSE) {			uninit_aedsp16_mpu();		} else {			initialized = TRUE;		}	}/* * In the sequence of init routines, the MSS init MUST be the last! * This because of the special register programming the MSS mode needs. * A board reset would disable the MSS mode restoring the default SBPRO * mode. */	if (ae_config.mss_base != -1) {		if (init_aedsp16_mss() == FALSE) {			uninit_aedsp16_mss();		} else {			initialized = TRUE;		}	}	if (initialized)		initialized = aedsp16_init_board();	return initialized;}void __init uninit_aedsp16(void){	if (ae_config.mss_base != -1)		uninit_aedsp16_mss();	else		uninit_aedsp16_sb();	if (ae_config.mpu_base != -1)		uninit_aedsp16_mpu();}static int __initdata io = -1;static int __initdata irq = -1;static int __initdata dma = -1;static int __initdata mpu_irq = -1;static int __initdata mss_base = -1;static int __initdata mpu_base = -1;MODULE_PARM(io, "i");MODULE_PARM_DESC(io, "I/O base address (0x220 0x240)");MODULE_PARM(irq, "i");MODULE_PARM_DESC(irq, "IRQ line (5 7 9 10 11)");MODULE_PARM(dma, "i");MODULE_PARM_DESC(dma, "dma line (0 1 3)");MODULE_PARM(mpu_irq, "i");MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ line (5 7 9 10 0)");MODULE_PARM(mss_base, "i");MODULE_PARM_DESC(mss_base, "MSS emulation I/O base address (0x530 0xE80)");MODULE_PARM(mpu_base, "i");MODULE_PARM_DESC(mpu_base,"MPU-401 I/O base address (0x300 0x310 0x320 0x330)");MODULE_AUTHOR("Riccardo Facchetti <fizban@tin.it>");MODULE_DESCRIPTION("Audio Excel DSP 16 Driver Version " VERSION);MODULE_LICENSE("GPL");static int __init do_init_aedsp16(void) {	printk("Audio Excel DSP 16 init driver Copyright (C) Riccardo Facchetti 1995-98\n");	if (io == -1 || dma == -1 || irq == -1) {		printk(KERN_INFO "aedsp16: I/O, IRQ and DMA are mandatory\n");		return -EINVAL;	}	ae_config.base_io = io;	ae_config.irq = irq;	ae_config.dma = dma;	ae_config.mss_base = mss_base;	ae_config.mpu_base = mpu_base;	ae_config.mpu_irq = mpu_irq;	if (init_aedsp16() == FALSE) {		printk(KERN_ERR "aedsp16: initialization failed\n");		/*		 * XXX		 * What error should we return here ?		 */		return -EINVAL;	}	return 0;}static void __exit cleanup_aedsp16(void) {	uninit_aedsp16();}module_init(do_init_aedsp16);module_exit(cleanup_aedsp16);#ifndef MODULEstatic int __init setup_aedsp16(char *str){	/* io, irq, dma, mss_io, mpu_io, mpu_irq */	int ints[7];		str = get_options(str, ARRAY_SIZE(ints), ints);	io	 = ints[1];	irq	 = ints[2];	dma	 = ints[3];	mss_base = ints[4];	mpu_base = ints[5];	mpu_irq	 = ints[6];	return 1;}__setup("aedsp16=", setup_aedsp16);#endif

⌨️ 快捷键说明

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