Commit c2353a08 authored by Clemens Ladisch's avatar Clemens Ladisch Committed by Jaroslav Kysela

[ALSA] oxygen: add register definitions

Add more symbols for registers and register fields.
Signed-off-by: default avatarClemens Ladisch <clemens@ladisch.de>
Signed-off-by: default avatarJaroslav Kysela <perex@perex.cz>
parent 4052ce4c
......@@ -102,18 +102,21 @@ static void ak4396_write(struct oxygen *chip, unsigned int codec,
static const u8 codec_spi_map[4] = {
0, 1, 2, 4
};
oxygen_write_spi(chip, OXYGEN_SPI_TRIGGER_WRITE |
oxygen_write_spi(chip, OXYGEN_SPI_TRIGGER |
OXYGEN_SPI_DATA_LENGTH_2 |
OXYGEN_SPI_CLOCK_160 |
(codec_spi_map[codec] << OXYGEN_SPI_CODEC_SHIFT) |
OXYGEN_SPI_MAGIC,
OXYGEN_SPI_CEN_LATCH_CLOCK_HI,
AK4396_WRITE | (reg << 8) | value);
}
static void wm8785_write(struct oxygen *chip, u8 reg, unsigned int value)
{
oxygen_write_spi(chip, OXYGEN_SPI_TRIGGER_WRITE |
oxygen_write_spi(chip, OXYGEN_SPI_TRIGGER |
OXYGEN_SPI_DATA_LENGTH_2 |
(3 << OXYGEN_SPI_CODEC_SHIFT),
OXYGEN_SPI_CLOCK_160 |
(3 << OXYGEN_SPI_CODEC_SHIFT) |
OXYGEN_SPI_CEN_LATCH_CLOCK_LO,
(reg << 9) | value);
}
......
......@@ -119,7 +119,7 @@ void oxygen_write_ac97(struct oxygen *chip, unsigned int codec,
udelay(5);
oxygen_write32(chip, OXYGEN_AC97_REGS, reg);
/* require two "completed" writes, just to be sure */
if (oxygen_ac97_wait(chip, OXYGEN_AC97_WRITE_COMPLETE) >= 0 &&
if (oxygen_ac97_wait(chip, OXYGEN_AC97_INT_WRITE_DONE) >= 0 &&
++succeeded >= 2)
return;
}
......@@ -141,7 +141,7 @@ u16 oxygen_read_ac97(struct oxygen *chip, unsigned int codec,
udelay(5);
oxygen_write32(chip, OXYGEN_AC97_REGS, reg);
udelay(10);
if (oxygen_ac97_wait(chip, OXYGEN_AC97_READ_COMPLETE) >= 0) {
if (oxygen_ac97_wait(chip, OXYGEN_AC97_INT_READ_DONE) >= 0) {
u16 value = oxygen_read16(chip, OXYGEN_AC97_REGS);
/* we require two consecutive reads of the same value */
if (value == last_read)
......
......@@ -51,11 +51,11 @@ static irqreturn_t oxygen_interrupt(int dummy, void *dev_id)
OXYGEN_CHANNEL_SPDIF |
OXYGEN_CHANNEL_MULTICH |
OXYGEN_CHANNEL_AC97 |
OXYGEN_INT_SPDIF_IN_CHANGE |
OXYGEN_INT_SPDIF_IN_DETECT |
OXYGEN_INT_GPIO);
if (clear) {
if (clear & OXYGEN_INT_SPDIF_IN_CHANGE)
chip->interrupt_mask &= ~OXYGEN_INT_SPDIF_IN_CHANGE;
if (clear & OXYGEN_INT_SPDIF_IN_DETECT)
chip->interrupt_mask &= ~OXYGEN_INT_SPDIF_IN_DETECT;
oxygen_write16(chip, OXYGEN_INTERRUPT_MASK,
chip->interrupt_mask & ~clear);
oxygen_write16(chip, OXYGEN_INTERRUPT_MASK,
......@@ -70,10 +70,10 @@ static irqreturn_t oxygen_interrupt(int dummy, void *dev_id)
if ((elapsed_streams & (1 << i)) && chip->streams[i])
snd_pcm_period_elapsed(chip->streams[i]);
if (status & OXYGEN_INT_SPDIF_IN_CHANGE) {
if (status & OXYGEN_INT_SPDIF_IN_DETECT) {
spin_lock(&chip->reg_lock);
i = oxygen_read32(chip, OXYGEN_SPDIF_CONTROL);
if (i & OXYGEN_SPDIF_IN_CHANGE) {
if (i & OXYGEN_SPDIF_RATE_INT) {
oxygen_write32(chip, OXYGEN_SPDIF_CONTROL, i);
schedule_work(&chip->spdif_input_bits_work);
}
......@@ -95,28 +95,32 @@ static void oxygen_spdif_input_bits_changed(struct work_struct *work)
spdif_input_bits_work);
spin_lock_irq(&chip->reg_lock);
oxygen_clear_bits32(chip, OXYGEN_SPDIF_CONTROL, OXYGEN_SPDIF_IN_INVERT);
oxygen_write32_masked(chip, OXYGEN_SPDIF_CONTROL,
OXYGEN_SPDIF_IN_CLOCK_96,
OXYGEN_SPDIF_IN_CLOCK_MASK);
spin_unlock_irq(&chip->reg_lock);
msleep(1);
if (!(oxygen_read32(chip, OXYGEN_SPDIF_CONTROL)
& OXYGEN_SPDIF_IN_VALID)) {
& OXYGEN_SPDIF_LOCK_STATUS)) {
spin_lock_irq(&chip->reg_lock);
oxygen_set_bits32(chip, OXYGEN_SPDIF_CONTROL,
OXYGEN_SPDIF_IN_INVERT);
oxygen_write32_masked(chip, OXYGEN_SPDIF_CONTROL,
OXYGEN_SPDIF_IN_CLOCK_192,
OXYGEN_SPDIF_IN_CLOCK_MASK);
spin_unlock_irq(&chip->reg_lock);
msleep(1);
if (!(oxygen_read32(chip, OXYGEN_SPDIF_CONTROL)
& OXYGEN_SPDIF_IN_VALID)) {
& OXYGEN_SPDIF_LOCK_STATUS)) {
spin_lock_irq(&chip->reg_lock);
oxygen_clear_bits32(chip, OXYGEN_SPDIF_CONTROL,
OXYGEN_SPDIF_IN_INVERT);
oxygen_write32_masked(chip, OXYGEN_SPDIF_CONTROL,
OXYGEN_SPDIF_IN_CLOCK_96,
OXYGEN_SPDIF_IN_CLOCK_MASK);
spin_unlock_irq(&chip->reg_lock);
}
}
if (chip->controls[CONTROL_SPDIF_INPUT_BITS]) {
spin_lock_irq(&chip->reg_lock);
chip->interrupt_mask |= OXYGEN_INT_SPDIF_IN_CHANGE;
chip->interrupt_mask |= OXYGEN_INT_SPDIF_IN_DETECT;
oxygen_write16(chip, OXYGEN_INTERRUPT_MASK,
chip->interrupt_mask);
spin_unlock_irq(&chip->reg_lock);
......@@ -194,7 +198,8 @@ static void __devinit oxygen_init(struct oxygen *chip)
chip->revision = 1;
if (chip->revision == 1)
oxygen_set_bits8(chip, OXYGEN_MISC, OXYGEN_MISC_MAGIC);
oxygen_set_bits8(chip, OXYGEN_MISC,
OXYGEN_MISC_PCI_MEM_W_1_CLOCK);
i = oxygen_read16(chip, OXYGEN_AC97_CONTROL);
chip->has_ac97_0 = (i & OXYGEN_AC97_CODEC_0) != 0;
......@@ -207,7 +212,7 @@ static void __devinit oxygen_init(struct oxygen *chip)
oxygen_write16(chip, OXYGEN_I2S_A_FORMAT, 0x010a);
oxygen_write16(chip, OXYGEN_I2S_B_FORMAT, 0x010a);
oxygen_write16(chip, OXYGEN_I2S_C_FORMAT, 0x010a);
oxygen_set_bits32(chip, OXYGEN_SPDIF_CONTROL, OXYGEN_SPDIF_MAGIC2);
oxygen_set_bits32(chip, OXYGEN_SPDIF_CONTROL, OXYGEN_SPDIF_RATE_MASK);
oxygen_write32(chip, OXYGEN_SPDIF_OUTPUT_BITS, chip->spdif_bits);
oxygen_write16(chip, OXYGEN_PLAY_ROUTING, 0xe100);
oxygen_write8(chip, OXYGEN_REC_ROUTING, 0x10);
......@@ -220,9 +225,17 @@ static void __devinit oxygen_init(struct oxygen *chip)
oxygen_write8(chip, OXYGEN_AC97_INTERRUPT_MASK, 0x00);
if (chip->has_ac97_0) {
oxygen_clear_bits16(chip, OXYGEN_AC97_OUT_CONFIG,
OXYGEN_AC97_OUT_MAGIC3);
OXYGEN_AC97_CODEC0_FRONTL |
OXYGEN_AC97_CODEC0_FRONTR |
OXYGEN_AC97_CODEC0_SIDEL |
OXYGEN_AC97_CODEC0_SIDER |
OXYGEN_AC97_CODEC0_CENTER |
OXYGEN_AC97_CODEC0_BASE |
OXYGEN_AC97_CODEC0_REARL |
OXYGEN_AC97_CODEC0_REARR);
oxygen_set_bits16(chip, OXYGEN_AC97_IN_CONFIG,
OXYGEN_AC97_IN_MAGIC3);
OXYGEN_AC97_CODEC0_LINEL |
OXYGEN_AC97_CODEC0_LINER);
oxygen_write_ac97(chip, 0, AC97_RESET, 0);
msleep(1);
oxygen_ac97_set_bits(chip, 0, 0x70, 0x0300);
......@@ -349,7 +362,7 @@ int __devinit oxygen_pci_probe(struct pci_dev *pci, int index, char *id,
oxygen_proc_init(chip);
spin_lock_irq(&chip->reg_lock);
chip->interrupt_mask |= OXYGEN_INT_SPDIF_IN_CHANGE;
chip->interrupt_mask |= OXYGEN_INT_SPDIF_IN_DETECT;
oxygen_write16(chip, OXYGEN_INTERRUPT_MASK, chip->interrupt_mask);
spin_unlock_irq(&chip->reg_lock);
......
......@@ -308,9 +308,10 @@ static unsigned int oxygen_rate(struct snd_pcm_hw_params *hw_params)
}
}
static unsigned int oxygen_i2s_magic2(struct snd_pcm_hw_params *hw_params)
static unsigned int oxygen_i2s_mclk(struct snd_pcm_hw_params *hw_params)
{
return params_rate(hw_params) <= 96000 ? 0x10 : 0x00;
return params_rate(hw_params) <= 96000
? OXYGEN_I2S_MCLK_256 : OXYGEN_I2S_MCLK_128;
}
static unsigned int oxygen_i2s_bits(struct snd_pcm_hw_params *hw_params)
......@@ -388,12 +389,12 @@ static int oxygen_rec_a_hw_params(struct snd_pcm_substream *substream,
OXYGEN_REC_FORMAT_A_MASK);
oxygen_write16_masked(chip, OXYGEN_I2S_A_FORMAT,
oxygen_rate(hw_params) |
oxygen_i2s_magic2(hw_params) |
oxygen_i2s_mclk(hw_params) |
chip->model->adc_i2s_format |
oxygen_i2s_bits(hw_params),
OXYGEN_I2S_RATE_MASK |
OXYGEN_I2S_FORMAT_MASK |
OXYGEN_I2S_MAGIC2_MASK |
OXYGEN_I2S_MCLK_MASK |
OXYGEN_I2S_BITS_MASK);
oxygen_clear_bits8(chip, OXYGEN_REC_ROUTING, 0x08);
spin_unlock_irq(&chip->reg_lock);
......@@ -420,12 +421,12 @@ static int oxygen_rec_b_hw_params(struct snd_pcm_substream *substream,
OXYGEN_REC_FORMAT_B_MASK);
oxygen_write16_masked(chip, OXYGEN_I2S_B_FORMAT,
oxygen_rate(hw_params) |
oxygen_i2s_magic2(hw_params) |
oxygen_i2s_mclk(hw_params) |
chip->model->adc_i2s_format |
oxygen_i2s_bits(hw_params),
OXYGEN_I2S_RATE_MASK |
OXYGEN_I2S_FORMAT_MASK |
OXYGEN_I2S_MAGIC2_MASK |
OXYGEN_I2S_MCLK_MASK |
OXYGEN_I2S_BITS_MASK);
oxygen_clear_bits8(chip, OXYGEN_REC_ROUTING, 0x10);
spin_unlock_irq(&chip->reg_lock);
......@@ -514,24 +515,6 @@ static int oxygen_multich_hw_params(struct snd_pcm_substream *substream,
return 0;
}
static int oxygen_ac97_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *hw_params)
{
struct oxygen *chip = snd_pcm_substream_chip(substream);
int err;
err = oxygen_hw_params(substream, hw_params);
if (err < 0)
return err;
spin_lock_irq(&chip->reg_lock);
oxygen_write8_masked(chip, OXYGEN_PLAY_FORMAT,
oxygen_format(hw_params) << OXYGEN_AC97_FORMAT_SHIFT,
OXYGEN_AC97_FORMAT_MASK);
spin_unlock_irq(&chip->reg_lock);
return 0;
}
static int oxygen_hw_free(struct snd_pcm_substream *substream)
{
struct oxygen *chip = snd_pcm_substream_chip(substream);
......@@ -680,7 +663,7 @@ static struct snd_pcm_ops oxygen_ac97_ops = {
.open = oxygen_ac97_open,
.close = oxygen_close,
.ioctl = snd_pcm_lib_ioctl,
.hw_params = oxygen_ac97_hw_params,
.hw_params = oxygen_hw_params,
.hw_free = oxygen_hw_free,
.prepare = oxygen_prepare,
.trigger = oxygen_trigger,
......
This diff is collapsed.
......@@ -80,10 +80,11 @@ static void pcm1796_write(struct oxygen *chip, unsigned int codec,
static const u8 codec_map[4] = {
0, 1, 2, 4
};
oxygen_write_spi(chip, OXYGEN_SPI_TRIGGER_WRITE |
oxygen_write_spi(chip, OXYGEN_SPI_TRIGGER |
OXYGEN_SPI_DATA_LENGTH_2 |
OXYGEN_SPI_CLOCK_160 |
(codec_map[codec] << OXYGEN_SPI_CODEC_SHIFT) |
OXYGEN_SPI_MAGIC,
OXYGEN_SPI_CEN_LATCH_CLOCK_HI,
(reg << 8) | value);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment