From patchwork Thu Dec 14 17:33:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 121997 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp7105544qgn; Thu, 14 Dec 2017 09:36:45 -0800 (PST) X-Google-Smtp-Source: ACJfBovhwoS7mQhwaOupazwcKsbAZOcuL+Qo1jUZTFa9AEXy7UQ4V5OEzkafb8ep2oinLD3OMnFK X-Received: by 10.99.109.202 with SMTP id i193mr9175603pgc.443.1513273005034; Thu, 14 Dec 2017 09:36:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513273005; cv=none; d=google.com; s=arc-20160816; b=TZqZ4Z88BNLf9mqXM4JVHEMnLt/6Dct9qi23zF23FPsCpdEcPZBzy1zsWESv1uT74A dY+8FLVegfXda2IlkG0CNVE1rSGgO46CxQhruuS21813rbnA+Qv2TrRJPLXi6R/lbDjJ TZqZ/PrE6NzcUJO6XO3wkw8Mv50PnSHIt1HtM448m2ka9oCEypEM98tsfSfMZV3aOkv9 +Pq34leYM/rBoHaa4Eq/6vjF6RtK12o8OeAOU0nLHh805vvIekhQ+ex4hlIXoSw9/Bpu QJRiEuHfxUVM2TJkguR6ZffIu8PH9FtjZ0pqhWPMuxY+n+8KtDFAIfPREce0cJEXam7P ctHg== 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=U2ihcoQlgRtVtyvdZGuHZEZ5Q+Uj3odRiRVXrjbQ81w=; b=sYlCxEH1RTSkVfEv8wSeq7xPopwzE059LBO8jMCYOqmnvKB6kEFCDj22dqip+fO8HR 6y3UBlS4Rkz5NC0D6zTJ8s/0W0X7wTp6v5eKj1KgEheodi/XeR5lFT/6G3eN3jS5Uxjp 7c6dAV0bGkIVV7wZBh1xAD52CaU3E7konE/3jBCdq/7SlE3nYdjUYvu/zu5GGoNyW68F NQ6xBVnvh5T2KG37udQFFZ+PUZUJaBMFKS40LTwWy8+0Z8HWMZ3Jcsx23jfsQZxWzcMn O250pgcBwhqEX4eaJfbhbsEb5NT+XKcUeT0E2ePOV2oyDwW3apZX/a1kg3vs+/fBlams Do9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Ij78uFnX; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-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 a16si3181496pgn.797.2017.12.14.09.36.44; Thu, 14 Dec 2017 09:36:45 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of devicetree-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=Ij78uFnX; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-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 S1753865AbdLNRgm (ORCPT + 6 others); Thu, 14 Dec 2017 12:36:42 -0500 Received: from mail-wr0-f193.google.com ([209.85.128.193]:43351 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753830AbdLNRgk (ORCPT ); Thu, 14 Dec 2017 12:36:40 -0500 Received: by mail-wr0-f193.google.com with SMTP id z34so5817571wrz.10 for ; Thu, 14 Dec 2017 09:36:39 -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=5XW8G3AfUSX1oIB43MTJ4nDLnbzlV2SUCs0XIXzlsDY=; b=Ij78uFnXgbhsVRRhTguxfWyXkru7D74ZeeshkyjZsspkyKMxnhMGBi7w3KrbkR1C7C qUa0VagNQq5HfROpcW891ECO14BJ4ttVt4y2XXbD2WZTIwoUaygaoXj7Fn5xN2uyHZE0 BzZ4RJ0MIXLNItJ3uAzhZ46XjRlYLEHNAPqgs= 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=5XW8G3AfUSX1oIB43MTJ4nDLnbzlV2SUCs0XIXzlsDY=; b=p5mo0U/AwfYrNzt0nWFCJ4ZTEV8pMiMayzW2d1zKrDG4BP7ryPKY1Jy3WWjhmW56/1 GA8ZBiwlX/aa2MZr0W0wrZ/QoxlWwF1dzegDz5nxwvwihogwu4RZM0CN+SY9SNHt7B6S AAM5OjT9DXKpEhhi2stwUx1zr5Qzs/11hFvWKUqV9p32uWmTKmUC0CZINK+e4XBw+wYt u90Wk7NFfj9Iv5VbC8BLZl/AkkURN0mbYdZ2dpbh5httNxN7rN11zfdQq/3pV65jIxEo werbHV7166RQKCqc32WTct3i06d6G7pHN2BWRsZH0WT0PBCEokIMAQQQWgJA/PKekbdL WzUQ== X-Gm-Message-State: AKGB3mJVduNrYauroZM2FjUYlCiiCiPX2rj1B4DwHrIM7jG6NDlsXKop H9eM3/XTveJJGEmcTKVTx9s5qg== X-Received: by 10.223.133.250 with SMTP id 55mr7107258wru.23.1513272998349; Thu, 14 Dec 2017 09:36:38 -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 r82sm1741757wme.31.2017.12.14.09.36.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 14 Dec 2017 09:36:37 -0800 (PST) From: srinivas.kandagatla@linaro.org To: Andy Gross , Mark Brown , linux-arm-msm@vger.kernel.org, alsa-devel@alsa-project.org Cc: David Brown , Rob Herring , Mark Rutland , Liam Girdwood , Patrick Lai , Banajit Goswami , Jaroslav Kysela , Takashi Iwai , linux-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, sboyd@codeaurora.org, Srinivas Kandagatla Subject: [RESEND PATCH v2 07/15] ASoC: qcom: q6asm: Add support to memory map and unmap Date: Thu, 14 Dec 2017 17:33:54 +0000 Message-Id: <20171214173402.19074-8-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171214173402.19074-1-srinivas.kandagatla@linaro.org> References: <20171214173402.19074-1-srinivas.kandagatla@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Srinivas Kandagatla This patch adds support to memory map and unmap regions commands in q6asm module. Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/qdsp6/q6asm.c | 343 ++++++++++++++++++++++++++++++++++++++++++- sound/soc/qcom/qdsp6/q6asm.h | 5 + 2 files changed, 347 insertions(+), 1 deletion(-) -- 2.15.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/sound/soc/qcom/qdsp6/q6asm.c b/sound/soc/qcom/qdsp6/q6asm.c index 9cc583afef4d..4be92441f524 100644 --- a/sound/soc/qcom/qdsp6/q6asm.c +++ b/sound/soc/qcom/qdsp6/q6asm.c @@ -14,9 +14,46 @@ #include "q6asm.h" #include "common.h" +#define ASM_CMD_SHARED_MEM_MAP_REGIONS 0x00010D92 +#define ASM_CMDRSP_SHARED_MEM_MAP_REGIONS 0x00010D93 +#define ASM_CMD_SHARED_MEM_UNMAP_REGIONS 0x00010D94 + #define TUN_READ_IO_MODE 0x0004 /* tunnel read write mode */ #define SYNC_IO_MODE 0x0001 #define ASYNC_IO_MODE 0x0002 +#define ASM_SHIFT_GAPLESS_MODE_FLAG 31 +#define ADSP_MEMORY_MAP_SHMEM8_4K_POOL 3 + +struct avs_cmd_shared_mem_map_regions { + struct apr_hdr hdr; + u16 mem_pool_id; + u16 num_regions; + u32 property_flag; +} __packed; + +struct avs_shared_map_region_payload { + u32 shm_addr_lsw; + u32 shm_addr_msw; + u32 mem_size_bytes; +} __packed; + +struct avs_cmd_shared_mem_unmap_regions { + struct apr_hdr hdr; + u32 mem_map_handle; +} __packed; + +struct audio_buffer { + dma_addr_t phys; + uint32_t used; + uint32_t size; /* size of buffer */ +}; + +struct audio_port_data { + struct audio_buffer *buf; + uint32_t max_buf_cnt; + uint32_t dsp_buf; + uint32_t mem_map_handle; +}; struct audio_client { int session; @@ -27,6 +64,8 @@ struct audio_client { uint64_t time_stamp; struct apr_device *adev; struct mutex cmd_lock; + /* idx:1 out port, 0: in port */ + struct audio_port_data port[2]; wait_queue_head_t cmd_wait; int perf_mode; int stream_id; @@ -86,6 +125,260 @@ static void q6asm_session_free(struct audio_client *ac) mutex_unlock(&a->session_lock); } +static inline void q6asm_add_mmaphdr(struct audio_client *ac, + struct apr_hdr *hdr, u32 pkt_size, + bool cmd_flg, u32 token) +{ + hdr->hdr_field = APR_SEQ_CMD_HDR_FIELD; + hdr->src_port = 0; + hdr->dest_port = 0; + hdr->pkt_size = pkt_size; + if (cmd_flg) + hdr->token = token; +} + +static inline void q6asm_add_hdr(struct audio_client *ac, struct apr_hdr *hdr, + uint32_t pkt_size, bool cmd_flg, + uint32_t stream_id) +{ + hdr->hdr_field = APR_SEQ_CMD_HDR_FIELD; + hdr->src_svc = ac->adev->svc_id; + hdr->src_domain = APR_DOMAIN_APPS; + hdr->dest_svc = APR_SVC_ASM; + hdr->dest_domain = APR_DOMAIN_ADSP; + hdr->src_port = ((ac->session << 8) & 0xFF00) | (stream_id); + hdr->dest_port = ((ac->session << 8) & 0xFF00) | (stream_id); + hdr->pkt_size = pkt_size; + if (cmd_flg) + hdr->token = ac->session; +} + +static int __q6asm_memory_unmap(struct audio_client *ac, + phys_addr_t buf_add, int dir) +{ + struct avs_cmd_shared_mem_unmap_regions mem_unmap; + struct q6asm *a = dev_get_drvdata(ac->dev->parent); + int rc; + + if (!a) + return -ENODEV; + + q6asm_add_mmaphdr(ac, &mem_unmap.hdr, sizeof(mem_unmap), true, + ((ac->session << 8) | dir)); + a->mem_state = -1; + + mem_unmap.hdr.opcode = ASM_CMD_SHARED_MEM_UNMAP_REGIONS; + mem_unmap.mem_map_handle = ac->port[dir].mem_map_handle; + + if (mem_unmap.mem_map_handle == 0) { + dev_err(ac->dev, "invalid mem handle\n"); + return -EINVAL; + } + + rc = apr_send_pkt(a->adev, (uint32_t *) &mem_unmap); + if (rc < 0) + return rc; + + rc = wait_event_timeout(a->mem_wait, (a->mem_state >= 0), + 5 * HZ); + if (!rc) { + dev_err(ac->dev, "CMD timeout for memory_unmap 0x%x\n", + mem_unmap.mem_map_handle); + return -ETIMEDOUT; + } else if (a->mem_state > 0) { + return adsp_err_get_lnx_err_code(a->mem_state); + } + ac->port[dir].mem_map_handle = 0; + + return 0; +} + +/** + * q6asm_unmap_memory_regions() - unmap memory regions in the dsp. + * + * @dir: direction of audio stream + * @ac: audio client instanace + * + * Return: Will be an negative value on failure or zero on success + */ +int q6asm_unmap_memory_regions(unsigned int dir, struct audio_client *ac) +{ + struct audio_port_data *port; + int cnt = 0; + int rc = 0; + + mutex_lock(&ac->cmd_lock); + port = &ac->port[dir]; + if (!port->buf) { + mutex_unlock(&ac->cmd_lock); + return 0; + } + cnt = port->max_buf_cnt - 1; + if (cnt >= 0) { + rc = __q6asm_memory_unmap(ac, port->buf[dir].phys, dir); + if (rc < 0) { + dev_err(ac->dev, "%s: Memory_unmap_regions failed %d\n", + __func__, rc); + mutex_unlock(&ac->cmd_lock); + return rc; + } + } + + port->max_buf_cnt = 0; + kfree(port->buf); + port->buf = NULL; + mutex_unlock(&ac->cmd_lock); + + return 0; +} +EXPORT_SYMBOL_GPL(q6asm_unmap_memory_regions); + +static int __q6asm_memory_map_regions(struct audio_client *ac, int dir, + uint32_t period_sz, uint32_t periods, + bool is_contiguous) +{ + struct avs_cmd_shared_mem_map_regions *mmap_regions = NULL; + struct avs_shared_map_region_payload *mregions = NULL; + struct q6asm *a = dev_get_drvdata(ac->dev->parent); + struct audio_port_data *port = NULL; + struct audio_buffer *ab = NULL; + void *mmap_region_cmd = NULL; + void *payload = NULL; + int rc = 0; + int i = 0; + int cmd_size = 0; + uint32_t num_regions; + uint32_t buf_sz; + + if (!a) + return -ENODEV; + num_regions = is_contiguous ? 1 : periods; + buf_sz = is_contiguous ? (period_sz * periods) : period_sz; + buf_sz = PAGE_ALIGN(buf_sz); + + cmd_size = sizeof(*mmap_regions) + (sizeof(*mregions) * num_regions); + + mmap_region_cmd = kzalloc(cmd_size, GFP_KERNEL); + if (!mmap_region_cmd) + return -ENOMEM; + + mmap_regions = (struct avs_cmd_shared_mem_map_regions *)mmap_region_cmd; + q6asm_add_mmaphdr(ac, &mmap_regions->hdr, cmd_size, true, + ((ac->session << 8) | dir)); + a->mem_state = -1; + + mmap_regions->hdr.opcode = ASM_CMD_SHARED_MEM_MAP_REGIONS; + mmap_regions->mem_pool_id = ADSP_MEMORY_MAP_SHMEM8_4K_POOL; + mmap_regions->num_regions = num_regions; + mmap_regions->property_flag = 0x00; + + payload = ((u8 *) mmap_region_cmd + + sizeof(struct avs_cmd_shared_mem_map_regions)); + + mregions = (struct avs_shared_map_region_payload *)payload; + + ac->port[dir].mem_map_handle = 0; + port = &ac->port[dir]; + + for (i = 0; i < num_regions; i++) { + ab = &port->buf[i]; + mregions->shm_addr_lsw = lower_32_bits(ab->phys); + mregions->shm_addr_msw = upper_32_bits(ab->phys); + mregions->mem_size_bytes = buf_sz; + ++mregions; + } + + rc = apr_send_pkt(a->adev, (uint32_t *) mmap_region_cmd); + if (rc < 0) + goto fail_cmd; + + rc = wait_event_timeout(a->mem_wait, (a->mem_state >= 0), + 5 * HZ); + if (!rc) { + dev_err(ac->dev, "timeout. waited for memory_map\n"); + rc = -ETIMEDOUT; + goto fail_cmd; + } + + if (a->mem_state > 0) { + rc = adsp_err_get_lnx_err_code(a->mem_state); + goto fail_cmd; + } + rc = 0; +fail_cmd: + kfree(mmap_region_cmd); + return rc; +} + +/** + * q6asm_map_memory_regions() - map memory regions in the dsp. + * + * @dir: direction of audio stream + * @ac: audio client instanace + * @phys: physcial address that needs mapping. + * @period_sz: audio period size + * @periods: number of periods + * + * Return: Will be an negative value on failure or zero on success + */ +int q6asm_map_memory_regions(unsigned int dir, struct audio_client *ac, + dma_addr_t phys, + unsigned int period_sz, unsigned int periods) +{ + struct audio_buffer *buf; + int cnt; + int rc; + + if (ac->port[dir].buf) { + dev_err(ac->dev, "Buffer already allocated\n"); + return 0; + } + + mutex_lock(&ac->cmd_lock); + + buf = kzalloc(((sizeof(struct audio_buffer)) * periods), GFP_KERNEL); + if (!buf) { + mutex_unlock(&ac->cmd_lock); + return -ENOMEM; + } + + + ac->port[dir].buf = buf; + + buf[0].phys = phys; + buf[0].used = dir ^ 1; + buf[0].size = period_sz; + cnt = 1; + while (cnt < periods) { + if (period_sz > 0) { + buf[cnt].phys = buf[0].phys + (cnt * period_sz); + buf[cnt].used = dir ^ 1; + buf[cnt].size = period_sz; + } + cnt++; + } + + ac->port[dir].max_buf_cnt = periods; + mutex_unlock(&ac->cmd_lock); + + rc = __q6asm_memory_map_regions(ac, dir, period_sz, periods, 1); + if (rc < 0) { + dev_err(ac->dev, + "CMD Memory_map_regions failed %d for size %d\n", rc, + period_sz); + + + ac->port[dir].max_buf_cnt = 0; + kfree(buf); + ac->port[dir].buf = NULL; + + return rc; + } + + return 0; +} +EXPORT_SYMBOL_GPL(q6asm_map_memory_regions); + /** * q6asm_audio_client_free() - Freee allocated audio client * @@ -117,8 +410,10 @@ static struct audio_client *q6asm_get_audio_client(struct q6asm *a, static int q6asm_srvc_callback(struct apr_device *adev, struct apr_client_data *data) { - struct q6asm *q6asm = dev_get_drvdata(&adev->dev); + 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; uint32_t *payload; @@ -135,6 +430,52 @@ static int q6asm_srvc_callback(struct apr_device *adev, struct apr_client_data * return 0; } + a = dev_get_drvdata(ac->dev->parent); + if (data->opcode == APR_BASIC_RSP_RESULT) { + switch (payload[0]) { + case ASM_CMD_SHARED_MEM_MAP_REGIONS: + case ASM_CMD_SHARED_MEM_UNMAP_REGIONS: + if (payload[1] != 0) { + dev_err(ac->dev, + "cmd = 0x%x returned error = 0x%x sid:%d\n", + payload[0], payload[1], sid); + a->mem_state = payload[1]; + } else { + a->mem_state = 0; + } + + wake_up(&a->mem_wait); + break; + default: + dev_err(&adev->dev, "command[0x%x] not expecting rsp\n", + payload[0]); + break; + } + return 0; + } + + dir = (data->token & 0x0F); + port = &ac->port[dir]; + + switch (data->opcode) { + case ASM_CMDRSP_SHARED_MEM_MAP_REGIONS:{ + a->mem_state = 0; + ac->port[dir].mem_map_handle = payload[0]; + wake_up(&a->mem_wait); + break; + } + case ASM_CMD_SHARED_MEM_UNMAP_REGIONS:{ + a->mem_state = 0; + ac->port[dir].mem_map_handle = 0; + wake_up(&a->mem_wait); + + break; + } + default: + dev_dbg(&adev->dev, "command[0x%x]success [0x%x]\n", + payload[0], payload[1]); + break; + } if (ac->cb) ac->cb(data->opcode, data->token, data->payload, ac->priv); return 0; diff --git a/sound/soc/qcom/qdsp6/q6asm.h b/sound/soc/qcom/qdsp6/q6asm.h index 7a8a9039fd89..e1409c368600 100644 --- a/sound/soc/qcom/qdsp6/q6asm.h +++ b/sound/soc/qcom/qdsp6/q6asm.h @@ -11,4 +11,9 @@ struct audio_client *q6asm_audio_client_alloc(struct device *dev, app_cb cb, void *priv); void q6asm_audio_client_free(struct audio_client *ac); int q6asm_get_session_id(struct audio_client *ac); +int q6asm_map_memory_regions(unsigned int dir, + struct audio_client *ac, + dma_addr_t phys, + unsigned int bufsz, unsigned int bufcnt); +int q6asm_unmap_memory_regions(unsigned int dir, struct audio_client *ac); #endif /* __Q6_ASM_H__ */ From patchwork Thu Dec 14 17:34:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 121999 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp7105764qgn; Thu, 14 Dec 2017 09:36:58 -0800 (PST) X-Google-Smtp-Source: ACJfBov0vex1W9M9KLwTm4wNVQe6zO7GXNdSTv92aue+IlNnhFpvMcO21mfu+ix8n+IZilHS4/Wv X-Received: by 10.84.231.194 with SMTP id g2mr10157479pln.182.1513273017911; Thu, 14 Dec 2017 09:36:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513273017; cv=none; d=google.com; s=arc-20160816; b=Cj5TdNrxQq/QhgE5cXHd9Y4bz02rasJYeIZe2fe0PObg0cKudSFBEa+456AAR6Zd9V /LN2r+l4jOSjB1zr/oKwgMP3AOJLw2JL4ieR/mvGcWGY5mQjn/E5/MgbfeSLOYbJE5/4 M/OXi7stZJTImQBBAHJ3YvUpIaFlNr8wbiBEmLWES+Gy6qo1zW69t8L5KpNy7qFuN/fd +i+vF2QTBHxBr5jt++MeJ/UKCSiqPdmrFOSJnGJVnpu2YzI3YKtEBOxeg4sZmCKeqC4u j2vmpyOxcJe7G3yjHBVQydfQymdlV3V9uW2cfn221MK8i8iaUj/B/ofz8+gzyfL3wK6l JMLQ== 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=DEAHeCRLPL4Ci8J+ax/7zObpCQEYRK4YNjnmb59elyk=; b=gkCW5tQFARVx9aRGUPu7nMZNHTvkIhXsXbeESqrbuxIQVxrAAa9VCVnd4EiNNExVbF 8zhCLlPxKkFoAptdIkE2RQrlztDd2hVcBLdFcjWOO2jETwEsGhHZZdNifNU0VFM58K21 mR6ucD0x1yeHTcdE/DCLvdYSXgOiAu3ed9KpRgTJBzNY7leErdxQbG13cxVFZSyZ6ieG 5zoAjJdUWVkIgPPKAcTA/j1PfQDwiO6I0c8Fz/3ctpkWv0VSSQqrY2Fi/qAPHEKFbm0i KgfgG5txQ4iMnt9DaPIKzej8y34sc/pFQn5FK6otQHXK8/hijtaDvExbrzRkjbl/qinB uWHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=EHWjGLWx; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-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 i9si3176403pgs.523.2017.12.14.09.36.57; Thu, 14 Dec 2017 09:36:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of devicetree-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=EHWjGLWx; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-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 S1753924AbdLNRgz (ORCPT + 6 others); Thu, 14 Dec 2017 12:36:55 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:42961 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753910AbdLNRgw (ORCPT ); Thu, 14 Dec 2017 12:36:52 -0500 Received: by mail-wm0-f66.google.com with SMTP id b199so12959480wme.1 for ; Thu, 14 Dec 2017 09:36:51 -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=5P11H62b4xPELhart8WGy+syC64k2uY5O2WNEbio21c=; b=EHWjGLWxC5uWzk41AmS2WsltXjFy/9CxGKGBCSO0Z4Aa95f7DuyyGK7yBBBR1EXWYD fJSxUPUz7oigNz0oJsydiUM7QEhNtmQLVERG8avpt8LLVOFkR+BgVbq5A2j9KFwbaCTQ gLQhoyex15mIM/+zQ73zdU10Mm4fQu7X6ktpA= 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=5P11H62b4xPELhart8WGy+syC64k2uY5O2WNEbio21c=; b=W7RplGqLG2pYkw/njaBZpHfCYNqluLMg9V8EvDZn6EGNepwLlrlYpkZnzLvaYZGFWQ qyefBU/Dnn2odAwLHldN5m9G8w5vikgOluWTt36F2ZhE7pIuy54NyUyoYl76Wsv1Dnxf MaVH8Z2J32lvJqYbPTmVuoNVR+06bdQ9XQZLJWvpGEflsGypy48h5r8IkjeI6PGGf+hV nNvVTr/88pyd5UpJp2FR08eKhcvrSeeQV6DTE/SbZdLS3qHncVIPkAY0PnpmNH912b9E GVCMRo8tDzJjm2XIx47RNKS7boKoZAsC3ksdYO2n/j6CPzv3ywV6yFNv/EIx8wjt4heE Zm4Q== X-Gm-Message-State: AKGB3mJIeCl7qQevbaH7X1/Xw4w9tcvBHnfNHxPjgvygbWspFz+Onpi8 nISpS2hS7LKP8jGlxDNAJ6hotg== X-Received: by 10.28.19.199 with SMTP id 190mr2661709wmt.87.1513273010774; Thu, 14 Dec 2017 09:36:50 -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 r82sm1741757wme.31.2017.12.14.09.36.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 14 Dec 2017 09:36:50 -0800 (PST) From: srinivas.kandagatla@linaro.org To: Andy Gross , Mark Brown , linux-arm-msm@vger.kernel.org, alsa-devel@alsa-project.org Cc: David Brown , Rob Herring , Mark Rutland , Liam Girdwood , Patrick Lai , Banajit Goswami , Jaroslav Kysela , Takashi Iwai , linux-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, sboyd@codeaurora.org, Srinivas Kandagatla Subject: [RESEND PATCH v2 14/15] ASoC: qcom: apq8096: Add db820c machine driver Date: Thu, 14 Dec 2017 17:34:01 +0000 Message-Id: <20171214173402.19074-15-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171214173402.19074-1-srinivas.kandagatla@linaro.org> References: <20171214173402.19074-1-srinivas.kandagatla@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Srinivas Kandagatla uThis patch adds support to DB820c machine driver. Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/Kconfig | 9 +++- sound/soc/qcom/apq8096.c | 124 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 132 insertions(+), 1 deletion(-) create mode 100644 sound/soc/qcom/apq8096.c -- 2.15.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/sound/soc/qcom/Kconfig b/sound/soc/qcom/Kconfig index ecd1e4ba834d..748ccc3edefa 100644 --- a/sound/soc/qcom/Kconfig +++ b/sound/soc/qcom/Kconfig @@ -72,7 +72,6 @@ config SND_SOC_QDSP6_ASM_DAI tristate default n - config SND_SOC_QDSP6 tristate "SoC ALSA audio driver for QDSP6" select SND_SOC_QDSP6_AFE @@ -87,3 +86,11 @@ config SND_SOC_QDSP6 This will enable sound soc platform specific audio drivers. This includes q6asm, q6adm, q6afe interfaces to DSP using apr. + +config SND_SOC_MSM8996 + tristate "SoC Machine driver for MSM8996 and APQ8096 boards" + select SND_SOC_QDSP6V2 + default n + help + To add support for SoC audio on MSM8996 and APQ8096 boards + diff --git a/sound/soc/qcom/apq8096.c b/sound/soc/qcom/apq8096.c new file mode 100644 index 000000000000..5b2036317f71 --- /dev/null +++ b/sound/soc/qcom/apq8096.c @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2017 The Linux Foundation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 and + * only version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ +#include +#include +#include +#include +#include +#include +#include +#include + +int msm8996_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, + struct snd_pcm_hw_params *params) +{ + struct snd_interval *rate = hw_param_interval(params, + SNDRV_PCM_HW_PARAM_RATE); + struct snd_interval *channels = hw_param_interval(params, + SNDRV_PCM_HW_PARAM_CHANNELS); + + rate->min = rate->max = 48000; + channels->min = channels->max = 2; + + return 0; +} +static struct snd_soc_dai_link msm8996_dai_links[] = { + /* FrontEnd DAI Links */ + { + .name = "MultiMedia1 Playback", + .stream_name = "MultiMedia1", + .cpu_dai_name = "MM_DL1", + .platform_name = "q6asm_dai", + .dynamic = 1, + .dpcm_playback = 1, + + .codec_dai_name = "snd-soc-dummy-dai", + .codec_name = "snd-soc-dummy", + }, + /* Backend DAI Links */ + { + .name = "HDMI Playback", + .stream_name = "q6afe_dai", + .cpu_dai_name = "HDMI", + .platform_name = "q6routing", + .no_pcm = 1, + .dpcm_playback = 1, + .be_hw_params_fixup = msm8996_be_hw_params_fixup, + .codec_dai_name = "i2s-hifi", + .codec_name = "hdmi-audio-codec.0.auto", + }, +}; + +static int apq8096_sbc_parse_of(struct snd_soc_card *card) +{ + struct device *dev = card->dev; + int ret; + + ret = snd_soc_of_parse_card_name(card, "qcom,model"); + if (ret) + dev_err(dev, "Error parsing card name: %d\n", ret); + + return ret; +} + +static int msm_snd_apq8096_probe(struct platform_device *pdev) +{ + int ret; + struct snd_soc_card *card; + + card = devm_kzalloc(&pdev->dev, sizeof(*card), GFP_KERNEL); + if (!card) + return -ENOMEM; + + card->dev = &pdev->dev; + + ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32)); + if (ret) + return ret; + + card->dai_link = msm8996_dai_links; + card->num_links = ARRAY_SIZE(msm8996_dai_links); + + ret = apq8096_sbc_parse_of(card); + if (ret) { + dev_err(&pdev->dev, "Error parsing OF data\n"); + return ret; + } + + ret = devm_snd_soc_register_card(&pdev->dev, card); + if (ret) + dev_err(&pdev->dev, "sound card register failed (%d)!\n", ret); + else + dev_err(&pdev->dev, "sound card register Sucessfull\n"); + + return ret; +} + +static const struct of_device_id msm_snd_apq8096_dt_match[] = { + {.compatible = "qcom,apq8096-sndcard"}, + {} +}; + +static struct platform_driver msm_snd_apq8096_driver = { + .probe = msm_snd_apq8096_probe, + .driver = { + .name = "msm-snd-apq8096", + .owner = THIS_MODULE, + .of_match_table = msm_snd_apq8096_dt_match, + }, +}; +module_platform_driver(msm_snd_apq8096_driver); +MODULE_AUTHOR("Srinivas Kandagatla