From patchwork Wed May 14 07:37:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sascha Hauer X-Patchwork-Id: 4173261 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1CF239F3AE for ; Wed, 14 May 2014 07:41:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1A4E320375 for ; Wed, 14 May 2014 07:41:17 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id CCF4F20136 for ; Wed, 14 May 2014 07:41:15 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id ECAB82625D4; Wed, 14 May 2014 09:41:14 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id E44BB2654FD; Wed, 14 May 2014 09:39:56 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id CC62E2654FD; Wed, 14 May 2014 09:39:55 +0200 (CEST) Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [92.198.50.35]) by alsa0.perex.cz (Postfix) with ESMTP id 4C3552619E5 for ; Wed, 14 May 2014 09:37:58 +0200 (CEST) Received: from dude.hi.pengutronix.de ([2001:6f8:1178:2:a236:9fff:fe00:814]) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1WkTku-0007oq-Kj; Wed, 14 May 2014 09:37:36 +0200 Received: from sha by dude.hi.pengutronix.de with local (Exim 4.82) (envelope-from ) id 1WkTkx-0001kv-Sy; Wed, 14 May 2014 09:37:39 +0200 From: Sascha Hauer To: alsa-devel@alsa-project.org Date: Wed, 14 May 2014 09:37:37 +0200 Message-Id: <1400053058-1115-6-git-send-email-s.hauer@pengutronix.de> X-Mailer: git-send-email 2.0.0.rc0 In-Reply-To: <1400053058-1115-1-git-send-email-s.hauer@pengutronix.de> References: <1400053058-1115-1-git-send-email-s.hauer@pengutronix.de> X-SA-Exim-Connect-IP: 2001:6f8:1178:2:a236:9fff:fe00:814 X-SA-Exim-Mail-From: sha@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: alsa-devel@alsa-project.org Cc: Sascha Hauer , Mark Brown Subject: [alsa-devel] [PATCH 5/6] ASoC: ak4642: Implement Microphone in pathes X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Sascha Hauer --- sound/soc/codecs/ak4642.c | 114 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) diff --git a/sound/soc/codecs/ak4642.c b/sound/soc/codecs/ak4642.c index 3ba4c0f..6292a6a 100644 --- a/sound/soc/codecs/ak4642.c +++ b/sound/soc/codecs/ak4642.c @@ -153,6 +153,81 @@ struct ak4642_priv { */ static const DECLARE_TLV_DB_SCALE(out_tlv, -11550, 50, 1); +static const char * const ak4642_micl_strings[] = { "LIN1", "LIN2", "LIN3", "LIN4" }; +static const char * const ak4642_micr_strings[] = { "RIN1", "RIN2", "RIN3", "RIN4" }; + +static const struct soc_enum ak4642_micl_enum = + SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(ak4642_micl_strings), + ak4642_micl_strings); + +static const struct soc_enum ak4642_micr_enum = + SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(ak4642_micr_strings), + ak4642_micr_strings); + +static int ak4642_micl_enum_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol); + u32 val, inl; + + val = snd_soc_read(codec, PW_MGMT3); + + inl = (val >> 1) & 0x1; + inl |= (val >> 5) & 0x2; + + ucontrol->value.integer.value[0] = inl; + + return 0; +} + +static int ak4642_micl_enum_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol); + int val, inl; + + val = ucontrol->value.integer.value[0]; + + inl = (val & 0x1) << 1; + inl |= (val & 0x2) << 5; + + snd_soc_update_bits(codec, PW_MGMT3, (1 << 1) | (1 << 6), inl); + + return 1; +} + +static int ak4642_micr_enum_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol); + u32 val, inr; + + val = snd_soc_read(codec, PW_MGMT3); + + inr = (val >> 2) & 0x1; + inr |= (val >> 6) & 0x2; + + ucontrol->value.integer.value[0] = inr; + + return 0; +} + +static int ak4642_micr_enum_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol); + int val, inr; + + val = ucontrol->value.integer.value[0]; + + inr = (val & 0x1) << 2; + inr |= (val & 0x2) << 6; + + snd_soc_update_bits(codec, PW_MGMT3, (1 << 2) | (1 << 7), inr); + + return 1; +} + static const struct snd_kcontrol_new ak4642_snd_controls[] = { SOC_DOUBLE_R_TLV("Digital Playback Volume", L_DVC, R_DVC, @@ -168,6 +243,16 @@ static const struct snd_kcontrol_new ak4642_lout_mixer_controls[] = { SOC_DAPM_SINGLE("DACL", SG_SL1, 4, 1, 0), }; +static const struct snd_kcontrol_new ak4642_micl_controls[] = { + SOC_ENUM_EXT("Mic Left Capture Route", ak4642_micl_enum, + ak4642_micl_enum_get, ak4642_micl_enum_put), +}; + +static const struct snd_kcontrol_new ak4642_micr_controls[] = { + SOC_ENUM_EXT("Mic Right Capture Route", ak4642_micr_enum, + ak4642_micr_enum_get, ak4642_micr_enum_put), +}; + static const struct snd_soc_dapm_widget ak4642_dapm_widgets[] = { /* Outputs */ @@ -188,6 +273,22 @@ static const struct snd_soc_dapm_widget ak4642_dapm_widgets[] = { /* DAC */ SND_SOC_DAPM_DAC("DAC", "HiFi Playback", PW_MGMT1, 2, 0), + + SND_SOC_DAPM_ADC("ADC", "Capture", SND_SOC_NOPM, 0, 0), + + SND_SOC_DAPM_MUX("Mic Left Capture Route", + SND_SOC_NOPM, 0, 0, ak4642_micl_controls), + SND_SOC_DAPM_MUX("Mic Right Capture Route", + SND_SOC_NOPM, 0, 0, ak4642_micr_controls), + + SND_SOC_DAPM_INPUT("LIN1"), + SND_SOC_DAPM_INPUT("LIN2"), + SND_SOC_DAPM_INPUT("LIN3"), + SND_SOC_DAPM_INPUT("LIN4"), + SND_SOC_DAPM_INPUT("RIN1"), + SND_SOC_DAPM_INPUT("RIN2"), + SND_SOC_DAPM_INPUT("RIN3"), + SND_SOC_DAPM_INPUT("RIN4"), }; static const struct snd_soc_dapm_route ak4642_intercon[] = { @@ -205,6 +306,19 @@ static const struct snd_soc_dapm_route ak4642_intercon[] = { {"DACH", NULL, "DAC"}, {"LINEOUT Mixer", "DACL", "DAC"}, + + {"Mic Left Capture Route", "LIN1", "LIN1"}, + {"Mic Left Capture Route", NULL, "LIN2"}, + {"Mic Left Capture Route", NULL, "LIN3"}, + {"Mic Left Capture Route", NULL, "LIN4"}, + + {"Mic Right Capture Route", "RIN1", "RIN1"}, + {"Mic Right Capture Route", NULL, "RIN2"}, + {"Mic Right Capture Route", NULL, "RIN3"}, + {"Mic Right Capture Route", NULL, "RIN4"}, + + {"ADC", NULL, "Mic Right Capture Route"}, + {"ADC", NULL, "Mic Left Capture Route"}, }; /*