Example #1
0
rtems_device_driver ac97_open(
   rtems_device_major_number major,
   rtems_device_minor_number minor,
   void *arg
)
{
  int codec_id;
  
  if (minor == 0) {
    /* snd */
    return RTEMS_SUCCESSFUL;
  } else {
    /* mixer */
    codec_id = read_cr(0x00);
    if ((codec_id != 0x0d50) && (codec_id != 0x6150)) {
      printk("AC97 codec detection failed\n");
      return RTEMS_UNSATISFIED;
    }
    write_cr(0x02, 0x0000); /* master volume */
    write_cr(0x04, 0x0f0f); /* headphones volume */
    write_cr(0x18, 0x0000); /* PCM out volume */
    write_cr(0x1c, 0x0f0f); /* record gain */

    write_cr(0x1a, 0x0505); /* record select: stereo mix */

    return RTEMS_SUCCESSFUL;
  }
}
Example #2
0
static rtems_status_code ioctl_read_channel(void *buf,
  unsigned int chan, int mono)
{
  unsigned int *val = (unsigned int *)buf;
  int mic_boost;
  int codec;
  int left, right;

  codec = read_cr(chan);
  if (codec < 0)
    return RTEMS_UNSATISFIED;
  if (codec & 0x8000) {
    /* muted */
    *val = 0;
    return RTEMS_SUCCESSFUL;
  }
  if (mono) {
    left = 100-(((codec & 0x1f) + 1)*100)/32;
    mic_boost = (codec & (1 << 6)) >> 6;
    *val = left | mic_boost << 8;
  } else {
Example #3
0
static int spansion_quad_enable(struct spi_nor *nor)
{
	int ret;
	int quad_en = CR_QUAD_EN_SPAN << 8;

	write_enable(nor);

	ret = write_sr_cr(nor, quad_en);
	if (ret < 0) {
		dev_err(nor->dev,
			"error while writing configuration register\n");
		return -EINVAL;
	}

	/* read back and check it */
	ret = read_cr(nor);
	if (!(ret > 0 && (ret & CR_QUAD_EN_SPAN))) {
		dev_err(nor->dev, "Spansion Quad bit not set\n");
		return -EINVAL;
	}

	return 0;
}