From patchwork Sat Mar 10 02:24:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 131262 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp1690545lja; Fri, 9 Mar 2018 18:28:18 -0800 (PST) X-Google-Smtp-Source: AG47ELscC9ivGC/orqYC7f34/1dMKaRu+pdQSwtYzilzWDWtNmZ0EBnXk9SkWV8faLA5gzeyaCET X-Received: by 2002:a17:902:7c16:: with SMTP id x22-v6mr620690pll.23.1520648898832; Fri, 09 Mar 2018 18:28:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520648898; cv=none; d=google.com; s=arc-20160816; b=dyED/meiggk8BzEtaImth12lpPPqixMWRDCFJAnA6Is0IgtOwIRb2Q6m+RJBzq7Nut OSVNT2s871dVr9YPZJxDOPvZziqsOzAHZ7cqRPHhT44dZC5pNO4GVL4UjJdviRVhB0uQ 7IHM5xdjDUFN1lBGoK932bYiL3Hopsf3KIpNqzQEhL3yUaWP1UPq+NSfpWmKX/eSvmXg 0II+NOPUL2pv8sGM+69LorgZtb1tyA5EDxj9l6gSKiwHGcV0Y1KGsyQl70dYJ3vqW546 sHZkHY/Ia0QWsFRIzVG+7FnHZhvPHT/UBZ5Zj0LE2xHqTAHLWqPWpKwaBt8lMXDW3Sh/ oPYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=4JNmyvSeXccmt+qq7aBs1SKSQQpJdIdgDpBVMdUDZ/A=; b=jSD1gDwibgPacHZ3FXisD4TACPqklLVAIYODB5UT+C58StJL6qlMS0/PKCxBWVgZfs U9K6N4vB1GoTou9qqVwLS+JZ6AL1UWaikOJ39+lstnnJQHnmqYS0qfck39U6D8t/u9xl 5CcCiQObykeo2pvWIJ0mHQgsI+8znUn8LkVG9w3j+pJmixSxmJvw+LJRgGR/A8O6cVep iA2A6+KlDs4vTDanoaUCvae4UdGuOX9R424e8sP0BQtAjCRgg+vumWnlDQiwTVWLZCOc malfTAr3FCOWPNNEoMgf+f9DF/9Mw5FrM4aeKPWxnYku537SP1EEXuT56HeZRygST0zR yaoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=dsHTTnZv; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n1-v6si1967961pls.21.2018.03.09.18.28.18; Fri, 09 Mar 2018 18:28:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=dsHTTnZv; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933050AbeCJC2P (ORCPT + 10 others); Fri, 9 Mar 2018 21:28:15 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:51191 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932942AbeCJC2L (ORCPT ); Fri, 9 Mar 2018 21:28:11 -0500 Received: by mail-wm0-f65.google.com with SMTP id w128so7119875wmw.0 for ; Fri, 09 Mar 2018 18:28:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1KaSyXInO3tNtw4jUQ074jYdbAxLTbOyGL2YrWUG2gg=; b=dsHTTnZvpmwsY5OUNkqjTPcP7YPEXdEGMYFIRVkVTrnCeQS2Tj2ZkqmGzOda5R1Y5Y pI/fmz+p9l5yRJu0FS58I+WZCrb5CbHv8v3C4KaJK6jTK5dwWTIuJl1Ul8+tiZJNLZyJ o8veKeprliq5kPyjmQdNLVjx6s83hsnWTE1Vo= 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=1KaSyXInO3tNtw4jUQ074jYdbAxLTbOyGL2YrWUG2gg=; b=Cx7+sp1ZZG/xh28w8hlE7nZ4iJvznAhsAu3cvdQR+uHz7+ZOZ5hBqIyzV+oPmcEZ73 E3jyxuhAFL2jKIVpvU4cf0rIsJM+z7SMORDxPvX/wg+TxEZwRsLCol4MsGrGK3mwVYvj eJPbZwBWWx9Kl170TKU35vPtPF7uWSq1wuE1/oiQhVonX7ieyajpR5bzOnJNIpa8hFHj AQIHa6Qe/vjCiHIDtY3KO/8MN1IFeKMUUP3rxRy6VqLrM7URMfmN2MDqPzASIsFko0yy fuZ7INGlveNGW26Zdm9MgGChok9sJ/wDJFSjLnaMiwIumXuOZMpnPvBOBL7dn5roZthr QuFw== X-Gm-Message-State: AElRT7EaeO7ke/eYGy7vPJXZXuKZSW5p/FLSYeLUq7eY8UoeJdZhKujZ 7d9HGSLSL9sQpL1anbS8jkfJ0w== X-Received: by 10.28.66.65 with SMTP id p62mr69074wma.8.1520648889997; Fri, 09 Mar 2018 18:28:09 -0800 (PST) Received: from localhost.localdomain (cpc90716-aztw32-2-0-cust92.18-1.cable.virginm.net. [86.26.100.93]) by smtp.gmail.com with ESMTPSA id g78sm21489wmc.31.2018.03.09.18.28.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Mar 2018 18:28:09 -0800 (PST) From: srinivas.kandagatla@linaro.org To: andy.gross@linaro.org, broonie@kernel.org, linux-arm-msm@vger.kernel.org, alsa-devel@alsa-project.org, robh+dt@kernel.org Cc: gregkh@linuxfoundation.org, david.brown@linaro.org, mark.rutland@arm.com, lgirdwood@gmail.com, plai@codeaurora.org, bgoswami@codeaurora.org, tiwai@suse.com, perex@perex.cz, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, rohkumar@qti.qualcomm.com, spatakok@qti.qualcomm.com, srinivas.kandagatla@linaro.org Subject: [PATCH v4 22/24] ASoC: qcom: apq8096: Add db820c machine driver Date: Sat, 10 Mar 2018 02:24:54 +0000 Message-Id: <20180310022456.26739-23-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180310022456.26739-1-srinivas.kandagatla@linaro.org> References: <20180310022456.26739-1-srinivas.kandagatla@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Srinivas Kandagatla This patch adds support to DB820c machine driver. Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/Kconfig | 9 ++ sound/soc/qcom/Makefile | 2 + sound/soc/qcom/apq8096.c | 235 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 246 insertions(+) create mode 100644 sound/soc/qcom/apq8096.c -- 2.15.1 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/sound/soc/qcom/Kconfig b/sound/soc/qcom/Kconfig index 5bdf39f6003f..9d8007e2f3cf 100644 --- a/sound/soc/qcom/Kconfig +++ b/sound/soc/qcom/Kconfig @@ -84,3 +84,12 @@ config SND_SOC_QDSP6 This will enable sound soc platform specific audio drivers. This includes q6asm, q6adm, q6afe interfaces to DSP using apr. + +config SND_SOC_MSM8996 + tristate "SoC Machine driver for MSM8996 and APQ8096 boards" + depends on QCOM_APR + select SND_SOC_QDSP6 + help + Support for Qualcomm Technologies LPASS audio block in + APQ8096 SoC-based systems. + Say Y if you want to use audio device on this SoCs diff --git a/sound/soc/qcom/Makefile b/sound/soc/qcom/Makefile index 0276717917c0..206945bb9ba1 100644 --- a/sound/soc/qcom/Makefile +++ b/sound/soc/qcom/Makefile @@ -13,9 +13,11 @@ obj-$(CONFIG_SND_SOC_LPASS_APQ8016) += snd-soc-lpass-apq8016.o # Machine snd-soc-storm-objs := storm.o snd-soc-apq8016-sbc-objs := apq8016_sbc.o +snd-soc-apq8096-objs := apq8096.o obj-$(CONFIG_SND_SOC_STORM) += snd-soc-storm.o obj-$(CONFIG_SND_SOC_APQ8016_SBC) += snd-soc-apq8016-sbc.o +obj-$(CONFIG_SND_SOC_MSM8996) += snd-soc-apq8096.o #DSP lib obj-$(CONFIG_SND_SOC_QDSP6) += qdsp6/ diff --git a/sound/soc/qcom/apq8096.c b/sound/soc/qcom/apq8096.c new file mode 100644 index 000000000000..e9b61dc0aa63 --- /dev/null +++ b/sound/soc/qcom/apq8096.c @@ -0,0 +1,235 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (c) 2018, Linaro Limited + +#include +#include +#include +#include +#include +#include +#include +#include + +static int apq8096_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, + struct snd_pcm_hw_params *params) +{ + struct snd_interval *rate = hw_param_interval(params, + SNDRV_PCM_HW_PARAM_RATE); + struct snd_interval *channels = hw_param_interval(params, + SNDRV_PCM_HW_PARAM_CHANNELS); + + rate->min = rate->max = 48000; + channels->min = channels->max = 2; + + return 0; +} + +static int apq8096_sbc_parse_of(struct snd_soc_card *card) +{ + struct device_node *np, *codec, *platform, *cpu, *node; + struct device *dev = card->dev; + struct snd_soc_dai_link *link; + int ret, num_links; + + ret = snd_soc_of_parse_card_name(card, "qcom,model"); + if (ret) { + dev_err(dev, "Error parsing card name: %d\n", ret); + return ret; + } + + node = dev->of_node; + + /* DAPM routes */ + if (of_property_read_bool(node, "qcom,audio-routing")) { + ret = snd_soc_of_parse_audio_routing(card, + "qcom,audio-routing"); + if (ret) + return ret; + } + + /* Populate links */ + num_links = of_get_child_count(node); + + /* Allocate the DAI link array */ + card->dai_link = kcalloc(num_links, sizeof(*link), GFP_KERNEL); + if (!card->dai_link) + return -ENOMEM; + + card->num_links = num_links; + link = card->dai_link; + + for_each_child_of_node(node, np) { + cpu = of_get_child_by_name(np, "cpu"); + platform = of_get_child_by_name(np, "platform"); + codec = of_get_child_by_name(np, "codec"); + + if (!cpu) { + dev_err(dev, "Can't find cpu DT node\n"); + return -EINVAL; + } + + link->cpu_of_node = of_parse_phandle(cpu, "sound-dai", 0); + if (!link->cpu_of_node) { + dev_err(card->dev, "error getting cpu phandle\n"); + return -EINVAL; + } + + link->platform_of_node = of_parse_phandle(platform, + "sound-dai", 0); + if (!link->platform_of_node) { + dev_err(card->dev, "error getting platform phandle\n"); + return -EINVAL; + } + + ret = snd_soc_of_get_dai_name(cpu, &link->cpu_dai_name); + if (ret) { + dev_err(card->dev, "error getting cpu dai name\n"); + return ret; + } + + if (codec) { + ret = snd_soc_of_get_dai_link_codecs(dev, codec, link); + + if (ret < 0) { + dev_err(card->dev, "error getting codec dai name\n"); + return ret; + } + link->no_pcm = 1; + link->ignore_suspend = 1; + link->ignore_pmdown_time = 1; + link->be_hw_params_fixup = apq8096_be_hw_params_fixup; + } else { + link->codec_dai_name = "snd-soc-dummy-dai"; + link->codec_name = "snd-soc-dummy"; + link->dynamic = 1; + } + + ret = of_property_read_string(np, "link-name", &link->name); + if (ret) { + dev_err(card->dev, "error getting codec dai_link name\n"); + return ret; + } + + link->dpcm_playback = 1; + link->dpcm_capture = 1; + link->stream_name = link->name; + link++; + } + + return ret; +} + +static int apq8096_bind(struct device *dev) +{ + struct snd_soc_card *card; + int ret; + + card = kzalloc(sizeof(*card), GFP_KERNEL); + if (!card) + return -ENOMEM; + + component_bind_all(dev, card); + card->dev = dev; + ret = apq8096_sbc_parse_of(card); + if (ret) { + dev_err(dev, "Error parsing OF data\n"); + component_unbind_all(dev, card); + return ret; + } + + return snd_soc_register_card(card); +} + +static void apq8096_unbind(struct device *dev) +{ + struct snd_soc_card *card = dev_get_drvdata(dev); + + component_unbind_all(dev, card); + snd_soc_unregister_card(card); + kfree(card->dai_link); + kfree(card); +} + +static const struct component_master_ops apq8096_ops = { + .bind = apq8096_bind, + .unbind = apq8096_unbind, +}; + +static int apq8016_compare_of(struct device *dev, void *data) +{ + return dev->of_node == data; +} + +static void apq8016_release_of(struct device *dev, void *data) +{ + of_node_put(data); +} + +static int add_audio_components(struct device *dev, + struct component_match **matchptr) +{ + struct device_node *np, *platform, *cpu, *node, *dai_node; + + node = dev->of_node; + + for_each_child_of_node(node, np) { + cpu = of_get_child_by_name(np, "cpu"); + if (cpu) { + dai_node = of_parse_phandle(cpu, "sound-dai", 0); + of_node_get(dai_node); + component_match_add_release(dev, matchptr, + apq8016_release_of, + apq8016_compare_of, + dai_node); + } + + platform = of_get_child_by_name(np, "platform"); + if (platform) { + dai_node = of_parse_phandle(platform, "sound-dai", 0); + component_match_add_release(dev, matchptr, + apq8016_release_of, + apq8016_compare_of, + dai_node); + } + } + + return 0; +} + +static int apq8096_platform_probe(struct platform_device *pdev) +{ + struct component_match *match = NULL; + int ret; + + ret = add_audio_components(&pdev->dev, &match); + if (ret) + return ret; + + return component_master_add_with_match(&pdev->dev, &apq8096_ops, match); +} + +static int apq8096_platform_remove(struct platform_device *pdev) +{ + component_master_del(&pdev->dev, &apq8096_ops); + + return 0; +} + +static const struct of_device_id msm_snd_apq8096_dt_match[] = { + {.compatible = "qcom,apq8096-sndcard"}, + {} +}; + +static struct platform_driver msm_snd_apq8096_driver = { + .probe = apq8096_platform_probe, + .remove = apq8096_platform_remove, + .driver = { + .name = "msm-snd-apq8096", + .owner = THIS_MODULE, + .of_match_table = msm_snd_apq8096_dt_match, + }, +}; +module_platform_driver(msm_snd_apq8096_driver); +MODULE_AUTHOR("Srinivas Kandagatla