From patchwork Tue Feb 13 16:58:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 128264 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp4457352ljc; Tue, 13 Feb 2018 09:01:41 -0800 (PST) X-Google-Smtp-Source: AH8x226xQl+aCsvCv6kOJWenkd2IA68lEas60UzNJqGcFoUps3jsiM6d8Tr0SthwcH8ldlcdnD90 X-Received: by 10.223.143.101 with SMTP id p92mr1757862wrb.241.1518541301193; Tue, 13 Feb 2018 09:01:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518541301; cv=none; d=google.com; s=arc-20160816; b=09GoqV2JkQDlbc9xaI6jsMSN5KKZSdBJCrkmCj0AUDVygkRacalKzvOzwbDFDTHehW PwI2X131D8JQRsbShkNXtOYvMxCBePy8tlDs1WnLwcn97xGoZIdk5rIvkTI0ouwCR0yr MDgM4X0BwBk2WsQUlds2WuV6W6PRSdc18JqpfLlqJK7cnWWtz/Ew7EO6tGY7XDXBzxbQ lWA8iyOLQn/5Brw8RnXRZj9P5+EkFuX4rW5H54tYUIX9R+26ihwCVdy6KZDPi/5lXOtJ 0CDWGI/4wMTzxkCGkJGn5lGFrqgV4NRLmD/BBHZ3TtbgeceXhFFQQKv2dOIzr7q3rHbO rjdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to:arc-authentication-results; bh=6VYxO2uYvpyazsEA9I11d5W9+H5qwpyZHMlTqz805X4=; b=odr5mYhR53NkDabkcz8w2qk/b8vLfKL+7Xv4KxFwKVzWNnUsGMsQVdDm+YVGoVIIz/ 8NX9FLVnVYQnJ8gpjJVpRFCsIYjzzwdPETqnqXHvfjLbE5bqvq5cDPuOlLvIxIaMiqqf b2prNEPfVdBNt9IWlh64mnjwaDv92kbTwQtP8rmHnaxEbxZT/z7IvkmAYCTG4He/lsEd vzJP9weCYSfD0qibGIB1dgQjwi0wXzNXrhVjzXs0oElQHeFgr4UqxocwCw4mMCuf0u89 QqrKwAhOf28fwismO9ljKC9Vs2w9cV/u/a5HbWVKOFukWEylUdQGVaVOTzbUIZNfyB87 NH+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=IpY6ks/W; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from alsa0.perex.cz (alsa0.perex.cz. [77.48.224.243]) by mx.google.com with ESMTP id l200si5676575wmd.32.2018.02.13.09.01.39; Tue, 13 Feb 2018 09:01:41 -0800 (PST) Received-SPF: pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) client-ip=77.48.224.243; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=IpY6ks/W; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 60050267753; Tue, 13 Feb 2018 18:01:22 +0100 (CET) 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 CCC8026774D; Tue, 13 Feb 2018 18:01:19 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail1.perex.cz X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FUZZY_PRICES,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_PASS autolearn=disabled version=3.4.0 Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by alsa0.perex.cz (Postfix) with ESMTP id 24764267748 for ; Tue, 13 Feb 2018 18:01:16 +0100 (CET) Received: by mail-wm0-f65.google.com with SMTP id r71so17415430wmd.1 for ; Tue, 13 Feb 2018 09:01:16 -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=gMzc/4UfCRL2FZQv6l25a9Yutn2cjjhV8z0U72lTsx4=; b=IpY6ks/W/uke/K4QykdivbGMar1/Y8Wd4paMb2rxPXmfMLSs+gAUkNMxyW5+tWL6WN 1WzWp3t0y3ZHsitXPcvPZGdBdn44sWmvQ53+z6sP37iTR4SL9ep9eUrEP+4v4KKP8foG YLKQxpFvhC3P5SXBpjXrpE0NoSjg2QlzylOBw= 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=gMzc/4UfCRL2FZQv6l25a9Yutn2cjjhV8z0U72lTsx4=; b=HuAhJMSHoZZX9gdNT8tMJZ36arStg8Vx8OYJxQ+ZanDNAWnhN7Cuepu8m9KxsZ5E4y 0ECuinAjDycmyPR7+aozC6lxQgQTBqJ54uotfNBTRJhxqZgaE/dbgNZ+U++ohc5L3NFZ Qk3i3/shPOIzxKnzO6Q+AdLvMg54EIP5a1Utei8SIxOIhw5BjOQPnacRhhxUh5eFqhHs ELPZbKqBIByE57JZLXKQvnxvaeeogTujaSBwJ3kFSvD8WZEChu5z63ssITke5iZVp7KG PPnBssTj8NOKqvcPxhmIu5P2V2rsJZB9vzmAMcCQHRFEms1FSOAcCxtZNmpn+VFOro7R ojjA== X-Gm-Message-State: APf1xPC7Rk1EkpM8eoWg+V41EHlFdI4EKuNf8UFLQrTuHkSyPfdxzYN9 FQ4IGWNPdaiCD4aCxlKdwf4z1g== X-Received: by 10.28.110.3 with SMTP id j3mr2022125wmc.97.1518541276526; Tue, 13 Feb 2018 09:01:16 -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.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 13 Feb 2018 09:01:15 -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 Date: Tue, 13 Feb 2018 16:58:13 +0000 Message-Id: <20180213165837.1620-2-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> Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, bgoswami@codeaurora.org, rohkumar@qti.qualcomm.com, linux-kernel@vger.kernel.org, plai@codeaurora.org, tiwai@suse.com, lgirdwood@gmail.com, david.brown@linaro.org, robh+dt@kernel.org, Srinivas Kandagatla , spatakok@qti.qualcomm.com, linux-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [alsa-devel] [PATCH v3 01/25] dt-bindings: soc: qcom: Add bindings for APR bus 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 From: Srinivas Kandagatla This patch add dt bindings for Qualcomm APR (Asynchronous Packet Router) bus driver. This bus is used for communicating with DSP which provides audio and various other services to cpu. Signed-off-by: Srinivas Kandagatla --- .../devicetree/bindings/soc/qcom/qcom,apr.txt | 83 ++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/qcom/qcom,apr.txt -- 2.15.1 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel diff --git a/Documentation/devicetree/bindings/soc/qcom/qcom,apr.txt b/Documentation/devicetree/bindings/soc/qcom/qcom,apr.txt new file mode 100644 index 000000000000..1b95fbfed348 --- /dev/null +++ b/Documentation/devicetree/bindings/soc/qcom/qcom,apr.txt @@ -0,0 +1,83 @@ +Qualcomm APR (Asynchronous Packet Router) binding + +This binding describes the Qualcomm APR. APR is a IPC protocol for +communication between Application processor and QDSP. APR is mainly +used for audio/voice services on the QDSP. + +- compatible: + Usage: required + Value type: + Definition: must be "qcom,apr-v", example "qcom,apr-v2" + +- qcom,apr-dest-domain-id + Usage: required + Value type: + Definition: Destination processor ID. + Possible values are : + 1 - APR simulator + 2 - PC + 3 - MODEM + 4 - ADSP + 5 - APPS + 6 - MODEM2 + 7 - APPS2 + += APR SERVICES +Each subnode of the APR node can represent service tied to this apr. The name +of the nodes are not important. The properties of these nodes are defined +by the individual bindings for the specific service +- but must contain the following property: + +- qcom,apr-svc-id + Usage: required + Value type: + Definition: APR Service ID, used for matching the service. + Possible values are : + 3 - DSP Core Service + 4 - Audio Front End Service. + 5 - Voice Stream Manager Service. + 6 - Voice processing manager. + 7 - Audio Stream Manager Service. + 8 - Audio Device Manager Service. + 9 - Multimode voice manager. + 10 - Core voice stream. + 11 - Core voice processor. + 12 - Ultrasound stream manager. + 13 - Listen stream manager. + +- qcom,apr-svc-name + Usage: required + Value type: + Definition: User readable name of a APR service. + += APR DEVICES: +Each subnode of the APR node can represent devices tied to this apr, like +sound-card. The properties of these nodes are defined by the individual +bindings for the specific device. + += EXAMPLE +The following example represents a QDSP based sound card on a MSM8996 device +which uses apr as communication between Apps and QDSP. + + apr { + compatible = "qcom,apr-v2"; + qcom,smd-channels = "apr_audio_svc"; + qcom,apr-dest-domain-id = ; + + q6core { + compatible = "qcom,q6core"; + qcom,apr-svc-name = "CORE"; + qcom,apr-svc-id = ; + }; + + q6afe { + compatible = "qcom,q6afe"; + qcom,apr-svc-name = "AFE"; + qcom,apr-svc-id = ; + }; + + audio { + compatible = "qcom,msm8996-snd-card"; + ... + }; + }; From patchwork Tue Feb 13 16:58:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 128268 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp4459076ljc; Tue, 13 Feb 2018 09:02:56 -0800 (PST) X-Google-Smtp-Source: AH8x225S8IQf7Mf82yvwDbpPBBzGpWzt+wAh2snZuD6oPdcx9xmSmNm22fuR67Vz/ovqrcmlxumi X-Received: by 10.223.132.38 with SMTP id 35mr1949758wrf.2.1518541376596; Tue, 13 Feb 2018 09:02:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518541376; cv=none; d=google.com; s=arc-20160816; b=BwKqPCqwqTy8mAUIBG2k+Gx0+MwpKgDyJPLbfNNPY4A2u87Zek2o3XMOQ8rbPt1Ye2 rdckSPyvlyhy/tf8W55adAkjxh65nPR825g+d1fHSzPaZjxdWkc42O9UEbvUozFgWh6j q9jANeOrLssMS3/UhJ3zOEkQVhYpzdiUP1O3o4pRms18geSyAn6HLUgnfBdDwpO7wsTc oUxMXgyPAx4AikVTJgLdOMKuDlZuSnQdDvu6D9m7IM3dxFVkTnrjv7Qp+ZERK086Csqy yGH13XKvwNUM58c4mNuMeWPtbp2+hV8gNezeU4Z12sOClzm5JesMQSPc7ocsaPShb/IU d7Mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to:arc-authentication-results; bh=Am1Gi9Xz/PuEgBR/+An9dl521GijwquIDlsUzuYzOAs=; b=HgqzhV1Pn700eF3BV8zkTPc4D11mb5qbmFAqqWH31SoHntyVX2JSGz5pjjzgKdQJMm XdfV9FIZ5jlhWBAltEn7SAoC9WzQHVSowq9vrCndQvQtlzwA0DuzdhD020bANeS/H4j1 ggKhdalHOoiBKHDbLIJMuydYyE63Y3lKR/LbLh/fsrsK3O5JOvKsqYKjiu2n2YGdIXy/ jgQjLolyJrOIlAs/O8WHVu7gazqI2XkpLTirL5AfcpTxxq9FfJYNB68wf1SnBYWiHXX7 li9UXDAHO266lr3lRNszwUwPRC7VWAqNgfD0yUWT/PvVq3PmR7Dr7JMtnmle+k8qJRYN azmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=CTuffByG; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from alsa0.perex.cz (alsa0.perex.cz. [77.48.224.243]) by mx.google.com with ESMTP id x5si5455940wmx.84.2018.02.13.09.02.55; Tue, 13 Feb 2018 09:02:56 -0800 (PST) Received-SPF: pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) client-ip=77.48.224.243; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=CTuffByG; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 41384267967; Tue, 13 Feb 2018 18:01:27 +0100 (CET) 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 1486A26795A; Tue, 13 Feb 2018 18:01:26 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_PASS autolearn=disabled version=3.4.0 Received: from mail-wr0-f194.google.com (mail-wr0-f194.google.com [209.85.128.194]) by alsa0.perex.cz (Postfix) with ESMTP id 7FE49267945 for ; Tue, 13 Feb 2018 18:01:23 +0100 (CET) Received: by mail-wr0-f194.google.com with SMTP id w77so4814767wrc.6 for ; Tue, 13 Feb 2018 09:01:23 -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=Xa5bLhE73TPWV6N4PMs+My1MxT0oxCAfGaksic1uEGo=; b=CTuffByGZWtdhQXJp+51sYl90kV6q/FrVKcB/MgZM3G8KU6dShQhO2N/2n2qDsxydZ VjR/vsqD+GZXIuBDNouiNrJRpduY3n9OBzHfq3Apo2LHA5Vl7bGEKRbU2QLR8Py7w7Z5 fh2XshxiBzrTEbMKbkxKFRhQnAzNnzAzN9Dj4= 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=Xa5bLhE73TPWV6N4PMs+My1MxT0oxCAfGaksic1uEGo=; b=OV2nf44sK1EzcVLeNFWfNO0d9M12cMOsP6sY9oVGYW19AihBQA2S3QH24noHImFgrR NYhJeqrg1hNJzhGMueZTLsbIY3KS6I361DVRFCfesL3U+U1WxVTCoLS42azFGTk60LOk LxB4xZ32fVnGe9D29jb1WjN6H+wtBERLot3TZt0PXmbOP+w9m/cqvSF7hbOcsk4rD37R v87el+0ANGK/Ryvb5/0PJS+BjI4LbRCDNHFkIHHzpR/VZYWxsi5fcQCtk7pRyS+Dp+/s ZYWh+GOgUcXoJt6m5lqE84zmvvOIcYq+RS9cB0F6XCnnQR2uzrp51sWH0nEKTxzQoTrp LbyA== X-Gm-Message-State: APf1xPAmbRLFPynDQ3bVSNp9rkmMY+smUXlHcQ8YzI7KzMw8RPR/AND5 GfT2zVNJpkMX0DZUKTyH9NAmqA== X-Received: by 10.223.157.200 with SMTP id q8mr1887017wre.205.1518541282595; Tue, 13 Feb 2018 09:01:22 -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.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 13 Feb 2018 09:01:22 -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 Date: Tue, 13 Feb 2018 16:58:18 +0000 Message-Id: <20180213165837.1620-7-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> Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, bgoswami@codeaurora.org, rohkumar@qti.qualcomm.com, linux-kernel@vger.kernel.org, plai@codeaurora.org, tiwai@suse.com, lgirdwood@gmail.com, david.brown@linaro.org, robh+dt@kernel.org, Srinivas Kandagatla , spatakok@qti.qualcomm.com, linux-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [alsa-devel] [PATCH v3 06/25] dt-bindings: sound: qcom: Add bindings for q6adm 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 From: Srinivas Kandagatla Signed-off-by: Srinivas Kandagatla --- .../devicetree/bindings/sound/qcom,q6adm.txt | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/qcom,q6adm.txt -- 2.15.1 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel diff --git a/Documentation/devicetree/bindings/sound/qcom,q6adm.txt b/Documentation/devicetree/bindings/sound/qcom,q6adm.txt new file mode 100644 index 000000000000..e493dccfe116 --- /dev/null +++ b/Documentation/devicetree/bindings/sound/qcom,q6adm.txt @@ -0,0 +1,31 @@ +Qualcomm Audio Device Manager (Q6ADM) binding + +Q6ADM is one of the APR audio service on Q6DSP. +Please refer to qcom,apr.txt for details of the coommon apr service bindings +used by the apr service device. + +- but must contain the following property: + +- compatible: + Usage: required + Value type: + Definition: must be "qcom,adm-v.". + example "qcom,adm-v2.0" + +- qcom,apr-svc-id + Usage: required + Value type: + Definition: Must be 8 for Audio Device Manager Service. + +- qcom,apr-svc-name + Usage: required + Value type: + Definition: Must be "ADM" + += EXAMPLE + +q6adm: q6adm { + compatible = "qcom,q6adm-v2.0"; + qcom,apr-svc-name = "ADM"; + qcom,apr-svc-id = ; +}; From patchwork Tue Feb 13 16:58:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 128274 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp4460103ljc; Tue, 13 Feb 2018 09:03:48 -0800 (PST) X-Google-Smtp-Source: AH8x225rhZog7WstMbsfE7/kaDr1G0wkDSsmLDY3wiN1LnscIn7AvqCW+L+6WKS7wdRkFOByVU/q X-Received: by 10.28.237.5 with SMTP id l5mr1792889wmh.154.1518541428795; Tue, 13 Feb 2018 09:03:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518541428; cv=none; d=google.com; s=arc-20160816; b=kB4PMnFvsIjA7+vXPVKd89XQB+j8wVMrZd+5cScOZIxe65EKLEzCnU4yTh9silQoOC PW4t9LICOfddbxGVHx+MSKRx3z2PE/Y2OaiPIVwv1acUI/usUSbP0vkF2IFIWb4kwSss sSiiWjKlAjjWalvvCj7BrN8lKQqWqGsKGiYIGxUjP4wphGBYuEruD4YhVfKeW0fGlhDm CD3m5jWXiTgD/YJE9JRAkeQ7aww6B01UutFvvIoBUhDkyvyCUr0R4LKym/+qoNjNHZ8U fGU4vw/2wlGivRO+VMI3gZOq8aboxI3gOEPTA0xkYAW4+vjT4p+pg51eseQ1pMP/TsgK kJmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to:arc-authentication-results; bh=d0UigHvu/OBpzdsjGNzw7S9B+IuCbutVG388sAC2FCw=; b=z4cL4+gi23c+gfI7VNXQC0vY10XR36EpHSOsi0drYqIYnnUx2ZMzDpDB6yfehNMWjC mzKv9bhceDcaL/JbDa3wrhCMANmjQvc/aSiXMoD/uAfWfx1wq9zROC7n31baT1LLoEjx lHN4U56R6Op78H6QEC96dnNwS9h1tw9sLw03rX1A3Uoef4eTAnVAe2KuVwQv1OOy17oL V5W3FN0uuzKSw3H0hwNFY6iWzLIPFPltqTv+zWCYE2ZmuXpnztwjuAtn+R3yIg7UPeib nTG99Pdbr73ynRE4j+UpwVlpL3tzmrTScu2P6ts3YA+N3maYr54rIwFOT0IgYJcaiA2n RbEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=RdjfgNyT; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from alsa0.perex.cz (alsa0.perex.cz. [77.48.224.243]) by mx.google.com with ESMTP id j11si5659219wmg.101.2018.02.13.09.03.48; Tue, 13 Feb 2018 09:03:48 -0800 (PST) Received-SPF: pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) client-ip=77.48.224.243; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=RdjfgNyT; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 7C28626798B; Tue, 13 Feb 2018 18:01:32 +0100 (CET) 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 2578D267972; Tue, 13 Feb 2018 18:01:29 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS autolearn=disabled version=3.4.0 Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by alsa0.perex.cz (Postfix) with ESMTP id A2FFC267958 for ; Tue, 13 Feb 2018 18:01:24 +0100 (CET) Received: by mail-wm0-f67.google.com with SMTP id r71so17416285wmd.1 for ; Tue, 13 Feb 2018 09:01:24 -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=eWlX5Mfkb6C0QSpqiIHFTPnC1f/uHFBwXveB5Qotf94=; b=RdjfgNyTZ1gu5sh9W229y7qpAMqiQCaHzPoos+rrzdJIqc1wuYWvp6MDJHijNdAtgC MX3tp4pHaSTpaoOowBB+8noxbHk1kl6Wlvj7jT2yMcTBB00ooh4gO40mq0uwHdZCCQkw ml1JvywuobapdUb2udN2LjDmtzkQoOMwOsmEE= 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=eWlX5Mfkb6C0QSpqiIHFTPnC1f/uHFBwXveB5Qotf94=; b=ZVOcLEaQfpPOnykl5vvnMJ8juvMyjKNtGjRjBkKG0S6RF0H/R8LSpJ3QBrBUmB5316 5nxX9drvIPzjNkTKDoTGnsQrwm7JElm0640cPf2IAGEZBY6Gi+MRdUicT33ly8cgc94F gRN9ahbjdvhHTqM91f/M7R8x7BepRnF7XgtLJeD2ukNv/dliuwOBv07FloN5JDUxHhQj raQhSW4rknfIyDMJG+073Ccj+KEcCof/hmUwaDlSagUo80SzNsd8Lb1k9WuG1wJjRxco Ls0qyrfgXt2gv/hW2cIn7Vh5N8INq7g1a+X3BEqYLUbj6RyNiYA/gPywyAfz7BI6S9x9 N9lg== X-Gm-Message-State: APf1xPDjnj3xXQ47iA/Dz8OHauUQMHUPPJD/4+SEQ2yzxpehhxaLJnpc lRdle3WvycqXCzHPX4DGnA0awg== X-Received: by 10.28.138.146 with SMTP id m140mr2012769wmd.85.1518541283953; Tue, 13 Feb 2018 09:01:23 -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.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 13 Feb 2018 09:01:23 -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 Date: Tue, 13 Feb 2018 16:58:19 +0000 Message-Id: <20180213165837.1620-8-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> Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, bgoswami@codeaurora.org, rohkumar@qti.qualcomm.com, linux-kernel@vger.kernel.org, plai@codeaurora.org, tiwai@suse.com, lgirdwood@gmail.com, david.brown@linaro.org, robh+dt@kernel.org, Srinivas Kandagatla , spatakok@qti.qualcomm.com, linux-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [alsa-devel] [PATCH v3 07/25] ASoC: qcom: qdsp6: Add support to Q6ADM 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 From: Srinivas Kandagatla This patch adds support to Q6ADM (Audio Device Manager) module in q6dsp. ADM performs routing between audio streams and AFE ports. It does Rate matching for streams going to devices driven by different clocks, it handles volume ramping, Mixing with channel and bit-width. ADM creates and destroys dynamic COPP services for device-related audio processing as needed. This patch adds basic support to ADM. Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/Kconfig | 5 + sound/soc/qcom/qdsp6/Makefile | 1 + sound/soc/qcom/qdsp6/q6adm.c | 634 ++++++++++++++++++++++++++++++++++++++++++ sound/soc/qcom/qdsp6/q6adm.h | 26 ++ 4 files changed, 666 insertions(+) create mode 100644 sound/soc/qcom/qdsp6/q6adm.c create mode 100644 sound/soc/qcom/qdsp6/q6adm.h -- 2.15.1 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel diff --git a/sound/soc/qcom/Kconfig b/sound/soc/qcom/Kconfig index caeaf8b1b561..bf04e1301608 100644 --- a/sound/soc/qcom/Kconfig +++ b/sound/soc/qcom/Kconfig @@ -52,11 +52,16 @@ config SND_SOC_QDSP6_AFE tristate default n +config SND_SOC_QDSP6_ADM + tristate + default n + config SND_SOC_QDSP6 tristate "SoC ALSA audio driver for QDSP6" depends on QCOM_APR && HAS_DMA select SND_SOC_QDSP6_COMMON select SND_SOC_QDSP6_AFE + select SND_SOC_QDSP6_ADM help To add support for MSM QDSP6 Soc Audio. This will enable sound soc platform specific diff --git a/sound/soc/qcom/qdsp6/Makefile b/sound/soc/qcom/qdsp6/Makefile index 9ec951e0833b..930944425051 100644 --- a/sound/soc/qcom/qdsp6/Makefile +++ b/sound/soc/qcom/qdsp6/Makefile @@ -1,2 +1,3 @@ obj-$(CONFIG_SND_SOC_QDSP6_COMMON) += q6dsp-common.o obj-$(CONFIG_SND_SOC_QDSP6_AFE) += q6afe.o +obj-$(CONFIG_SND_SOC_QDSP6_ADM) += q6adm.o diff --git a/sound/soc/qcom/qdsp6/q6adm.c b/sound/soc/qcom/qdsp6/q6adm.c new file mode 100644 index 000000000000..e9c65e05882b --- /dev/null +++ b/sound/soc/qcom/qdsp6/q6adm.c @@ -0,0 +1,634 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2011-2017, The Linux Foundation + * Copyright (c) 2018, Linaro Limited + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "q6adm.h" +#include "q6afe.h" +#include "q6dsp-errno.h" +#include "q6dsp-common.h" + +#define ADM_CMD_DEVICE_OPEN_V5 0x00010326 +#define ADM_CMDRSP_DEVICE_OPEN_V5 0x00010329 +#define ADM_CMD_DEVICE_CLOSE_V5 0x00010327 +#define ADM_CMD_MATRIX_MAP_ROUTINGS_V5 0x00010325 + +#define TIMEOUT_MS 1000 +#define RESET_COPP_ID 99 +#define INVALID_COPP_ID 0xFF +/* Definition for a legacy device session. */ +#define ADM_LEGACY_DEVICE_SESSION 0 +#define ADM_MATRIX_ID_AUDIO_RX 0 + +struct copp { + int afe_port; + int copp_idx; + int id; + int refcnt; + int topology; + int mode; + int stat; + int rate; + int bit_width; + int channels; + int app_type; + int acdb_id; + struct mutex lock; + wait_queue_head_t wait; + struct list_head node; + struct q6adm *adm; +}; + +struct q6adm { + struct apr_device *apr; + struct device *dev; + unsigned long copp_bitmap[AFE_MAX_PORTS]; + struct list_head copps_list; + spinlock_t copps_list_lock; + int matrix_map_stat; + struct mutex lock; + wait_queue_head_t matrix_map_wait; + void *routing_data; +}; + +struct adm_cmd_device_open_v5 { + struct apr_hdr hdr; + u16 flags; + u16 mode_of_operation; + u16 endpoint_id_1; + u16 endpoint_id_2; + u32 topology_id; + u16 dev_num_channel; + u16 bit_width; + u32 sample_rate; + u8 dev_channel_mapping[8]; +} __packed; + +struct adm_cmd_matrix_map_routings_v5 { + struct apr_hdr hdr; + u32 matrix_id; + u32 num_sessions; +} __packed; + +struct adm_session_map_node_v5 { + u16 session_id; + u16 num_copps; +} __packed; + +static struct copp *adm_find_copp(struct q6adm *adm, int port_idx, + int copp_idx) +{ + struct copp *c; + + spin_lock(&adm->copps_list_lock); + list_for_each_entry(c, &adm->copps_list, node) { + if ((port_idx == c->afe_port) && (copp_idx == c->copp_idx)) { + spin_unlock(&adm->copps_list_lock); + return c; + } + } + + spin_unlock(&adm->copps_list_lock); + return NULL; + +} + +static int adm_callback(struct apr_device *adev, + struct apr_client_message *data) +{ + struct aprv2_ibasic_rsp_result_t *result = data->payload; + int port_idx, copp_idx; + struct copp *copp; + struct q6adm *adm = dev_get_drvdata(&adev->dev); + + if (!data->payload_size) + return 0; + + copp_idx = (data->token) & 0XFF; + port_idx = ((data->token) >> 16) & 0xFF; + if (port_idx < 0 || port_idx >= AFE_MAX_PORTS) { + dev_err(&adev->dev, "Invalid port idx %d token %d\n", + port_idx, data->token); + return 0; + } + if (copp_idx < 0 || copp_idx >= MAX_COPPS_PER_PORT) { + dev_err(&adev->dev, "Invalid copp idx %d token %d\n", + copp_idx, data->token); + return 0; + } + + switch (data->opcode) { + case APR_BASIC_RSP_RESULT: { + if (result->status != 0) { + dev_err(&adev->dev, "cmd = 0x%x return error = 0x%x\n", + result->opcode, result->status); + } + switch (result->opcode) { + case ADM_CMD_DEVICE_OPEN_V5: + case ADM_CMD_DEVICE_CLOSE_V5: + copp = adm_find_copp(adm, port_idx, copp_idx); + if (IS_ERR_OR_NULL(copp)) + return 0; + + copp->stat = result->status; + wake_up(&copp->wait); + break; + case ADM_CMD_MATRIX_MAP_ROUTINGS_V5: + adm->matrix_map_stat = result->status; + wake_up(&adm->matrix_map_wait); + break; + + default: + dev_err(&adev->dev, "Unknown Cmd: 0x%x\n", + result->opcode); + break; + } + return 0; + } + case ADM_CMDRSP_DEVICE_OPEN_V5: { + struct adm_cmd_rsp_device_open_v5 { + u32 status; + u16 copp_id; + u16 reserved; + } __packed * open = data->payload; + + open = data->payload; + copp = adm_find_copp(adm, port_idx, copp_idx); + if (IS_ERR_OR_NULL(copp)) + return 0; + + if (open->copp_id == INVALID_COPP_ID) { + dev_err(&adev->dev, "Invalid coppid rxed %d\n", + open->copp_id); + copp->stat = ADSP_EBADPARAM; + wake_up(&copp->wait); + break; + } + copp->stat = result->opcode; + copp->id = open->copp_id; + wake_up(&copp->wait); + } + break; + default: + dev_err(&adev->dev, "Unknown cmd:0x%x\n", + data->opcode); + break; + } + + return 0; +} + +static struct copp *adm_alloc_copp(struct q6adm *adm, int port_idx) +{ + struct copp *c; + int idx; + + idx = find_first_zero_bit(&adm->copp_bitmap[port_idx], + MAX_COPPS_PER_PORT); + + if (idx > MAX_COPPS_PER_PORT) + return ERR_PTR(-EBUSY); + + c = kzalloc(sizeof(*c), GFP_KERNEL); + if (!c) + return ERR_PTR(-ENOMEM); + + set_bit(idx, &adm->copp_bitmap[port_idx]); + c->copp_idx = idx; + c->afe_port = port_idx; + c->adm = adm; + + mutex_init(&c->lock); + init_waitqueue_head(&c->wait); + + spin_lock(&adm->copps_list_lock); + list_add_tail(&c->node, &adm->copps_list); + spin_unlock(&adm->copps_list_lock); + + return c; +} + +static void adm_free_copp(struct q6adm *adm, struct copp *c, int port_idx) +{ + clear_bit(c->copp_idx, &adm->copp_bitmap[port_idx]); + spin_lock(&adm->copps_list_lock); + list_del(&c->node); + spin_unlock(&adm->copps_list_lock); + kfree(c); +} + +static struct copp *adm_find_matching_copp(struct q6adm *adm, + int port_id, int topology, + int mode, int rate, int channel_mode, + int bit_width, int app_type) +{ + struct copp *c; + + spin_lock(&adm->copps_list_lock); + + list_for_each_entry(c, &adm->copps_list, node) { + if ((port_id == c->afe_port) && (topology == c->topology) && + (mode == c->mode) && (rate == c->rate) && + (bit_width == c->bit_width) && (app_type == c->app_type)) { + spin_unlock(&adm->copps_list_lock); + return c; + } + } + spin_unlock(&adm->copps_list_lock); + + c = adm_alloc_copp(adm, port_id); + if (IS_ERR_OR_NULL(c)) + return ERR_CAST(c); + + mutex_lock(&c->lock); + c->refcnt = 0; + c->topology = topology; + c->mode = mode; + c->rate = rate; + c->channels = channel_mode; + c->bit_width = bit_width; + c->app_type = app_type; + mutex_unlock(&c->lock); + + return c; + +} + +static int q6adm_apr_send_copp_pkt(struct q6adm *adm, struct copp *copp, + void *data) +{ + struct device *dev = adm->dev; + int ret; + + mutex_lock(&copp->lock); + copp->stat = -1; + ret = apr_send_pkt(adm->apr, data); + if (ret < 0) { + dev_err(dev, "Failed to send APR packet\n"); + ret = -EINVAL; + goto err; + } + /* Wait for the callback with copp id */ + ret = wait_event_timeout(copp->wait, copp->stat >= 0, + msecs_to_jiffies(TIMEOUT_MS)); + if (!ret) { + dev_err(dev, "ADM copp cmd timedout\n"); + ret = -EINVAL; + } else if (copp->stat > 0) { + dev_err(dev, "DSP returned error[%s]\n", + q6dsp_strerror(copp->stat)); + ret = q6dsp_errno(copp->stat); + } + +err: + mutex_unlock(&copp->lock); + return ret; +} + +static int q6adm_device_open(struct q6adm *adm, struct copp *copp, int port_id, + int path, int topology, int channel_mode, + int bit_width, int rate) +{ + struct adm_cmd_device_open_v5 open = {0,}; + int afe_port = q6afe_get_port_id(port_id); + int ret; + + open.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, + APR_HDR_LEN(APR_HDR_SIZE), + APR_PKT_VER); + open.hdr.pkt_size = sizeof(open); + open.hdr.src_svc = APR_SVC_ADM; + open.hdr.src_domain = APR_DOMAIN_APPS; + open.hdr.src_port = afe_port; + open.hdr.dest_svc = APR_SVC_ADM; + open.hdr.dest_domain = APR_DOMAIN_ADSP; + open.hdr.dest_port = afe_port; + open.hdr.token = port_id << 16 | copp->copp_idx; + open.hdr.opcode = ADM_CMD_DEVICE_OPEN_V5; + open.flags = ADM_LEGACY_DEVICE_SESSION; + open.mode_of_operation = path; + open.endpoint_id_1 = afe_port; + open.topology_id = topology; + open.dev_num_channel = channel_mode & 0x00FF; + open.bit_width = bit_width; + open.sample_rate = rate; + + ret = q6dsp_map_channels(&open.dev_channel_mapping[0], + channel_mode); + if (ret) + return ret; + + return q6adm_apr_send_copp_pkt(adm, copp, &open); +} + +/** + * q6adm_open() - open adm and grab a free copp + * + * @dev: Pointer to adm child device. + * @port_id: port id + * @path: playback or capture path. + * @rate: rate at which copp is required. + * @channel_mode: channel mode + * @topology: adm topology id + * @perf_mode: performace mode. + * @bit_width: audio sample bit width + * @app_type: Application type. + * @acdb_id: ACDB id + * + * Return: Will be an negative on error or a valid copp index on success. + */ +int q6adm_open(struct device *dev, int port_id, int path, int rate, + int channel_mode, int topology, int perf_mode, + uint16_t bit_width, int app_type, int acdb_id) +{ + struct q6adm *adm = dev_get_drvdata(dev); + struct copp *copp; + int ret = 0; + + if (port_id < 0) { + dev_err(dev, "Invalid port_id 0x%x\n", port_id); + return -EINVAL; + } + + copp = adm_find_matching_copp(adm, port_id, topology, perf_mode, + rate, channel_mode, bit_width, app_type); + + /* Create a COPP if port id are not enabled */ + if (copp->refcnt == 0) { + ret = q6adm_device_open(adm, copp, port_id, path, topology, + channel_mode, bit_width, rate); + if (ret < 0) + return ret; + } + mutex_lock(&copp->lock); + copp->refcnt++; + mutex_unlock(&copp->lock); + + return copp->copp_idx; +} +EXPORT_SYMBOL_GPL(q6adm_open); + +/** + * q6adm_set_routing_data() - set routing private data + * + * @dev: Pointer to adm device. + * @data: routing private data + * + */ +void q6adm_set_routing_data(struct device *dev, void *data) +{ + struct q6adm *adm = dev_get_drvdata(dev); + + adm->routing_data = data; +} +EXPORT_SYMBOL_GPL(q6adm_set_routing_data); + +/** + * q6adm_get_routing_data() - get routing private data + * + * @dev: Pointer to adm device. + * + * Return: pointer to routing private data + */ +void *q6adm_get_routing_data(struct device *dev) +{ + struct q6adm *adm = dev_get_drvdata(dev); + + return adm->routing_data; +} +EXPORT_SYMBOL_GPL(q6adm_get_routing_data); + +/** + * q6adm_matrix_map() - Map asm streams and afe ports using payload + * + * @dev: Pointer to adm child device. + * @path: playback or capture path. + * @payload_map: map between session id and afe ports. + * @perf_mode: Performace mode. + * + * Return: Will be an negative on error or a zero on success. + */ +int q6adm_matrix_map(struct device *dev, int path, + struct route_payload payload_map, int perf_mode) +{ + struct q6adm *adm = dev_get_drvdata(dev); + struct adm_cmd_matrix_map_routings_v5 *route; + struct adm_session_map_node_v5 *node; + uint16_t *copps_list; + int cmd_size, ret, i, copp_idx; + void *matrix_map = NULL; + struct copp *copp; + + /* Assumes port_ids have already been validated during adm_open */ + cmd_size = (sizeof(*route) + + sizeof(*node) + + (sizeof(uint32_t) * payload_map.num_copps)); + matrix_map = kzalloc(cmd_size, GFP_KERNEL); + if (!matrix_map) + return -ENOMEM; + + route = matrix_map; + route->hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, + APR_HDR_LEN(APR_HDR_SIZE), + APR_PKT_VER); + route->hdr.pkt_size = cmd_size; + route->hdr.src_svc = 0; + route->hdr.src_domain = APR_DOMAIN_APPS; + route->hdr.dest_svc = APR_SVC_ADM; + route->hdr.dest_domain = APR_DOMAIN_ADSP; + route->hdr.token = 0; + route->hdr.opcode = ADM_CMD_MATRIX_MAP_ROUTINGS_V5; + route->num_sessions = 1; + + switch (path) { + case ADM_PATH_PLAYBACK: + route->matrix_id = ADM_MATRIX_ID_AUDIO_RX; + break; + default: + dev_err(dev, "Wrong path set[%d]\n", path); + + break; + } + + node = matrix_map + sizeof(*route); + node->session_id = payload_map.session_id; + node->num_copps = payload_map.num_copps; + copps_list = matrix_map + sizeof(*route) + sizeof(*node); + + for (i = 0; i < payload_map.num_copps; i++) { + int port_idx = payload_map.port_id[i]; + + if (port_idx < 0) { + dev_err(dev, "Invalid port_id 0x%x\n", + payload_map.port_id[i]); + ret = -EINVAL; + goto fail_cmd; + } + copp_idx = payload_map.copp_idx[i]; + + copp = adm_find_copp(adm, port_idx, copp_idx); + if (IS_ERR_OR_NULL(copp)) { + ret = -EINVAL; + goto fail_cmd; + } + + copps_list[i] = copp->id; + } + + mutex_lock(&adm->lock); + adm->matrix_map_stat = -1; + + ret = apr_send_pkt(adm->apr, matrix_map); + if (ret < 0) { + dev_err(dev, "routing for syream %d failed ret %d\n", + payload_map.session_id, ret); + ret = -EINVAL; + goto fail_cmd; + } + ret = wait_event_timeout(adm->matrix_map_wait, + adm->matrix_map_stat >= 0, + msecs_to_jiffies(TIMEOUT_MS)); + if (!ret) { + dev_err(dev, "routing for syream %d failed\n", + payload_map.session_id); + ret = -ETIMEDOUT; + goto fail_cmd; + } else if (adm->matrix_map_stat > 0) { + dev_err(dev, "DSP returned error[%s]\n", + q6dsp_strerror(adm->matrix_map_stat)); + ret = q6dsp_errno(adm->matrix_map_stat); + goto fail_cmd; + } + +fail_cmd: + mutex_unlock(&adm->lock); + kfree(matrix_map); + return ret; +} +EXPORT_SYMBOL_GPL(q6adm_matrix_map); + +static int q6adm_device_close(struct q6adm *adm, struct copp *copp, + int port_id, int copp_idx) +{ + struct apr_hdr close = {0}; + + close.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, + APR_HDR_LEN(APR_HDR_SIZE), + APR_PKT_VER); + close.pkt_size = sizeof(close); + close.src_svc = APR_SVC_ADM; + close.src_domain = APR_DOMAIN_APPS; + close.src_port = port_id; + close.dest_svc = APR_SVC_ADM; + close.dest_domain = APR_DOMAIN_ADSP; + close.dest_port = copp->id; + close.token = port_id << 16 | copp_idx; + close.opcode = ADM_CMD_DEVICE_CLOSE_V5; + + return q6adm_apr_send_copp_pkt(adm, copp, &close); +} + +/** + * q6adm_close() - Close adm copp + * + * @dev: Pointer to adm child device. + * @port_id: afe port id. + * @perf_mode: perf_mode mode + * @copp_idx: copp index to close + * + * Return: Will be an negative on error or a zero on success. + */ +int q6adm_close(struct device *dev, int port_id, int perf_mode, int copp_idx) +{ + struct q6adm *adm = dev_get_drvdata(dev); + struct copp *copp; + + if (port_id < 0) { + dev_err(dev, "Invalid port_id 0x%x\n", port_id); + return -EINVAL; + } + + if ((copp_idx < 0) || (copp_idx >= MAX_COPPS_PER_PORT)) { + dev_err(dev, "Invalid copp idx: %d\n", copp_idx); + return -EINVAL; + } + + copp = adm_find_copp(adm, port_id, copp_idx); + if (IS_ERR_OR_NULL(copp)) + return -EINVAL; + + mutex_lock(&copp->lock); + copp->refcnt--; + mutex_unlock(&copp->lock); + if (!copp->refcnt) { + int ret = q6adm_device_close(adm, copp, port_id, copp_idx); + + if (ret < 0) + return ret; + + adm_free_copp(adm, copp, port_id); + } + + return 0; +} +EXPORT_SYMBOL_GPL(q6adm_close); + +static int q6adm_probe(struct apr_device *adev) +{ + struct q6adm *adm; + + adm = devm_kzalloc(&adev->dev, sizeof(*adm), GFP_KERNEL); + if (!adm) + return -ENOMEM; + + adm->apr = adev; + dev_set_drvdata(&adev->dev, adm); + adm->dev = &adev->dev; + adm->matrix_map_stat = 0; + mutex_init(&adm->lock); + init_waitqueue_head(&adm->matrix_map_wait); + + INIT_LIST_HEAD(&adm->copps_list); + spin_lock_init(&adm->copps_list_lock); + + return q6pcm_routing_probe(adm->dev); +} + +static int q6adm_exit(struct apr_device *adev) +{ + q6pcm_routing_remove(&adev->dev); + return 0; +} + +static const struct of_device_id q6adm_device_id[] = { + { .compatible = "qcom,q6adm" }, + {}, +}; +MODULE_DEVICE_TABLE(of, q6adm_device_id); + +static struct apr_driver qcom_q6adm_driver = { + .probe = q6adm_probe, + .remove = q6adm_exit, + .callback = adm_callback, + .driver = { + .name = "qcom-q6adm", + .of_match_table = of_match_ptr(q6adm_device_id), + }, +}; + +module_apr_driver(qcom_q6adm_driver); +MODULE_DESCRIPTION("Q6 Audio Device Manager"); +MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/qcom/qdsp6/q6adm.h b/sound/soc/qcom/qdsp6/q6adm.h new file mode 100644 index 000000000000..8f89210e2fcf --- /dev/null +++ b/sound/soc/qcom/qdsp6/q6adm.h @@ -0,0 +1,26 @@ +// SPDX-License-Identifier: GPL-2.0 +#ifndef __Q6_ADM_V2_H__ +#define __Q6_ADM_V2_H__ + +#define ADM_PATH_PLAYBACK 0x1 +#define MAX_COPPS_PER_PORT 8 +#define NULL_COPP_TOPOLOGY 0x00010312 + +/* multiple copp per stream. */ +struct route_payload { + int num_copps; + int session_id; + int copp_idx[MAX_COPPS_PER_PORT]; + int port_id[MAX_COPPS_PER_PORT]; +}; + +void *q6adm_get_routing_data(struct device *dev); +void q6adm_set_routing_data(struct device *dev, void *data); +int q6adm_open(struct device *dev, int port_id, int path, int rate, + int channel_mode, int topology, int perf_mode, + uint16_t bit_width, int app_type, int acdb_id); +int q6adm_close(struct device *dev, int port, int topology, int perf_mode); +int q6adm_matrix_map(struct device *dev, int path, + struct route_payload payload_map, int perf_mode); + +#endif /* __Q6_ADM_V2_H__ */ From patchwork Tue Feb 13 16:58:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 128271 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp4459844ljc; Tue, 13 Feb 2018 09:03:35 -0800 (PST) X-Google-Smtp-Source: AH8x224uuPzOJ6mdp2BM+lp2fmE/4vsS+8B4+9j3nN/j1vDrEcWXp77/wLFaOCmJTXl7U/uaIII6 X-Received: by 10.223.158.132 with SMTP id a4mr1809325wrf.236.1518541415643; Tue, 13 Feb 2018 09:03:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518541415; cv=none; d=google.com; s=arc-20160816; b=s/9iBpL//ni+15/toFsYQBVcx49b4b0FJYK9R8wGuLMK32prfpGYa/hfD+U5H3PkgY CjA61GhT5Qx3lAl+3kYDZEs1boXawTbKRdB1mS32a96QvPSx/fFRfJJdTuJWiYRJJPeK J4WV+mCaLBwuVllVnykkA8oX5ZhImtJRCBV1F6m4O/5lLYgAsqUVjwwSRRrc9zTy7iQK B89fs9NFQNFL8ciTrSjBn7K+x1zMm2iu6+GDTzPShKcIC0KqEpNeqBiiFmMjxz6MUM2Q NUdPVTc886OVoGHkfrwsiu+TNZ05GSp4A64qhRaXSvG/OSbq8AWPcECGP6Yi2RyKI68T Yn5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to:arc-authentication-results; bh=B6VIEQahipQ6cqrW7FkLhPv26h2Hlx9NVeYLh1pITHw=; b=f+YFEwI3/AbDIR4t/6iZYgBz0jKOQm4orh47r1NWaWaT5zxPrLqlkSqlfLxYrpIBd8 sGz9Ii2b5K9If4ql9Jhi/s9FiyIZEEpVFHFz8UycDoEbcsANOFqf+Jmum7t/wdolxJQL SrAqand3JgZJLDSBk/eWcdhcrfl1rQlX2og8rxO8e+S4lSkzqB+OV6xizboREglbVPiB Tp2PMxMJThN8Ds/Enix7vorESd0BDKwEzwA9PKjt9WZJjKmVbK8nB/ikcPEn6geA+l7B coilTeKFSlgKXhlaEOp8J7uAk8jZwFcKL/RTF9ueuVivdpo0+Aq7rXjssP8tiGszjToN vZ5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=XJV4MqU+; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from alsa0.perex.cz (alsa0.perex.cz. [77.48.224.243]) by mx.google.com with ESMTP id z17si3713801wrg.434.2018.02.13.09.03.34; Tue, 13 Feb 2018 09:03:35 -0800 (PST) Received-SPF: pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) client-ip=77.48.224.243; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=XJV4MqU+; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id D1A0826797F; Tue, 13 Feb 2018 18:01:31 +0100 (CET) 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 867AE267973; Tue, 13 Feb 2018 18:01:28 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS autolearn=disabled version=3.4.0 Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by alsa0.perex.cz (Postfix) with ESMTP id AE1C726795E for ; Tue, 13 Feb 2018 18:01:25 +0100 (CET) Received: by mail-wm0-f65.google.com with SMTP id j21so14097575wmh.1 for ; Tue, 13 Feb 2018 09:01:25 -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=/QgrLtTUZZuxnkuSzL60H80LEuHsLt6Z29SEmWGIcyE=; b=XJV4MqU+uScpNpHY2ATlSkylUHxMl/82AMwqgBq4OK+zQzJRy7XHODgC9Xp7Gk2mB5 9qiW7JoH0hBDnO52UPs2UjLg7YUf1zs7hQDsapcNehSD0uTs/1/IHyfRFJDYmZpuopoQ 8IS6lX0QcKCnzaBrcZqDbsRypIjG9xYLhEZ8I= 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=/QgrLtTUZZuxnkuSzL60H80LEuHsLt6Z29SEmWGIcyE=; b=KMRmvwDKAdPxE2elJRNEiCuuzfQoLWXPsH82Q9IURURI7dVcgh+V4kY/ZF/3DgKco7 /WL1KM37s/uXkCUT9Kp7XmYUBaOJQhNC9Iv7twwKcuU5s6sKzwwabix93+ReSTyPJAm7 UGv9f6mzvPtNFnxTA3tzBVQEM0rFnw58Xux1aYa1Y+Qxzt3yVXm+IXpnZzwFMfGkC5BG gZ4rbyDifC6xCKqi4WiKV31aYZZmacUBfdXkQpHNpoA0kpQg3MnSHgfrsXHH++rNjUs1 RJkfRwMJ6Rv0LojQ3UEZqLUEDVsQ0ajUnPhvOZZvGTHRkMNX74cp87OvRuhE86OYoZfs SCCA== X-Gm-Message-State: APf1xPDOXaKpANKqoNh5lsOcEgTTrkkHU3GOW7AEaJZbbqwE8p8Ht3Qk JYtdH+BHkXMPJ7ZKO/b1rn7MjQ== X-Received: by 10.28.199.132 with SMTP id x126mr1787691wmf.71.1518541285191; Tue, 13 Feb 2018 09:01:25 -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.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 13 Feb 2018 09:01:24 -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 Date: Tue, 13 Feb 2018 16:58:20 +0000 Message-Id: <20180213165837.1620-9-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> Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, bgoswami@codeaurora.org, rohkumar@qti.qualcomm.com, linux-kernel@vger.kernel.org, plai@codeaurora.org, tiwai@suse.com, lgirdwood@gmail.com, david.brown@linaro.org, robh+dt@kernel.org, Srinivas Kandagatla , spatakok@qti.qualcomm.com, linux-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [alsa-devel] [PATCH v3 08/25] dt-bindings: sound: qcom: Add bindings for q6asm 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 From: Srinivas Kandagatla Signed-off-by: Srinivas Kandagatla --- .../devicetree/bindings/sound/qcom,q6asm.txt | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/qcom,q6asm.txt -- 2.15.1 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel diff --git a/Documentation/devicetree/bindings/sound/qcom,q6asm.txt b/Documentation/devicetree/bindings/sound/qcom,q6asm.txt new file mode 100644 index 000000000000..5d6a90681796 --- /dev/null +++ b/Documentation/devicetree/bindings/sound/qcom,q6asm.txt @@ -0,0 +1,38 @@ +Qualcomm Audio Stream Manager (Q6ASM) binding + +Q6ASM is one of the APR audio service on Q6DSP. +Please refer to qcom,apr.txt for details of the coommon apr service bindings +used by the apr service device. + +- but must contain the following property: + +- compatible: + Usage: required + Value type: + Definition: must be "qcom,asm-v.". + example "qcom,asm-v2.0" + +- qcom,apr-svc-id + Usage: required + Value type: + Definition: Must be 7 for Audio Stream Manager Service. + +- qcom,apr-svc-name + Usage: required + Value type: + Definition: Must be "ASM" + +- #sound-dai-cells + Usage: required + Value type: + Definition: Must be 1 + + += EXAMPLE + +q6asm: q6asm { + compatible = "qcom,q6asm"; + qcom,apr-svc-name = "ASM"; + qcom,apr-svc-id = ; + #sound-dai-cells = <1>; +}; From patchwork Tue Feb 13 16:58:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 128275 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp4460419ljc; Tue, 13 Feb 2018 09:04:04 -0800 (PST) X-Google-Smtp-Source: AH8x224PnHFhdRN98c3OpBSJTa+JPVqB5zE1uqimPsG3pL3Jy85AquReIFBI4dGdIjYa909PnEG2 X-Received: by 10.223.153.230 with SMTP id y93mr1821666wrb.215.1518541444022; Tue, 13 Feb 2018 09:04:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518541444; cv=none; d=google.com; s=arc-20160816; b=xgCIJLjkzbNzUxJFqq+CsMnvuKWqYu4O2Nv0nHksmo+fI+tN0A6FRoG+yEfd6eajTZ gbPtm571e5QHWxVt85whoNTEg5gCLbhzFbKOsyff9H/mHwfi/SKl05r+XIbFvajAOfCp uv2RIAXMX31K7rs1AKxeG2szpWe8pIbSpeYNeadh9CEPYLgZFTDbkO1zkury3zsJKxnx qfIKQoDgysaMi71VqXgt80tdeClNryihkt1Y/zhN5P4PplP58QCSJNGve0B9TJdB+WQJ O4Hph+iV+XkZB4J3PINC+DfRN2w6QzsyN7X1jX6q9pkBfkEEuDVXptCqOhezws6PUHW1 BWNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to:arc-authentication-results; bh=s30iQwmm/F/yoNSW+HtzP3Nw0LRclJsA80oI+K25m3s=; b=T3xhHNO04l9Uf9Sa1Y41z9inaQr2R/RUERYhqw7XSzYjp7oCrEVxQ2YunU9SS3EXXJ H6Ly12S0CM+7pv0JWNY0aRzxFZgXHagqAk8nIBqLsiJKb9mUB3qwRlikgUyPtA8f55M8 g2zmX6JiSg237CPtkikVRrlhXVWDq07Yu5sO3b6Q0QExOWEGMbvB/72tmssPCx3yKsFR 13KdR8nBFpYnLv4DJdrYHl2GFtgqb6rwblE5v+z8w+ChdrzQ99i+dlk5TtlYsX+YJtEI 9Sn9xqwJH4fQiwSvDNSONgxsUgTiUCS3fOC7AuKOso1dFPR4k24JlwtV0SaXfmoQ1XY3 yvIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=c4/Rm6U9; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from alsa0.perex.cz (alsa0.perex.cz. [77.48.224.243]) by mx.google.com with ESMTP id o8si6342554wra.440.2018.02.13.09.04.03; Tue, 13 Feb 2018 09:04:04 -0800 (PST) Received-SPF: pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) client-ip=77.48.224.243; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=c4/Rm6U9; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 3EB8A267991; Tue, 13 Feb 2018 18:01:33 +0100 (CET) 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 195E0267976; Tue, 13 Feb 2018 18:01:30 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS autolearn=disabled version=3.4.0 Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by alsa0.perex.cz (Postfix) with ESMTP id ECF97267975 for ; Tue, 13 Feb 2018 18:01:26 +0100 (CET) Received: by mail-wm0-f66.google.com with SMTP id i186so17315667wmi.4 for ; Tue, 13 Feb 2018 09:01:26 -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=ZA2y8zemA2ia74W0PyEVkJBP64izsiQnMDoIJ7E6DUM=; b=c4/Rm6U95dWkRIwxoHFZCWV8Aed0MHjix3ibs/HC3EBrxgKaSAg5YvsLKg+r3yy5rW OyK9SweqvNxq0fE0KO+2N33zJdDzRNNCc9riyasbs46lui/0cOIqpSdwCW/NJh/g9IHS qw05kZwpdSPJYanwv1wF5u3rwdVbYHqdX/g/E= 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=ZA2y8zemA2ia74W0PyEVkJBP64izsiQnMDoIJ7E6DUM=; b=hiEYm+pzTz1KhljaDlimyJAlkfMa+ol0s+qHfFDPPjKpXhsThVovc53yq7J1Ek19av yQ7lhdv+aRn6td8pvSX+yPrNKYxN8VXjQWWQXvDHWth39hYptsHmn6qVfA6rP2O5zdIq GtmjgXssLKNJz7Z+7lvZATd3/2WiJw0TuXediLWRDBZTy/SIVq8aY+zhDooDbeIlw6Ey x7lixq+P8mWD0cbKmQ0/U1fwOdHzcFEZzbF39K6XCKIEayG6UmApg/bmY+/2r311J8Rp 6DbSDhOqD+wM3A7NYGed1xcTYicrnY/nqKZU4Vsh5Huokkc0l3QfM9J7Palv0um1ZdH4 Y83g== X-Gm-Message-State: APf1xPAbgx0SvntDATyYRbVs8xylXXpttyIJbjew26uD3xPsqMCwma+Q FdNCBxhtyiyGyaXDmUNH3S8A3ReNXSc= X-Received: by 10.28.142.74 with SMTP id q71mr1931468wmd.125.1518541286517; Tue, 13 Feb 2018 09:01:26 -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.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 13 Feb 2018 09:01:25 -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 Date: Tue, 13 Feb 2018 16:58:21 +0000 Message-Id: <20180213165837.1620-10-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> Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, bgoswami@codeaurora.org, rohkumar@qti.qualcomm.com, linux-kernel@vger.kernel.org, plai@codeaurora.org, tiwai@suse.com, lgirdwood@gmail.com, david.brown@linaro.org, robh+dt@kernel.org, Srinivas Kandagatla , spatakok@qti.qualcomm.com, linux-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [alsa-devel] [PATCH v3 09/25] ASoC: qcom: qdsp6: Add support to Q6ASM 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 From: Srinivas Kandagatla This patch adds basic support to Q6 ASM (Audio Stream Manager) module on Q6DSP. ASM supports up to 8 concurrent streams. each stream can be setup as playback/capture. ASM provides top control functions like Pause/flush/resume for playback and record. ASM can Create/destroy encoder, decoder and also provides POPP dynamic services. This patch adds support to basic features to allow hdmi playback. Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/Kconfig | 5 + sound/soc/qcom/qdsp6/Makefile | 1 + sound/soc/qcom/qdsp6/q6asm.c | 252 ++++++++++++++++++++++++++++++++++++++++++ sound/soc/qcom/qdsp6/q6asm.h | 18 +++ 4 files changed, 276 insertions(+) create mode 100644 sound/soc/qcom/qdsp6/q6asm.c create mode 100644 sound/soc/qcom/qdsp6/q6asm.h -- 2.15.1 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel diff --git a/sound/soc/qcom/Kconfig b/sound/soc/qcom/Kconfig index bf04e1301608..a14d960b8fe4 100644 --- a/sound/soc/qcom/Kconfig +++ b/sound/soc/qcom/Kconfig @@ -56,12 +56,17 @@ config SND_SOC_QDSP6_ADM tristate default n +config SND_SOC_QDSP6_ASM + tristate + default n + config SND_SOC_QDSP6 tristate "SoC ALSA audio driver for QDSP6" depends on QCOM_APR && HAS_DMA select SND_SOC_QDSP6_COMMON select SND_SOC_QDSP6_AFE select SND_SOC_QDSP6_ADM + select SND_SOC_QDSP6_ASM help To add support for MSM QDSP6 Soc Audio. This will enable sound soc platform specific diff --git a/sound/soc/qcom/qdsp6/Makefile b/sound/soc/qcom/qdsp6/Makefile index 930944425051..eea962315ab3 100644 --- a/sound/soc/qcom/qdsp6/Makefile +++ b/sound/soc/qcom/qdsp6/Makefile @@ -1,3 +1,4 @@ obj-$(CONFIG_SND_SOC_QDSP6_COMMON) += q6dsp-common.o obj-$(CONFIG_SND_SOC_QDSP6_AFE) += q6afe.o obj-$(CONFIG_SND_SOC_QDSP6_ADM) += q6adm.o +obj-$(CONFIG_SND_SOC_QDSP6_ASM) += q6asm.o diff --git a/sound/soc/qcom/qdsp6/q6asm.c b/sound/soc/qcom/qdsp6/q6asm.c new file mode 100644 index 000000000000..768d9b446da9 --- /dev/null +++ b/sound/soc/qcom/qdsp6/q6asm.c @@ -0,0 +1,252 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2011-2017, The Linux Foundation + * Copyright (c) 2018, Linaro Limited + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "q6asm.h" +#include "q6dsp-errno.h" +#include "q6dsp-common.h" + +#define ASM_SYNC_IO_MODE 0x0001 +#define ASM_ASYNC_IO_MODE 0x0002 +#define ASM_TUN_READ_IO_MODE 0x0004 /* tunnel read write mode */ +#define ASM_TUN_WRITE_IO_MODE 0x0008 /* tunnel read write mode */ + +struct audio_client { + int session; + q6asm_cb cb; + int cmd_state; + void *priv; + uint32_t io_mode; + struct apr_device *adev; + struct mutex lock; + wait_queue_head_t cmd_wait; + int perf_mode; + int stream_id; + struct device *dev; +}; + +struct q6asm { + struct apr_device *adev; + int mem_state; + struct device *dev; + wait_queue_head_t mem_wait; + struct mutex session_lock; + struct platform_device *pcmdev; + struct audio_client *session[MAX_SESSIONS + 1]; + void *dai_data; +}; + +static bool q6asm_is_valid_audio_client(struct audio_client *ac) +{ + struct q6asm *a = dev_get_drvdata(ac->dev); + int n; + + if (!ac) + return false; + + for (n = 1; n <= MAX_SESSIONS; n++) { + if (a->session[n] == ac) + return true; + } + + return false; +} + +/** + * q6asm_audio_client_free() - Freee allocated audio client + * + * @ac: audio client to free + */ +void q6asm_audio_client_free(struct audio_client *ac) +{ + struct q6asm *a = dev_get_drvdata(ac->dev); + + mutex_lock(&a->session_lock); + a->session[ac->session] = NULL; + mutex_unlock(&a->session_lock); + kfree(ac); +} +EXPORT_SYMBOL_GPL(q6asm_audio_client_free); + +static struct audio_client *q6asm_get_audio_client(struct q6asm *a, + int session_id) +{ + if ((session_id <= 0) || (session_id > MAX_SESSIONS)) { + dev_err(a->dev, "invalid session: %d\n", session_id); + return NULL; + } + + if (!a->session[session_id]) { + dev_err(a->dev, "session not active: %d\n", session_id); + return NULL; + } + + return a->session[session_id]; +} + +/** + * q6asm_set_dai_data() - set dai private data + * + * @dev: Pointer to asm device. + * @data: dai private data + * + */ +void q6asm_set_dai_data(struct device *dev, void *data) +{ + struct q6asm *a = dev_get_drvdata(dev); + + a->dai_data = data; +} +EXPORT_SYMBOL_GPL(q6asm_set_dai_data); + +/** + * q6asm_get_dai_data() - get dai private data + * + * @dev: Pointer to asm device. + * + * Return: pointer to dai private data + */ +void *q6asm_get_dai_data(struct device *dev) +{ + struct q6asm *a = dev_get_drvdata(dev); + + return a->dai_data; +} +EXPORT_SYMBOL_GPL(q6asm_get_dai_data); + +static int q6asm_srvc_callback(struct apr_device *adev, + struct apr_client_message *data) +{ + struct aprv2_ibasic_rsp_result_t *result; + struct q6asm *a, *q6asm = dev_get_drvdata(&adev->dev); + struct audio_client *ac = NULL; + struct audio_port_data *port; + uint32_t dir = 0; + uint32_t sid = 0; + + result = data->payload; + sid = (data->token >> 8) & 0x0F; + ac = q6asm_get_audio_client(q6asm, sid); + if (!ac) { + dev_err(&adev->dev, "Audio Client not active\n"); + return 0; + } + + if (ac->cb) + ac->cb(data->opcode, data->token, data->payload, ac->priv); + + return 0; +} + +/** + * q6asm_get_session_id() - get session id for audio client + * + * @ac: audio client pointer + * + * Return: Will be an session id of the audio client. + */ +int q6asm_get_session_id(struct audio_client *c) +{ + return c->session; +} +EXPORT_SYMBOL_GPL(q6asm_get_session_id); + +/** + * q6asm_audio_client_alloc() - Allocate a new audio client + * + * @dev: Pointer to asm child device. + * @cb: event callback. + * @priv: private data associated with this client. + * + * Return: Will be an error pointer on error or a valid audio client + * on success. + */ +struct audio_client *q6asm_audio_client_alloc(struct device *dev, q6asm_cb cb, + void *priv, int stream_id) +{ + struct q6asm *a = dev_get_drvdata(dev); + struct audio_client *ac; + + if (stream_id + 1 > MAX_SESSIONS) + return ERR_PTR(-EINVAL); + + ac = kzalloc(sizeof(*ac), GFP_KERNEL); + if (!ac) + return ERR_PTR(-ENOMEM); + + mutex_lock(&a->session_lock); + a->session[stream_id + 1] = ac; + mutex_unlock(&a->session_lock); + + ac->session = stream_id + 1; + ac->cb = cb; + ac->dev = dev; + ac->priv = priv; + ac->io_mode = ASM_SYNC_IO_MODE; + ac->perf_mode = LEGACY_PCM_MODE; + /* DSP expects stream id from 1 */ + ac->stream_id = 1; + ac->adev = a->adev; + + init_waitqueue_head(&ac->cmd_wait); + mutex_init(&ac->lock); + ac->cmd_state = 0; + + return ac; +} +EXPORT_SYMBOL_GPL(q6asm_audio_client_alloc); + + +static int q6asm_probe(struct apr_device *adev) +{ + struct q6asm *q6asm; + + q6asm = devm_kzalloc(&adev->dev, sizeof(*q6asm), GFP_KERNEL); + if (!q6asm) + return -ENOMEM; + + q6asm->dev = &adev->dev; + q6asm->adev = adev; + q6asm->mem_state = 0; + init_waitqueue_head(&q6asm->mem_wait); + mutex_init(&q6asm->session_lock); + dev_set_drvdata(&adev->dev, q6asm); + + return q6asm_dai_probe(&adev->dev); +} + +static int q6asm_remove(struct apr_device *adev) +{ + return q6asm_dai_remove(&adev->dev); +} + +static const struct of_device_id q6asm_device_id[] = { + { .compatible = "qcom,q6asm" }, + {}, +}; +MODULE_DEVICE_TABLE(of, q6asm_device_id); + +static struct apr_driver qcom_q6asm_driver = { + .probe = q6asm_probe, + .remove = q6asm_remove, + .callback = q6asm_srvc_callback, + .driver = { + .name = "qcom-q6asm", + .of_match_table = of_match_ptr(q6asm_device_id), + }, +}; + +module_apr_driver(qcom_q6asm_driver); +MODULE_DESCRIPTION("Q6 Audio Stream Manager driver"); +MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/qcom/qdsp6/q6asm.h b/sound/soc/qcom/qdsp6/q6asm.h new file mode 100644 index 000000000000..b13fe0d2ea61 --- /dev/null +++ b/sound/soc/qcom/qdsp6/q6asm.h @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: GPL-2.0 +#ifndef __Q6_ASM_H__ +#define __Q6_ASM_H__ + +#define MAX_SESSIONS 16 + +void q6asm_set_dai_data(struct device *dev, void *data); +void *q6asm_get_dai_data(struct device *dev); + +typedef void (*q6asm_cb) (uint32_t opcode, uint32_t token, + void *payload, void *priv); +struct audio_client; +struct audio_client *q6asm_audio_client_alloc(struct device *dev, + q6asm_cb cb, void *priv, + int session_id); +void q6asm_audio_client_free(struct audio_client *ac); +int q6asm_get_session_id(struct audio_client *ac); +#endif /* __Q6_ASM_H__ */ From patchwork Tue Feb 13 16:58:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 128282 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp4462477ljc; Tue, 13 Feb 2018 09:06:04 -0800 (PST) X-Google-Smtp-Source: AH8x226Y049JFz2q+9SwKEv41V01DqejzGEzH73fmmfSfNSI3KhDveN2gfRQvv0xa3yc2jizvDGo X-Received: by 10.223.187.208 with SMTP id z16mr1909024wrg.57.1518541564723; Tue, 13 Feb 2018 09:06:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518541564; cv=none; d=google.com; s=arc-20160816; b=p7PVNCYN00I2ny0w3yLGV5mcKDXPMkDlsnsphOw94G0i4/lCIgfuCm/d6wtGUlXDHF a9Xj5XghZlwnHCsSlA7BiBjIkLTX+Fj6gg0ytlMmo277lhs2H2JAQltSQtJgcUCtDnQK zS1ypW5og4GjO5n5a2aJGQkbu7aP0wtvAbVASDyK49pETSeWCvh+B7kiui9qI6ekMTn5 oqC9uoG6dSbrW9yI8ZrPUYHlP7+ZKYN7qQB9LAai8eQpeM3uvpnyCFr/XqvWXL6hJALh knQovx7kWAMjZWgtWnfyhKViuLhwlymplfqrGWXuPTkiGtSCm3f1Z16DyPgkp9yvN11s h1nA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to:arc-authentication-results; bh=UoocZ2M9ZZFhB8Yeesa/Ko4IexgJUOLfsIVEGrDCP+Y=; b=ijAduhzb5kZeGjnRL3MaxWrJffIm0VALZiUKwh5E6S1u8LnY1ydAkOjpBV+y4a2tBu pFEHFAtKC7O2InTO8P/h6DrsIWcTq/mpDDsm5W+jejooGP/DCxH2tfzbMe85EB1qQUjk tA+kxLA4EQnWvG/YwoYiQfl4ODzeQ95AkhhShqCqYPGZRtCOzrozGUdREaN8lQaZEhuz ntTCtV+oVw4odnghV0wEt8U6YgaIB+SL0kdJ32kD0R+NB7zWCfudz29E69FrRh+6gunk pRYwB0l168WIZUQjlsQ9n0ii2m1RQFn903tVFCLgrflZkYqEJEyNQfcbl7hrjm5/Ihwh kqOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=InQDg3Oz; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from alsa0.perex.cz (alsa0.perex.cz. [77.48.224.243]) by mx.google.com with ESMTP id y138si5413022wmc.255.2018.02.13.09.06.04; Tue, 13 Feb 2018 09:06:04 -0800 (PST) Received-SPF: pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) client-ip=77.48.224.243; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=InQDg3Oz; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 2EE7D267A0E; Tue, 13 Feb 2018 18:01:53 +0100 (CET) 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 803492679D9; Tue, 13 Feb 2018 18:01:51 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_PASS autolearn=disabled version=3.4.0 Received: from mail-wr0-f196.google.com (mail-wr0-f196.google.com [209.85.128.196]) by alsa0.perex.cz (Postfix) with ESMTP id 70784267999 for ; Tue, 13 Feb 2018 18:01:36 +0100 (CET) Received: by mail-wr0-f196.google.com with SMTP id y3so19304765wrh.3 for ; Tue, 13 Feb 2018 09:01:36 -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=cmoqoFXxiRg8McqJo8lPHfnd1+9P7ZdfCuAwoSfnTTU=; b=InQDg3OzjinciEQbPKa2KQw5voo7xJgM7nSrvQpAEPaNgqxEdxhR5rM+98wsFRqNzW UvpB/6iQ8m1aVIRxu1UUlNbvjJPUu91HKveyDDg2wTr01IUS1OM0w1kX6On9Lc+jmzmE MCXcjtCJmj3vfB4oi4M9EinZLOQDyD2tzmslA= 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=cmoqoFXxiRg8McqJo8lPHfnd1+9P7ZdfCuAwoSfnTTU=; b=DfKxf6Te9ADW1b2bjkhYgi0Eta53y/vgyvzbuCabBRBR6MD0wiQtGGn4crL0YcpbZ6 duY3PT+8juPfs9/cmUoo3fhFLQjnIiy/5u4QQNQZ1UqcHy+kFq/o2cBagMiPEtZGnFRB ++a36uZ/m09PegkPKSdsFt9i9c6d5fS2m6sJ8VAevgHe9SNaBaxCEFPMbjE7RRwkvSAv Ybp2MkdE74XyvH34shRdxEr5ANaI1E/PS0edjjfyQWYPZaQEM4ptjMOgFQRjXWcHLOov lbSScmv3LQflj1qIqXU6sf5yQwH2s2UL+6MNeg74BL7B1KQxWOcAhujdjaw9+GB9qHDy FxOQ== X-Gm-Message-State: APf1xPC/MmB63XkyXSO27gY+6u1RropqSLAFdoimy/nec0iIxoZ/vqtl tLh0eRTZ8ldPfxFw73VjSeWK1w== X-Received: by 10.223.134.49 with SMTP id 46mr1751542wrv.262.1518541294789; Tue, 13 Feb 2018 09:01:34 -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.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 13 Feb 2018 09:01:34 -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 Date: Tue, 13 Feb 2018 16:58:27 +0000 Message-Id: <20180213165837.1620-16-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> Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, bgoswami@codeaurora.org, rohkumar@qti.qualcomm.com, linux-kernel@vger.kernel.org, plai@codeaurora.org, tiwai@suse.com, lgirdwood@gmail.com, david.brown@linaro.org, robh+dt@kernel.org, Srinivas Kandagatla , spatakok@qti.qualcomm.com, linux-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [alsa-devel] [PATCH v3 15/25] ASoC: qcom: qdsp6: Add support to q6asm dai driver 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 From: Srinivas Kandagatla This patch adds support to q6asm dai driver which configures Q6ASM streams to pass pcm data. Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/qdsp6/Makefile | 2 +- sound/soc/qcom/qdsp6/q6asm-dai.c | 621 +++++++++++++++++++++++++++++++++++++++ sound/soc/qcom/qdsp6/q6asm.h | 2 + 3 files changed, 624 insertions(+), 1 deletion(-) create mode 100644 sound/soc/qcom/qdsp6/q6asm-dai.c -- 2.15.1 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel diff --git a/sound/soc/qcom/qdsp6/Makefile b/sound/soc/qcom/qdsp6/Makefile index c7833842b878..5f2d54d573f0 100644 --- a/sound/soc/qcom/qdsp6/Makefile +++ b/sound/soc/qcom/qdsp6/Makefile @@ -1,5 +1,5 @@ obj-$(CONFIG_SND_SOC_QDSP6_COMMON) += q6dsp-common.o obj-$(CONFIG_SND_SOC_QDSP6_AFE) += q6afe.o q6afe-dai.o obj-$(CONFIG_SND_SOC_QDSP6_ADM) += q6adm.o q6routing.o -obj-$(CONFIG_SND_SOC_QDSP6_ASM) += q6asm.o +obj-$(CONFIG_SND_SOC_QDSP6_ASM) += q6asm.o q6asm-dai.o obj-$(CONFIG_SND_SOC_QDSP6_CORE) += q6core.o diff --git a/sound/soc/qcom/qdsp6/q6asm-dai.c b/sound/soc/qcom/qdsp6/q6asm-dai.c new file mode 100644 index 000000000000..7c5e94b2ced4 --- /dev/null +++ b/sound/soc/qcom/qdsp6/q6asm-dai.c @@ -0,0 +1,621 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2011-2016, The Linux Foundation + * Copyright (c) 2017, Linaro Limited + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "q6asm.h" +#include "q6routing.h" +#include "q6dsp-errno.h" + +#define PLAYBACK_MIN_NUM_PERIODS 2 +#define PLAYBACK_MAX_NUM_PERIODS 8 +#define PLAYBACK_MAX_PERIOD_SIZE 65536 +#define PLAYBACK_MIN_PERIOD_SIZE 128 + +enum stream_state { + Q6ASM_STREAM_IDLE = 0, + Q6ASM_STREAM_STOPPED, + Q6ASM_STREAM_RUNNING, +}; + +struct q6asm_dai_rtd { + struct snd_pcm_substream *substream; + phys_addr_t phys; + unsigned int pcm_size; + unsigned int pcm_count; + unsigned int pcm_irq_pos; /* IRQ position */ + unsigned int periods; + uint16_t bits_per_sample; + uint16_t source; /* Encoding source bit mask */ + struct audio_client *audio_client; + uint16_t session_id; + enum stream_state state; +}; + +struct q6asm_dai_data { + long long int sid; +}; + +static struct snd_pcm_hardware q6asm_dai_hardware_playback = { + .info = (SNDRV_PCM_INFO_MMAP | + SNDRV_PCM_INFO_BLOCK_TRANSFER | + SNDRV_PCM_INFO_MMAP_VALID | + SNDRV_PCM_INFO_INTERLEAVED | + SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME), + .formats = (SNDRV_PCM_FMTBIT_S16_LE | + SNDRV_PCM_FMTBIT_S24_LE), + .rates = SNDRV_PCM_RATE_8000_192000, + .rate_min = 8000, + .rate_max = 192000, + .channels_min = 1, + .channels_max = 8, + .buffer_bytes_max = (PLAYBACK_MAX_NUM_PERIODS * + PLAYBACK_MAX_PERIOD_SIZE), + .period_bytes_min = PLAYBACK_MIN_PERIOD_SIZE, + .period_bytes_max = PLAYBACK_MAX_PERIOD_SIZE, + .periods_min = PLAYBACK_MIN_NUM_PERIODS, + .periods_max = PLAYBACK_MAX_NUM_PERIODS, + .fifo_size = 0, +}; + +/* Conventional and unconventional sample rate supported */ +static unsigned int supported_sample_rates[] = { + 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000, + 88200, 96000, 176400, 192000 +}; + +static struct snd_pcm_hw_constraint_list constraints_sample_rates = { + .count = ARRAY_SIZE(supported_sample_rates), + .list = supported_sample_rates, + .mask = 0, +}; + +static void event_handler(uint32_t opcode, uint32_t token, + uint32_t *payload, void *priv) +{ + struct q6asm_dai_rtd *prtd = priv; + struct snd_pcm_substream *substream = prtd->substream; + + switch (opcode) { + case ASM_CLIENT_EVENT_CMD_RUN_DONE: + q6asm_write_async(prtd->audio_client, + prtd->pcm_count, 0, 0, NO_TIMESTAMP); + break; + case ASM_CLIENT_EVENT_CMD_EOS_DONE: + prtd->state = Q6ASM_STREAM_STOPPED; + break; + case ASM_CLIENT_EVENT_DATA_WRITE_DONE: { + prtd->pcm_irq_pos += prtd->pcm_count; + snd_pcm_period_elapsed(substream); + if (prtd->state == Q6ASM_STREAM_RUNNING) + q6asm_write_async(prtd->audio_client, + prtd->pcm_count, 0, 0, NO_TIMESTAMP); + + break; + } + default: + break; + } +} + +static int q6asm_dai_prepare(struct snd_pcm_substream *substream) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_soc_pcm_runtime *soc_prtd = substream->private_data; + struct q6asm_dai_rtd *prtd = runtime->private_data; + struct q6asm_dai_data *pdata; + int ret; + + pdata = q6asm_get_dai_data(soc_prtd->platform->dev); + if (!pdata) + return -EINVAL; + + if (!prtd || !prtd->audio_client) { + pr_err("%s: private data null or audio client freed\n", + __func__); + return -EINVAL; + } + + prtd->pcm_count = snd_pcm_lib_period_bytes(substream); + prtd->pcm_irq_pos = 0; + /* rate and channels are sent to audio driver */ + if (prtd->state) { + /* clear the previous setup if any */ + q6asm_cmd(prtd->audio_client, CMD_CLOSE); + q6asm_unmap_memory_regions(substream->stream, + prtd->audio_client); + q6routing_stream_close(soc_prtd->dai_link->id, + SNDRV_PCM_STREAM_PLAYBACK); + } + + ret = q6asm_map_memory_regions(substream->stream, prtd->audio_client, + prtd->phys, + (prtd->pcm_size / prtd->periods), + prtd->periods); + + if (ret < 0) { + pr_err("Audio Start: Buffer Allocation failed rc = %d\n", + ret); + return -ENOMEM; + } + + ret = q6asm_open_write(prtd->audio_client, FORMAT_LINEAR_PCM, + prtd->bits_per_sample); + if (ret < 0) { + pr_err("%s: q6asm_open_write failed\n", __func__); + q6asm_audio_client_free(prtd->audio_client); + prtd->audio_client = NULL; + return -ENOMEM; + } + + prtd->session_id = q6asm_get_session_id(prtd->audio_client); + ret = q6routing_stream_open(soc_prtd->dai_link->id, LEGACY_PCM_MODE, + prtd->session_id, substream->stream); + if (ret) { + pr_err("%s: stream reg failed ret:%d\n", __func__, ret); + return ret; + } + + ret = q6asm_media_format_block_multi_ch_pcm( + prtd->audio_client, runtime->rate, + runtime->channels, NULL, + prtd->bits_per_sample); + if (ret < 0) + pr_info("%s: CMD Format block failed\n", __func__); + + prtd->state = Q6ASM_STREAM_RUNNING; + + return 0; +} + +static int q6asm_dai_trigger(struct snd_pcm_substream *substream, int cmd) +{ + int ret = 0; + struct snd_pcm_runtime *runtime = substream->runtime; + struct q6asm_dai_rtd *prtd = runtime->private_data; + + switch (cmd) { + case SNDRV_PCM_TRIGGER_START: + ret = q6asm_run_nowait(prtd->audio_client, 0, 0, 0); + break; + case SNDRV_PCM_TRIGGER_RESUME: + case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: + ret = q6asm_run_nowait(prtd->audio_client, 0, 0, 0); + break; + case SNDRV_PCM_TRIGGER_STOP: + prtd->state = Q6ASM_STREAM_STOPPED; + ret = q6asm_cmd_nowait(prtd->audio_client, CMD_EOS); + break; + case SNDRV_PCM_TRIGGER_SUSPEND: + case SNDRV_PCM_TRIGGER_PAUSE_PUSH: + ret = q6asm_cmd_nowait(prtd->audio_client, CMD_PAUSE); + break; + default: + ret = -EINVAL; + break; + } + + return ret; +} + +static int q6asm_dai_open(struct snd_pcm_substream *substream) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_soc_pcm_runtime *soc_prtd = substream->private_data; + struct snd_soc_dai *cpu_dai = soc_prtd->cpu_dai; + + struct q6asm_dai_rtd *prtd; + struct q6asm_dai_data *pdata; + struct device *dev = soc_prtd->platform->dev; + int ret = 0; + int stream_id; + + stream_id = cpu_dai->driver->id; + + pdata = q6asm_get_dai_data(dev); + if (!pdata) { + pr_err("Platform data not found ..\n"); + return -EINVAL; + } + + prtd = kzalloc(sizeof(struct q6asm_dai_rtd), GFP_KERNEL); + if (prtd == NULL) + return -ENOMEM; + + prtd->substream = substream; + prtd->audio_client = q6asm_audio_client_alloc(dev, + (q6asm_cb)event_handler, prtd, stream_id); + if (!prtd->audio_client) { + pr_info("%s: Could not allocate memory\n", __func__); + kfree(prtd); + return -ENOMEM; + } + +// prtd->audio_client->dev = dev; + + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + runtime->hw = q6asm_dai_hardware_playback; + + ret = snd_pcm_hw_constraint_list(runtime, 0, + SNDRV_PCM_HW_PARAM_RATE, + &constraints_sample_rates); + if (ret < 0) + pr_info("snd_pcm_hw_constraint_list failed\n"); + /* Ensure that buffer size is a multiple of period size */ + ret = snd_pcm_hw_constraint_integer(runtime, + SNDRV_PCM_HW_PARAM_PERIODS); + if (ret < 0) + pr_info("snd_pcm_hw_constraint_integer failed\n"); + + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + ret = snd_pcm_hw_constraint_minmax(runtime, + SNDRV_PCM_HW_PARAM_BUFFER_BYTES, + PLAYBACK_MIN_NUM_PERIODS * PLAYBACK_MIN_PERIOD_SIZE, + PLAYBACK_MAX_NUM_PERIODS * PLAYBACK_MAX_PERIOD_SIZE); + if (ret < 0) { + pr_err("constraint for buffer bytes min max ret = %d\n", + ret); + } + } + + ret = snd_pcm_hw_constraint_step(runtime, 0, + SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 32); + if (ret < 0) { + pr_err("constraint for period bytes step ret = %d\n", + ret); + } + ret = snd_pcm_hw_constraint_step(runtime, 0, + SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 32); + if (ret < 0) { + pr_err("constraint for buffer bytes step ret = %d\n", + ret); + } + + runtime->private_data = prtd; + + snd_soc_set_runtime_hwparams(substream, &q6asm_dai_hardware_playback); + + runtime->dma_bytes = q6asm_dai_hardware_playback.buffer_bytes_max; + + + if (pdata->sid < 0) + prtd->phys = substream->dma_buffer.addr; + else + prtd->phys = substream->dma_buffer.addr | (pdata->sid << 32); + + snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); + + return 0; +} + +static int q6asm_dai_close(struct snd_pcm_substream *substream) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_soc_pcm_runtime *soc_prtd = substream->private_data; + struct q6asm_dai_rtd *prtd = runtime->private_data; + + if (prtd->audio_client) { + q6asm_cmd(prtd->audio_client, CMD_CLOSE); + q6asm_unmap_memory_regions(substream->stream, + prtd->audio_client); + q6asm_audio_client_free(prtd->audio_client); + } + q6routing_stream_close(soc_prtd->dai_link->id, + SNDRV_PCM_STREAM_PLAYBACK); + kfree(prtd); + return 0; +} + +static snd_pcm_uframes_t q6asm_dai_pointer(struct snd_pcm_substream *substream) +{ + + struct snd_pcm_runtime *runtime = substream->runtime; + struct q6asm_dai_rtd *prtd = runtime->private_data; + + if (prtd->pcm_irq_pos >= prtd->pcm_size) + prtd->pcm_irq_pos = 0; + + return bytes_to_frames(runtime, (prtd->pcm_irq_pos)); +} + +static int q6asm_dai_mmap(struct snd_pcm_substream *substream, + struct vm_area_struct *vma) +{ + + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_soc_pcm_runtime *soc_prtd = substream->private_data; + struct device *dev = soc_prtd->platform->dev->parent; + + return dma_mmap_coherent(dev, vma, + runtime->dma_area, runtime->dma_addr, + runtime->dma_bytes); +} + +static int q6asm_dai_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + struct q6asm_dai_rtd *prtd = runtime->private_data; + + prtd->pcm_size = params_buffer_bytes(params); + prtd->periods = params_periods(params); + + switch (params_format(params)) { + case SNDRV_PCM_FORMAT_S16_LE: + prtd->bits_per_sample = 16; + break; + case SNDRV_PCM_FORMAT_S24_LE: + prtd->bits_per_sample = 24; + break; + } + + return 0; +} + +static struct snd_pcm_ops q6asm_dai_ops = { + .open = q6asm_dai_open, + .hw_params = q6asm_dai_hw_params, + .close = q6asm_dai_close, + .ioctl = snd_pcm_lib_ioctl, + .prepare = q6asm_dai_prepare, + .trigger = q6asm_dai_trigger, + .pointer = q6asm_dai_pointer, + .mmap = q6asm_dai_mmap, +}; + +static int q6asm_dai_pcm_new(struct snd_soc_pcm_runtime *rtd) +{ + struct snd_pcm_substream *substream; + struct of_phandle_args args; + struct device_node *node; + struct q6asm_dai_data *pdata; + struct snd_pcm *pcm = rtd->pcm; + struct device *dev; + int size, ret; + + dev = rtd->platform->dev->parent; + node = dev->of_node; + pdata = q6asm_get_dai_data(rtd->platform->dev); + + ret = of_parse_phandle_with_fixed_args(node, "iommus", 1, 0, &args); + if (ret < 0) + pdata->sid = -1; + else + pdata->sid = args.args[0]; + + + + substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; + size = q6asm_dai_hardware_playback.buffer_bytes_max; + ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, dev, size, + &substream->dma_buffer); + if (ret) + dev_err(dev, "Cannot allocate buffer(s)\n"); + + return ret; +} + +static void q6asm_dai_pcm_free(struct snd_pcm *pcm) +{ + struct snd_pcm_substream *substream; + int i; + + for (i = 0; i < ARRAY_SIZE(pcm->streams); i++) { + substream = pcm->streams[i].substream; + if (substream) { + snd_dma_free_pages(&substream->dma_buffer); + substream->dma_buffer.area = NULL; + substream->dma_buffer.addr = 0; + } + } +} + +static struct snd_soc_platform_driver q6asm_soc_platform = { + .ops = &q6asm_dai_ops, + .pcm_new = q6asm_dai_pcm_new, + .pcm_free = q6asm_dai_pcm_free, + +}; + +static const struct snd_soc_dapm_route afe_pcm_routes[] = { + {"MM_DL1", NULL, "MultiMedia1 Playback" }, + {"MM_DL2", NULL, "MultiMedia2 Playback" }, + {"MM_DL3", NULL, "MultiMedia3 Playback" }, + {"MM_DL4", NULL, "MultiMedia4 Playback" }, + {"MM_DL5", NULL, "MultiMedia5 Playback" }, + {"MM_DL6", NULL, "MultiMedia6 Playback" }, + {"MM_DL7", NULL, "MultiMedia7 Playback" }, + +}; + +static int fe_dai_probe(struct snd_soc_dai *dai) +{ + struct snd_soc_dapm_context *dapm; + + dapm = snd_soc_component_get_dapm(dai->component); + snd_soc_dapm_add_routes(dapm, afe_pcm_routes, + ARRAY_SIZE(afe_pcm_routes)); + + return 0; +} + +static const struct snd_soc_component_driver q6asm_fe_dai_component = { + .name = "q6asm-fe-dai", +}; + +static struct snd_soc_dai_driver q6asm_fe_dais[] = { + { + .playback = { + .stream_name = "MultiMedia1 Playback", + .rates = (SNDRV_PCM_RATE_8000_192000| + SNDRV_PCM_RATE_KNOT), + .formats = (SNDRV_PCM_FMTBIT_S16_LE | + SNDRV_PCM_FMTBIT_S24_LE), + .channels_min = 1, + .channels_max = 8, + .rate_min = 8000, + .rate_max = 192000, + }, + .name = "MultiMedia1", + .probe = fe_dai_probe, + .id = MSM_FRONTEND_DAI_MULTIMEDIA1, + }, + { + .playback = { + .stream_name = "MultiMedia2 Playback", + .rates = (SNDRV_PCM_RATE_8000_192000| + SNDRV_PCM_RATE_KNOT), + .formats = (SNDRV_PCM_FMTBIT_S16_LE | + SNDRV_PCM_FMTBIT_S24_LE), + .channels_min = 1, + .channels_max = 8, + .rate_min = 8000, + .rate_max = 192000, + }, + .name = "MultiMedia2", + .probe = fe_dai_probe, + .id = MSM_FRONTEND_DAI_MULTIMEDIA2, + }, + { + .playback = { + .stream_name = "MultiMedia3 Playback", + .rates = (SNDRV_PCM_RATE_8000_192000| + SNDRV_PCM_RATE_KNOT), + .formats = (SNDRV_PCM_FMTBIT_S16_LE | + SNDRV_PCM_FMTBIT_S24_LE), + .channels_min = 1, + .channels_max = 8, + .rate_min = 8000, + .rate_max = 192000, + }, + .name = "MultiMedia3", + .probe = fe_dai_probe, + .id = MSM_FRONTEND_DAI_MULTIMEDIA3, + }, + { + .playback = { + .stream_name = "MultiMedia4 Playback", + .rates = (SNDRV_PCM_RATE_8000_192000| + SNDRV_PCM_RATE_KNOT), + .formats = (SNDRV_PCM_FMTBIT_S16_LE | + SNDRV_PCM_FMTBIT_S24_LE), + .channels_min = 1, + .channels_max = 8, + .rate_min = 8000, + .rate_max = 192000, + }, + .name = "MultiMedia4", + .probe = fe_dai_probe, + .id = MSM_FRONTEND_DAI_MULTIMEDIA4, + }, + { + .playback = { + .stream_name = "MultiMedia5 Playback", + .rates = (SNDRV_PCM_RATE_8000_192000| + SNDRV_PCM_RATE_KNOT), + .formats = (SNDRV_PCM_FMTBIT_S16_LE | + SNDRV_PCM_FMTBIT_S24_LE), + .channels_min = 1, + .channels_max = 8, + .rate_min = 8000, + .rate_max = 192000, + }, + .name = "MultiMedia5", + .probe = fe_dai_probe, + .id = MSM_FRONTEND_DAI_MULTIMEDIA5, + }, + { + .playback = { + .stream_name = "MultiMedia6 Playback", + .rates = (SNDRV_PCM_RATE_8000_192000| + SNDRV_PCM_RATE_KNOT), + .formats = (SNDRV_PCM_FMTBIT_S16_LE | + SNDRV_PCM_FMTBIT_S24_LE), + .channels_min = 1, + .channels_max = 8, + .rate_min = 8000, + .rate_max = 192000, + }, + .name = "MultiMedia6", + .probe = fe_dai_probe, + .id = MSM_FRONTEND_DAI_MULTIMEDIA6, + }, + { + .playback = { + .stream_name = "MultiMedia7 Playback", + .rates = (SNDRV_PCM_RATE_8000_192000| + SNDRV_PCM_RATE_KNOT), + .formats = (SNDRV_PCM_FMTBIT_S16_LE | + SNDRV_PCM_FMTBIT_S24_LE), + .channels_min = 1, + .channels_max = 8, + .rate_min = 8000, + .rate_max = 192000, + }, + .name = "MultiMedia7", + .probe = fe_dai_probe, + .id = MSM_FRONTEND_DAI_MULTIMEDIA7, + }, + { + .playback = { + .stream_name = "MultiMedia8 Playback", + .rates = (SNDRV_PCM_RATE_8000_192000| + SNDRV_PCM_RATE_KNOT), + .formats = (SNDRV_PCM_FMTBIT_S16_LE | + SNDRV_PCM_FMTBIT_S24_LE), + .channels_min = 1, + .channels_max = 8, + .rate_min = 8000, + .rate_max = 192000, + }, + .name = "MultiMedia8", + .probe = fe_dai_probe, + .id = MSM_FRONTEND_DAI_MULTIMEDIA8, + }, +}; + +int q6asm_dai_probe(struct device *dev) +{ + struct q6asm_dai_data *pdata; + int rc; + + pdata = devm_kzalloc(dev, sizeof(struct q6asm_dai_data), GFP_KERNEL); + if (!pdata) + return -ENOMEM; + + + q6asm_set_dai_data(dev, pdata); + + rc = devm_snd_soc_register_platform(dev, &q6asm_soc_platform); + if (rc) { + dev_err(dev, "err_dai_platform\n"); + return rc; + } + + return devm_snd_soc_register_component(dev, &q6asm_fe_dai_component, + q6asm_fe_dais, + ARRAY_SIZE(q6asm_fe_dais)); +} +EXPORT_SYMBOL_GPL(q6asm_dai_probe); + +int q6asm_dai_remove(struct device *dev) +{ + return 0; +} +EXPORT_SYMBOL_GPL(q6asm_dai_remove); + +MODULE_DESCRIPTION("Q6ASM dai driver"); +MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/qcom/qdsp6/q6asm.h b/sound/soc/qcom/qdsp6/q6asm.h index b5ef90bb724b..6595695f06c3 100644 --- a/sound/soc/qcom/qdsp6/q6asm.h +++ b/sound/soc/qcom/qdsp6/q6asm.h @@ -33,6 +33,8 @@ enum { void q6asm_set_dai_data(struct device *dev, void *data); void *q6asm_get_dai_data(struct device *dev); +int q6asm_dai_probe(struct device *dev); +int q6asm_dai_remove(struct device *dev); typedef void (*q6asm_cb) (uint32_t opcode, uint32_t token, void *payload, void *priv);