From patchwork Fri Aug 11 13:29:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 109872 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp918891qge; Fri, 11 Aug 2017 06:31:53 -0700 (PDT) X-Received: by 10.84.217.13 with SMTP id o13mr18029094pli.315.1502458313667; Fri, 11 Aug 2017 06:31:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502458313; cv=none; d=google.com; s=arc-20160816; b=VpvtuTOA/LM4dHXcqbfHRK7hpf8AmRn67jq8i0tpUe5Tr+cWoYoIlr4qe7MI8P9bvT mdifPNjzgCIl43W0jaPhrjAZWhb8HxnMVdHoprdw/R9JSQ8qV4nUbI9gLUcUNOHoyKGF QXRuEjj4Hif3XPqOz7CskiNuTxabEFZxZCAvEWFRDx6UIMXOq3YWwRD9skqvVj+YYjGk B30wSP1q1560I6mCM8pdS2rPcXjN9NEIi3LusFL61HZocjnuwSIdiDFqLeyHjewmaMJC bsTykNhJCqMH0I1UJXw/BALr2ID5BR0exjlFOMkLmVkaqxS+tNUh8kR3fN+eOVYDTcaD U9Ww== 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=q7gdXYnxY6xYfOj4oelxzFeuMkBRh+V87Ll6XqPslvM=; b=tFUnOL2isYUURLOg/VgErFLJPGK6e2E+2G+OAJxRPblqsIRJMPAY4/j3oJ06d9CE8D T/aP32CUX/gCzNm9diodDtx5zWMGJYaoh1hMUCEOOq8EwWOvN6pEbndvhfjk/NkhE8eL R0vill8synxD0ANI+nWUO4uRcHNc87UVVtN1/aJKFhfJXydxkNEnbl0MgZ6P/Lo3YQhm IR6AXFqXndnUw7lHGTKrcO1Oj860+xhB613SctUSLprCUEm78hqNfb+B8EHxvzqsNyPu rV6N1UgG0irrWlWWj1+Hj7ieYtCa8KxIccWhGAOK0t5Mnn4ijRRR6fMKKRkN78RB/Nt9 7yRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hZMxzrl+; 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 s11si493039pgn.850.2017.08.11.06.31.53; Fri, 11 Aug 2017 06:31:53 -0700 (PDT) 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=hZMxzrl+; 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 S1753425AbdHKNbj (ORCPT + 25 others); Fri, 11 Aug 2017 09:31:39 -0400 Received: from mail-it0-f47.google.com ([209.85.214.47]:35915 "EHLO mail-it0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753283AbdHKNaV (ORCPT ); Fri, 11 Aug 2017 09:30:21 -0400 Received: by mail-it0-f47.google.com with SMTP id 77so27768895itj.1 for ; Fri, 11 Aug 2017 06:30:21 -0700 (PDT) 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=q7gdXYnxY6xYfOj4oelxzFeuMkBRh+V87Ll6XqPslvM=; b=hZMxzrl+v3YhcXDNfKCI/mDFvuGlVn1wZ6fzbPDqvG7tBtPU6Q6k/TfM4ZL5hxnQJn pfpfFTMVO2wqUO9NQ/gr8owydTIf8BvMFkmO4/XNkuqty2ffmAA7NPns0PWYhLFC7UjT t0dbptYtizIXPGgNGZ1L9ejorRlJ1GQrQk9qE= 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=q7gdXYnxY6xYfOj4oelxzFeuMkBRh+V87Ll6XqPslvM=; b=NKESesYjvwuIogbWv4JGa2fWREGdcnMD3Qnvj4Wfjqt0OlL12rFavEINgBc0UgJQs7 yi86hyaHgMyVDZpouO9ZKNxG4/A+8S9JNquKjWuXTtiQxAx0yrgy6o1fJQotDajnJreT S1LybLIx+ed+q0tpPz/2IL3lego/f+V5RDtYDNRuOmu07NvZiDuBtS7E5nc18mz2ubO/ pqKUPqtfdtioFONkXa5c9Hfq0BsLBmxYFZQ2nnEC6+L1YvNpQTbosX67dUEOEdtYD/el kWpERWqm4zNNYWUqRFfh+djNL3c4aNpMQKUvzDvCVC6BjsfAWF//1slZfrbfA5O3X4Vt kHoQ== X-Gm-Message-State: AHYfb5hBDYeLOwTkSzDddgkuwtO8O1jcyfWU6EbieGX1I/Uv2mVm05uE 3XAPLX2lL493ZR6f X-Received: by 10.36.125.11 with SMTP id b11mr14090864itc.47.1502458220662; Fri, 11 Aug 2017 06:30:20 -0700 (PDT) Received: from localhost.localdomain (static.8.26.4.46.clients.your-server.de. [46.4.26.8]) by smtp.gmail.com with ESMTPSA id y72sm398422iod.40.2017.08.11.06.30.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 11 Aug 2017 06:30:20 -0700 (PDT) From: srinivas.kandagatla@linaro.org To: Mark Brown , Banajit Goswami , alsa-devel@alsa-project.org Cc: Takashi Iwai , Patrick Lai , linux-kernel@vger.kernel.org, kwestfie@codeaurora.org, linux-arm-msm@vger.kernel.org, lkasam@qti.qualcomm.com, sboyd@codeaurora.org, Srinivas Kandagatla Subject: [RFC PATCH 8/9] ASoC: qcom: apq8096: Add db820c machine driver Date: Fri, 11 Aug 2017 15:29:51 +0200 Message-Id: <20170811132952.32572-9-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170811132952.32572-1-srinivas.kandagatla@linaro.org> References: <20170811132952.32572-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 uThis patch adds support to DB820c machine driver. Signed-off-by: Srinivas Kandagatla --- .../devicetree/bindings/sound/qcom,apq8096.txt | 85 ++++++++++ sound/soc/qcom/Kconfig | 9 +- sound/soc/qcom/Makefile | 2 + sound/soc/qcom/apq8096.c | 174 +++++++++++++++++++++ 4 files changed, 269 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/sound/qcom,apq8096.txt create mode 100644 sound/soc/qcom/apq8096.c -- 2.9.3 diff --git a/Documentation/devicetree/bindings/sound/qcom,apq8096.txt b/Documentation/devicetree/bindings/sound/qcom,apq8096.txt new file mode 100644 index 0000000..cf6a15b --- /dev/null +++ b/Documentation/devicetree/bindings/sound/qcom,apq8096.txt @@ -0,0 +1,85 @@ +* Qualcomm Technologies APQ8096 ASoC sound card driver + +This binding describes the APQ8096 sound card, which uses qdsp for audio. + +- compatible: + Usage: required + Value type: + Definition: must be "qcom,apq8096-sndcard" + += FRONTEND and BACKEND dailinks +Each subnode of sndcard represents either frontend or backend dailink, +and subnodes of each backend/frontend dailinks would be +cpu/codec/platform dais. + +- fe: + Usage: required + Value type: + Definition: FrontEnd CPU dailink sub-node + +- be: + Usage: required + Value type: + Definition: BackEnd dailink sub-node + +- link-name: + Usage: required + Value type: msm_dai_q6_hdmi + Definition: User friendly name for dai link + +- is-fe: + Usage: optional + Value type: + Definition: present if the dailink is frontend + + += CPU, PLATFORM, CODEC dais subnodes +- cpu: + Usage: required + Value type: + Definition: cpu dai sub-node + +- codec: + Usage: required + Value type: + Definition: codec dai sub-node + +- platform: + Usage: opional + Value type: + Definition: platform dai sub-node + +- sound-dai: + Usage: required + Value type: + Definition: phandle/s and port of CPU/CODEC/PLATFORM dais + +Example: + sound { + compatible = "qcom,snd-apq8096"; + qcom,model = "DB820c"; + + fe@1 { + is-fe; + link-name = "MultiMedia1 PCM"; + cpu { + sound-dai = <&pcm MSM_FRONTEND_DAI_MULTIMEDIA1>; + }; + platform { + sound-dai = <&pcm MSM_FRONTEND_DAI_MULTIMEDIA1>; + }; + }; + + be@1 { + link-name = "HDMI"; + cpu { + sound-dai = <&hdmi_dai>; + }; + platform { + sound-dai = <&routing>; + }; + codec { + sound-dai = <&hdmi>; + }; + }; + }; diff --git a/sound/soc/qcom/Kconfig b/sound/soc/qcom/Kconfig index a2aa480..c190d11 100644 --- a/sound/soc/qcom/Kconfig +++ b/sound/soc/qcom/Kconfig @@ -68,7 +68,6 @@ config SND_SOC_QDSP6V2_PCM tristate default n - config SND_SOC_QDSP6V2 tristate "SoC ALSA audio driver for QDSP6V2" select SND_SOC_QDSP6V2_AFE @@ -82,3 +81,11 @@ config SND_SOC_QDSP6V2 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" + select SND_SOC_QDSP6V2 + default n + help + To add support for SoC audio on MSM8996 and APQ8096 boards + diff --git a/sound/soc/qcom/Makefile b/sound/soc/qcom/Makefile index a51bf0a..f3889c4 100644 --- a/sound/soc/qcom/Makefile +++ b/sound/soc/qcom/Makefile @@ -12,9 +12,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-msm8996-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-msm8996.o #DSP lib obj-$(CONFIG_SND_SOC_QDSP6V2) += qdsp6v2/ diff --git a/sound/soc/qcom/apq8096.c b/sound/soc/qcom/apq8096.c new file mode 100644 index 0000000..de62613 --- /dev/null +++ b/sound/soc/qcom/apq8096.c @@ -0,0 +1,174 @@ +/* + * Copyright (c) 2017 The Linux Foundation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 and + * only version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +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); + return ret; + } + + num_links = of_get_child_count(node); + + /* 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[0]; + + 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->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 0; +} + +static int msm_snd_apq8096_probe(struct platform_device *pdev) +{ + int ret; + struct snd_soc_card *card; + + card = devm_kzalloc(&pdev->dev, sizeof(*card), GFP_KERNEL); + if (!card) + return -ENOMEM; + + card->dev = &pdev->dev; + ret = apq8096_sbc_parse_of(card); + if (ret) { + dev_err(&pdev->dev, "Error parsing OF data\n"); + return ret; + } + + ret = devm_snd_soc_register_card(&pdev->dev, card); + if (ret) + dev_err(&pdev->dev, "sound card register faile (%d)!\n", ret); + + return ret; +} + +static const struct of_device_id msm_snd_apq8096_dt_match[] = { + {.compatible = "qcom,apq8096-sndcard"}, + {} +}; + +static struct platform_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_platform_driver(msm_snd_apq8096_driver); +MODULE_AUTHOR("Srinivas Kandagatla