From patchwork Tue Feb 13 16:58:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 128276 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp4460438ljc; Tue, 13 Feb 2018 09:04:05 -0800 (PST) X-Google-Smtp-Source: AH8x227mwxxQDMuyjT+UUW3bO0bexVM63Ox7xAb+eFZnE086bcAgPKluehKpeJByhuceUZPzi77B X-Received: by 10.98.27.66 with SMTP id b63mr1894904pfb.103.1518541444882; 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=H8pvuwMDhiTchEDcZr/njjpsL5gerJeaQB5I6YnvdZTTK5XShZFXqj5VqCK6mRp/HB TXgr/ZdcbUqRSQo/zL8Apxup8AnfoQztiN/rrzLp/ecT7eXHXNcLxZxrwsVGfMNjXOFR rvwfRZ4+HrTzkADbn3inpJZDx87a/xo5hfuCuwPi1l/vIwQQHKNO53dPRXLOcMHlWqmz pmlUEMjNuNneTtemnWmBrAd0qp9hMWxWJ9bRQYf7AvrdDtFwNAxMNvlM+X3TZivAesVB bcG6/MXkKYj5HrWyvQ5RbbqOGrxuIlrqKLUEPja+bcIMWcFp+QVEffQJbHRldGLRE4Ch XfIA== 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=WNORhI1jHCTd2QHwvmEA2TDfeVv1My5EG9GdwYD2g8o=; b=c7quXVUYTX/pq1s9xfCs+6aJt5pxLzSFmOB0nA5BMX4jX4uQ3oUInJdQG6NDK/PsWZ VlQ9epI36B0WD0sXO2AGbS1B20d4uea1b3KhunOeJJVIgK42ZfsxOLhwCtymbkdDEztV 6OVajIy7aYn/adps6TOlap7Lwivly9wkUXZMMa5h5g63JlSU/w1t8F/p39wgY7jHVeY8 Q5+D4jAvkv9PBqbhZKNuQHpURu53AOWuDozd1sI7RTjIZzxGupVQweEuJ+HRRIdJ2W5L 34AkCcwnn9xQq/gme4/M0c8Tb0K2fHk8DZ6zB9hE7pYpgcrtIe8ZpEyD3mjjVnWA2Gel NfuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=GXHkUKR8; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k131si1167293pgc.101.2018.02.13.09.04.04; Tue, 13 Feb 2018 09:04:04 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=GXHkUKR8; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965414AbeBMRED (ORCPT + 10 others); Tue, 13 Feb 2018 12:04:03 -0500 Received: from mail-wr0-f194.google.com ([209.85.128.194]:43060 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965493AbeBMRBn (ORCPT ); Tue, 13 Feb 2018 12:01:43 -0500 Received: by mail-wr0-f194.google.com with SMTP id b52so19282699wrd.10 for ; Tue, 13 Feb 2018 09:01:42 -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=jTQy5JAOV7evy+Bhdv5u9UUQREJev4fzJzguSIB9I28=; b=GXHkUKR8/D9//heddGDKElgps4su2v456DwqBxEhDviC4AhTjL/akWHa9MmJxgCngV zx+rpeOIw53eL4+67v5SnfE/H7dBlvjmLVoRbbiP6XoT+s+ZPg/2NfePW0qywH3nbs8v gdIBzu8t780xnQIl7KfSlS8hnP5b0IEyOwSeU= 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=jTQy5JAOV7evy+Bhdv5u9UUQREJev4fzJzguSIB9I28=; b=jswBrV7d2oLjpALfCMcK+hOgl6mlGRyqDNH+sqAD8FhX1DktXmzD8SCuEy5pOeKbKn Vefukw7oyUt/cFFg/V16XAI0SHdCOAMJ8kR2xzIvQ9Xt6sC6d7V1nJDzWstz48326Jrq DloEqXt84XJeNGjgGQK0cbd4IBLEHZ7AEmXXanO7ywl5x6rLXrPMDt5mi3VwJAFWnNGB kirGMEpI4829eR3U70SWtV/XZLCBFTTgiYIbizblEHQrpqkghEumTf1tRkBKqfQla8qE NiOWAVzvUF5Wn9YvkI7dmq+0StrQb+Pyexmh40fXMCxHMHt32f1ZlPqRtl5S9U3Tt+F8 2d7A== X-Gm-Message-State: APf1xPCO6ypOof8zuv4i1HwK0lvga8Y+QN/7Y9Dg8G3NkyNXDVzxfwFz TpZ695r3LQ/rH6rghXUwBjInxw== X-Received: by 10.223.135.115 with SMTP id 48mr2006885wrz.212.1518541300571; Tue, 13 Feb 2018 09:01:40 -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.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 13 Feb 2018 09:01:39 -0800 (PST) From: srinivas.kandagatla@linaro.org To: andy.gross@linaro.org, broonie@kernel.org, linux-arm-msm@vger.kernel.org, alsa-devel@alsa-project.org Cc: david.brown@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com, lgirdwood@gmail.com, plai@codeaurora.org, bgoswami@codeaurora.org, perex@perex.cz, tiwai@suse.com, linux-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, rohkumar@qti.qualcomm.com, spatakok@qti.qualcomm.com, Srinivas Kandagatla Subject: [PATCH v3 19/25] ASoC: qcom: q6afe: add support to MI2S ports Date: Tue, 13 Feb 2018 16:58:31 +0000 Message-Id: <20180213165837.1620-20-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180213165837.1620-1-srinivas.kandagatla@linaro.org> References: <20180213165837.1620-1-srinivas.kandagatla@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Srinivas Kandagatla Signed-off-by: Srinivas Kandagatla --- include/dt-bindings/sound/qcom,q6afe.h | 10 +++ sound/soc/qcom/qdsp6/q6afe.c | 111 +++++++++++++++++++++++++++++++++ sound/soc/qcom/qdsp6/q6afe.h | 10 +++ 3 files changed, 131 insertions(+) -- 2.15.1 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/include/dt-bindings/sound/qcom,q6afe.h b/include/dt-bindings/sound/qcom,q6afe.h index e9004ee39f72..3cd862262369 100644 --- a/include/dt-bindings/sound/qcom,q6afe.h +++ b/include/dt-bindings/sound/qcom,q6afe.h @@ -16,6 +16,16 @@ #define SLIMBUS_4_TX 24 #define SLIMBUS_5_RX 25 #define SLIMBUS_5_TX 26 +#define QUATERNARY_MI2S_RX 34 +#define QUATERNARY_MI2S_TX 35 +#define SECONDARY_MI2S_RX 36 +#define SECONDARY_MI2S_TX 37 +#define TERTIARY_MI2S_RX 38 +#define TERTIARY_MI2S_TX 39 +#define PRIMARY_MI2S_RX 40 +#define PRIMARY_MI2S_TX 41 +#define SECONDARY_PCM_RX 42 +#define SECONDARY_PCM_TX 43 #define SLIMBUS_6_RX 45 #define SLIMBUS_6_TX 46 diff --git a/sound/soc/qcom/qdsp6/q6afe.c b/sound/soc/qcom/qdsp6/q6afe.c index 637390f5421e..c04caea5481c 100644 --- a/sound/soc/qcom/qdsp6/q6afe.c +++ b/sound/soc/qcom/qdsp6/q6afe.c @@ -14,6 +14,10 @@ #include #include #include +#include +#include +#include +#include #include "q6dsp-errno.h" #include "q6afe.h" @@ -28,6 +32,24 @@ #define AFE_PARAM_ID_CDC_SLIMBUS_SLAVE_CFG 0x00010235 #define AFE_PARAM_ID_SLIMBUS_CONFIG 0x00010212 +#define AFE_PARAM_ID_I2S_CONFIG 0x0001020D + +/* I2S config specific */ +#define AFE_API_VERSION_I2S_CONFIG 0x1 +#define AFE_PORT_I2S_SD0 0x1 +#define AFE_PORT_I2S_SD1 0x2 +#define AFE_PORT_I2S_SD2 0x3 +#define AFE_PORT_I2S_SD3 0x4 +#define AFE_PORT_I2S_QUAD01 0x5 +#define AFE_PORT_I2S_QUAD23 0x6 +#define AFE_PORT_I2S_6CHS 0x7 +#define AFE_PORT_I2S_8CHS 0x8 +#define AFE_PORT_I2S_MONO 0x0 +#define AFE_PORT_I2S_STEREO 0x1 +#define AFE_PORT_CONFIG_I2S_WS_SRC_EXTERNAL 0x0 +#define AFE_PORT_CONFIG_I2S_WS_SRC_INTERNAL 0x1 +#define AFE_LINEAR_PCM_DATA 0x0 + /* Port IDs */ #define AFE_API_VERSION_HDMI_CONFIG 0x1 @@ -63,6 +85,14 @@ #define AFE_PORT_ID_SLIMBUS_MULTI_CHAN_6_RX 0x400c /* SLIMbus Tx port on channel 6. */ #define AFE_PORT_ID_SLIMBUS_MULTI_CHAN_6_TX 0x400d +#define AFE_PORT_ID_PRIMARY_MI2S_RX 0x1000 +#define AFE_PORT_ID_PRIMARY_MI2S_TX 0x1001 +#define AFE_PORT_ID_SECONDARY_MI2S_RX 0x1002 +#define AFE_PORT_ID_SECONDARY_MI2S_TX 0x1003 +#define AFE_PORT_ID_TERTIARY_MI2S_RX 0x1004 +#define AFE_PORT_ID_TERTIARY_MI2S_TX 0x1005 +#define AFE_PORT_ID_QUATERNARY_MI2S_RX 0x1006 +#define AFE_PORT_ID_QUATERNARY_MI2S_TX 0x1007 #define TIMEOUT_MS 1000 #define AFE_CMD_RESP_AVAIL 0 @@ -161,10 +191,21 @@ struct afe_param_id_slimbus_cfg { */ } __packed; +struct afe_param_id_i2s_cfg { + u32 i2s_cfg_minor_version; + u16 bit_width; + u16 channel_mode; + u16 mono_stereo; + u16 ws_src; + u32 sample_rate; + u16 data_format; + u16 reserved; +} __packed; union afe_port_config { struct afe_param_id_hdmi_multi_chan_audio_cfg hdmi_multi_ch; struct afe_param_id_slimbus_cfg slim_cfg; + struct afe_param_id_i2s_cfg i2s_cfg; } __packed; struct q6afe_port { @@ -207,6 +248,14 @@ static struct afe_port_map port_maps[AFE_PORT_MAX] = { SLIMBUS_4_RX, 1, 1}, [SLIMBUS_5_RX] = { AFE_PORT_ID_SLIMBUS_MULTI_CHAN_5_RX, SLIMBUS_5_RX, 1, 1}, + [QUATERNARY_MI2S_RX] = { AFE_PORT_ID_QUATERNARY_MI2S_RX, + QUATERNARY_MI2S_RX, 1, 1}, + [SECONDARY_MI2S_RX] = { AFE_PORT_ID_SECONDARY_MI2S_RX, + SECONDARY_MI2S_RX, 1, 1}, + [TERTIARY_MI2S_RX] = { AFE_PORT_ID_TERTIARY_MI2S_RX, + TERTIARY_MI2S_RX, 1, 1}, + [PRIMARY_MI2S_RX] = { AFE_PORT_ID_PRIMARY_MI2S_RX, + PRIMARY_MI2S_RX, 1, 1}, [SLIMBUS_6_RX] = { AFE_PORT_ID_SLIMBUS_MULTI_CHAN_6_RX, SLIMBUS_6_RX, 1, 1}, }; @@ -513,6 +562,61 @@ void q6afe_hdmi_port_prepare(struct q6afe_port *port, } EXPORT_SYMBOL_GPL(q6afe_hdmi_port_prepare); +/** + * q6afe_i2s_port_prepare() - Prepare i2s afe port. + * + * @port: Instance of afe port + * @cfg: I2S configuration for the afe port + * + */ +void q6afe_i2s_port_prepare(struct q6afe_port *port, struct q6afe_i2s_cfg *cfg) +{ + union afe_port_config *pcfg = &port->port_cfg; + + pcfg->i2s_cfg.i2s_cfg_minor_version = AFE_API_VERSION_I2S_CONFIG; + pcfg->i2s_cfg.sample_rate = cfg->sample_rate; + pcfg->i2s_cfg.bit_width = cfg->bit_width; + pcfg->i2s_cfg.data_format = AFE_LINEAR_PCM_DATA; + + switch (cfg->fmt & SND_SOC_DAIFMT_MASTER_MASK) { + case SND_SOC_DAIFMT_CBS_CFS: + pcfg->i2s_cfg.ws_src = AFE_PORT_CONFIG_I2S_WS_SRC_INTERNAL; + break; + case SND_SOC_DAIFMT_CBM_CFM: + /* CPU is slave */ + pcfg->i2s_cfg.ws_src = AFE_PORT_CONFIG_I2S_WS_SRC_EXTERNAL; + break; + default: + break; + } + + switch (cfg->num_channels) { + case 1: + pcfg->i2s_cfg.mono_stereo = AFE_PORT_I2S_MONO; + pcfg->i2s_cfg.channel_mode = AFE_PORT_I2S_SD0; + break; + case 2: + pcfg->i2s_cfg.channel_mode = AFE_PORT_I2S_SD0; + pcfg->i2s_cfg.mono_stereo = AFE_PORT_I2S_STEREO; + break; + case 3: + case 4: + pcfg->i2s_cfg.channel_mode = AFE_PORT_I2S_QUAD01; + break; + case 5: + case 6: + pcfg->i2s_cfg.channel_mode = AFE_PORT_I2S_6CHS; + break; + case 7: + case 8: + pcfg->i2s_cfg.channel_mode = AFE_PORT_I2S_8CHS; + break; + default: + break; + } +} +EXPORT_SYMBOL_GPL(q6afe_i2s_port_prepare); + /** * q6afe_port_start() - Start a afe port * @@ -562,6 +666,13 @@ struct q6afe_port *q6afe_port_get_from_id(struct device *dev, int id) case AFE_PORT_ID_SLIMBUS_MULTI_CHAN_6_RX: cfg_type = AFE_PARAM_ID_SLIMBUS_CONFIG; break; + + case AFE_PORT_ID_PRIMARY_MI2S_RX: + case AFE_PORT_ID_SECONDARY_MI2S_RX: + case AFE_PORT_ID_TERTIARY_MI2S_RX: + case AFE_PORT_ID_QUATERNARY_MI2S_RX: + cfg_type = AFE_PARAM_ID_I2S_CONFIG; + break; default: dev_err(dev, "Invalid port id 0x%x\n", port_id); return ERR_PTR(-EINVAL); diff --git a/sound/soc/qcom/qdsp6/q6afe.h b/sound/soc/qcom/qdsp6/q6afe.h index aeacf1f2c9a9..9114d68a79cb 100644 --- a/sound/soc/qcom/qdsp6/q6afe.h +++ b/sound/soc/qcom/qdsp6/q6afe.h @@ -29,9 +29,18 @@ struct q6afe_slim_cfg { u8 ch_mapping[AFE_MAX_CHAN_COUNT]; }; +struct q6afe_i2s_cfg { + u32 sample_rate; + u16 bit_width; + u16 data_format; + u16 num_channels; + int fmt; +}; + struct q6afe_port_config { struct q6afe_hdmi_cfg hdmi; struct q6afe_slim_cfg slim; + struct q6afe_i2s_cfg i2s_cfg; }; struct q6afe_port; @@ -50,5 +59,6 @@ void q6afe_hdmi_port_prepare(struct q6afe_port *port, struct q6afe_hdmi_cfg *cfg); void q6afe_slim_port_prepare(struct q6afe_port *port, struct q6afe_slim_cfg *cfg); +void q6afe_i2s_port_prepare(struct q6afe_port *port, struct q6afe_i2s_cfg *cfg); #endif /* __Q6AFE_H__ */