From patchwork Sun Dec 3 20:41:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasily Khoruzhick X-Patchwork-Id: 10089401 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A83086035E for ; Sun, 3 Dec 2017 20:44:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B280C28DD1 for ; Sun, 3 Dec 2017 20:44:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A769C28DE5; Sun, 3 Dec 2017 20:44:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2B34D28DD1 for ; Sun, 3 Dec 2017 20:44:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=i+xZWE2f0q+mSiOVhc4oFhcdTOJkAhPT/28aIELyGvA=; b=qvcT9LNv66JUddjM2+za0gvjUa tp8+U/HKapNeQ02Mgvd6zQBUI+7i8R5b+FVeC/98RUDIfBp0kWgtAqor+04nTNDoiuEKRRn3/asOa LuGhQfk/jWnmcHOGY5QbCGUO5nmjXLS+qzfOJtJtP9hARVLbsQZrgzJagv0vTgSm/5HpoYKBAmBYw Ce9VXxYHjcMD7cXUjqlK1gCP1VWZYeJBXTcOy4QD1WN4OU7ZS0aU/m4v4yNKauuB0ZNNXf/c7ADW4 T8Mo4+xmIIdwhY5jMacrUnr4r3i2fFru5KLLABkIbct33IaSHajX8kFPW16D8BTyaK4BGUxGeD6Ez IKpJWRLw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eLb7d-0000MQ-2m; Sun, 03 Dec 2017 20:44:21 +0000 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eLb5p-00070I-0J for linux-arm-kernel@lists.infradead.org; Sun, 03 Dec 2017 20:42:32 +0000 Received: by mail-pg0-x243.google.com with SMTP id w7so6748650pgv.6 for ; Sun, 03 Dec 2017 12:42:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=IFjNMGZX4VwcwWQrwfuUSRxJ5Dp+nnX+w9gPE6ihq+E=; b=cRdws7J49cQRUZV6gTjKa/7Ef6vbqqt96gYo/syIQfFH/TD7oE0AvlcaLcwt4tjTvm 7liegCQN53408boiY/lQTu+FZKZspI3V2ueeA/JagFv/lfBe+zeVWxTJj9l5E59i8jru ceyhaIm1ajGpBmLsXZ+Oci4xtNTlGIcHA55zlDGEr5bnSSb/xPO9ggfc994vJdT8865A ouGrz25kBGXangX5nh2d4ZZ/ZVvQYe5JZExCwxZwunAaLOd6BAbf4oGVrB3BxtbawtqW vnUZbiTxb3xfp8E5caEjYps1fu49OQ85jbjzvph4wSNoxz5J3pSzTiJHqABk9TH46LJD fpxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=IFjNMGZX4VwcwWQrwfuUSRxJ5Dp+nnX+w9gPE6ihq+E=; b=XM8bdt0osJ5XZmmQPggQJnXCpqhxKkKeAo21JWK6TM+hZVhvYpHK5XYMRbZXunjP/s Q81xSMjCguj306S65uudMiF0YWy7y0Zd1fLXk14IXKGa4GJ1X/4WRXJ7JDZGuH685QSc v7U6k6Porh+EgODIxmYlZkMCw3oFNmV6fqNcBoNX9DL1zYbAgUrGb02dQtQ8QZY8PuXo 7KCLz/454uwCtRevTMXSu4/rTkd04GS1stk5KRGJ113+bf/HrArSqORq8ou3gl1HlwIV U38KNJ5XIvG4931vysphX7qOsOydGJ1vXEaXPp5L9V5pNllbeLl0Gnk1bApG8zC/Kobi volw== X-Gm-Message-State: AJaThX5dLT7PL0oaOdMSn4MM8siqTO6pckdJzRpdc/PTd4hTNZVy5Tzq JSPhUmpJutpTn0f+s/Erx/4= X-Google-Smtp-Source: AGs4zMYxlye+WQW4ZT7t9W/QZ/9J65xjedA5v/O2ybqbZowG32j9BYZa2GBeYOF+ser6yRcdn2iF7w== X-Received: by 10.84.173.1 with SMTP id o1mr12671762plb.400.1512333726923; Sun, 03 Dec 2017 12:42:06 -0800 (PST) Received: from anarsoul-thinkpad.lan (216-71-193-140.dyn.novuscom.net. [216.71.193.140]) by smtp.gmail.com with ESMTPSA id z25sm19264929pfe.121.2017.12.03.12.42.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 Dec 2017 12:42:06 -0800 (PST) From: Vasily Khoruzhick To: Liam Girdwood , Mark Brown , Maxime Ripard , Chen-Yu Tsai , Marcus Cooper , =?UTF-8?q?Myl=C3=A8ne=20Josserand?= , alsa-devel@alsa-project.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 5/9] ASoC: sun8i-codec-analog: Use callbacks to add headphones and lineout outputs Date: Sun, 3 Dec 2017 12:41:53 -0800 Message-Id: <20171203204157.20829-6-anarsoul@gmail.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171203204157.20829-1-anarsoul@gmail.com> References: <20171203204157.20829-1-anarsoul@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171203_124229_352498_4832451F X-CRM114-Status: GOOD ( 13.25 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vasily Khoruzhick MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Marcus Cooper Widgets for headphones and lineout outputs on A64 are different enough and use different regs, so move addition of these outputs into callback to simplify upcoming A64 support. Signed-off-by: Vasily Khoruzhick Signed-off-by: Marcus Cooper --- sound/soc/sunxi/sun8i-codec-analog.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/sound/soc/sunxi/sun8i-codec-analog.c b/sound/soc/sunxi/sun8i-codec-analog.c index 485e79f292c4..384f582b6f69 100644 --- a/sound/soc/sunxi/sun8i-codec-analog.c +++ b/sound/soc/sunxi/sun8i-codec-analog.c @@ -397,7 +397,7 @@ static const struct snd_soc_dapm_route sun8i_codec_mixer_routes[] = { /* headphone specific controls, widgets, and routes */ static const DECLARE_TLV_DB_SCALE(sun8i_codec_hp_vol_scale, -6300, 100, 1); -static const struct snd_kcontrol_new sun8i_codec_headphone_controls[] = { +static const struct snd_kcontrol_new sun8i_a23_codec_hp_ctrls[] = { SOC_SINGLE_TLV("Headphone Playback Volume", SUN8I_ADDA_HP_VOLC, SUN8I_ADDA_HP_VOLC_HP_VOL, 0x3f, 0, @@ -447,7 +447,7 @@ static int sun8i_headphone_amp_event(struct snd_soc_dapm_widget *w, return 0; } -static const struct snd_soc_dapm_widget sun8i_codec_headphone_widgets[] = { +static const struct snd_soc_dapm_widget sun8i_a23_codec_hp_widgets[] = { SND_SOC_DAPM_MUX("Headphone Source Playback Route", SND_SOC_NOPM, 0, 0, sun8i_codec_hp_src), SND_SOC_DAPM_OUT_DRV_E("Headphone Amp", SUN8I_ADDA_PAEN_HP_CTRL, @@ -471,22 +471,24 @@ static const struct snd_soc_dapm_route sun8i_codec_headphone_routes[] = { { "HP", NULL, "Headphone Amp" }, }; -static int sun8i_codec_add_headphone(struct snd_soc_component *cmpnt) +static int sun8i_a23_codec_add_headphone(struct snd_soc_component *cmpnt) { struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(cmpnt); struct device *dev = cmpnt->dev; int ret; ret = snd_soc_add_component_controls(cmpnt, - sun8i_codec_headphone_controls, - ARRAY_SIZE(sun8i_codec_headphone_controls)); + sun8i_a23_codec_hp_ctrls, + ARRAY_SIZE( + sun8i_a23_codec_hp_ctrls)); if (ret) { dev_err(dev, "Failed to add Headphone controls: %d\n", ret); return ret; } - ret = snd_soc_dapm_new_controls(dapm, sun8i_codec_headphone_widgets, - ARRAY_SIZE(sun8i_codec_headphone_widgets)); + ret = snd_soc_dapm_new_controls(dapm, + sun8i_a23_codec_hp_widgets, + ARRAY_SIZE(sun8i_a23_codec_hp_widgets)); if (ret) { dev_err(dev, "Failed to add Headphone DAPM widgets: %d\n", ret); return ret; @@ -604,6 +606,7 @@ static const DECLARE_TLV_DB_RANGE(sun8i_codec_lineout_vol_scale, 0, 1, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 1), 2, 31, TLV_DB_SCALE_ITEM(-4350, 150, 0), ); + static const struct snd_kcontrol_new sun8i_codec_lineout_controls[] = { SOC_SINGLE_TLV("Line Out Playback Volume", SUN8I_ADDA_PHONE_GAIN_CTRL, @@ -648,7 +651,7 @@ static const struct snd_soc_dapm_route sun8i_codec_lineout_routes[] = { { "LINEOUT", NULL, "Line Out Enable", }, }; -static int sun8i_codec_add_lineout(struct snd_soc_component *cmpnt) +static int sun8i_h3_codec_add_lineout(struct snd_soc_component *cmpnt) { struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(cmpnt); struct device *dev = cmpnt->dev; @@ -751,6 +754,9 @@ struct sun8i_codec_analog_quirks { bool has_lineout; bool has_mbias; bool has_mic2; + const struct snd_soc_component_driver *cmpnt_drv; + int (*add_headphone)(struct snd_soc_component *cmpnt); + int (*add_lineout)(struct snd_soc_component *cmpnt); }; static const struct sun8i_codec_analog_quirks sun8i_a23_quirks = { @@ -759,6 +765,7 @@ static const struct sun8i_codec_analog_quirks sun8i_a23_quirks = { .has_linein = true, .has_mbias = true, .has_mic2 = true, + .add_headphone = sun8i_a23_codec_add_headphone, }; static const struct sun8i_codec_analog_quirks sun8i_h3_quirks = { @@ -766,8 +773,10 @@ static const struct sun8i_codec_analog_quirks sun8i_h3_quirks = { .has_lineout = true, .has_mbias = true, .has_mic2 = true, + .add_lineout = sun8i_h3_codec_add_lineout, }; + static int sun8i_codec_analog_add_mixer(struct snd_soc_component *cmpnt, const struct sun8i_codec_analog_quirks *quirks) { @@ -834,7 +843,7 @@ static int sun8i_codec_analog_cmpnt_probe(struct snd_soc_component *cmpnt) return ret; if (quirks->has_headphone) { - ret = sun8i_codec_add_headphone(cmpnt); + ret = quirks->add_headphone(cmpnt); if (ret) return ret; } @@ -852,7 +861,7 @@ static int sun8i_codec_analog_cmpnt_probe(struct snd_soc_component *cmpnt) } if (quirks->has_lineout) { - ret = sun8i_codec_add_lineout(cmpnt); + ret = quirks->add_lineout(cmpnt); if (ret) return ret; }