From patchwork Mon Jul 17 10:20:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 13315398 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DEF72EB64DC for ; Mon, 17 Jul 2023 10:23:39 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 99202DEC; Mon, 17 Jul 2023 12:22:47 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 99202DEC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1689589417; bh=MzKi7VoadE+F+sw82wvpygf+dp7NL1ahajfncYXkh2A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=nqMttXOaVOq/J/F0s125/yBk6SjnCA/uytm0JDjJ0kW5/lmwUJfqNrUW4ZnVEz6bw Ih+CEWtQa8N6JMDzcPtsoLEg2fbUX9eJ6ErIkp8f03Jm7TzSUseQBvOtvkzBZXg3yo +T+7Goa1ln8K5fUxKIGYr7bIRb0Cnqlg8WEu29r4= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 3D1B7F80494; Mon, 17 Jul 2023 12:22:47 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id D46B9F804DA; Mon, 17 Jul 2023 12:22:46 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 133E6F80494; Mon, 17 Jul 2023 12:22:43 +0200 (CEST) Received: from bluemchen.kde.org (bluemchen.kde.org [209.51.188.41]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 8EEC0F80551 for ; Mon, 17 Jul 2023 12:20:38 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 8EEC0F80551 Received: from ugly.fritz.box (localhost [127.0.0.1]) by bluemchen.kde.org (Postfix) with ESMTP id 13FD7241E3; Mon, 17 Jul 2023 06:20:37 -0400 (EDT) Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1qLLLI-hAl-00; Mon, 17 Jul 2023 12:20:36 +0200 From: Oswald Buddenhagen To: alsa-devel@alsa-project.org Cc: Takashi Iwai , Jaroslav Kysela Subject: [PATCH v3 2/6] ALSA: emu10k1: improve mixer control naming in E-MU D.A.S. mode Date: Mon, 17 Jul 2023 12:20:32 +0200 Message-Id: <20230717102036.404260-3-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.40.0.152.g15d061e6df In-Reply-To: <20230717102036.404260-1-oswald.buddenhagen@gmx.de> References: <20230717102036.404260-1-oswald.buddenhagen@gmx.de> MIME-Version: 1.0 Message-ID-Hash: MKOTMUMQVLMG3P5HNEBD63T2G7H7Y2DF X-Message-ID-Hash: MKOTMUMQVLMG3P5HNEBD63T2G7H7Y2DF X-MailFrom: ossi@kde.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Use the clearer "PbChn " instead of "DSP " for the source names. In particular, this is much less confusing in the capture source selection - "DSP 0" having the source "DSP 0" really didn't help. I didn't use "Playback Channel ", because that would be a tad too long to be sensibly displayed in alsamixer. The capture enums also get a "DSP" => "CpChn" replacement. I used zero-padded decimals, so the capture elements are properly sorted in alsamixer. I found hex too confusing. Note that unlike in the legacy mixer, we define enum values only for actually "wired" channels. I'm leaving the legacy mixer alone, as I don't want to completely invalidate saved mixer states. This introduces some bloat, but it seems bearable. Signed-off-by: Oswald Buddenhagen --- sound/pci/emu10k1/emumixer.c | 108 ++++++++++++++++++++++++++--------- 1 file changed, 81 insertions(+), 27 deletions(-) diff --git a/sound/pci/emu10k1/emumixer.c b/sound/pci/emu10k1/emumixer.c index 278aecb3fd94..4ab00f65e48d 100644 --- a/sound/pci/emu10k1/emumixer.c +++ b/sound/pci/emu10k1/emumixer.c @@ -100,6 +100,12 @@ static int snd_emu10k1_spdif_get_mask(struct snd_kcontrol *kcontrol, "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 PB_TEXTS \ + "PbChn 00", "PbChn 01", "PbChn 02", "PbChn 03", \ + "PbChn 04", "PbChn 05", "PbChn 06", "PbChn 07", \ + "PbChn 08", "PbChn 09", "PbChn 10", "PbChn 11", \ + "PbChn 12", "PbChn 13", "PbChn 14", "PbChn 15" + #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, "") @@ -155,6 +161,11 @@ static const char * const emu1010_src_texts[] = { DSP_TEXTS, }; +static const char * const emu1010_das_src_texts[] = { + EMU1010_COMMON_TEXTS, + PB_TEXTS, +}; + static const unsigned short emu1010_src_regs[] = { EMU_SRC_SILENCE, PAIR_REGS(EMU_SRC_DOCK_MIC, _A, _B), @@ -186,6 +197,11 @@ static const char * const emu1010b_src_texts[] = { DSP_TEXTS, }; +static const char * const emu1010b_das_src_texts[] = { + EMU1010b_COMMON_TEXTS, + PB_TEXTS, +}; + static const unsigned short emu1010b_src_regs[] = { EMU_SRC_SILENCE, PAIR_REGS(EMU_SRC_DOCK_MIC, _A, _B), @@ -215,6 +231,11 @@ static const char * const emu1616_src_texts[] = { DSP_TEXTS, }; +static const char * const emu1616_das_src_texts[] = { + EMU1616_COMMON_TEXTS, + PB_TEXTS, +}; + static const unsigned short emu1616_src_regs[] = { EMU_SRC_SILENCE, PAIR_REGS(EMU_SRC_DOCK_MIC, _A, _B), @@ -238,6 +259,11 @@ static const char * const emu0404_src_texts[] = { DSP_TEXTS, }; +static const char * const emu0404_das_src_texts[] = { + EMU0404_COMMON_TEXTS, + PB_TEXTS, +}; + static const unsigned short emu0404_src_regs[] = { EMU_SRC_SILENCE, LR_REGS(EMU_SRC_HAMOA_ADC), @@ -421,6 +447,25 @@ static const char * const emu1010_input_texts[] = { }; static_assert(ARRAY_SIZE(emu1010_input_texts) <= NUM_INPUT_DESTS); +static const char * const emu1010_das_input_texts[] = { + "CpChn 00 Capture Enum", + "CpChn 01 Capture Enum", + "CpChn 02 Capture Enum", + "CpChn 03 Capture Enum", + "CpChn 04 Capture Enum", + "CpChn 05 Capture Enum", + "CpChn 06 Capture Enum", + "CpChn 07 Capture Enum", + "CpChn 08 Capture Enum", + "CpChn 09 Capture Enum", + "CpChn 10 Capture Enum", + "CpChn 11 Capture Enum", + "CpChn 12 Capture Enum", + "CpChn 13 Capture Enum", + "CpChn 14 Capture Enum", + "CpChn 15 Capture Enum", +}; + static const unsigned short emu1010_input_dst[] = { EMU_DST_ALICE2_EMU32_0, EMU_DST_ALICE2_EMU32_1, @@ -498,78 +543,78 @@ static const unsigned short emu0404_input_dflt[] = { }; struct snd_emu1010_routing_info { - const char * const *src_texts; + const char * const *src_texts[2]; const char * const *out_texts; const unsigned short *src_regs; const unsigned short *out_regs; const unsigned short *in_regs; const unsigned short *out_dflts; const unsigned short *in_dflts; - unsigned n_srcs; + unsigned n_srcs[2]; unsigned n_outs; - unsigned n_ins; + unsigned n_ins[2]; }; static const struct snd_emu1010_routing_info emu1010_routing_info[] = { { /* rev1 1010 */ .src_regs = emu1010_src_regs, - .src_texts = emu1010_src_texts, - .n_srcs = ARRAY_SIZE(emu1010_src_texts), + .src_texts = { emu1010_src_texts, emu1010_das_src_texts }, + .n_srcs = { ARRAY_SIZE(emu1010_src_texts), ARRAY_SIZE(emu1010_das_src_texts) }, .out_dflts = emu1010_output_dflt, .out_regs = emu1010_output_dst, .out_texts = emu1010_output_texts, .n_outs = ARRAY_SIZE(emu1010_output_dst), .in_dflts = emu1010_input_dflt, .in_regs = emu1010_input_dst, - .n_ins = ARRAY_SIZE(emu1010_input_dst), + .n_ins = { ARRAY_SIZE(emu1010_input_dst), 16 }, }, { /* rev2 1010 */ .src_regs = emu1010b_src_regs, - .src_texts = emu1010b_src_texts, - .n_srcs = ARRAY_SIZE(emu1010b_src_texts), + .src_texts = { emu1010b_src_texts, emu1010b_das_src_texts }, + .n_srcs = { ARRAY_SIZE(emu1010b_src_texts), ARRAY_SIZE(emu1010b_das_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, + .n_ins = { ARRAY_SIZE(emu1010_input_dst) - 6, 16 }, }, { /* 1616(m) cardbus */ .src_regs = emu1616_src_regs, - .src_texts = emu1616_src_texts, - .n_srcs = ARRAY_SIZE(emu1616_src_texts), + .src_texts = { emu1616_src_texts, emu1616_das_src_texts }, + .n_srcs = { ARRAY_SIZE(emu1616_src_texts), ARRAY_SIZE(emu1616_das_src_texts) }, .out_dflts = emu1616_output_dflt, .out_regs = emu1616_output_dst, .out_texts = snd_emu1616_output_texts, .n_outs = ARRAY_SIZE(emu1616_output_dst), .in_dflts = emu1010_input_dflt, .in_regs = emu1010_input_dst, - .n_ins = ARRAY_SIZE(emu1010_input_dst) - 6, + .n_ins = { ARRAY_SIZE(emu1010_input_dst) - 6, 16 }, }, { /* 0404 */ .src_regs = emu0404_src_regs, - .src_texts = emu0404_src_texts, - .n_srcs = ARRAY_SIZE(emu0404_src_texts), + .src_texts = { emu0404_src_texts, emu0404_das_src_texts }, + .n_srcs = { ARRAY_SIZE(emu0404_src_texts), ARRAY_SIZE(emu0404_das_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, + .n_ins = { ARRAY_SIZE(emu1010_input_dst) - 6, 16 }, }, }; @@ -602,32 +647,34 @@ static void snd_emu1010_apply_sources(struct snd_emu10k1 *emu) { const struct snd_emu1010_routing_info *emu_ri = &emu1010_routing_info[emu1010_idx(emu)]; + unsigned iidx = emu->das_mode; 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++) + for (unsigned i = 0; i < emu_ri->n_ins[iidx]; 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) + unsigned das_mode, unsigned val) { - for (unsigned i = 0; i < emu_ri->n_srcs; i++) + for (unsigned i = 0; i < emu_ri->n_srcs[das_mode]; i++) if (val == emu_ri->src_regs[i]) return i; return 0; } static int snd_emu1010_input_output_source_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); const struct snd_emu1010_routing_info *emu_ri = &emu1010_routing_info[emu1010_idx(emu)]; + unsigned iidx = emu->das_mode; - return snd_ctl_enum_info(uinfo, 1, emu_ri->n_srcs, emu_ri->src_texts); + return snd_ctl_enum_info(uinfo, 1, emu_ri->n_srcs[iidx], emu_ri->src_texts[iidx]); } static int snd_emu1010_output_source_get(struct snd_kcontrol *kcontrol, @@ -650,11 +697,12 @@ static int snd_emu1010_output_source_put(struct snd_kcontrol *kcontrol, struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); const struct snd_emu1010_routing_info *emu_ri = &emu1010_routing_info[emu1010_idx(emu)]; + unsigned iidx = emu->das_mode; unsigned val = ucontrol->value.enumerated.item[0]; unsigned channel = kcontrol->private_value; int change; - if (val >= emu_ri->n_srcs) + if (val >= emu_ri->n_srcs[iidx]) return -EINVAL; if (channel >= emu_ri->n_outs) return -EINVAL; @@ -680,27 +728,29 @@ static int snd_emu1010_input_source_get(struct snd_kcontrol *kcontrol, struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); const struct snd_emu1010_routing_info *emu_ri = &emu1010_routing_info[emu1010_idx(emu)]; + unsigned iidx = emu->das_mode; unsigned channel = kcontrol->private_value; - if (channel >= emu_ri->n_ins) + if (channel >= emu_ri->n_ins[iidx]) return -EINVAL; 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); const struct snd_emu1010_routing_info *emu_ri = &emu1010_routing_info[emu1010_idx(emu)]; + unsigned iidx = emu->das_mode; unsigned val = ucontrol->value.enumerated.item[0]; unsigned channel = kcontrol->private_value; int change; - if (val >= emu_ri->n_srcs) + if (val >= emu_ri->n_srcs[iidx]) return -EINVAL; - if (channel >= emu_ri->n_ins) + if (channel >= emu_ri->n_ins[iidx]) return -EINVAL; change = (emu->emu1010.input_source[channel] != val); if (change) { @@ -722,14 +772,17 @@ static int add_emu1010_source_mixers(struct snd_emu10k1 *emu) { const struct snd_emu1010_routing_info *emu_ri = &emu1010_routing_info[emu1010_idx(emu)]; + unsigned iidx = emu->das_mode; 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); + iidx ? emu1010_das_input_texts : + emu1010_input_texts, + emu_ri->n_ins[iidx]); return err; } @@ -2330,13 +2383,14 @@ int snd_emu10k1_mixer(struct snd_emu10k1 *emu, const struct snd_emu1010_routing_info *emu_ri = &emu1010_routing_info[emu_idx]; const struct snd_emu1010_pads_info *emu_pi = &emu1010_pads_info[emu_idx]; + int midx = emu->das_mode; - for (i = 0; i < emu_ri->n_ins; i++) + for (i = 0; i < emu_ri->n_ins[midx]; i++) emu->emu1010.input_source[i] = - emu1010_map_source(emu_ri, emu_ri->in_dflts[i]); + emu1010_map_source(emu_ri, midx, 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]); + emu1010_map_source(emu_ri, midx, emu_ri->out_dflts[i]); snd_emu1010_apply_sources(emu); kctl = emu->ctl_clock_source = snd_ctl_new1(&snd_emu1010_clock_source, emu);