Commit d37bdab3 authored by Linaro CI's avatar Linaro CI

Merge remote-tracking branch 'audio/tracking-qcomlt-audio' into integration-linux-qcomlt

parents cd2d678e fe8abbe3
...@@ -98,11 +98,6 @@ static int slim_device_remove(struct device *dev) ...@@ -98,11 +98,6 @@ static int slim_device_remove(struct device *dev)
static int slim_device_uevent(struct device *dev, struct kobj_uevent_env *env) static int slim_device_uevent(struct device *dev, struct kobj_uevent_env *env)
{ {
struct slim_device *sbdev = to_slim_device(dev); struct slim_device *sbdev = to_slim_device(dev);
int ret;
ret = of_device_uevent_modalias(dev, env);
if (ret != -ENODEV)
return ret;
return add_uevent_var(env, "MODALIAS=slim:%s", dev_name(&sbdev->dev)); return add_uevent_var(env, "MODALIAS=slim:%s", dev_name(&sbdev->dev));
} }
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/idr.h> #include <linux/idr.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/workqueue.h>
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/soc/qcom/apr.h> #include <linux/soc/qcom/apr.h>
#include <linux/rpmsg.h> #include <linux/rpmsg.h>
...@@ -17,8 +18,18 @@ struct apr { ...@@ -17,8 +18,18 @@ struct apr {
struct rpmsg_endpoint *ch; struct rpmsg_endpoint *ch;
struct device *dev; struct device *dev;
spinlock_t svcs_lock; spinlock_t svcs_lock;
spinlock_t rx_lock;
struct idr svcs_idr; struct idr svcs_idr;
int dest_domain_id; int dest_domain_id;
struct workqueue_struct *rxwq;
struct work_struct rx_work;
struct list_head rx_list;
};
struct apr_rx_buf {
struct list_head node;
int len;
uint8_t buf[];
}; };
/** /**
...@@ -62,6 +73,36 @@ static int apr_callback(struct rpmsg_device *rpdev, void *buf, ...@@ -62,6 +73,36 @@ static int apr_callback(struct rpmsg_device *rpdev, void *buf,
int len, void *priv, u32 addr) int len, void *priv, u32 addr)
{ {
struct apr *apr = dev_get_drvdata(&rpdev->dev); struct apr *apr = dev_get_drvdata(&rpdev->dev);
struct apr_rx_buf *abuf;
unsigned long flags;
if (len <= APR_HDR_SIZE) {
dev_err(apr->dev, "APR: Improper apr pkt received:%p %d\n",
buf, len);
return -EINVAL;
}
abuf = kzalloc(sizeof(*abuf) + len, GFP_ATOMIC);
if (!abuf)
return -ENOMEM;
abuf->len = len;
memcpy(abuf->buf, buf, len);
spin_lock_irqsave(&apr->rx_lock, flags);
list_add_tail(&abuf->node, &apr->rx_list);
spin_unlock_irqrestore(&apr->rx_lock, flags);
queue_work(apr->rxwq, &apr->rx_work);
return 0;
}
static int apr_do_rx_callback(struct apr *apr, struct apr_rx_buf *abuf)
{
void *buf = abuf->buf;
int len = abuf->len;
uint16_t hdr_size, msg_type, ver, svc_id; uint16_t hdr_size, msg_type, ver, svc_id;
struct apr_device *svc = NULL; struct apr_device *svc = NULL;
struct apr_driver *adrv = NULL; struct apr_driver *adrv = NULL;
...@@ -132,6 +173,19 @@ static int apr_callback(struct rpmsg_device *rpdev, void *buf, ...@@ -132,6 +173,19 @@ static int apr_callback(struct rpmsg_device *rpdev, void *buf,
return 0; return 0;
} }
static void apr_rxwq(struct work_struct *work) {
struct apr *apr = container_of(work, struct apr, rx_work);
struct apr_rx_buf *abuf, *b;
if (!list_empty(&apr->rx_list)) {
list_for_each_entry_safe(abuf, b, &apr->rx_list, node) {
apr_do_rx_callback(apr, abuf);
list_del(&abuf->node);
kfree(abuf);
}
}
}
static int apr_device_match(struct device *dev, struct device_driver *drv) static int apr_device_match(struct device *dev, struct device_driver *drv)
{ {
struct apr_device *adev = to_apr_device(dev); struct apr_device *adev = to_apr_device(dev);
...@@ -285,6 +339,14 @@ static int apr_probe(struct rpmsg_device *rpdev) ...@@ -285,6 +339,14 @@ static int apr_probe(struct rpmsg_device *rpdev)
dev_set_drvdata(dev, apr); dev_set_drvdata(dev, apr);
apr->ch = rpdev->ept; apr->ch = rpdev->ept;
apr->dev = dev; apr->dev = dev;
apr->rxwq = create_singlethread_workqueue("qcom_apr_rx");
if (!apr->rxwq) {
dev_err(apr->dev, "Failed to start Rx WQ\n");
return -ENOMEM;
}
INIT_WORK(&apr->rx_work, apr_rxwq);
INIT_LIST_HEAD(&apr->rx_list);
spin_lock_init(&apr->rx_lock);
spin_lock_init(&apr->svcs_lock); spin_lock_init(&apr->svcs_lock);
idr_init(&apr->svcs_idr); idr_init(&apr->svcs_idr);
of_register_apr_devices(dev); of_register_apr_devices(dev);
...@@ -303,6 +365,9 @@ static int apr_remove_device(struct device *dev, void *null) ...@@ -303,6 +365,9 @@ static int apr_remove_device(struct device *dev, void *null)
static void apr_remove(struct rpmsg_device *rpdev) static void apr_remove(struct rpmsg_device *rpdev)
{ {
struct apr *apr = dev_get_drvdata(&rpdev->dev);
destroy_workqueue(apr->rxwq);
device_for_each_child(&rpdev->dev, NULL, apr_remove_device); device_for_each_child(&rpdev->dev, NULL, apr_remove_device);
} }
......
...@@ -96,6 +96,16 @@ config SND_SOC_MSM8996 ...@@ -96,6 +96,16 @@ config SND_SOC_MSM8996
APQ8096 SoC-based systems. APQ8096 SoC-based systems.
Say Y if you want to use audio device on this SoCs Say Y if you want to use audio device on this SoCs
config SND_SOC_DB845C
tristate "SoC Machine driver for Dragon Board DB845c board"
depends on QCOM_APR
select SND_SOC_QDSP6
select SND_SOC_QCOM_COMMON
help
To add support for audio on Qualcomm Technologies Inc.
Dragon Board DB845c Board.
Say Y if you want to use audio device on this Board.
config SND_SOC_SDM845 config SND_SOC_SDM845
tristate "SoC Machine driver for SDM845 boards" tristate "SoC Machine driver for SDM845 boards"
depends on QCOM_APR && MFD_CROS_EC depends on QCOM_APR && MFD_CROS_EC
......
...@@ -15,12 +15,14 @@ snd-soc-storm-objs := storm.o ...@@ -15,12 +15,14 @@ snd-soc-storm-objs := storm.o
snd-soc-apq8016-sbc-objs := apq8016_sbc.o snd-soc-apq8016-sbc-objs := apq8016_sbc.o
snd-soc-apq8096-objs := apq8096.o snd-soc-apq8096-objs := apq8096.o
snd-soc-sdm845-objs := sdm845.o snd-soc-sdm845-objs := sdm845.o
snd-soc-db845c-objs := db845c.o
snd-soc-qcom-common-objs := common.o snd-soc-qcom-common-objs := common.o
obj-$(CONFIG_SND_SOC_STORM) += snd-soc-storm.o obj-$(CONFIG_SND_SOC_STORM) += snd-soc-storm.o
obj-$(CONFIG_SND_SOC_APQ8016_SBC) += snd-soc-apq8016-sbc.o obj-$(CONFIG_SND_SOC_APQ8016_SBC) += snd-soc-apq8016-sbc.o
obj-$(CONFIG_SND_SOC_MSM8996) += snd-soc-apq8096.o obj-$(CONFIG_SND_SOC_MSM8996) += snd-soc-apq8096.o
obj-$(CONFIG_SND_SOC_SDM845) += snd-soc-sdm845.o obj-$(CONFIG_SND_SOC_SDM845) += snd-soc-sdm845.o
obj-$(CONFIG_SND_SOC_DB845C) += snd-soc-db845c.o
obj-$(CONFIG_SND_SOC_QCOM_COMMON) += snd-soc-qcom-common.o obj-$(CONFIG_SND_SOC_QCOM_COMMON) += snd-soc-qcom-common.o
#DSP lib #DSP lib
......
...@@ -5,14 +5,21 @@ ...@@ -5,14 +5,21 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/of_device.h> #include <linux/of_device.h>
#include <sound/soc.h> #include <sound/soc.h>
#include <sound/jack.h>
#include <sound/soc-dapm.h> #include <sound/soc-dapm.h>
#include <sound/pcm.h> #include <sound/pcm.h>
#include <uapi/linux/input-event-codes.h>
#include "common.h" #include "common.h"
#define SLIM_MAX_TX_PORTS 16 #define SLIM_MAX_TX_PORTS 16
#define SLIM_MAX_RX_PORTS 16 #define SLIM_MAX_RX_PORTS 16
#define WCD9335_DEFAULT_MCLK_RATE 9600000 #define WCD9335_DEFAULT_MCLK_RATE 9600000
struct apq8096_card_data {
struct snd_soc_jack jack;
bool jack_setup;
};
static int apq8096_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, static int apq8096_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
struct snd_pcm_hw_params *params) struct snd_pcm_hw_params *params)
{ {
...@@ -67,6 +74,7 @@ static struct snd_soc_ops apq8096_ops = { ...@@ -67,6 +74,7 @@ static struct snd_soc_ops apq8096_ops = {
static int apq8096_init(struct snd_soc_pcm_runtime *rtd) static int apq8096_init(struct snd_soc_pcm_runtime *rtd)
{ {
struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_dai *codec_dai = rtd->codec_dai;
struct apq8096_card_data *data = snd_soc_card_get_drvdata(rtd->card);
/* /*
* Codec SLIMBUS configuration * Codec SLIMBUS configuration
...@@ -79,6 +87,8 @@ static int apq8096_init(struct snd_soc_pcm_runtime *rtd) ...@@ -79,6 +87,8 @@ static int apq8096_init(struct snd_soc_pcm_runtime *rtd)
unsigned int tx_ch[SLIM_MAX_TX_PORTS] = {128, 129, 130, 131, 132, 133, unsigned int tx_ch[SLIM_MAX_TX_PORTS] = {128, 129, 130, 131, 132, 133,
134, 135, 136, 137, 138, 139, 134, 135, 136, 137, 138, 139,
140, 141, 142, 143}; 140, 141, 142, 143};
struct snd_soc_card *card = rtd->card;
int rval;
snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch), snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch),
tx_ch, ARRAY_SIZE(rx_ch), rx_ch); tx_ch, ARRAY_SIZE(rx_ch), rx_ch);
...@@ -86,6 +96,38 @@ static int apq8096_init(struct snd_soc_pcm_runtime *rtd) ...@@ -86,6 +96,38 @@ static int apq8096_init(struct snd_soc_pcm_runtime *rtd)
snd_soc_dai_set_sysclk(codec_dai, 0, WCD9335_DEFAULT_MCLK_RATE, snd_soc_dai_set_sysclk(codec_dai, 0, WCD9335_DEFAULT_MCLK_RATE,
SNDRV_PCM_STREAM_PLAYBACK); SNDRV_PCM_STREAM_PLAYBACK);
if (!data->jack_setup) {
struct snd_jack *jack;
rval = snd_soc_card_jack_new(card, "Headset Jack",
SND_JACK_HEADSET |
SND_JACK_HEADPHONE |
SND_JACK_BTN_0 | SND_JACK_BTN_1 |
SND_JACK_BTN_2 | SND_JACK_BTN_3 |
SND_JACK_BTN_4,
&data->jack, NULL, 0);
if (rval < 0) {
dev_err(card->dev, "Unable to add Headphone Jack\n");
return rval;
}
jack = data->jack.jack;
snd_jack_set_key(jack, SND_JACK_BTN_0, KEY_PLAYPAUSE);
snd_jack_set_key(jack, SND_JACK_BTN_1, KEY_VOICECOMMAND);
snd_jack_set_key(jack, SND_JACK_BTN_2, KEY_VOLUMEUP);
snd_jack_set_key(jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN);
data->jack_setup = true;
}
rval = snd_soc_component_set_jack(codec_dai->component,
&data->jack, NULL);
if (rval != 0 && rval != -ENOTSUPP) {
dev_warn(card->dev, "Failed to set jack: %d\n", rval);
return rval;
}
return 0; return 0;
} }
...@@ -105,6 +147,7 @@ static void apq8096_add_be_ops(struct snd_soc_card *card) ...@@ -105,6 +147,7 @@ static void apq8096_add_be_ops(struct snd_soc_card *card)
static int apq8096_platform_probe(struct platform_device *pdev) static int apq8096_platform_probe(struct platform_device *pdev)
{ {
struct apq8096_card_data *data;
struct snd_soc_card *card; struct snd_soc_card *card;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
int ret; int ret;
...@@ -113,8 +156,15 @@ static int apq8096_platform_probe(struct platform_device *pdev) ...@@ -113,8 +156,15 @@ static int apq8096_platform_probe(struct platform_device *pdev)
if (!card) if (!card)
return -ENOMEM; return -ENOMEM;
data = kzalloc(sizeof(*data), GFP_KERNEL);
if (!data) {
kfree(card);
return -ENOMEM;
}
card->dev = dev; card->dev = dev;
dev_set_drvdata(dev, card); dev_set_drvdata(dev, card);
snd_soc_card_set_drvdata(card, data);
ret = qcom_snd_parse_of(card); ret = qcom_snd_parse_of(card);
if (ret) { if (ret) {
dev_err(dev, "Error parsing OF data\n"); dev_err(dev, "Error parsing OF data\n");
...@@ -132,16 +182,19 @@ static int apq8096_platform_probe(struct platform_device *pdev) ...@@ -132,16 +182,19 @@ static int apq8096_platform_probe(struct platform_device *pdev)
kfree(card->dai_link); kfree(card->dai_link);
err: err:
kfree(card); kfree(card);
kfree(data);
return ret; return ret;
} }
static int apq8096_platform_remove(struct platform_device *pdev) static int apq8096_platform_remove(struct platform_device *pdev)
{ {
struct snd_soc_card *card = dev_get_drvdata(&pdev->dev); struct snd_soc_card *card = dev_get_drvdata(&pdev->dev);
struct apq8096_card_data *data = snd_soc_card_get_drvdata(card);
snd_soc_unregister_card(card); snd_soc_unregister_card(card);
kfree(card->dai_link); kfree(card->dai_link);
kfree(card); kfree(card);
kfree(data);
return 0; return 0;
} }
......
...@@ -90,6 +90,7 @@ int qcom_snd_parse_of(struct snd_soc_card *card) ...@@ -90,6 +90,7 @@ int qcom_snd_parse_of(struct snd_soc_card *card)
link->dynamic = 1; link->dynamic = 1;
} }
link->nonatomic = 1;
link->ignore_suspend = 1; link->ignore_suspend = 1;
ret = of_property_read_string(np, "link-name", &link->name); ret = of_property_read_string(np, "link-name", &link->name);
if (ret) { if (ret) {
......
// SPDX-License-Identifier: GPL-2.0
// Copyright (c) 2019, Linaro Limited
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/of_device.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include "common.h"
#include "qdsp6/q6afe.h"
#define DEFAULT_SAMPLE_RATE_48K 48000
#define DEFAULT_MCLK_RATE 24576000
#define MI2S_BCLK_RATE 1536000
static int db845c_snd_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
int ret = 0;
switch (cpu_dai->id) {
case QUATERNARY_MI2S_RX:
snd_soc_dai_set_sysclk(cpu_dai,
Q6AFE_LPASS_CLK_ID_QUAD_MI2S_IBIT,
MI2S_BCLK_RATE, SNDRV_PCM_STREAM_PLAYBACK);
break;
default:
pr_err("%s: invalid dai id 0x%x\n", __func__, cpu_dai->id);
break;
}
return ret;
}
static int db845c_snd_startup(struct snd_pcm_substream *substream)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
switch (cpu_dai->id) {
case QUATERNARY_MI2S_RX:
snd_soc_dai_set_sysclk(cpu_dai,
Q6AFE_LPASS_CLK_ID_MCLK_4,
DEFAULT_MCLK_RATE, SNDRV_PCM_STREAM_PLAYBACK);
snd_soc_dai_set_sysclk(cpu_dai,
Q6AFE_LPASS_CLK_ID_QUAD_MI2S_IBIT,
MI2S_BCLK_RATE, SNDRV_PCM_STREAM_PLAYBACK);
snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_CBS_CFS);
break;
default:
pr_err("%s: invalid dai id 0x%x\n", __func__, cpu_dai->id);
break;
}
return 0;
}
static const struct snd_soc_ops db845c_be_ops = {
.hw_params = db845c_snd_hw_params,
.startup = db845c_snd_startup,
};
static int db845c_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);
struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
rate->min = rate->max = DEFAULT_SAMPLE_RATE_48K;
channels->min = channels->max = 2;
snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S16_LE);
return 0;
}
static void db845c_add_ops(struct snd_soc_card *card)
{
struct snd_soc_dai_link *link;
int i;
for_each_card_prelinks(card, i, link) {
if (link->no_pcm == 1) {
link->ops = &db845c_be_ops;
link->be_hw_params_fixup = db845c_be_hw_params_fixup;
}
}
}
static int db845c_snd_platform_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct snd_soc_card *card;
int ret;
card = kzalloc(sizeof(*card), GFP_KERNEL);
if (!card)
return -ENOMEM;
card->dev = dev;
dev_set_drvdata(dev, card);
ret = qcom_snd_parse_of(card);
if (ret) {
dev_err(dev, "Error parsing OF data\n");
goto parse_dt_fail;
}
db845c_add_ops(card);
ret = snd_soc_register_card(card);
if (ret) {
dev_err(dev, "Sound card registration failed\n");
goto register_card_fail;
}
return ret;
register_card_fail:
kfree(card->dai_link);
parse_dt_fail:
kfree(card);
return ret;
}
static int db845c_snd_platform_remove(struct platform_device *pdev)
{
struct snd_soc_card *card = dev_get_drvdata(&pdev->dev);
snd_soc_unregister_card(card);
kfree(card->dai_link);
kfree(card);
return 0;
}
static const struct of_device_id db845c_snd_device_id[] = {
{ .compatible = "qcom,db845c-sndcard" },
{},
};
MODULE_DEVICE_TABLE(of, db845c_snd_device_id);
static struct platform_driver db845c_snd_driver = {
.probe = db845c_snd_platform_probe,
.remove = db845c_snd_platform_remove,
.driver = {
.name = "msm-snd-db845c",
.of_match_table = db845c_snd_device_id,
},
};
module_platform_driver(db845c_snd_driver);
MODULE_DESCRIPTION("db845c ASoC Machine Driver");
MODULE_LICENSE("GPL v2");
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment