From patchwork Tue Feb 13 16:58:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 128267 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp4458417ljc; Tue, 13 Feb 2018 09:02:27 -0800 (PST) X-Google-Smtp-Source: AH8x2244+i/6+LBtHpdsNx+7B5Fkk7g/oDyVyVo0HRiPjJhe4X18uWh/0Q7xvYjxtM/tlT5tSmFp X-Received: by 2002:a17:902:d68a:: with SMTP id v10-v6mr1707158ply.206.1518541347249; Tue, 13 Feb 2018 09:02:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518541347; cv=none; d=google.com; s=arc-20160816; b=VzsyKGnJNFq4X2bVeRm0a2AH727SbBgl1rCEmhlj++g2FoTq9HV1DhUFjwSu438GsX OcRAsHLM03RtaV1JlrmASTdYURQmQUFq8IC/TVLeWC6Fk1hzc3MkbKZajuz/jjkdpTmM xXn1Ss0eJlpsVV5zcro8Vm93XmRCm+d3OnviI35JhozKZ+aeO7QBydDUs4x80NQawsYE diX2QwiUniHfc7yruJ0AyFSpM882FSUNuy8JVPJIhZaPdQcPQXF4UuBNeridNlbFqvx6 Mbl5fGxyhBWfJsAtiIeR1WpgAAeLcmaZYac31BbzySqApNX23ejrQdnB1OY5tr0d8oiN wKww== 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=4gSyMnZu0jAokTqfgezSMJZSoMNWyk9PtERXGo4ALSY=; b=BS3h8RqWU4AZT1LZ5HmkuTISc1XmI+Qz4M09FuZLIx1KJQ3W7F6BsMsFbYXWN5eWGS +M1FCHGk83SHX43+IScR1uzx7mqdopehQuGS18qoq0APlJVgC4B+BkydURJT/c/3Yubk yIQWcC5w9GPhaCRrJBRR0nRmAY5+ugn/TG4y76Zz8NJ5Kandmzinuh5E8jMUQRUdO1I2 qPGgIKUxVn4lAw5+GfAUvISgD3aY7mwBUdtMt0VdhF9aDudGZc04TJPOJTs1jSeILjQt JXcKJDYp9oKsOt+3pymfIjhHCcnOieQNndsW9zP0EvLE3NRLuotufQ7LjFUQua901xB9 2HwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BYy+aPgu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (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 z5si1403465pgo.514.2018.02.13.09.02.26; Tue, 13 Feb 2018 09:02:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BYy+aPgu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965554AbeBMRCY (ORCPT + 28 others); Tue, 13 Feb 2018 12:02:24 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:39834 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965534AbeBMRBs (ORCPT ); Tue, 13 Feb 2018 12:01:48 -0500 Received: by mail-wm0-f66.google.com with SMTP id b21so17276170wme.4 for ; Tue, 13 Feb 2018 09:01:48 -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=4gSyMnZu0jAokTqfgezSMJZSoMNWyk9PtERXGo4ALSY=; b=BYy+aPguNwQl15SwsGsTzTsHZbTIqxH/9b6plpAXipn6cR1hBTPE+UuNN4PSxZ05bw xW67ac2uTwluyKlvGgYbhtFso3n36NYbcJp+c595YAVmd6bdM2dsnYtI86GgT0nIX+Ap MFEzuWbRJ7Jid47J+YHY/CdKAml9q13h35Pdg= 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=4gSyMnZu0jAokTqfgezSMJZSoMNWyk9PtERXGo4ALSY=; b=pKiWG29XP1pahVSK9Dz68L7DvThcViHjWTCeU49XxKaRWLgc7Cd2Vujg9OFrLwIQ4L 4X2/DId80YdIIribcSDIwCtLFVZGAnPXWN6ZCK3ETVTFyssvfUW1lV2xZLzM/fIci+Oq UNUZ4DIHbWur2LNgiY1P7CKqaWCIeeTipINLDgZ+XbwQyNGcajCLCMhyjqglhE6LJIyM 2Kni2y0PhLyfreLYEMqvx5bT/QlorPalnQ1qRSZzUWp5IeGOnPJKQlyeQLKJwsTznFwg mr9+Bqvi5uVJdfMTT5dQlowP3d8H+Y40d9xv4HgVz5+6kKaVuAF4Yknw7dKB7zVctDOi LvPg== X-Gm-Message-State: APf1xPBK1/e8pSo58fYFJ0vVvcSZdKBqe+Vy7DUVXYNNbvCxGStjivfs T9WFqsTe36wVlrA/7Tok0bglbg== X-Received: by 10.28.110.3 with SMTP id j3mr2024042wmc.97.1518541306929; Tue, 13 Feb 2018 09:01:46 -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 y145sm7432723wmd.43.2018.02.13.09.01.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 13 Feb 2018 09:01:46 -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 Cc: david.brown@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com, lgirdwood@gmail.com, plai@codeaurora.org, bgoswami@codeaurora.org, perex@perex.cz, tiwai@suse.com, linux-soc@vger.kernel.org, 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 Subject: [PATCH v3 24/25] ASoC: qcom: apq8096: Add db820c machine driver Date: Tue, 13 Feb 2018 16:58:36 +0000 Message-Id: <20180213165837.1620-25-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180213165837.1620-1-srinivas.kandagatla@linaro.org> References: <20180213165837.1620-1-srinivas.kandagatla@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Srinivas Kandagatla This patch adds support to DB820c machine driver. Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/Kconfig | 8 +++ sound/soc/qcom/apq8096.c | 173 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 181 insertions(+) create mode 100644 sound/soc/qcom/apq8096.c -- 2.15.1 diff --git a/sound/soc/qcom/Kconfig b/sound/soc/qcom/Kconfig index 8c2d65e0a28e..fa4b575c086c 100644 --- a/sound/soc/qcom/Kconfig +++ b/sound/soc/qcom/Kconfig @@ -77,3 +77,11 @@ 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_QDSP6V2 + default n + help + To add support for SoC audio on MSM8996 and APQ8096 boards diff --git a/sound/soc/qcom/apq8096.c b/sound/soc/qcom/apq8096.c new file mode 100644 index 000000000000..b12d2398557a --- /dev/null +++ b/sound/soc/qcom/apq8096.c @@ -0,0 +1,173 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2018, Linaro Limited + */ + +#include +#include +#include +#include +#include +#include + +static int msm8996_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 *dev = card->dev; + struct snd_soc_dai_link *link; + struct device_node *np, *codec, *platform, *cpu, *node = dev->of_node; + int ret, num_links; + bool is_fe; + + + ret = snd_soc_of_parse_card_name(card, "qcom,model"); + if (ret) + dev_err(dev, "Error parsing card name: %d\n", ret); + + if (of_property_read_bool(dev->of_node, "qcom,audio-routing")) + ret = snd_soc_of_parse_audio_routing(card, + "qcom,audio-routing"); + + /* Populate links */ + num_links = of_get_child_count(node); + + dev_info(dev, "Found %d child audio dai links..\n", num_links); + /* Allocate the private data and the DAI link array */ + card->dai_link = devm_kzalloc(dev, sizeof(*link) * num_links, + GFP_KERNEL); + if (!card->dai_link) + return -ENOMEM; + + card->num_links = num_links; + + link = card->dai_link; + + for_each_child_of_node(node, np) { + is_fe = false; + if (of_property_read_bool(np, "is-fe")) + is_fe = true; + + if (is_fe) { + /* BE is dummy */ + link->codec_of_node = NULL; + link->codec_dai_name = "snd-soc-dummy-dai"; + link->codec_name = "snd-soc-dummy"; + + /* FE settings */ + link->dynamic = 1; + link->dpcm_playback = 1; + + } else { + link->no_pcm = 1; + link->dpcm_playback = 1; + link->ignore_suspend = 1; + link->ignore_pmdown_time = 1; + link->be_hw_params_fixup = msm8996_be_hw_params_fixup; + } + + 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; + } + } + + 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->stream_name = link->name; + link++; + } + + return ret; +} + +static int msm_snd_apq8096_probe(struct apr_device *adev) +{ + int ret; + struct snd_soc_card *card; + + card = devm_kzalloc(&adev->dev, sizeof(*card), GFP_KERNEL); + if (!card) + return -ENOMEM; + + card->dev = &adev->dev; + + ret = apq8096_sbc_parse_of(card); + if (ret) { + dev_err(&adev->dev, "Error parsing OF data\n"); + return ret; + } + + ret = devm_snd_soc_register_card(&adev->dev, card); + if (ret) + dev_err(&adev->dev, "sound card register failed (%d)!\n", ret); + else + dev_err(&adev->dev, "sound card register Sucessfull\n"); + + return ret; +} + +static const struct of_device_id msm_snd_apq8096_dt_match[] = { + {.compatible = "qcom,apq8096-sndcard"}, + {} +}; + +static struct apr_driver msm_snd_apq8096_driver = { + .probe = msm_snd_apq8096_probe, + .driver = { + .name = "msm-snd-apq8096", + .owner = THIS_MODULE, + .of_match_table = msm_snd_apq8096_dt_match, + }, +}; +module_apr_driver(msm_snd_apq8096_driver); +MODULE_AUTHOR("Srinivas Kandagatla