Skip to content

Commit 1359886

Browse files
ossilatortiwai
authored andcommitted
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. Signed-off-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Link: https://lore.kernel.org/r/20230612191325.1315854-2-oswald.buddenhagen@gmx.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 508b662 commit 1359886

4 files changed

Lines changed: 72 additions & 27 deletions

File tree

include/sound/emu10k1.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1668,7 +1668,8 @@ struct snd_emu1010 {
16681668
unsigned char input_source[NUM_INPUT_DESTS];
16691669
unsigned int adc_pads; /* bit mask */
16701670
unsigned int dac_pads; /* bit mask */
1671-
unsigned int internal_clock; /* 44100 or 48000 */
1671+
unsigned int clock_source;
1672+
unsigned int clock_fallback;
16721673
unsigned int optical_in; /* 0:SPDIF, 1:ADAT */
16731674
unsigned int optical_out; /* 0:SPDIF, 1:ADAT */
16741675
struct delayed_work firmware_work;

sound/pci/emu10k1/emu10k1_main.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,8 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 *emu)
900900
/* IRQ Enable: All off */
901901
snd_emu1010_fpga_write(emu, EMU_HANA_IRQ_ENABLE, 0x00);
902902

903-
emu->emu1010.internal_clock = 1; /* 48000 */
903+
emu->emu1010.clock_source = 1; /* 48000 */
904+
emu->emu1010.clock_fallback = 1; /* 48000 */
904905
/* Default WCLK set to 48kHz. */
905906
snd_emu1010_fpga_write(emu, EMU_HANA_DEFCLOCK, EMU_HANA_DEFCLOCK_48K);
906907
/* Word Clock source, Internal 48kHz x1 */

sound/pci/emu10k1/emumixer.c

Lines changed: 66 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,7 @@ static const struct snd_emu1010_pads_info emu1010_pads_info[] = {
888888
};
889889

890890

891-
static int snd_emu1010_internal_clock_info(struct snd_kcontrol *kcontrol,
891+
static int snd_emu1010_clock_source_info(struct snd_kcontrol *kcontrol,
892892
struct snd_ctl_elem_info *uinfo)
893893
{
894894
static const char * const texts[4] = {
@@ -898,16 +898,16 @@ static int snd_emu1010_internal_clock_info(struct snd_kcontrol *kcontrol,
898898
return snd_ctl_enum_info(uinfo, 1, 4, texts);
899899
}
900900

901-
static int snd_emu1010_internal_clock_get(struct snd_kcontrol *kcontrol,
901+
static int snd_emu1010_clock_source_get(struct snd_kcontrol *kcontrol,
902902
struct snd_ctl_elem_value *ucontrol)
903903
{
904904
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
905905

906-
ucontrol->value.enumerated.item[0] = emu->emu1010.internal_clock;
906+
ucontrol->value.enumerated.item[0] = emu->emu1010.clock_source;
907907
return 0;
908908
}
909909

910-
static int snd_emu1010_internal_clock_put(struct snd_kcontrol *kcontrol,
910+
static int snd_emu1010_clock_source_put(struct snd_kcontrol *kcontrol,
911911
struct snd_ctl_elem_value *ucontrol)
912912
{
913913
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
@@ -918,16 +918,14 @@ static int snd_emu1010_internal_clock_put(struct snd_kcontrol *kcontrol,
918918
/* Limit: uinfo->value.enumerated.items = 4; */
919919
if (val >= 4)
920920
return -EINVAL;
921-
change = (emu->emu1010.internal_clock != val);
921+
change = (emu->emu1010.clock_source != val);
922922
if (change) {
923-
emu->emu1010.internal_clock = val;
923+
emu->emu1010.clock_source = val;
924924
switch (val) {
925925
case 0:
926926
/* 44100 */
927927
/* Mute all */
928928
snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, EMU_MUTE );
929-
/* Default fallback clock 44.1kHz */
930-
snd_emu1010_fpga_write(emu, EMU_HANA_DEFCLOCK, EMU_HANA_DEFCLOCK_44_1K );
931929
/* Word Clock source, Internal 44.1kHz x1 */
932930
snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK,
933931
EMU_HANA_WCLOCK_INT_44_1K | EMU_HANA_WCLOCK_1X );
@@ -943,8 +941,6 @@ static int snd_emu1010_internal_clock_put(struct snd_kcontrol *kcontrol,
943941
/* 48000 */
944942
/* Mute all */
945943
snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, EMU_MUTE );
946-
/* Default fallback clock 48kHz */
947-
snd_emu1010_fpga_write(emu, EMU_HANA_DEFCLOCK, EMU_HANA_DEFCLOCK_48K );
948944
/* Word Clock source, Internal 48kHz x1 */
949945
snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK,
950946
EMU_HANA_WCLOCK_INT_48K | EMU_HANA_WCLOCK_1X );
@@ -960,8 +956,6 @@ static int snd_emu1010_internal_clock_put(struct snd_kcontrol *kcontrol,
960956
case 2: /* Take clock from S/PDIF IN */
961957
/* Mute all */
962958
snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, EMU_MUTE );
963-
/* Default fallback clock 48kHz */
964-
snd_emu1010_fpga_write(emu, EMU_HANA_DEFCLOCK, EMU_HANA_DEFCLOCK_48K );
965959
/* Word Clock source, sync to S/PDIF input */
966960
snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK,
967961
EMU_HANA_WCLOCK_HANA_SPDIF_IN | EMU_HANA_WCLOCK_1X );
@@ -979,8 +973,6 @@ static int snd_emu1010_internal_clock_put(struct snd_kcontrol *kcontrol,
979973
/* Take clock from ADAT IN */
980974
/* Mute all */
981975
snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, EMU_MUTE );
982-
/* Default fallback clock 48kHz */
983-
snd_emu1010_fpga_write(emu, EMU_HANA_DEFCLOCK, EMU_HANA_DEFCLOCK_48K );
984976
/* Word Clock source, sync to ADAT input */
985977
snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK,
986978
EMU_HANA_WCLOCK_HANA_ADAT_IN | EMU_HANA_WCLOCK_1X );
@@ -999,15 +991,62 @@ static int snd_emu1010_internal_clock_put(struct snd_kcontrol *kcontrol,
999991
return change;
1000992
}
1001993

1002-
static const struct snd_kcontrol_new snd_emu1010_internal_clock =
994+
static const struct snd_kcontrol_new snd_emu1010_clock_source =
1003995
{
1004-
.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
1005-
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1006-
.name = "Clock Internal Rate",
1007-
.count = 1,
1008-
.info = snd_emu1010_internal_clock_info,
1009-
.get = snd_emu1010_internal_clock_get,
1010-
.put = snd_emu1010_internal_clock_put
996+
.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
997+
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
998+
.name = "Clock Source",
999+
.count = 1,
1000+
.info = snd_emu1010_clock_source_info,
1001+
.get = snd_emu1010_clock_source_get,
1002+
.put = snd_emu1010_clock_source_put
1003+
};
1004+
1005+
static int snd_emu1010_clock_fallback_info(struct snd_kcontrol *kcontrol,
1006+
struct snd_ctl_elem_info *uinfo)
1007+
{
1008+
static const char * const texts[2] = {
1009+
"44100", "48000"
1010+
};
1011+
1012+
return snd_ctl_enum_info(uinfo, 1, 2, texts);
1013+
}
1014+
1015+
static int snd_emu1010_clock_fallback_get(struct snd_kcontrol *kcontrol,
1016+
struct snd_ctl_elem_value *ucontrol)
1017+
{
1018+
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
1019+
1020+
ucontrol->value.enumerated.item[0] = emu->emu1010.clock_fallback;
1021+
return 0;
1022+
}
1023+
1024+
static int snd_emu1010_clock_fallback_put(struct snd_kcontrol *kcontrol,
1025+
struct snd_ctl_elem_value *ucontrol)
1026+
{
1027+
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
1028+
unsigned int val = ucontrol->value.enumerated.item[0];
1029+
int change;
1030+
1031+
if (val >= 2)
1032+
return -EINVAL;
1033+
change = (emu->emu1010.clock_fallback != val);
1034+
if (change) {
1035+
emu->emu1010.clock_fallback = val;
1036+
snd_emu1010_fpga_write(emu, EMU_HANA_DEFCLOCK, 1 - val);
1037+
}
1038+
return change;
1039+
}
1040+
1041+
static const struct snd_kcontrol_new snd_emu1010_clock_fallback =
1042+
{
1043+
.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
1044+
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1045+
.name = "Clock Fallback",
1046+
.count = 1,
1047+
.info = snd_emu1010_clock_fallback_info,
1048+
.get = snd_emu1010_clock_fallback_get,
1049+
.put = snd_emu1010_clock_fallback_put
10111050
};
10121051

10131052
static int snd_emu1010_optical_out_info(struct snd_kcontrol *kcontrol,
@@ -2297,7 +2336,11 @@ int snd_emu10k1_mixer(struct snd_emu10k1 *emu,
22972336
snd_emu1010_apply_sources(emu);
22982337

22992338
err = snd_ctl_add(card,
2300-
snd_ctl_new1(&snd_emu1010_internal_clock, emu));
2339+
snd_ctl_new1(&snd_emu1010_clock_source, emu));
2340+
if (err < 0)
2341+
return err;
2342+
err = snd_ctl_add(card,
2343+
snd_ctl_new1(&snd_emu1010_clock_fallback, emu));
23012344
if (err < 0)
23022345
return err;
23032346

sound/pci/emu10k1/emupcm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,7 +1185,7 @@ static int snd_emu10k1_playback_open(struct snd_pcm_substream *substream)
11851185
kfree(epcm);
11861186
return err;
11871187
}
1188-
if (emu->card_capabilities->emu_model && emu->emu1010.internal_clock == 0)
1188+
if (emu->card_capabilities->emu_model && emu->emu1010.clock_source == 0)
11891189
sample_rate = 44100;
11901190
else
11911191
sample_rate = 48000;
@@ -1335,7 +1335,7 @@ static int snd_emu10k1_capture_efx_open(struct snd_pcm_substream *substream)
13351335
* but we don't exceed 16 channels anyway.
13361336
*/
13371337
#if 1
1338-
switch (emu->emu1010.internal_clock) {
1338+
switch (emu->emu1010.clock_source) {
13391339
case 0:
13401340
/* For 44.1kHz */
13411341
runtime->hw.rates = SNDRV_PCM_RATE_44100;

0 commit comments

Comments
 (0)