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

📄 aedsp16.c

📁 freebsd v4.4内核源码
💻 C
📖 第 1 页 / 共 2 页
字号:
	{	  OUTB (cmd, port + DSP_COMMAND);	  return 0;	}    }  while (loop--);  printk ("[aedsp16] DSP Command (0x%x) timeout.\n", cmd);  return -1;}intInitMSS (int port){  tenmillisec ();  if (WriteDSPCommand (port, CMD6))    {      printk ("[aedsp16] CMD 0x%x: failed!\n", CMD6);      return -1;    }  tenmillisec ();  return 0;}static intSetUpBoard (int port){  int             loop = RETRY;  do    {      if (WriteDSPCommand (portbase, CMD3))	{	  printk ("[aedsp16] CMD 0x%x: failed!\n", CMD3);	  return -1;	}      tenmillisec ();    }  while (WaitForDataAvail (port) && loop--);#if defined(THIS_SHOULD_GO_AWAY)  if (CheckDSPOkay (port))    {      printk ("[aedsp16]     CheckDSPOkay: failed\n");      return -1;    }#else  if (ReadData (port) == -1)    {      printk ("[aedsp16] ReadData after CMD 0x%x: failed\n", CMD3);      return -1;    }#endif  if (WriteDSPCommand (portbase, CMD4))    {      printk ("[aedsp16] CMD 0x%x: failed!\n", CMD4);      return -1;    }  if (WriteDSPCommand (portbase, CMD5))    {      printk ("[aedsp16] CMD 0x%x: failed!\n", CMD5);      return -1;    }  if (WriteDSPCommand (portbase, oredparams))    {      printk ("[aedsp16] Initialization of (M)IRQ and DMA: failed!\n");      return -1;    }  return 0;}static intGetCardVersion (int port){  int             len = 0;  int             ret;  int             ver[3];  do    {      if ((ret = ReadData (port)) == -1)	return -1;      /*         * We alredy know how many int are stored (2), so we know when the         * string is finished.       */      ver[len++] = ret;    }  while (len < CARDVERLEN);  sprintf (AudioExcelVersion, "%d.%d", ver[0], ver[1]);  return 0;}static intGetCardName (int port){  int             len = 0;  int             ret;  do    {      if ((ret = ReadData (port)) == -1)	/*	   * If no more data availabe, return to the caller, no error if len>0.	   * We have no other way to know when the string is finished.	 */	return (len ? 0 : -1);      AudioExcelName[len++] = ret;    }  while (len < CARDNAMELEN);  return 0;}static voidInitializeHardParams (void){  memset (AudioExcelName, 0, CARDNAMELEN + 1);  memset (AudioExcelVersion, 0, CARDVERLEN + 1);  for (gc = 0; orIRQ[gc].or; gc++)    if (orIRQ[gc].val == irq)      oredparams |= orIRQ[gc].or;  for (gc = 0; orMIRQ[gc].or; gc++)    if (orMIRQ[gc].or == mirq)      oredparams |= orMIRQ[gc].or;  for (gc = 0; orDMA[gc].or; gc++)    if (orDMA[gc].val == dma)      oredparams |= orDMA[gc].or;}static intInitAEDSP16 (int which){  static char    *InitName = NULL;  InitializeHardParams ();  if (ResetBoard (portbase))    {      printk ("[aedsp16] ResetBoard: failed!\n");      return -1;    }#if defined(THIS_SHOULD_GO_AWAY)  if (CheckDSPOkay (portbase))    {      printk ("[aedsp16] CheckDSPOkay: failed!\n");      return -1;    }#endif  if (WriteDSPCommand (portbase, CMD1))    {      printk ("[aedsp16] CMD 0x%x: failed!\n", CMD1);      return -1;    }  if (GetCardName (portbase))    {      printk ("[aedsp16] GetCardName: failed!\n");      return -1;    }  /*     * My AEDSP16 card return SC-6000 in AudioExcelName, so     * if we have something different, we have to be warned.   */  if (strcmp ("SC-6000", AudioExcelName))    printk ("[aedsp16] Warning: non SC-6000 audio card!\n");  if (WriteDSPCommand (portbase, CMD2))    {      printk ("[aedsp16] CMD 0x%x: failed!\n", CMD2);      return -1;    }  if (GetCardVersion (portbase))    {      printk ("[aedsp16] GetCardVersion: failed!\n");      return -1;    }  if (SetUpBoard (portbase))    {      printk ("[aedsp16] SetUpBoard: failed!\n");      return -1;    }  if (which == INIT_MSS)    {      if (InitMSS (portbase))	{	  printk ("[aedsp16] Can't initialize Microsoft Sound System mode.\n");	  return -1;	}    }  /*     * If we are resetting, do not print any message because we may be     * in playing and we do not want lost too much time.   */  if (!(which & RESET_DSP16))    {      if (which & INIT_MPU401)	InitName = "MPU401";      else if (which & INIT_SBPRO)	InitName = "SBPro";      else if (which & INIT_MSS)	InitName = "MSS";      else	InitName = "None";      printk ("Audio Excel DSP 16 init v%s (%s %s) [%s]\n",	      VERSION, AudioExcelName,	      AudioExcelVersion, InitName);    }  tenmillisec ();  return 0;}#if defined(AEDSP16_SBPRO)intInitAEDSP16_SBPRO (struct address_info *hw_config){  /*     * If the card is alredy init'ed MSS, we can not init it to SBPRO too     * because the board can not emulate simultaneously MSS and SBPRO.   */  if (ae_init & INIT_MSS)    return -1;  if (ae_init & INIT_SBPRO)    return 0;  /*     * For now we will leave this     * code included only when INCLUDE_AEDSP16 is configured in, but it should     * be better include it every time.   */  if (!(ae_init & INIT_MPU401))    {      if (check_region (hw_config->io_base, 0x0f))	{	  printk ("AEDSP16/SBPRO I/O port region is alredy in use.\n");	  return -1;	}    }  /*     * Set up the internal hardware parameters, to let the driver reach     * the Sound Card.   */  portbase = hw_config->io_base;  irq = hw_config->irq;  dma = hw_config->dma;  if (InitAEDSP16 (INIT_SBPRO))    return -1;  if (!(ae_init & INIT_MPU401))    request_region (hw_config->io_base, 0x0f, "aedsp16 (sbpro)");  ae_init |= INIT_SBPRO;  return 0;}#endif /* AEDSP16_SBPRO */#if defined(AEDSP16_MSS)intInitAEDSP16_MSS (struct address_info *hw_config){  /*     * If the card is alredy init'ed SBPRO, we can not init it to MSS too     * because the board can not emulate simultaneously MSS and SBPRO.   */  if (ae_init & INIT_SBPRO)    return -1;  if (ae_init & INIT_MSS)    return 0;  /*     * For now we will leave this     * code included only when INCLUDE_AEDSP16 is configured in, but it should     * be better include it every time.   */  if (check_region (hw_config->io_base, 0x08))    {      printk ("MSS I/O port region is alredy in use.\n");      return -1;    }  /*     * We must allocate the AEDSP16 region too because these are the I/O ports     * to access card's control registers.   */  if (!(ae_init & INIT_MPU401))    {      if (check_region (AEDSP16_BASE, 0x0f))	{	  printk ("AEDSP16 I/O port region is alredy in use.\n");	  return -1;	}    }  /*     * If we are configuring the card for MSS, the portbase for card configuration     * is the default one (0x220 unless you have changed the factory default     * with board switches), so no need to modify the portbase variable.     * The default is AEDSP16_BASE, that is the right value.   */  irq = hw_config->irq;  dma = hw_config->dma;  if (InitAEDSP16 (INIT_MSS))    return -1;  request_region (hw_config->io_base, 0x08, "aedsp16 (mss)");  if (!(ae_init & INIT_MPU401))    request_region (AEDSP16_BASE, 0x0f, "aedsp16 (sbpro)");  ae_init |= INIT_MSS;  return 0;}#endif /* AEDSP16_MSS */#if defined(AEDSP16_MPU401)intInitAEDSP16_MPU401 (struct address_info *hw_config){  if (ae_init & INIT_MPU401)    return 0;  /*     * For now we will leave this     * code included only when INCLUDE_AEDSP16 is configured in, but it should     * be better include it every time.   */  if (check_region (hw_config->io_base, 0x02))    {      printk ("SB I/O port region is alredy in use.\n");      return -1;    }  /*     * We must allocate the AEDSP16 region too because these are the I/O ports     * to access card's control registers.   */  if (!(ae_init & (INIT_MSS | INIT_SBPRO)))    {      if (check_region (AEDSP16_BASE, 0x0f))	{	  printk ("AEDSP16 I/O port region is alredy in use.\n");	  return -1;	}    }  /*     * If mpu401, the irq and dma are not important, do not touch it     * because we may use the default if sbpro is not yet configured,     * we may use the sbpro ones if configured, and nothing wrong     * should happen.     *     * The mirq default is 0, but once set it to non-0 value, we should     * not touch it anymore (unless I write an ioctl to do it, of course).   */  mirq = hw_config->irq;  if (InitAEDSP16 (INIT_MPU401))    return -1;  request_region (hw_config->io_base, 0x02, "aedsp16 (mpu401)");  if (!(ae_init & (INIT_MSS | INIT_SBPRO)))    request_region (AEDSP16_BASE, 0x0f, "aedsp16 (sbpro)");  ae_init |= INIT_MPU401;  return 0;}#endif /* AEDSP16_MPU401 */#if 0				/* Leave it out for now. We are not using this portion of code. *//* * Entry point for a reset function. * May be I will write the infamous ioctl :) */intResetAEDSP16 (void){#if defined(AEDSP16_DEBUG)  printk ("[aedsp16] ResetAEDSP16 called.\n");#endif  return InitAEDSP16 (RESET_DSP16);}#endif /* 0 */#endif /* !EXCLUDE_AEDSP16 */

⌨️ 快捷键说明

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