コード例 #1
0
ファイル: ax88180.c プロジェクト: 0xFelix/u-boot-edminiv2
static void ax88180_read_mac_addr (struct eth_device *dev)
{
	unsigned short macid0_val, macid1_val, macid2_val;
	unsigned short tmp_regval;
	unsigned short i;

	/* Reload MAC address from EEPROM */
	OUTW (dev, RELOAD_EEPROM, PROMCTRL);

	/* Waiting for reload eeprom completion */
	for (i = 0; i < 500; i++) {
		tmp_regval = INW (dev, PROMCTRL);
		if ((tmp_regval & RELOAD_EEPROM) == 0)
			break;
		udelay (1000);
	}

	/* Get MAC addresses */
	macid0_val = INW (dev, MACID0);
	macid1_val = INW (dev, MACID1);
	macid2_val = INW (dev, MACID2);

	if (((macid0_val | macid1_val | macid2_val) != 0) &&
	    ((macid0_val & 0x01) == 0)) {
		dev->enetaddr[0] = (unsigned char)macid0_val;
		dev->enetaddr[1] = (unsigned char)(macid0_val >> 8);
		dev->enetaddr[2] = (unsigned char)macid1_val;
		dev->enetaddr[3] = (unsigned char)(macid1_val >> 8);
		dev->enetaddr[4] = (unsigned char)macid2_val;
		dev->enetaddr[5] = (unsigned char)(macid2_val >> 8);
	}
コード例 #2
0
ファイル: ax88180.c プロジェクト: 0xFelix/u-boot-edminiv2
/* Get a data block via Ethernet */
static int ax88180_recv (struct eth_device *dev)
{
	unsigned short ISR_Status;
	unsigned short tmp_regval;

	/* Read and check interrupt status here. */
	ISR_Status = INW (dev, ISR);

	while (ISR_Status) {
		/* Clear the interrupt status */
		OUTW (dev, ISR_Status, ISR);

		debug ("\nax88180: The interrupt status = 0x%04x\n",
		       ISR_Status);

		if (ISR_Status & ISR_PHY) {
			/* Read ISR register once to clear PHY interrupt bit */
			tmp_regval = ax88180_mdio_read (dev, M88_ISR);
			ax88180_media_config (dev);
		}

		if ((ISR_Status & ISR_RX) || (ISR_Status & ISR_RXBUFFOVR)) {
			ax88180_rx_handler (dev);
		}

		/* Read and check interrupt status again */
		ISR_Status = INW (dev, ISR);
	}

	return 0;
}
コード例 #3
0
ファイル: ax88180.c プロジェクト: 0xFelix/u-boot-edminiv2
/* Send a data block via Ethernet. */
static int ax88180_send(struct eth_device *dev, void *packet, int length)
{
	struct ax88180_private *priv = (struct ax88180_private *)dev->priv;
	unsigned short TXDES_addr;
	unsigned short txcmd_txdp, txbs_txdp;
	unsigned short tmp_data;
	int i;
#if defined (CONFIG_DRIVER_AX88180_16BIT)
	volatile unsigned short *txdata = (volatile unsigned short *)packet;
#else
	volatile unsigned long *txdata = (volatile unsigned long *)packet;
#endif
	unsigned short count;

	if (priv->LinkState != INS_LINK_UP) {
		return 0;
	}

	priv->FirstTxDesc = priv->NextTxDesc;
	txbs_txdp = 1 << priv->FirstTxDesc;

	debug ("ax88180: TXDP%d is available\n", priv->FirstTxDesc);

	txcmd_txdp = priv->FirstTxDesc << 13;
	TXDES_addr = TXDES0 + (priv->FirstTxDesc << 2);

	OUTW (dev, (txcmd_txdp | length | TX_START_WRITE), TXCMD);

	/* Comput access times */
	count = (length + priv->PadSize) >> priv->BusWidth;

	for (i = 0; i < count; i++) {
		WRITE_TXBUF (dev, *(txdata + i));
	}

	OUTW (dev, txcmd_txdp | length, TXCMD);
	OUTW (dev, txbs_txdp, TXBS);
	OUTW (dev, (TXDPx_ENABLE | length), TXDES_addr);

	priv->NextTxDesc = (priv->NextTxDesc + 1) & TXDP_MASK;

	/*
	 * Check the available transmit descriptor, if we had exhausted all
	 * transmit descriptor ,then we have to wait for at least one free
	 * descriptor
	 */
	txbs_txdp = 1 << priv->NextTxDesc;
	tmp_data = INW (dev, TXBS);

	if (tmp_data & txbs_txdp) {
		if (ax88180_poll_tx_complete (dev) < 0) {
			ax88180_mac_reset (dev);
			priv->FirstTxDesc = TXDP0;
			priv->NextTxDesc = TXDP0;
			printf ("ax88180: Transmit time out occurred!\n");
		}
	}

	return 0;
}
コード例 #4
0
ファイル: ax88180.c プロジェクト: 0xFelix/u-boot-edminiv2
static void ax88180_mac_reset (struct eth_device *dev)
{
	unsigned long tmpval;
	unsigned char i;

	struct {
		unsigned short offset, value;
	} program_seq[] = {
		{
		MISC, MISC_NORMAL}, {
		RXINDICATOR, DEFAULT_RXINDICATOR}, {
		TXCMD, DEFAULT_TXCMD}, {
		TXBS, DEFAULT_TXBS}, {
		TXDES0, DEFAULT_TXDES0}, {
		TXDES1, DEFAULT_TXDES1}, {
		TXDES2, DEFAULT_TXDES2}, {
		TXDES3, DEFAULT_TXDES3}, {
		TXCFG, DEFAULT_TXCFG}, {
		MACCFG2, DEFAULT_MACCFG2}, {
		MACCFG3, DEFAULT_MACCFG3}, {
		TXLEN, DEFAULT_TXLEN}, {
		RXBTHD0, DEFAULT_RXBTHD0}, {
		RXBTHD1, DEFAULT_RXBTHD1}, {
		RXFULTHD, DEFAULT_RXFULTHD}, {
		DOGTHD0, DEFAULT_DOGTHD0}, {
	DOGTHD1, DEFAULT_DOGTHD1},};

	OUTW (dev, MISC_RESET_MAC, MISC);
	tmpval = INW (dev, MISC);

	for (i = 0; i < ARRAY_SIZE(program_seq); i++)
		OUTW (dev, program_seq[i].value, program_seq[i].offset);
}
コード例 #5
0
static int
ac97_write2 (void *devc_, int index, int data)
{
  fm801_devc *devc = devc_;
  int idx;
  oss_native_word flags;
  MUTEX_ENTER_IRQDISABLE (devc->low_mutex, flags);
  /*
   * Wait until the codec interface is ready..
   */
  for (idx = 0; idx < 10000; idx++)
    {
      if (!(INW (devc->osdev, devc->base + AC97_CMD) & (1 << 9)))
	break;
      oss_udelay (10);
    }
  if (INW (devc->osdev, devc->base + AC97_CMD) & (1 << 9))
    {
      DDB (cmn_err (CE_WARN, "Secondary AC97 busy\n"));
      MUTEX_EXIT_IRQRESTORE (devc->low_mutex, flags);
      return OSS_EIO;
    }
  /* write data and address */
  OUTW (devc->osdev, data, devc->base + AC97_DATA);
  OUTW (devc->osdev, index | (0x1 << 10), devc->base + AC97_CMD);
  /*
   * Wait until the write command is completed..
   */
  for (idx = 0; idx < 1000; idx++)
    {
      if (!(INW (devc->osdev, devc->base + AC97_CMD) & (1 << 9)))
	break;
      oss_udelay (10);
    }
  if (INW (devc->osdev, devc->base + AC97_CMD) & (1 << 9))
    {
      DDB (cmn_err (CE_WARN, "Secondary AC97 busy (1)\n"));
      MUTEX_EXIT_IRQRESTORE (devc->low_mutex, flags);
      return OSS_EIO;
    }
  MUTEX_EXIT_IRQRESTORE (devc->low_mutex, flags);
  return 0;
}
コード例 #6
0
ファイル: sscom.c プロジェクト: MarginC/kame
static void
iputchar(int c)
{
	uint32_t stat;
	int timo;

	/* Wait for any pending transmission to finish. */
	timo = 50000;   
	while (ISSET(stat = INW(SSCOM_UFSTAT), UFSTAT_TXFULL) && --timo)
		/* spin */ ;

	OUTB(SSCOM_UTXH, c);

#if 0
	/* Wait for this transmission to complete. */
	timo = 1500000;
	while (!ISSET(stat = INW(SSCOM_UFSTAT), UFSTAT_TXFULL) && --timo)
		/* spin */ ;
#endif
}
コード例 #7
0
static void
uninit_audio (fm801_devc * devc)
{
  unsigned int irqmask;
  devc->audio_initialized = 0;
#ifndef _TRU64_UNIX
  /* interrupt setup - mask MPU, PLAYBACK & CAPTURE */
  irqmask = INW (devc->osdev, devc->base + IRQ_MASK);
  irqmask |= 0x00C3;
  OUTW (devc->osdev, irqmask, devc->base + IRQ_MASK);
  pci_write_config_word (devc->osdev, 0x40, 0x807F);
#endif
}
コード例 #8
0
static int
ac97_read2 (void *devc_, int index)
{
  fm801_devc *devc = devc_;
  int idx;
  oss_native_word flags;
  MUTEX_ENTER_IRQDISABLE (devc->low_mutex, flags);
  /*
   * Wait until the codec interface is not ready..
   */
  for (idx = 0; idx < 10000; idx++)
    {
      if (!(INW (devc->osdev, devc->base + AC97_CMD) & (1 << 9)))
	break;
      oss_udelay (10);
    }
  if (INW (devc->osdev, devc->base + AC97_CMD) & (1 << 9))
    {
      DDB (cmn_err (CE_WARN, "Secondary AC97 (read) not ready (1)\n"));
      MUTEX_EXIT_IRQRESTORE (devc->low_mutex, flags);
      return 0;
    }
  /* read command */
  OUTW (devc->osdev, index | (0x1 << 10) | (1 << 7), devc->base + AC97_CMD);
  for (idx = 0; idx < 10000; idx++)
    {
      if (!(INW (devc->osdev, devc->base + AC97_CMD) & (1 << 9)))
	break;
      oss_udelay (10);
    }
  /*
   * Wait until the codec interface is not ready..
   */
  if (INW (devc->osdev, devc->base + AC97_CMD) & (1 << 9))
    {
      DDB (cmn_err (CE_WARN, "Secondary AC97 (read) not ready(2)\n"));
      MUTEX_EXIT_IRQRESTORE (devc->low_mutex, flags);
      return 0;
    }
  for (idx = 0; idx < 10000; idx++)
    {
      if (INW (devc->osdev, devc->base + AC97_CMD) & (1 << 8))
	break;
      oss_udelay (10);
    }
  if (!(INW (devc->osdev, devc->base + AC97_CMD) & (1 << 8)))
    {
      cmn_err (CE_WARN, "Secondary AC97 (read) data not valid (2)\n");
      MUTEX_EXIT_IRQRESTORE (devc->low_mutex, flags);
      return 0;
    }
  MUTEX_EXIT_IRQRESTORE (devc->low_mutex, flags);
  return INW (devc->osdev, devc->base + AC97_DATA);
}
コード例 #9
0
ファイル: ax88180.c プロジェクト: 0xFelix/u-boot-edminiv2
/*
 * ===========================================================================
 * Local SubProgram Bodies
 * ===========================================================================
 */
static int ax88180_mdio_check_complete (struct eth_device *dev)
{
	int us_cnt = 10000;
	unsigned short tmpval;

	/* MDIO read/write should not take more than 10 ms */
	while (--us_cnt) {
		tmpval = INW (dev, MDIOCTRL);
		if (((tmpval & READ_PHY) == 0) && ((tmpval & WRITE_PHY) == 0))
			break;
	}

	return us_cnt;
}
コード例 #10
0
ファイル: ax88180.c プロジェクト: 0xFelix/u-boot-edminiv2
static unsigned short
ax88180_mdio_read (struct eth_device *dev, unsigned long regaddr)
{
	struct ax88180_private *priv = (struct ax88180_private *)dev->priv;
	unsigned long tmpval = 0;

	OUTW (dev, (READ_PHY | (regaddr << 8) | priv->PhyAddr), MDIOCTRL);

	if (ax88180_mdio_check_complete (dev))
		tmpval = INW (dev, MDIODP);
	else
		printf ("Failed to read PHY register!\n");

	return (unsigned short)(tmpval & 0xFFFF);
}
コード例 #11
0
static int
ac97_read (void *devc_, int index)
{
  oss_native_word access;
  unsigned int data;
  unsigned i, N;
  unsigned char byte;
  oss_native_word flags;
  als300_devc *devc = devc_;

  MUTEX_ENTER_IRQDISABLE (devc->low_mutex, flags);
  i = 0;
  N = 1000;
  do
    {
      byte = INB (devc->osdev, devc->base + 6) & 0x80;
      if (byte == 0x00)
	goto next;
      oss_udelay (10);
      i++;
    }
  while (i < N);
  if (i >= N)
    cmn_err (CE_WARN, "\n Write AC97 mixer index time out !!");
next:
  access = index;
  access <<= 24;		/*index */
  access |= 0x80000000;
  OUTL (devc->osdev, access, devc->base);

  i = 0;
  N = 1000;
  do
    {
      byte = INB (devc->osdev, devc->base + 6);
      if ((byte & 0x40) != 0)
	goto next1;
      oss_udelay (10);
      i++;
    }
  while (i < N);
  if (i >= N)
    cmn_err (CE_WARN, "Read AC97 mixer data time out !!");
next1:
  data = INW (devc->osdev, devc->base + 0x04);
  MUTEX_EXIT_IRQRESTORE (devc->low_mutex, flags);
  return data;
}
コード例 #12
0
ファイル: ax88180.c プロジェクト: 0xFelix/u-boot-edminiv2
static int ax88180_init (struct eth_device *dev, bd_t * bd)
{
	struct ax88180_private *priv = (struct ax88180_private *)dev->priv;
	unsigned short tmp_regval;

	ax88180_mac_reset (dev);

	/* Disable interrupt */
	OUTW (dev, CLEAR_IMR, IMR);

	/* Disable AX88180 TX/RX functions */
	OUTW (dev, WAKEMOD, CMD);

	/* Fill the MAC address */
	tmp_regval =
	    dev->enetaddr[0] | (((unsigned short)dev->enetaddr[1]) << 8);
	OUTW (dev, tmp_regval, MACID0);

	tmp_regval =
	    dev->enetaddr[2] | (((unsigned short)dev->enetaddr[3]) << 8);
	OUTW (dev, tmp_regval, MACID1);

	tmp_regval =
	    dev->enetaddr[4] | (((unsigned short)dev->enetaddr[5]) << 8);
	OUTW (dev, tmp_regval, MACID2);

	ax88180_media_config (dev);

	OUTW (dev, DEFAULT_RXFILTER, RXFILTER);

	/* Initial variables here */
	priv->FirstTxDesc = TXDP0;
	priv->NextTxDesc = TXDP0;

	/* Check if there is any invalid interrupt status and clear it. */
	OUTW (dev, INW (dev, ISR), ISR);

	/* Start AX88180 TX/RX functions */
	OUTW (dev, (RXEN | TXEN | WAKEMOD), CMD);

	return 0;
}
コード例 #13
0
void
atge_l1e_tx_reclaim(atge_t *atgep)
{
	int start, end;

	ASSERT(MUTEX_HELD(&atgep->atge_tx_lock));

	end = INW(atgep, L1E_TPD_CONS_IDX);
	start = atgep->atge_tx_ring->r_consumer;

	ATGE_DB(("%s: %s() start : %d, end : %d, avail : %d",
	    atgep->atge_name, __func__, start, end,
	    atgep->atge_tx_ring->r_avail_desc));

	while (start != end) {
		atgep->atge_tx_ring->r_avail_desc++;
		ATGE_DESC_INC(start, L1E_TX_RING_CNT);
	}

	atgep->atge_tx_ring->r_consumer = start;
}
コード例 #14
0
ファイル: ax88180.c プロジェクト: 0xFelix/u-boot-edminiv2
static int ax88180_poll_tx_complete (struct eth_device *dev)
{
	struct ax88180_private *priv = (struct ax88180_private *)dev->priv;
	unsigned long tmpval, txbs_txdp;
	int TimeOutCnt = 10000;

	txbs_txdp = 1 << priv->NextTxDesc;

	while (TimeOutCnt--) {

		tmpval = INW (dev, TXBS);

		if ((tmpval & txbs_txdp) == 0)
			break;

		udelay (100);
	}

	if (TimeOutCnt)
		return 0;
	else
		return -TimeOutCnt;
}
コード例 #15
0
static int
ac97_read (void *devc_, int addr)
{
  allegro_devc *devc = devc_;
  oss_native_word flags;
  unsigned short data;
#if 0
  int i;
  int sanity = 10000;

  MUTEX_ENTER_IRQDISABLE (devc->low_mutex, flags);
  for (i = 0; i < 100000; i++)
    if (!(INB (devc->osdev, devc->base + 0x30) & 0x01))
      break;
  OUTW (devc->osdev, addr | 0x80, devc->base + 0x30);

  while (INB (devc->osdev, devc->base + 0x30) & 1)
    {
      sanity--;
      if (!sanity)
	{
	  cmn_err (CE_WARN, "ac97 codec timeout - 0x%x.\n", addr);
	  MUTEX_EXIT_IRQRESTORE (devc->low_mutex, flags);
	  return 0;
	}
    }

  data = INW (devc->osdev, devc->base + 0x32);
  MUTEX_EXIT_IRQRESTORE (devc->low_mutex, flags);
#else
  MUTEX_ENTER_IRQDISABLE (devc->low_mutex, flags);
  HWMGR_ReadCodecData (devc, (UCHAR) addr, &data);
  MUTEX_EXIT_IRQRESTORE (devc->low_mutex, flags);
#endif
  return data;
}
コード例 #16
0
static int
init_fm801 (fm801_devc * devc)
{
  int my_mixer, my_mixer2;
  int legacy;
  int irqmask;
  int adev;
  int first_dev = 0;
  int i;

  devc->mpu_attached = devc->fm_attached = 0;

  legacy = 0;

#if !defined(__hpux) && !defined(sparc) && !defined(_TRU64)
  /* Enable Legacy FM, MPU and Joystick ports */
  legacy = 0x001E;
  switch (fmedia_mpu_irq)
    {
    case 5:
      legacy |= 0x0000;
      break;
    case 7:
      legacy |= 0x0800;
      break;
    case 9:
      legacy |= 0x1000;
      break;
    case 10:
      legacy |= 0x1800;
      break;
    case 11:
      legacy |= 0x2000;
      break;
    }
#endif

  pci_write_config_word (devc->osdev, 0x40, legacy);

  /* codec cold reset + AC'97 warm reset */
  OUTW (devc->osdev, (1 << 5) | (1 << 6), devc->base + CODEC_CONTROL);
  oss_udelay (10);
  OUTW (devc->osdev, 0, devc->base + CODEC_CONTROL);

  if (devc->model == MDL_FM801AU)
    {
      OUTW (devc->osdev, (1 << 7), devc->base + CODEC_CONTROL);
      oss_udelay (10);
    }

  /* init volume */
  OUTW (devc->osdev, 0x0808, devc->base + PCM_VOL);
  OUTW (devc->osdev, 0x0808, devc->base + FM_VOL);
  OUTW (devc->osdev, 0x0808, devc->base + I2S_VOL);
  /* interrupt setup - unmask MPU, PLAYBACK & CAPTURE */
  irqmask = INW (devc->osdev, devc->base + IRQ_MASK);
  irqmask &= ~0x0083;
  OUTW (devc->osdev, irqmask, devc->base + IRQ_MASK);
  OUTW (devc->osdev, 0x280C, devc->base + GENERAL_CONTROL);
  OUTW (devc->osdev, 0x0, devc->base + I2S_MODE);
#if !defined(__hpux) && !defined(sparc) && !defined(_TRU64_UNIX)
  /* interrupt clear */
  /*
   * TODO: Check this. Unaligned I/O access causes a crash onder non-x86
   */
  OUTW (devc->osdev, IRQ_PLAY | IRQ_REC | IRQ_MPU, devc->base + IRQ_STATUS);
#endif
  /*
   * Enable BusMasterMode and IOSpace Access
   */
#ifdef OBSOLETED_STUFF
  attach_fm (devc);
  attach_mpu (devc);
#endif
  my_mixer = ac97_install (&devc->ac97devc, "FM801 AC97 Mixer",
			   ac97_read, ac97_write, devc, devc->osdev);

  if (my_mixer >= 0)
    {
      devc->mixer_dev = my_mixer;
      if (devc->model == MDL_FM801AU)
	{
	  my_mixer2 = ac97_install (&devc->ac97devc2, "FM801 AC97 Secondary",
				    ac97_read2, ac97_write2, devc,
				    devc->osdev);
	  if (my_mixer2 >= 0)
	    devc->mixer2_dev = my_mixer2;
	}
    }
  else
    return 0;

  for (i = 0; i < MAX_PORTC; i++)
    {
      char tmp_name[100];
      fm801_portc *portc = &devc->portc[i];
      int caps = ADEV_AUTOMODE;
      if (i == 0)
	{
	  strcpy (tmp_name, devc->chip_name);
	  caps |= ADEV_DUPLEX;
	}
      else
	{
	  strcpy (tmp_name, devc->chip_name);
	  caps |= ADEV_DUPLEX | ADEV_SHADOW;
	}
      if ((adev = oss_install_audiodev (OSS_AUDIO_DRIVER_VERSION,
					devc->osdev,
					devc->osdev,
					tmp_name,
					&fm801_audio_driver,
					sizeof (audiodrv_t),
					caps,
					AFMT_U8 | AFMT_S16_LE, devc, -1)) < 0)
	{
	  adev = -1;
	  return 1;
	}
      else
	{
	  if (i == 0)
	    first_dev = adev;
	  audio_engines[adev]->portc = portc;
	  audio_engines[adev]->rate_source = first_dev;
	  audio_engines[adev]->mixer_dev = my_mixer;
	  audio_engines[adev]->min_rate = 5000;
	  audio_engines[adev]->max_rate = 48000;
	  audio_engines[adev]->caps |= PCM_CAP_FREERATE;
	  audio_engines[adev]->min_channels = 2;
	  audio_engines[adev]->max_channels = 6;
	  portc->open_mode = 0;
	  portc->audiodev = adev;
	  portc->audio_enabled = 0;
#ifdef CONFIG_OSS_VMIX
	  if (i == 0)
	     vmix_attach_audiodev(devc->osdev, adev, -1, 0);
#endif
	}
      init_audio (devc);
    }
  return 1;
}
コード例 #17
0
ファイル: info.c プロジェクト: sinamoeini/AtomEye
bool print_status (int iw)
{
    int i;
    double x[3], V[3][3];
    SimpleStatistics ss;
    /* xterm_get_focus(iw); */
    for (i=0; i<CONFIG_num_auxiliary; i++)
    {
        CalculateSimpleStatistics
            (np, CHARP(CONFIG_auxiliary[i]), sizeof(double),
             IOVAL_DOUBLE, &ss);
        printf("\nauxiliary[%d]=%s [%s], threshold=[%g, %g]\n", i,
               CONFIG_auxiliary_name[i], CONFIG_auxiliary_unit[i],
               n[iw].auxiliary_threshold[i][0],
               n[iw].auxiliary_threshold[i][1]);
        printf("[%g(%d), %g(%d)], avg=%g, std.dev.=%g\n",
               ss.min, ss.idx_min, ss.max, ss.idx_max,
               ss.average, ss.standard_deviation);
    }
    printf("\n======================= Status of Viewport #%d "
           "=======================\n",iw);
    V3EQV (AX_3D[iw].x, x);
    V3pr ("Viewpoint is at %M A,\n", x);
    M3inv (H, V);
    V3mM3 (AX_3D[iw].x, V, x);
    V3pr("in reduced coordinates it is %M;\n", x);
    M3EQV(AX_3D[iw].V, V); S3PR("viewport axes = %M;\n", V);
    printf ("window width = %d, height = %d pixels,\n",
            AX_size[iw].width, AX_size[iw].height);
    printf ("and conversion factor is %g pixel/radian,\n", AX_3D[iw].k);
    printf ("which converts to %g x %g degrees of field of view.\n",
            RADIAN_TO_DEGREE(2*atan(AX_size[iw].width/2/AX_3D[iw].k)),
            RADIAN_TO_DEGREE(2*atan(AX_size[iw].height/2/AX_3D[iw].k)));
    printf ("The viewport is now anchored to %s",
            (n[iw].anchor>=0)? "atom" : "hook" );
    if (n[iw].anchor >= 0) print_atom(iw,n[iw].anchor);
    else
    {
        M3inv (H, V);
        V3mM3 (n[iw].hook, V, x);
        printf("\nx = [%g %g %g] A, or s = [%g %g %g].\n", n[iw].hook[0],
               n[iw].hook[1], n[iw].hook[2], x[0], x[1], x[2]);
    }
    printf("parallel projection mode is turned %s.\n",
           n[iw].parallel_projection?"ON":"OFF");
    printf("term printout suppression is turned %s.\n",
           n[iw].suppress_printout?"ON":"OFF");
    V3pr ("background color = %M.\n", n[iw].bgcolor);
    printf ("atom r_ratio = %f, bond radius = %f A.\n",
            n[iw].atom_r_ratio, n[iw].bond_radius);
    printf("bond mode is turned %s.\n", n[iw].bond_mode?"ON":"OFF");
    printf("system average IS%s subtracted off from atomistic strains.\n",
           shear_strain_subtract_mean ? "" : "N'T");
    printf("wireframe mode is %s.\n",
           (n[iw].wireframe_mode==WIREFRAME_MODE_CONTRAST)?"CONTRAST":
           (n[iw].wireframe_mode==WIREFRAME_MODE_NONE)?"NONE":
           (n[iw].wireframe_mode==WIREFRAME_MODE_RGBO)?"RGBO":
           (n[iw].wireframe_mode==WIREFRAME_MODE_RGBK)?"RGBK":
           (n[iw].wireframe_mode==WIREFRAME_MODE_RGB)?"RGB":
           "UNKNOWN");
    if (n[iw].xtal_mode)
    {
        printf ("Xtal mode is turned ON:\n");
        V3mM3 (n[iw].xtal_origin, HI, x);
        V3TRIM (x, x);
        V3pr ("xtal_origin = %M.\n", x);
    }
    else printf ("Xtal mode is turned OFF.\n");
    printf ("color mode = %s.\n",
            (n[iw].color_mode==COLOR_MODE_NORMAL)? "NORMAL" :
            (n[iw].color_mode==COLOR_MODE_COORD)? "COORDINATION" :
            (n[iw].color_mode==COLOR_MODE_AUXILIARY)? "Auxiliary Properties" :
            (n[iw].color_mode==COLOR_MODE_SCRATCH)? "SCRATCH" : "UNKNOWN");
    if (n[iw].shell_viewer_mode)
        printf("Shell viewer auto-invoke is turned ON.\n");
    else printf("Shell viewer auto-invoke is turned OFF.\n");
    printf("s[%d]=%d surface is now seen or selected.\n",
           n[iw].last_surface_id/2, n[iw].last_surface_id%2);
    if (rcut_patching)
        printf ("Neighbor distance cutoff between %s = %g.\n",
                rcut_patch_pairname, rcut_patch[rcut_patch_item].rcut);
    printf ("rate of change = %g.\n", n[iw].delta);
    if (n[iw].color_mode==COLOR_MODE_AUXILIARY)
    {
        i = n[iw].auxiliary_idx;
        if (i < CONFIG_num_auxiliary)
            printf("auxiliary[%d] = %s [%s], threshold = [%g, %g],\n", i,
                   CONFIG_auxiliary_name[i], CONFIG_auxiliary_unit[i],
                   n[iw].auxiliary_threshold[i][0],
                   n[iw].auxiliary_threshold[i][1]);
        else printf("auxiliary = %s, threshold = [%g, %g],\n", 
                    geolist[i-CONFIG_MAX_AUXILIARY].token, 
                    n[iw].auxiliary_threshold[i][0],
                    n[iw].auxiliary_threshold[i][1]);
        CalculateSimpleStatistics
            (np, CHARP(INW(n[iw].auxiliary_idx,CONFIG_num_auxiliary) ?
                       CONFIG_auxiliary[i] : geo[i-CONFIG_MAX_AUXILIARY]),
             sizeof(double), IOVAL_DOUBLE, &ss);
        printf("[%g(%d),%g(%d)], avg=%g, std.dev.=%g,\n",
               ss.min, ss.idx_min, ss.max, ss.idx_max,
               ss.average, ss.standard_deviation);
        printf("auxiliaries' colormap = %s \"%s\".\n",
               AX_cmap_funs[n[iw].auxiliary_cmap].name,
               AX_cmap_funs[n[iw].auxiliary_cmap].description);
        printf("invisible outside auxiliary thresholds flag = %s.\n",
               n[iw].auxiliary_thresholds_saturation?"OFF":"ON");
        printf("floating auxiliary thresholds flag = %s.\n",
               n[iw].auxiliary_thresholds_rigid?"OFF":"ON");
    }
    printf ("clicked atoms = [ ");
    for (i=0; i<ATOM_STACK_SIZE; i++) printf ("%d ", n[iw].atom_stack[i]);
    printf ("];\n");
    for (i=0; i<AX_3D_MAX_FILTER_PLANE; i++)
        if (AX_V3NEZERO(AX_3D[iw].fp[i].dx))
            printf("%s fp %d: dx = [%g %g %g], s = [%g %g %g]\n",
                   (n[iw].just_activated_fp==i) ? "*" : " ",
                   i, V3E(AX_3D[iw].fp[i].dx), V3E(n[iw].fp[i].s0));
    printf("=============================================="
           "=======================\n");
    return(FALSE);
} /* end print_status() */
コード例 #18
0
ファイル: wavplay.c プロジェクト: f32c/f32c
void
main(void)
{
	char tmpbuf[256];
	int i, f, fpos = 0, block, cur, got, vol = 0xfff;
	char *buf = (void *) 0x80080000;

	fnames = malloc(MAX_FNAMES * 256);

	tmpbuf[0] = 'd';
	tmpbuf[1] = ':';
	tmpbuf[2] = 0;
	f = open(tmpbuf, O_RDONLY);
	if (f > 0)
		close(f);
	scan_files(tmpbuf);
	lcd_init();

next_file:
	f = open(fnames[fpos], O_RDONLY);
	if (f < 0) {
		printf("Open failed\n");
		exit (1);
	}
	printf("Playing %s, vol %d\n", fnames[fpos], vol);
	lcd_pos(0, 0);
	lcd_puts(&fnames[fpos][3]);
	lcd_puts("          ");

	block = 0;
	got = read(f, buf, 0x8000);
	OUTW(IO_PCM_FIRST, buf);
	OUTW(IO_PCM_LAST, buf + 0x7ffe);
	OUTW(IO_PCM_FREQ, 9108); /* 44.1 kHz sample rate */
	OUTW(IO_PCM_VOLUME, vol + (vol << 16));

	while (got > 0) {
		INW(cur, IO_PCM_CUR);
		if ((cur & 0x4000) != block) {
			got = read(f, buf + block, 0x4000);
			block = cur & 0x4000;
			INB(i, IO_PUSHBTN);
			if ((i & BTN_UP) && vol < 0xffff)
				vol = (vol << 1) + 1;
			if ((i & BTN_DOWN) && vol > 0)
				vol = vol >> 1;
			if ((i & (BTN_UP|BTN_DOWN)))
				printf("Playing %s, vol %d\n",
				    fnames[fpos], vol);
			lcd_pos(0, 1);
			sprintf(tmpbuf, "volume %d ", vol);
			lcd_puts(tmpbuf);
			OUTW(IO_PCM_VOLUME, vol + (vol << 16));
			if ((i & BTN_LEFT)) {
				close(f);
				if (fpos == 0)
					fpos = fcnt;
				fpos--;
				goto next_file;
			}
			if ((i & BTN_RIGHT))
				break;
		}
#ifdef __mips__
		/* Wait for an interrupt, but which one? - XXX REVISIT!!! */
		__asm __volatile__("wait");
#endif
	}
コード例 #19
0
ファイル: i2ellis.c プロジェクト: Antonio-Zhou/Linux-2.6.11
//******************************************************************************
// Function:   iiReadWord16(pB)
// Parameters: pB      - pointer to board structure
//
// Returns:    True if everything appears copacetic.
//             False if there is any error: the pB->i2eError field has the error
//
// Description:
//
// Returns the word read from the data fifo specified by the board-structure
// pointer pB. Uses a 16-bit operation. Is called indirectly through
// pB->i2eReadWord.
//
//******************************************************************************
static unsigned short
iiReadWord16(i2eBordStrPtr pB)
{
	return (unsigned short)( INW(pB->i2eData) );
}
コード例 #20
0
static void
fm801_audio_trigger (int dev, int state)
{
  fm801_portc *portc = audio_engines[dev]->portc;
  fm801_devc *devc = audio_engines[dev]->devc;
  oss_native_word flags;
  MUTEX_ENTER_IRQDISABLE (devc->mutex, flags);
  if (portc->open_mode & OPEN_WRITE)
    {
      if (state & PCM_ENABLE_OUTPUT)
	{
	  if ((portc->audio_enabled & PCM_ENABLE_OUTPUT) &&
	      !(portc->trigger_bits & PCM_ENABLE_OUTPUT))
	    {
	      OUTW (devc->osdev,
		    INW (devc->osdev,
			 devc->base +
			 PLAY_CONTROL) | FM801_START | FM801_IMMED_STOP,
		    devc->base + PLAY_CONTROL);
	      portc->trigger_bits |= PCM_ENABLE_OUTPUT;
	    }
	}
      else
	{
	  if ((portc->audio_enabled & PCM_ENABLE_OUTPUT) &&
	      (portc->trigger_bits & PCM_ENABLE_OUTPUT))
	    {
	      portc->audio_enabled &= ~PCM_ENABLE_OUTPUT;
	      portc->trigger_bits &= ~PCM_ENABLE_OUTPUT;
	      OUTW (devc->osdev,
		    (INW (devc->osdev, devc->base + PLAY_CONTROL) &
		     (~FM801_START | FM801_IMMED_STOP)) | (FM801_BUF1_LAST |
							   FM801_BUF2_LAST),
		    devc->base + PLAY_CONTROL);
	    }
	}
    }
  if (portc->open_mode & OPEN_READ)
    {
      if (state & PCM_ENABLE_INPUT)
	{
	  if ((portc->audio_enabled & PCM_ENABLE_INPUT) &&
	      !(portc->trigger_bits & PCM_ENABLE_INPUT))
	    {
	      OUTW (devc->osdev, INW (devc->osdev, devc->base + REC_CONTROL) |
		    FM801_START | FM801_IMMED_STOP, devc->base + REC_CONTROL);
	      portc->trigger_bits |= PCM_ENABLE_INPUT;
	    }
	}
      else
	{
	  if ((portc->audio_enabled & PCM_ENABLE_INPUT) &&
	      (portc->trigger_bits & PCM_ENABLE_INPUT))
	    {
	      portc->audio_enabled &= ~PCM_ENABLE_INPUT;
	      portc->trigger_bits &= ~PCM_ENABLE_INPUT;
	      OUTW (devc->osdev,
		    (INW (devc->osdev, devc->base + REC_CONTROL) &
		     (~FM801_START | FM801_IMMED_STOP)) | (FM801_BUF1_LAST |
							   FM801_BUF2_LAST),
		    devc->base + REC_CONTROL);
	    }
	}
    }
  MUTEX_EXIT_IRQRESTORE (devc->mutex, flags);
}
コード例 #21
0
ファイル: ax88180.c プロジェクト: 0xFelix/u-boot-edminiv2
static void ax88180_rx_handler (struct eth_device *dev)
{
	struct ax88180_private *priv = (struct ax88180_private *)dev->priv;
	unsigned long data_size;
	unsigned short rxcurt_ptr, rxbound_ptr, next_ptr;
	int i;
#if defined (CONFIG_DRIVER_AX88180_16BIT)
	unsigned short *rxdata = (unsigned short *)net_rx_packets[0];
#else
	unsigned long *rxdata = (unsigned long *)net_rx_packets[0];
#endif
	unsigned short count;

	rxcurt_ptr = INW (dev, RXCURT);
	rxbound_ptr = INW (dev, RXBOUND);
	next_ptr = (rxbound_ptr + 1) & RX_PAGE_NUM_MASK;

	debug ("ax88180: RX original RXBOUND=0x%04x,"
	       " RXCURT=0x%04x\n", rxbound_ptr, rxcurt_ptr);

	while (next_ptr != rxcurt_ptr) {

		OUTW (dev, RX_START_READ, RXINDICATOR);

		data_size = READ_RXBUF (dev) & 0xFFFF;

		if ((data_size == 0) || (data_size > MAX_RX_SIZE)) {

			OUTW (dev, RX_STOP_READ, RXINDICATOR);

			ax88180_mac_reset (dev);
			printf ("ax88180: Invalid Rx packet length!"
				" (len=0x%04lx)\n", data_size);

			debug ("ax88180: RX RXBOUND=0x%04x,"
			       "RXCURT=0x%04x\n", rxbound_ptr, rxcurt_ptr);
			return;
		}

		rxbound_ptr += (((data_size + 0xF) & 0xFFF0) >> 4) + 1;
		rxbound_ptr &= RX_PAGE_NUM_MASK;

		/* Comput access times */
		count = (data_size + priv->PadSize) >> priv->BusWidth;

		for (i = 0; i < count; i++) {
			*(rxdata + i) = READ_RXBUF (dev);
		}

		OUTW (dev, RX_STOP_READ, RXINDICATOR);

		/* Pass the packet up to the protocol layers. */
		net_process_received_packet(net_rx_packets[0], data_size);

		OUTW (dev, rxbound_ptr, RXBOUND);

		rxcurt_ptr = INW (dev, RXCURT);
		rxbound_ptr = INW (dev, RXBOUND);
		next_ptr = (rxbound_ptr + 1) & RX_PAGE_NUM_MASK;

		debug ("ax88180: RX updated RXBOUND=0x%04x,"
		       "RXCURT=0x%04x\n", rxbound_ptr, rxcurt_ptr);
	}

	return;
}