2019-05-27 14:55:05 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
2007-10-15 15:50:19 +08:00
|
|
|
* Copyright (c) by Jaroslav Kysela <perex@perex.cz>,
|
2005-04-17 06:20:36 +08:00
|
|
|
* Takashi Iwai <tiwai@suse.de>
|
2023-07-16 00:08:39 +08:00
|
|
|
* Lee Revell <rlrevell@joe-job.com>
|
|
|
|
* James Courtier-Dutton <James@superbug.co.uk>
|
|
|
|
* Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
|
2005-04-17 06:20:36 +08:00
|
|
|
* Creative Labs, Inc.
|
|
|
|
*
|
2023-07-16 00:08:39 +08:00
|
|
|
* Routines for control of EMU10K1 chips / mixer routines
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/time.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <sound/core.h>
|
|
|
|
#include <sound/emu10k1.h>
|
2006-10-11 01:08:45 +08:00
|
|
|
#include <linux/delay.h>
|
2006-12-06 23:58:02 +08:00
|
|
|
#include <sound/tlv.h>
|
|
|
|
|
|
|
|
#include "p17v.h"
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#define AC97_ID_STAC9758 0x83847658
|
|
|
|
|
2007-01-29 22:33:49 +08:00
|
|
|
static const DECLARE_TLV_DB_SCALE(snd_audigy_db_scale2, -10350, 50, 1); /* WM8775 gain scale */
|
2006-12-06 23:58:02 +08:00
|
|
|
|
2023-05-16 17:36:05 +08:00
|
|
|
|
|
|
|
static int add_ctls(struct snd_emu10k1 *emu, const struct snd_kcontrol_new *tpl,
|
|
|
|
const char * const *ctls, unsigned nctls)
|
|
|
|
{
|
|
|
|
struct snd_kcontrol_new kctl = *tpl;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
for (unsigned i = 0; i < nctls; i++) {
|
|
|
|
kctl.name = ctls[i];
|
|
|
|
kctl.private_value = i;
|
|
|
|
err = snd_ctl_add(emu->card, snd_ctl_new1(&kctl, emu));
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-11-17 21:50:13 +08:00
|
|
|
static int snd_emu10k1_spdif_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958;
|
|
|
|
uinfo->count = 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 21:50:13 +08:00
|
|
|
static int snd_emu10k1_spdif_get(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-11-17 21:50:13 +08:00
|
|
|
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
|
|
|
|
|
2007-11-12 22:55:19 +08:00
|
|
|
/* Limit: emu->spdif_bits */
|
|
|
|
if (idx >= 3)
|
|
|
|
return -EINVAL;
|
2005-04-17 06:20:36 +08:00
|
|
|
ucontrol->value.iec958.status[0] = (emu->spdif_bits[idx] >> 0) & 0xff;
|
|
|
|
ucontrol->value.iec958.status[1] = (emu->spdif_bits[idx] >> 8) & 0xff;
|
|
|
|
ucontrol->value.iec958.status[2] = (emu->spdif_bits[idx] >> 16) & 0xff;
|
|
|
|
ucontrol->value.iec958.status[3] = (emu->spdif_bits[idx] >> 24) & 0xff;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 21:50:13 +08:00
|
|
|
static int snd_emu10k1_spdif_get_mask(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
ucontrol->value.iec958.status[0] = 0xff;
|
|
|
|
ucontrol->value.iec958.status[1] = 0xff;
|
|
|
|
ucontrol->value.iec958.status[2] = 0xff;
|
|
|
|
ucontrol->value.iec958.status[3] = 0xff;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2023-05-16 17:36:04 +08:00
|
|
|
#define PAIR_PS(base, one, two, sfx) base " " one sfx, base " " two sfx
|
|
|
|
#define LR_PS(base, sfx) PAIR_PS(base, "Left", "Right", sfx)
|
2006-10-01 17:48:04 +08:00
|
|
|
|
2023-05-16 17:36:04 +08:00
|
|
|
#define ADAT_PS(pfx, sfx) \
|
|
|
|
pfx "ADAT 0" sfx, pfx "ADAT 1" sfx, pfx "ADAT 2" sfx, pfx "ADAT 3" sfx, \
|
|
|
|
pfx "ADAT 4" sfx, pfx "ADAT 5" sfx, pfx "ADAT 6" sfx, pfx "ADAT 7" sfx
|
2007-12-13 23:27:13 +08:00
|
|
|
|
2023-05-16 17:36:04 +08:00
|
|
|
#define PAIR_REGS(base, one, two) \
|
|
|
|
base ## one ## 1, \
|
|
|
|
base ## two ## 1
|
|
|
|
|
|
|
|
#define LR_REGS(base) PAIR_REGS(base, _LEFT, _RIGHT)
|
2007-12-13 23:27:13 +08:00
|
|
|
|
2023-05-16 17:36:04 +08:00
|
|
|
#define ADAT_REGS(base) \
|
|
|
|
base+0, base+1, base+2, base+3, base+4, base+5, base+6, base+7
|
2007-12-13 23:27:13 +08:00
|
|
|
|
2007-06-11 18:21:20 +08:00
|
|
|
/*
|
|
|
|
* List of data sources available for each destination
|
|
|
|
*/
|
2023-05-16 17:36:04 +08:00
|
|
|
|
|
|
|
#define DSP_TEXTS \
|
|
|
|
"DSP 0", "DSP 1", "DSP 2", "DSP 3", "DSP 4", "DSP 5", "DSP 6", "DSP 7", \
|
|
|
|
"DSP 8", "DSP 9", "DSP 10", "DSP 11", "DSP 12", "DSP 13", "DSP 14", "DSP 15", \
|
|
|
|
"DSP 16", "DSP 17", "DSP 18", "DSP 19", "DSP 20", "DSP 21", "DSP 22", "DSP 23", \
|
|
|
|
"DSP 24", "DSP 25", "DSP 26", "DSP 27", "DSP 28", "DSP 29", "DSP 30", "DSP 31"
|
|
|
|
|
|
|
|
#define PAIR_TEXTS(base, one, two) PAIR_PS(base, one, two, "")
|
|
|
|
#define LR_TEXTS(base) LR_PS(base, "")
|
|
|
|
#define ADAT_TEXTS(pfx) ADAT_PS(pfx, "")
|
|
|
|
|
|
|
|
#define EMU32_SRC_REGS \
|
|
|
|
EMU_SRC_ALICE_EMU32A, \
|
|
|
|
EMU_SRC_ALICE_EMU32A+1, \
|
|
|
|
EMU_SRC_ALICE_EMU32A+2, \
|
|
|
|
EMU_SRC_ALICE_EMU32A+3, \
|
|
|
|
EMU_SRC_ALICE_EMU32A+4, \
|
|
|
|
EMU_SRC_ALICE_EMU32A+5, \
|
|
|
|
EMU_SRC_ALICE_EMU32A+6, \
|
|
|
|
EMU_SRC_ALICE_EMU32A+7, \
|
|
|
|
EMU_SRC_ALICE_EMU32A+8, \
|
|
|
|
EMU_SRC_ALICE_EMU32A+9, \
|
|
|
|
EMU_SRC_ALICE_EMU32A+0xa, \
|
|
|
|
EMU_SRC_ALICE_EMU32A+0xb, \
|
|
|
|
EMU_SRC_ALICE_EMU32A+0xc, \
|
|
|
|
EMU_SRC_ALICE_EMU32A+0xd, \
|
|
|
|
EMU_SRC_ALICE_EMU32A+0xe, \
|
|
|
|
EMU_SRC_ALICE_EMU32A+0xf, \
|
|
|
|
EMU_SRC_ALICE_EMU32B, \
|
|
|
|
EMU_SRC_ALICE_EMU32B+1, \
|
|
|
|
EMU_SRC_ALICE_EMU32B+2, \
|
|
|
|
EMU_SRC_ALICE_EMU32B+3, \
|
|
|
|
EMU_SRC_ALICE_EMU32B+4, \
|
|
|
|
EMU_SRC_ALICE_EMU32B+5, \
|
|
|
|
EMU_SRC_ALICE_EMU32B+6, \
|
|
|
|
EMU_SRC_ALICE_EMU32B+7, \
|
|
|
|
EMU_SRC_ALICE_EMU32B+8, \
|
|
|
|
EMU_SRC_ALICE_EMU32B+9, \
|
|
|
|
EMU_SRC_ALICE_EMU32B+0xa, \
|
|
|
|
EMU_SRC_ALICE_EMU32B+0xb, \
|
|
|
|
EMU_SRC_ALICE_EMU32B+0xc, \
|
|
|
|
EMU_SRC_ALICE_EMU32B+0xd, \
|
|
|
|
EMU_SRC_ALICE_EMU32B+0xe, \
|
|
|
|
EMU_SRC_ALICE_EMU32B+0xf
|
|
|
|
|
2023-05-16 17:36:11 +08:00
|
|
|
/* 1010 rev1 */
|
|
|
|
|
2023-05-16 17:36:04 +08:00
|
|
|
#define EMU1010_COMMON_TEXTS \
|
|
|
|
"Silence", \
|
|
|
|
PAIR_TEXTS("Dock Mic", "A", "B"), \
|
|
|
|
LR_TEXTS("Dock ADC1"), \
|
|
|
|
LR_TEXTS("Dock ADC2"), \
|
|
|
|
LR_TEXTS("Dock ADC3"), \
|
|
|
|
LR_TEXTS("0202 ADC"), \
|
|
|
|
LR_TEXTS("1010 SPDIF"), \
|
|
|
|
ADAT_TEXTS("1010 ")
|
|
|
|
|
|
|
|
static const char * const emu1010_src_texts[] = {
|
|
|
|
EMU1010_COMMON_TEXTS,
|
|
|
|
DSP_TEXTS,
|
|
|
|
};
|
|
|
|
|
2023-05-16 17:36:03 +08:00
|
|
|
static const unsigned short emu1010_src_regs[] = {
|
2023-05-16 17:36:04 +08:00
|
|
|
EMU_SRC_SILENCE,
|
|
|
|
PAIR_REGS(EMU_SRC_DOCK_MIC, _A, _B),
|
|
|
|
LR_REGS(EMU_SRC_DOCK_ADC1),
|
|
|
|
LR_REGS(EMU_SRC_DOCK_ADC2),
|
|
|
|
LR_REGS(EMU_SRC_DOCK_ADC3),
|
|
|
|
LR_REGS(EMU_SRC_HAMOA_ADC),
|
|
|
|
LR_REGS(EMU_SRC_HANA_SPDIF),
|
|
|
|
ADAT_REGS(EMU_SRC_HANA_ADAT),
|
|
|
|
EMU32_SRC_REGS,
|
2006-10-01 17:48:04 +08:00
|
|
|
};
|
2023-05-16 17:36:04 +08:00
|
|
|
static_assert(ARRAY_SIZE(emu1010_src_regs) == ARRAY_SIZE(emu1010_src_texts));
|
2006-10-01 17:48:04 +08:00
|
|
|
|
2023-05-16 17:36:10 +08:00
|
|
|
/* 1010 rev2 */
|
|
|
|
|
|
|
|
#define EMU1010b_COMMON_TEXTS \
|
|
|
|
"Silence", \
|
|
|
|
PAIR_TEXTS("Dock Mic", "A", "B"), \
|
|
|
|
LR_TEXTS("Dock ADC1"), \
|
|
|
|
LR_TEXTS("Dock ADC2"), \
|
|
|
|
LR_TEXTS("0202 ADC"), \
|
|
|
|
LR_TEXTS("Dock SPDIF"), \
|
|
|
|
LR_TEXTS("1010 SPDIF"), \
|
|
|
|
ADAT_TEXTS("Dock "), \
|
|
|
|
ADAT_TEXTS("1010 ")
|
|
|
|
|
|
|
|
static const char * const emu1010b_src_texts[] = {
|
|
|
|
EMU1010b_COMMON_TEXTS,
|
|
|
|
DSP_TEXTS,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const unsigned short emu1010b_src_regs[] = {
|
|
|
|
EMU_SRC_SILENCE,
|
|
|
|
PAIR_REGS(EMU_SRC_DOCK_MIC, _A, _B),
|
|
|
|
LR_REGS(EMU_SRC_DOCK_ADC1),
|
|
|
|
LR_REGS(EMU_SRC_DOCK_ADC2),
|
|
|
|
LR_REGS(EMU_SRC_HAMOA_ADC),
|
|
|
|
LR_REGS(EMU_SRC_MDOCK_SPDIF),
|
|
|
|
LR_REGS(EMU_SRC_HANA_SPDIF),
|
|
|
|
ADAT_REGS(EMU_SRC_MDOCK_ADAT),
|
|
|
|
ADAT_REGS(EMU_SRC_HANA_ADAT),
|
|
|
|
EMU32_SRC_REGS,
|
|
|
|
};
|
|
|
|
static_assert(ARRAY_SIZE(emu1010b_src_regs) == ARRAY_SIZE(emu1010b_src_texts));
|
|
|
|
|
2007-12-13 23:27:13 +08:00
|
|
|
/* 1616(m) cardbus */
|
2023-05-16 17:36:04 +08:00
|
|
|
|
|
|
|
#define EMU1616_COMMON_TEXTS \
|
|
|
|
"Silence", \
|
|
|
|
PAIR_TEXTS("Mic", "A", "B"), \
|
|
|
|
LR_TEXTS("ADC1"), \
|
|
|
|
LR_TEXTS("ADC2"), \
|
|
|
|
LR_TEXTS("SPDIF"), \
|
|
|
|
ADAT_TEXTS("")
|
|
|
|
|
|
|
|
static const char * const emu1616_src_texts[] = {
|
|
|
|
EMU1616_COMMON_TEXTS,
|
|
|
|
DSP_TEXTS,
|
|
|
|
};
|
|
|
|
|
2023-05-16 17:36:03 +08:00
|
|
|
static const unsigned short emu1616_src_regs[] = {
|
2007-12-13 23:27:13 +08:00
|
|
|
EMU_SRC_SILENCE,
|
2023-05-16 17:36:04 +08:00
|
|
|
PAIR_REGS(EMU_SRC_DOCK_MIC, _A, _B),
|
|
|
|
LR_REGS(EMU_SRC_DOCK_ADC1),
|
|
|
|
LR_REGS(EMU_SRC_DOCK_ADC2),
|
|
|
|
LR_REGS(EMU_SRC_MDOCK_SPDIF),
|
|
|
|
ADAT_REGS(EMU_SRC_MDOCK_ADAT),
|
|
|
|
EMU32_SRC_REGS,
|
2007-12-13 23:27:13 +08:00
|
|
|
};
|
2023-05-16 17:36:04 +08:00
|
|
|
static_assert(ARRAY_SIZE(emu1616_src_regs) == ARRAY_SIZE(emu1616_src_texts));
|
2007-12-13 23:27:13 +08:00
|
|
|
|
2023-05-16 17:36:11 +08:00
|
|
|
/* 0404 rev1 & rev2 */
|
|
|
|
|
|
|
|
#define EMU0404_COMMON_TEXTS \
|
|
|
|
"Silence", \
|
|
|
|
LR_TEXTS("ADC"), \
|
|
|
|
LR_TEXTS("SPDIF")
|
|
|
|
|
|
|
|
static const char * const emu0404_src_texts[] = {
|
|
|
|
EMU0404_COMMON_TEXTS,
|
|
|
|
DSP_TEXTS,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const unsigned short emu0404_src_regs[] = {
|
|
|
|
EMU_SRC_SILENCE,
|
|
|
|
LR_REGS(EMU_SRC_HAMOA_ADC),
|
|
|
|
LR_REGS(EMU_SRC_HANA_SPDIF),
|
|
|
|
EMU32_SRC_REGS,
|
|
|
|
};
|
|
|
|
static_assert(ARRAY_SIZE(emu0404_src_regs) == ARRAY_SIZE(emu0404_src_texts));
|
|
|
|
|
2007-06-11 18:21:20 +08:00
|
|
|
/*
|
|
|
|
* Data destinations - physical EMU outputs.
|
|
|
|
* Each destination has an enum mixer control to choose a data source
|
|
|
|
*/
|
2023-05-16 17:36:05 +08:00
|
|
|
|
|
|
|
#define LR_CTLS(base) LR_PS(base, " Playback Enum")
|
|
|
|
#define ADAT_CTLS(pfx) ADAT_PS(pfx, " Playback Enum")
|
|
|
|
|
2023-05-16 17:36:11 +08:00
|
|
|
/* 1010 rev1 */
|
|
|
|
|
2023-05-16 17:36:05 +08:00
|
|
|
static const char * const emu1010_output_texts[] = {
|
|
|
|
LR_CTLS("Dock DAC1"),
|
|
|
|
LR_CTLS("Dock DAC2"),
|
|
|
|
LR_CTLS("Dock DAC3"),
|
|
|
|
LR_CTLS("Dock DAC4"),
|
|
|
|
LR_CTLS("Dock Phones"),
|
|
|
|
LR_CTLS("Dock SPDIF"),
|
|
|
|
LR_CTLS("0202 DAC"),
|
|
|
|
LR_CTLS("1010 SPDIF"),
|
|
|
|
ADAT_CTLS("1010 "),
|
|
|
|
};
|
2023-05-16 17:36:12 +08:00
|
|
|
static_assert(ARRAY_SIZE(emu1010_output_texts) <= NUM_OUTPUT_DESTS);
|
2023-05-16 17:36:05 +08:00
|
|
|
|
2023-05-16 17:36:03 +08:00
|
|
|
static const unsigned short emu1010_output_dst[] = {
|
2023-05-16 17:36:05 +08:00
|
|
|
LR_REGS(EMU_DST_DOCK_DAC1),
|
|
|
|
LR_REGS(EMU_DST_DOCK_DAC2),
|
|
|
|
LR_REGS(EMU_DST_DOCK_DAC3),
|
|
|
|
LR_REGS(EMU_DST_DOCK_DAC4),
|
|
|
|
LR_REGS(EMU_DST_DOCK_PHONES),
|
|
|
|
LR_REGS(EMU_DST_DOCK_SPDIF),
|
|
|
|
LR_REGS(EMU_DST_HAMOA_DAC),
|
|
|
|
LR_REGS(EMU_DST_HANA_SPDIF),
|
|
|
|
ADAT_REGS(EMU_DST_HANA_ADAT),
|
2006-10-01 17:48:04 +08:00
|
|
|
};
|
2023-05-16 17:36:05 +08:00
|
|
|
static_assert(ARRAY_SIZE(emu1010_output_dst) == ARRAY_SIZE(emu1010_output_texts));
|
2006-10-01 17:48:04 +08:00
|
|
|
|
ALSA: emu10k1: make E-MU I/O routing init data-driven
... and move it to the mixer init, as it's logically part of it.
As a side effect, this fixes the initial values of the input destination
mixer controls, which would have previously remained at "Silent" despite
different defaults. This didn't really matter, though, as ALSA state
restoration would hide that bug beyond first use.
Note that this completely does away with clearing the output routing
registers, as it was rather pointless - we just programmed the FPGA
(resetting it first if necessary), so everything is zeroed anyway
(that's documented by Xilinx, and as further evidence, some of the loops
terminated too early, and we didn't bother clearing the high channels of
the input routes at all, all with no observed adverse effects).
As a drive-by, this also fixes some capture channel defaults - any
EMU_SRC_*2 isn't a sensible value in 1x clock mode.
Signed-off-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Link: https://lore.kernel.org/r/20230516093612.3536508-7-oswald.buddenhagen@gmx.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-05-16 17:36:08 +08:00
|
|
|
static const unsigned short emu1010_output_dflt[] = {
|
|
|
|
EMU_SRC_ALICE_EMU32A+0, EMU_SRC_ALICE_EMU32A+1,
|
|
|
|
EMU_SRC_ALICE_EMU32A+2, EMU_SRC_ALICE_EMU32A+3,
|
|
|
|
EMU_SRC_ALICE_EMU32A+4, EMU_SRC_ALICE_EMU32A+5,
|
|
|
|
EMU_SRC_ALICE_EMU32A+6, EMU_SRC_ALICE_EMU32A+7,
|
|
|
|
EMU_SRC_ALICE_EMU32A+0, EMU_SRC_ALICE_EMU32A+1,
|
|
|
|
EMU_SRC_ALICE_EMU32A+0, EMU_SRC_ALICE_EMU32A+1,
|
|
|
|
EMU_SRC_ALICE_EMU32A+0, EMU_SRC_ALICE_EMU32A+1,
|
|
|
|
EMU_SRC_ALICE_EMU32A+0, EMU_SRC_ALICE_EMU32A+1,
|
|
|
|
EMU_SRC_ALICE_EMU32A+0, EMU_SRC_ALICE_EMU32A+1, EMU_SRC_ALICE_EMU32A+2, EMU_SRC_ALICE_EMU32A+3,
|
|
|
|
EMU_SRC_ALICE_EMU32A+4, EMU_SRC_ALICE_EMU32A+5, EMU_SRC_ALICE_EMU32A+6, EMU_SRC_ALICE_EMU32A+7,
|
|
|
|
};
|
|
|
|
static_assert(ARRAY_SIZE(emu1010_output_dflt) == ARRAY_SIZE(emu1010_output_dst));
|
|
|
|
|
2023-05-16 17:36:10 +08:00
|
|
|
/* 1010 rev2 */
|
|
|
|
|
|
|
|
static const char * const snd_emu1010b_output_texts[] = {
|
|
|
|
LR_CTLS("Dock DAC1"),
|
|
|
|
LR_CTLS("Dock DAC2"),
|
|
|
|
LR_CTLS("Dock DAC3"),
|
|
|
|
LR_CTLS("Dock SPDIF"),
|
|
|
|
ADAT_CTLS("Dock "),
|
|
|
|
LR_CTLS("0202 DAC"),
|
|
|
|
LR_CTLS("1010 SPDIF"),
|
|
|
|
ADAT_CTLS("1010 "),
|
|
|
|
};
|
2023-05-16 17:36:12 +08:00
|
|
|
static_assert(ARRAY_SIZE(snd_emu1010b_output_texts) <= NUM_OUTPUT_DESTS);
|
2023-05-16 17:36:10 +08:00
|
|
|
|
|
|
|
static const unsigned short emu1010b_output_dst[] = {
|
|
|
|
LR_REGS(EMU_DST_DOCK_DAC1),
|
|
|
|
LR_REGS(EMU_DST_DOCK_DAC2),
|
|
|
|
LR_REGS(EMU_DST_DOCK_DAC3),
|
|
|
|
LR_REGS(EMU_DST_MDOCK_SPDIF),
|
|
|
|
ADAT_REGS(EMU_DST_MDOCK_ADAT),
|
|
|
|
LR_REGS(EMU_DST_HAMOA_DAC),
|
|
|
|
LR_REGS(EMU_DST_HANA_SPDIF),
|
|
|
|
ADAT_REGS(EMU_DST_HANA_ADAT),
|
|
|
|
};
|
|
|
|
static_assert(ARRAY_SIZE(emu1010b_output_dst) == ARRAY_SIZE(snd_emu1010b_output_texts));
|
|
|
|
|
|
|
|
static const unsigned short emu1010b_output_dflt[] = {
|
|
|
|
EMU_SRC_ALICE_EMU32A+0, EMU_SRC_ALICE_EMU32A+1,
|
|
|
|
EMU_SRC_ALICE_EMU32A+2, EMU_SRC_ALICE_EMU32A+3,
|
|
|
|
EMU_SRC_ALICE_EMU32A+4, EMU_SRC_ALICE_EMU32A+5,
|
|
|
|
EMU_SRC_ALICE_EMU32A+0, EMU_SRC_ALICE_EMU32A+1,
|
|
|
|
EMU_SRC_ALICE_EMU32A+0, EMU_SRC_ALICE_EMU32A+1, EMU_SRC_ALICE_EMU32A+2, EMU_SRC_ALICE_EMU32A+3,
|
|
|
|
EMU_SRC_ALICE_EMU32A+4, EMU_SRC_ALICE_EMU32A+5, EMU_SRC_ALICE_EMU32A+6, EMU_SRC_ALICE_EMU32A+7,
|
|
|
|
EMU_SRC_ALICE_EMU32A+0, EMU_SRC_ALICE_EMU32A+1,
|
|
|
|
EMU_SRC_ALICE_EMU32A+0, EMU_SRC_ALICE_EMU32A+1,
|
|
|
|
EMU_SRC_ALICE_EMU32A+0, EMU_SRC_ALICE_EMU32A+1, EMU_SRC_ALICE_EMU32A+2, EMU_SRC_ALICE_EMU32A+3,
|
|
|
|
EMU_SRC_ALICE_EMU32A+4, EMU_SRC_ALICE_EMU32A+5, EMU_SRC_ALICE_EMU32A+6, EMU_SRC_ALICE_EMU32A+7,
|
|
|
|
};
|
|
|
|
|
2007-12-13 23:27:13 +08:00
|
|
|
/* 1616(m) cardbus */
|
2023-05-16 17:36:05 +08:00
|
|
|
|
|
|
|
static const char * const snd_emu1616_output_texts[] = {
|
|
|
|
LR_CTLS("Dock DAC1"),
|
|
|
|
LR_CTLS("Dock DAC2"),
|
|
|
|
LR_CTLS("Dock DAC3"),
|
|
|
|
LR_CTLS("Dock SPDIF"),
|
|
|
|
ADAT_CTLS("Dock "),
|
|
|
|
LR_CTLS("Mana DAC"),
|
|
|
|
};
|
2023-05-16 17:36:12 +08:00
|
|
|
static_assert(ARRAY_SIZE(snd_emu1616_output_texts) <= NUM_OUTPUT_DESTS);
|
2023-05-16 17:36:05 +08:00
|
|
|
|
2023-05-16 17:36:03 +08:00
|
|
|
static const unsigned short emu1616_output_dst[] = {
|
2023-05-16 17:36:05 +08:00
|
|
|
LR_REGS(EMU_DST_DOCK_DAC1),
|
|
|
|
LR_REGS(EMU_DST_DOCK_DAC2),
|
|
|
|
LR_REGS(EMU_DST_DOCK_DAC3),
|
|
|
|
LR_REGS(EMU_DST_MDOCK_SPDIF),
|
|
|
|
ADAT_REGS(EMU_DST_MDOCK_ADAT),
|
|
|
|
EMU_DST_MANA_DAC_LEFT, EMU_DST_MANA_DAC_RIGHT,
|
2007-12-13 23:27:13 +08:00
|
|
|
};
|
2023-05-16 17:36:05 +08:00
|
|
|
static_assert(ARRAY_SIZE(emu1616_output_dst) == ARRAY_SIZE(snd_emu1616_output_texts));
|
2007-12-13 23:27:13 +08:00
|
|
|
|
ALSA: emu10k1: make E-MU I/O routing init data-driven
... and move it to the mixer init, as it's logically part of it.
As a side effect, this fixes the initial values of the input destination
mixer controls, which would have previously remained at "Silent" despite
different defaults. This didn't really matter, though, as ALSA state
restoration would hide that bug beyond first use.
Note that this completely does away with clearing the output routing
registers, as it was rather pointless - we just programmed the FPGA
(resetting it first if necessary), so everything is zeroed anyway
(that's documented by Xilinx, and as further evidence, some of the loops
terminated too early, and we didn't bother clearing the high channels of
the input routes at all, all with no observed adverse effects).
As a drive-by, this also fixes some capture channel defaults - any
EMU_SRC_*2 isn't a sensible value in 1x clock mode.
Signed-off-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Link: https://lore.kernel.org/r/20230516093612.3536508-7-oswald.buddenhagen@gmx.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-05-16 17:36:08 +08:00
|
|
|
static const unsigned short emu1616_output_dflt[] = {
|
|
|
|
EMU_SRC_ALICE_EMU32A+0, EMU_SRC_ALICE_EMU32A+1,
|
|
|
|
EMU_SRC_ALICE_EMU32A+2, EMU_SRC_ALICE_EMU32A+3,
|
|
|
|
EMU_SRC_ALICE_EMU32A+4, EMU_SRC_ALICE_EMU32A+5,
|
|
|
|
EMU_SRC_ALICE_EMU32A+0, EMU_SRC_ALICE_EMU32A+1,
|
|
|
|
EMU_SRC_ALICE_EMU32A+0, EMU_SRC_ALICE_EMU32A+1, EMU_SRC_ALICE_EMU32A+2, EMU_SRC_ALICE_EMU32A+3,
|
|
|
|
EMU_SRC_ALICE_EMU32A+4, EMU_SRC_ALICE_EMU32A+5, EMU_SRC_ALICE_EMU32A+6, EMU_SRC_ALICE_EMU32A+7,
|
|
|
|
EMU_SRC_ALICE_EMU32A+0, EMU_SRC_ALICE_EMU32A+1,
|
|
|
|
};
|
|
|
|
static_assert(ARRAY_SIZE(emu1616_output_dflt) == ARRAY_SIZE(emu1616_output_dst));
|
|
|
|
|
2023-05-16 17:36:11 +08:00
|
|
|
/* 0404 rev1 & rev2 */
|
|
|
|
|
|
|
|
static const char * const snd_emu0404_output_texts[] = {
|
|
|
|
LR_CTLS("DAC"),
|
|
|
|
LR_CTLS("SPDIF"),
|
|
|
|
};
|
2023-05-16 17:36:12 +08:00
|
|
|
static_assert(ARRAY_SIZE(snd_emu0404_output_texts) <= NUM_OUTPUT_DESTS);
|
2023-05-16 17:36:11 +08:00
|
|
|
|
|
|
|
static const unsigned short emu0404_output_dst[] = {
|
|
|
|
LR_REGS(EMU_DST_HAMOA_DAC),
|
|
|
|
LR_REGS(EMU_DST_HANA_SPDIF),
|
|
|
|
};
|
|
|
|
static_assert(ARRAY_SIZE(emu0404_output_dst) == ARRAY_SIZE(snd_emu0404_output_texts));
|
|
|
|
|
|
|
|
static const unsigned short emu0404_output_dflt[] = {
|
|
|
|
EMU_SRC_ALICE_EMU32A+0, EMU_SRC_ALICE_EMU32A+1,
|
|
|
|
EMU_SRC_ALICE_EMU32A+0, EMU_SRC_ALICE_EMU32A+1,
|
|
|
|
};
|
|
|
|
static_assert(ARRAY_SIZE(emu0404_output_dflt) == ARRAY_SIZE(emu0404_output_dst));
|
|
|
|
|
2007-06-11 18:21:20 +08:00
|
|
|
/*
|
2023-04-23 00:10:15 +08:00
|
|
|
* Data destinations - FPGA outputs going to Alice2 (Audigy) for
|
2007-06-11 18:21:20 +08:00
|
|
|
* capture (EMU32 + I2S links)
|
|
|
|
* Each destination has an enum mixer control to choose a data source
|
|
|
|
*/
|
2023-05-16 17:36:05 +08:00
|
|
|
|
|
|
|
static const char * const emu1010_input_texts[] = {
|
|
|
|
"DSP 0 Capture Enum",
|
|
|
|
"DSP 1 Capture Enum",
|
|
|
|
"DSP 2 Capture Enum",
|
|
|
|
"DSP 3 Capture Enum",
|
|
|
|
"DSP 4 Capture Enum",
|
|
|
|
"DSP 5 Capture Enum",
|
|
|
|
"DSP 6 Capture Enum",
|
|
|
|
"DSP 7 Capture Enum",
|
|
|
|
"DSP 8 Capture Enum",
|
|
|
|
"DSP 9 Capture Enum",
|
|
|
|
"DSP A Capture Enum",
|
|
|
|
"DSP B Capture Enum",
|
|
|
|
"DSP C Capture Enum",
|
|
|
|
"DSP D Capture Enum",
|
|
|
|
"DSP E Capture Enum",
|
|
|
|
"DSP F Capture Enum",
|
|
|
|
/* These exist only on rev1 EMU1010 cards. */
|
|
|
|
"DSP 10 Capture Enum",
|
|
|
|
"DSP 11 Capture Enum",
|
|
|
|
"DSP 12 Capture Enum",
|
|
|
|
"DSP 13 Capture Enum",
|
|
|
|
"DSP 14 Capture Enum",
|
|
|
|
"DSP 15 Capture Enum",
|
|
|
|
};
|
2023-05-16 17:36:12 +08:00
|
|
|
static_assert(ARRAY_SIZE(emu1010_input_texts) <= NUM_INPUT_DESTS);
|
2023-05-16 17:36:05 +08:00
|
|
|
|
2023-05-16 17:36:03 +08:00
|
|
|
static const unsigned short emu1010_input_dst[] = {
|
2006-10-01 17:48:04 +08:00
|
|
|
EMU_DST_ALICE2_EMU32_0,
|
|
|
|
EMU_DST_ALICE2_EMU32_1,
|
|
|
|
EMU_DST_ALICE2_EMU32_2,
|
|
|
|
EMU_DST_ALICE2_EMU32_3,
|
|
|
|
EMU_DST_ALICE2_EMU32_4,
|
|
|
|
EMU_DST_ALICE2_EMU32_5,
|
|
|
|
EMU_DST_ALICE2_EMU32_6,
|
|
|
|
EMU_DST_ALICE2_EMU32_7,
|
|
|
|
EMU_DST_ALICE2_EMU32_8,
|
|
|
|
EMU_DST_ALICE2_EMU32_9,
|
|
|
|
EMU_DST_ALICE2_EMU32_A,
|
|
|
|
EMU_DST_ALICE2_EMU32_B,
|
|
|
|
EMU_DST_ALICE2_EMU32_C,
|
|
|
|
EMU_DST_ALICE2_EMU32_D,
|
|
|
|
EMU_DST_ALICE2_EMU32_E,
|
|
|
|
EMU_DST_ALICE2_EMU32_F,
|
2023-04-23 00:10:15 +08:00
|
|
|
/* These exist only on rev1 EMU1010 cards. */
|
2006-10-01 17:48:04 +08:00
|
|
|
EMU_DST_ALICE_I2S0_LEFT,
|
|
|
|
EMU_DST_ALICE_I2S0_RIGHT,
|
|
|
|
EMU_DST_ALICE_I2S1_LEFT,
|
|
|
|
EMU_DST_ALICE_I2S1_RIGHT,
|
|
|
|
EMU_DST_ALICE_I2S2_LEFT,
|
|
|
|
EMU_DST_ALICE_I2S2_RIGHT,
|
|
|
|
};
|
2023-05-16 17:36:05 +08:00
|
|
|
static_assert(ARRAY_SIZE(emu1010_input_dst) == ARRAY_SIZE(emu1010_input_texts));
|
2006-10-01 17:48:04 +08:00
|
|
|
|
ALSA: emu10k1: make E-MU I/O routing init data-driven
... and move it to the mixer init, as it's logically part of it.
As a side effect, this fixes the initial values of the input destination
mixer controls, which would have previously remained at "Silent" despite
different defaults. This didn't really matter, though, as ALSA state
restoration would hide that bug beyond first use.
Note that this completely does away with clearing the output routing
registers, as it was rather pointless - we just programmed the FPGA
(resetting it first if necessary), so everything is zeroed anyway
(that's documented by Xilinx, and as further evidence, some of the loops
terminated too early, and we didn't bother clearing the high channels of
the input routes at all, all with no observed adverse effects).
As a drive-by, this also fixes some capture channel defaults - any
EMU_SRC_*2 isn't a sensible value in 1x clock mode.
Signed-off-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Link: https://lore.kernel.org/r/20230516093612.3536508-7-oswald.buddenhagen@gmx.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-05-16 17:36:08 +08:00
|
|
|
static const unsigned short emu1010_input_dflt[] = {
|
|
|
|
EMU_SRC_DOCK_MIC_A1,
|
|
|
|
EMU_SRC_DOCK_MIC_B1,
|
|
|
|
EMU_SRC_HAMOA_ADC_LEFT1,
|
|
|
|
EMU_SRC_HAMOA_ADC_RIGHT1,
|
|
|
|
EMU_SRC_DOCK_ADC1_LEFT1,
|
|
|
|
EMU_SRC_DOCK_ADC1_RIGHT1,
|
|
|
|
EMU_SRC_DOCK_ADC2_LEFT1,
|
|
|
|
EMU_SRC_DOCK_ADC2_RIGHT1,
|
|
|
|
/* Pavel Hofman - setting defaults for all capture channels.
|
|
|
|
* Defaults only, users will set their own values anyways, let's
|
|
|
|
* just copy/paste. */
|
|
|
|
EMU_SRC_DOCK_MIC_A1,
|
|
|
|
EMU_SRC_DOCK_MIC_B1,
|
|
|
|
EMU_SRC_HAMOA_ADC_LEFT1,
|
|
|
|
EMU_SRC_HAMOA_ADC_RIGHT1,
|
|
|
|
EMU_SRC_DOCK_ADC1_LEFT1,
|
|
|
|
EMU_SRC_DOCK_ADC1_RIGHT1,
|
|
|
|
EMU_SRC_DOCK_ADC2_LEFT1,
|
|
|
|
EMU_SRC_DOCK_ADC2_RIGHT1,
|
|
|
|
|
|
|
|
EMU_SRC_DOCK_ADC1_LEFT1,
|
|
|
|
EMU_SRC_DOCK_ADC1_RIGHT1,
|
|
|
|
EMU_SRC_DOCK_ADC2_LEFT1,
|
|
|
|
EMU_SRC_DOCK_ADC2_RIGHT1,
|
|
|
|
EMU_SRC_DOCK_ADC3_LEFT1,
|
|
|
|
EMU_SRC_DOCK_ADC3_RIGHT1,
|
|
|
|
};
|
|
|
|
static_assert(ARRAY_SIZE(emu1010_input_dflt) == ARRAY_SIZE(emu1010_input_dst));
|
|
|
|
|
2023-05-16 17:36:11 +08:00
|
|
|
static const unsigned short emu0404_input_dflt[] = {
|
|
|
|
EMU_SRC_HAMOA_ADC_LEFT1,
|
|
|
|
EMU_SRC_HAMOA_ADC_RIGHT1,
|
|
|
|
EMU_SRC_SILENCE,
|
|
|
|
EMU_SRC_SILENCE,
|
|
|
|
EMU_SRC_SILENCE,
|
|
|
|
EMU_SRC_SILENCE,
|
|
|
|
EMU_SRC_SILENCE,
|
|
|
|
EMU_SRC_SILENCE,
|
|
|
|
EMU_SRC_HANA_SPDIF_LEFT1,
|
|
|
|
EMU_SRC_HANA_SPDIF_RIGHT1,
|
|
|
|
EMU_SRC_SILENCE,
|
|
|
|
EMU_SRC_SILENCE,
|
|
|
|
EMU_SRC_SILENCE,
|
|
|
|
EMU_SRC_SILENCE,
|
|
|
|
EMU_SRC_SILENCE,
|
|
|
|
EMU_SRC_SILENCE,
|
|
|
|
};
|
|
|
|
|
2023-05-16 17:36:06 +08:00
|
|
|
struct snd_emu1010_routing_info {
|
|
|
|
const char * const *src_texts;
|
2023-05-16 17:36:09 +08:00
|
|
|
const char * const *out_texts;
|
2023-05-16 17:36:06 +08:00
|
|
|
const unsigned short *src_regs;
|
|
|
|
const unsigned short *out_regs;
|
|
|
|
const unsigned short *in_regs;
|
ALSA: emu10k1: make E-MU I/O routing init data-driven
... and move it to the mixer init, as it's logically part of it.
As a side effect, this fixes the initial values of the input destination
mixer controls, which would have previously remained at "Silent" despite
different defaults. This didn't really matter, though, as ALSA state
restoration would hide that bug beyond first use.
Note that this completely does away with clearing the output routing
registers, as it was rather pointless - we just programmed the FPGA
(resetting it first if necessary), so everything is zeroed anyway
(that's documented by Xilinx, and as further evidence, some of the loops
terminated too early, and we didn't bother clearing the high channels of
the input routes at all, all with no observed adverse effects).
As a drive-by, this also fixes some capture channel defaults - any
EMU_SRC_*2 isn't a sensible value in 1x clock mode.
Signed-off-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Link: https://lore.kernel.org/r/20230516093612.3536508-7-oswald.buddenhagen@gmx.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-05-16 17:36:08 +08:00
|
|
|
const unsigned short *out_dflts;
|
|
|
|
const unsigned short *in_dflts;
|
2023-05-16 17:36:06 +08:00
|
|
|
unsigned n_srcs;
|
|
|
|
unsigned n_outs;
|
|
|
|
unsigned n_ins;
|
|
|
|
};
|
|
|
|
|
2023-05-18 20:38:26 +08:00
|
|
|
static const struct snd_emu1010_routing_info emu1010_routing_info[] = {
|
2023-05-16 17:36:06 +08:00
|
|
|
{
|
2023-05-16 17:36:11 +08:00
|
|
|
/* rev1 1010 */
|
2023-05-16 17:36:06 +08:00
|
|
|
.src_regs = emu1010_src_regs,
|
|
|
|
.src_texts = emu1010_src_texts,
|
|
|
|
.n_srcs = ARRAY_SIZE(emu1010_src_texts),
|
|
|
|
|
ALSA: emu10k1: make E-MU I/O routing init data-driven
... and move it to the mixer init, as it's logically part of it.
As a side effect, this fixes the initial values of the input destination
mixer controls, which would have previously remained at "Silent" despite
different defaults. This didn't really matter, though, as ALSA state
restoration would hide that bug beyond first use.
Note that this completely does away with clearing the output routing
registers, as it was rather pointless - we just programmed the FPGA
(resetting it first if necessary), so everything is zeroed anyway
(that's documented by Xilinx, and as further evidence, some of the loops
terminated too early, and we didn't bother clearing the high channels of
the input routes at all, all with no observed adverse effects).
As a drive-by, this also fixes some capture channel defaults - any
EMU_SRC_*2 isn't a sensible value in 1x clock mode.
Signed-off-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Link: https://lore.kernel.org/r/20230516093612.3536508-7-oswald.buddenhagen@gmx.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-05-16 17:36:08 +08:00
|
|
|
.out_dflts = emu1010_output_dflt,
|
2023-05-16 17:36:06 +08:00
|
|
|
.out_regs = emu1010_output_dst,
|
2023-05-16 17:36:09 +08:00
|
|
|
.out_texts = emu1010_output_texts,
|
2023-05-16 17:36:06 +08:00
|
|
|
.n_outs = ARRAY_SIZE(emu1010_output_dst),
|
|
|
|
|
ALSA: emu10k1: make E-MU I/O routing init data-driven
... and move it to the mixer init, as it's logically part of it.
As a side effect, this fixes the initial values of the input destination
mixer controls, which would have previously remained at "Silent" despite
different defaults. This didn't really matter, though, as ALSA state
restoration would hide that bug beyond first use.
Note that this completely does away with clearing the output routing
registers, as it was rather pointless - we just programmed the FPGA
(resetting it first if necessary), so everything is zeroed anyway
(that's documented by Xilinx, and as further evidence, some of the loops
terminated too early, and we didn't bother clearing the high channels of
the input routes at all, all with no observed adverse effects).
As a drive-by, this also fixes some capture channel defaults - any
EMU_SRC_*2 isn't a sensible value in 1x clock mode.
Signed-off-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Link: https://lore.kernel.org/r/20230516093612.3536508-7-oswald.buddenhagen@gmx.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-05-16 17:36:08 +08:00
|
|
|
.in_dflts = emu1010_input_dflt,
|
2023-05-16 17:36:06 +08:00
|
|
|
.in_regs = emu1010_input_dst,
|
|
|
|
.n_ins = ARRAY_SIZE(emu1010_input_dst),
|
|
|
|
},
|
2023-05-16 17:36:10 +08:00
|
|
|
{
|
|
|
|
/* rev2 1010 */
|
|
|
|
.src_regs = emu1010b_src_regs,
|
|
|
|
.src_texts = emu1010b_src_texts,
|
|
|
|
.n_srcs = ARRAY_SIZE(emu1010b_src_texts),
|
|
|
|
|
|
|
|
.out_dflts = emu1010b_output_dflt,
|
|
|
|
.out_regs = emu1010b_output_dst,
|
|
|
|
.out_texts = snd_emu1010b_output_texts,
|
|
|
|
.n_outs = ARRAY_SIZE(emu1010b_output_dst),
|
|
|
|
|
|
|
|
.in_dflts = emu1010_input_dflt,
|
|
|
|
.in_regs = emu1010_input_dst,
|
|
|
|
.n_ins = ARRAY_SIZE(emu1010_input_dst) - 6,
|
|
|
|
},
|
2023-05-16 17:36:06 +08:00
|
|
|
{
|
|
|
|
/* 1616(m) cardbus */
|
|
|
|
.src_regs = emu1616_src_regs,
|
|
|
|
.src_texts = emu1616_src_texts,
|
|
|
|
.n_srcs = ARRAY_SIZE(emu1616_src_texts),
|
|
|
|
|
ALSA: emu10k1: make E-MU I/O routing init data-driven
... and move it to the mixer init, as it's logically part of it.
As a side effect, this fixes the initial values of the input destination
mixer controls, which would have previously remained at "Silent" despite
different defaults. This didn't really matter, though, as ALSA state
restoration would hide that bug beyond first use.
Note that this completely does away with clearing the output routing
registers, as it was rather pointless - we just programmed the FPGA
(resetting it first if necessary), so everything is zeroed anyway
(that's documented by Xilinx, and as further evidence, some of the loops
terminated too early, and we didn't bother clearing the high channels of
the input routes at all, all with no observed adverse effects).
As a drive-by, this also fixes some capture channel defaults - any
EMU_SRC_*2 isn't a sensible value in 1x clock mode.
Signed-off-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Link: https://lore.kernel.org/r/20230516093612.3536508-7-oswald.buddenhagen@gmx.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-05-16 17:36:08 +08:00
|
|
|
.out_dflts = emu1616_output_dflt,
|
2023-05-16 17:36:06 +08:00
|
|
|
.out_regs = emu1616_output_dst,
|
2023-05-16 17:36:09 +08:00
|
|
|
.out_texts = snd_emu1616_output_texts,
|
2023-05-16 17:36:06 +08:00
|
|
|
.n_outs = ARRAY_SIZE(emu1616_output_dst),
|
|
|
|
|
ALSA: emu10k1: make E-MU I/O routing init data-driven
... and move it to the mixer init, as it's logically part of it.
As a side effect, this fixes the initial values of the input destination
mixer controls, which would have previously remained at "Silent" despite
different defaults. This didn't really matter, though, as ALSA state
restoration would hide that bug beyond first use.
Note that this completely does away with clearing the output routing
registers, as it was rather pointless - we just programmed the FPGA
(resetting it first if necessary), so everything is zeroed anyway
(that's documented by Xilinx, and as further evidence, some of the loops
terminated too early, and we didn't bother clearing the high channels of
the input routes at all, all with no observed adverse effects).
As a drive-by, this also fixes some capture channel defaults - any
EMU_SRC_*2 isn't a sensible value in 1x clock mode.
Signed-off-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Link: https://lore.kernel.org/r/20230516093612.3536508-7-oswald.buddenhagen@gmx.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-05-16 17:36:08 +08:00
|
|
|
.in_dflts = emu1010_input_dflt,
|
2023-05-16 17:36:06 +08:00
|
|
|
.in_regs = emu1010_input_dst,
|
|
|
|
.n_ins = ARRAY_SIZE(emu1010_input_dst) - 6,
|
|
|
|
},
|
2023-05-16 17:36:11 +08:00
|
|
|
{
|
|
|
|
/* 0404 */
|
|
|
|
.src_regs = emu0404_src_regs,
|
|
|
|
.src_texts = emu0404_src_texts,
|
|
|
|
.n_srcs = ARRAY_SIZE(emu0404_src_texts),
|
|
|
|
|
|
|
|
.out_dflts = emu0404_output_dflt,
|
|
|
|
.out_regs = emu0404_output_dst,
|
|
|
|
.out_texts = snd_emu0404_output_texts,
|
|
|
|
.n_outs = ARRAY_SIZE(emu0404_output_dflt),
|
|
|
|
|
|
|
|
.in_dflts = emu0404_input_dflt,
|
|
|
|
.in_regs = emu1010_input_dst,
|
|
|
|
.n_ins = ARRAY_SIZE(emu1010_input_dst) - 6,
|
|
|
|
},
|
2023-05-16 17:36:06 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static unsigned emu1010_idx(struct snd_emu10k1 *emu)
|
|
|
|
{
|
2023-05-16 17:36:11 +08:00
|
|
|
return emu->card_capabilities->emu_model - 1;
|
2023-05-16 17:36:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void snd_emu1010_output_source_apply(struct snd_emu10k1 *emu,
|
|
|
|
int channel, int src)
|
|
|
|
{
|
|
|
|
const struct snd_emu1010_routing_info *emu_ri =
|
|
|
|
&emu1010_routing_info[emu1010_idx(emu)];
|
|
|
|
|
|
|
|
snd_emu1010_fpga_link_dst_src_write(emu,
|
|
|
|
emu_ri->out_regs[channel], emu_ri->src_regs[src]);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void snd_emu1010_input_source_apply(struct snd_emu10k1 *emu,
|
|
|
|
int channel, int src)
|
|
|
|
{
|
|
|
|
const struct snd_emu1010_routing_info *emu_ri =
|
|
|
|
&emu1010_routing_info[emu1010_idx(emu)];
|
|
|
|
|
|
|
|
snd_emu1010_fpga_link_dst_src_write(emu,
|
|
|
|
emu_ri->in_regs[channel], emu_ri->src_regs[src]);
|
|
|
|
}
|
|
|
|
|
ALSA: emu10k1: make E-MU I/O routing init data-driven
... and move it to the mixer init, as it's logically part of it.
As a side effect, this fixes the initial values of the input destination
mixer controls, which would have previously remained at "Silent" despite
different defaults. This didn't really matter, though, as ALSA state
restoration would hide that bug beyond first use.
Note that this completely does away with clearing the output routing
registers, as it was rather pointless - we just programmed the FPGA
(resetting it first if necessary), so everything is zeroed anyway
(that's documented by Xilinx, and as further evidence, some of the loops
terminated too early, and we didn't bother clearing the high channels of
the input routes at all, all with no observed adverse effects).
As a drive-by, this also fixes some capture channel defaults - any
EMU_SRC_*2 isn't a sensible value in 1x clock mode.
Signed-off-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Link: https://lore.kernel.org/r/20230516093612.3536508-7-oswald.buddenhagen@gmx.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-05-16 17:36:08 +08:00
|
|
|
static void snd_emu1010_apply_sources(struct snd_emu10k1 *emu)
|
|
|
|
{
|
|
|
|
const struct snd_emu1010_routing_info *emu_ri =
|
|
|
|
&emu1010_routing_info[emu1010_idx(emu)];
|
|
|
|
|
|
|
|
for (unsigned i = 0; i < emu_ri->n_outs; i++)
|
|
|
|
snd_emu1010_output_source_apply(
|
|
|
|
emu, i, emu->emu1010.output_source[i]);
|
|
|
|
for (unsigned i = 0; i < emu_ri->n_ins; i++)
|
|
|
|
snd_emu1010_input_source_apply(
|
|
|
|
emu, i, emu->emu1010.input_source[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
static u8 emu1010_map_source(const struct snd_emu1010_routing_info *emu_ri,
|
|
|
|
unsigned val)
|
|
|
|
{
|
|
|
|
for (unsigned i = 0; i < emu_ri->n_srcs; i++)
|
|
|
|
if (val == emu_ri->src_regs[i])
|
|
|
|
return i;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-12-13 23:27:13 +08:00
|
|
|
static int snd_emu1010_input_output_source_info(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_info *uinfo)
|
2006-10-01 17:48:04 +08:00
|
|
|
{
|
2007-12-13 23:27:13 +08:00
|
|
|
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
|
2023-05-16 17:36:06 +08:00
|
|
|
const struct snd_emu1010_routing_info *emu_ri =
|
|
|
|
&emu1010_routing_info[emu1010_idx(emu)];
|
2007-12-13 23:27:13 +08:00
|
|
|
|
2023-05-16 17:36:06 +08:00
|
|
|
return snd_ctl_enum_info(uinfo, 1, emu_ri->n_srcs, emu_ri->src_texts);
|
2006-10-01 17:48:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int snd_emu1010_output_source_get(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
|
|
|
{
|
|
|
|
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
|
2023-05-16 17:36:06 +08:00
|
|
|
const struct snd_emu1010_routing_info *emu_ri =
|
|
|
|
&emu1010_routing_info[emu1010_idx(emu)];
|
|
|
|
unsigned channel = kcontrol->private_value;
|
2006-10-01 17:48:04 +08:00
|
|
|
|
2023-05-16 17:36:06 +08:00
|
|
|
if (channel >= emu_ri->n_outs)
|
2007-11-12 22:55:19 +08:00
|
|
|
return -EINVAL;
|
2006-10-01 17:48:04 +08:00
|
|
|
ucontrol->value.enumerated.item[0] = emu->emu1010.output_source[channel];
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int snd_emu1010_output_source_put(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
|
|
|
{
|
|
|
|
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
|
2023-05-16 17:36:06 +08:00
|
|
|
const struct snd_emu1010_routing_info *emu_ri =
|
|
|
|
&emu1010_routing_info[emu1010_idx(emu)];
|
|
|
|
unsigned val = ucontrol->value.enumerated.item[0];
|
|
|
|
unsigned channel = kcontrol->private_value;
|
|
|
|
int change;
|
2006-10-01 17:48:04 +08:00
|
|
|
|
2023-05-16 17:36:06 +08:00
|
|
|
if (val >= emu_ri->n_srcs)
|
2007-11-15 20:16:02 +08:00
|
|
|
return -EINVAL;
|
2023-05-16 17:36:06 +08:00
|
|
|
if (channel >= emu_ri->n_outs)
|
2007-11-12 22:55:19 +08:00
|
|
|
return -EINVAL;
|
2023-05-16 17:36:06 +08:00
|
|
|
change = (emu->emu1010.output_source[channel] != val);
|
|
|
|
if (change) {
|
|
|
|
emu->emu1010.output_source[channel] = val;
|
|
|
|
snd_emu1010_output_source_apply(emu, channel, val);
|
|
|
|
}
|
|
|
|
return change;
|
2006-10-01 17:48:04 +08:00
|
|
|
}
|
|
|
|
|
2023-05-16 17:36:05 +08:00
|
|
|
static const struct snd_kcontrol_new emu1010_output_source_ctl = {
|
|
|
|
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
|
|
|
|
.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
|
|
|
|
.info = snd_emu1010_input_output_source_info,
|
|
|
|
.get = snd_emu1010_output_source_get,
|
|
|
|
.put = snd_emu1010_output_source_put
|
|
|
|
};
|
|
|
|
|
2006-10-01 17:48:04 +08:00
|
|
|
static int snd_emu1010_input_source_get(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
|
|
|
{
|
|
|
|
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
|
2023-05-16 17:36:06 +08:00
|
|
|
const struct snd_emu1010_routing_info *emu_ri =
|
|
|
|
&emu1010_routing_info[emu1010_idx(emu)];
|
|
|
|
unsigned channel = kcontrol->private_value;
|
2006-10-01 17:48:04 +08:00
|
|
|
|
2023-05-16 17:36:06 +08:00
|
|
|
if (channel >= emu_ri->n_ins)
|
2007-11-12 22:55:19 +08:00
|
|
|
return -EINVAL;
|
2006-10-01 17:48:04 +08:00
|
|
|
ucontrol->value.enumerated.item[0] = emu->emu1010.input_source[channel];
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int snd_emu1010_input_source_put(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
|
|
|
{
|
|
|
|
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
|
2023-05-16 17:36:06 +08:00
|
|
|
const struct snd_emu1010_routing_info *emu_ri =
|
|
|
|
&emu1010_routing_info[emu1010_idx(emu)];
|
|
|
|
unsigned val = ucontrol->value.enumerated.item[0];
|
|
|
|
unsigned channel = kcontrol->private_value;
|
|
|
|
int change;
|
2006-10-01 17:48:04 +08:00
|
|
|
|
2023-05-16 17:36:06 +08:00
|
|
|
if (val >= emu_ri->n_srcs)
|
2007-11-15 20:16:02 +08:00
|
|
|
return -EINVAL;
|
2023-05-16 17:36:06 +08:00
|
|
|
if (channel >= emu_ri->n_ins)
|
2007-11-12 22:55:19 +08:00
|
|
|
return -EINVAL;
|
2023-05-16 17:36:06 +08:00
|
|
|
change = (emu->emu1010.input_source[channel] != val);
|
|
|
|
if (change) {
|
|
|
|
emu->emu1010.input_source[channel] = val;
|
|
|
|
snd_emu1010_input_source_apply(emu, channel, val);
|
|
|
|
}
|
|
|
|
return change;
|
2006-10-01 17:48:04 +08:00
|
|
|
}
|
|
|
|
|
2023-05-16 17:36:05 +08:00
|
|
|
static const struct snd_kcontrol_new emu1010_input_source_ctl = {
|
|
|
|
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
|
|
|
|
.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
|
|
|
|
.info = snd_emu1010_input_output_source_info,
|
|
|
|
.get = snd_emu1010_input_source_get,
|
|
|
|
.put = snd_emu1010_input_source_put
|
2006-10-01 17:48:04 +08:00
|
|
|
};
|
|
|
|
|
2023-05-16 17:36:09 +08:00
|
|
|
static int add_emu1010_source_mixers(struct snd_emu10k1 *emu)
|
|
|
|
{
|
|
|
|
const struct snd_emu1010_routing_info *emu_ri =
|
|
|
|
&emu1010_routing_info[emu1010_idx(emu)];
|
|
|
|
int err;
|
|
|
|
|
|
|
|
err = add_ctls(emu, &emu1010_output_source_ctl,
|
|
|
|
emu_ri->out_texts, emu_ri->n_outs);
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
err = add_ctls(emu, &emu1010_input_source_ctl,
|
|
|
|
emu1010_input_texts, emu_ri->n_ins);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2007-12-13 23:27:13 +08:00
|
|
|
|
2023-05-16 17:36:05 +08:00
|
|
|
static const char * const snd_emu1010_adc_pads[] = {
|
2023-05-16 17:36:10 +08:00
|
|
|
"ADC1 14dB PAD 0202 Capture Switch",
|
2023-05-16 17:36:05 +08:00
|
|
|
"ADC1 14dB PAD Audio Dock Capture Switch",
|
|
|
|
"ADC2 14dB PAD Audio Dock Capture Switch",
|
|
|
|
"ADC3 14dB PAD Audio Dock Capture Switch",
|
2007-12-13 23:27:13 +08:00
|
|
|
};
|
|
|
|
|
2023-05-16 17:36:05 +08:00
|
|
|
static const unsigned short snd_emu1010_adc_pad_regs[] = {
|
2023-05-16 17:36:10 +08:00
|
|
|
EMU_HANA_0202_ADC_PAD1,
|
2023-05-16 17:36:05 +08:00
|
|
|
EMU_HANA_DOCK_ADC_PAD1,
|
|
|
|
EMU_HANA_DOCK_ADC_PAD2,
|
|
|
|
EMU_HANA_DOCK_ADC_PAD3,
|
2006-10-10 06:08:00 +08:00
|
|
|
};
|
|
|
|
|
2007-07-23 21:42:26 +08:00
|
|
|
#define snd_emu1010_adc_pads_info snd_ctl_boolean_mono_info
|
2006-10-10 06:08:00 +08:00
|
|
|
|
|
|
|
static int snd_emu1010_adc_pads_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
|
|
|
|
{
|
|
|
|
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
|
2023-05-16 17:36:05 +08:00
|
|
|
unsigned int mask = snd_emu1010_adc_pad_regs[kcontrol->private_value];
|
|
|
|
|
2006-10-10 06:08:00 +08:00
|
|
|
ucontrol->value.integer.value[0] = (emu->emu1010.adc_pads & mask) ? 1 : 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int snd_emu1010_adc_pads_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
|
|
|
|
{
|
|
|
|
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
|
2023-05-16 17:36:05 +08:00
|
|
|
unsigned int mask = snd_emu1010_adc_pad_regs[kcontrol->private_value];
|
2006-10-10 06:08:00 +08:00
|
|
|
unsigned int val, cache;
|
2023-07-12 22:57:48 +08:00
|
|
|
int change;
|
|
|
|
|
2006-10-10 06:08:00 +08:00
|
|
|
val = ucontrol->value.integer.value[0];
|
|
|
|
cache = emu->emu1010.adc_pads;
|
|
|
|
if (val == 1)
|
|
|
|
cache = cache | mask;
|
|
|
|
else
|
|
|
|
cache = cache & ~mask;
|
2023-07-12 22:57:48 +08:00
|
|
|
change = (cache != emu->emu1010.adc_pads);
|
|
|
|
if (change) {
|
2006-10-10 06:08:00 +08:00
|
|
|
snd_emu1010_fpga_write(emu, EMU_HANA_ADC_PADS, cache );
|
|
|
|
emu->emu1010.adc_pads = cache;
|
|
|
|
}
|
|
|
|
|
2023-07-12 22:57:48 +08:00
|
|
|
return change;
|
2006-10-10 06:08:00 +08:00
|
|
|
}
|
|
|
|
|
2023-05-16 17:36:05 +08:00
|
|
|
static const struct snd_kcontrol_new emu1010_adc_pads_ctl = {
|
|
|
|
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
|
|
|
|
.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
|
|
|
|
.info = snd_emu1010_adc_pads_info,
|
|
|
|
.get = snd_emu1010_adc_pads_get,
|
|
|
|
.put = snd_emu1010_adc_pads_put
|
|
|
|
};
|
2006-10-10 06:08:00 +08:00
|
|
|
|
|
|
|
|
2023-05-16 17:36:05 +08:00
|
|
|
static const char * const snd_emu1010_dac_pads[] = {
|
2023-05-16 17:36:10 +08:00
|
|
|
"DAC1 0202 14dB PAD Playback Switch",
|
2023-05-16 17:36:05 +08:00
|
|
|
"DAC1 Audio Dock 14dB PAD Playback Switch",
|
|
|
|
"DAC2 Audio Dock 14dB PAD Playback Switch",
|
|
|
|
"DAC3 Audio Dock 14dB PAD Playback Switch",
|
|
|
|
"DAC4 Audio Dock 14dB PAD Playback Switch",
|
|
|
|
};
|
2006-10-10 06:08:00 +08:00
|
|
|
|
2023-05-16 17:36:05 +08:00
|
|
|
static const unsigned short snd_emu1010_dac_regs[] = {
|
2023-05-16 17:36:10 +08:00
|
|
|
EMU_HANA_0202_DAC_PAD1,
|
2023-05-16 17:36:05 +08:00
|
|
|
EMU_HANA_DOCK_DAC_PAD1,
|
|
|
|
EMU_HANA_DOCK_DAC_PAD2,
|
|
|
|
EMU_HANA_DOCK_DAC_PAD3,
|
|
|
|
EMU_HANA_DOCK_DAC_PAD4,
|
2006-10-10 06:08:00 +08:00
|
|
|
};
|
|
|
|
|
2007-07-23 21:42:26 +08:00
|
|
|
#define snd_emu1010_dac_pads_info snd_ctl_boolean_mono_info
|
2006-10-10 06:08:00 +08:00
|
|
|
|
|
|
|
static int snd_emu1010_dac_pads_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
|
|
|
|
{
|
|
|
|
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
|
2023-05-16 17:36:05 +08:00
|
|
|
unsigned int mask = snd_emu1010_dac_regs[kcontrol->private_value];
|
|
|
|
|
2006-10-10 06:08:00 +08:00
|
|
|
ucontrol->value.integer.value[0] = (emu->emu1010.dac_pads & mask) ? 1 : 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int snd_emu1010_dac_pads_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
|
|
|
|
{
|
|
|
|
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
|
2023-05-16 17:36:05 +08:00
|
|
|
unsigned int mask = snd_emu1010_dac_regs[kcontrol->private_value];
|
2006-10-10 06:08:00 +08:00
|
|
|
unsigned int val, cache;
|
2023-05-16 17:36:07 +08:00
|
|
|
int change;
|
|
|
|
|
2006-10-10 06:08:00 +08:00
|
|
|
val = ucontrol->value.integer.value[0];
|
|
|
|
cache = emu->emu1010.dac_pads;
|
|
|
|
if (val == 1)
|
|
|
|
cache = cache | mask;
|
|
|
|
else
|
|
|
|
cache = cache & ~mask;
|
2023-05-16 17:36:07 +08:00
|
|
|
change = (cache != emu->emu1010.dac_pads);
|
|
|
|
if (change) {
|
2006-10-10 06:08:00 +08:00
|
|
|
snd_emu1010_fpga_write(emu, EMU_HANA_DAC_PADS, cache );
|
|
|
|
emu->emu1010.dac_pads = cache;
|
|
|
|
}
|
|
|
|
|
2023-05-16 17:36:07 +08:00
|
|
|
return change;
|
2006-10-10 06:08:00 +08:00
|
|
|
}
|
|
|
|
|
2023-05-16 17:36:05 +08:00
|
|
|
static const struct snd_kcontrol_new emu1010_dac_pads_ctl = {
|
|
|
|
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
|
|
|
|
.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
|
|
|
|
.info = snd_emu1010_dac_pads_info,
|
|
|
|
.get = snd_emu1010_dac_pads_get,
|
|
|
|
.put = snd_emu1010_dac_pads_put
|
2006-10-01 17:48:04 +08:00
|
|
|
};
|
|
|
|
|
2006-10-11 01:08:45 +08:00
|
|
|
|
2023-05-16 17:36:09 +08:00
|
|
|
struct snd_emu1010_pads_info {
|
|
|
|
const char * const *adc_ctls, * const *dac_ctls;
|
|
|
|
unsigned n_adc_ctls, n_dac_ctls;
|
|
|
|
};
|
|
|
|
|
2023-05-18 20:38:26 +08:00
|
|
|
static const struct snd_emu1010_pads_info emu1010_pads_info[] = {
|
2023-05-16 17:36:09 +08:00
|
|
|
{
|
2023-05-16 17:36:11 +08:00
|
|
|
/* rev1 1010 */
|
2023-05-16 17:36:09 +08:00
|
|
|
.adc_ctls = snd_emu1010_adc_pads,
|
|
|
|
.n_adc_ctls = ARRAY_SIZE(snd_emu1010_adc_pads),
|
|
|
|
.dac_ctls = snd_emu1010_dac_pads,
|
|
|
|
.n_dac_ctls = ARRAY_SIZE(snd_emu1010_dac_pads),
|
|
|
|
},
|
|
|
|
{
|
2023-05-16 17:36:10 +08:00
|
|
|
/* rev2 1010 */
|
2023-05-16 17:36:09 +08:00
|
|
|
.adc_ctls = snd_emu1010_adc_pads,
|
2023-05-16 17:36:10 +08:00
|
|
|
.n_adc_ctls = ARRAY_SIZE(snd_emu1010_adc_pads) - 1,
|
2023-05-16 17:36:09 +08:00
|
|
|
.dac_ctls = snd_emu1010_dac_pads,
|
2023-05-16 17:36:10 +08:00
|
|
|
.n_dac_ctls = ARRAY_SIZE(snd_emu1010_dac_pads) - 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
/* 1616(m) cardbus */
|
|
|
|
.adc_ctls = snd_emu1010_adc_pads + 1,
|
|
|
|
.n_adc_ctls = ARRAY_SIZE(snd_emu1010_adc_pads) - 2,
|
|
|
|
.dac_ctls = snd_emu1010_dac_pads + 1,
|
2023-05-16 17:36:09 +08:00
|
|
|
.n_dac_ctls = ARRAY_SIZE(snd_emu1010_dac_pads) - 2,
|
|
|
|
},
|
2023-05-16 17:36:11 +08:00
|
|
|
{
|
|
|
|
/* 0404 */
|
|
|
|
.adc_ctls = NULL,
|
|
|
|
.n_adc_ctls = 0,
|
|
|
|
.dac_ctls = NULL,
|
|
|
|
.n_dac_ctls = 0,
|
|
|
|
},
|
2023-05-16 17:36:09 +08:00
|
|
|
};
|
|
|
|
|
2023-06-13 03:13:18 +08:00
|
|
|
static const char * const emu1010_clock_texts[] = {
|
|
|
|
"44100", "48000", "SPDIF", "ADAT", "Dock", "BNC"
|
|
|
|
};
|
|
|
|
|
|
|
|
static const u8 emu1010_clock_vals[] = {
|
|
|
|
EMU_HANA_WCLOCK_INT_44_1K,
|
|
|
|
EMU_HANA_WCLOCK_INT_48K,
|
|
|
|
EMU_HANA_WCLOCK_HANA_SPDIF_IN,
|
|
|
|
EMU_HANA_WCLOCK_HANA_ADAT_IN,
|
|
|
|
EMU_HANA_WCLOCK_2ND_HANA,
|
|
|
|
EMU_HANA_WCLOCK_SYNC_BNC,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char * const emu0404_clock_texts[] = {
|
|
|
|
"44100", "48000", "SPDIF", "BNC"
|
|
|
|
};
|
|
|
|
|
|
|
|
static const u8 emu0404_clock_vals[] = {
|
|
|
|
EMU_HANA_WCLOCK_INT_44_1K,
|
|
|
|
EMU_HANA_WCLOCK_INT_48K,
|
|
|
|
EMU_HANA_WCLOCK_HANA_SPDIF_IN,
|
|
|
|
EMU_HANA_WCLOCK_SYNC_BNC,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct snd_emu1010_clock_info {
|
|
|
|
const char * const *texts;
|
|
|
|
const u8 *vals;
|
|
|
|
unsigned num;
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct snd_emu1010_clock_info emu1010_clock_info[] = {
|
|
|
|
{
|
|
|
|
// rev1 1010
|
|
|
|
.texts = emu1010_clock_texts,
|
|
|
|
.vals = emu1010_clock_vals,
|
|
|
|
.num = ARRAY_SIZE(emu1010_clock_vals),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// rev2 1010
|
|
|
|
.texts = emu1010_clock_texts,
|
|
|
|
.vals = emu1010_clock_vals,
|
|
|
|
.num = ARRAY_SIZE(emu1010_clock_vals) - 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// 1616(m) CardBus
|
|
|
|
.texts = emu1010_clock_texts,
|
|
|
|
// TODO: determine what is actually available.
|
|
|
|
// Pedantically, *every* source comes from the 2nd FPGA, as the
|
|
|
|
// card itself has no own (digital) audio ports. The user manual
|
|
|
|
// claims that ADAT and S/PDIF clock sources are separate, which
|
|
|
|
// can mean two things: either E-MU mapped the dock's sources to
|
|
|
|
// the primary ones, or they determine the meaning of the "Dock"
|
|
|
|
// source depending on how the ports are actually configured
|
|
|
|
// (which the 2nd FPGA must be doing anyway).
|
|
|
|
.vals = emu1010_clock_vals,
|
|
|
|
.num = ARRAY_SIZE(emu1010_clock_vals),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// 0404
|
|
|
|
.texts = emu0404_clock_texts,
|
|
|
|
.vals = emu0404_clock_vals,
|
|
|
|
.num = ARRAY_SIZE(emu0404_clock_vals),
|
|
|
|
},
|
|
|
|
};
|
2023-05-16 17:36:09 +08:00
|
|
|
|
2023-06-13 03:13:17 +08:00
|
|
|
static int snd_emu1010_clock_source_info(struct snd_kcontrol *kcontrol,
|
2006-10-11 01:08:45 +08:00
|
|
|
struct snd_ctl_elem_info *uinfo)
|
|
|
|
{
|
2023-06-13 03:13:18 +08:00
|
|
|
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
|
|
|
|
const struct snd_emu1010_clock_info *emu_ci =
|
|
|
|
&emu1010_clock_info[emu1010_idx(emu)];
|
2007-07-24 03:30:22 +08:00
|
|
|
|
2023-06-13 03:13:18 +08:00
|
|
|
return snd_ctl_enum_info(uinfo, 1, emu_ci->num, emu_ci->texts);
|
2006-10-11 01:08:45 +08:00
|
|
|
}
|
|
|
|
|
2023-06-13 03:13:17 +08:00
|
|
|
static int snd_emu1010_clock_source_get(struct snd_kcontrol *kcontrol,
|
2006-10-11 01:08:45 +08:00
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
|
|
|
{
|
|
|
|
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
|
|
|
|
|
2023-06-13 03:13:17 +08:00
|
|
|
ucontrol->value.enumerated.item[0] = emu->emu1010.clock_source;
|
2006-10-11 01:08:45 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2023-06-13 03:13:17 +08:00
|
|
|
static int snd_emu1010_clock_source_put(struct snd_kcontrol *kcontrol,
|
2006-10-11 01:08:45 +08:00
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
|
|
|
{
|
|
|
|
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
|
2023-06-13 03:13:18 +08:00
|
|
|
const struct snd_emu1010_clock_info *emu_ci =
|
|
|
|
&emu1010_clock_info[emu1010_idx(emu)];
|
2006-10-11 01:08:45 +08:00
|
|
|
unsigned int val;
|
|
|
|
int change = 0;
|
|
|
|
|
|
|
|
val = ucontrol->value.enumerated.item[0] ;
|
2023-06-13 03:13:18 +08:00
|
|
|
if (val >= emu_ci->num)
|
2007-11-12 22:55:19 +08:00
|
|
|
return -EINVAL;
|
2023-07-16 00:07:38 +08:00
|
|
|
spin_lock_irq(&emu->reg_lock);
|
2023-06-13 03:13:17 +08:00
|
|
|
change = (emu->emu1010.clock_source != val);
|
2006-10-11 01:08:45 +08:00
|
|
|
if (change) {
|
2023-06-13 03:13:17 +08:00
|
|
|
emu->emu1010.clock_source = val;
|
2023-06-13 03:13:18 +08:00
|
|
|
emu->emu1010.wclock = emu_ci->vals[val];
|
2023-07-16 00:07:38 +08:00
|
|
|
snd_emu1010_update_clock(emu);
|
2023-06-13 03:13:18 +08:00
|
|
|
|
|
|
|
snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, EMU_MUTE);
|
|
|
|
snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK, emu->emu1010.wclock);
|
2023-07-16 00:07:38 +08:00
|
|
|
spin_unlock_irq(&emu->reg_lock);
|
|
|
|
|
2023-06-13 03:13:18 +08:00
|
|
|
msleep(10); // Allow DLL to settle
|
|
|
|
snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, EMU_UNMUTE);
|
2023-07-16 00:07:38 +08:00
|
|
|
} else {
|
|
|
|
spin_unlock_irq(&emu->reg_lock);
|
2006-10-11 01:08:45 +08:00
|
|
|
}
|
2023-06-13 03:13:18 +08:00
|
|
|
return change;
|
2006-10-11 01:08:45 +08:00
|
|
|
}
|
|
|
|
|
2023-06-13 03:13:17 +08:00
|
|
|
static const struct snd_kcontrol_new snd_emu1010_clock_source =
|
2006-10-11 01:08:45 +08:00
|
|
|
{
|
2023-06-13 03:13:17 +08:00
|
|
|
.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
|
|
|
|
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
|
|
|
|
.name = "Clock Source",
|
|
|
|
.count = 1,
|
|
|
|
.info = snd_emu1010_clock_source_info,
|
|
|
|
.get = snd_emu1010_clock_source_get,
|
|
|
|
.put = snd_emu1010_clock_source_put
|
|
|
|
};
|
|
|
|
|
|
|
|
static int snd_emu1010_clock_fallback_info(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_info *uinfo)
|
|
|
|
{
|
|
|
|
static const char * const texts[2] = {
|
|
|
|
"44100", "48000"
|
|
|
|
};
|
|
|
|
|
|
|
|
return snd_ctl_enum_info(uinfo, 1, 2, texts);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int snd_emu1010_clock_fallback_get(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
|
|
|
{
|
|
|
|
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
|
|
|
|
|
|
|
|
ucontrol->value.enumerated.item[0] = emu->emu1010.clock_fallback;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int snd_emu1010_clock_fallback_put(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
|
|
|
{
|
|
|
|
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
|
|
|
|
unsigned int val = ucontrol->value.enumerated.item[0];
|
|
|
|
int change;
|
|
|
|
|
|
|
|
if (val >= 2)
|
|
|
|
return -EINVAL;
|
|
|
|
change = (emu->emu1010.clock_fallback != val);
|
|
|
|
if (change) {
|
|
|
|
emu->emu1010.clock_fallback = val;
|
|
|
|
snd_emu1010_fpga_write(emu, EMU_HANA_DEFCLOCK, 1 - val);
|
|
|
|
}
|
|
|
|
return change;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct snd_kcontrol_new snd_emu1010_clock_fallback =
|
|
|
|
{
|
|
|
|
.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
|
|
|
|
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
|
|
|
|
.name = "Clock Fallback",
|
|
|
|
.count = 1,
|
|
|
|
.info = snd_emu1010_clock_fallback_info,
|
|
|
|
.get = snd_emu1010_clock_fallback_get,
|
|
|
|
.put = snd_emu1010_clock_fallback_put
|
2006-10-11 01:08:45 +08:00
|
|
|
};
|
|
|
|
|
2015-04-12 00:00:19 +08:00
|
|
|
static int snd_emu1010_optical_out_info(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_info *uinfo)
|
|
|
|
{
|
|
|
|
static const char * const texts[2] = {
|
|
|
|
"SPDIF", "ADAT"
|
|
|
|
};
|
|
|
|
|
|
|
|
return snd_ctl_enum_info(uinfo, 1, 2, texts);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int snd_emu1010_optical_out_get(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
|
|
|
{
|
|
|
|
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
|
|
|
|
|
|
|
|
ucontrol->value.enumerated.item[0] = emu->emu1010.optical_out;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int snd_emu1010_optical_out_put(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
|
|
|
{
|
|
|
|
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
|
|
|
|
unsigned int val;
|
|
|
|
u32 tmp;
|
|
|
|
int change = 0;
|
|
|
|
|
|
|
|
val = ucontrol->value.enumerated.item[0];
|
|
|
|
/* Limit: uinfo->value.enumerated.items = 2; */
|
|
|
|
if (val >= 2)
|
|
|
|
return -EINVAL;
|
|
|
|
change = (emu->emu1010.optical_out != val);
|
|
|
|
if (change) {
|
|
|
|
emu->emu1010.optical_out = val;
|
2023-04-28 16:07:32 +08:00
|
|
|
tmp = (emu->emu1010.optical_in ? EMU_HANA_OPTICAL_IN_ADAT : EMU_HANA_OPTICAL_IN_SPDIF) |
|
|
|
|
(emu->emu1010.optical_out ? EMU_HANA_OPTICAL_OUT_ADAT : EMU_HANA_OPTICAL_OUT_SPDIF);
|
2015-04-12 00:00:19 +08:00
|
|
|
snd_emu1010_fpga_write(emu, EMU_HANA_OPTICAL_TYPE, tmp);
|
|
|
|
}
|
|
|
|
return change;
|
|
|
|
}
|
|
|
|
|
2017-02-20 02:48:09 +08:00
|
|
|
static const struct snd_kcontrol_new snd_emu1010_optical_out = {
|
2015-04-12 00:00:19 +08:00
|
|
|
.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
|
|
|
|
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
|
|
|
|
.name = "Optical Output Mode",
|
|
|
|
.count = 1,
|
|
|
|
.info = snd_emu1010_optical_out_info,
|
|
|
|
.get = snd_emu1010_optical_out_get,
|
|
|
|
.put = snd_emu1010_optical_out_put
|
|
|
|
};
|
|
|
|
|
|
|
|
static int snd_emu1010_optical_in_info(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_info *uinfo)
|
|
|
|
{
|
|
|
|
static const char * const texts[2] = {
|
|
|
|
"SPDIF", "ADAT"
|
|
|
|
};
|
|
|
|
|
|
|
|
return snd_ctl_enum_info(uinfo, 1, 2, texts);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int snd_emu1010_optical_in_get(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
|
|
|
{
|
|
|
|
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
|
|
|
|
|
|
|
|
ucontrol->value.enumerated.item[0] = emu->emu1010.optical_in;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int snd_emu1010_optical_in_put(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
|
|
|
{
|
|
|
|
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
|
|
|
|
unsigned int val;
|
|
|
|
u32 tmp;
|
|
|
|
int change = 0;
|
|
|
|
|
|
|
|
val = ucontrol->value.enumerated.item[0];
|
|
|
|
/* Limit: uinfo->value.enumerated.items = 2; */
|
|
|
|
if (val >= 2)
|
|
|
|
return -EINVAL;
|
|
|
|
change = (emu->emu1010.optical_in != val);
|
|
|
|
if (change) {
|
|
|
|
emu->emu1010.optical_in = val;
|
2023-04-28 16:07:32 +08:00
|
|
|
tmp = (emu->emu1010.optical_in ? EMU_HANA_OPTICAL_IN_ADAT : EMU_HANA_OPTICAL_IN_SPDIF) |
|
|
|
|
(emu->emu1010.optical_out ? EMU_HANA_OPTICAL_OUT_ADAT : EMU_HANA_OPTICAL_OUT_SPDIF);
|
2015-04-12 00:00:19 +08:00
|
|
|
snd_emu1010_fpga_write(emu, EMU_HANA_OPTICAL_TYPE, tmp);
|
|
|
|
}
|
|
|
|
return change;
|
|
|
|
}
|
|
|
|
|
2017-02-20 02:48:09 +08:00
|
|
|
static const struct snd_kcontrol_new snd_emu1010_optical_in = {
|
2015-04-12 00:00:19 +08:00
|
|
|
.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
|
|
|
|
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
|
|
|
|
.name = "Optical Input Mode",
|
|
|
|
.count = 1,
|
|
|
|
.info = snd_emu1010_optical_in_info,
|
|
|
|
.get = snd_emu1010_optical_in_get,
|
|
|
|
.put = snd_emu1010_optical_in_put
|
|
|
|
};
|
|
|
|
|
2006-12-06 23:58:02 +08:00
|
|
|
static int snd_audigy_i2c_capture_source_info(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_info *uinfo)
|
|
|
|
{
|
|
|
|
#if 0
|
2014-10-21 00:16:48 +08:00
|
|
|
static const char * const texts[4] = {
|
2006-12-06 23:58:02 +08:00
|
|
|
"Unknown1", "Unknown2", "Mic", "Line"
|
|
|
|
};
|
|
|
|
#endif
|
2014-10-21 00:16:48 +08:00
|
|
|
static const char * const texts[2] = {
|
2006-12-06 23:58:02 +08:00
|
|
|
"Mic", "Line"
|
|
|
|
};
|
|
|
|
|
2014-10-21 00:16:48 +08:00
|
|
|
return snd_ctl_enum_info(uinfo, 1, 2, texts);
|
2006-12-06 23:58:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int snd_audigy_i2c_capture_source_get(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
|
|
|
{
|
|
|
|
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
|
|
|
|
|
|
|
|
ucontrol->value.enumerated.item[0] = emu->i2c_capture_source;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int snd_audigy_i2c_capture_source_put(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
|
|
|
{
|
|
|
|
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
|
|
|
|
unsigned int source_id;
|
|
|
|
unsigned int ngain, ogain;
|
2023-04-21 22:10:01 +08:00
|
|
|
u16 gpio;
|
2006-12-06 23:58:02 +08:00
|
|
|
int change = 0;
|
|
|
|
u32 source;
|
|
|
|
/* If the capture source has changed,
|
|
|
|
* update the capture volume from the cached value
|
|
|
|
* for the particular source.
|
|
|
|
*/
|
2007-11-12 22:55:19 +08:00
|
|
|
source_id = ucontrol->value.enumerated.item[0];
|
|
|
|
/* Limit: uinfo->value.enumerated.items = 2; */
|
|
|
|
/* emu->i2c_capture_volume */
|
|
|
|
if (source_id >= 2)
|
|
|
|
return -EINVAL;
|
2006-12-06 23:58:02 +08:00
|
|
|
change = (emu->i2c_capture_source != source_id);
|
|
|
|
if (change) {
|
|
|
|
snd_emu10k1_i2c_write(emu, ADC_MUX, 0); /* Mute input */
|
2023-07-12 22:57:49 +08:00
|
|
|
spin_lock_irq(&emu->emu_lock);
|
2023-04-21 22:10:01 +08:00
|
|
|
gpio = inw(emu->port + A_IOCFG);
|
2006-12-06 23:58:02 +08:00
|
|
|
if (source_id==0)
|
2023-04-21 22:10:01 +08:00
|
|
|
outw(gpio | 0x4, emu->port + A_IOCFG);
|
2006-12-06 23:58:02 +08:00
|
|
|
else
|
2023-04-21 22:10:01 +08:00
|
|
|
outw(gpio & ~0x4, emu->port + A_IOCFG);
|
2023-07-12 22:57:49 +08:00
|
|
|
spin_unlock_irq(&emu->emu_lock);
|
2006-12-06 23:58:02 +08:00
|
|
|
|
|
|
|
ngain = emu->i2c_capture_volume[source_id][0]; /* Left */
|
|
|
|
ogain = emu->i2c_capture_volume[emu->i2c_capture_source][0]; /* Left */
|
|
|
|
if (ngain != ogain)
|
|
|
|
snd_emu10k1_i2c_write(emu, ADC_ATTEN_ADCL, ((ngain) & 0xff));
|
|
|
|
ngain = emu->i2c_capture_volume[source_id][1]; /* Right */
|
|
|
|
ogain = emu->i2c_capture_volume[emu->i2c_capture_source][1]; /* Right */
|
|
|
|
if (ngain != ogain)
|
|
|
|
snd_emu10k1_i2c_write(emu, ADC_ATTEN_ADCR, ((ngain) & 0xff));
|
|
|
|
|
|
|
|
source = 1 << (source_id + 2);
|
|
|
|
snd_emu10k1_i2c_write(emu, ADC_MUX, source); /* Set source */
|
|
|
|
emu->i2c_capture_source = source_id;
|
|
|
|
}
|
|
|
|
return change;
|
|
|
|
}
|
|
|
|
|
2017-02-20 02:48:09 +08:00
|
|
|
static const struct snd_kcontrol_new snd_audigy_i2c_capture_source =
|
2006-12-06 23:58:02 +08:00
|
|
|
{
|
|
|
|
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
|
|
|
|
.name = "Capture Source",
|
|
|
|
.info = snd_audigy_i2c_capture_source_info,
|
|
|
|
.get = snd_audigy_i2c_capture_source_get,
|
|
|
|
.put = snd_audigy_i2c_capture_source_put
|
|
|
|
};
|
|
|
|
|
|
|
|
static int snd_audigy_i2c_volume_info(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_info *uinfo)
|
|
|
|
{
|
|
|
|
uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
|
|
|
|
uinfo->count = 2;
|
|
|
|
uinfo->value.integer.min = 0;
|
|
|
|
uinfo->value.integer.max = 255;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int snd_audigy_i2c_volume_get(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
|
|
|
{
|
|
|
|
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
|
2007-11-12 22:55:19 +08:00
|
|
|
unsigned int source_id;
|
2006-12-06 23:58:02 +08:00
|
|
|
|
|
|
|
source_id = kcontrol->private_value;
|
2007-11-12 22:55:19 +08:00
|
|
|
/* Limit: emu->i2c_capture_volume */
|
|
|
|
/* capture_source: uinfo->value.enumerated.items = 2 */
|
|
|
|
if (source_id >= 2)
|
|
|
|
return -EINVAL;
|
2006-12-06 23:58:02 +08:00
|
|
|
|
|
|
|
ucontrol->value.integer.value[0] = emu->i2c_capture_volume[source_id][0];
|
|
|
|
ucontrol->value.integer.value[1] = emu->i2c_capture_volume[source_id][1];
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int snd_audigy_i2c_volume_put(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
|
|
|
{
|
|
|
|
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
|
|
|
|
unsigned int ogain;
|
2023-04-23 00:10:21 +08:00
|
|
|
unsigned int ngain0, ngain1;
|
2007-11-12 22:55:19 +08:00
|
|
|
unsigned int source_id;
|
2006-12-06 23:58:02 +08:00
|
|
|
int change = 0;
|
|
|
|
|
|
|
|
source_id = kcontrol->private_value;
|
2007-11-12 22:55:19 +08:00
|
|
|
/* Limit: emu->i2c_capture_volume */
|
|
|
|
/* capture_source: uinfo->value.enumerated.items = 2 */
|
|
|
|
if (source_id >= 2)
|
|
|
|
return -EINVAL;
|
2023-04-23 00:10:21 +08:00
|
|
|
ngain0 = ucontrol->value.integer.value[0];
|
|
|
|
ngain1 = ucontrol->value.integer.value[1];
|
|
|
|
if (ngain0 > 0xff)
|
|
|
|
return -EINVAL;
|
|
|
|
if (ngain1 > 0xff)
|
|
|
|
return -EINVAL;
|
2006-12-06 23:58:02 +08:00
|
|
|
ogain = emu->i2c_capture_volume[source_id][0]; /* Left */
|
2023-04-23 00:10:21 +08:00
|
|
|
if (ogain != ngain0) {
|
2006-12-06 23:58:02 +08:00
|
|
|
if (emu->i2c_capture_source == source_id)
|
2023-04-23 00:10:21 +08:00
|
|
|
snd_emu10k1_i2c_write(emu, ADC_ATTEN_ADCL, ngain0);
|
|
|
|
emu->i2c_capture_volume[source_id][0] = ngain0;
|
2006-12-06 23:58:02 +08:00
|
|
|
change = 1;
|
|
|
|
}
|
|
|
|
ogain = emu->i2c_capture_volume[source_id][1]; /* Right */
|
2023-04-23 00:10:21 +08:00
|
|
|
if (ogain != ngain1) {
|
2006-12-06 23:58:02 +08:00
|
|
|
if (emu->i2c_capture_source == source_id)
|
2023-04-23 00:10:21 +08:00
|
|
|
snd_emu10k1_i2c_write(emu, ADC_ATTEN_ADCR, ngain1);
|
|
|
|
emu->i2c_capture_volume[source_id][1] = ngain1;
|
2006-12-06 23:58:02 +08:00
|
|
|
change = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return change;
|
|
|
|
}
|
|
|
|
|
2023-05-16 17:36:05 +08:00
|
|
|
static const struct snd_kcontrol_new i2c_volume_ctl = {
|
|
|
|
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
|
|
|
|
.access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
|
|
|
|
SNDRV_CTL_ELEM_ACCESS_TLV_READ,
|
|
|
|
.info = snd_audigy_i2c_volume_info,
|
|
|
|
.get = snd_audigy_i2c_volume_get,
|
|
|
|
.put = snd_audigy_i2c_volume_put,
|
|
|
|
.tlv = { .p = snd_audigy_db_scale2 }
|
|
|
|
};
|
2006-12-06 23:58:02 +08:00
|
|
|
|
2023-05-16 17:36:05 +08:00
|
|
|
static const char * const snd_audigy_i2c_volume_ctls[] = {
|
|
|
|
"Mic Capture Volume",
|
|
|
|
"Line Capture Volume",
|
2006-12-06 23:58:02 +08:00
|
|
|
};
|
|
|
|
|
2005-04-11 23:03:03 +08:00
|
|
|
#if 0
|
2005-11-17 21:50:13 +08:00
|
|
|
static int snd_audigy_spdif_output_rate_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2014-10-21 00:16:48 +08:00
|
|
|
static const char * const texts[] = {"44100", "48000", "96000"};
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2014-10-21 00:16:48 +08:00
|
|
|
return snd_ctl_enum_info(uinfo, 1, 3, texts);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2005-11-17 21:50:13 +08:00
|
|
|
static int snd_audigy_spdif_output_rate_get(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-11-17 21:50:13 +08:00
|
|
|
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned int tmp;
|
|
|
|
|
|
|
|
tmp = snd_emu10k1_ptr_read(emu, A_SPDIF_SAMPLERATE, 0);
|
|
|
|
switch (tmp & A_SPDIF_RATE_MASK) {
|
|
|
|
case A_SPDIF_44100:
|
|
|
|
ucontrol->value.enumerated.item[0] = 0;
|
|
|
|
break;
|
|
|
|
case A_SPDIF_48000:
|
|
|
|
ucontrol->value.enumerated.item[0] = 1;
|
|
|
|
break;
|
|
|
|
case A_SPDIF_96000:
|
|
|
|
ucontrol->value.enumerated.item[0] = 2;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ucontrol->value.enumerated.item[0] = 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 21:50:13 +08:00
|
|
|
static int snd_audigy_spdif_output_rate_put(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-11-17 21:50:13 +08:00
|
|
|
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
|
2005-04-17 06:20:36 +08:00
|
|
|
int change;
|
|
|
|
unsigned int reg, val, tmp;
|
|
|
|
|
|
|
|
switch(ucontrol->value.enumerated.item[0]) {
|
|
|
|
case 0:
|
|
|
|
val = A_SPDIF_44100;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
val = A_SPDIF_48000;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
val = A_SPDIF_96000;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
val = A_SPDIF_48000;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-07-12 22:57:49 +08:00
|
|
|
spin_lock_irq(&emu->reg_lock);
|
2005-04-17 06:20:36 +08:00
|
|
|
reg = snd_emu10k1_ptr_read(emu, A_SPDIF_SAMPLERATE, 0);
|
|
|
|
tmp = reg & ~A_SPDIF_RATE_MASK;
|
|
|
|
tmp |= val;
|
2021-06-08 22:05:14 +08:00
|
|
|
change = (tmp != reg);
|
|
|
|
if (change)
|
2005-04-17 06:20:36 +08:00
|
|
|
snd_emu10k1_ptr_write(emu, A_SPDIF_SAMPLERATE, 0, tmp);
|
2023-07-12 22:57:49 +08:00
|
|
|
spin_unlock_irq(&emu->reg_lock);
|
2005-04-17 06:20:36 +08:00
|
|
|
return change;
|
|
|
|
}
|
|
|
|
|
2020-01-03 16:16:53 +08:00
|
|
|
static const struct snd_kcontrol_new snd_audigy_spdif_output_rate =
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
|
|
|
|
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
|
|
|
|
.name = "Audigy SPDIF Output Sample Rate",
|
|
|
|
.count = 1,
|
|
|
|
.info = snd_audigy_spdif_output_rate_info,
|
|
|
|
.get = snd_audigy_spdif_output_rate_get,
|
|
|
|
.put = snd_audigy_spdif_output_rate_put
|
|
|
|
};
|
2005-04-11 23:03:03 +08:00
|
|
|
#endif
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-11-17 21:50:13 +08:00
|
|
|
static int snd_emu10k1_spdif_put(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-11-17 21:50:13 +08:00
|
|
|
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
|
|
|
|
int change;
|
|
|
|
unsigned int val;
|
|
|
|
|
2007-11-12 22:55:19 +08:00
|
|
|
/* Limit: emu->spdif_bits */
|
|
|
|
if (idx >= 3)
|
|
|
|
return -EINVAL;
|
2005-04-17 06:20:36 +08:00
|
|
|
val = (ucontrol->value.iec958.status[0] << 0) |
|
|
|
|
(ucontrol->value.iec958.status[1] << 8) |
|
|
|
|
(ucontrol->value.iec958.status[2] << 16) |
|
|
|
|
(ucontrol->value.iec958.status[3] << 24);
|
|
|
|
change = val != emu->spdif_bits[idx];
|
|
|
|
if (change) {
|
|
|
|
snd_emu10k1_ptr_write(emu, SPCS0 + idx, 0, val);
|
|
|
|
emu->spdif_bits[idx] = val;
|
|
|
|
}
|
|
|
|
return change;
|
|
|
|
}
|
|
|
|
|
2017-02-20 02:48:09 +08:00
|
|
|
static const struct snd_kcontrol_new snd_emu10k1_spdif_mask_control =
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
.access = SNDRV_CTL_ELEM_ACCESS_READ,
|
2005-08-03 19:50:30 +08:00
|
|
|
.iface = SNDRV_CTL_ELEM_IFACE_PCM,
|
2005-04-17 06:20:36 +08:00
|
|
|
.name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,MASK),
|
2007-08-17 01:32:16 +08:00
|
|
|
.count = 3,
|
2005-04-17 06:20:36 +08:00
|
|
|
.info = snd_emu10k1_spdif_info,
|
|
|
|
.get = snd_emu10k1_spdif_get_mask
|
|
|
|
};
|
|
|
|
|
2017-02-20 02:48:09 +08:00
|
|
|
static const struct snd_kcontrol_new snd_emu10k1_spdif_control =
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-08-03 19:50:30 +08:00
|
|
|
.iface = SNDRV_CTL_ELEM_IFACE_PCM,
|
2005-04-17 06:20:36 +08:00
|
|
|
.name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT),
|
2007-08-17 01:32:16 +08:00
|
|
|
.count = 3,
|
2005-04-17 06:20:36 +08:00
|
|
|
.info = snd_emu10k1_spdif_info,
|
|
|
|
.get = snd_emu10k1_spdif_get,
|
|
|
|
.put = snd_emu10k1_spdif_put
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2005-11-17 21:50:13 +08:00
|
|
|
static void update_emu10k1_fxrt(struct snd_emu10k1 *emu, int voice, unsigned char *route)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
if (emu->audigy) {
|
2023-05-18 17:31:34 +08:00
|
|
|
snd_emu10k1_ptr_write_multiple(emu, voice,
|
|
|
|
A_FXRT1, snd_emu10k1_compose_audigy_fxrt1(route),
|
|
|
|
A_FXRT2, snd_emu10k1_compose_audigy_fxrt2(route),
|
|
|
|
REGLIST_END);
|
2005-04-17 06:20:36 +08:00
|
|
|
} else {
|
|
|
|
snd_emu10k1_ptr_write(emu, FXRT, voice,
|
|
|
|
snd_emu10k1_compose_send_routing(route));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-11-17 21:50:13 +08:00
|
|
|
static void update_emu10k1_send_volume(struct snd_emu10k1 *emu, int voice, unsigned char *volume)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
snd_emu10k1_ptr_write(emu, PTRX_FXSENDAMOUNT_A, voice, volume[0]);
|
|
|
|
snd_emu10k1_ptr_write(emu, PTRX_FXSENDAMOUNT_B, voice, volume[1]);
|
|
|
|
snd_emu10k1_ptr_write(emu, PSST_FXSENDAMOUNT_C, voice, volume[2]);
|
|
|
|
snd_emu10k1_ptr_write(emu, DSL_FXSENDAMOUNT_D, voice, volume[3]);
|
|
|
|
if (emu->audigy) {
|
2023-05-16 17:36:12 +08:00
|
|
|
snd_emu10k1_ptr_write(emu, A_SENDAMOUNTS, voice,
|
|
|
|
snd_emu10k1_compose_audigy_sendamounts(volume));
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* PCM stream controls */
|
|
|
|
|
2005-11-17 21:50:13 +08:00
|
|
|
static int snd_emu10k1_send_routing_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-11-17 21:50:13 +08:00
|
|
|
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
|
2005-04-17 06:20:36 +08:00
|
|
|
uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
|
|
|
|
uinfo->count = emu->audigy ? 3*8 : 3*4;
|
|
|
|
uinfo->value.integer.min = 0;
|
|
|
|
uinfo->value.integer.max = emu->audigy ? 0x3f : 0x0f;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 21:50:13 +08:00
|
|
|
static int snd_emu10k1_send_routing_get(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-11-17 21:50:13 +08:00
|
|
|
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
|
|
|
|
struct snd_emu10k1_pcm_mixer *mix =
|
|
|
|
&emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)];
|
2005-04-17 06:20:36 +08:00
|
|
|
int voice, idx;
|
|
|
|
int num_efx = emu->audigy ? 8 : 4;
|
|
|
|
int mask = emu->audigy ? 0x3f : 0x0f;
|
|
|
|
|
|
|
|
for (voice = 0; voice < 3; voice++)
|
|
|
|
for (idx = 0; idx < num_efx; idx++)
|
|
|
|
ucontrol->value.integer.value[(voice * num_efx) + idx] =
|
|
|
|
mix->send_routing[voice][idx] & mask;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 21:50:13 +08:00
|
|
|
static int snd_emu10k1_send_routing_put(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-11-17 21:50:13 +08:00
|
|
|
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
|
|
|
|
struct snd_emu10k1_pcm_mixer *mix =
|
|
|
|
&emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)];
|
2005-04-17 06:20:36 +08:00
|
|
|
int change = 0, voice, idx, val;
|
|
|
|
int num_efx = emu->audigy ? 8 : 4;
|
|
|
|
int mask = emu->audigy ? 0x3f : 0x0f;
|
|
|
|
|
2023-07-12 22:57:49 +08:00
|
|
|
spin_lock_irq(&emu->reg_lock);
|
2005-04-17 06:20:36 +08:00
|
|
|
for (voice = 0; voice < 3; voice++)
|
|
|
|
for (idx = 0; idx < num_efx; idx++) {
|
|
|
|
val = ucontrol->value.integer.value[(voice * num_efx) + idx] & mask;
|
|
|
|
if (mix->send_routing[voice][idx] != val) {
|
|
|
|
mix->send_routing[voice][idx] = val;
|
|
|
|
change = 1;
|
|
|
|
}
|
|
|
|
}
|
2023-05-18 22:09:47 +08:00
|
|
|
if (change && mix->epcm && mix->epcm->voices[0]) {
|
|
|
|
if (!mix->epcm->voices[0]->last) {
|
2005-04-17 06:20:36 +08:00
|
|
|
update_emu10k1_fxrt(emu, mix->epcm->voices[0]->number,
|
|
|
|
&mix->send_routing[1][0]);
|
2023-05-18 22:09:47 +08:00
|
|
|
update_emu10k1_fxrt(emu, mix->epcm->voices[0]->number + 1,
|
2005-04-17 06:20:36 +08:00
|
|
|
&mix->send_routing[2][0]);
|
2023-05-18 22:09:47 +08:00
|
|
|
} else {
|
2005-04-17 06:20:36 +08:00
|
|
|
update_emu10k1_fxrt(emu, mix->epcm->voices[0]->number,
|
|
|
|
&mix->send_routing[0][0]);
|
|
|
|
}
|
|
|
|
}
|
2023-07-12 22:57:49 +08:00
|
|
|
spin_unlock_irq(&emu->reg_lock);
|
2005-04-17 06:20:36 +08:00
|
|
|
return change;
|
|
|
|
}
|
|
|
|
|
2017-02-20 02:48:09 +08:00
|
|
|
static const struct snd_kcontrol_new snd_emu10k1_send_routing_control =
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
.access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_INACTIVE,
|
[ALSA] sound - fix .iface field of mixer control elements
Documentation,CS46xx driver,EMU10K1/EMU10K2 driver,AD1848 driver
SB16/AWE driver,CMIPCI driver,ENS1370/1+ driver,RME32 driver
RME96 driver,ICE1712 driver,ICE1724 driver,KORG1212 driver
RME HDSP driver,RME9652 driver
This patch changes .iface to SNDRV_CTL_ELEM_IFACE_MIXER whre _PCM or
_HWDEP was used in controls that are not associated with a specific PCM
(sub)stream or hwdep device, and changes some controls that got
inconsitent .iface values due to copy+paste errors. Furthermore, it
makes sure that all control that do use _PCM or _HWDEP use the correct
number in the .device field.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
2005-07-29 21:32:58 +08:00
|
|
|
.iface = SNDRV_CTL_ELEM_IFACE_PCM,
|
2005-04-17 06:20:36 +08:00
|
|
|
.name = "EMU10K1 PCM Send Routing",
|
|
|
|
.count = 32,
|
|
|
|
.info = snd_emu10k1_send_routing_info,
|
|
|
|
.get = snd_emu10k1_send_routing_get,
|
|
|
|
.put = snd_emu10k1_send_routing_put
|
|
|
|
};
|
|
|
|
|
2005-11-17 21:50:13 +08:00
|
|
|
static int snd_emu10k1_send_volume_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-11-17 21:50:13 +08:00
|
|
|
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
|
2005-04-17 06:20:36 +08:00
|
|
|
uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
|
|
|
|
uinfo->count = emu->audigy ? 3*8 : 3*4;
|
|
|
|
uinfo->value.integer.min = 0;
|
|
|
|
uinfo->value.integer.max = 255;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 21:50:13 +08:00
|
|
|
static int snd_emu10k1_send_volume_get(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-11-17 21:50:13 +08:00
|
|
|
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
|
|
|
|
struct snd_emu10k1_pcm_mixer *mix =
|
|
|
|
&emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)];
|
2005-04-17 06:20:36 +08:00
|
|
|
int idx;
|
|
|
|
int num_efx = emu->audigy ? 8 : 4;
|
|
|
|
|
|
|
|
for (idx = 0; idx < 3*num_efx; idx++)
|
|
|
|
ucontrol->value.integer.value[idx] = mix->send_volume[idx/num_efx][idx%num_efx];
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 21:50:13 +08:00
|
|
|
static int snd_emu10k1_send_volume_put(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-11-17 21:50:13 +08:00
|
|
|
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
|
|
|
|
struct snd_emu10k1_pcm_mixer *mix =
|
|
|
|
&emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)];
|
2005-04-17 06:20:36 +08:00
|
|
|
int change = 0, idx, val;
|
|
|
|
int num_efx = emu->audigy ? 8 : 4;
|
|
|
|
|
2023-07-12 22:57:49 +08:00
|
|
|
spin_lock_irq(&emu->reg_lock);
|
2005-04-17 06:20:36 +08:00
|
|
|
for (idx = 0; idx < 3*num_efx; idx++) {
|
|
|
|
val = ucontrol->value.integer.value[idx] & 255;
|
|
|
|
if (mix->send_volume[idx/num_efx][idx%num_efx] != val) {
|
|
|
|
mix->send_volume[idx/num_efx][idx%num_efx] = val;
|
|
|
|
change = 1;
|
|
|
|
}
|
|
|
|
}
|
2023-05-18 22:09:47 +08:00
|
|
|
if (change && mix->epcm && mix->epcm->voices[0]) {
|
|
|
|
if (!mix->epcm->voices[0]->last) {
|
2005-04-17 06:20:36 +08:00
|
|
|
update_emu10k1_send_volume(emu, mix->epcm->voices[0]->number,
|
|
|
|
&mix->send_volume[1][0]);
|
2023-05-18 22:09:47 +08:00
|
|
|
update_emu10k1_send_volume(emu, mix->epcm->voices[0]->number + 1,
|
2005-04-17 06:20:36 +08:00
|
|
|
&mix->send_volume[2][0]);
|
2023-05-18 22:09:47 +08:00
|
|
|
} else {
|
2005-04-17 06:20:36 +08:00
|
|
|
update_emu10k1_send_volume(emu, mix->epcm->voices[0]->number,
|
|
|
|
&mix->send_volume[0][0]);
|
|
|
|
}
|
|
|
|
}
|
2023-07-12 22:57:49 +08:00
|
|
|
spin_unlock_irq(&emu->reg_lock);
|
2005-04-17 06:20:36 +08:00
|
|
|
return change;
|
|
|
|
}
|
|
|
|
|
2017-02-20 02:48:09 +08:00
|
|
|
static const struct snd_kcontrol_new snd_emu10k1_send_volume_control =
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
.access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_INACTIVE,
|
[ALSA] sound - fix .iface field of mixer control elements
Documentation,CS46xx driver,EMU10K1/EMU10K2 driver,AD1848 driver
SB16/AWE driver,CMIPCI driver,ENS1370/1+ driver,RME32 driver
RME96 driver,ICE1712 driver,ICE1724 driver,KORG1212 driver
RME HDSP driver,RME9652 driver
This patch changes .iface to SNDRV_CTL_ELEM_IFACE_MIXER whre _PCM or
_HWDEP was used in controls that are not associated with a specific PCM
(sub)stream or hwdep device, and changes some controls that got
inconsitent .iface values due to copy+paste errors. Furthermore, it
makes sure that all control that do use _PCM or _HWDEP use the correct
number in the .device field.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
2005-07-29 21:32:58 +08:00
|
|
|
.iface = SNDRV_CTL_ELEM_IFACE_PCM,
|
2005-04-17 06:20:36 +08:00
|
|
|
.name = "EMU10K1 PCM Send Volume",
|
|
|
|
.count = 32,
|
|
|
|
.info = snd_emu10k1_send_volume_info,
|
|
|
|
.get = snd_emu10k1_send_volume_get,
|
|
|
|
.put = snd_emu10k1_send_volume_put
|
|
|
|
};
|
|
|
|
|
2005-11-17 21:50:13 +08:00
|
|
|
static int snd_emu10k1_attn_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
|
|
|
|
uinfo->count = 3;
|
|
|
|
uinfo->value.integer.min = 0;
|
2023-05-15 01:03:23 +08:00
|
|
|
uinfo->value.integer.max = 0x1fffd;
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 21:50:13 +08:00
|
|
|
static int snd_emu10k1_attn_get(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-11-17 21:50:13 +08:00
|
|
|
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
|
|
|
|
struct snd_emu10k1_pcm_mixer *mix =
|
|
|
|
&emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)];
|
2005-04-17 06:20:36 +08:00
|
|
|
int idx;
|
|
|
|
|
|
|
|
for (idx = 0; idx < 3; idx++)
|
2023-05-15 01:03:23 +08:00
|
|
|
ucontrol->value.integer.value[idx] = mix->attn[idx] * 0xffffU / 0x8000U;
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 21:50:13 +08:00
|
|
|
static int snd_emu10k1_attn_put(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-11-17 21:50:13 +08:00
|
|
|
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
|
|
|
|
struct snd_emu10k1_pcm_mixer *mix =
|
|
|
|
&emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)];
|
2005-04-17 06:20:36 +08:00
|
|
|
int change = 0, idx, val;
|
|
|
|
|
2023-07-12 22:57:49 +08:00
|
|
|
spin_lock_irq(&emu->reg_lock);
|
2005-04-17 06:20:36 +08:00
|
|
|
for (idx = 0; idx < 3; idx++) {
|
2023-05-15 01:03:23 +08:00
|
|
|
unsigned uval = ucontrol->value.integer.value[idx] & 0x1ffff;
|
|
|
|
val = uval * 0x8000U / 0xffffU;
|
2005-04-17 06:20:36 +08:00
|
|
|
if (mix->attn[idx] != val) {
|
|
|
|
mix->attn[idx] = val;
|
|
|
|
change = 1;
|
|
|
|
}
|
|
|
|
}
|
2023-05-18 22:09:47 +08:00
|
|
|
if (change && mix->epcm && mix->epcm->voices[0]) {
|
|
|
|
if (!mix->epcm->voices[0]->last) {
|
2005-04-17 06:20:36 +08:00
|
|
|
snd_emu10k1_ptr_write(emu, VTFT_VOLUMETARGET, mix->epcm->voices[0]->number, mix->attn[1]);
|
2023-05-18 22:09:47 +08:00
|
|
|
snd_emu10k1_ptr_write(emu, VTFT_VOLUMETARGET, mix->epcm->voices[0]->number + 1, mix->attn[2]);
|
|
|
|
} else {
|
2005-04-17 06:20:36 +08:00
|
|
|
snd_emu10k1_ptr_write(emu, VTFT_VOLUMETARGET, mix->epcm->voices[0]->number, mix->attn[0]);
|
|
|
|
}
|
|
|
|
}
|
2023-07-12 22:57:49 +08:00
|
|
|
spin_unlock_irq(&emu->reg_lock);
|
2005-04-17 06:20:36 +08:00
|
|
|
return change;
|
|
|
|
}
|
|
|
|
|
2017-02-20 02:48:09 +08:00
|
|
|
static const struct snd_kcontrol_new snd_emu10k1_attn_control =
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
.access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_INACTIVE,
|
[ALSA] sound - fix .iface field of mixer control elements
Documentation,CS46xx driver,EMU10K1/EMU10K2 driver,AD1848 driver
SB16/AWE driver,CMIPCI driver,ENS1370/1+ driver,RME32 driver
RME96 driver,ICE1712 driver,ICE1724 driver,KORG1212 driver
RME HDSP driver,RME9652 driver
This patch changes .iface to SNDRV_CTL_ELEM_IFACE_MIXER whre _PCM or
_HWDEP was used in controls that are not associated with a specific PCM
(sub)stream or hwdep device, and changes some controls that got
inconsitent .iface values due to copy+paste errors. Furthermore, it
makes sure that all control that do use _PCM or _HWDEP use the correct
number in the .device field.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
2005-07-29 21:32:58 +08:00
|
|
|
.iface = SNDRV_CTL_ELEM_IFACE_PCM,
|
2005-04-17 06:20:36 +08:00
|
|
|
.name = "EMU10K1 PCM Volume",
|
|
|
|
.count = 32,
|
|
|
|
.info = snd_emu10k1_attn_info,
|
|
|
|
.get = snd_emu10k1_attn_get,
|
|
|
|
.put = snd_emu10k1_attn_put
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Mutichannel PCM stream controls */
|
|
|
|
|
2005-11-17 21:50:13 +08:00
|
|
|
static int snd_emu10k1_efx_send_routing_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-11-17 21:50:13 +08:00
|
|
|
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
|
2005-04-17 06:20:36 +08:00
|
|
|
uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
|
|
|
|
uinfo->count = emu->audigy ? 8 : 4;
|
|
|
|
uinfo->value.integer.min = 0;
|
|
|
|
uinfo->value.integer.max = emu->audigy ? 0x3f : 0x0f;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 21:50:13 +08:00
|
|
|
static int snd_emu10k1_efx_send_routing_get(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-11-17 21:50:13 +08:00
|
|
|
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
|
|
|
|
struct snd_emu10k1_pcm_mixer *mix =
|
|
|
|
&emu->efx_pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)];
|
2005-04-17 06:20:36 +08:00
|
|
|
int idx;
|
|
|
|
int num_efx = emu->audigy ? 8 : 4;
|
|
|
|
int mask = emu->audigy ? 0x3f : 0x0f;
|
|
|
|
|
|
|
|
for (idx = 0; idx < num_efx; idx++)
|
|
|
|
ucontrol->value.integer.value[idx] =
|
|
|
|
mix->send_routing[0][idx] & mask;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 21:50:13 +08:00
|
|
|
static int snd_emu10k1_efx_send_routing_put(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-11-17 21:50:13 +08:00
|
|
|
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
|
2005-04-17 06:20:36 +08:00
|
|
|
int ch = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
|
2005-11-17 21:50:13 +08:00
|
|
|
struct snd_emu10k1_pcm_mixer *mix = &emu->efx_pcm_mixer[ch];
|
2005-04-17 06:20:36 +08:00
|
|
|
int change = 0, idx, val;
|
|
|
|
int num_efx = emu->audigy ? 8 : 4;
|
|
|
|
int mask = emu->audigy ? 0x3f : 0x0f;
|
|
|
|
|
2023-07-12 22:57:49 +08:00
|
|
|
spin_lock_irq(&emu->reg_lock);
|
2005-04-17 06:20:36 +08:00
|
|
|
for (idx = 0; idx < num_efx; idx++) {
|
|
|
|
val = ucontrol->value.integer.value[idx] & mask;
|
|
|
|
if (mix->send_routing[0][idx] != val) {
|
|
|
|
mix->send_routing[0][idx] = val;
|
|
|
|
change = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (change && mix->epcm) {
|
|
|
|
if (mix->epcm->voices[ch]) {
|
|
|
|
update_emu10k1_fxrt(emu, mix->epcm->voices[ch]->number,
|
|
|
|
&mix->send_routing[0][0]);
|
|
|
|
}
|
|
|
|
}
|
2023-07-12 22:57:49 +08:00
|
|
|
spin_unlock_irq(&emu->reg_lock);
|
2005-04-17 06:20:36 +08:00
|
|
|
return change;
|
|
|
|
}
|
|
|
|
|
2017-02-20 02:48:09 +08:00
|
|
|
static const struct snd_kcontrol_new snd_emu10k1_efx_send_routing_control =
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
.access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_INACTIVE,
|
|
|
|
.iface = SNDRV_CTL_ELEM_IFACE_PCM,
|
|
|
|
.name = "Multichannel PCM Send Routing",
|
|
|
|
.count = 16,
|
|
|
|
.info = snd_emu10k1_efx_send_routing_info,
|
|
|
|
.get = snd_emu10k1_efx_send_routing_get,
|
|
|
|
.put = snd_emu10k1_efx_send_routing_put
|
|
|
|
};
|
|
|
|
|
2005-11-17 21:50:13 +08:00
|
|
|
static int snd_emu10k1_efx_send_volume_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-11-17 21:50:13 +08:00
|
|
|
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
|
2005-04-17 06:20:36 +08:00
|
|
|
uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
|
|
|
|
uinfo->count = emu->audigy ? 8 : 4;
|
|
|
|
uinfo->value.integer.min = 0;
|
|
|
|
uinfo->value.integer.max = 255;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 21:50:13 +08:00
|
|
|
static int snd_emu10k1_efx_send_volume_get(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-11-17 21:50:13 +08:00
|
|
|
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
|
|
|
|
struct snd_emu10k1_pcm_mixer *mix =
|
|
|
|
&emu->efx_pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)];
|
2005-04-17 06:20:36 +08:00
|
|
|
int idx;
|
|
|
|
int num_efx = emu->audigy ? 8 : 4;
|
|
|
|
|
|
|
|
for (idx = 0; idx < num_efx; idx++)
|
|
|
|
ucontrol->value.integer.value[idx] = mix->send_volume[0][idx];
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 21:50:13 +08:00
|
|
|
static int snd_emu10k1_efx_send_volume_put(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-11-17 21:50:13 +08:00
|
|
|
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
|
2005-04-17 06:20:36 +08:00
|
|
|
int ch = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
|
2005-11-17 21:50:13 +08:00
|
|
|
struct snd_emu10k1_pcm_mixer *mix = &emu->efx_pcm_mixer[ch];
|
2005-04-17 06:20:36 +08:00
|
|
|
int change = 0, idx, val;
|
|
|
|
int num_efx = emu->audigy ? 8 : 4;
|
|
|
|
|
2023-07-12 22:57:49 +08:00
|
|
|
spin_lock_irq(&emu->reg_lock);
|
2005-04-17 06:20:36 +08:00
|
|
|
for (idx = 0; idx < num_efx; idx++) {
|
|
|
|
val = ucontrol->value.integer.value[idx] & 255;
|
|
|
|
if (mix->send_volume[0][idx] != val) {
|
|
|
|
mix->send_volume[0][idx] = val;
|
|
|
|
change = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (change && mix->epcm) {
|
|
|
|
if (mix->epcm->voices[ch]) {
|
|
|
|
update_emu10k1_send_volume(emu, mix->epcm->voices[ch]->number,
|
|
|
|
&mix->send_volume[0][0]);
|
|
|
|
}
|
|
|
|
}
|
2023-07-12 22:57:49 +08:00
|
|
|
spin_unlock_irq(&emu->reg_lock);
|
2005-04-17 06:20:36 +08:00
|
|
|
return change;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-02-20 02:48:09 +08:00
|
|
|
static const struct snd_kcontrol_new snd_emu10k1_efx_send_volume_control =
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
.access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_INACTIVE,
|
|
|
|
.iface = SNDRV_CTL_ELEM_IFACE_PCM,
|
|
|
|
.name = "Multichannel PCM Send Volume",
|
|
|
|
.count = 16,
|
|
|
|
.info = snd_emu10k1_efx_send_volume_info,
|
|
|
|
.get = snd_emu10k1_efx_send_volume_get,
|
|
|
|
.put = snd_emu10k1_efx_send_volume_put
|
|
|
|
};
|
|
|
|
|
2005-11-17 21:50:13 +08:00
|
|
|
static int snd_emu10k1_efx_attn_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
|
|
|
|
uinfo->count = 1;
|
|
|
|
uinfo->value.integer.min = 0;
|
2023-05-15 01:03:23 +08:00
|
|
|
uinfo->value.integer.max = 0x1fffd;
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 21:50:13 +08:00
|
|
|
static int snd_emu10k1_efx_attn_get(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-11-17 21:50:13 +08:00
|
|
|
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
|
|
|
|
struct snd_emu10k1_pcm_mixer *mix =
|
|
|
|
&emu->efx_pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)];
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2023-05-15 01:03:23 +08:00
|
|
|
ucontrol->value.integer.value[0] = mix->attn[0] * 0xffffU / 0x8000U;
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 21:50:13 +08:00
|
|
|
static int snd_emu10k1_efx_attn_put(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-11-17 21:50:13 +08:00
|
|
|
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
|
2005-04-17 06:20:36 +08:00
|
|
|
int ch = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
|
2005-11-17 21:50:13 +08:00
|
|
|
struct snd_emu10k1_pcm_mixer *mix = &emu->efx_pcm_mixer[ch];
|
2005-04-17 06:20:36 +08:00
|
|
|
int change = 0, val;
|
2023-05-15 01:03:23 +08:00
|
|
|
unsigned uval;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2023-07-12 22:57:49 +08:00
|
|
|
spin_lock_irq(&emu->reg_lock);
|
2023-05-15 01:03:23 +08:00
|
|
|
uval = ucontrol->value.integer.value[0] & 0x1ffff;
|
|
|
|
val = uval * 0x8000U / 0xffffU;
|
2005-04-17 06:20:36 +08:00
|
|
|
if (mix->attn[0] != val) {
|
|
|
|
mix->attn[0] = val;
|
|
|
|
change = 1;
|
|
|
|
}
|
|
|
|
if (change && mix->epcm) {
|
|
|
|
if (mix->epcm->voices[ch]) {
|
|
|
|
snd_emu10k1_ptr_write(emu, VTFT_VOLUMETARGET, mix->epcm->voices[ch]->number, mix->attn[0]);
|
|
|
|
}
|
|
|
|
}
|
2023-07-12 22:57:49 +08:00
|
|
|
spin_unlock_irq(&emu->reg_lock);
|
2005-04-17 06:20:36 +08:00
|
|
|
return change;
|
|
|
|
}
|
|
|
|
|
2017-02-20 02:48:09 +08:00
|
|
|
static const struct snd_kcontrol_new snd_emu10k1_efx_attn_control =
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
.access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_INACTIVE,
|
|
|
|
.iface = SNDRV_CTL_ELEM_IFACE_PCM,
|
|
|
|
.name = "Multichannel PCM Volume",
|
|
|
|
.count = 16,
|
|
|
|
.info = snd_emu10k1_efx_attn_info,
|
|
|
|
.get = snd_emu10k1_efx_attn_get,
|
|
|
|
.put = snd_emu10k1_efx_attn_put
|
|
|
|
};
|
|
|
|
|
2007-07-23 21:42:26 +08:00
|
|
|
#define snd_emu10k1_shared_spdif_info snd_ctl_boolean_mono_info
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-11-17 21:50:13 +08:00
|
|
|
static int snd_emu10k1_shared_spdif_get(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-11-17 21:50:13 +08:00
|
|
|
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (emu->audigy)
|
2023-04-21 22:10:01 +08:00
|
|
|
ucontrol->value.integer.value[0] = inw(emu->port + A_IOCFG) & A_IOCFG_GPOUT0 ? 1 : 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
else
|
|
|
|
ucontrol->value.integer.value[0] = inl(emu->port + HCFG) & HCFG_GPOUT0 ? 1 : 0;
|
2008-06-02 17:45:53 +08:00
|
|
|
if (emu->card_capabilities->invert_shared_spdif)
|
|
|
|
ucontrol->value.integer.value[0] =
|
|
|
|
!ucontrol->value.integer.value[0];
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 21:50:13 +08:00
|
|
|
static int snd_emu10k1_shared_spdif_put(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-11-17 21:50:13 +08:00
|
|
|
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
|
2008-06-02 17:45:53 +08:00
|
|
|
unsigned int reg, val, sw;
|
2005-04-17 06:20:36 +08:00
|
|
|
int change = 0;
|
|
|
|
|
2008-06-02 17:45:53 +08:00
|
|
|
sw = ucontrol->value.integer.value[0];
|
|
|
|
if (emu->card_capabilities->invert_shared_spdif)
|
|
|
|
sw = !sw;
|
2023-07-12 22:57:49 +08:00
|
|
|
spin_lock_irq(&emu->emu_lock);
|
2006-12-06 23:58:02 +08:00
|
|
|
if ( emu->card_capabilities->i2c_adc) {
|
|
|
|
/* Do nothing for Audigy 2 ZS Notebook */
|
|
|
|
} else if (emu->audigy) {
|
2023-04-21 22:10:01 +08:00
|
|
|
reg = inw(emu->port + A_IOCFG);
|
2008-06-02 17:45:53 +08:00
|
|
|
val = sw ? A_IOCFG_GPOUT0 : 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
change = (reg & A_IOCFG_GPOUT0) != val;
|
|
|
|
if (change) {
|
|
|
|
reg &= ~A_IOCFG_GPOUT0;
|
|
|
|
reg |= val;
|
2023-04-21 22:10:01 +08:00
|
|
|
outw(reg | val, emu->port + A_IOCFG);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
reg = inl(emu->port + HCFG);
|
2008-06-02 17:45:53 +08:00
|
|
|
val = sw ? HCFG_GPOUT0 : 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
change |= (reg & HCFG_GPOUT0) != val;
|
|
|
|
if (change) {
|
|
|
|
reg &= ~HCFG_GPOUT0;
|
|
|
|
reg |= val;
|
|
|
|
outl(reg | val, emu->port + HCFG);
|
|
|
|
}
|
2023-07-12 22:57:49 +08:00
|
|
|
spin_unlock_irq(&emu->emu_lock);
|
2005-04-17 06:20:36 +08:00
|
|
|
return change;
|
|
|
|
}
|
|
|
|
|
2017-02-20 02:48:09 +08:00
|
|
|
static const struct snd_kcontrol_new snd_emu10k1_shared_spdif =
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
|
|
|
|
.name = "SB Live Analog/Digital Output Jack",
|
|
|
|
.info = snd_emu10k1_shared_spdif_info,
|
|
|
|
.get = snd_emu10k1_shared_spdif_get,
|
|
|
|
.put = snd_emu10k1_shared_spdif_put
|
|
|
|
};
|
|
|
|
|
2017-02-20 02:48:09 +08:00
|
|
|
static const struct snd_kcontrol_new snd_audigy_shared_spdif =
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
|
|
|
|
.name = "Audigy Analog/Digital Output Jack",
|
|
|
|
.info = snd_emu10k1_shared_spdif_info,
|
|
|
|
.get = snd_emu10k1_shared_spdif_get,
|
|
|
|
.put = snd_emu10k1_shared_spdif_put
|
|
|
|
};
|
|
|
|
|
2008-12-02 16:31:16 +08:00
|
|
|
/* workaround for too low volume on Audigy due to 16bit/24bit conversion */
|
|
|
|
|
|
|
|
#define snd_audigy_capture_boost_info snd_ctl_boolean_mono_info
|
|
|
|
|
|
|
|
static int snd_audigy_capture_boost_get(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
|
|
|
{
|
|
|
|
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
|
|
|
|
unsigned int val;
|
|
|
|
|
|
|
|
/* FIXME: better to use a cached version */
|
|
|
|
val = snd_ac97_read(emu->ac97, AC97_REC_GAIN);
|
|
|
|
ucontrol->value.integer.value[0] = !!val;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int snd_audigy_capture_boost_put(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
|
|
|
{
|
|
|
|
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
|
|
|
|
unsigned int val;
|
|
|
|
|
|
|
|
if (ucontrol->value.integer.value[0])
|
|
|
|
val = 0x0f0f;
|
|
|
|
else
|
|
|
|
val = 0;
|
|
|
|
return snd_ac97_update(emu->ac97, AC97_REC_GAIN, val);
|
|
|
|
}
|
|
|
|
|
2017-02-20 02:48:09 +08:00
|
|
|
static const struct snd_kcontrol_new snd_audigy_capture_boost =
|
2008-12-02 16:31:16 +08:00
|
|
|
{
|
|
|
|
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
|
2015-07-08 03:54:02 +08:00
|
|
|
.name = "Mic Extra Boost",
|
2008-12-02 16:31:16 +08:00
|
|
|
.info = snd_audigy_capture_boost_info,
|
|
|
|
.get = snd_audigy_capture_boost_get,
|
|
|
|
.put = snd_audigy_capture_boost_put
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
*/
|
2005-11-17 21:50:13 +08:00
|
|
|
static void snd_emu10k1_mixer_free_ac97(struct snd_ac97 *ac97)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-11-17 21:50:13 +08:00
|
|
|
struct snd_emu10k1 *emu = ac97->private_data;
|
2005-04-17 06:20:36 +08:00
|
|
|
emu->ac97 = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
*/
|
2005-11-17 21:50:13 +08:00
|
|
|
static int remove_ctl(struct snd_card *card, const char *name)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-11-17 21:50:13 +08:00
|
|
|
struct snd_ctl_elem_id id;
|
2005-04-17 06:20:36 +08:00
|
|
|
memset(&id, 0, sizeof(id));
|
|
|
|
strcpy(id.name, name);
|
|
|
|
id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
|
|
|
|
return snd_ctl_remove_id(card, &id);
|
|
|
|
}
|
|
|
|
|
2005-11-17 21:50:13 +08:00
|
|
|
static int rename_ctl(struct snd_card *card, const char *src, const char *dst)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2023-07-20 16:21:01 +08:00
|
|
|
struct snd_kcontrol *kctl = snd_ctl_find_id_mixer(card, src);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (kctl) {
|
2022-10-21 04:46:24 +08:00
|
|
|
snd_ctl_rename(card, kctl, dst);
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return -ENOENT;
|
|
|
|
}
|
|
|
|
|
2012-12-07 01:35:10 +08:00
|
|
|
int snd_emu10k1_mixer(struct snd_emu10k1 *emu,
|
|
|
|
int pcm_device, int multi_device)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2023-05-16 17:36:07 +08:00
|
|
|
int err;
|
2005-11-17 21:50:13 +08:00
|
|
|
struct snd_kcontrol *kctl;
|
|
|
|
struct snd_card *card = emu->card;
|
2020-01-05 22:47:29 +08:00
|
|
|
const char * const *c;
|
|
|
|
static const char * const emu10k1_remove_ctls[] = {
|
2005-04-17 06:20:36 +08:00
|
|
|
/* no AC97 mono, surround, center/lfe */
|
|
|
|
"Master Mono Playback Switch",
|
|
|
|
"Master Mono Playback Volume",
|
|
|
|
"PCM Out Path & Mute",
|
|
|
|
"Mono Output Select",
|
|
|
|
"Surround Playback Switch",
|
|
|
|
"Surround Playback Volume",
|
|
|
|
"Center Playback Switch",
|
|
|
|
"Center Playback Volume",
|
|
|
|
"LFE Playback Switch",
|
|
|
|
"LFE Playback Volume",
|
|
|
|
NULL
|
|
|
|
};
|
2020-01-05 22:47:29 +08:00
|
|
|
static const char * const emu10k1_rename_ctls[] = {
|
2005-04-17 06:20:36 +08:00
|
|
|
"Surround Digital Playback Volume", "Surround Playback Volume",
|
|
|
|
"Center Digital Playback Volume", "Center Playback Volume",
|
|
|
|
"LFE Digital Playback Volume", "LFE Playback Volume",
|
|
|
|
NULL
|
|
|
|
};
|
2020-01-05 22:47:29 +08:00
|
|
|
static const char * const audigy_remove_ctls[] = {
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Master/PCM controls on ac97 of Audigy has no effect */
|
2006-04-10 00:36:39 +08:00
|
|
|
/* On the Audigy2 the AC97 playback is piped into
|
|
|
|
* the Philips ADC for 24bit capture */
|
2005-04-17 06:20:36 +08:00
|
|
|
"PCM Playback Switch",
|
|
|
|
"PCM Playback Volume",
|
|
|
|
"Master Playback Switch",
|
|
|
|
"Master Playback Volume",
|
|
|
|
"PCM Out Path & Mute",
|
|
|
|
"Mono Output Select",
|
|
|
|
/* remove unused AC97 capture controls */
|
|
|
|
"Capture Source",
|
|
|
|
"Capture Switch",
|
|
|
|
"Capture Volume",
|
|
|
|
"Mic Select",
|
2015-07-08 03:52:24 +08:00
|
|
|
"Headphone Playback Switch",
|
|
|
|
"Headphone Playback Volume",
|
|
|
|
"3D Control - Center",
|
|
|
|
"3D Control - Depth",
|
|
|
|
"3D Control - Switch",
|
2005-04-17 06:20:36 +08:00
|
|
|
"Video Playback Switch",
|
|
|
|
"Video Playback Volume",
|
|
|
|
"Mic Playback Switch",
|
|
|
|
"Mic Playback Volume",
|
2015-07-08 03:52:24 +08:00
|
|
|
"External Amplifier",
|
2005-04-17 06:20:36 +08:00
|
|
|
NULL
|
|
|
|
};
|
2020-01-05 22:47:29 +08:00
|
|
|
static const char * const audigy_rename_ctls[] = {
|
2005-04-17 06:20:36 +08:00
|
|
|
/* use conventional names */
|
|
|
|
"Wave Playback Volume", "PCM Playback Volume",
|
|
|
|
/* "Wave Capture Volume", "PCM Capture Volume", */
|
|
|
|
"Wave Master Playback Volume", "Master Playback Volume",
|
|
|
|
"AMic Playback Volume", "Mic Playback Volume",
|
2015-07-08 03:53:15 +08:00
|
|
|
"Master Mono Playback Switch", "Phone Output Playback Switch",
|
|
|
|
"Master Mono Playback Volume", "Phone Output Playback Volume",
|
2005-04-17 06:20:36 +08:00
|
|
|
NULL
|
|
|
|
};
|
2020-01-05 22:47:29 +08:00
|
|
|
static const char * const audigy_rename_ctls_i2c_adc[] = {
|
2006-12-06 23:58:02 +08:00
|
|
|
//"Analog Mix Capture Volume","OLD Analog Mix Capture Volume",
|
|
|
|
"Line Capture Volume", "Analog Mix Capture Volume",
|
|
|
|
"Wave Playback Volume", "OLD PCM Playback Volume",
|
|
|
|
"Wave Master Playback Volume", "Master Playback Volume",
|
|
|
|
"AMic Playback Volume", "Old Mic Playback Volume",
|
2006-12-07 04:38:45 +08:00
|
|
|
"CD Capture Volume", "IEC958 Optical Capture Volume",
|
2006-12-06 23:58:02 +08:00
|
|
|
NULL
|
|
|
|
};
|
2020-01-05 22:47:29 +08:00
|
|
|
static const char * const audigy_remove_ctls_i2c_adc[] = {
|
2006-12-06 23:58:02 +08:00
|
|
|
/* On the Audigy2 ZS Notebook
|
|
|
|
* Capture via WM8775 */
|
|
|
|
"Mic Capture Volume",
|
|
|
|
"Analog Mix Capture Volume",
|
|
|
|
"Aux Capture Volume",
|
2006-12-07 04:38:45 +08:00
|
|
|
"IEC958 Optical Capture Volume",
|
2006-12-06 23:58:02 +08:00
|
|
|
NULL
|
|
|
|
};
|
2020-01-05 22:47:29 +08:00
|
|
|
static const char * const audigy_remove_ctls_1361t_adc[] = {
|
2006-04-10 00:36:39 +08:00
|
|
|
/* On the Audigy2 the AC97 playback is piped into
|
|
|
|
* the Philips ADC for 24bit capture */
|
|
|
|
"PCM Playback Switch",
|
|
|
|
"PCM Playback Volume",
|
|
|
|
"Capture Source",
|
|
|
|
"Capture Switch",
|
|
|
|
"Capture Volume",
|
|
|
|
"Mic Capture Volume",
|
|
|
|
"Headphone Playback Switch",
|
|
|
|
"Headphone Playback Volume",
|
|
|
|
"3D Control - Center",
|
|
|
|
"3D Control - Depth",
|
|
|
|
"3D Control - Switch",
|
|
|
|
"Line2 Playback Volume",
|
|
|
|
"Line2 Capture Volume",
|
|
|
|
NULL
|
|
|
|
};
|
2020-01-05 22:47:29 +08:00
|
|
|
static const char * const audigy_rename_ctls_1361t_adc[] = {
|
2006-04-10 00:36:39 +08:00
|
|
|
"Master Playback Switch", "Master Capture Switch",
|
|
|
|
"Master Playback Volume", "Master Capture Volume",
|
|
|
|
"Wave Master Playback Volume", "Master Playback Volume",
|
2009-11-03 22:47:25 +08:00
|
|
|
"Beep Playback Switch", "Beep Capture Switch",
|
|
|
|
"Beep Playback Volume", "Beep Capture Volume",
|
2006-04-10 00:36:39 +08:00
|
|
|
"Phone Playback Switch", "Phone Capture Switch",
|
|
|
|
"Phone Playback Volume", "Phone Capture Volume",
|
|
|
|
"Mic Playback Switch", "Mic Capture Switch",
|
|
|
|
"Mic Playback Volume", "Mic Capture Volume",
|
|
|
|
"Line Playback Switch", "Line Capture Switch",
|
|
|
|
"Line Playback Volume", "Line Capture Volume",
|
|
|
|
"CD Playback Switch", "CD Capture Switch",
|
|
|
|
"CD Playback Volume", "CD Capture Volume",
|
|
|
|
"Aux Playback Switch", "Aux Capture Switch",
|
|
|
|
"Aux Playback Volume", "Aux Capture Volume",
|
|
|
|
"Video Playback Switch", "Video Capture Switch",
|
|
|
|
"Video Playback Volume", "Video Capture Volume",
|
2015-07-08 03:53:15 +08:00
|
|
|
"Master Mono Playback Switch", "Phone Output Playback Switch",
|
|
|
|
"Master Mono Playback Volume", "Phone Output Playback Volume",
|
2006-04-10 00:36:39 +08:00
|
|
|
NULL
|
|
|
|
};
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-03-30 19:51:18 +08:00
|
|
|
if (emu->card_capabilities->ac97_chip) {
|
2005-11-17 21:50:13 +08:00
|
|
|
struct snd_ac97_bus *pbus;
|
|
|
|
struct snd_ac97_template ac97;
|
2020-01-03 16:16:43 +08:00
|
|
|
static const struct snd_ac97_bus_ops ops = {
|
2005-04-17 06:20:36 +08:00
|
|
|
.write = snd_emu10k1_ac97_write,
|
|
|
|
.read = snd_emu10k1_ac97_read,
|
|
|
|
};
|
|
|
|
|
2021-06-08 22:05:14 +08:00
|
|
|
err = snd_ac97_bus(emu->card, 0, &ops, NULL, &pbus);
|
|
|
|
if (err < 0)
|
2005-10-04 19:49:32 +08:00
|
|
|
return err;
|
2005-04-17 06:20:36 +08:00
|
|
|
pbus->no_vra = 1; /* we don't need VRA */
|
|
|
|
|
|
|
|
memset(&ac97, 0, sizeof(ac97));
|
|
|
|
ac97.private_data = emu;
|
|
|
|
ac97.private_free = snd_emu10k1_mixer_free_ac97;
|
|
|
|
ac97.scaps = AC97_SCAP_NO_SPDIF;
|
2021-06-08 22:05:14 +08:00
|
|
|
err = snd_ac97_mixer(pbus, &ac97, &emu->ac97);
|
|
|
|
if (err < 0) {
|
2005-10-04 19:49:32 +08:00
|
|
|
if (emu->card_capabilities->ac97_chip == 1)
|
|
|
|
return err;
|
2014-02-26 00:02:09 +08:00
|
|
|
dev_info(emu->card->dev,
|
|
|
|
"AC97 is optional on this board\n");
|
|
|
|
dev_info(emu->card->dev,
|
|
|
|
"Proceeding without ac97 mixers...\n");
|
2005-10-04 19:49:32 +08:00
|
|
|
snd_device_free(emu->card, pbus);
|
|
|
|
goto no_ac97; /* FIXME: get rid of ugly gotos.. */
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
if (emu->audigy) {
|
|
|
|
/* set master volume to 0 dB */
|
2006-01-04 23:00:48 +08:00
|
|
|
snd_ac97_write_cache(emu->ac97, AC97_MASTER, 0x0000);
|
2005-04-17 06:20:36 +08:00
|
|
|
/* set capture source to mic */
|
2006-01-04 23:00:48 +08:00
|
|
|
snd_ac97_write_cache(emu->ac97, AC97_REC_SEL, 0x0000);
|
2015-07-08 03:53:15 +08:00
|
|
|
/* set mono output (TAD) to mic */
|
|
|
|
snd_ac97_update_bits(emu->ac97, AC97_GENERAL_PURPOSE,
|
|
|
|
0x0200, 0x0200);
|
2006-04-10 00:36:39 +08:00
|
|
|
if (emu->card_capabilities->adc_1361t)
|
|
|
|
c = audigy_remove_ctls_1361t_adc;
|
|
|
|
else
|
|
|
|
c = audigy_remove_ctls;
|
2005-04-17 06:20:36 +08:00
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Credits for cards based on STAC9758:
|
|
|
|
* James Courtier-Dutton <James@superbug.demon.co.uk>
|
|
|
|
* Voluspa <voluspa@comhem.se>
|
|
|
|
*/
|
|
|
|
if (emu->ac97->id == AC97_ID_STAC9758) {
|
|
|
|
emu->rear_ac97 = 1;
|
|
|
|
snd_emu10k1_ptr_write(emu, AC97SLOT, 0, AC97SLOT_CNTR|AC97SLOT_LFE|AC97SLOT_REAR_LEFT|AC97SLOT_REAR_RIGHT);
|
2007-02-07 02:18:14 +08:00
|
|
|
snd_ac97_write_cache(emu->ac97, AC97_HEADPHONE, 0x0202);
|
2011-04-15 11:42:42 +08:00
|
|
|
remove_ctl(card,"Front Playback Volume");
|
|
|
|
remove_ctl(card,"Front Playback Switch");
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
/* remove unused AC97 controls */
|
2006-01-04 23:00:48 +08:00
|
|
|
snd_ac97_write_cache(emu->ac97, AC97_SURROUND_MASTER, 0x0202);
|
|
|
|
snd_ac97_write_cache(emu->ac97, AC97_CENTER_LFE_MASTER, 0x0202);
|
2005-04-17 06:20:36 +08:00
|
|
|
c = emu10k1_remove_ctls;
|
|
|
|
}
|
|
|
|
for (; *c; c++)
|
|
|
|
remove_ctl(card, *c);
|
2006-12-06 23:58:02 +08:00
|
|
|
} else if (emu->card_capabilities->i2c_adc) {
|
|
|
|
c = audigy_remove_ctls_i2c_adc;
|
|
|
|
for (; *c; c++)
|
|
|
|
remove_ctl(card, *c);
|
2005-04-17 06:20:36 +08:00
|
|
|
} else {
|
2005-09-30 22:56:59 +08:00
|
|
|
no_ac97:
|
2005-03-30 19:51:18 +08:00
|
|
|
if (emu->card_capabilities->ecard)
|
2005-04-17 06:20:36 +08:00
|
|
|
strcpy(emu->card->mixername, "EMU APS");
|
|
|
|
else if (emu->audigy)
|
|
|
|
strcpy(emu->card->mixername, "SB Audigy");
|
|
|
|
else
|
|
|
|
strcpy(emu->card->mixername, "Emu10k1");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (emu->audigy)
|
2006-04-10 00:36:39 +08:00
|
|
|
if (emu->card_capabilities->adc_1361t)
|
|
|
|
c = audigy_rename_ctls_1361t_adc;
|
2006-12-06 23:58:02 +08:00
|
|
|
else if (emu->card_capabilities->i2c_adc)
|
|
|
|
c = audigy_rename_ctls_i2c_adc;
|
2006-04-10 00:36:39 +08:00
|
|
|
else
|
|
|
|
c = audigy_rename_ctls;
|
2005-04-17 06:20:36 +08:00
|
|
|
else
|
|
|
|
c = emu10k1_rename_ctls;
|
|
|
|
for (; *c; c += 2)
|
|
|
|
rename_ctl(card, c[0], c[1]);
|
2006-04-10 00:36:39 +08:00
|
|
|
|
2011-03-30 20:00:39 +08:00
|
|
|
if (emu->card_capabilities->subsystem == 0x80401102) { /* SB Live! Platinum CT4760P */
|
|
|
|
remove_ctl(card, "Center Playback Volume");
|
|
|
|
remove_ctl(card, "LFE Playback Volume");
|
|
|
|
remove_ctl(card, "Wave Center Playback Volume");
|
|
|
|
remove_ctl(card, "Wave LFE Playback Volume");
|
|
|
|
}
|
2005-12-24 23:54:51 +08:00
|
|
|
if (emu->card_capabilities->subsystem == 0x20071102) { /* Audigy 4 Pro */
|
|
|
|
rename_ctl(card, "Line2 Capture Volume", "Line1/Mic Capture Volume");
|
|
|
|
rename_ctl(card, "Analog Mix Capture Volume", "Line2 Capture Volume");
|
|
|
|
rename_ctl(card, "Aux2 Capture Volume", "Line3 Capture Volume");
|
|
|
|
rename_ctl(card, "Mic Capture Volume", "Unknown1 Capture Volume");
|
|
|
|
}
|
2021-06-08 22:05:14 +08:00
|
|
|
kctl = emu->ctl_send_routing = snd_ctl_new1(&snd_emu10k1_send_routing_control, emu);
|
|
|
|
if (!kctl)
|
2005-04-17 06:20:36 +08:00
|
|
|
return -ENOMEM;
|
[ALSA] sound - fix .iface field of mixer control elements
Documentation,CS46xx driver,EMU10K1/EMU10K2 driver,AD1848 driver
SB16/AWE driver,CMIPCI driver,ENS1370/1+ driver,RME32 driver
RME96 driver,ICE1712 driver,ICE1724 driver,KORG1212 driver
RME HDSP driver,RME9652 driver
This patch changes .iface to SNDRV_CTL_ELEM_IFACE_MIXER whre _PCM or
_HWDEP was used in controls that are not associated with a specific PCM
(sub)stream or hwdep device, and changes some controls that got
inconsitent .iface values due to copy+paste errors. Furthermore, it
makes sure that all control that do use _PCM or _HWDEP use the correct
number in the .device field.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
2005-07-29 21:32:58 +08:00
|
|
|
kctl->id.device = pcm_device;
|
2021-06-08 22:05:14 +08:00
|
|
|
err = snd_ctl_add(card, kctl);
|
|
|
|
if (err)
|
2005-04-17 06:20:36 +08:00
|
|
|
return err;
|
2021-06-08 22:05:14 +08:00
|
|
|
kctl = emu->ctl_send_volume = snd_ctl_new1(&snd_emu10k1_send_volume_control, emu);
|
|
|
|
if (!kctl)
|
2005-04-17 06:20:36 +08:00
|
|
|
return -ENOMEM;
|
[ALSA] sound - fix .iface field of mixer control elements
Documentation,CS46xx driver,EMU10K1/EMU10K2 driver,AD1848 driver
SB16/AWE driver,CMIPCI driver,ENS1370/1+ driver,RME32 driver
RME96 driver,ICE1712 driver,ICE1724 driver,KORG1212 driver
RME HDSP driver,RME9652 driver
This patch changes .iface to SNDRV_CTL_ELEM_IFACE_MIXER whre _PCM or
_HWDEP was used in controls that are not associated with a specific PCM
(sub)stream or hwdep device, and changes some controls that got
inconsitent .iface values due to copy+paste errors. Furthermore, it
makes sure that all control that do use _PCM or _HWDEP use the correct
number in the .device field.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
2005-07-29 21:32:58 +08:00
|
|
|
kctl->id.device = pcm_device;
|
2021-06-08 22:05:14 +08:00
|
|
|
err = snd_ctl_add(card, kctl);
|
|
|
|
if (err)
|
2005-04-17 06:20:36 +08:00
|
|
|
return err;
|
2021-06-08 22:05:14 +08:00
|
|
|
kctl = emu->ctl_attn = snd_ctl_new1(&snd_emu10k1_attn_control, emu);
|
|
|
|
if (!kctl)
|
2005-04-17 06:20:36 +08:00
|
|
|
return -ENOMEM;
|
[ALSA] sound - fix .iface field of mixer control elements
Documentation,CS46xx driver,EMU10K1/EMU10K2 driver,AD1848 driver
SB16/AWE driver,CMIPCI driver,ENS1370/1+ driver,RME32 driver
RME96 driver,ICE1712 driver,ICE1724 driver,KORG1212 driver
RME HDSP driver,RME9652 driver
This patch changes .iface to SNDRV_CTL_ELEM_IFACE_MIXER whre _PCM or
_HWDEP was used in controls that are not associated with a specific PCM
(sub)stream or hwdep device, and changes some controls that got
inconsitent .iface values due to copy+paste errors. Furthermore, it
makes sure that all control that do use _PCM or _HWDEP use the correct
number in the .device field.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
2005-07-29 21:32:58 +08:00
|
|
|
kctl->id.device = pcm_device;
|
2021-06-08 22:05:14 +08:00
|
|
|
err = snd_ctl_add(card, kctl);
|
|
|
|
if (err)
|
2005-04-17 06:20:36 +08:00
|
|
|
return err;
|
|
|
|
|
2021-06-08 22:05:14 +08:00
|
|
|
kctl = emu->ctl_efx_send_routing = snd_ctl_new1(&snd_emu10k1_efx_send_routing_control, emu);
|
|
|
|
if (!kctl)
|
2005-04-17 06:20:36 +08:00
|
|
|
return -ENOMEM;
|
[ALSA] sound - fix .iface field of mixer control elements
Documentation,CS46xx driver,EMU10K1/EMU10K2 driver,AD1848 driver
SB16/AWE driver,CMIPCI driver,ENS1370/1+ driver,RME32 driver
RME96 driver,ICE1712 driver,ICE1724 driver,KORG1212 driver
RME HDSP driver,RME9652 driver
This patch changes .iface to SNDRV_CTL_ELEM_IFACE_MIXER whre _PCM or
_HWDEP was used in controls that are not associated with a specific PCM
(sub)stream or hwdep device, and changes some controls that got
inconsitent .iface values due to copy+paste errors. Furthermore, it
makes sure that all control that do use _PCM or _HWDEP use the correct
number in the .device field.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
2005-07-29 21:32:58 +08:00
|
|
|
kctl->id.device = multi_device;
|
2021-06-08 22:05:14 +08:00
|
|
|
err = snd_ctl_add(card, kctl);
|
|
|
|
if (err)
|
2005-04-17 06:20:36 +08:00
|
|
|
return err;
|
|
|
|
|
2021-06-08 22:05:14 +08:00
|
|
|
kctl = emu->ctl_efx_send_volume = snd_ctl_new1(&snd_emu10k1_efx_send_volume_control, emu);
|
|
|
|
if (!kctl)
|
2005-04-17 06:20:36 +08:00
|
|
|
return -ENOMEM;
|
[ALSA] sound - fix .iface field of mixer control elements
Documentation,CS46xx driver,EMU10K1/EMU10K2 driver,AD1848 driver
SB16/AWE driver,CMIPCI driver,ENS1370/1+ driver,RME32 driver
RME96 driver,ICE1712 driver,ICE1724 driver,KORG1212 driver
RME HDSP driver,RME9652 driver
This patch changes .iface to SNDRV_CTL_ELEM_IFACE_MIXER whre _PCM or
_HWDEP was used in controls that are not associated with a specific PCM
(sub)stream or hwdep device, and changes some controls that got
inconsitent .iface values due to copy+paste errors. Furthermore, it
makes sure that all control that do use _PCM or _HWDEP use the correct
number in the .device field.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
2005-07-29 21:32:58 +08:00
|
|
|
kctl->id.device = multi_device;
|
2021-06-08 22:05:14 +08:00
|
|
|
err = snd_ctl_add(card, kctl);
|
|
|
|
if (err)
|
2005-04-17 06:20:36 +08:00
|
|
|
return err;
|
|
|
|
|
2021-06-08 22:05:14 +08:00
|
|
|
kctl = emu->ctl_efx_attn = snd_ctl_new1(&snd_emu10k1_efx_attn_control, emu);
|
|
|
|
if (!kctl)
|
2005-04-17 06:20:36 +08:00
|
|
|
return -ENOMEM;
|
[ALSA] sound - fix .iface field of mixer control elements
Documentation,CS46xx driver,EMU10K1/EMU10K2 driver,AD1848 driver
SB16/AWE driver,CMIPCI driver,ENS1370/1+ driver,RME32 driver
RME96 driver,ICE1712 driver,ICE1724 driver,KORG1212 driver
RME HDSP driver,RME9652 driver
This patch changes .iface to SNDRV_CTL_ELEM_IFACE_MIXER whre _PCM or
_HWDEP was used in controls that are not associated with a specific PCM
(sub)stream or hwdep device, and changes some controls that got
inconsitent .iface values due to copy+paste errors. Furthermore, it
makes sure that all control that do use _PCM or _HWDEP use the correct
number in the .device field.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
2005-07-29 21:32:58 +08:00
|
|
|
kctl->id.device = multi_device;
|
2021-06-08 22:05:14 +08:00
|
|
|
err = snd_ctl_add(card, kctl);
|
|
|
|
if (err)
|
2005-04-17 06:20:36 +08:00
|
|
|
return err;
|
|
|
|
|
2023-05-11 01:37:22 +08:00
|
|
|
if (!emu->card_capabilities->ecard && !emu->card_capabilities->emu_model) {
|
2005-04-17 06:20:36 +08:00
|
|
|
/* sb live! and audigy */
|
2021-06-08 22:05:14 +08:00
|
|
|
kctl = snd_ctl_new1(&snd_emu10k1_spdif_mask_control, emu);
|
|
|
|
if (!kctl)
|
2005-04-17 06:20:36 +08:00
|
|
|
return -ENOMEM;
|
2005-08-03 19:50:30 +08:00
|
|
|
if (!emu->audigy)
|
|
|
|
kctl->id.device = emu->pcm_efx->device;
|
2021-06-08 22:05:14 +08:00
|
|
|
err = snd_ctl_add(card, kctl);
|
|
|
|
if (err)
|
2005-04-17 06:20:36 +08:00
|
|
|
return err;
|
2021-06-08 22:05:14 +08:00
|
|
|
kctl = snd_ctl_new1(&snd_emu10k1_spdif_control, emu);
|
|
|
|
if (!kctl)
|
2005-04-17 06:20:36 +08:00
|
|
|
return -ENOMEM;
|
2005-08-03 19:50:30 +08:00
|
|
|
if (!emu->audigy)
|
|
|
|
kctl->id.device = emu->pcm_efx->device;
|
2021-06-08 22:05:14 +08:00
|
|
|
err = snd_ctl_add(card, kctl);
|
|
|
|
if (err)
|
2005-04-17 06:20:36 +08:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2007-11-04 22:08:26 +08:00
|
|
|
if (emu->card_capabilities->emu_model) {
|
2005-12-05 01:03:03 +08:00
|
|
|
; /* Disable the snd_audigy_spdif_shared_spdif */
|
|
|
|
} else if (emu->audigy) {
|
2021-06-08 22:05:14 +08:00
|
|
|
kctl = snd_ctl_new1(&snd_audigy_shared_spdif, emu);
|
|
|
|
if (!kctl)
|
2005-04-17 06:20:36 +08:00
|
|
|
return -ENOMEM;
|
2021-06-08 22:05:14 +08:00
|
|
|
err = snd_ctl_add(card, kctl);
|
|
|
|
if (err)
|
2005-04-17 06:20:36 +08:00
|
|
|
return err;
|
2005-04-10 05:38:25 +08:00
|
|
|
#if 0
|
2021-06-08 22:05:14 +08:00
|
|
|
kctl = snd_ctl_new1(&snd_audigy_spdif_output_rate, emu);
|
|
|
|
if (!kctl)
|
2005-04-17 06:20:36 +08:00
|
|
|
return -ENOMEM;
|
2021-06-08 22:05:14 +08:00
|
|
|
err = snd_ctl_add(card, kctl);
|
|
|
|
if (err)
|
2005-04-17 06:20:36 +08:00
|
|
|
return err;
|
2005-04-10 05:38:25 +08:00
|
|
|
#endif
|
2005-03-30 19:51:18 +08:00
|
|
|
} else if (! emu->card_capabilities->ecard) {
|
2005-04-17 06:20:36 +08:00
|
|
|
/* sb live! */
|
2021-06-08 22:05:14 +08:00
|
|
|
kctl = snd_ctl_new1(&snd_emu10k1_shared_spdif, emu);
|
|
|
|
if (!kctl)
|
2005-04-17 06:20:36 +08:00
|
|
|
return -ENOMEM;
|
2021-06-08 22:05:14 +08:00
|
|
|
err = snd_ctl_add(card, kctl);
|
|
|
|
if (err)
|
2005-04-17 06:20:36 +08:00
|
|
|
return err;
|
|
|
|
}
|
2005-03-30 19:51:18 +08:00
|
|
|
if (emu->card_capabilities->ca0151_chip) { /* P16V */
|
2021-06-08 22:05:14 +08:00
|
|
|
err = snd_p16v_mixer(emu);
|
|
|
|
if (err)
|
2005-04-17 06:20:36 +08:00
|
|
|
return err;
|
|
|
|
}
|
2006-10-01 17:48:04 +08:00
|
|
|
|
ALSA: emu10k1: make E-MU I/O routing init data-driven
... and move it to the mixer init, as it's logically part of it.
As a side effect, this fixes the initial values of the input destination
mixer controls, which would have previously remained at "Silent" despite
different defaults. This didn't really matter, though, as ALSA state
restoration would hide that bug beyond first use.
Note that this completely does away with clearing the output routing
registers, as it was rather pointless - we just programmed the FPGA
(resetting it first if necessary), so everything is zeroed anyway
(that's documented by Xilinx, and as further evidence, some of the loops
terminated too early, and we didn't bother clearing the high channels of
the input routes at all, all with no observed adverse effects).
As a drive-by, this also fixes some capture channel defaults - any
EMU_SRC_*2 isn't a sensible value in 1x clock mode.
Signed-off-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Link: https://lore.kernel.org/r/20230516093612.3536508-7-oswald.buddenhagen@gmx.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-05-16 17:36:08 +08:00
|
|
|
if (emu->card_capabilities->emu_model) {
|
|
|
|
unsigned i, emu_idx = emu1010_idx(emu);
|
|
|
|
const struct snd_emu1010_routing_info *emu_ri =
|
|
|
|
&emu1010_routing_info[emu_idx];
|
2023-05-16 17:36:09 +08:00
|
|
|
const struct snd_emu1010_pads_info *emu_pi = &emu1010_pads_info[emu_idx];
|
ALSA: emu10k1: make E-MU I/O routing init data-driven
... and move it to the mixer init, as it's logically part of it.
As a side effect, this fixes the initial values of the input destination
mixer controls, which would have previously remained at "Silent" despite
different defaults. This didn't really matter, though, as ALSA state
restoration would hide that bug beyond first use.
Note that this completely does away with clearing the output routing
registers, as it was rather pointless - we just programmed the FPGA
(resetting it first if necessary), so everything is zeroed anyway
(that's documented by Xilinx, and as further evidence, some of the loops
terminated too early, and we didn't bother clearing the high channels of
the input routes at all, all with no observed adverse effects).
As a drive-by, this also fixes some capture channel defaults - any
EMU_SRC_*2 isn't a sensible value in 1x clock mode.
Signed-off-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Link: https://lore.kernel.org/r/20230516093612.3536508-7-oswald.buddenhagen@gmx.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-05-16 17:36:08 +08:00
|
|
|
|
|
|
|
for (i = 0; i < emu_ri->n_ins; i++)
|
|
|
|
emu->emu1010.input_source[i] =
|
|
|
|
emu1010_map_source(emu_ri, emu_ri->in_dflts[i]);
|
|
|
|
for (i = 0; i < emu_ri->n_outs; i++)
|
|
|
|
emu->emu1010.output_source[i] =
|
|
|
|
emu1010_map_source(emu_ri, emu_ri->out_dflts[i]);
|
|
|
|
snd_emu1010_apply_sources(emu);
|
|
|
|
|
2023-07-16 00:07:38 +08:00
|
|
|
kctl = emu->ctl_clock_source = snd_ctl_new1(&snd_emu1010_clock_source, emu);
|
|
|
|
err = snd_ctl_add(card, kctl);
|
2023-06-13 03:13:17 +08:00
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
err = snd_ctl_add(card,
|
|
|
|
snd_ctl_new1(&snd_emu1010_clock_fallback, emu));
|
2007-12-13 23:27:13 +08:00
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
|
2023-05-16 17:36:05 +08:00
|
|
|
err = add_ctls(emu, &emu1010_adc_pads_ctl,
|
2023-05-16 17:36:09 +08:00
|
|
|
emu_pi->adc_ctls, emu_pi->n_adc_ctls);
|
2023-05-16 17:36:05 +08:00
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
err = add_ctls(emu, &emu1010_dac_pads_ctl,
|
2023-05-16 17:36:09 +08:00
|
|
|
emu_pi->dac_ctls, emu_pi->n_dac_ctls);
|
2006-10-11 01:08:45 +08:00
|
|
|
if (err < 0)
|
|
|
|
return err;
|
2023-05-16 17:36:09 +08:00
|
|
|
|
2023-05-16 17:36:11 +08:00
|
|
|
if (!emu->card_capabilities->no_adat) {
|
|
|
|
err = snd_ctl_add(card,
|
|
|
|
snd_ctl_new1(&snd_emu1010_optical_out, emu));
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
err = snd_ctl_add(card,
|
|
|
|
snd_ctl_new1(&snd_emu1010_optical_in, emu));
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
}
|
2023-05-16 17:36:09 +08:00
|
|
|
|
|
|
|
err = add_emu1010_source_mixers(emu);
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
2006-10-01 17:48:04 +08:00
|
|
|
}
|
2006-12-06 23:58:02 +08:00
|
|
|
|
|
|
|
if ( emu->card_capabilities->i2c_adc) {
|
|
|
|
err = snd_ctl_add(card, snd_ctl_new1(&snd_audigy_i2c_capture_source, emu));
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
|
2023-05-16 17:36:05 +08:00
|
|
|
err = add_ctls(emu, &i2c_volume_ctl,
|
|
|
|
snd_audigy_i2c_volume_ctls,
|
|
|
|
ARRAY_SIZE(snd_audigy_i2c_volume_ctls));
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
2006-12-06 23:58:02 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-12-02 16:31:16 +08:00
|
|
|
if (emu->card_capabilities->ac97_chip && emu->audigy) {
|
|
|
|
err = snd_ctl_add(card, snd_ctl_new1(&snd_audigy_capture_boost,
|
|
|
|
emu));
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
|
|
|
}
|