mirror of https://gitee.com/openkylin/linux.git
Merge remote-tracking branches 'asoc/topic/qcom', 'asoc/topic/rcar', 'asoc/topic/rt286' and 'asoc/topic/rt5640' into asoc-next
This commit is contained in:
commit
71d8c2d783
|
@ -0,0 +1,60 @@
|
|||
* Qualcomm Technologies APQ8016 SBC ASoC machine driver
|
||||
|
||||
This node models the Qualcomm Technologies APQ8016 SBC ASoC machine driver
|
||||
|
||||
Required properties:
|
||||
|
||||
- compatible : "qcom,apq8016-sbc-sndcard"
|
||||
|
||||
- pinctrl-N : One property must exist for each entry in
|
||||
pinctrl-names. See ../pinctrl/pinctrl-bindings.txt
|
||||
for details of the property values.
|
||||
- pinctrl-names : Must contain a "default" entry.
|
||||
- reg : Must contain an address for each entry in reg-names.
|
||||
- reg-names : A list which must include the following entries:
|
||||
* "mic-iomux"
|
||||
* "spkr-iomux"
|
||||
- qcom,model : Name of the sound card.
|
||||
|
||||
Dai-link subnode properties and subnodes:
|
||||
|
||||
Required dai-link subnodes:
|
||||
|
||||
- cpu : CPU sub-node
|
||||
- codec : CODEC sub-node
|
||||
|
||||
Required CPU/CODEC subnodes properties:
|
||||
|
||||
-link-name : Name of the dai link.
|
||||
-sound-dai : phandle and port of CPU/CODEC
|
||||
-capture-dai : phandle and port of CPU/CODEC
|
||||
|
||||
Example:
|
||||
|
||||
sound: sound {
|
||||
compatible = "qcom,apq8016-sbc-sndcard";
|
||||
reg = <0x07702000 0x4>, <0x07702004 0x4>;
|
||||
reg-names = "mic-iomux", "spkr-iomux";
|
||||
qcom,model = "DB410c";
|
||||
|
||||
/* I2S - Internal codec */
|
||||
internal-dai-link@0 {
|
||||
cpu { /* PRIMARY */
|
||||
sound-dai = <&lpass MI2S_PRIMARY>;
|
||||
};
|
||||
codec {
|
||||
sound-dai = <&wcd_codec 0>;
|
||||
};
|
||||
};
|
||||
|
||||
/* External Primary or External Secondary -ADV7533 HDMI */
|
||||
external-dai-link@0 {
|
||||
link-name = "ADV7533";
|
||||
cpu { /* QUAT */
|
||||
sound-dai = <&lpass MI2S_QUATERNARY>;
|
||||
};
|
||||
codec {
|
||||
sound-dai = <&adv_bridge 0>;
|
||||
};
|
||||
};
|
||||
};
|
|
@ -509,6 +509,11 @@ config SND_SOC_RL6231
|
|||
default m if SND_SOC_RT5670=m
|
||||
default m if SND_SOC_RT5677=m
|
||||
|
||||
config SND_SOC_RL6347A
|
||||
tristate
|
||||
default y if SND_SOC_RT286=y
|
||||
default m if SND_SOC_RT286=m
|
||||
|
||||
config SND_SOC_RT286
|
||||
tristate
|
||||
depends on I2C
|
||||
|
|
|
@ -77,6 +77,7 @@ snd-soc-pcm512x-objs := pcm512x.o
|
|||
snd-soc-pcm512x-i2c-objs := pcm512x-i2c.o
|
||||
snd-soc-pcm512x-spi-objs := pcm512x-spi.o
|
||||
snd-soc-rl6231-objs := rl6231.o
|
||||
snd-soc-rl6347a-objs := rl6347a.o
|
||||
snd-soc-rt286-objs := rt286.o
|
||||
snd-soc-rt5631-objs := rt5631.o
|
||||
snd-soc-rt5640-objs := rt5640.o
|
||||
|
@ -263,6 +264,7 @@ obj-$(CONFIG_SND_SOC_PCM512x) += snd-soc-pcm512x.o
|
|||
obj-$(CONFIG_SND_SOC_PCM512x_I2C) += snd-soc-pcm512x-i2c.o
|
||||
obj-$(CONFIG_SND_SOC_PCM512x_SPI) += snd-soc-pcm512x-spi.o
|
||||
obj-$(CONFIG_SND_SOC_RL6231) += snd-soc-rl6231.o
|
||||
obj-$(CONFIG_SND_SOC_RL6347A) += snd-soc-rl6347a.o
|
||||
obj-$(CONFIG_SND_SOC_RT286) += snd-soc-rt286.o
|
||||
obj-$(CONFIG_SND_SOC_RT5631) += snd-soc-rt5631.o
|
||||
obj-$(CONFIG_SND_SOC_RT5640) += snd-soc-rt5640.o
|
||||
|
|
|
@ -0,0 +1,128 @@
|
|||
/*
|
||||
* rl6347a.c - RL6347A class device shared support
|
||||
*
|
||||
* Copyright 2015 Realtek Semiconductor Corp.
|
||||
*
|
||||
* Author: Oder Chiou <oder_chiou@realtek.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/moduleparam.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/pm.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/spi/spi.h>
|
||||
#include <linux/dmi.h>
|
||||
#include <linux/acpi.h>
|
||||
#include <sound/core.h>
|
||||
#include <sound/pcm.h>
|
||||
#include <sound/pcm_params.h>
|
||||
#include <sound/soc.h>
|
||||
#include <sound/soc-dapm.h>
|
||||
#include <sound/initval.h>
|
||||
#include <sound/tlv.h>
|
||||
#include <sound/jack.h>
|
||||
#include <linux/workqueue.h>
|
||||
#include <sound/hda_verbs.h>
|
||||
|
||||
#include "rl6347a.h"
|
||||
|
||||
int rl6347a_hw_write(void *context, unsigned int reg, unsigned int value)
|
||||
{
|
||||
struct i2c_client *client = context;
|
||||
struct rl6347a_priv *rl6347a = i2c_get_clientdata(client);
|
||||
u8 data[4];
|
||||
int ret, i;
|
||||
|
||||
/* handle index registers */
|
||||
if (reg <= 0xff) {
|
||||
rl6347a_hw_write(client, RL6347A_COEF_INDEX, reg);
|
||||
for (i = 0; i < rl6347a->index_cache_size; i++) {
|
||||
if (reg == rl6347a->index_cache[i].reg) {
|
||||
rl6347a->index_cache[i].def = value;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
reg = RL6347A_PROC_COEF;
|
||||
}
|
||||
|
||||
data[0] = (reg >> 24) & 0xff;
|
||||
data[1] = (reg >> 16) & 0xff;
|
||||
/*
|
||||
* 4 bit VID: reg should be 0
|
||||
* 12 bit VID: value should be 0
|
||||
* So we use an OR operator to handle it rather than use if condition.
|
||||
*/
|
||||
data[2] = ((reg >> 8) & 0xff) | ((value >> 8) & 0xff);
|
||||
data[3] = value & 0xff;
|
||||
|
||||
ret = i2c_master_send(client, data, 4);
|
||||
|
||||
if (ret == 4)
|
||||
return 0;
|
||||
else
|
||||
pr_err("ret=%d\n", ret);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
else
|
||||
return -EIO;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(rl6347a_hw_write);
|
||||
|
||||
int rl6347a_hw_read(void *context, unsigned int reg, unsigned int *value)
|
||||
{
|
||||
struct i2c_client *client = context;
|
||||
struct i2c_msg xfer[2];
|
||||
int ret;
|
||||
__be32 be_reg;
|
||||
unsigned int index, vid, buf = 0x0;
|
||||
|
||||
/* handle index registers */
|
||||
if (reg <= 0xff) {
|
||||
rl6347a_hw_write(client, RL6347A_COEF_INDEX, reg);
|
||||
reg = RL6347A_PROC_COEF;
|
||||
}
|
||||
|
||||
reg = reg | 0x80000;
|
||||
vid = (reg >> 8) & 0xfff;
|
||||
|
||||
if (AC_VERB_GET_AMP_GAIN_MUTE == (vid & 0xf00)) {
|
||||
index = (reg >> 8) & 0xf;
|
||||
reg = (reg & ~0xf0f) | index;
|
||||
}
|
||||
be_reg = cpu_to_be32(reg);
|
||||
|
||||
/* Write register */
|
||||
xfer[0].addr = client->addr;
|
||||
xfer[0].flags = 0;
|
||||
xfer[0].len = 4;
|
||||
xfer[0].buf = (u8 *)&be_reg;
|
||||
|
||||
/* Read data */
|
||||
xfer[1].addr = client->addr;
|
||||
xfer[1].flags = I2C_M_RD;
|
||||
xfer[1].len = 4;
|
||||
xfer[1].buf = (u8 *)&buf;
|
||||
|
||||
ret = i2c_transfer(client->adapter, xfer, 2);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
else if (ret != 2)
|
||||
return -EIO;
|
||||
|
||||
*value = be32_to_cpu(buf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(rl6347a_hw_read);
|
||||
|
||||
MODULE_DESCRIPTION("RL6347A class device shared support");
|
||||
MODULE_AUTHOR("Oder Chiou <oder_chiou@realtek.com>");
|
||||
MODULE_LICENSE("GPL v2");
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* rl6347a.h - RL6347A class device shared support
|
||||
*
|
||||
* Copyright 2015 Realtek Semiconductor Corp.
|
||||
*
|
||||
* Author: Oder Chiou <oder_chiou@realtek.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*/
|
||||
#ifndef __RL6347A_H__
|
||||
#define __RL6347A_H__
|
||||
|
||||
#define VERB_CMD(V, N, D) ((N << 20) | (V << 8) | D)
|
||||
|
||||
#define RL6347A_VENDOR_REGISTERS 0x20
|
||||
|
||||
#define RL6347A_COEF_INDEX\
|
||||
VERB_CMD(AC_VERB_SET_COEF_INDEX, RL6347A_VENDOR_REGISTERS, 0)
|
||||
#define RL6347A_PROC_COEF\
|
||||
VERB_CMD(AC_VERB_SET_PROC_COEF, RL6347A_VENDOR_REGISTERS, 0)
|
||||
|
||||
struct rl6347a_priv {
|
||||
struct reg_default *index_cache;
|
||||
int index_cache_size;
|
||||
};
|
||||
|
||||
int rl6347a_hw_write(void *context, unsigned int reg, unsigned int value);
|
||||
int rl6347a_hw_read(void *context, unsigned int reg, unsigned int *value);
|
||||
|
||||
#endif /* __RL6347A_H__ */
|
|
@ -31,12 +31,15 @@
|
|||
#include <sound/rt286.h>
|
||||
#include <sound/hda_verbs.h>
|
||||
|
||||
#include "rl6347a.h"
|
||||
#include "rt286.h"
|
||||
|
||||
#define RT286_VENDOR_ID 0x10ec0286
|
||||
#define RT288_VENDOR_ID 0x10ec0288
|
||||
|
||||
struct rt286_priv {
|
||||
struct reg_default *index_cache;
|
||||
int index_cache_size;
|
||||
struct regmap *regmap;
|
||||
struct snd_soc_codec *codec;
|
||||
struct rt286_platform_data pdata;
|
||||
|
@ -45,7 +48,6 @@ struct rt286_priv {
|
|||
struct delayed_work jack_detect_work;
|
||||
int sys_clk;
|
||||
int clk_id;
|
||||
struct reg_default *index_cache;
|
||||
};
|
||||
|
||||
static struct reg_default rt286_index_def[] = {
|
||||
|
@ -185,94 +187,6 @@ static bool rt286_readable_register(struct device *dev, unsigned int reg)
|
|||
}
|
||||
}
|
||||
|
||||
static int rt286_hw_write(void *context, unsigned int reg, unsigned int value)
|
||||
{
|
||||
struct i2c_client *client = context;
|
||||
struct rt286_priv *rt286 = i2c_get_clientdata(client);
|
||||
u8 data[4];
|
||||
int ret, i;
|
||||
|
||||
/* handle index registers */
|
||||
if (reg <= 0xff) {
|
||||
rt286_hw_write(client, RT286_COEF_INDEX, reg);
|
||||
for (i = 0; i < INDEX_CACHE_SIZE; i++) {
|
||||
if (reg == rt286->index_cache[i].reg) {
|
||||
rt286->index_cache[i].def = value;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
reg = RT286_PROC_COEF;
|
||||
}
|
||||
|
||||
data[0] = (reg >> 24) & 0xff;
|
||||
data[1] = (reg >> 16) & 0xff;
|
||||
/*
|
||||
* 4 bit VID: reg should be 0
|
||||
* 12 bit VID: value should be 0
|
||||
* So we use an OR operator to handle it rather than use if condition.
|
||||
*/
|
||||
data[2] = ((reg >> 8) & 0xff) | ((value >> 8) & 0xff);
|
||||
data[3] = value & 0xff;
|
||||
|
||||
ret = i2c_master_send(client, data, 4);
|
||||
|
||||
if (ret == 4)
|
||||
return 0;
|
||||
else
|
||||
pr_err("ret=%d\n", ret);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
else
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
static int rt286_hw_read(void *context, unsigned int reg, unsigned int *value)
|
||||
{
|
||||
struct i2c_client *client = context;
|
||||
struct i2c_msg xfer[2];
|
||||
int ret;
|
||||
__be32 be_reg;
|
||||
unsigned int index, vid, buf = 0x0;
|
||||
|
||||
/* handle index registers */
|
||||
if (reg <= 0xff) {
|
||||
rt286_hw_write(client, RT286_COEF_INDEX, reg);
|
||||
reg = RT286_PROC_COEF;
|
||||
}
|
||||
|
||||
reg = reg | 0x80000;
|
||||
vid = (reg >> 8) & 0xfff;
|
||||
|
||||
if (AC_VERB_GET_AMP_GAIN_MUTE == (vid & 0xf00)) {
|
||||
index = (reg >> 8) & 0xf;
|
||||
reg = (reg & ~0xf0f) | index;
|
||||
}
|
||||
be_reg = cpu_to_be32(reg);
|
||||
|
||||
/* Write register */
|
||||
xfer[0].addr = client->addr;
|
||||
xfer[0].flags = 0;
|
||||
xfer[0].len = 4;
|
||||
xfer[0].buf = (u8 *)&be_reg;
|
||||
|
||||
/* Read data */
|
||||
xfer[1].addr = client->addr;
|
||||
xfer[1].flags = I2C_M_RD;
|
||||
xfer[1].len = 4;
|
||||
xfer[1].buf = (u8 *)&buf;
|
||||
|
||||
ret = i2c_transfer(client->adapter, xfer, 2);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
else if (ret != 2)
|
||||
return -EIO;
|
||||
|
||||
*value = be32_to_cpu(buf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
static void rt286_index_sync(struct snd_soc_codec *codec)
|
||||
{
|
||||
|
@ -1174,8 +1088,8 @@ static const struct regmap_config rt286_regmap = {
|
|||
.max_register = 0x02370100,
|
||||
.volatile_reg = rt286_volatile_register,
|
||||
.readable_reg = rt286_readable_register,
|
||||
.reg_write = rt286_hw_write,
|
||||
.reg_read = rt286_hw_read,
|
||||
.reg_write = rl6347a_hw_write,
|
||||
.reg_read = rl6347a_hw_read,
|
||||
.cache_type = REGCACHE_RBTREE,
|
||||
.reg_defaults = rt286_reg,
|
||||
.num_reg_defaults = ARRAY_SIZE(rt286_reg),
|
||||
|
@ -1248,6 +1162,7 @@ static int rt286_i2c_probe(struct i2c_client *i2c,
|
|||
}
|
||||
|
||||
rt286->index_cache = rt286_index_def;
|
||||
rt286->index_cache_size = INDEX_CACHE_SIZE;
|
||||
rt286->i2c = i2c;
|
||||
i2c_set_clientdata(i2c, rt286);
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ static const struct regmap_range_cfg rt5640_ranges[] = {
|
|||
.window_len = 0x1, },
|
||||
};
|
||||
|
||||
static struct reg_default init_list[] = {
|
||||
static const struct reg_default init_list[] = {
|
||||
{RT5640_PR_BASE + 0x3d, 0x3600},
|
||||
{RT5640_PR_BASE + 0x12, 0x0aa8},
|
||||
{RT5640_PR_BASE + 0x14, 0x0aaa},
|
||||
|
@ -59,7 +59,6 @@ static struct reg_default init_list[] = {
|
|||
{RT5640_PR_BASE + 0x21, 0xe0e0},
|
||||
{RT5640_PR_BASE + 0x23, 0x1804},
|
||||
};
|
||||
#define RT5640_INIT_REG_LEN ARRAY_SIZE(init_list)
|
||||
|
||||
static const struct reg_default rt5640_reg[] = {
|
||||
{ 0x00, 0x000e },
|
||||
|
@ -2122,7 +2121,7 @@ MODULE_DEVICE_TABLE(of, rt5640_of_match);
|
|||
#endif
|
||||
|
||||
#ifdef CONFIG_ACPI
|
||||
static struct acpi_device_id rt5640_acpi_match[] = {
|
||||
static const struct acpi_device_id rt5640_acpi_match[] = {
|
||||
{ "INT33CA", 0 },
|
||||
{ "10EC5640", 0 },
|
||||
{ "10EC5642", 0 },
|
||||
|
|
|
@ -32,3 +32,12 @@ config SND_SOC_STORM
|
|||
help
|
||||
Say Y or M if you want add support for SoC audio on the
|
||||
Qualcomm Technologies IPQ806X-based Storm board.
|
||||
|
||||
config SND_SOC_APQ8016_SBC
|
||||
tristate "SoC Audio support for APQ8016 SBC platforms"
|
||||
depends on SND_SOC_QCOM && (ARCH_QCOM || COMPILE_TEST)
|
||||
select SND_SOC_LPASS_APQ8016
|
||||
help
|
||||
Support for Qualcomm Technologies LPASS audio block in
|
||||
APQ8016 SOC-based systems.
|
||||
Say Y if you want to use audio devices on MI2S.
|
||||
|
|
|
@ -11,5 +11,7 @@ obj-$(CONFIG_SND_SOC_LPASS_APQ8016) += snd-soc-lpass-apq8016.o
|
|||
|
||||
# Machine
|
||||
snd-soc-storm-objs := storm.o
|
||||
snd-soc-apq8016-sbc-objs := apq8016_sbc.o
|
||||
|
||||
obj-$(CONFIG_SND_SOC_STORM) += snd-soc-storm.o
|
||||
obj-$(CONFIG_SND_SOC_APQ8016_SBC) += snd-soc-apq8016-sbc.o
|
||||
|
|
|
@ -0,0 +1,198 @@
|
|||
/*
|
||||
* Copyright (c) 2015 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 <linux/device.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/io.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/clk.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <sound/pcm.h>
|
||||
#include <sound/pcm_params.h>
|
||||
#include <sound/soc.h>
|
||||
#include <dt-bindings/sound/apq8016-lpass.h>
|
||||
|
||||
struct apq8016_sbc_data {
|
||||
void __iomem *mic_iomux;
|
||||
void __iomem *spkr_iomux;
|
||||
struct snd_soc_dai_link dai_link[]; /* dynamically allocated */
|
||||
};
|
||||
|
||||
#define MIC_CTRL_QUA_WS_SLAVE_SEL_10 BIT(17)
|
||||
#define MIC_CTRL_TLMM_SCLK_EN BIT(1)
|
||||
#define SPKR_CTL_PRI_WS_SLAVE_SEL_11 (BIT(17) | BIT(16))
|
||||
|
||||
static int apq8016_sbc_dai_init(struct snd_soc_pcm_runtime *rtd)
|
||||
{
|
||||
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
|
||||
struct snd_soc_card *card = rtd->card;
|
||||
struct apq8016_sbc_data *pdata = snd_soc_card_get_drvdata(card);
|
||||
int rval = 0;
|
||||
|
||||
switch (cpu_dai->id) {
|
||||
case MI2S_PRIMARY:
|
||||
writel(readl(pdata->spkr_iomux) | SPKR_CTL_PRI_WS_SLAVE_SEL_11,
|
||||
pdata->spkr_iomux);
|
||||
break;
|
||||
|
||||
case MI2S_QUATERNARY:
|
||||
/* Configure the Quat MI2S to TLMM */
|
||||
writel(readl(pdata->mic_iomux) | MIC_CTRL_QUA_WS_SLAVE_SEL_10 |
|
||||
MIC_CTRL_TLMM_SCLK_EN,
|
||||
pdata->mic_iomux);
|
||||
break;
|
||||
|
||||
default:
|
||||
dev_err(card->dev, "unsupported cpu dai configuration\n");
|
||||
rval = -EINVAL;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
static struct apq8016_sbc_data *apq8016_sbc_parse_of(struct snd_soc_card *card)
|
||||
{
|
||||
struct device *dev = card->dev;
|
||||
struct snd_soc_dai_link *link;
|
||||
struct device_node *np, *codec, *cpu, *node = dev->of_node;
|
||||
struct apq8016_sbc_data *data;
|
||||
int ret, num_links;
|
||||
|
||||
ret = snd_soc_of_parse_card_name(card, "qcom,model");
|
||||
if (ret) {
|
||||
dev_err(dev, "Error parsing card name: %d\n", ret);
|
||||
return ERR_PTR(ret);
|
||||
}
|
||||
|
||||
/* Populate links */
|
||||
num_links = of_get_child_count(node);
|
||||
|
||||
/* Allocate the private data and the DAI link array */
|
||||
data = devm_kzalloc(dev, sizeof(*data) + sizeof(*link) * num_links,
|
||||
GFP_KERNEL);
|
||||
if (!data)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
card->dai_link = &data->dai_link[0];
|
||||
card->num_links = num_links;
|
||||
|
||||
link = data->dai_link;
|
||||
|
||||
for_each_child_of_node(node, np) {
|
||||
cpu = of_get_child_by_name(np, "cpu");
|
||||
codec = of_get_child_by_name(np, "codec");
|
||||
|
||||
if (!cpu || !codec) {
|
||||
dev_err(dev, "Can't find cpu/codec DT node\n");
|
||||
return ERR_PTR(-EINVAL);
|
||||
}
|
||||
|
||||
link->cpu_of_node = of_parse_phandle(cpu, "sound-dai", 0);
|
||||
if (!link->cpu_of_node) {
|
||||
dev_err(card->dev, "error getting cpu phandle\n");
|
||||
return ERR_PTR(-EINVAL);
|
||||
}
|
||||
|
||||
link->codec_of_node = of_parse_phandle(codec, "sound-dai", 0);
|
||||
if (!link->codec_of_node) {
|
||||
dev_err(card->dev, "error getting codec phandle\n");
|
||||
return ERR_PTR(-EINVAL);
|
||||
}
|
||||
|
||||
ret = snd_soc_of_get_dai_name(cpu, &link->cpu_dai_name);
|
||||
if (ret) {
|
||||
dev_err(card->dev, "error getting cpu dai name\n");
|
||||
return ERR_PTR(ret);
|
||||
}
|
||||
|
||||
ret = snd_soc_of_get_dai_name(codec, &link->codec_dai_name);
|
||||
if (ret) {
|
||||
dev_err(card->dev, "error getting codec dai name\n");
|
||||
return ERR_PTR(ret);
|
||||
}
|
||||
|
||||
link->platform_of_node = link->cpu_of_node;
|
||||
/* For now we only support playback */
|
||||
link->playback_only = true;
|
||||
|
||||
ret = of_property_read_string(np, "link-name", &link->name);
|
||||
if (ret) {
|
||||
dev_err(card->dev, "error getting codec dai_link name\n");
|
||||
return ERR_PTR(ret);
|
||||
}
|
||||
|
||||
link->stream_name = link->name;
|
||||
link->init = apq8016_sbc_dai_init;
|
||||
link++;
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
static int apq8016_sbc_platform_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct device *dev = &pdev->dev;
|
||||
struct snd_soc_card *card;
|
||||
struct apq8016_sbc_data *data;
|
||||
struct resource *res;
|
||||
|
||||
card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL);
|
||||
if (!card)
|
||||
return -ENOMEM;
|
||||
|
||||
card->dev = dev;
|
||||
data = apq8016_sbc_parse_of(card);
|
||||
if (IS_ERR(data)) {
|
||||
dev_err(&pdev->dev, "Error resolving dai links: %ld\n",
|
||||
PTR_ERR(data));
|
||||
return PTR_ERR(data);
|
||||
}
|
||||
|
||||
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mic-iomux");
|
||||
data->mic_iomux = devm_ioremap_resource(dev, res);
|
||||
if (IS_ERR(data->mic_iomux))
|
||||
return PTR_ERR(data->mic_iomux);
|
||||
|
||||
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "spkr-iomux");
|
||||
data->spkr_iomux = devm_ioremap_resource(dev, res);
|
||||
if (IS_ERR(data->spkr_iomux))
|
||||
return PTR_ERR(data->spkr_iomux);
|
||||
|
||||
platform_set_drvdata(pdev, data);
|
||||
snd_soc_card_set_drvdata(card, data);
|
||||
|
||||
return devm_snd_soc_register_card(&pdev->dev, card);
|
||||
}
|
||||
|
||||
static const struct of_device_id apq8016_sbc_device_id[] = {
|
||||
{ .compatible = "qcom,apq8016-sbc-sndcard" },
|
||||
{},
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, apq8016_sbc_device_id);
|
||||
|
||||
static struct platform_driver apq8016_sbc_platform_driver = {
|
||||
.driver = {
|
||||
.name = "qcom-apq8016-sbc",
|
||||
.of_match_table = of_match_ptr(apq8016_sbc_device_id),
|
||||
},
|
||||
.probe = apq8016_sbc_platform_probe,
|
||||
};
|
||||
module_platform_driver(apq8016_sbc_platform_driver);
|
||||
|
||||
MODULE_AUTHOR("Srinivas Kandagatla <srinivas.kandagatla@linaro.org");
|
||||
MODULE_DESCRIPTION("APQ8016 ASoC Machine Driver");
|
||||
MODULE_LICENSE("GPL v2");
|
|
@ -69,11 +69,6 @@ static struct snd_soc_dai_link storm_dai_link = {
|
|||
.ops = &storm_soc_ops,
|
||||
};
|
||||
|
||||
static struct snd_soc_card storm_soc_card = {
|
||||
.name = "ipq806x-storm",
|
||||
.dev = NULL,
|
||||
};
|
||||
|
||||
static int storm_parse_of(struct snd_soc_card *card)
|
||||
{
|
||||
struct snd_soc_dai_link *dai_link = card->dai_link;
|
||||
|
@ -99,14 +94,13 @@ static int storm_parse_of(struct snd_soc_card *card)
|
|||
|
||||
static int storm_platform_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct snd_soc_card *card = &storm_soc_card;
|
||||
struct snd_soc_card *card;
|
||||
int ret;
|
||||
|
||||
if (card->dev) {
|
||||
dev_err(&pdev->dev, "%s() error, existing soundcard\n",
|
||||
__func__);
|
||||
return -ENODEV;
|
||||
}
|
||||
card = devm_kzalloc(&pdev->dev, sizeof(*card), GFP_KERNEL);
|
||||
if (!card)
|
||||
return -ENOMEM;
|
||||
|
||||
card->dev = &pdev->dev;
|
||||
platform_set_drvdata(pdev, card);
|
||||
|
||||
|
@ -128,16 +122,12 @@ static int storm_platform_probe(struct platform_device *pdev)
|
|||
}
|
||||
|
||||
ret = devm_snd_soc_register_card(&pdev->dev, card);
|
||||
if (ret == -EPROBE_DEFER) {
|
||||
card->dev = NULL;
|
||||
return ret;
|
||||
} else if (ret) {
|
||||
if (ret)
|
||||
dev_err(&pdev->dev, "%s() error registering soundcard: %d\n",
|
||||
__func__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
#ifdef CONFIG_OF
|
||||
|
|
|
@ -137,15 +137,17 @@ char *rsnd_mod_name(struct rsnd_mod *mod)
|
|||
return mod->ops->name;
|
||||
}
|
||||
|
||||
struct dma_chan *rsnd_mod_dma_req(struct rsnd_mod *mod)
|
||||
struct dma_chan *rsnd_mod_dma_req(struct rsnd_dai_stream *io,
|
||||
struct rsnd_mod *mod)
|
||||
{
|
||||
if (!mod || !mod->ops || !mod->ops->dma_req)
|
||||
return NULL;
|
||||
|
||||
return mod->ops->dma_req(mod);
|
||||
return mod->ops->dma_req(io, mod);
|
||||
}
|
||||
|
||||
int rsnd_mod_init(struct rsnd_mod *mod,
|
||||
int rsnd_mod_init(struct rsnd_priv *priv,
|
||||
struct rsnd_mod *mod,
|
||||
struct rsnd_mod_ops *ops,
|
||||
struct clk *clk,
|
||||
enum rsnd_mod_type type,
|
||||
|
@ -160,6 +162,7 @@ int rsnd_mod_init(struct rsnd_mod *mod,
|
|||
mod->ops = ops;
|
||||
mod->type = type;
|
||||
mod->clk = clk;
|
||||
mod->priv = priv;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -170,10 +173,31 @@ void rsnd_mod_quit(struct rsnd_mod *mod)
|
|||
clk_unprepare(mod->clk);
|
||||
}
|
||||
|
||||
int rsnd_mod_is_working(struct rsnd_mod *mod)
|
||||
void rsnd_mod_interrupt(struct rsnd_mod *mod,
|
||||
void (*callback)(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io))
|
||||
{
|
||||
struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
|
||||
struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
|
||||
struct rsnd_dai_stream *io;
|
||||
struct rsnd_dai *rdai;
|
||||
int i, j;
|
||||
|
||||
for_each_rsnd_dai(rdai, priv, j) {
|
||||
|
||||
for (i = 0; i < RSND_MOD_MAX; i++) {
|
||||
io = &rdai->playback;
|
||||
if (mod == io->mod[i])
|
||||
callback(mod, io);
|
||||
|
||||
io = &rdai->capture;
|
||||
if (mod == io->mod[i])
|
||||
callback(mod, io);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int rsnd_io_is_working(struct rsnd_dai_stream *io)
|
||||
{
|
||||
/* see rsnd_dai_stream_init/quit() */
|
||||
return !!io->substream;
|
||||
}
|
||||
|
@ -181,10 +205,9 @@ int rsnd_mod_is_working(struct rsnd_mod *mod)
|
|||
/*
|
||||
* settting function
|
||||
*/
|
||||
u32 rsnd_get_adinr(struct rsnd_mod *mod)
|
||||
u32 rsnd_get_adinr(struct rsnd_mod *mod, struct rsnd_dai_stream *io)
|
||||
{
|
||||
struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
|
||||
struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
|
||||
struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
|
||||
struct device *dev = rsnd_priv_to_dev(priv);
|
||||
u32 adinr = runtime->channels;
|
||||
|
@ -207,26 +230,31 @@ u32 rsnd_get_adinr(struct rsnd_mod *mod)
|
|||
/*
|
||||
* rsnd_dai functions
|
||||
*/
|
||||
#define __rsnd_mod_call(mod, func, param...) \
|
||||
#define __rsnd_mod_call(mod, io, func, param...) \
|
||||
({ \
|
||||
struct rsnd_priv *priv = rsnd_mod_to_priv(mod); \
|
||||
struct device *dev = rsnd_priv_to_dev(priv); \
|
||||
u32 mask = (1 << __rsnd_mod_shift_##func) & ~(1 << 31); \
|
||||
u32 call = __rsnd_mod_call_##func << __rsnd_mod_shift_##func; \
|
||||
u32 mask = 0xF << __rsnd_mod_shift_##func; \
|
||||
u8 val = (mod->status >> __rsnd_mod_shift_##func) & 0xF; \
|
||||
u8 add = ((val + __rsnd_mod_add_##func) & 0xF); \
|
||||
int ret = 0; \
|
||||
if ((mod->status & mask) == call) { \
|
||||
dev_dbg(dev, "%s[%d] %s\n", \
|
||||
rsnd_mod_name(mod), rsnd_mod_id(mod), #func); \
|
||||
ret = (mod)->ops->func(mod, param); \
|
||||
mod->status = (mod->status & ~mask) | (~call & mask); \
|
||||
int called = 0; \
|
||||
if (val == __rsnd_mod_call_##func) { \
|
||||
called = 1; \
|
||||
ret = (mod)->ops->func(mod, io, param); \
|
||||
mod->status = (mod->status & ~mask) + \
|
||||
(add << __rsnd_mod_shift_##func); \
|
||||
} \
|
||||
dev_dbg(dev, "%s[%d] 0x%08x %s\n", \
|
||||
rsnd_mod_name(mod), rsnd_mod_id(mod), mod->status, \
|
||||
called ? #func : ""); \
|
||||
ret; \
|
||||
})
|
||||
|
||||
#define rsnd_mod_call(mod, func, param...) \
|
||||
#define rsnd_mod_call(mod, io, func, param...) \
|
||||
(!(mod) ? -ENODEV : \
|
||||
!((mod)->ops->func) ? 0 : \
|
||||
__rsnd_mod_call(mod, func, param))
|
||||
__rsnd_mod_call(mod, io, func, param))
|
||||
|
||||
#define rsnd_dai_call(fn, io, param...) \
|
||||
({ \
|
||||
|
@ -236,7 +264,7 @@ u32 rsnd_get_adinr(struct rsnd_mod *mod)
|
|||
mod = (io)->mod[i]; \
|
||||
if (!mod) \
|
||||
continue; \
|
||||
ret = rsnd_mod_call(mod, fn, param); \
|
||||
ret = rsnd_mod_call(mod, io, fn, param); \
|
||||
if (ret < 0) \
|
||||
break; \
|
||||
} \
|
||||
|
@ -260,7 +288,6 @@ static int rsnd_dai_connect(struct rsnd_mod *mod,
|
|||
}
|
||||
|
||||
io->mod[mod->type] = mod;
|
||||
mod->io = io;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -268,7 +295,6 @@ static int rsnd_dai_connect(struct rsnd_mod *mod,
|
|||
static void rsnd_dai_disconnect(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io)
|
||||
{
|
||||
mod->io = NULL;
|
||||
io->mod[mod->type] = NULL;
|
||||
}
|
||||
|
||||
|
@ -302,7 +328,7 @@ int rsnd_dai_pointer_offset(struct rsnd_dai_stream *io, int additional)
|
|||
return pos;
|
||||
}
|
||||
|
||||
void rsnd_dai_pointer_update(struct rsnd_dai_stream *io, int byte)
|
||||
bool rsnd_dai_pointer_update(struct rsnd_dai_stream *io, int byte)
|
||||
{
|
||||
io->byte_pos += byte;
|
||||
|
||||
|
@ -319,8 +345,24 @@ void rsnd_dai_pointer_update(struct rsnd_dai_stream *io, int byte)
|
|||
io->next_period_byte = io->byte_per_period;
|
||||
}
|
||||
|
||||
snd_pcm_period_elapsed(substream);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void rsnd_dai_period_elapsed(struct rsnd_dai_stream *io)
|
||||
{
|
||||
struct snd_pcm_substream *substream = io->substream;
|
||||
|
||||
/*
|
||||
* this function should be called...
|
||||
*
|
||||
* - if rsnd_dai_pointer_update() returns true
|
||||
* - without spin lock
|
||||
*/
|
||||
|
||||
snd_pcm_period_elapsed(substream);
|
||||
}
|
||||
|
||||
static void rsnd_dai_stream_init(struct rsnd_dai_stream *io,
|
||||
|
@ -834,16 +876,18 @@ static int rsnd_kctrl_put(struct snd_kcontrol *kctrl,
|
|||
}
|
||||
|
||||
if (change)
|
||||
cfg->update(mod);
|
||||
cfg->update(cfg->io, mod);
|
||||
|
||||
return change;
|
||||
}
|
||||
|
||||
static int __rsnd_kctrl_new(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io,
|
||||
struct snd_soc_pcm_runtime *rtd,
|
||||
const unsigned char *name,
|
||||
struct rsnd_kctrl_cfg *cfg,
|
||||
void (*update)(struct rsnd_mod *mod))
|
||||
void (*update)(struct rsnd_dai_stream *io,
|
||||
struct rsnd_mod *mod))
|
||||
{
|
||||
struct snd_soc_card *soc_card = rtd->card;
|
||||
struct snd_card *card = rtd->card->snd_card;
|
||||
|
@ -872,6 +916,7 @@ static int __rsnd_kctrl_new(struct rsnd_mod *mod,
|
|||
cfg->update = update;
|
||||
cfg->card = card;
|
||||
cfg->kctrl = kctrl;
|
||||
cfg->io = io;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -882,36 +927,42 @@ void _rsnd_kctrl_remove(struct rsnd_kctrl_cfg *cfg)
|
|||
}
|
||||
|
||||
int rsnd_kctrl_new_m(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io,
|
||||
struct snd_soc_pcm_runtime *rtd,
|
||||
const unsigned char *name,
|
||||
void (*update)(struct rsnd_mod *mod),
|
||||
void (*update)(struct rsnd_dai_stream *io,
|
||||
struct rsnd_mod *mod),
|
||||
struct rsnd_kctrl_cfg_m *_cfg,
|
||||
u32 max)
|
||||
{
|
||||
_cfg->cfg.max = max;
|
||||
_cfg->cfg.size = RSND_DVC_CHANNELS;
|
||||
_cfg->cfg.val = _cfg->val;
|
||||
return __rsnd_kctrl_new(mod, rtd, name, &_cfg->cfg, update);
|
||||
return __rsnd_kctrl_new(mod, io, rtd, name, &_cfg->cfg, update);
|
||||
}
|
||||
|
||||
int rsnd_kctrl_new_s(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io,
|
||||
struct snd_soc_pcm_runtime *rtd,
|
||||
const unsigned char *name,
|
||||
void (*update)(struct rsnd_mod *mod),
|
||||
void (*update)(struct rsnd_dai_stream *io,
|
||||
struct rsnd_mod *mod),
|
||||
struct rsnd_kctrl_cfg_s *_cfg,
|
||||
u32 max)
|
||||
{
|
||||
_cfg->cfg.max = max;
|
||||
_cfg->cfg.size = 1;
|
||||
_cfg->cfg.val = &_cfg->val;
|
||||
return __rsnd_kctrl_new(mod, rtd, name, &_cfg->cfg, update);
|
||||
return __rsnd_kctrl_new(mod, io, rtd, name, &_cfg->cfg, update);
|
||||
}
|
||||
|
||||
int rsnd_kctrl_new_e(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io,
|
||||
struct snd_soc_pcm_runtime *rtd,
|
||||
const unsigned char *name,
|
||||
struct rsnd_kctrl_cfg_s *_cfg,
|
||||
void (*update)(struct rsnd_mod *mod),
|
||||
void (*update)(struct rsnd_dai_stream *io,
|
||||
struct rsnd_mod *mod),
|
||||
const char * const *texts,
|
||||
u32 max)
|
||||
{
|
||||
|
@ -919,7 +970,7 @@ int rsnd_kctrl_new_e(struct rsnd_mod *mod,
|
|||
_cfg->cfg.size = 1;
|
||||
_cfg->cfg.val = &_cfg->val;
|
||||
_cfg->cfg.texts = texts;
|
||||
return __rsnd_kctrl_new(mod, rtd, name, &_cfg->cfg, update);
|
||||
return __rsnd_kctrl_new(mod, io, rtd, name, &_cfg->cfg, update);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -32,11 +32,12 @@ struct rsnd_dma_ctrl {
|
|||
/*
|
||||
* Audio DMAC
|
||||
*/
|
||||
static void rsnd_dmaen_complete(void *data)
|
||||
static void __rsnd_dmaen_complete(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io)
|
||||
{
|
||||
struct rsnd_dma *dma = (struct rsnd_dma *)data;
|
||||
struct rsnd_mod *mod = rsnd_dma_to_mod(dma);
|
||||
struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
|
||||
struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
|
||||
bool elapsed = false;
|
||||
unsigned long flags;
|
||||
|
||||
/*
|
||||
* Renesas sound Gen1 needs 1 DMAC,
|
||||
|
@ -49,23 +50,36 @@ static void rsnd_dmaen_complete(void *data)
|
|||
* rsnd_dai_pointer_update() will be called twice,
|
||||
* ant it will breaks io->byte_pos
|
||||
*/
|
||||
spin_lock_irqsave(&priv->lock, flags);
|
||||
|
||||
rsnd_dai_pointer_update(io, io->byte_per_period);
|
||||
if (rsnd_io_is_working(io))
|
||||
elapsed = rsnd_dai_pointer_update(io, io->byte_per_period);
|
||||
|
||||
spin_unlock_irqrestore(&priv->lock, flags);
|
||||
|
||||
if (elapsed)
|
||||
rsnd_dai_period_elapsed(io);
|
||||
}
|
||||
|
||||
static void rsnd_dmaen_stop(struct rsnd_dma *dma)
|
||||
static void rsnd_dmaen_complete(void *data)
|
||||
{
|
||||
struct rsnd_mod *mod = data;
|
||||
|
||||
rsnd_mod_interrupt(mod, __rsnd_dmaen_complete);
|
||||
}
|
||||
|
||||
static void rsnd_dmaen_stop(struct rsnd_dai_stream *io, struct rsnd_dma *dma)
|
||||
{
|
||||
struct rsnd_dmaen *dmaen = rsnd_dma_to_dmaen(dma);
|
||||
|
||||
dmaengine_terminate_all(dmaen->chan);
|
||||
}
|
||||
|
||||
static void rsnd_dmaen_start(struct rsnd_dma *dma)
|
||||
static void rsnd_dmaen_start(struct rsnd_dai_stream *io, struct rsnd_dma *dma)
|
||||
{
|
||||
struct rsnd_dmaen *dmaen = rsnd_dma_to_dmaen(dma);
|
||||
struct rsnd_mod *mod = rsnd_dma_to_mod(dma);
|
||||
struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
|
||||
struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
|
||||
struct snd_pcm_substream *substream = io->substream;
|
||||
struct device *dev = rsnd_priv_to_dev(priv);
|
||||
struct dma_async_tx_descriptor *desc;
|
||||
|
@ -84,7 +98,7 @@ static void rsnd_dmaen_start(struct rsnd_dma *dma)
|
|||
}
|
||||
|
||||
desc->callback = rsnd_dmaen_complete;
|
||||
desc->callback_param = dma;
|
||||
desc->callback_param = mod;
|
||||
|
||||
if (dmaengine_submit(desc) < 0) {
|
||||
dev_err(dev, "dmaengine_submit() fail\n");
|
||||
|
@ -115,7 +129,8 @@ struct dma_chan *rsnd_dma_request_channel(struct device_node *of_node,
|
|||
return chan;
|
||||
}
|
||||
|
||||
static struct dma_chan *rsnd_dmaen_request_channel(struct rsnd_mod *mod_from,
|
||||
static struct dma_chan *rsnd_dmaen_request_channel(struct rsnd_dai_stream *io,
|
||||
struct rsnd_mod *mod_from,
|
||||
struct rsnd_mod *mod_to)
|
||||
{
|
||||
if ((!mod_from && !mod_to) ||
|
||||
|
@ -123,19 +138,19 @@ static struct dma_chan *rsnd_dmaen_request_channel(struct rsnd_mod *mod_from,
|
|||
return NULL;
|
||||
|
||||
if (mod_from)
|
||||
return rsnd_mod_dma_req(mod_from);
|
||||
return rsnd_mod_dma_req(io, mod_from);
|
||||
else
|
||||
return rsnd_mod_dma_req(mod_to);
|
||||
return rsnd_mod_dma_req(io, mod_to);
|
||||
}
|
||||
|
||||
static int rsnd_dmaen_init(struct rsnd_priv *priv, struct rsnd_dma *dma, int id,
|
||||
static int rsnd_dmaen_init(struct rsnd_dai_stream *io,
|
||||
struct rsnd_dma *dma, int id,
|
||||
struct rsnd_mod *mod_from, struct rsnd_mod *mod_to)
|
||||
{
|
||||
struct rsnd_dmaen *dmaen = rsnd_dma_to_dmaen(dma);
|
||||
struct rsnd_priv *priv = rsnd_io_to_priv(io);
|
||||
struct device *dev = rsnd_priv_to_dev(priv);
|
||||
struct dma_slave_config cfg = {};
|
||||
struct rsnd_mod *mod = rsnd_dma_to_mod(dma);
|
||||
struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
|
||||
int is_play = rsnd_io_is_play(io);
|
||||
int ret;
|
||||
|
||||
|
@ -145,7 +160,7 @@ static int rsnd_dmaen_init(struct rsnd_priv *priv, struct rsnd_dma *dma, int id,
|
|||
}
|
||||
|
||||
if (dev->of_node) {
|
||||
dmaen->chan = rsnd_dmaen_request_channel(mod_from, mod_to);
|
||||
dmaen->chan = rsnd_dmaen_request_channel(io, mod_from, mod_to);
|
||||
} else {
|
||||
dma_cap_mask_t mask;
|
||||
|
||||
|
@ -177,7 +192,7 @@ static int rsnd_dmaen_init(struct rsnd_priv *priv, struct rsnd_dma *dma, int id,
|
|||
return 0;
|
||||
|
||||
rsnd_dma_init_err:
|
||||
rsnd_dma_quit(dma);
|
||||
rsnd_dma_quit(io, dma);
|
||||
rsnd_dma_channel_err:
|
||||
|
||||
/*
|
||||
|
@ -189,7 +204,7 @@ static int rsnd_dmaen_init(struct rsnd_priv *priv, struct rsnd_dma *dma, int id,
|
|||
return -EAGAIN;
|
||||
}
|
||||
|
||||
static void rsnd_dmaen_quit(struct rsnd_dma *dma)
|
||||
static void rsnd_dmaen_quit(struct rsnd_dai_stream *io, struct rsnd_dma *dma)
|
||||
{
|
||||
struct rsnd_dmaen *dmaen = rsnd_dma_to_dmaen(dma);
|
||||
|
||||
|
@ -238,9 +253,9 @@ static const u8 gen2_id_table_cmd[] = {
|
|||
0x38, /* SCU_CMD1 */
|
||||
};
|
||||
|
||||
static u32 rsnd_dmapp_get_id(struct rsnd_mod *mod)
|
||||
static u32 rsnd_dmapp_get_id(struct rsnd_dai_stream *io,
|
||||
struct rsnd_mod *mod)
|
||||
{
|
||||
struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
|
||||
struct rsnd_mod *ssi = rsnd_io_to_mod_ssi(io);
|
||||
struct rsnd_mod *src = rsnd_io_to_mod_src(io);
|
||||
struct rsnd_mod *dvc = rsnd_io_to_mod_dvc(io);
|
||||
|
@ -268,11 +283,12 @@ static u32 rsnd_dmapp_get_id(struct rsnd_mod *mod)
|
|||
return entry[id];
|
||||
}
|
||||
|
||||
static u32 rsnd_dmapp_get_chcr(struct rsnd_mod *mod_from,
|
||||
static u32 rsnd_dmapp_get_chcr(struct rsnd_dai_stream *io,
|
||||
struct rsnd_mod *mod_from,
|
||||
struct rsnd_mod *mod_to)
|
||||
{
|
||||
return (rsnd_dmapp_get_id(mod_from) << 24) +
|
||||
(rsnd_dmapp_get_id(mod_to) << 16);
|
||||
return (rsnd_dmapp_get_id(io, mod_from) << 24) +
|
||||
(rsnd_dmapp_get_id(io, mod_to) << 16);
|
||||
}
|
||||
|
||||
#define rsnd_dmapp_addr(dmac, dma, reg) \
|
||||
|
@ -299,7 +315,7 @@ static u32 rsnd_dmapp_read(struct rsnd_dma *dma, u32 reg)
|
|||
return ioread32(rsnd_dmapp_addr(dmac, dma, reg));
|
||||
}
|
||||
|
||||
static void rsnd_dmapp_stop(struct rsnd_dma *dma)
|
||||
static void rsnd_dmapp_stop(struct rsnd_dai_stream *io, struct rsnd_dma *dma)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -312,7 +328,7 @@ static void rsnd_dmapp_stop(struct rsnd_dma *dma)
|
|||
}
|
||||
}
|
||||
|
||||
static void rsnd_dmapp_start(struct rsnd_dma *dma)
|
||||
static void rsnd_dmapp_start(struct rsnd_dai_stream *io, struct rsnd_dma *dma)
|
||||
{
|
||||
struct rsnd_dmapp *dmapp = rsnd_dma_to_dmapp(dma);
|
||||
|
||||
|
@ -321,19 +337,21 @@ static void rsnd_dmapp_start(struct rsnd_dma *dma)
|
|||
rsnd_dmapp_write(dma, dmapp->chcr, PDMACHCR);
|
||||
}
|
||||
|
||||
static int rsnd_dmapp_init(struct rsnd_priv *priv, struct rsnd_dma *dma, int id,
|
||||
static int rsnd_dmapp_init(struct rsnd_dai_stream *io,
|
||||
struct rsnd_dma *dma, int id,
|
||||
struct rsnd_mod *mod_from, struct rsnd_mod *mod_to)
|
||||
{
|
||||
struct rsnd_dmapp *dmapp = rsnd_dma_to_dmapp(dma);
|
||||
struct rsnd_priv *priv = rsnd_io_to_priv(io);
|
||||
struct rsnd_dma_ctrl *dmac = rsnd_priv_to_dmac(priv);
|
||||
struct device *dev = rsnd_priv_to_dev(priv);
|
||||
|
||||
dmapp->dmapp_id = dmac->dmapp_num;
|
||||
dmapp->chcr = rsnd_dmapp_get_chcr(mod_from, mod_to) | PDMACHCR_DE;
|
||||
dmapp->chcr = rsnd_dmapp_get_chcr(io, mod_from, mod_to) | PDMACHCR_DE;
|
||||
|
||||
dmac->dmapp_num++;
|
||||
|
||||
rsnd_dmapp_stop(dma);
|
||||
rsnd_dmapp_stop(io, dma);
|
||||
|
||||
dev_dbg(dev, "id/src/dst/chcr = %d/%pad/%pad/%08x\n",
|
||||
dmapp->dmapp_id, &dma->src_addr, &dma->dst_addr, dmapp->chcr);
|
||||
|
@ -386,12 +404,12 @@ static struct rsnd_dma_ops rsnd_dmapp_ops = {
|
|||
#define RDMA_CMD_O_P(addr, i) (addr ##_reg - 0x001f8000 + (0x400 * i))
|
||||
|
||||
static dma_addr_t
|
||||
rsnd_gen2_dma_addr(struct rsnd_priv *priv,
|
||||
rsnd_gen2_dma_addr(struct rsnd_dai_stream *io,
|
||||
struct rsnd_mod *mod,
|
||||
int is_play, int is_from)
|
||||
{
|
||||
struct rsnd_priv *priv = rsnd_io_to_priv(io);
|
||||
struct device *dev = rsnd_priv_to_dev(priv);
|
||||
struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
|
||||
phys_addr_t ssi_reg = rsnd_gen_get_phy_addr(priv, RSND_GEN2_SSI);
|
||||
phys_addr_t src_reg = rsnd_gen_get_phy_addr(priv, RSND_GEN2_SCU);
|
||||
int is_ssi = !!(rsnd_io_to_mod_ssi(io) == mod);
|
||||
|
@ -438,7 +456,7 @@ rsnd_gen2_dma_addr(struct rsnd_priv *priv,
|
|||
dev_err(dev, "DVC is selected without SRC\n");
|
||||
|
||||
/* use SSIU or SSI ? */
|
||||
if (is_ssi && rsnd_ssi_use_busif(mod))
|
||||
if (is_ssi && rsnd_ssi_use_busif(io, mod))
|
||||
is_ssi++;
|
||||
|
||||
return (is_from) ?
|
||||
|
@ -446,10 +464,12 @@ rsnd_gen2_dma_addr(struct rsnd_priv *priv,
|
|||
dma_addrs[is_ssi][is_play][use_src + use_dvc].in_addr;
|
||||
}
|
||||
|
||||
static dma_addr_t rsnd_dma_addr(struct rsnd_priv *priv,
|
||||
static dma_addr_t rsnd_dma_addr(struct rsnd_dai_stream *io,
|
||||
struct rsnd_mod *mod,
|
||||
int is_play, int is_from)
|
||||
{
|
||||
struct rsnd_priv *priv = rsnd_io_to_priv(io);
|
||||
|
||||
/*
|
||||
* gen1 uses default DMA addr
|
||||
*/
|
||||
|
@ -459,17 +479,17 @@ static dma_addr_t rsnd_dma_addr(struct rsnd_priv *priv,
|
|||
if (!mod)
|
||||
return 0;
|
||||
|
||||
return rsnd_gen2_dma_addr(priv, mod, is_play, is_from);
|
||||
return rsnd_gen2_dma_addr(io, mod, is_play, is_from);
|
||||
}
|
||||
|
||||
#define MOD_MAX 4 /* MEM/SSI/SRC/DVC */
|
||||
static void rsnd_dma_of_path(struct rsnd_dma *dma,
|
||||
struct rsnd_dai_stream *io,
|
||||
int is_play,
|
||||
struct rsnd_mod **mod_from,
|
||||
struct rsnd_mod **mod_to)
|
||||
{
|
||||
struct rsnd_mod *this = rsnd_dma_to_mod(dma);
|
||||
struct rsnd_dai_stream *io = rsnd_mod_to_io(this);
|
||||
struct rsnd_mod *ssi = rsnd_io_to_mod_ssi(io);
|
||||
struct rsnd_mod *src = rsnd_io_to_mod_src(io);
|
||||
struct rsnd_mod *dvc = rsnd_io_to_mod_dvc(io);
|
||||
|
@ -524,17 +544,17 @@ static void rsnd_dma_of_path(struct rsnd_dma *dma,
|
|||
}
|
||||
}
|
||||
|
||||
void rsnd_dma_stop(struct rsnd_dma *dma)
|
||||
void rsnd_dma_stop(struct rsnd_dai_stream *io, struct rsnd_dma *dma)
|
||||
{
|
||||
dma->ops->stop(dma);
|
||||
dma->ops->stop(io, dma);
|
||||
}
|
||||
|
||||
void rsnd_dma_start(struct rsnd_dma *dma)
|
||||
void rsnd_dma_start(struct rsnd_dai_stream *io, struct rsnd_dma *dma)
|
||||
{
|
||||
dma->ops->start(dma);
|
||||
dma->ops->start(io, dma);
|
||||
}
|
||||
|
||||
void rsnd_dma_quit(struct rsnd_dma *dma)
|
||||
void rsnd_dma_quit(struct rsnd_dai_stream *io, struct rsnd_dma *dma)
|
||||
{
|
||||
struct rsnd_mod *mod = rsnd_dma_to_mod(dma);
|
||||
struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
|
||||
|
@ -543,15 +563,14 @@ void rsnd_dma_quit(struct rsnd_dma *dma)
|
|||
if (!dmac)
|
||||
return;
|
||||
|
||||
dma->ops->quit(dma);
|
||||
dma->ops->quit(io, dma);
|
||||
}
|
||||
|
||||
int rsnd_dma_init(struct rsnd_priv *priv, struct rsnd_dma *dma, int id)
|
||||
int rsnd_dma_init(struct rsnd_dai_stream *io, struct rsnd_dma *dma, int id)
|
||||
{
|
||||
struct rsnd_mod *mod = rsnd_dma_to_mod(dma);
|
||||
struct rsnd_mod *mod_from;
|
||||
struct rsnd_mod *mod_to;
|
||||
struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
|
||||
struct rsnd_priv *priv = rsnd_io_to_priv(io);
|
||||
struct rsnd_dma_ctrl *dmac = rsnd_priv_to_dmac(priv);
|
||||
int is_play = rsnd_io_is_play(io);
|
||||
|
||||
|
@ -564,10 +583,10 @@ int rsnd_dma_init(struct rsnd_priv *priv, struct rsnd_dma *dma, int id)
|
|||
if (!dmac)
|
||||
return -EAGAIN;
|
||||
|
||||
rsnd_dma_of_path(dma, is_play, &mod_from, &mod_to);
|
||||
rsnd_dma_of_path(dma, io, is_play, &mod_from, &mod_to);
|
||||
|
||||
dma->src_addr = rsnd_dma_addr(priv, mod_from, is_play, 1);
|
||||
dma->dst_addr = rsnd_dma_addr(priv, mod_to, is_play, 0);
|
||||
dma->src_addr = rsnd_dma_addr(io, mod_from, is_play, 1);
|
||||
dma->dst_addr = rsnd_dma_addr(io, mod_to, is_play, 0);
|
||||
|
||||
/* for Gen2 */
|
||||
if (mod_from && mod_to)
|
||||
|
@ -579,7 +598,7 @@ int rsnd_dma_init(struct rsnd_priv *priv, struct rsnd_dma *dma, int id)
|
|||
if (rsnd_is_gen1(priv))
|
||||
dma->ops = &rsnd_dmaen_ops;
|
||||
|
||||
return dma->ops->init(priv, dma, id, mod_from, mod_to);
|
||||
return dma->ops->init(io, dma, id, mod_from, mod_to);
|
||||
}
|
||||
|
||||
int rsnd_dma_probe(struct platform_device *pdev,
|
||||
|
|
|
@ -63,7 +63,8 @@ static const char * const dvc_ramp_rate[] = {
|
|||
"0.125 dB/8192 steps", /* 10111 */
|
||||
};
|
||||
|
||||
static void rsnd_dvc_volume_update(struct rsnd_mod *mod)
|
||||
static void rsnd_dvc_volume_update(struct rsnd_dai_stream *io,
|
||||
struct rsnd_mod *mod)
|
||||
{
|
||||
struct rsnd_dvc *dvc = rsnd_mod_to_dvc(mod);
|
||||
u32 val[RSND_DVC_CHANNELS];
|
||||
|
@ -120,6 +121,7 @@ static void rsnd_dvc_volume_update(struct rsnd_mod *mod)
|
|||
}
|
||||
|
||||
static int rsnd_dvc_remove_gen2(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io,
|
||||
struct rsnd_priv *priv)
|
||||
{
|
||||
struct rsnd_dvc *dvc = rsnd_mod_to_dvc(mod);
|
||||
|
@ -134,9 +136,9 @@ static int rsnd_dvc_remove_gen2(struct rsnd_mod *mod,
|
|||
}
|
||||
|
||||
static int rsnd_dvc_init(struct rsnd_mod *dvc_mod,
|
||||
struct rsnd_dai_stream *io,
|
||||
struct rsnd_priv *priv)
|
||||
{
|
||||
struct rsnd_dai_stream *io = rsnd_mod_to_io(dvc_mod);
|
||||
struct rsnd_mod *src_mod = rsnd_io_to_mod_src(io);
|
||||
struct device *dev = rsnd_priv_to_dev(priv);
|
||||
int dvc_id = rsnd_mod_id(dvc_mod);
|
||||
|
@ -168,10 +170,10 @@ static int rsnd_dvc_init(struct rsnd_mod *dvc_mod,
|
|||
|
||||
rsnd_mod_write(dvc_mod, DVC_DVUIR, 1);
|
||||
|
||||
rsnd_mod_write(dvc_mod, DVC_ADINR, rsnd_get_adinr(dvc_mod));
|
||||
rsnd_mod_write(dvc_mod, DVC_ADINR, rsnd_get_adinr(dvc_mod, io));
|
||||
|
||||
/* ch0/ch1 Volume */
|
||||
rsnd_dvc_volume_update(dvc_mod);
|
||||
rsnd_dvc_volume_update(io, dvc_mod);
|
||||
|
||||
rsnd_mod_write(dvc_mod, DVC_DVUIR, 0);
|
||||
|
||||
|
@ -181,6 +183,7 @@ static int rsnd_dvc_init(struct rsnd_mod *dvc_mod,
|
|||
}
|
||||
|
||||
static int rsnd_dvc_quit(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io,
|
||||
struct rsnd_priv *priv)
|
||||
{
|
||||
rsnd_mod_hw_stop(mod);
|
||||
|
@ -189,6 +192,7 @@ static int rsnd_dvc_quit(struct rsnd_mod *mod,
|
|||
}
|
||||
|
||||
static int rsnd_dvc_start(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io,
|
||||
struct rsnd_priv *priv)
|
||||
{
|
||||
rsnd_mod_write(mod, CMD_CTRL, 0x10);
|
||||
|
@ -197,6 +201,7 @@ static int rsnd_dvc_start(struct rsnd_mod *mod,
|
|||
}
|
||||
|
||||
static int rsnd_dvc_stop(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io,
|
||||
struct rsnd_priv *priv)
|
||||
{
|
||||
rsnd_mod_write(mod, CMD_CTRL, 0);
|
||||
|
@ -205,15 +210,15 @@ static int rsnd_dvc_stop(struct rsnd_mod *mod,
|
|||
}
|
||||
|
||||
static int rsnd_dvc_pcm_new(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io,
|
||||
struct snd_soc_pcm_runtime *rtd)
|
||||
{
|
||||
struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
|
||||
struct rsnd_dvc *dvc = rsnd_mod_to_dvc(mod);
|
||||
int is_play = rsnd_io_is_play(io);
|
||||
int ret;
|
||||
|
||||
/* Volume */
|
||||
ret = rsnd_kctrl_new_m(mod, rtd,
|
||||
ret = rsnd_kctrl_new_m(mod, io, rtd,
|
||||
is_play ?
|
||||
"DVC Out Playback Volume" : "DVC In Capture Volume",
|
||||
rsnd_dvc_volume_update,
|
||||
|
@ -222,7 +227,7 @@ static int rsnd_dvc_pcm_new(struct rsnd_mod *mod,
|
|||
return ret;
|
||||
|
||||
/* Mute */
|
||||
ret = rsnd_kctrl_new_m(mod, rtd,
|
||||
ret = rsnd_kctrl_new_m(mod, io, rtd,
|
||||
is_play ?
|
||||
"DVC Out Mute Switch" : "DVC In Mute Switch",
|
||||
rsnd_dvc_volume_update,
|
||||
|
@ -231,7 +236,7 @@ static int rsnd_dvc_pcm_new(struct rsnd_mod *mod,
|
|||
return ret;
|
||||
|
||||
/* Ramp */
|
||||
ret = rsnd_kctrl_new_s(mod, rtd,
|
||||
ret = rsnd_kctrl_new_s(mod, io, rtd,
|
||||
is_play ?
|
||||
"DVC Out Ramp Switch" : "DVC In Ramp Switch",
|
||||
rsnd_dvc_volume_update,
|
||||
|
@ -239,7 +244,7 @@ static int rsnd_dvc_pcm_new(struct rsnd_mod *mod,
|
|||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
ret = rsnd_kctrl_new_e(mod, rtd,
|
||||
ret = rsnd_kctrl_new_e(mod, io, rtd,
|
||||
is_play ?
|
||||
"DVC Out Ramp Up Rate" : "DVC In Ramp Up Rate",
|
||||
&dvc->rup,
|
||||
|
@ -248,7 +253,7 @@ static int rsnd_dvc_pcm_new(struct rsnd_mod *mod,
|
|||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
ret = rsnd_kctrl_new_e(mod, rtd,
|
||||
ret = rsnd_kctrl_new_e(mod, io, rtd,
|
||||
is_play ?
|
||||
"DVC Out Ramp Down Rate" : "DVC In Ramp Down Rate",
|
||||
&dvc->rdown,
|
||||
|
@ -261,7 +266,8 @@ static int rsnd_dvc_pcm_new(struct rsnd_mod *mod,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static struct dma_chan *rsnd_dvc_dma_req(struct rsnd_mod *mod)
|
||||
static struct dma_chan *rsnd_dvc_dma_req(struct rsnd_dai_stream *io,
|
||||
struct rsnd_mod *mod)
|
||||
{
|
||||
struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
|
||||
|
||||
|
@ -366,7 +372,7 @@ int rsnd_dvc_probe(struct platform_device *pdev,
|
|||
|
||||
dvc->info = &info->dvc_info[i];
|
||||
|
||||
ret = rsnd_mod_init(&dvc->mod, &rsnd_dvc_ops,
|
||||
ret = rsnd_mod_init(priv, &dvc->mod, &rsnd_dvc_ops,
|
||||
clk, RSND_MOD_DVC, i);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
|
|
@ -165,18 +165,18 @@ void rsnd_write(struct rsnd_priv *priv, struct rsnd_mod *mod,
|
|||
enum rsnd_reg reg, u32 data);
|
||||
void rsnd_bset(struct rsnd_priv *priv, struct rsnd_mod *mod, enum rsnd_reg reg,
|
||||
u32 mask, u32 data);
|
||||
u32 rsnd_get_adinr(struct rsnd_mod *mod);
|
||||
u32 rsnd_get_adinr(struct rsnd_mod *mod, struct rsnd_dai_stream *io);
|
||||
|
||||
/*
|
||||
* R-Car DMA
|
||||
*/
|
||||
struct rsnd_dma;
|
||||
struct rsnd_dma_ops {
|
||||
void (*start)(struct rsnd_dma *dma);
|
||||
void (*stop)(struct rsnd_dma *dma);
|
||||
int (*init)(struct rsnd_priv *priv, struct rsnd_dma *dma, int id,
|
||||
void (*start)(struct rsnd_dai_stream *io, struct rsnd_dma *dma);
|
||||
void (*stop)(struct rsnd_dai_stream *io, struct rsnd_dma *dma);
|
||||
int (*init)(struct rsnd_dai_stream *io, struct rsnd_dma *dma, int id,
|
||||
struct rsnd_mod *mod_from, struct rsnd_mod *mod_to);
|
||||
void (*quit)(struct rsnd_dma *dma);
|
||||
void (*quit)(struct rsnd_dai_stream *io, struct rsnd_dma *dma);
|
||||
};
|
||||
|
||||
struct rsnd_dmaen {
|
||||
|
@ -200,10 +200,10 @@ struct rsnd_dma {
|
|||
#define rsnd_dma_to_dmaen(dma) (&(dma)->dma.en)
|
||||
#define rsnd_dma_to_dmapp(dma) (&(dma)->dma.pp)
|
||||
|
||||
void rsnd_dma_start(struct rsnd_dma *dma);
|
||||
void rsnd_dma_stop(struct rsnd_dma *dma);
|
||||
int rsnd_dma_init(struct rsnd_priv *priv, struct rsnd_dma *dma, int id);
|
||||
void rsnd_dma_quit(struct rsnd_dma *dma);
|
||||
void rsnd_dma_start(struct rsnd_dai_stream *io, struct rsnd_dma *dma);
|
||||
void rsnd_dma_stop(struct rsnd_dai_stream *io, struct rsnd_dma *dma);
|
||||
int rsnd_dma_init(struct rsnd_dai_stream *io, struct rsnd_dma *dma, int id);
|
||||
void rsnd_dma_quit(struct rsnd_dai_stream *io, struct rsnd_dma *dma);
|
||||
int rsnd_dma_probe(struct platform_device *pdev,
|
||||
const struct rsnd_of_data *of_data,
|
||||
struct rsnd_priv *priv);
|
||||
|
@ -224,25 +224,35 @@ enum rsnd_mod_type {
|
|||
|
||||
struct rsnd_mod_ops {
|
||||
char *name;
|
||||
struct dma_chan* (*dma_req)(struct rsnd_mod *mod);
|
||||
struct dma_chan* (*dma_req)(struct rsnd_dai_stream *io,
|
||||
struct rsnd_mod *mod);
|
||||
int (*probe)(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io,
|
||||
struct rsnd_priv *priv);
|
||||
int (*remove)(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io,
|
||||
struct rsnd_priv *priv);
|
||||
int (*init)(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io,
|
||||
struct rsnd_priv *priv);
|
||||
int (*quit)(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io,
|
||||
struct rsnd_priv *priv);
|
||||
int (*start)(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io,
|
||||
struct rsnd_priv *priv);
|
||||
int (*stop)(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io,
|
||||
struct rsnd_priv *priv);
|
||||
int (*pcm_new)(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io,
|
||||
struct snd_soc_pcm_runtime *rtd);
|
||||
int (*hw_params)(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io,
|
||||
struct snd_pcm_substream *substream,
|
||||
struct snd_pcm_hw_params *hw_params);
|
||||
int (*fallback)(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io,
|
||||
struct rsnd_priv *priv);
|
||||
};
|
||||
|
||||
|
@ -252,32 +262,43 @@ struct rsnd_mod {
|
|||
enum rsnd_mod_type type;
|
||||
struct rsnd_mod_ops *ops;
|
||||
struct rsnd_dma dma;
|
||||
struct rsnd_dai_stream *io;
|
||||
struct rsnd_priv *priv;
|
||||
struct clk *clk;
|
||||
u32 status;
|
||||
};
|
||||
/*
|
||||
* status
|
||||
*
|
||||
* bit
|
||||
* 0 0: probe 1: remove
|
||||
* 1 0: init 1: quit
|
||||
* 2 0: start 1: stop
|
||||
* 3 0: pcm_new
|
||||
* 4 0: fallback
|
||||
* 0xH0000CBA
|
||||
*
|
||||
* 31 bit is always called (see __rsnd_mod_call)
|
||||
* 31 0: hw_params
|
||||
* A 0: probe 1: remove
|
||||
* B 0: init 1: quit
|
||||
* C 0: start 1: stop
|
||||
*
|
||||
* H is always called (see __rsnd_mod_call)
|
||||
* H 0: pcm_new
|
||||
* H 0: fallback
|
||||
* H 0: hw_params
|
||||
*/
|
||||
#define __rsnd_mod_shift_probe 0
|
||||
#define __rsnd_mod_shift_remove 0
|
||||
#define __rsnd_mod_shift_init 1
|
||||
#define __rsnd_mod_shift_quit 1
|
||||
#define __rsnd_mod_shift_start 2
|
||||
#define __rsnd_mod_shift_stop 2
|
||||
#define __rsnd_mod_shift_pcm_new 3
|
||||
#define __rsnd_mod_shift_fallback 4
|
||||
#define __rsnd_mod_shift_hw_params 31 /* always called */
|
||||
#define __rsnd_mod_shift_init 4
|
||||
#define __rsnd_mod_shift_quit 4
|
||||
#define __rsnd_mod_shift_start 8
|
||||
#define __rsnd_mod_shift_stop 8
|
||||
#define __rsnd_mod_shift_pcm_new 28 /* always called */
|
||||
#define __rsnd_mod_shift_fallback 28 /* always called */
|
||||
#define __rsnd_mod_shift_hw_params 28 /* always called */
|
||||
|
||||
#define __rsnd_mod_add_probe 1
|
||||
#define __rsnd_mod_add_remove -1
|
||||
#define __rsnd_mod_add_init 1
|
||||
#define __rsnd_mod_add_quit -1
|
||||
#define __rsnd_mod_add_start 1
|
||||
#define __rsnd_mod_add_stop -1
|
||||
#define __rsnd_mod_add_pcm_new 0
|
||||
#define __rsnd_mod_add_fallback 0
|
||||
#define __rsnd_mod_add_hw_params 0
|
||||
|
||||
#define __rsnd_mod_call_probe 0
|
||||
#define __rsnd_mod_call_remove 1
|
||||
|
@ -289,22 +310,25 @@ struct rsnd_mod {
|
|||
#define __rsnd_mod_call_fallback 0
|
||||
#define __rsnd_mod_call_hw_params 0
|
||||
|
||||
#define rsnd_mod_to_priv(mod) (rsnd_io_to_priv(rsnd_mod_to_io(mod)))
|
||||
#define rsnd_mod_to_priv(mod) ((mod)->priv)
|
||||
#define rsnd_mod_to_dma(mod) (&(mod)->dma)
|
||||
#define rsnd_mod_to_io(mod) ((mod)->io)
|
||||
#define rsnd_mod_id(mod) ((mod)->id)
|
||||
#define rsnd_mod_hw_start(mod) clk_enable((mod)->clk)
|
||||
#define rsnd_mod_hw_stop(mod) clk_disable((mod)->clk)
|
||||
|
||||
int rsnd_mod_init(struct rsnd_mod *mod,
|
||||
int rsnd_mod_init(struct rsnd_priv *priv,
|
||||
struct rsnd_mod *mod,
|
||||
struct rsnd_mod_ops *ops,
|
||||
struct clk *clk,
|
||||
enum rsnd_mod_type type,
|
||||
int id);
|
||||
void rsnd_mod_quit(struct rsnd_mod *mod);
|
||||
char *rsnd_mod_name(struct rsnd_mod *mod);
|
||||
int rsnd_mod_is_working(struct rsnd_mod *mod);
|
||||
struct dma_chan *rsnd_mod_dma_req(struct rsnd_mod *mod);
|
||||
struct dma_chan *rsnd_mod_dma_req(struct rsnd_dai_stream *io,
|
||||
struct rsnd_mod *mod);
|
||||
void rsnd_mod_interrupt(struct rsnd_mod *mod,
|
||||
void (*callback)(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io));
|
||||
|
||||
/*
|
||||
* R-Car sound DAI
|
||||
|
@ -329,7 +353,7 @@ struct rsnd_dai_stream {
|
|||
#define rsnd_io_is_play(io) (&rsnd_io_to_rdai(io)->playback == io)
|
||||
#define rsnd_io_to_runtime(io) ((io)->substream ? \
|
||||
(io)->substream->runtime : NULL)
|
||||
|
||||
int rsnd_io_is_working(struct rsnd_dai_stream *io);
|
||||
|
||||
struct rsnd_dai {
|
||||
char name[RSND_DAI_NAME_SIZE];
|
||||
|
@ -355,7 +379,8 @@ struct rsnd_dai {
|
|||
|
||||
struct rsnd_dai *rsnd_rdai_get(struct rsnd_priv *priv, int id);
|
||||
|
||||
void rsnd_dai_pointer_update(struct rsnd_dai_stream *io, int cnt);
|
||||
bool rsnd_dai_pointer_update(struct rsnd_dai_stream *io, int cnt);
|
||||
void rsnd_dai_period_elapsed(struct rsnd_dai_stream *io);
|
||||
int rsnd_dai_pointer_offset(struct rsnd_dai_stream *io, int additional);
|
||||
|
||||
/*
|
||||
|
@ -459,7 +484,8 @@ struct rsnd_kctrl_cfg {
|
|||
unsigned int size;
|
||||
u32 *val;
|
||||
const char * const *texts;
|
||||
void (*update)(struct rsnd_mod *mod);
|
||||
void (*update)(struct rsnd_dai_stream *io, struct rsnd_mod *mod);
|
||||
struct rsnd_dai_stream *io;
|
||||
struct snd_card *card;
|
||||
struct snd_kcontrol *kctrl;
|
||||
};
|
||||
|
@ -479,22 +505,28 @@ void _rsnd_kctrl_remove(struct rsnd_kctrl_cfg *cfg);
|
|||
#define rsnd_kctrl_remove(_cfg) _rsnd_kctrl_remove(&((_cfg).cfg))
|
||||
|
||||
int rsnd_kctrl_new_m(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io,
|
||||
struct snd_soc_pcm_runtime *rtd,
|
||||
const unsigned char *name,
|
||||
void (*update)(struct rsnd_mod *mod),
|
||||
void (*update)(struct rsnd_dai_stream *io,
|
||||
struct rsnd_mod *mod),
|
||||
struct rsnd_kctrl_cfg_m *_cfg,
|
||||
u32 max);
|
||||
int rsnd_kctrl_new_s(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io,
|
||||
struct snd_soc_pcm_runtime *rtd,
|
||||
const unsigned char *name,
|
||||
void (*update)(struct rsnd_mod *mod),
|
||||
void (*update)(struct rsnd_dai_stream *io,
|
||||
struct rsnd_mod *mod),
|
||||
struct rsnd_kctrl_cfg_s *_cfg,
|
||||
u32 max);
|
||||
int rsnd_kctrl_new_e(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io,
|
||||
struct snd_soc_pcm_runtime *rtd,
|
||||
const unsigned char *name,
|
||||
struct rsnd_kctrl_cfg_s *_cfg,
|
||||
void (*update)(struct rsnd_mod *mod),
|
||||
void (*update)(struct rsnd_dai_stream *io,
|
||||
struct rsnd_mod *mod),
|
||||
const char * const *texts,
|
||||
u32 max);
|
||||
|
||||
|
@ -511,8 +543,10 @@ unsigned int rsnd_src_get_ssi_rate(struct rsnd_priv *priv,
|
|||
struct rsnd_dai_stream *io,
|
||||
struct snd_pcm_runtime *runtime);
|
||||
int rsnd_src_ssiu_start(struct rsnd_mod *ssi_mod,
|
||||
struct rsnd_dai_stream *io,
|
||||
int use_busif);
|
||||
int rsnd_src_ssiu_stop(struct rsnd_mod *ssi_mod);
|
||||
int rsnd_src_ssiu_stop(struct rsnd_mod *ssi_mod,
|
||||
struct rsnd_dai_stream *io);
|
||||
int rsnd_src_ssi_irq_enable(struct rsnd_mod *ssi_mod);
|
||||
int rsnd_src_ssi_irq_disable(struct rsnd_mod *ssi_mod);
|
||||
|
||||
|
@ -529,7 +563,7 @@ void rsnd_ssi_remove(struct platform_device *pdev,
|
|||
struct rsnd_mod *rsnd_ssi_mod_get(struct rsnd_priv *priv, int id);
|
||||
int rsnd_ssi_is_pin_sharing(struct rsnd_mod *mod);
|
||||
int rsnd_ssi_is_dma_mode(struct rsnd_mod *mod);
|
||||
int rsnd_ssi_use_busif(struct rsnd_mod *mod);
|
||||
int rsnd_ssi_use_busif(struct rsnd_dai_stream *io, struct rsnd_mod *mod);
|
||||
|
||||
/*
|
||||
* R-Car DVC
|
||||
|
|
|
@ -45,61 +45,50 @@ static const struct of_device_id rsrc_card_of_match[] = {
|
|||
};
|
||||
MODULE_DEVICE_TABLE(of, rsrc_card_of_match);
|
||||
|
||||
#define DAI_NAME_NUM 32
|
||||
struct rsrc_card_dai {
|
||||
const char *name;
|
||||
unsigned int fmt;
|
||||
unsigned int sysclk;
|
||||
struct clk *clk;
|
||||
char dai_name[DAI_NAME_NUM];
|
||||
};
|
||||
|
||||
#define RSRC_FB_NUM 2 /* FE/BE */
|
||||
#define IDX_CPU 0
|
||||
#define IDX_CODEC 1
|
||||
struct rsrc_card_priv {
|
||||
struct snd_soc_card snd_card;
|
||||
struct rsrc_card_dai_props {
|
||||
struct rsrc_card_dai cpu_dai;
|
||||
struct rsrc_card_dai codec_dai;
|
||||
} dai_props[RSRC_FB_NUM];
|
||||
struct snd_soc_codec_conf codec_conf;
|
||||
struct snd_soc_dai_link dai_link[RSRC_FB_NUM];
|
||||
struct rsrc_card_dai *dai_props;
|
||||
struct snd_soc_dai_link *dai_link;
|
||||
int dai_num;
|
||||
u32 convert_rate;
|
||||
};
|
||||
|
||||
#define rsrc_priv_to_dev(priv) ((priv)->snd_card.dev)
|
||||
#define rsrc_priv_to_link(priv, i) ((priv)->snd_card.dai_link + i)
|
||||
#define rsrc_priv_to_props(priv, i) ((priv)->dai_props + i)
|
||||
#define rsrc_priv_to_link(priv, i) ((priv)->snd_card.dai_link + (i))
|
||||
#define rsrc_priv_to_props(priv, i) ((priv)->dai_props + (i))
|
||||
#define rsrc_dev_to_of_data(dev) (of_match_device(rsrc_card_of_match, (dev))->data)
|
||||
|
||||
static int rsrc_card_startup(struct snd_pcm_substream *substream)
|
||||
{
|
||||
struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
||||
struct rsrc_card_priv *priv = snd_soc_card_get_drvdata(rtd->card);
|
||||
struct rsrc_card_dai_props *dai_props =
|
||||
&priv->dai_props[rtd - rtd->card->rtd];
|
||||
struct rsrc_card_dai *dai_props =
|
||||
rsrc_priv_to_props(priv, rtd - rtd->card->rtd);
|
||||
int ret;
|
||||
|
||||
ret = clk_prepare_enable(dai_props->cpu_dai.clk);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = clk_prepare_enable(dai_props->codec_dai.clk);
|
||||
if (ret)
|
||||
clk_disable_unprepare(dai_props->cpu_dai.clk);
|
||||
|
||||
return ret;
|
||||
return clk_prepare_enable(dai_props->clk);
|
||||
}
|
||||
|
||||
static void rsrc_card_shutdown(struct snd_pcm_substream *substream)
|
||||
{
|
||||
struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
||||
struct rsrc_card_priv *priv = snd_soc_card_get_drvdata(rtd->card);
|
||||
struct rsrc_card_dai_props *dai_props =
|
||||
&priv->dai_props[rtd - rtd->card->rtd];
|
||||
struct rsrc_card_dai *dai_props =
|
||||
rsrc_priv_to_props(priv, rtd - rtd->card->rtd);
|
||||
|
||||
clk_disable_unprepare(dai_props->cpu_dai.clk);
|
||||
|
||||
clk_disable_unprepare(dai_props->codec_dai.clk);
|
||||
clk_disable_unprepare(dai_props->clk);
|
||||
}
|
||||
|
||||
static struct snd_soc_ops rsrc_card_ops = {
|
||||
|
@ -107,21 +96,31 @@ static struct snd_soc_ops rsrc_card_ops = {
|
|||
.shutdown = rsrc_card_shutdown,
|
||||
};
|
||||
|
||||
static int __rsrc_card_dai_init(struct snd_soc_dai *dai,
|
||||
struct rsrc_card_dai *set)
|
||||
static int rsrc_card_dai_init(struct snd_soc_pcm_runtime *rtd)
|
||||
{
|
||||
struct rsrc_card_priv *priv = snd_soc_card_get_drvdata(rtd->card);
|
||||
struct snd_soc_dai *dai;
|
||||
struct snd_soc_dai_link *dai_link;
|
||||
struct rsrc_card_dai *dai_props;
|
||||
int num = rtd - rtd->card->rtd;
|
||||
int ret;
|
||||
|
||||
if (set->fmt) {
|
||||
ret = snd_soc_dai_set_fmt(dai, set->fmt);
|
||||
dai_link = rsrc_priv_to_link(priv, num);
|
||||
dai_props = rsrc_priv_to_props(priv, num);
|
||||
dai = dai_link->dynamic ?
|
||||
rtd->cpu_dai :
|
||||
rtd->codec_dai;
|
||||
|
||||
if (dai_props->fmt) {
|
||||
ret = snd_soc_dai_set_fmt(dai, dai_props->fmt);
|
||||
if (ret && ret != -ENOTSUPP) {
|
||||
dev_err(dai->dev, "set_fmt error\n");
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
if (set->sysclk) {
|
||||
ret = snd_soc_dai_set_sysclk(dai, 0, set->sysclk, 0);
|
||||
if (dai_props->sysclk) {
|
||||
ret = snd_soc_dai_set_sysclk(dai, 0, dai_props->sysclk, 0);
|
||||
if (ret && ret != -ENOTSUPP) {
|
||||
dev_err(dai->dev, "set_sysclk error\n");
|
||||
goto err;
|
||||
|
@ -134,27 +133,6 @@ static int __rsrc_card_dai_init(struct snd_soc_dai *dai,
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int rsrc_card_dai_init(struct snd_soc_pcm_runtime *rtd)
|
||||
{
|
||||
struct rsrc_card_priv *priv = snd_soc_card_get_drvdata(rtd->card);
|
||||
struct snd_soc_dai *codec = rtd->codec_dai;
|
||||
struct snd_soc_dai *cpu = rtd->cpu_dai;
|
||||
struct rsrc_card_dai_props *dai_props;
|
||||
int num, ret;
|
||||
|
||||
num = rtd - rtd->card->rtd;
|
||||
dai_props = &priv->dai_props[num];
|
||||
ret = __rsrc_card_dai_init(codec, &dai_props->codec_dai);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
ret = __rsrc_card_dai_init(cpu, &dai_props->cpu_dai);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rsrc_card_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
|
||||
struct snd_pcm_hw_params *params)
|
||||
{
|
||||
|
@ -170,111 +148,15 @@ static int rsrc_card_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
rsrc_card_sub_parse_of(struct rsrc_card_priv *priv,
|
||||
struct device_node *np,
|
||||
struct rsrc_card_dai *dai,
|
||||
struct snd_soc_dai_link *dai_link,
|
||||
int *args_count)
|
||||
{
|
||||
struct device *dev = rsrc_priv_to_dev(priv);
|
||||
const struct rsrc_card_of_data *of_data = rsrc_dev_to_of_data(dev);
|
||||
struct of_phandle_args args;
|
||||
struct device_node **p_node;
|
||||
struct clk *clk;
|
||||
const char **dai_name;
|
||||
const char **name;
|
||||
u32 val;
|
||||
int ret;
|
||||
|
||||
if (args_count) {
|
||||
p_node = &dai_link->cpu_of_node;
|
||||
dai_name = &dai_link->cpu_dai_name;
|
||||
name = &dai_link->cpu_name;
|
||||
} else {
|
||||
p_node = &dai_link->codec_of_node;
|
||||
dai_name = &dai_link->codec_dai_name;
|
||||
name = &dai_link->codec_name;
|
||||
}
|
||||
|
||||
if (!np) {
|
||||
/* use snd-soc-dummy */
|
||||
*p_node = NULL;
|
||||
*dai_name = "snd-soc-dummy-dai";
|
||||
*name = "snd-soc-dummy";
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get node via "sound-dai = <&phandle port>"
|
||||
* it will be used as xxx_of_node on soc_bind_dai_link()
|
||||
*/
|
||||
ret = of_parse_phandle_with_args(np, "sound-dai",
|
||||
"#sound-dai-cells", 0, &args);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
*p_node = args.np;
|
||||
|
||||
/* Get dai->name */
|
||||
ret = snd_soc_of_get_dai_name(np, dai_name);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
/*
|
||||
* FIXME
|
||||
*
|
||||
* rsrc assumes DPCM playback/capture
|
||||
*/
|
||||
dai_link->dpcm_playback = 1;
|
||||
dai_link->dpcm_capture = 1;
|
||||
|
||||
if (args_count) {
|
||||
*args_count = args.args_count;
|
||||
dai_link->dynamic = 1;
|
||||
dai_link->dpcm_merged_format = 1;
|
||||
} else {
|
||||
dai_link->no_pcm = 1;
|
||||
priv->codec_conf.of_node = (*p_node);
|
||||
priv->codec_conf.name_prefix = of_data->prefix;
|
||||
}
|
||||
|
||||
/*
|
||||
* Parse dai->sysclk come from "clocks = <&xxx>"
|
||||
* (if system has common clock)
|
||||
* or "system-clock-frequency = <xxx>"
|
||||
* or device's module clock.
|
||||
*/
|
||||
if (of_property_read_bool(np, "clocks")) {
|
||||
clk = of_clk_get(np, 0);
|
||||
if (IS_ERR(clk)) {
|
||||
ret = PTR_ERR(clk);
|
||||
return ret;
|
||||
}
|
||||
|
||||
dai->sysclk = clk_get_rate(clk);
|
||||
dai->clk = clk;
|
||||
} else if (!of_property_read_u32(np, "system-clock-frequency", &val)) {
|
||||
dai->sysclk = val;
|
||||
} else {
|
||||
clk = of_clk_get(args.np, 0);
|
||||
if (!IS_ERR(clk))
|
||||
dai->sysclk = clk_get_rate(clk);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rsrc_card_parse_daifmt(struct device_node *node,
|
||||
struct device_node *np,
|
||||
struct rsrc_card_priv *priv,
|
||||
struct device_node *codec,
|
||||
int idx)
|
||||
int idx, bool is_fe)
|
||||
{
|
||||
struct rsrc_card_dai *dai_props = rsrc_priv_to_props(priv, idx);
|
||||
struct device_node *bitclkmaster = NULL;
|
||||
struct device_node *framemaster = NULL;
|
||||
struct rsrc_card_dai_props *dai_props = rsrc_priv_to_props(priv, idx);
|
||||
struct rsrc_card_dai *cpu_dai = &dai_props->cpu_dai;
|
||||
struct rsrc_card_dai *codec_dai = &dai_props->codec_dai;
|
||||
struct device_node *codec = is_fe ? NULL : np;
|
||||
unsigned int daifmt;
|
||||
|
||||
daifmt = snd_soc_of_parse_daifmt(node, NULL,
|
||||
|
@ -291,8 +173,7 @@ static int rsrc_card_parse_daifmt(struct device_node *node,
|
|||
daifmt |= (codec == framemaster) ?
|
||||
SND_SOC_DAIFMT_CBS_CFM : SND_SOC_DAIFMT_CBS_CFS;
|
||||
|
||||
cpu_dai->fmt = daifmt;
|
||||
codec_dai->fmt = daifmt;
|
||||
dai_props->fmt = daifmt;
|
||||
|
||||
of_node_put(bitclkmaster);
|
||||
of_node_put(framemaster);
|
||||
|
@ -300,82 +181,39 @@ static int rsrc_card_parse_daifmt(struct device_node *node,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int rsrc_card_dai_link_of(struct device_node *node,
|
||||
static int rsrc_card_parse_links(struct device_node *np,
|
||||
struct rsrc_card_priv *priv,
|
||||
int idx)
|
||||
int idx, bool is_fe)
|
||||
{
|
||||
struct device *dev = rsrc_priv_to_dev(priv);
|
||||
struct snd_soc_dai_link *dai_link = rsrc_priv_to_link(priv, idx);
|
||||
struct rsrc_card_dai_props *dai_props = rsrc_priv_to_props(priv, idx);
|
||||
struct device_node *cpu = NULL;
|
||||
struct device_node *codec = NULL;
|
||||
char *name;
|
||||
char prop[128];
|
||||
int ret, cpu_args;
|
||||
struct rsrc_card_dai *dai_props = rsrc_priv_to_props(priv, idx);
|
||||
struct of_phandle_args args;
|
||||
int ret;
|
||||
|
||||
cpu = of_get_child_by_name(node, "cpu");
|
||||
codec = of_get_child_by_name(node, "codec");
|
||||
/*
|
||||
* Get node via "sound-dai = <&phandle port>"
|
||||
* it will be used as xxx_of_node on soc_bind_dai_link()
|
||||
*/
|
||||
ret = of_parse_phandle_with_args(np, "sound-dai",
|
||||
"#sound-dai-cells", 0, &args);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (!cpu || !codec) {
|
||||
ret = -EINVAL;
|
||||
dev_err(dev, "%s: Can't find %s DT node\n", __func__, prop);
|
||||
goto dai_link_of_err;
|
||||
}
|
||||
if (is_fe) {
|
||||
/* BE is dummy */
|
||||
dai_link->codec_of_node = NULL;
|
||||
dai_link->codec_dai_name = "snd-soc-dummy-dai";
|
||||
dai_link->codec_name = "snd-soc-dummy";
|
||||
|
||||
ret = rsrc_card_parse_daifmt(node, priv, codec, idx);
|
||||
if (ret < 0)
|
||||
goto dai_link_of_err;
|
||||
/* FE settings */
|
||||
dai_link->dynamic = 1;
|
||||
dai_link->dpcm_merged_format = 1;
|
||||
dai_link->cpu_of_node = args.np;
|
||||
snd_soc_of_get_dai_name(np, &dai_link->cpu_dai_name);
|
||||
|
||||
ret = rsrc_card_sub_parse_of(priv, (idx == IDX_CPU) ? cpu : NULL,
|
||||
&dai_props->cpu_dai,
|
||||
dai_link,
|
||||
&cpu_args);
|
||||
if (ret < 0)
|
||||
goto dai_link_of_err;
|
||||
|
||||
ret = rsrc_card_sub_parse_of(priv, (idx == IDX_CODEC) ? codec : NULL,
|
||||
&dai_props->codec_dai,
|
||||
dai_link,
|
||||
NULL);
|
||||
if (ret < 0)
|
||||
goto dai_link_of_err;
|
||||
|
||||
if (!dai_link->cpu_dai_name || !dai_link->codec_dai_name) {
|
||||
ret = -EINVAL;
|
||||
goto dai_link_of_err;
|
||||
}
|
||||
|
||||
/* Simple Card assumes platform == cpu */
|
||||
dai_link->platform_of_node = dai_link->cpu_of_node;
|
||||
|
||||
/* DAI link name is created from CPU/CODEC dai name */
|
||||
name = devm_kzalloc(dev,
|
||||
strlen(dai_link->cpu_dai_name) +
|
||||
strlen(dai_link->codec_dai_name) + 2,
|
||||
GFP_KERNEL);
|
||||
if (!name) {
|
||||
ret = -ENOMEM;
|
||||
goto dai_link_of_err;
|
||||
}
|
||||
|
||||
sprintf(name, "%s-%s", dai_link->cpu_dai_name,
|
||||
dai_link->codec_dai_name);
|
||||
dai_link->name = dai_link->stream_name = name;
|
||||
dai_link->ops = &rsrc_card_ops;
|
||||
dai_link->init = rsrc_card_dai_init;
|
||||
|
||||
if (idx == IDX_CODEC)
|
||||
dai_link->be_hw_params_fixup = rsrc_card_be_hw_params_fixup;
|
||||
|
||||
dev_dbg(dev, "\tname : %s\n", dai_link->stream_name);
|
||||
dev_dbg(dev, "\tcpu : %s / %04x / %d\n",
|
||||
dai_link->cpu_dai_name,
|
||||
dai_props->cpu_dai.fmt,
|
||||
dai_props->cpu_dai.sysclk);
|
||||
dev_dbg(dev, "\tcodec : %s / %04x / %d\n",
|
||||
dai_link->codec_dai_name,
|
||||
dai_props->codec_dai.fmt,
|
||||
dai_props->codec_dai.sysclk);
|
||||
/* set dai_name */
|
||||
snprintf(dai_props->dai_name, DAI_NAME_NUM, "fe.%s",
|
||||
dai_link->cpu_dai_name);
|
||||
|
||||
/*
|
||||
* In soc_bind_dai_link() will check cpu name after
|
||||
|
@ -386,34 +224,151 @@ static int rsrc_card_dai_link_of(struct device_node *node,
|
|||
* fmt_single_name()
|
||||
* fmt_multiple_name()
|
||||
*/
|
||||
if (!cpu_args)
|
||||
if (!args.args_count)
|
||||
dai_link->cpu_dai_name = NULL;
|
||||
} else {
|
||||
struct device *dev = rsrc_priv_to_dev(priv);
|
||||
const struct rsrc_card_of_data *of_data;
|
||||
|
||||
dai_link_of_err:
|
||||
of_node_put(cpu);
|
||||
of_node_put(codec);
|
||||
of_data = rsrc_dev_to_of_data(dev);
|
||||
|
||||
/* FE is dummy */
|
||||
dai_link->cpu_of_node = NULL;
|
||||
dai_link->cpu_dai_name = "snd-soc-dummy-dai";
|
||||
dai_link->cpu_name = "snd-soc-dummy";
|
||||
|
||||
/* BE settings */
|
||||
dai_link->no_pcm = 1;
|
||||
dai_link->be_hw_params_fixup = rsrc_card_be_hw_params_fixup;
|
||||
dai_link->codec_of_node = args.np;
|
||||
snd_soc_of_get_dai_name(np, &dai_link->codec_dai_name);
|
||||
|
||||
/* additional name prefix */
|
||||
priv->codec_conf.of_node = dai_link->codec_of_node;
|
||||
priv->codec_conf.name_prefix = of_data->prefix;
|
||||
|
||||
/* set dai_name */
|
||||
snprintf(dai_props->dai_name, DAI_NAME_NUM, "be.%s",
|
||||
dai_link->codec_dai_name);
|
||||
}
|
||||
|
||||
/* Simple Card assumes platform == cpu */
|
||||
dai_link->platform_of_node = dai_link->cpu_of_node;
|
||||
dai_link->dpcm_playback = 1;
|
||||
dai_link->dpcm_capture = 1;
|
||||
dai_link->name = dai_props->dai_name;
|
||||
dai_link->stream_name = dai_props->dai_name;
|
||||
dai_link->ops = &rsrc_card_ops;
|
||||
dai_link->init = rsrc_card_dai_init;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rsrc_card_parse_clk(struct device_node *np,
|
||||
struct rsrc_card_priv *priv,
|
||||
int idx, bool is_fe)
|
||||
{
|
||||
struct snd_soc_dai_link *dai_link = rsrc_priv_to_link(priv, idx);
|
||||
struct rsrc_card_dai *dai_props = rsrc_priv_to_props(priv, idx);
|
||||
struct clk *clk;
|
||||
struct device_node *of_np = is_fe ? dai_link->cpu_of_node :
|
||||
dai_link->codec_of_node;
|
||||
u32 val;
|
||||
|
||||
/*
|
||||
* Parse dai->sysclk come from "clocks = <&xxx>"
|
||||
* (if system has common clock)
|
||||
* or "system-clock-frequency = <xxx>"
|
||||
* or device's module clock.
|
||||
*/
|
||||
if (of_property_read_bool(np, "clocks")) {
|
||||
clk = of_clk_get(np, 0);
|
||||
if (IS_ERR(clk))
|
||||
return PTR_ERR(clk);
|
||||
|
||||
dai_props->sysclk = clk_get_rate(clk);
|
||||
dai_props->clk = clk;
|
||||
} else if (!of_property_read_u32(np, "system-clock-frequency", &val)) {
|
||||
dai_props->sysclk = val;
|
||||
} else {
|
||||
clk = of_clk_get(of_np, 0);
|
||||
if (!IS_ERR(clk))
|
||||
dai_props->sysclk = clk_get_rate(clk);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rsrc_card_dai_link_of(struct device_node *node,
|
||||
struct device_node *np,
|
||||
struct rsrc_card_priv *priv,
|
||||
int idx)
|
||||
{
|
||||
struct device *dev = rsrc_priv_to_dev(priv);
|
||||
struct rsrc_card_dai *dai_props = rsrc_priv_to_props(priv, idx);
|
||||
bool is_fe = false;
|
||||
int ret;
|
||||
|
||||
if (0 == strcmp(np->name, "cpu"))
|
||||
is_fe = true;
|
||||
|
||||
ret = rsrc_card_parse_daifmt(node, np, priv, idx, is_fe);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
ret = rsrc_card_parse_links(np, priv, idx, is_fe);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
ret = rsrc_card_parse_clk(np, priv, idx, is_fe);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
dev_dbg(dev, "\t%s / %04x / %d\n",
|
||||
dai_props->dai_name,
|
||||
dai_props->fmt,
|
||||
dai_props->sysclk);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int rsrc_card_parse_of(struct device_node *node,
|
||||
struct rsrc_card_priv *priv)
|
||||
struct rsrc_card_priv *priv,
|
||||
struct device *dev)
|
||||
{
|
||||
struct device *dev = rsrc_priv_to_dev(priv);
|
||||
const struct rsrc_card_of_data *of_data = rsrc_dev_to_of_data(dev);
|
||||
struct rsrc_card_dai *props;
|
||||
struct snd_soc_dai_link *links;
|
||||
struct device_node *np;
|
||||
int ret;
|
||||
int i;
|
||||
int i, num;
|
||||
|
||||
if (!node)
|
||||
return -EINVAL;
|
||||
|
||||
/* Parse the card name from DT */
|
||||
snd_soc_of_parse_card_name(&priv->snd_card, "card-name");
|
||||
num = of_get_child_count(node);
|
||||
props = devm_kzalloc(dev, sizeof(*props) * num, GFP_KERNEL);
|
||||
links = devm_kzalloc(dev, sizeof(*links) * num, GFP_KERNEL);
|
||||
if (!props || !links)
|
||||
return -ENOMEM;
|
||||
|
||||
/* DAPM routes */
|
||||
priv->dai_props = props;
|
||||
priv->dai_link = links;
|
||||
priv->dai_num = num;
|
||||
|
||||
/* Init snd_soc_card */
|
||||
priv->snd_card.owner = THIS_MODULE;
|
||||
priv->snd_card.dev = dev;
|
||||
priv->snd_card.dai_link = priv->dai_link;
|
||||
priv->snd_card.num_links = num;
|
||||
priv->snd_card.codec_conf = &priv->codec_conf;
|
||||
priv->snd_card.num_configs = 1;
|
||||
priv->snd_card.of_dapm_routes = of_data->routes;
|
||||
priv->snd_card.num_of_dapm_routes = of_data->num_routes;
|
||||
|
||||
/* Parse the card name from DT */
|
||||
snd_soc_of_parse_card_name(&priv->snd_card, "card-name");
|
||||
|
||||
/* sampling rate convert */
|
||||
of_property_read_u32(node, "convert-rate", &priv->convert_rate);
|
||||
|
||||
|
@ -421,11 +376,12 @@ static int rsrc_card_parse_of(struct device_node *node,
|
|||
priv->snd_card.name ? priv->snd_card.name : "",
|
||||
priv->convert_rate);
|
||||
|
||||
/* FE/BE */
|
||||
for (i = 0; i < RSRC_FB_NUM; i++) {
|
||||
ret = rsrc_card_dai_link_of(node, priv, i);
|
||||
i = 0;
|
||||
for_each_child_of_node(node, np) {
|
||||
ret = rsrc_card_dai_link_of(node, np, priv, i);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
i++;
|
||||
}
|
||||
|
||||
if (!priv->snd_card.name)
|
||||
|
@ -452,7 +408,6 @@ static int rsrc_card_unref(struct snd_soc_card *card)
|
|||
static int rsrc_card_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct rsrc_card_priv *priv;
|
||||
struct snd_soc_dai_link *dai_link;
|
||||
struct device_node *np = pdev->dev.of_node;
|
||||
struct device *dev = &pdev->dev;
|
||||
int ret;
|
||||
|
@ -462,16 +417,7 @@ static int rsrc_card_probe(struct platform_device *pdev)
|
|||
if (!priv)
|
||||
return -ENOMEM;
|
||||
|
||||
/* Init snd_soc_card */
|
||||
priv->snd_card.owner = THIS_MODULE;
|
||||
priv->snd_card.dev = dev;
|
||||
dai_link = priv->dai_link;
|
||||
priv->snd_card.dai_link = dai_link;
|
||||
priv->snd_card.num_links = RSRC_FB_NUM;
|
||||
priv->snd_card.codec_conf = &priv->codec_conf;
|
||||
priv->snd_card.num_configs = 1;
|
||||
|
||||
ret = rsrc_card_parse_of(np, priv);
|
||||
ret = rsrc_card_parse_of(np, priv, dev);
|
||||
if (ret < 0) {
|
||||
if (ret != -EPROBE_DEFER)
|
||||
dev_err(dev, "parse error %d\n", ret);
|
||||
|
|
|
@ -117,10 +117,10 @@ struct rsnd_src {
|
|||
/*
|
||||
* Gen1/Gen2 common functions
|
||||
*/
|
||||
static struct dma_chan *rsnd_src_dma_req(struct rsnd_mod *mod)
|
||||
static struct dma_chan *rsnd_src_dma_req(struct rsnd_dai_stream *io,
|
||||
struct rsnd_mod *mod)
|
||||
{
|
||||
struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
|
||||
struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
|
||||
int is_play = rsnd_io_is_play(io);
|
||||
|
||||
return rsnd_dma_request_channel(rsnd_src_of_node(priv),
|
||||
|
@ -129,9 +129,9 @@ static struct dma_chan *rsnd_src_dma_req(struct rsnd_mod *mod)
|
|||
}
|
||||
|
||||
int rsnd_src_ssiu_start(struct rsnd_mod *ssi_mod,
|
||||
struct rsnd_dai_stream *io,
|
||||
int use_busif)
|
||||
{
|
||||
struct rsnd_dai_stream *io = rsnd_mod_to_io(ssi_mod);
|
||||
struct rsnd_dai *rdai = rsnd_io_to_rdai(io);
|
||||
struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
|
||||
int ssi_id = rsnd_mod_id(ssi_mod);
|
||||
|
@ -174,7 +174,7 @@ int rsnd_src_ssiu_start(struct rsnd_mod *ssi_mod,
|
|||
u32 mask = ~0;
|
||||
|
||||
rsnd_mod_write(ssi_mod, SSI_BUSIF_ADINR,
|
||||
rsnd_get_adinr(ssi_mod));
|
||||
rsnd_get_adinr(ssi_mod, io));
|
||||
rsnd_mod_write(ssi_mod, SSI_BUSIF_MODE, 1);
|
||||
rsnd_mod_write(ssi_mod, SSI_CTRL, 0x1);
|
||||
|
||||
|
@ -196,7 +196,8 @@ int rsnd_src_ssiu_start(struct rsnd_mod *ssi_mod,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int rsnd_src_ssiu_stop(struct rsnd_mod *ssi_mod)
|
||||
int rsnd_src_ssiu_stop(struct rsnd_mod *ssi_mod,
|
||||
struct rsnd_dai_stream *io)
|
||||
{
|
||||
/*
|
||||
* DMA settings for SSIU
|
||||
|
@ -235,10 +236,9 @@ int rsnd_src_ssi_irq_disable(struct rsnd_mod *ssi_mod)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static u32 rsnd_src_convert_rate(struct rsnd_src *src)
|
||||
static u32 rsnd_src_convert_rate(struct rsnd_dai_stream *io,
|
||||
struct rsnd_src *src)
|
||||
{
|
||||
struct rsnd_mod *mod = &src->mod;
|
||||
struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
|
||||
struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
|
||||
u32 convert_rate;
|
||||
|
||||
|
@ -274,7 +274,7 @@ unsigned int rsnd_src_get_ssi_rate(struct rsnd_priv *priv,
|
|||
* return convert rate if SRC is used,
|
||||
* otherwise, return runtime->rate as usual
|
||||
*/
|
||||
rate = rsnd_src_convert_rate(src);
|
||||
rate = rsnd_src_convert_rate(io, src);
|
||||
}
|
||||
|
||||
if (!rate)
|
||||
|
@ -283,12 +283,12 @@ unsigned int rsnd_src_get_ssi_rate(struct rsnd_priv *priv,
|
|||
return rate;
|
||||
}
|
||||
|
||||
static int rsnd_src_set_convert_rate(struct rsnd_mod *mod)
|
||||
static int rsnd_src_set_convert_rate(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io)
|
||||
{
|
||||
struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
|
||||
struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
|
||||
struct rsnd_src *src = rsnd_mod_to_src(mod);
|
||||
u32 convert_rate = rsnd_src_convert_rate(src);
|
||||
u32 convert_rate = rsnd_src_convert_rate(io, src);
|
||||
u32 fsrate = 0;
|
||||
|
||||
if (convert_rate)
|
||||
|
@ -299,7 +299,7 @@ static int rsnd_src_set_convert_rate(struct rsnd_mod *mod)
|
|||
rsnd_mod_write(mod, SRC_SWRSR, 1);
|
||||
|
||||
/* Set channel number and output bit length */
|
||||
rsnd_mod_write(mod, SRC_ADINR, rsnd_get_adinr(mod));
|
||||
rsnd_mod_write(mod, SRC_ADINR, rsnd_get_adinr(mod, io));
|
||||
|
||||
/* Enable the initial value of IFS */
|
||||
if (fsrate) {
|
||||
|
@ -316,6 +316,7 @@ static int rsnd_src_set_convert_rate(struct rsnd_mod *mod)
|
|||
}
|
||||
|
||||
static int rsnd_src_hw_params(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io,
|
||||
struct snd_pcm_substream *substream,
|
||||
struct snd_pcm_hw_params *fe_params)
|
||||
{
|
||||
|
@ -372,6 +373,7 @@ static int rsnd_src_init(struct rsnd_mod *mod,
|
|||
}
|
||||
|
||||
static int rsnd_src_quit(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io,
|
||||
struct rsnd_priv *priv)
|
||||
{
|
||||
struct rsnd_src *src = rsnd_mod_to_src(mod);
|
||||
|
@ -411,9 +413,9 @@ static int rsnd_src_stop(struct rsnd_mod *mod)
|
|||
/*
|
||||
* Gen1 functions
|
||||
*/
|
||||
static int rsnd_src_set_route_gen1(struct rsnd_mod *mod)
|
||||
static int rsnd_src_set_route_gen1(struct rsnd_dai_stream *io,
|
||||
struct rsnd_mod *mod)
|
||||
{
|
||||
struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
|
||||
struct src_route_config {
|
||||
u32 mask;
|
||||
int shift;
|
||||
|
@ -448,13 +450,13 @@ static int rsnd_src_set_route_gen1(struct rsnd_mod *mod)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int rsnd_src_set_convert_timing_gen1(struct rsnd_mod *mod)
|
||||
static int rsnd_src_set_convert_timing_gen1(struct rsnd_dai_stream *io,
|
||||
struct rsnd_mod *mod)
|
||||
{
|
||||
struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
|
||||
struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
|
||||
struct rsnd_src *src = rsnd_mod_to_src(mod);
|
||||
struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
|
||||
u32 convert_rate = rsnd_src_convert_rate(src);
|
||||
u32 convert_rate = rsnd_src_convert_rate(io, src);
|
||||
u32 mask;
|
||||
u32 val;
|
||||
int shift;
|
||||
|
@ -506,12 +508,13 @@ static int rsnd_src_set_convert_timing_gen1(struct rsnd_mod *mod)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int rsnd_src_set_convert_rate_gen1(struct rsnd_mod *mod)
|
||||
static int rsnd_src_set_convert_rate_gen1(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io)
|
||||
{
|
||||
struct rsnd_src *src = rsnd_mod_to_src(mod);
|
||||
int ret;
|
||||
|
||||
ret = rsnd_src_set_convert_rate(mod);
|
||||
ret = rsnd_src_set_convert_rate(mod, io);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
|
@ -523,7 +526,7 @@ static int rsnd_src_set_convert_rate_gen1(struct rsnd_mod *mod)
|
|||
rsnd_mod_read(mod, SRC_IFSVR) / 100 * 98);
|
||||
|
||||
/* Gen1/Gen2 are not compatible */
|
||||
if (rsnd_src_convert_rate(src))
|
||||
if (rsnd_src_convert_rate(io, src))
|
||||
rsnd_mod_write(mod, SRC_ROUTE_MODE0, 1);
|
||||
|
||||
/* no SRC_BFSSR settings, since SRC_SRCCR::BUFMD is 0 */
|
||||
|
@ -532,6 +535,7 @@ static int rsnd_src_set_convert_rate_gen1(struct rsnd_mod *mod)
|
|||
}
|
||||
|
||||
static int rsnd_src_init_gen1(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io,
|
||||
struct rsnd_priv *priv)
|
||||
{
|
||||
int ret;
|
||||
|
@ -540,15 +544,15 @@ static int rsnd_src_init_gen1(struct rsnd_mod *mod,
|
|||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
ret = rsnd_src_set_route_gen1(mod);
|
||||
ret = rsnd_src_set_route_gen1(io, mod);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
ret = rsnd_src_set_convert_rate_gen1(mod);
|
||||
ret = rsnd_src_set_convert_rate_gen1(mod, io);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
ret = rsnd_src_set_convert_timing_gen1(mod);
|
||||
ret = rsnd_src_set_convert_timing_gen1(io, mod);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
|
@ -556,6 +560,7 @@ static int rsnd_src_init_gen1(struct rsnd_mod *mod,
|
|||
}
|
||||
|
||||
static int rsnd_src_start_gen1(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io,
|
||||
struct rsnd_priv *priv)
|
||||
{
|
||||
int id = rsnd_mod_id(mod);
|
||||
|
@ -566,6 +571,7 @@ static int rsnd_src_start_gen1(struct rsnd_mod *mod,
|
|||
}
|
||||
|
||||
static int rsnd_src_stop_gen1(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io,
|
||||
struct rsnd_priv *priv)
|
||||
{
|
||||
int id = rsnd_mod_id(mod);
|
||||
|
@ -643,9 +649,9 @@ static bool rsnd_src_error_record_gen2(struct rsnd_mod *mod)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int _rsnd_src_start_gen2(struct rsnd_mod *mod)
|
||||
static int _rsnd_src_start_gen2(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io)
|
||||
{
|
||||
struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
|
||||
u32 val = rsnd_io_to_mod_dvc(io) ? 0x01 : 0x11;
|
||||
|
||||
rsnd_mod_write(mod, SRC_CTRL, val);
|
||||
|
@ -670,15 +676,15 @@ static int _rsnd_src_stop_gen2(struct rsnd_mod *mod)
|
|||
return rsnd_src_stop(mod);
|
||||
}
|
||||
|
||||
static irqreturn_t rsnd_src_interrupt_gen2(int irq, void *data)
|
||||
static void __rsnd_src_interrupt_gen2(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io)
|
||||
{
|
||||
struct rsnd_mod *mod = data;
|
||||
struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
|
||||
|
||||
spin_lock(&priv->lock);
|
||||
|
||||
/* ignore all cases if not working */
|
||||
if (!rsnd_mod_is_working(mod))
|
||||
if (!rsnd_io_is_working(io))
|
||||
goto rsnd_src_interrupt_gen2_out;
|
||||
|
||||
if (rsnd_src_error_record_gen2(mod)) {
|
||||
|
@ -691,24 +697,32 @@ static irqreturn_t rsnd_src_interrupt_gen2(int irq, void *data)
|
|||
|
||||
_rsnd_src_stop_gen2(mod);
|
||||
if (src->err < 1024)
|
||||
_rsnd_src_start_gen2(mod);
|
||||
_rsnd_src_start_gen2(mod, io);
|
||||
else
|
||||
dev_warn(dev, "no more SRC restart\n");
|
||||
}
|
||||
|
||||
rsnd_src_interrupt_gen2_out:
|
||||
spin_unlock(&priv->lock);
|
||||
}
|
||||
|
||||
static irqreturn_t rsnd_src_interrupt_gen2(int irq, void *data)
|
||||
{
|
||||
struct rsnd_mod *mod = data;
|
||||
|
||||
rsnd_mod_interrupt(mod, __rsnd_src_interrupt_gen2);
|
||||
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
static int rsnd_src_set_convert_rate_gen2(struct rsnd_mod *mod)
|
||||
static int rsnd_src_set_convert_rate_gen2(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io)
|
||||
{
|
||||
struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
|
||||
struct device *dev = rsnd_priv_to_dev(priv);
|
||||
struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
|
||||
struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
|
||||
struct rsnd_src *src = rsnd_mod_to_src(mod);
|
||||
u32 convert_rate = rsnd_src_convert_rate(src);
|
||||
u32 convert_rate = rsnd_src_convert_rate(io, src);
|
||||
u32 cr, route;
|
||||
uint ratio;
|
||||
int ret;
|
||||
|
@ -726,7 +740,7 @@ static int rsnd_src_set_convert_rate_gen2(struct rsnd_mod *mod)
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
ret = rsnd_src_set_convert_rate(mod);
|
||||
ret = rsnd_src_set_convert_rate(mod, io);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
|
@ -762,12 +776,12 @@ static int rsnd_src_set_convert_rate_gen2(struct rsnd_mod *mod)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int rsnd_src_set_convert_timing_gen2(struct rsnd_mod *mod)
|
||||
static int rsnd_src_set_convert_timing_gen2(struct rsnd_dai_stream *io,
|
||||
struct rsnd_mod *mod)
|
||||
{
|
||||
struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
|
||||
struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
|
||||
struct rsnd_src *src = rsnd_mod_to_src(mod);
|
||||
u32 convert_rate = rsnd_src_convert_rate(src);
|
||||
u32 convert_rate = rsnd_src_convert_rate(io, src);
|
||||
int ret;
|
||||
|
||||
if (convert_rate)
|
||||
|
@ -781,6 +795,7 @@ static int rsnd_src_set_convert_timing_gen2(struct rsnd_mod *mod)
|
|||
}
|
||||
|
||||
static int rsnd_src_probe_gen2(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io,
|
||||
struct rsnd_priv *priv)
|
||||
{
|
||||
struct rsnd_src *src = rsnd_mod_to_src(mod);
|
||||
|
@ -802,7 +817,7 @@ static int rsnd_src_probe_gen2(struct rsnd_mod *mod,
|
|||
return ret;
|
||||
}
|
||||
|
||||
ret = rsnd_dma_init(priv,
|
||||
ret = rsnd_dma_init(io,
|
||||
rsnd_mod_to_dma(mod),
|
||||
src->info->dma_id);
|
||||
|
||||
|
@ -810,14 +825,16 @@ static int rsnd_src_probe_gen2(struct rsnd_mod *mod,
|
|||
}
|
||||
|
||||
static int rsnd_src_remove_gen2(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io,
|
||||
struct rsnd_priv *priv)
|
||||
{
|
||||
rsnd_dma_quit(rsnd_mod_to_dma(mod));
|
||||
rsnd_dma_quit(io, rsnd_mod_to_dma(mod));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rsnd_src_init_gen2(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io,
|
||||
struct rsnd_priv *priv)
|
||||
{
|
||||
int ret;
|
||||
|
@ -826,11 +843,11 @@ static int rsnd_src_init_gen2(struct rsnd_mod *mod,
|
|||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
ret = rsnd_src_set_convert_rate_gen2(mod);
|
||||
ret = rsnd_src_set_convert_rate_gen2(mod, io);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
ret = rsnd_src_set_convert_timing_gen2(mod);
|
||||
ret = rsnd_src_set_convert_timing_gen2(io, mod);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
|
@ -838,31 +855,33 @@ static int rsnd_src_init_gen2(struct rsnd_mod *mod,
|
|||
}
|
||||
|
||||
static int rsnd_src_start_gen2(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io,
|
||||
struct rsnd_priv *priv)
|
||||
{
|
||||
rsnd_dma_start(rsnd_mod_to_dma(mod));
|
||||
rsnd_dma_start(io, rsnd_mod_to_dma(mod));
|
||||
|
||||
return _rsnd_src_start_gen2(mod);
|
||||
return _rsnd_src_start_gen2(mod, io);
|
||||
}
|
||||
|
||||
static int rsnd_src_stop_gen2(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io,
|
||||
struct rsnd_priv *priv)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = _rsnd_src_stop_gen2(mod);
|
||||
|
||||
rsnd_dma_stop(rsnd_mod_to_dma(mod));
|
||||
rsnd_dma_stop(io, rsnd_mod_to_dma(mod));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void rsnd_src_reconvert_update(struct rsnd_mod *mod)
|
||||
static void rsnd_src_reconvert_update(struct rsnd_dai_stream *io,
|
||||
struct rsnd_mod *mod)
|
||||
{
|
||||
struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
|
||||
struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
|
||||
struct rsnd_src *src = rsnd_mod_to_src(mod);
|
||||
u32 convert_rate = rsnd_src_convert_rate(src);
|
||||
u32 convert_rate = rsnd_src_convert_rate(io, src);
|
||||
u32 fsrate;
|
||||
|
||||
if (!runtime)
|
||||
|
@ -878,10 +897,10 @@ static void rsnd_src_reconvert_update(struct rsnd_mod *mod)
|
|||
}
|
||||
|
||||
static int rsnd_src_pcm_new(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io,
|
||||
struct snd_soc_pcm_runtime *rtd)
|
||||
{
|
||||
struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
|
||||
struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
|
||||
struct rsnd_dai *rdai = rsnd_io_to_rdai(io);
|
||||
struct rsnd_src *src = rsnd_mod_to_src(mod);
|
||||
int ret;
|
||||
|
@ -912,7 +931,7 @@ static int rsnd_src_pcm_new(struct rsnd_mod *mod,
|
|||
/*
|
||||
* enable sync convert
|
||||
*/
|
||||
ret = rsnd_kctrl_new_s(mod, rtd,
|
||||
ret = rsnd_kctrl_new_s(mod, io, rtd,
|
||||
rsnd_io_is_play(io) ?
|
||||
"SRC Out Rate Switch" :
|
||||
"SRC In Rate Switch",
|
||||
|
@ -921,7 +940,7 @@ static int rsnd_src_pcm_new(struct rsnd_mod *mod,
|
|||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
ret = rsnd_kctrl_new_s(mod, rtd,
|
||||
ret = rsnd_kctrl_new_s(mod, io, rtd,
|
||||
rsnd_io_is_play(io) ?
|
||||
"SRC Out Rate" :
|
||||
"SRC In Rate",
|
||||
|
@ -1046,7 +1065,7 @@ int rsnd_src_probe(struct platform_device *pdev,
|
|||
|
||||
src->info = &info->src_info[i];
|
||||
|
||||
ret = rsnd_mod_init(&src->mod, ops, clk, RSND_MOD_SRC, i);
|
||||
ret = rsnd_mod_init(priv, &src->mod, ops, clk, RSND_MOD_SRC, i);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -87,10 +87,9 @@ struct rsnd_ssi {
|
|||
#define rsnd_ssi_of_node(priv) \
|
||||
of_get_child_by_name(rsnd_priv_to_dev(priv)->of_node, "rcar_sound,ssi")
|
||||
|
||||
int rsnd_ssi_use_busif(struct rsnd_mod *mod)
|
||||
int rsnd_ssi_use_busif(struct rsnd_dai_stream *io, struct rsnd_mod *mod)
|
||||
{
|
||||
struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod);
|
||||
struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
|
||||
int use_busif = 0;
|
||||
|
||||
if (!rsnd_ssi_is_dma_mode(mod))
|
||||
|
@ -199,15 +198,17 @@ static void rsnd_ssi_hw_start(struct rsnd_ssi *ssi,
|
|||
}
|
||||
}
|
||||
|
||||
cr_mode = rsnd_ssi_is_dma_mode(&ssi->mod) ?
|
||||
DMEN : /* DMA : enable DMA */
|
||||
DIEN; /* PIO : enable Data interrupt */
|
||||
|
||||
if (rsnd_ssi_is_dma_mode(&ssi->mod)) {
|
||||
cr_mode = UIEN | OIEN | /* over/under run */
|
||||
DMEN; /* DMA : enable DMA */
|
||||
} else {
|
||||
cr_mode = DIEN; /* PIO : enable Data interrupt */
|
||||
}
|
||||
|
||||
cr = ssi->cr_own |
|
||||
ssi->cr_clk |
|
||||
cr_mode |
|
||||
UIEN | OIEN | EN;
|
||||
EN;
|
||||
|
||||
rsnd_mod_write(&ssi->mod, SSICR, cr);
|
||||
|
||||
|
@ -224,10 +225,9 @@ static void rsnd_ssi_hw_start(struct rsnd_ssi *ssi,
|
|||
rsnd_mod_name(&ssi->mod), rsnd_mod_id(&ssi->mod));
|
||||
}
|
||||
|
||||
static void rsnd_ssi_hw_stop(struct rsnd_ssi *ssi)
|
||||
static void rsnd_ssi_hw_stop(struct rsnd_dai_stream *io, struct rsnd_ssi *ssi)
|
||||
{
|
||||
struct rsnd_priv *priv = rsnd_mod_to_priv(&ssi->mod);
|
||||
struct rsnd_dai_stream *io = rsnd_mod_to_io(&ssi->mod);
|
||||
struct rsnd_dai *rdai = rsnd_io_to_rdai(io);
|
||||
struct device *dev = rsnd_priv_to_dev(priv);
|
||||
u32 cr;
|
||||
|
@ -261,7 +261,7 @@ static void rsnd_ssi_hw_stop(struct rsnd_ssi *ssi)
|
|||
struct rsnd_ssi *ssi_parent = rsnd_ssi_parent(ssi);
|
||||
|
||||
if (ssi_parent)
|
||||
rsnd_ssi_hw_stop(ssi_parent);
|
||||
rsnd_ssi_hw_stop(io, ssi_parent);
|
||||
else
|
||||
rsnd_ssi_master_clk_stop(ssi);
|
||||
}
|
||||
|
@ -279,10 +279,10 @@ static void rsnd_ssi_hw_stop(struct rsnd_ssi *ssi)
|
|||
* SSI mod common functions
|
||||
*/
|
||||
static int rsnd_ssi_init(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io,
|
||||
struct rsnd_priv *priv)
|
||||
{
|
||||
struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod);
|
||||
struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
|
||||
struct rsnd_dai *rdai = rsnd_io_to_rdai(io);
|
||||
struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
|
||||
u32 cr;
|
||||
|
@ -330,6 +330,7 @@ static int rsnd_ssi_init(struct rsnd_mod *mod,
|
|||
}
|
||||
|
||||
static int rsnd_ssi_quit(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io,
|
||||
struct rsnd_priv *priv)
|
||||
{
|
||||
struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod);
|
||||
|
@ -346,6 +347,7 @@ static int rsnd_ssi_quit(struct rsnd_mod *mod,
|
|||
}
|
||||
|
||||
static int rsnd_ssi_hw_params(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io,
|
||||
struct snd_pcm_substream *substream,
|
||||
struct snd_pcm_hw_params *params)
|
||||
{
|
||||
|
@ -369,7 +371,8 @@ static int rsnd_ssi_hw_params(struct rsnd_mod *mod,
|
|||
/* It will be removed on rsnd_ssi_hw_stop */
|
||||
ssi->chan = chan;
|
||||
if (ssi_parent)
|
||||
return rsnd_ssi_hw_params(&ssi_parent->mod, substream, params);
|
||||
return rsnd_ssi_hw_params(&ssi_parent->mod, io,
|
||||
substream, params);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -386,12 +389,12 @@ static void rsnd_ssi_record_error(struct rsnd_ssi *ssi, u32 status)
|
|||
}
|
||||
|
||||
static int rsnd_ssi_start(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io,
|
||||
struct rsnd_priv *priv)
|
||||
{
|
||||
struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod);
|
||||
struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
|
||||
|
||||
rsnd_src_ssiu_start(mod, rsnd_ssi_use_busif(mod));
|
||||
rsnd_src_ssiu_start(mod, io, rsnd_ssi_use_busif(io, mod));
|
||||
|
||||
rsnd_ssi_hw_start(ssi, io);
|
||||
|
||||
|
@ -401,6 +404,7 @@ static int rsnd_ssi_start(struct rsnd_mod *mod,
|
|||
}
|
||||
|
||||
static int rsnd_ssi_stop(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io,
|
||||
struct rsnd_priv *priv)
|
||||
{
|
||||
struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod);
|
||||
|
@ -409,26 +413,26 @@ static int rsnd_ssi_stop(struct rsnd_mod *mod,
|
|||
|
||||
rsnd_ssi_record_error(ssi, rsnd_mod_read(mod, SSISR));
|
||||
|
||||
rsnd_ssi_hw_stop(ssi);
|
||||
rsnd_ssi_hw_stop(io, ssi);
|
||||
|
||||
rsnd_src_ssiu_stop(mod);
|
||||
rsnd_src_ssiu_stop(mod, io);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static irqreturn_t rsnd_ssi_interrupt(int irq, void *data)
|
||||
static void __rsnd_ssi_interrupt(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io)
|
||||
{
|
||||
struct rsnd_ssi *ssi = data;
|
||||
struct rsnd_mod *mod = &ssi->mod;
|
||||
struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod);
|
||||
struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
|
||||
struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
|
||||
int is_dma = rsnd_ssi_is_dma_mode(mod);
|
||||
u32 status;
|
||||
bool elapsed = false;
|
||||
|
||||
spin_lock(&priv->lock);
|
||||
|
||||
/* ignore all cases if not working */
|
||||
if (!rsnd_mod_is_working(mod))
|
||||
if (!rsnd_io_is_working(io))
|
||||
goto rsnd_ssi_interrupt_out;
|
||||
|
||||
status = rsnd_mod_read(mod, SSISR);
|
||||
|
@ -449,11 +453,11 @@ static irqreturn_t rsnd_ssi_interrupt(int irq, void *data)
|
|||
else
|
||||
*buf = rsnd_mod_read(mod, SSIRDR);
|
||||
|
||||
rsnd_dai_pointer_update(io, sizeof(*buf));
|
||||
elapsed = rsnd_dai_pointer_update(io, sizeof(*buf));
|
||||
}
|
||||
|
||||
/* PIO / DMA */
|
||||
if (status & (UIRQ | OIRQ)) {
|
||||
/* DMA only */
|
||||
if (is_dma && (status & (UIRQ | OIRQ))) {
|
||||
struct device *dev = rsnd_priv_to_dev(priv);
|
||||
|
||||
/*
|
||||
|
@ -462,9 +466,9 @@ static irqreturn_t rsnd_ssi_interrupt(int irq, void *data)
|
|||
dev_dbg(dev, "%s[%d] restart\n",
|
||||
rsnd_mod_name(mod), rsnd_mod_id(mod));
|
||||
|
||||
rsnd_ssi_stop(mod, priv);
|
||||
rsnd_ssi_stop(mod, io, priv);
|
||||
if (ssi->err < 1024)
|
||||
rsnd_ssi_start(mod, priv);
|
||||
rsnd_ssi_start(mod, io, priv);
|
||||
else
|
||||
dev_warn(dev, "no more SSI restart\n");
|
||||
}
|
||||
|
@ -474,6 +478,16 @@ static irqreturn_t rsnd_ssi_interrupt(int irq, void *data)
|
|||
rsnd_ssi_interrupt_out:
|
||||
spin_unlock(&priv->lock);
|
||||
|
||||
if (elapsed)
|
||||
rsnd_dai_period_elapsed(io);
|
||||
}
|
||||
|
||||
static irqreturn_t rsnd_ssi_interrupt(int irq, void *data)
|
||||
{
|
||||
struct rsnd_mod *mod = data;
|
||||
|
||||
rsnd_mod_interrupt(mod, __rsnd_ssi_interrupt);
|
||||
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
|
@ -481,6 +495,7 @@ static irqreturn_t rsnd_ssi_interrupt(int irq, void *data)
|
|||
* SSI PIO
|
||||
*/
|
||||
static int rsnd_ssi_pio_probe(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io,
|
||||
struct rsnd_priv *priv)
|
||||
{
|
||||
struct device *dev = rsnd_priv_to_dev(priv);
|
||||
|
@ -490,7 +505,7 @@ static int rsnd_ssi_pio_probe(struct rsnd_mod *mod,
|
|||
ret = devm_request_irq(dev, ssi->info->irq,
|
||||
rsnd_ssi_interrupt,
|
||||
IRQF_SHARED,
|
||||
dev_name(dev), ssi);
|
||||
dev_name(dev), mod);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -506,6 +521,7 @@ static struct rsnd_mod_ops rsnd_ssi_pio_ops = {
|
|||
};
|
||||
|
||||
static int rsnd_ssi_dma_probe(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io,
|
||||
struct rsnd_priv *priv)
|
||||
{
|
||||
struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod);
|
||||
|
@ -516,25 +532,26 @@ static int rsnd_ssi_dma_probe(struct rsnd_mod *mod,
|
|||
ret = devm_request_irq(dev, ssi->info->irq,
|
||||
rsnd_ssi_interrupt,
|
||||
IRQF_SHARED,
|
||||
dev_name(dev), ssi);
|
||||
dev_name(dev), mod);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = rsnd_dma_init(
|
||||
priv, rsnd_mod_to_dma(mod),
|
||||
io, rsnd_mod_to_dma(mod),
|
||||
dma_id);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int rsnd_ssi_dma_remove(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io,
|
||||
struct rsnd_priv *priv)
|
||||
{
|
||||
struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod);
|
||||
struct device *dev = rsnd_priv_to_dev(priv);
|
||||
int irq = ssi->info->irq;
|
||||
|
||||
rsnd_dma_quit(rsnd_mod_to_dma(mod));
|
||||
rsnd_dma_quit(io, rsnd_mod_to_dma(mod));
|
||||
|
||||
/* PIO will request IRQ again */
|
||||
devm_free_irq(dev, irq, ssi);
|
||||
|
@ -543,6 +560,7 @@ static int rsnd_ssi_dma_remove(struct rsnd_mod *mod,
|
|||
}
|
||||
|
||||
static int rsnd_ssi_fallback(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io,
|
||||
struct rsnd_priv *priv)
|
||||
{
|
||||
struct device *dev = rsnd_priv_to_dev(priv);
|
||||
|
@ -563,37 +581,39 @@ static int rsnd_ssi_fallback(struct rsnd_mod *mod,
|
|||
}
|
||||
|
||||
static int rsnd_ssi_dma_start(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io,
|
||||
struct rsnd_priv *priv)
|
||||
{
|
||||
struct rsnd_dma *dma = rsnd_mod_to_dma(mod);
|
||||
|
||||
rsnd_dma_start(dma);
|
||||
rsnd_dma_start(io, dma);
|
||||
|
||||
rsnd_ssi_start(mod, priv);
|
||||
rsnd_ssi_start(mod, io, priv);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rsnd_ssi_dma_stop(struct rsnd_mod *mod,
|
||||
struct rsnd_dai_stream *io,
|
||||
struct rsnd_priv *priv)
|
||||
{
|
||||
struct rsnd_dma *dma = rsnd_mod_to_dma(mod);
|
||||
|
||||
rsnd_ssi_stop(mod, priv);
|
||||
rsnd_ssi_stop(mod, io, priv);
|
||||
|
||||
rsnd_dma_stop(dma);
|
||||
rsnd_dma_stop(io, dma);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct dma_chan *rsnd_ssi_dma_req(struct rsnd_mod *mod)
|
||||
static struct dma_chan *rsnd_ssi_dma_req(struct rsnd_dai_stream *io,
|
||||
struct rsnd_mod *mod)
|
||||
{
|
||||
struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
|
||||
struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
|
||||
int is_play = rsnd_io_is_play(io);
|
||||
char *name;
|
||||
|
||||
if (rsnd_ssi_use_busif(mod))
|
||||
if (rsnd_ssi_use_busif(io, mod))
|
||||
name = is_play ? "rxu" : "txu";
|
||||
else
|
||||
name = is_play ? "rx" : "tx";
|
||||
|
@ -776,7 +796,7 @@ int rsnd_ssi_probe(struct platform_device *pdev,
|
|||
else if (rsnd_ssi_pio_available(ssi))
|
||||
ops = &rsnd_ssi_pio_ops;
|
||||
|
||||
ret = rsnd_mod_init(&ssi->mod, ops, clk, RSND_MOD_SSI, i);
|
||||
ret = rsnd_mod_init(priv, &ssi->mod, ops, clk, RSND_MOD_SSI, i);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
|
Loading…
Reference in New Issue