Skip to content

Commit 77d531b

Browse files
committed
Merge branch 'xonar-dg' of git://git.alsa-project.org/alsa-kprivate into for-next
This completes the hardware support for the Asus Xonar DG/DGX cards, and makes them actually usable. This is v4 of Roman's patch set with some small formatting changes.
2 parents cd26251 + 3f49a66 commit 77d531b

File tree

9 files changed

+713
-501
lines changed

9 files changed

+713
-501
lines changed

sound/pci/oxygen/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
snd-oxygen-lib-objs := oxygen_io.o oxygen_lib.o oxygen_mixer.o oxygen_pcm.o
2-
snd-oxygen-objs := oxygen.o xonar_dg.o
2+
snd-oxygen-objs := oxygen.o xonar_dg_mixer.o xonar_dg.o
33
snd-virtuoso-objs := virtuoso.o xonar_lib.o \
44
xonar_pcm179x.o xonar_cs43xx.o xonar_wm87x6.o xonar_hdmi.o
55

sound/pci/oxygen/cs4245.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@
102102
#define CS4245_ADC_OVFL 0x02
103103
#define CS4245_ADC_UNDRFL 0x01
104104

105+
#define CS4245_SPI_ADDRESS_S (0x9e << 16)
106+
#define CS4245_SPI_WRITE_S (0 << 16)
105107

106-
#define CS4245_SPI_ADDRESS (0x9e << 16)
107-
#define CS4245_SPI_WRITE (0 << 16)
108+
#define CS4245_SPI_ADDRESS 0x9e
109+
#define CS4245_SPI_WRITE 0
110+
#define CS4245_SPI_READ 1

sound/pci/oxygen/oxygen.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ void oxygen_write_ac97(struct oxygen *chip, unsigned int codec,
198198
void oxygen_write_ac97_masked(struct oxygen *chip, unsigned int codec,
199199
unsigned int index, u16 data, u16 mask);
200200

201-
void oxygen_write_spi(struct oxygen *chip, u8 control, unsigned int data);
201+
int oxygen_write_spi(struct oxygen *chip, u8 control, unsigned int data);
202202
void oxygen_write_i2c(struct oxygen *chip, u8 device, u8 map, u8 data);
203203

204204
void oxygen_reset_uart(struct oxygen *chip);

sound/pci/oxygen/oxygen_io.c

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -194,23 +194,36 @@ void oxygen_write_ac97_masked(struct oxygen *chip, unsigned int codec,
194194
}
195195
EXPORT_SYMBOL(oxygen_write_ac97_masked);
196196

197-
void oxygen_write_spi(struct oxygen *chip, u8 control, unsigned int data)
197+
static int oxygen_wait_spi(struct oxygen *chip)
198198
{
199199
unsigned int count;
200200

201-
/* should not need more than 30.72 us (24 * 1.28 us) */
202-
count = 10;
203-
while ((oxygen_read8(chip, OXYGEN_SPI_CONTROL) & OXYGEN_SPI_BUSY)
204-
&& count > 0) {
201+
/*
202+
* Higher timeout to be sure: 200 us;
203+
* actual transaction should not need more than 40 us.
204+
*/
205+
for (count = 50; count > 0; count--) {
205206
udelay(4);
206-
--count;
207+
if ((oxygen_read8(chip, OXYGEN_SPI_CONTROL) &
208+
OXYGEN_SPI_BUSY) == 0)
209+
return 0;
207210
}
211+
snd_printk(KERN_ERR "oxygen: SPI wait timeout\n");
212+
return -EIO;
213+
}
208214

215+
int oxygen_write_spi(struct oxygen *chip, u8 control, unsigned int data)
216+
{
217+
/*
218+
* We need to wait AFTER initiating the SPI transaction,
219+
* otherwise read operations will not work.
220+
*/
209221
oxygen_write8(chip, OXYGEN_SPI_DATA1, data);
210222
oxygen_write8(chip, OXYGEN_SPI_DATA2, data >> 8);
211223
if (control & OXYGEN_SPI_DATA_LENGTH_3)
212224
oxygen_write8(chip, OXYGEN_SPI_DATA3, data >> 16);
213225
oxygen_write8(chip, OXYGEN_SPI_CONTROL, control);
226+
return oxygen_wait_spi(chip);
214227
}
215228
EXPORT_SYMBOL(oxygen_write_spi);
216229

sound/pci/oxygen/oxygen_mixer.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ void oxygen_update_dac_routing(struct oxygen *chip)
190190
if (chip->model.update_center_lfe_mix)
191191
chip->model.update_center_lfe_mix(chip, chip->dac_routing > 2);
192192
}
193+
EXPORT_SYMBOL(oxygen_update_dac_routing);
193194

194195
static int upmix_put(struct snd_kcontrol *ctl, struct snd_ctl_elem_value *value)
195196
{

sound/pci/oxygen/oxygen_regs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@
318318
#define OXYGEN_PLAY_MUTE23 0x0002
319319
#define OXYGEN_PLAY_MUTE45 0x0004
320320
#define OXYGEN_PLAY_MUTE67 0x0008
321+
#define OXYGEN_PLAY_MUTE_MASK 0x000f
321322
#define OXYGEN_PLAY_MULTICH_MASK 0x0010
322323
#define OXYGEN_PLAY_MULTICH_I2S_DAC 0x0000
323324
#define OXYGEN_PLAY_MULTICH_AC97 0x0010

0 commit comments

Comments
 (0)