Skip to contentSkip to conversation

ALSA: emu10k1: improvements related to the switchable word clock of E-MU cards

PATCH Applied Oswald Buddenhagen 2 participants 11 messages Jun 12, 2023 – Jun 13, 2023 Sound

lore
Share & tools
lore
#0 lore raw

cover ALSA: emu10k1: improvements related to the switchable word clock of E-MU cards

Oswald Buddenhagen (9):
ALSA: emu10k1: split off E-MU fallback clock from clock source
ALSA: emu10k1: make available E-MU clock sources card-specific
ALSA: emu10k1: query rate of external clock sources on E-MU cards
ALSA: emu10k1: fix sample rates for E-MU cards at 44.1 kHz word clock
ALSA: emu10k1: fix synthesizer pitch for E-MU cards at 44.1 kHz
ALSA: timer: minimize open-coded access to hw.resolution
ALSA: emu10k1: fix timer for E-MU cards at 44.1 kHz word clock
ALSA: emu10k1: add support for 12 kHz capture on Audigy
ALSA: emu10k1: actually show some S/PDIF status in /proc for E-MU
cards

 include/sound/emu10k1.h              |  11 +-
 include/sound/emux_synth.h           |   2 +-
 sound/core/timer.c                   |  18 +-
 sound/pci/emu10k1/emu10k1_callback.c |  10 ++
 sound/pci/emu10k1/emu10k1_main.c     |   7 +-
 sound/pci/emu10k1/emu10k1_synth.c    |   1 -
 sound/pci/emu10k1/emumixer.c         | 242 ++++++++++++++++-----------
 sound/pci/emu10k1/emupcm.c           | 125 +++++++-------
 sound/pci/emu10k1/emuproc.c          |  51 +++---
 sound/pci/emu10k1/io.c               |  72 ++++++++
 sound/pci/emu10k1/timer.c            |  20 ++-
 sound/synth/emux/emux_synth.c        |   3 +-
 12 files changed, 374 insertions(+), 188 deletions(-)
Signature · 1 line
2.40.0.152.g15d061e6df
#1 lore raw

PATCH 1/9 ALSA: emu10k1: split off E-MU fallback clock from clock source

So far, we set the fallback as a side effect of setting the source. But the fallback makes no sense at all when an internal clock is selected. Defaulting to 48k for S/PDIF & ADAT makes sense, but as that is the global default and we're not changing it automatically any more, it's just fine to leave it entirely to the explicit setting.

This changes the name of the pre-existing control to something more appropriate (regardless of the split), so users will need to adjust their mixer settings.

---
 include/sound/emu10k1.h          |  3 +-
 sound/pci/emu10k1/emu10k1_main.c |  3 +-
 sound/pci/emu10k1/emumixer.c     | 89 +++++++++++++++++++++++---------
 sound/pci/emu10k1/emupcm.c       |  4 +-
 4 files changed, 72 insertions(+), 27 deletions(-)
include/sound/emu10k1.h +2 -1
index cc0151e7c828..59e79ea1f75e 100644
@@ -1668,7 +1668,8 @@ struct snd_emu1010 {
 	unsigned char input_source[NUM_INPUT_DESTS];
 	unsigned int adc_pads; /* bit mask */
 	unsigned int dac_pads; /* bit mask */
-	unsigned int internal_clock; /* 44100 or 48000 */
+	unsigned int clock_source;
+	unsigned int clock_fallback;
 	unsigned int optical_in; /* 0:SPDIF, 1:ADAT */
 	unsigned int optical_out; /* 0:SPDIF, 1:ADAT */
 	struct delayed_work firmware_work;
sound/pci/emu10k1/emu10k1_main.c +2 -1
index 65207ef689cb..2aa11d70e285 100644
@@ -900,7 +900,8 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 *emu)
 	/* IRQ Enable: All off */
 	snd_emu1010_fpga_write(emu, EMU_HANA_IRQ_ENABLE, 0x00);
 
-	emu->emu1010.internal_clock = 1; /* 48000 */
+	emu->emu1010.clock_source = 1;  /* 48000 */
+	emu->emu1010.clock_fallback = 1;  /* 48000 */
 	/* Default WCLK set to 48kHz. */
 	snd_emu1010_fpga_write(emu, EMU_HANA_DEFCLOCK, EMU_HANA_DEFCLOCK_48K);
 	/* Word Clock source, Internal 48kHz x1 */
sound/pci/emu10k1/emumixer.c +66 -23

158 lines not on this page · raw message

sound/pci/emu10k1/emupcm.c +2 -2
index 550caefa0ce4..fab537788587 100644
@@ -1185,7 +1185,7 @@ static int snd_emu10k1_playback_open(struct snd_pcm_substream *substream)
 		kfree(epcm);
 		return err;
 	}
-	if (emu->card_capabilities->emu_model && emu->emu1010.internal_clock == 0)
+	if (emu->card_capabilities->emu_model && emu->emu1010.clock_source == 0)
 		sample_rate = 44100;
 	else
 		sample_rate = 48000;
@@ -1335,7 +1335,7 @@ static int snd_emu10k1_capture_efx_open(struct snd_pcm_substream *substream)
 		 * but we don't exceed 16 channels anyway.
 		 */
 #if 1
-		switch (emu->emu1010.internal_clock) {
+		switch (emu->emu1010.clock_source) {
 		case 0:
 			/* For 44.1kHz */
 			runtime->hw.rates = SNDRV_PCM_RATE_44100;
Signature · 1 line
2.40.0.152.g15d061e6df
#2 lore raw

PATCH 2/9 ALSA: emu10k1: make available E-MU clock sources card-specific

In reply to Oswald Buddenhagen

The actually available clock sources depend on the available audio input ports and dedicated clock input ports.

This includes refactoring the code to be data-driven to remain manageable.

---
 include/sound/emu10k1.h          |   2 +
 sound/pci/emu10k1/emu10k1_main.c |   4 +-
 sound/pci/emu10k1/emumixer.c     | 153 ++++++++++++++++---------------
 sound/pci/emu10k1/io.c           |  23 +++++
 4 files changed, 107 insertions(+), 75 deletions(-)
include/sound/emu10k1.h +2 -0
index 59e79ea1f75e..703ef441bb2a 100644
@@ -1668,6 +1668,7 @@ struct snd_emu1010 {
 	unsigned char input_source[NUM_INPUT_DESTS];
 	unsigned int adc_pads; /* bit mask */
 	unsigned int dac_pads; /* bit mask */
+	unsigned int wclock;  /* Cached register value */
 	unsigned int clock_source;
 	unsigned int clock_fallback;
 	unsigned int optical_in; /* 0:SPDIF, 1:ADAT */
@@ -1824,6 +1825,7 @@ void snd_emu1010_fpga_write(struct snd_emu10k1 *emu, u32 reg, u32 value);
 void snd_emu1010_fpga_read(struct snd_emu10k1 *emu, u32 reg, u32 *value);
 void snd_emu1010_fpga_link_dst_src_write(struct snd_emu10k1 *emu, u32 dst, u32 src);
 u32 snd_emu1010_fpga_link_dst_src_read(struct snd_emu10k1 *emu, u32 dst);
+void snd_emu1010_update_clock(struct snd_emu10k1 *emu);
 unsigned int snd_emu10k1_efx_read(struct snd_emu10k1 *emu, unsigned int pc);
 void snd_emu10k1_intr_enable(struct snd_emu10k1 *emu, unsigned int intrenb);
 void snd_emu10k1_intr_disable(struct snd_emu10k1 *emu, unsigned int intrenb);
sound/pci/emu10k1/emu10k1_main.c +2 -2
index 2aa11d70e285..58ed72de6403 100644
@@ -905,10 +905,10 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 *emu)
 	/* Default WCLK set to 48kHz. */
 	snd_emu1010_fpga_write(emu, EMU_HANA_DEFCLOCK, EMU_HANA_DEFCLOCK_48K);
 	/* Word Clock source, Internal 48kHz x1 */
+	emu->emu1010.wclock = EMU_HANA_WCLOCK_INT_48K;
 	snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK, EMU_HANA_WCLOCK_INT_48K);
 	/* snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK, EMU_HANA_WCLOCK_INT_48K | EMU_HANA_WCLOCK_4X); */
-	/* Audio Dock LEDs. */
-	snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_LEDS_2, EMU_HANA_DOCK_LEDS_2_LOCK | EMU_HANA_DOCK_LEDS_2_48K);
+	snd_emu1010_update_clock(emu);
 
 	// The routes are all set to EMU_SRC_SILENCE due to the reset,
 	// so it is safe to simply enable the outputs.
sound/pci/emu10k1/emumixer.c +80 -73

179 lines not on this page · raw message

sound/pci/emu10k1/io.c +23 -0
index abe69ae40499..e7a44443023a 100644
@@ -357,6 +357,29 @@ u32 snd_emu1010_fpga_link_dst_src_read(struct snd_emu10k1 *emu, u32 dst)
 	return (hi << 8) | lo;
 }
 
+void snd_emu1010_update_clock(struct snd_emu10k1 *emu)
+{
+	u32 leds;
+
+	switch (emu->emu1010.wclock) {
+	case EMU_HANA_WCLOCK_INT_44_1K | EMU_HANA_WCLOCK_1X:
+		leds = EMU_HANA_DOCK_LEDS_2_44K;
+		break;
+	case EMU_HANA_WCLOCK_INT_48K | EMU_HANA_WCLOCK_1X:
+		leds = EMU_HANA_DOCK_LEDS_2_48K;
+		break;
+	default:
+		leds = EMU_HANA_DOCK_LEDS_2_EXT;
+		break;
+	}
+
+	// FIXME: this should probably represent the AND of all currently
+	// used sources' lock status. But we don't know how to get that ...
+	leds |= EMU_HANA_DOCK_LEDS_2_LOCK;
+
+	snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_LEDS_2, leds);
+}
+
 void snd_emu10k1_intr_enable(struct snd_emu10k1 *emu, unsigned int intrenb)
 {
 	unsigned long flags;
Signature · 1 line
2.40.0.152.g15d061e6df
#3 lore raw

PATCH 3/9 ALSA: emu10k1: query rate of external clock sources on E-MU cards

In reply to Oswald Buddenhagen

The value isn't used yet; the subsequent commits will do that.

This ignores the existence of rates above 48 kHz, which is fine, as the hardware will just switch to the fallback clock source when fed with a rate which is incompatible with the base clock multiplier, which currently is always x1.

The sample rate display in /proc spdif-in is adjusted to reflect our understanding of the input rates.

This is tested only with an 0404b card without sync card, so there is a lot of room for improvement.

---

FIXME: needs a lot of testing to figure out things for real: 0404, 1010, 1010b, and 1616 hardware, with adat, s/pdif on 1010 and dock, and bnc sync. what are the lock status and the displayed rates with no signal, good signal async to internal clock, and synced signal? test s/pdif at least with 48 & 96 khz (192 works on 1010b & 1616m cards on the RCA port).

---
 include/sound/emu10k1.h     |  5 ++++
 sound/pci/emu10k1/emuproc.c | 43 ++++++++++++++++---------------
 sound/pci/emu10k1/io.c      | 51 ++++++++++++++++++++++++++++++++++++-
 3 files changed, 78 insertions(+), 21 deletions(-)
include/sound/emu10k1.h +5 -0
index 703ef441bb2a..d64cf1697586 100644
@@ -1110,6 +1110,9 @@ SUB_REG_NC(A_EHC, A_I2S_CAPTURE_RATE, 0x00000e00)  /* This sets the capture PCM
 #define EMU_DOCK_BOARD_ID0		0x00	/* ID bit 0 */
 #define EMU_DOCK_BOARD_ID1		0x03	/* ID bit 1 */
 
+// The actual code disagrees about the bit width of the registers -
+// the formula used is freq = 0x1770000 / (((X_HI << 5) | X_LO) + 1)
+
 #define EMU_HANA_WC_SPDIF_HI	0x28	/* 0xxxxxx  6 bit  SPDIF IN Word clock, upper 6 bits */
 #define EMU_HANA_WC_SPDIF_LO	0x29	/* 0xxxxxx  6 bit  SPDIF IN Word clock, lower 6 bits */
 
@@ -1669,6 +1672,7 @@ struct snd_emu1010 {
 	unsigned int adc_pads; /* bit mask */
 	unsigned int dac_pads; /* bit mask */
 	unsigned int wclock;  /* Cached register value */
+	unsigned int word_clock;  /* Cached effective value */
 	unsigned int clock_source;
 	unsigned int clock_fallback;
 	unsigned int optical_in; /* 0:SPDIF, 1:ADAT */
@@ -1825,6 +1829,7 @@ void snd_emu1010_fpga_write(struct snd_emu10k1 *emu, u32 reg, u32 value);
 void snd_emu1010_fpga_read(struct snd_emu10k1 *emu, u32 reg, u32 *value);
 void snd_emu1010_fpga_link_dst_src_write(struct snd_emu10k1 *emu, u32 dst, u32 src);
 u32 snd_emu1010_fpga_link_dst_src_read(struct snd_emu10k1 *emu, u32 dst);
+int snd_emu1010_get_raw_rate(struct snd_emu10k1 *emu, u8 src);
 void snd_emu1010_update_clock(struct snd_emu10k1 *emu);
 unsigned int snd_emu10k1_efx_read(struct snd_emu10k1 *emu, unsigned int pc);
 void snd_emu10k1_intr_enable(struct snd_emu10k1 *emu, unsigned int intrenb);
sound/pci/emu10k1/emuproc.c +23 -20

52 lines not on this page · raw message

sound/pci/emu10k1/io.c +50 -1

71 lines not on this page · raw message

Signature · 1 line
2.40.0.152.g15d061e6df
#4 lore raw

PATCH 4/9 ALSA: emu10k1: fix sample rates for E-MU cards at 44.1 kHz word clock

In reply to Oswald Buddenhagen

Now that we know the actual word clock, we can:
- Put the resulting rate into the hardware info
- At 44.1 kHz word clock shift the rate for the pitch calculations, which presume a 48 kHz word clock

---
 include/sound/emu10k1.h    |   1 +
 sound/pci/emu10k1/emupcm.c | 112 ++++++++++++++++++-------------------
 2 files changed, 56 insertions(+), 57 deletions(-)
include/sound/emu10k1.h +1 -0
index d64cf1697586..386a5f3be3e0 100644
@@ -1495,6 +1495,7 @@ struct snd_emu10k1_pcm {
 	unsigned short first_ptr;
 	snd_pcm_uframes_t resume_pos;
 	struct snd_util_memblk *memblk;
+	unsigned int pitch_target;
 	unsigned int start_addr;
 	unsigned int ccca_start_addr;
 	unsigned int capture_ipr;	/* interrupt acknowledge mask */
sound/pci/emu10k1/emupcm.c +55 -57

220 lines not on this page · raw message

Signature · 1 line
2.40.0.152.g15d061e6df
#5 lore raw

PATCH 5/9 ALSA: emu10k1: fix synthesizer pitch for E-MU cards at 44.1 kHz

In reply to Oswald Buddenhagen

This is only a very partial fix - the frequency-dependent envelope & LFO register values aren't adjusted.

But I'm not sure they were even correct at 48 kHz to start with, as most of them are precalculated by common code which assumes an EMU8K-specific 44.1 kHz word clock, and it seems somewhat unlikely that the hardware's register interpretation was adjusted to compensate for the different word clock.

In any case I'm not going to spend time on fixing that, as this code is unlikely to be actually used by anyone today.

---
 include/sound/emux_synth.h           |  2 +-
 sound/pci/emu10k1/emu10k1_callback.c | 10 ++++++++++
 sound/pci/emu10k1/emu10k1_synth.c    |  1 -
 sound/synth/emux/emux_synth.c        |  3 ++-
 4 files changed, 13 insertions(+), 3 deletions(-)
include/sound/emux_synth.h +1 -1
index d499b68122a3..1cc530434b97 100644
@@ -54,6 +54,7 @@ struct snd_emux_operators {
 #if IS_ENABLED(CONFIG_SND_SEQUENCER_OSS)
 	int (*oss_ioctl)(struct snd_emux *emu, int cmd, int p1, int p2);
 #endif
+	int (*get_pitch_shift)(struct snd_emux *emu);
 };
 
 
@@ -82,7 +83,6 @@ struct snd_emux {
 	int max_voices;		/* Number of voices */
 	int mem_size;		/* memory size (in byte) */
 	int num_ports;		/* number of ports to be created */
-	int pitch_shift;	/* pitch shift value (for Emu10k1) */
 	struct snd_emux_operators ops;	/* operators */
 	void *hw;		/* hardware */
 	unsigned long flags;	/* other conditions */
sound/pci/emu10k1/emu10k1_callback.c +10 -0
index ad0dea0c2be9..d36234b88fb4 100644
@@ -35,6 +35,7 @@ static void terminate_voice(struct snd_emux_voice *vp);
 static void free_voice(struct snd_emux_voice *vp);
 static u32 make_fmmod(struct snd_emux_voice *vp);
 static u32 make_fm2frq2(struct snd_emux_voice *vp);
+static int get_pitch_shift(struct snd_emux *emu);
 
 /*
  * Ensure a value is between two points
@@ -58,6 +59,7 @@ static const struct snd_emux_operators emu10k1_ops = {
 	.free_voice =	free_voice,
 	.sample_new =	snd_emu10k1_sample_new,
 	.sample_free =	snd_emu10k1_sample_free,
+	.get_pitch_shift = get_pitch_shift,
 };
 
 void
@@ -508,3 +510,11 @@ make_fm2frq2(struct snd_emux_voice *vp)
 	LIMITVALUE(pitch, -128, 127);
 	return ((unsigned char)pitch << 8) | freq;
 }
+
+static int get_pitch_shift(struct snd_emux *emu)
+{
+	struct snd_emu10k1 *hw = emu->hw;
+
+	return (hw->card_capabilities->emu_model &&
+			hw->emu1010.word_clock == 44100) ? 0 : -501;
+}
sound/pci/emu10k1/emu10k1_synth.c +0 -1
index 549013a4a80b..759e66e1105a 100644
@@ -43,7 +43,6 @@ static int snd_emu10k1_synth_probe(struct device *_dev)
 	emux->hw = hw;
 	emux->max_voices = arg->max_voices;
 	emux->num_ports = arg->seq_ports;
-	emux->pitch_shift = -501;
 	emux->memhdr = hw->memhdr;
 	/* maximum two ports */
 	emux->midi_ports = arg->seq_ports < 2 ? arg->seq_ports : 2;
sound/synth/emux/emux_synth.c +2 -1
index a5385efcedb6..075358a533a0 100644
@@ -845,7 +845,8 @@ calc_pitch(struct snd_emux_voice *vp)
 
 	/* 0xe000: root pitch */
 	offset += 0xe000 + vp->reg.rate_offset;
-	offset += vp->emu->pitch_shift;
+	if (vp->emu->ops.get_pitch_shift)
+		offset += vp->emu->ops.get_pitch_shift(vp->emu);
 	LIMITVALUE(offset, 0, 0xffff);
 	if (offset == vp->apitch)
 		return 0; /* unchanged */
Signature · 1 line
2.40.0.152.g15d061e6df
#6 lore raw

PATCH 6/9 ALSA: timer: minimize open-coded access to hw.resolution

In reply to Oswald Buddenhagen

Some info-querying code still used hw.resolution directly instead of calling snd_timer_hw_resolution(), thus missing a possible hw.c_resolution callback. This patch rectifies that.

---
 sound/core/timer.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
sound/core/timer.c +13 -5
index e08a37c23add..9d0d2a5c2e15 100644
@@ -1246,6 +1246,7 @@ static void snd_timer_proc_read(struct snd_info_entry *entry,
 {
 	struct snd_timer *timer;
 	struct snd_timer_instance *ti;
+	unsigned long resolution;
 
 	mutex_lock(&register_mutex);
 	list_for_each_entry(timer, &snd_timer_list, device_list) {
@@ -1269,10 +1270,13 @@ static void snd_timer_proc_read(struct snd_info_entry *entry,
 				    timer->tmr_device, timer->tmr_subdevice);
 		}
 		snd_iprintf(buffer, "%s :", timer->name);
-		if (timer->hw.resolution)
+		spin_lock_irq(&timer->lock);
+		resolution = snd_timer_hw_resolution(timer);
+		spin_unlock_irq(&timer->lock);
+		if (resolution)
 			snd_iprintf(buffer, " %lu.%03luus (%lu ticks)",
-				    timer->hw.resolution / 1000,
-				    timer->hw.resolution % 1000,
+				    resolution / 1000,
+				    resolution % 1000,
 				    timer->hw.ticks);
 		if (timer->hw.flags & SNDRV_TIMER_HW_SLAVE)
 			snd_iprintf(buffer, " SLAVE");
@@ -1662,7 +1666,9 @@ static int snd_timer_user_ginfo(struct file *file,
 			ginfo->flags |= SNDRV_TIMER_FLG_SLAVE;
 		strscpy(ginfo->id, t->id, sizeof(ginfo->id));
 		strscpy(ginfo->name, t->name, sizeof(ginfo->name));
-		ginfo->resolution = t->hw.resolution;
+		spin_lock_irq(&t->lock);
+		ginfo->resolution = snd_timer_hw_resolution(t);
+		spin_unlock_irq(&t->lock);
 		if (t->hw.resolution_min > 0) {
 			ginfo->resolution_min = t->hw.resolution_min;
 			ginfo->resolution_max = t->hw.resolution_max;
@@ -1817,7 +1823,9 @@ static int snd_timer_user_info(struct file *file,
 		info->flags |= SNDRV_TIMER_FLG_SLAVE;
 	strscpy(info->id, t->id, sizeof(info->id));
 	strscpy(info->name, t->name, sizeof(info->name));
-	info->resolution = t->hw.resolution;
+	spin_lock_irq(&t->lock);
+	info->resolution = snd_timer_hw_resolution(t);
+	spin_unlock_irq(&t->lock);
 	if (copy_to_user(_info, info, sizeof(*_info)))
 		err = -EFAULT;
 	kfree(info);
Signature · 1 line
2.40.0.152.g15d061e6df
#7 lore raw

PATCH 7/9 ALSA: emu10k1: fix timer for E-MU cards at 44.1 kHz word clock

In reply to Oswald Buddenhagen

The timer was presuming a fixed 48 kHz word clock, like the rest of the code.

---
 sound/pci/emu10k1/timer.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)
sound/pci/emu10k1/timer.c +18 -2
index 993663fef885..f3c78adf3248 100644
@@ -38,20 +38,36 @@ static int snd_emu10k1_timer_stop(struct snd_timer *timer)
 	return 0;
 }
 
+static unsigned long snd_emu10k1_timer_c_resolution(struct snd_timer *timer)
+{
+	struct snd_emu10k1 *emu = snd_timer_chip(timer);
+
+	if (emu->card_capabilities->emu_model &&
+	    emu->emu1010.word_clock == 44100)
+		return 22676;  // 1 sample @ 44.1 kHz = 22.675736...us
+	else
+		return 20833;  // 1 sample @ 48 kHz = 20.833...us
+}
+
 static int snd_emu10k1_timer_precise_resolution(struct snd_timer *timer,
 					       unsigned long *num, unsigned long *den)
 {
+	struct snd_emu10k1 *emu = snd_timer_chip(timer);
+
 	*num = 1;
-	*den = 48000;
+	if (emu->card_capabilities->emu_model)
+		*den = emu->emu1010.word_clock;
+	else
+		*den = 48000;
 	return 0;
 }
 
 static const struct snd_timer_hardware snd_emu10k1_timer_hw = {
 	.flags = SNDRV_TIMER_HW_AUTO,
-	.resolution = 20833, /* 1 sample @ 48KHZ = 20.833...us */
 	.ticks = 1024,
 	.start = snd_emu10k1_timer_start,
 	.stop = snd_emu10k1_timer_stop,
+	.c_resolution = snd_emu10k1_timer_c_resolution,
 	.precise_resolution = snd_emu10k1_timer_precise_resolution,
 };
 
Signature · 1 line
2.40.0.152.g15d061e6df
#8 lore raw

PATCH 8/9 ALSA: emu10k1: add support for 12 kHz capture on Audigy

In reply to Oswald Buddenhagen

Fixes a tentative FIXME. Because we can.

---
 sound/pci/emu10k1/emupcm.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
sound/pci/emu10k1/emupcm.c +13 -2
index 3ef9130a9577..387288d623d7 100644
@@ -177,12 +177,22 @@ static unsigned int snd_emu10k1_capture_rate_reg(unsigned int rate)
 	}
 }
 
+static const unsigned int audigy_capture_rates[9] = {
+	8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000
+};
+
+static const struct snd_pcm_hw_constraint_list hw_constraints_audigy_capture_rates = {
+	.count = 9,
+	.list = audigy_capture_rates,
+	.mask = 0
+};
+
 static unsigned int snd_emu10k1_audigy_capture_rate_reg(unsigned int rate)
 {
 	switch (rate) {
 	case 8000:	return A_ADCCR_SAMPLERATE_8;
 	case 11025:	return A_ADCCR_SAMPLERATE_11;
-	case 12000:	return A_ADCCR_SAMPLERATE_12; /* really supported? */
+	case 12000:	return A_ADCCR_SAMPLERATE_12;
 	case 16000:	return ADCCR_SAMPLERATE_16;
 	case 22050:	return ADCCR_SAMPLERATE_22;
 	case 24000:	return ADCCR_SAMPLERATE_24;
@@ -209,7 +219,8 @@ static void snd_emu10k1_constrain_capture_rates(struct snd_emu10k1 *emu,
 		return;
 	}
 	snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
-				   &hw_constraints_capture_rates);
+				   emu->audigy ? &hw_constraints_audigy_capture_rates :
+						 &hw_constraints_capture_rates);
 }
 
 static void snd_emu1010_constrain_efx_rate(struct snd_emu10k1 *emu,
Signature · 1 line
2.40.0.152.g15d061e6df
#9 lore raw

PATCH 9/9 ALSA: emu10k1: actually show some S/PDIF status in /proc for E-MU cards

In reply to Oswald Buddenhagen

The file is called spdif-in, but we abused it to show only sample rates from various sources. Rectify it as far as possible (the FPGA doesn't give us a lot of information).

---

FIXME: the polarity of "no copy" isn't clear - it could mean either "no copyright asserted" or "no copies permitted". my attempts to test it with an 0404b fed by an intel hda board went nowhere - the bit is never set regardless of what i poke into the hda codec, and i don't know whether the source or the card is to blame.

---
 sound/pci/emu10k1/emuproc.c | 8 ++++++++
 1 file changed, 8 insertions(+)
sound/pci/emu10k1/emuproc.c +8 -0
index 993b35362499..7e2cc532471f 100644
@@ -194,6 +194,14 @@ static void snd_emu10k1_proc_spdif_read(struct snd_info_entry *entry,
 		    emu->card_capabilities->emu_model == EMU_MODEL_EMU1010)
 			snd_iprintf(buffer, "BNC rate: %dHz\n",
 				    snd_emu1010_get_raw_rate(emu, EMU_HANA_WCLOCK_SYNC_BNC));
+
+		snd_emu1010_fpga_read(emu, EMU_HANA_SPDIF_MODE, &value);
+		if (value & EMU_HANA_SPDIF_MODE_RX_INVALID)
+			snd_iprintf(buffer, "\nS/PDIF input invalid\n");
+		else
+			snd_iprintf(buffer, "\nS/PDIF mode: %s%s\n",
+				    value & EMU_HANA_SPDIF_MODE_RX_PRO ? "professional" : "consumer",
+				    value & EMU_HANA_SPDIF_MODE_RX_NOCOPY ? ", no copy" : "");
 	} else {
 		snd_emu10k1_proc_spdif_status(emu, buffer, "CD-ROM S/PDIF In", CDCS, CDSRCS);
 		snd_emu10k1_proc_spdif_status(emu, buffer, "Optical or Coax S/PDIF In", GPSCS, GPSRCS);
Signature · 1 line
2.40.0.152.g15d061e6df
Applied
#10 lore raw
In reply to Oswald Buddenhagen
Quoted 13 lines · Oswald Buddenhagen

Oswald Buddenhagen (9):
ALSA: emu10k1: split off E-MU fallback clock from clock source
ALSA: emu10k1: make available E-MU clock sources card-specific
ALSA: emu10k1: query rate of external clock sources on E-MU cards
ALSA: emu10k1: fix sample rates for E-MU cards at 44.1 kHz word clock
ALSA: emu10k1: fix synthesizer pitch for E-MU cards at 44.1 kHz
ALSA: timer: minimize open-coded access to hw.resolution
ALSA: emu10k1: fix timer for E-MU cards at 44.1 kHz word clock
ALSA: emu10k1: add support for 12 kHz capture on Audigy
ALSA: emu10k1: actually show some S/PDIF status in /proc for E-MU
cards

Applied all patches now. Thanks.

Takashi