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

📄 aedsp16.c

📁 Linux内核源代码 为压缩文件 是<<Linux内核>>一书中的源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
/* * Magic values that the DSP will eat when configuring irq/mirq/dma *//* DSP IRQ conversion array             */static struct orVals orIRQ[] __initdata = {	{0x05, 0x28},	{0x07, 0x08},	{0x09, 0x10},	{0x0a, 0x18},	{0x0b, 0x20},	{0x00, 0x00}};/* MPU-401 IRQ conversion array         */static struct orVals orMIRQ[] __initdata = {	{0x05, 0x04},	{0x07, 0x44},	{0x09, 0x84},	{0x0a, 0xc4},	{0x00, 0x00}};/* DMA Channels conversion array        */static struct orVals orDMA[] __initdata = {	{0x00, 0x01},	{0x01, 0x02},	{0x03, 0x03},	{0x00, 0x00}};static struct aedsp16_info ae_config __initdata = {	DEF_AEDSP16_IOB,	DEF_AEDSP16_IRQ,	DEF_AEDSP16_MRQ,	DEF_AEDSP16_DMA,	-1,	-1,	INIT_NONE};/* * Buffers to store audio card informations */static char     DSPCopyright[CARDNAMELEN + 1] __initdata = {0, };static char     DSPVersion[CARDVERLEN + 1] __initdata = {0, };static int __init aedsp16_wait_data(int port){	int             loop = STATUSRETRY;	unsigned char   ret = 0;	DBG1(("aedsp16_wait_data (0x%x): ", port));	do {		  ret = inb(port + DSP_DATAVAIL);	/*	 * Wait for data available (bit 7 of ret == 1)	 */	  } while (!(ret & 0x80) && loop--);	if (ret & 0x80) {		DBG1(("success.\n"));		return TRUE;	}	DBG1(("failure.\n"));	return FALSE;}static int __init aedsp16_read(int port){	int inbyte;	DBG(("    Read DSP Byte (0x%x): ", port));	if (aedsp16_wait_data(port) == FALSE) {		DBG(("failure.\n"));		return -1;	}	inbyte = inb(port + DSP_READ);	DBG(("read [0x%x]/{%c}.\n", inbyte, inbyte));	return inbyte;}static int __init aedsp16_test_dsp(int port){	return ((aedsp16_read(port) == 0xaa) ? TRUE : FALSE);}static int __init aedsp16_dsp_reset(int port){	/*	 * Reset DSP	 */	DBG(("Reset DSP:\n"));	outb(1, (port + DSP_RESET));	udelay(10);	outb(0, (port + DSP_RESET));	udelay(10);	udelay(10);	if (aedsp16_test_dsp(port) == TRUE) {		DBG(("success.\n"));		return TRUE;	} else		DBG(("failure.\n"));	return FALSE;}static int __init aedsp16_write(int port, int cmd){	unsigned char   ret;	int             loop = HARDRETRY;	DBG(("    Write DSP Byte (0x%x) [0x%x]: ", port, cmd));	do {		ret = inb(port + DSP_STATUS);		/*		 * DSP ready to receive data if bit 7 of ret == 0		 */		if (!(ret & 0x80)) {			outb(cmd, port + DSP_COMMAND);			DBG(("success.\n"));			return 0;		}	} while (loop--);	DBG(("timeout.\n"));	printk("[AEDSP16] DSP Command (0x%x) timeout.\n", cmd);	return -1;}#if defined(CONFIG_SC6600)#if defined(AEDSP16_INFO) || defined(AEDSP16_DEBUG)void __init aedsp16_pinfo(void) {	DBG(("\n Base address:  %x\n", decoded_hcfg.iobase));	DBG((" Joystick    : %s present\n", decoded_hcfg.joystick?"":" not"));	DBG((" WSS addr    :  %x\n", decoded_hcfg.wssbase));	DBG((" MPU-401 addr:  %x\n", decoded_hcfg.mpubase));	DBG((" CDROM       : %s present\n", (decoded_hcfg.cdrom!=4)?"":" not"));	DBG((" CDROMADDR   :  %x\n\n", decoded_hcfg.cdrombase));}#endifvoid __init aedsp16_hard_decode(void) {	DBG((" aedsp16_hard_decode: 0x%x, 0x%x\n", hard_cfg[0], hard_cfg[1]));/* * Decode Cfg Bytes. */	decoded_hcfg.iobase	= IOBASE(hard_cfg[0]);	decoded_hcfg.joystick	= JOY(hard_cfg[0]);	decoded_hcfg.wssbase	= WSSADDR(hard_cfg[0]);	decoded_hcfg.mpubase	= MPUADDR(hard_cfg[0]);	decoded_hcfg.cdrom	= CDROM(hard_cfg[1]);	decoded_hcfg.cdrombase	= CDROMADDR(hard_cfg[1]);#if defined(AEDSP16_INFO) || defined(AEDSP16_DEBUG)	printk(" Original sound card configuration:\n");	aedsp16_pinfo();#endif/* * Now set up the real kernel configuration. */	decoded_hcfg.iobase	= ae_config.base_io;	decoded_hcfg.wssbase	= ae_config.mss_base;	decoded_hcfg.mpubase	= ae_config.mpu_base;#if defined(CONFIG_SC6600_JOY) 	decoded_hcfg.joystick	= CONFIG_SC6600_JOY; /* Enable */#endif#if defined(CONFIG_SC6600_CDROM)	decoded_hcfg.cdrom	= CONFIG_SC6600_CDROM; /* 4:N-3:I-2:G-1:P-0:S */#endif#if defined(CONFIG_SC6600_CDROMBASE)	decoded_hcfg.cdrombase	= CONFIG_SC6600_CDROMBASE; /* 0 Disable */#endif#if defined(AEDSP16_DEBUG)	DBG((" New Values:\n"));	aedsp16_pinfo();#endif	DBG(("success.\n"));}void __init aedsp16_hard_encode(void) {	DBG((" aedsp16_hard_encode: 0x%x, 0x%x\n", hard_cfg[0], hard_cfg[1]));	hard_cfg[0] = 0;	hard_cfg[1] = 0;	hard_cfg[0] |= 0x20;	BLDIOBASE (hard_cfg[0], decoded_hcfg.iobase);	BLDWSSADDR(hard_cfg[0], decoded_hcfg.wssbase);	BLDMPUADDR(hard_cfg[0], decoded_hcfg.mpubase);	BLDJOY(hard_cfg[0], decoded_hcfg.joystick);	BLDCDROM(hard_cfg[1], decoded_hcfg.cdrom);	BLDCDROMADDR(hard_cfg[1], decoded_hcfg.cdrombase);#if defined(AEDSP16_DEBUG)	aedsp16_pinfo();#endif	DBG((" aedsp16_hard_encode: 0x%x, 0x%x\n", hard_cfg[0], hard_cfg[1]));	DBG(("success.\n"));}static int __init aedsp16_hard_write(int port) {	DBG(("aedsp16_hard_write:\n"));	if (aedsp16_write(port, COMMAND_6C)) {		printk("[AEDSP16] CMD 0x%x: failed!\n", COMMAND_6C);		DBG(("failure.\n"));		return FALSE;	}	if (aedsp16_write(port, COMMAND_5C)) {		printk("[AEDSP16] CMD 0x%x: failed!\n", COMMAND_5C);		DBG(("failure.\n"));		return FALSE;	}	if (aedsp16_write(port, hard_cfg[0])) {		printk("[AEDSP16] DATA 0x%x: failed!\n", hard_cfg[0]);		DBG(("failure.\n"));		return FALSE;	}	if (aedsp16_write(port, hard_cfg[1])) {		printk("[AEDSP16] DATA 0x%x: failed!\n", hard_cfg[1]);		DBG(("failure.\n"));		return FALSE;	}	if (aedsp16_write(port, COMMAND_C5)) {		printk("[AEDSP16] CMD 0x%x: failed!\n", COMMAND_C5);		DBG(("failure.\n"));		return FALSE;	}	DBG(("success.\n"));	return TRUE;}static int __init aedsp16_hard_read(int port) {	DBG(("aedsp16_hard_read:\n"));	if (aedsp16_write(port, READ_HARD_CFG)) {		printk("[AEDSP16] CMD 0x%x: failed!\n", READ_HARD_CFG);		DBG(("failure.\n"));		return FALSE;	}	if ((hard_cfg[0] = aedsp16_read(port)) == -1) {		printk("[AEDSP16] aedsp16_read after CMD 0x%x: failed\n",			READ_HARD_CFG);		DBG(("failure.\n"));		return FALSE;	}	if ((hard_cfg[1] = aedsp16_read(port)) == -1) {		printk("[AEDSP16] aedsp16_read after CMD 0x%x: failed\n",			READ_HARD_CFG);		DBG(("failure.\n"));		return FALSE;	}	if (aedsp16_read(port) == -1) {		printk("[AEDSP16] aedsp16_read after CMD 0x%x: failed\n",			READ_HARD_CFG);		DBG(("failure.\n"));		return FALSE;	}	DBG(("success.\n"));	return TRUE;}static int __init aedsp16_ext_cfg_write(int port) {	int extcfg, val;	if (aedsp16_write(port, COMMAND_66)) {		printk("[AEDSP16] CMD 0x%x: failed!\n", COMMAND_66);		return FALSE;	}	extcfg = 7;	if (decoded_hcfg.cdrom != 2)		extcfg = 0x0F;	if ((decoded_hcfg.cdrom == 4) ||	    (decoded_hcfg.cdrom == 3))		extcfg &= ~2;	if (decoded_hcfg.cdrombase == 0)		extcfg &= ~2;	if (decoded_hcfg.mpubase == 0)		extcfg &= ~1;	if (aedsp16_write(port, extcfg)) {		printk("[AEDSP16] Write extcfg: failed!\n");		return FALSE;	}	if (aedsp16_write(port, 0)) {		printk("[AEDSP16] Write extcfg: failed!\n");		return FALSE;	}	if (decoded_hcfg.cdrom == 3) {		if (aedsp16_write(port, COMMAND_52)) {			printk("[AEDSP16] CMD 0x%x: failed!\n", COMMAND_52);			return FALSE;		}		if ((val = aedsp16_read(port)) == -1) {			printk("[AEDSP16] aedsp16_read after CMD 0x%x: failed\n"					, COMMAND_52);			return FALSE;		}		val &= 0x7F;		if (aedsp16_write(port, COMMAND_60)) {			printk("[AEDSP16] CMD 0x%x: failed!\n", COMMAND_60);			return FALSE;		}		if (aedsp16_write(port, val)) {			printk("[AEDSP16] Write val: failed!\n");			return FALSE;		}	}	return TRUE;}#endif /* CONFIG_SC6600 */static int __init aedsp16_cfg_write(int port) {	if (aedsp16_write(port, WRITE_MDIRQ_CFG)) {		printk("[AEDSP16] CMD 0x%x: failed!\n", WRITE_MDIRQ_CFG);		return FALSE;	}	if (aedsp16_write(port, soft_cfg)) {		printk("[AEDSP16] Initialization of (M)IRQ and DMA: failed!\n");		return FALSE;	}	return TRUE;}static int __init aedsp16_init_mss(int port){	DBG(("aedsp16_init_mss:\n"));	mdelay(10);	if (aedsp16_write(port, DSP_INIT_MSS)) {		printk("[AEDSP16] aedsp16_init_mss [0x%x]: failed!\n",				DSP_INIT_MSS);		DBG(("failure.\n"));		return FALSE;	}		mdelay(10);	if (aedsp16_cfg_write(port) == FALSE)		return FALSE;	outb(soft_cfg_mss, ae_config.mss_base);	DBG(("success.\n"));	return TRUE;}static int __init aedsp16_setup_board(int port) {	int	loop = RETRY;#if defined(CONFIG_SC6600)	int	val = 0;	if (aedsp16_hard_read(port) == FALSE) {		printk("[AEDSP16] aedsp16_hard_read: failed!\n");		return FALSE;	}	if (aedsp16_write(port, COMMAND_52)) {		printk("[AEDSP16] CMD 0x%x: failed!\n", COMMAND_52);		return FALSE;	}	if ((val = aedsp16_read(port)) == -1) {		printk("[AEDSP16] aedsp16_read after CMD 0x%x: failed\n",				COMMAND_52);		return FALSE;	}#endif	do {		if (aedsp16_write(port, COMMAND_88)) {			printk("[AEDSP16] CMD 0x%x: failed!\n", COMMAND_88);			return FALSE;		}		mdelay(10);	} while ((aedsp16_wait_data(port) == FALSE) && loop--);	if (aedsp16_read(port) == -1) {		printk("[AEDSP16] aedsp16_read after CMD 0x%x: failed\n",				COMMAND_88);		return FALSE;	}#if !defined(CONFIG_SC6600)	if (aedsp16_write(port, COMMAND_5C)) {		printk("[AEDSP16] CMD 0x%x: failed!\n", COMMAND_5C);		return FALSE;	}#endif	if (aedsp16_cfg_write(port) == FALSE)		return FALSE;#if defined(CONFIG_SC6600)	if (aedsp16_write(port, COMMAND_60)) {		printk("[AEDSP16] CMD 0x%x: failed!\n", COMMAND_60);		return FALSE;	}	if (aedsp16_write(port, val)) {		printk("[AEDSP16] DATA 0x%x: failed!\n", val);		return FALSE;	}	if (aedsp16_write(port, COMMAND_6E)) {		printk("[AEDSP16] CMD 0x%x: failed!\n", COMMAND_6E);		return FALSE;	}	if (aedsp16_write(port, ver[0])) {		printk("[AEDSP16] DATA 0x%x: failed!\n", ver[0]);		return FALSE;	}	if (aedsp16_write(port, ver[1])) {		printk("[AEDSP16] DATA 0x%x: failed!\n", ver[1]);		return FALSE;	}	if (aedsp16_hard_write(port) == FALSE) {		printk("[AEDSP16] aedsp16_hard_write: failed!\n");		return FALSE;	}	if (aedsp16_write(port, COMMAND_5C)) {		printk("[AEDSP16] CMD 0x%x: failed!\n", COMMAND_5C);		return FALSE;	}#if defined(THIS_IS_A_THING_I_HAVE_NOT_TESTED_YET)	if (aedsp16_cfg_write(port) == FALSE)

⌨️ 快捷键说明

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