asoc: clean up audio-drivers
Remove backend cpu dai driver Change-Id: Ibe7bdbc765970f8eab57562858c1caf3ed8ecc7b Signed-off-by: Taha Azzaoui <tazzaoui@codeaurora.org>
This commit is contained in:

committed by
Gerrit - the friendly Code Review server

parent
f8d25f4dfb
commit
31670c14e6
@@ -151,13 +151,8 @@ ifdef CONFIG_SND_SOC_SA8155
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
ifdef CONFIG_SND_SOC_QDSP6V2
|
ifdef CONFIG_SND_SOC_QDSP6V2
|
||||||
PLATFORM_OBJS += msm-dai-q6-hdmi-v2.o
|
|
||||||
PLATFORM_OBJS += msm-dai-q6-v2.o
|
|
||||||
PLATFORM_OBJS += platform_init.o
|
PLATFORM_OBJS += platform_init.o
|
||||||
endif
|
endif
|
||||||
ifdef CONFIG_WCD9XXX_CODEC_CORE
|
|
||||||
PLATFORM_OBJS += msm-dai-slim.o
|
|
||||||
endif
|
|
||||||
|
|
||||||
LINUX_INC += -Iinclude/linux
|
LINUX_INC += -Iinclude/linux
|
||||||
|
|
||||||
|
@@ -1,701 +0,0 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-only
|
|
||||||
/* Copyright (c) 2012-2020, The Linux Foundation. All rights reserved.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <linux/init.h>
|
|
||||||
#include <linux/module.h>
|
|
||||||
#include <linux/device.h>
|
|
||||||
#include <linux/platform_device.h>
|
|
||||||
#include <linux/bitops.h>
|
|
||||||
#include <linux/slab.h>
|
|
||||||
#include <linux/of_device.h>
|
|
||||||
#include <sound/core.h>
|
|
||||||
#include <sound/pcm.h>
|
|
||||||
#include <sound/soc.h>
|
|
||||||
#include <sound/pcm_params.h>
|
|
||||||
#include <dsp/apr_audio-v2.h>
|
|
||||||
#include "msm-dai-q6-v2.h"
|
|
||||||
|
|
||||||
#define HDMI_RX_CA_MAX 0x32
|
|
||||||
|
|
||||||
enum {
|
|
||||||
DP_CONTROLLER0 = 0,
|
|
||||||
DP_CONTROLLER1,
|
|
||||||
DP_CONTROLLER_MAX,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum {
|
|
||||||
DP_STREAM0 = 0,
|
|
||||||
DP_STREAM1,
|
|
||||||
DP_STREAM_MAX,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum {
|
|
||||||
STATUS_PORT_STARTED, /* track if AFE port has started */
|
|
||||||
STATUS_MAX
|
|
||||||
};
|
|
||||||
|
|
||||||
struct msm_ext_disp_ca {
|
|
||||||
bool set_ca;
|
|
||||||
u32 ca;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct msm_dai_q6_hdmi_dai_data {
|
|
||||||
DECLARE_BITMAP(status_mask, STATUS_MAX);
|
|
||||||
u32 rate;
|
|
||||||
u32 channels;
|
|
||||||
u32 stream_idx;
|
|
||||||
u32 ctl_idx;
|
|
||||||
struct msm_ext_disp_ca ca;
|
|
||||||
union afe_port_config port_config;
|
|
||||||
};
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
static int get_port_id(int dai_id)
|
|
||||||
{
|
|
||||||
/* Currently, display devices share a common AFE port */
|
|
||||||
if (dai_id != HDMI_RX)
|
|
||||||
return DISPLAY_PORT_RX;
|
|
||||||
|
|
||||||
return dai_id;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static int msm_dai_q6_ext_disp_format_put(struct snd_kcontrol *kcontrol,
|
|
||||||
struct snd_ctl_elem_value *ucontrol)
|
|
||||||
{
|
|
||||||
struct msm_dai_q6_hdmi_dai_data *dai_data = kcontrol->private_data;
|
|
||||||
int value = ucontrol->value.integer.value[0];
|
|
||||||
|
|
||||||
if (!dai_data) {
|
|
||||||
pr_err("%s: dai_data is NULL\n", __func__);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
dai_data->port_config.hdmi_multi_ch.datatype = value;
|
|
||||||
pr_debug("%s: value = %d\n", __func__, value);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int msm_dai_q6_ext_disp_format_get(struct snd_kcontrol *kcontrol,
|
|
||||||
struct snd_ctl_elem_value *ucontrol)
|
|
||||||
{
|
|
||||||
struct msm_dai_q6_hdmi_dai_data *dai_data = kcontrol->private_data;
|
|
||||||
|
|
||||||
if (!dai_data) {
|
|
||||||
pr_err("%s: dai_data is NULL\n", __func__);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ucontrol->value.integer.value[0] =
|
|
||||||
dai_data->port_config.hdmi_multi_ch.datatype;
|
|
||||||
pr_debug("%s: value = %ld\n",
|
|
||||||
__func__, ucontrol->value.integer.value[0]);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int msm_dai_q6_ext_disp_device_idx_put(struct snd_kcontrol *kcontrol,
|
|
||||||
struct snd_ctl_elem_value *ucontrol)
|
|
||||||
{
|
|
||||||
struct msm_dai_q6_hdmi_dai_data *dai_data = kcontrol->private_data;
|
|
||||||
|
|
||||||
if (!dai_data) {
|
|
||||||
pr_err("%s: dai_data is NULL\n", __func__);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((ucontrol->value.integer.value[0] > (DP_CONTROLLER_MAX - 1)) ||
|
|
||||||
(ucontrol->value.integer.value[1] > (DP_STREAM_MAX - 1)) ||
|
|
||||||
(ucontrol->value.integer.value[0] < 0) ||
|
|
||||||
(ucontrol->value.integer.value[1] < 0)) {
|
|
||||||
pr_err("%s: DP control index invalid\n", __func__);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
dai_data->ctl_idx = ucontrol->value.integer.value[0];
|
|
||||||
dai_data->stream_idx = ucontrol->value.integer.value[1];
|
|
||||||
pr_debug("%s: DP ctl id %d stream id %d\n", __func__,
|
|
||||||
dai_data->ctl_idx, dai_data->stream_idx);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int msm_dai_q6_ext_disp_device_idx_get(struct snd_kcontrol *kcontrol,
|
|
||||||
struct snd_ctl_elem_value *ucontrol)
|
|
||||||
{
|
|
||||||
struct msm_dai_q6_hdmi_dai_data *dai_data = kcontrol->private_data;
|
|
||||||
|
|
||||||
if (!dai_data) {
|
|
||||||
pr_err("%s: dai_data is NULL\n", __func__);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ucontrol->value.integer.value[0] = dai_data->ctl_idx;
|
|
||||||
ucontrol->value.integer.value[1] = dai_data->stream_idx;
|
|
||||||
pr_debug("%s: DP ctl id %d stream id %d\n", __func__,
|
|
||||||
dai_data->ctl_idx, dai_data->stream_idx);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int msm_dai_q6_ext_disp_ca_put(struct snd_kcontrol *kcontrol,
|
|
||||||
struct snd_ctl_elem_value *ucontrol)
|
|
||||||
{
|
|
||||||
struct msm_dai_q6_hdmi_dai_data *dai_data = kcontrol->private_data;
|
|
||||||
|
|
||||||
if (!dai_data) {
|
|
||||||
pr_err("%s: dai_data is NULL\n", __func__);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
dai_data->ca.ca = ucontrol->value.integer.value[0];
|
|
||||||
dai_data->ca.set_ca = true;
|
|
||||||
pr_debug("%s: ca = %d\n", __func__, dai_data->ca.ca);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int msm_dai_q6_ext_disp_ca_get(struct snd_kcontrol *kcontrol,
|
|
||||||
struct snd_ctl_elem_value *ucontrol)
|
|
||||||
{
|
|
||||||
struct msm_dai_q6_hdmi_dai_data *dai_data = kcontrol->private_data;
|
|
||||||
|
|
||||||
if (!dai_data) {
|
|
||||||
pr_err("%s: dai_data is NULL\n", __func__);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ucontrol->value.integer.value[0] = dai_data->ca.ca;
|
|
||||||
pr_debug("%s: ca = %d\n", __func__, dai_data->ca.ca);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* HDMI format field for AFE_PORT_MULTI_CHAN_HDMI_AUDIO_IF_CONFIG command
|
|
||||||
* 0: linear PCM
|
|
||||||
* 1: non-linear PCM
|
|
||||||
*/
|
|
||||||
static const char * const hdmi_format[] = {
|
|
||||||
"LPCM",
|
|
||||||
"Compr"
|
|
||||||
};
|
|
||||||
|
|
||||||
static const struct soc_enum hdmi_config_enum[] = {
|
|
||||||
SOC_ENUM_SINGLE_EXT(2, hdmi_format),
|
|
||||||
};
|
|
||||||
|
|
||||||
static int msm_dai_q6_ext_disp_drift_info(struct snd_kcontrol *kcontrol,
|
|
||||||
struct snd_ctl_elem_info *uinfo)
|
|
||||||
{
|
|
||||||
uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
|
|
||||||
uinfo->count = sizeof(struct afe_param_id_dev_timing_stats);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int msm_dai_q6_ext_disp_drift_get(struct snd_kcontrol *kcontrol,
|
|
||||||
struct snd_ctl_elem_value *ucontrol)
|
|
||||||
{
|
|
||||||
#if 0
|
|
||||||
int ret = -EINVAL;
|
|
||||||
struct afe_param_id_dev_timing_stats timing_stats;
|
|
||||||
struct snd_soc_dai *dai = kcontrol->private_data;
|
|
||||||
struct msm_dai_q6_hdmi_dai_data *dai_data = dev_get_drvdata(dai->dev);
|
|
||||||
|
|
||||||
if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
|
|
||||||
pr_debug("%s: afe port not started. status_mask = %ld\n",
|
|
||||||
__func__, *dai_data->status_mask);
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(&timing_stats, 0, sizeof(struct afe_param_id_dev_timing_stats));
|
|
||||||
ret = afe_get_av_dev_drift(&timing_stats, get_port_id(dai->id));
|
|
||||||
if (ret) {
|
|
||||||
pr_err("%s: Error getting AFE Drift for port %d, err=%d\n",
|
|
||||||
__func__, get_port_id(dai->id), ret);
|
|
||||||
|
|
||||||
ret = -EINVAL;
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(ucontrol->value.bytes.data, (void *)&timing_stats,
|
|
||||||
sizeof(struct afe_param_id_dev_timing_stats));
|
|
||||||
done:
|
|
||||||
return ret;
|
|
||||||
#endif
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct snd_kcontrol_new hdmi_config_controls[] = {
|
|
||||||
SOC_ENUM_EXT("HDMI RX Format", hdmi_config_enum[0],
|
|
||||||
msm_dai_q6_ext_disp_format_get,
|
|
||||||
msm_dai_q6_ext_disp_format_put),
|
|
||||||
SOC_SINGLE_MULTI_EXT("HDMI RX CA", SND_SOC_NOPM, 0,
|
|
||||||
HDMI_RX_CA_MAX, 0, 1,
|
|
||||||
msm_dai_q6_ext_disp_ca_get,
|
|
||||||
msm_dai_q6_ext_disp_ca_put),
|
|
||||||
{
|
|
||||||
.access = SNDRV_CTL_ELEM_ACCESS_READ,
|
|
||||||
.iface = SNDRV_CTL_ELEM_IFACE_PCM,
|
|
||||||
.name = "HDMI DRIFT",
|
|
||||||
.info = msm_dai_q6_ext_disp_drift_info,
|
|
||||||
.get = msm_dai_q6_ext_disp_drift_get,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
static const struct snd_kcontrol_new display_port_config_controls[] = {
|
|
||||||
SOC_ENUM_EXT("Display Port RX Format", hdmi_config_enum[0],
|
|
||||||
msm_dai_q6_ext_disp_format_get,
|
|
||||||
msm_dai_q6_ext_disp_format_put),
|
|
||||||
SOC_SINGLE_MULTI_EXT("Display Port RX CA", SND_SOC_NOPM, 0,
|
|
||||||
HDMI_RX_CA_MAX, 0, 1,
|
|
||||||
msm_dai_q6_ext_disp_ca_get,
|
|
||||||
msm_dai_q6_ext_disp_ca_put),
|
|
||||||
SOC_SINGLE_MULTI_EXT("Display Port RX DEVICE IDX", SND_SOC_NOPM, 0,
|
|
||||||
1, 0, 2,
|
|
||||||
msm_dai_q6_ext_disp_device_idx_get,
|
|
||||||
msm_dai_q6_ext_disp_device_idx_put),
|
|
||||||
{
|
|
||||||
.access = SNDRV_CTL_ELEM_ACCESS_READ,
|
|
||||||
.iface = SNDRV_CTL_ELEM_IFACE_PCM,
|
|
||||||
.name = "DISPLAY_PORT DRIFT",
|
|
||||||
.info = msm_dai_q6_ext_disp_drift_info,
|
|
||||||
.get = msm_dai_q6_ext_disp_drift_get,
|
|
||||||
},
|
|
||||||
SOC_ENUM_EXT("Display Port1 RX Format", hdmi_config_enum[0],
|
|
||||||
msm_dai_q6_ext_disp_format_get,
|
|
||||||
msm_dai_q6_ext_disp_format_put),
|
|
||||||
SOC_SINGLE_MULTI_EXT("Display Port1 RX CA", SND_SOC_NOPM, 0,
|
|
||||||
HDMI_RX_CA_MAX, 0, 1,
|
|
||||||
msm_dai_q6_ext_disp_ca_get,
|
|
||||||
msm_dai_q6_ext_disp_ca_put),
|
|
||||||
SOC_SINGLE_MULTI_EXT("Display Port1 RX DEVICE IDX", SND_SOC_NOPM, 0,
|
|
||||||
1, 0, 2,
|
|
||||||
msm_dai_q6_ext_disp_device_idx_get,
|
|
||||||
msm_dai_q6_ext_disp_device_idx_put),
|
|
||||||
{
|
|
||||||
.access = SNDRV_CTL_ELEM_ACCESS_READ,
|
|
||||||
.iface = SNDRV_CTL_ELEM_IFACE_PCM,
|
|
||||||
.name = "DISPLAY_PORT1 DRIFT",
|
|
||||||
.info = msm_dai_q6_ext_disp_drift_info,
|
|
||||||
.get = msm_dai_q6_ext_disp_drift_get,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Current implementation assumes hw_param is called once
|
|
||||||
* This may not be the case but what to do when ADM and AFE
|
|
||||||
* port are already opened and parameter changes
|
|
||||||
*/
|
|
||||||
static int msm_dai_q6_hdmi_hw_params(struct snd_pcm_substream *substream,
|
|
||||||
struct snd_pcm_hw_params *params,
|
|
||||||
struct snd_soc_dai *dai)
|
|
||||||
{
|
|
||||||
struct msm_dai_q6_hdmi_dai_data *dai_data = dev_get_drvdata(dai->dev);
|
|
||||||
|
|
||||||
dai_data->channels = params_channels(params);
|
|
||||||
dai_data->rate = params_rate(params);
|
|
||||||
dai_data->port_config.hdmi_multi_ch.reserved = 0;
|
|
||||||
dai_data->port_config.hdmi_multi_ch.hdmi_cfg_minor_version = 1;
|
|
||||||
dai_data->port_config.hdmi_multi_ch.sample_rate = dai_data->rate;
|
|
||||||
switch (params_format(params)) {
|
|
||||||
case SNDRV_PCM_FORMAT_S16_LE:
|
|
||||||
dai_data->port_config.hdmi_multi_ch.bit_width = 16;
|
|
||||||
break;
|
|
||||||
case SNDRV_PCM_FORMAT_S24_LE:
|
|
||||||
case SNDRV_PCM_FORMAT_S24_3LE:
|
|
||||||
dai_data->port_config.hdmi_multi_ch.bit_width = 24;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*refer to HDMI spec CEA-861-E: Table 28 Audio InfoFrame Data Byte 4*/
|
|
||||||
switch (dai_data->channels) {
|
|
||||||
case 2:
|
|
||||||
dai_data->port_config.hdmi_multi_ch.channel_allocation = 0;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
dai_data->port_config.hdmi_multi_ch.channel_allocation = 0x02;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
dai_data->port_config.hdmi_multi_ch.channel_allocation = 0x06;
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
dai_data->port_config.hdmi_multi_ch.channel_allocation = 0x0A;
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
dai_data->port_config.hdmi_multi_ch.channel_allocation = 0x0B;
|
|
||||||
break;
|
|
||||||
case 7:
|
|
||||||
dai_data->port_config.hdmi_multi_ch.channel_allocation = 0x12;
|
|
||||||
break;
|
|
||||||
case 8:
|
|
||||||
dai_data->port_config.hdmi_multi_ch.channel_allocation = 0x13;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
dev_err(dai->dev, "invalid Channels = %u\n",
|
|
||||||
dai_data->channels);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
dev_dbg(dai->dev, "%s() minor version: %u samplerate: %u bitwidth: %u\n"
|
|
||||||
"num_ch = %u channel_allocation = %u datatype = %d\n", __func__,
|
|
||||||
dai_data->port_config.hdmi_multi_ch.hdmi_cfg_minor_version,
|
|
||||||
dai_data->port_config.hdmi_multi_ch.sample_rate,
|
|
||||||
dai_data->port_config.hdmi_multi_ch.bit_width,
|
|
||||||
dai_data->channels,
|
|
||||||
dai_data->port_config.hdmi_multi_ch.channel_allocation,
|
|
||||||
dai_data->port_config.hdmi_multi_ch.datatype);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void msm_dai_q6_hdmi_shutdown(struct snd_pcm_substream *substream,
|
|
||||||
struct snd_soc_dai *dai)
|
|
||||||
{
|
|
||||||
struct msm_dai_q6_hdmi_dai_data *dai_data = dev_get_drvdata(dai->dev);
|
|
||||||
// int rc = 0;
|
|
||||||
|
|
||||||
if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
|
|
||||||
pr_info("%s: afe port not started. dai_data->status_mask = %ld\n",
|
|
||||||
__func__, *dai_data->status_mask);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#if 0
|
|
||||||
rc = afe_close(get_port_id(dai->id)); /* can block */
|
|
||||||
if (rc < 0)
|
|
||||||
dev_err(dai->dev, "fail to close AFE port\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
pr_debug("%s: dai_data->status_mask = %ld\n", __func__,
|
|
||||||
*dai_data->status_mask);
|
|
||||||
|
|
||||||
clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int msm_dai_q6_hdmi_prepare(struct snd_pcm_substream *substream,
|
|
||||||
struct snd_soc_dai *dai)
|
|
||||||
{
|
|
||||||
struct msm_dai_q6_hdmi_dai_data *dai_data = dev_get_drvdata(dai->dev);
|
|
||||||
int rc = 0;
|
|
||||||
|
|
||||||
if (dai_data->ca.set_ca)
|
|
||||||
dai_data->port_config.hdmi_multi_ch.channel_allocation =
|
|
||||||
dai_data->ca.ca;
|
|
||||||
|
|
||||||
if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
|
|
||||||
#if 0
|
|
||||||
rc = afe_set_display_stream(get_port_id(dai->id), dai_data->stream_idx,
|
|
||||||
dai_data->ctl_idx);
|
|
||||||
if (rc < 0) {
|
|
||||||
dev_err(dai->dev, "fail to set AFE ctl, stream ID params %x\n",
|
|
||||||
dai->id);
|
|
||||||
if (rc != -EOPNOTSUPP) {
|
|
||||||
dev_err(dai->dev, "not starting AFE port\n");
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = afe_port_start(get_port_id(dai->id), &dai_data->port_config,
|
|
||||||
dai_data->rate);
|
|
||||||
if (rc < 0)
|
|
||||||
dev_err(dai->dev, "fail to open AFE port %x\n",
|
|
||||||
get_port_id(dai->id));
|
|
||||||
else
|
|
||||||
set_bit(STATUS_PORT_STARTED,
|
|
||||||
dai_data->status_mask);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
//err:
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void msm_dai_q6_hdmi_set_dai_id(struct snd_soc_dai *dai)
|
|
||||||
{
|
|
||||||
if (!dai->driver->id) {
|
|
||||||
dev_warn(dai->dev, "DAI driver id is not set\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
dai->id = dai->driver->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int msm_dai_q6_hdmi_dai_probe(struct snd_soc_dai *dai)
|
|
||||||
{
|
|
||||||
struct msm_dai_q6_hdmi_dai_data *dai_data;
|
|
||||||
const struct snd_kcontrol_new *kcontrol;
|
|
||||||
int rc = 0;
|
|
||||||
struct snd_soc_dapm_route intercon;
|
|
||||||
struct snd_soc_dapm_context *dapm;
|
|
||||||
|
|
||||||
if (!dai || !dai->driver) {
|
|
||||||
pr_err("%s: dai or dai->driver is NULL\n", __func__);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
dai_data = kzalloc(sizeof(struct msm_dai_q6_hdmi_dai_data),
|
|
||||||
GFP_KERNEL);
|
|
||||||
|
|
||||||
if (!dai_data) {
|
|
||||||
dev_err(dai->dev, "DAI-%d: fail to allocate dai data\n",
|
|
||||||
dai->id);
|
|
||||||
rc = -ENOMEM;
|
|
||||||
} else
|
|
||||||
dev_set_drvdata(dai->dev, dai_data);
|
|
||||||
|
|
||||||
msm_dai_q6_hdmi_set_dai_id(dai);
|
|
||||||
|
|
||||||
if (dai->driver->id == HDMI_RX) {
|
|
||||||
kcontrol = &hdmi_config_controls[0];
|
|
||||||
rc = snd_ctl_add(dai->component->card->snd_card,
|
|
||||||
snd_ctl_new1(kcontrol, dai_data));
|
|
||||||
|
|
||||||
kcontrol = &hdmi_config_controls[1];
|
|
||||||
rc = snd_ctl_add(dai->component->card->snd_card,
|
|
||||||
snd_ctl_new1(kcontrol, dai_data));
|
|
||||||
|
|
||||||
kcontrol = &hdmi_config_controls[2];
|
|
||||||
rc = snd_ctl_add(dai->component->card->snd_card,
|
|
||||||
snd_ctl_new1(kcontrol, dai));
|
|
||||||
} else if (dai->driver->id == MSM_DISPLAY_PORT) {
|
|
||||||
kcontrol = &display_port_config_controls[0];
|
|
||||||
rc = snd_ctl_add(dai->component->card->snd_card,
|
|
||||||
snd_ctl_new1(kcontrol, dai_data));
|
|
||||||
|
|
||||||
kcontrol = &display_port_config_controls[1];
|
|
||||||
rc = snd_ctl_add(dai->component->card->snd_card,
|
|
||||||
snd_ctl_new1(kcontrol, dai_data));
|
|
||||||
|
|
||||||
kcontrol = &display_port_config_controls[2];
|
|
||||||
rc = snd_ctl_add(dai->component->card->snd_card,
|
|
||||||
snd_ctl_new1(kcontrol, dai_data));
|
|
||||||
|
|
||||||
kcontrol = &display_port_config_controls[3];
|
|
||||||
rc = snd_ctl_add(dai->component->card->snd_card,
|
|
||||||
snd_ctl_new1(kcontrol, dai));
|
|
||||||
} else if (dai->driver->id == MSM_DISPLAY_PORT1) {
|
|
||||||
kcontrol = &display_port_config_controls[4];
|
|
||||||
rc = snd_ctl_add(dai->component->card->snd_card,
|
|
||||||
snd_ctl_new1(kcontrol, dai_data));
|
|
||||||
|
|
||||||
kcontrol = &display_port_config_controls[5];
|
|
||||||
rc = snd_ctl_add(dai->component->card->snd_card,
|
|
||||||
snd_ctl_new1(kcontrol, dai_data));
|
|
||||||
|
|
||||||
kcontrol = &display_port_config_controls[6];
|
|
||||||
rc = snd_ctl_add(dai->component->card->snd_card,
|
|
||||||
snd_ctl_new1(kcontrol, dai_data));
|
|
||||||
|
|
||||||
kcontrol = &display_port_config_controls[7];
|
|
||||||
rc = snd_ctl_add(dai->component->card->snd_card,
|
|
||||||
snd_ctl_new1(kcontrol, dai));
|
|
||||||
} else {
|
|
||||||
dev_err(dai->dev, "%s: Invalid id:%d\n",
|
|
||||||
__func__, dai->driver->id);
|
|
||||||
kfree(dai_data);
|
|
||||||
dev_set_drvdata(dai->dev, NULL);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
dapm = snd_soc_component_get_dapm(dai->component);
|
|
||||||
memset(&intercon, 0, sizeof(intercon));
|
|
||||||
if (!rc) {
|
|
||||||
if (dai->driver->playback.stream_name &&
|
|
||||||
dai->driver->playback.aif_name) {
|
|
||||||
dev_dbg(dai->dev, "%s add route for widget %s",
|
|
||||||
__func__, dai->driver->playback.stream_name);
|
|
||||||
intercon.source = dai->driver->playback.aif_name;
|
|
||||||
intercon.sink = dai->driver->playback.stream_name;
|
|
||||||
dev_dbg(dai->dev, "%s src %s sink %s\n",
|
|
||||||
__func__, intercon.source, intercon.sink);
|
|
||||||
snd_soc_dapm_add_routes(dapm, &intercon, 1);
|
|
||||||
}
|
|
||||||
if (dai->driver->capture.stream_name &&
|
|
||||||
dai->driver->capture.aif_name) {
|
|
||||||
dev_dbg(dai->dev, "%s add route for widget %s",
|
|
||||||
__func__, dai->driver->capture.stream_name);
|
|
||||||
intercon.sink = dai->driver->capture.aif_name;
|
|
||||||
intercon.source = dai->driver->capture.stream_name;
|
|
||||||
dev_dbg(dai->dev, "%s src %s sink %s\n",
|
|
||||||
__func__, intercon.source, intercon.sink);
|
|
||||||
snd_soc_dapm_add_routes(dapm, &intercon, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int msm_dai_q6_hdmi_dai_remove(struct snd_soc_dai *dai)
|
|
||||||
{
|
|
||||||
struct msm_dai_q6_hdmi_dai_data *dai_data;
|
|
||||||
// int rc;
|
|
||||||
|
|
||||||
dai_data = dev_get_drvdata(dai->dev);
|
|
||||||
|
|
||||||
/* If AFE port is still up, close it */
|
|
||||||
if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
|
|
||||||
#if 0
|
|
||||||
rc = afe_close(get_port_id(dai->id)); /* can block */
|
|
||||||
if (rc < 0)
|
|
||||||
dev_err(dai->dev, "fail to close AFE port\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
|
|
||||||
}
|
|
||||||
kfree(dai_data);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct snd_soc_dai_ops msm_dai_q6_hdmi_ops = {
|
|
||||||
.prepare = msm_dai_q6_hdmi_prepare,
|
|
||||||
.hw_params = msm_dai_q6_hdmi_hw_params,
|
|
||||||
.shutdown = msm_dai_q6_hdmi_shutdown,
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct snd_soc_dai_driver msm_dai_q6_hdmi_hdmi_rx_dai = {
|
|
||||||
.playback = {
|
|
||||||
.stream_name = "HDMI Playback",
|
|
||||||
.aif_name = "HDMI",
|
|
||||||
.rates = SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
|
|
||||||
SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
|
|
||||||
SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
|
|
||||||
SNDRV_PCM_RATE_192000,
|
|
||||||
.formats = SNDRV_PCM_FMTBIT_S16_LE |
|
|
||||||
SNDRV_PCM_FMTBIT_S24_LE |
|
|
||||||
SNDRV_PCM_FMTBIT_S24_3LE,
|
|
||||||
.channels_min = 2,
|
|
||||||
.channels_max = 8,
|
|
||||||
.rate_max = 192000,
|
|
||||||
.rate_min = 48000,
|
|
||||||
},
|
|
||||||
.ops = &msm_dai_q6_hdmi_ops,
|
|
||||||
.id = HDMI_RX,
|
|
||||||
.probe = msm_dai_q6_hdmi_dai_probe,
|
|
||||||
.remove = msm_dai_q6_hdmi_dai_remove,
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct snd_soc_dai_driver msm_dai_q6_display_port_rx_dai[] = {
|
|
||||||
{
|
|
||||||
.playback = {
|
|
||||||
.stream_name = "Display Port Playback",
|
|
||||||
.aif_name = "DISPLAY_PORT",
|
|
||||||
.rates = SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
|
|
||||||
SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
|
|
||||||
SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
|
|
||||||
SNDRV_PCM_RATE_192000,
|
|
||||||
.formats = SNDRV_PCM_FMTBIT_S16_LE |
|
|
||||||
SNDRV_PCM_FMTBIT_S24_LE |
|
|
||||||
SNDRV_PCM_FMTBIT_S24_3LE,
|
|
||||||
.channels_min = 2,
|
|
||||||
.channels_max = 8,
|
|
||||||
.rate_max = 192000,
|
|
||||||
.rate_min = 48000,
|
|
||||||
},
|
|
||||||
.ops = &msm_dai_q6_hdmi_ops,
|
|
||||||
.id = MSM_DISPLAY_PORT,
|
|
||||||
.probe = msm_dai_q6_hdmi_dai_probe,
|
|
||||||
.remove = msm_dai_q6_hdmi_dai_remove,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.playback = {
|
|
||||||
.stream_name = "Display Port1 Playback",
|
|
||||||
.aif_name = "DISPLAY_PORT1",
|
|
||||||
.rates = SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
|
|
||||||
SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
|
|
||||||
SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
|
|
||||||
SNDRV_PCM_RATE_192000,
|
|
||||||
.formats = SNDRV_PCM_FMTBIT_S16_LE |
|
|
||||||
SNDRV_PCM_FMTBIT_S24_LE |
|
|
||||||
SNDRV_PCM_FMTBIT_S24_3LE,
|
|
||||||
.channels_min = 2,
|
|
||||||
.channels_max = 8,
|
|
||||||
.rate_max = 192000,
|
|
||||||
.rate_min = 48000,
|
|
||||||
},
|
|
||||||
.ops = &msm_dai_q6_hdmi_ops,
|
|
||||||
.id = MSM_DISPLAY_PORT1,
|
|
||||||
.probe = msm_dai_q6_hdmi_dai_probe,
|
|
||||||
.remove = msm_dai_q6_hdmi_dai_remove,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
static const struct snd_soc_component_driver msm_dai_hdmi_q6_component = {
|
|
||||||
.name = "msm-dai-q6-hdmi",
|
|
||||||
};
|
|
||||||
|
|
||||||
/* To do: change to register DAIs as batch */
|
|
||||||
static int msm_dai_q6_hdmi_dev_probe(struct platform_device *pdev)
|
|
||||||
{
|
|
||||||
int rc, id;
|
|
||||||
const char *q6_dev_id = "qcom,msm-dai-q6-dev-id";
|
|
||||||
|
|
||||||
rc = of_property_read_u32(pdev->dev.of_node, q6_dev_id, &id);
|
|
||||||
if (rc) {
|
|
||||||
dev_err(&pdev->dev,
|
|
||||||
"%s: missing %s in dt node\n", __func__, q6_dev_id);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
pdev->id = id;
|
|
||||||
|
|
||||||
pr_debug("%s: dev name %s, id:%d\n", __func__,
|
|
||||||
dev_name(&pdev->dev), pdev->id);
|
|
||||||
|
|
||||||
switch (pdev->id) {
|
|
||||||
case HDMI_RX:
|
|
||||||
rc = snd_soc_register_component(&pdev->dev,
|
|
||||||
&msm_dai_hdmi_q6_component,
|
|
||||||
&msm_dai_q6_hdmi_hdmi_rx_dai, 1);
|
|
||||||
break;
|
|
||||||
case MSM_DISPLAY_PORT:
|
|
||||||
rc = snd_soc_register_component(&pdev->dev,
|
|
||||||
&msm_dai_hdmi_q6_component,
|
|
||||||
&msm_dai_q6_display_port_rx_dai[0], 1);
|
|
||||||
break;
|
|
||||||
case MSM_DISPLAY_PORT1:
|
|
||||||
rc = snd_soc_register_component(&pdev->dev,
|
|
||||||
&msm_dai_hdmi_q6_component,
|
|
||||||
&msm_dai_q6_display_port_rx_dai[1], 1);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
dev_err(&pdev->dev, "invalid device ID %d\n", pdev->id);
|
|
||||||
rc = -ENODEV;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int msm_dai_q6_hdmi_dev_remove(struct platform_device *pdev)
|
|
||||||
{
|
|
||||||
snd_soc_unregister_component(&pdev->dev);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct of_device_id msm_dai_q6_hdmi_dt_match[] = {
|
|
||||||
{.compatible = "qcom,msm-dai-q6-hdmi"},
|
|
||||||
{}
|
|
||||||
};
|
|
||||||
MODULE_DEVICE_TABLE(of, msm_dai_q6_hdmi_dt_match);
|
|
||||||
|
|
||||||
static struct platform_driver msm_dai_q6_hdmi_driver = {
|
|
||||||
.probe = msm_dai_q6_hdmi_dev_probe,
|
|
||||||
.remove = msm_dai_q6_hdmi_dev_remove,
|
|
||||||
.driver = {
|
|
||||||
.name = "msm-dai-q6-hdmi",
|
|
||||||
.owner = THIS_MODULE,
|
|
||||||
.of_match_table = msm_dai_q6_hdmi_dt_match,
|
|
||||||
.suppress_bind_attrs = true,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
int __init msm_dai_q6_hdmi_init(void)
|
|
||||||
{
|
|
||||||
return platform_driver_register(&msm_dai_q6_hdmi_driver);
|
|
||||||
}
|
|
||||||
|
|
||||||
void msm_dai_q6_hdmi_exit(void)
|
|
||||||
{
|
|
||||||
platform_driver_unregister(&msm_dai_q6_hdmi_driver);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Module information */
|
|
||||||
MODULE_DESCRIPTION("MSM DSP HDMI DAI driver");
|
|
||||||
MODULE_LICENSE("GPL v2");
|
|
6588
asoc/msm-dai-q6-v2.c
6588
asoc/msm-dai-q6-v2.c
File diff suppressed because it is too large
Load Diff
@@ -1,108 +0,0 @@
|
|||||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
||||||
/* Copyright (c) 2012-2017, 2019 The Linux Foundation. All rights reserved.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __MSM_DAI_Q6_PDATA_H__
|
|
||||||
|
|
||||||
#define __MSM_DAI_Q6_PDATA_H__
|
|
||||||
|
|
||||||
#define MSM_MI2S_SD0 (1 << 0)
|
|
||||||
#define MSM_MI2S_SD1 (1 << 1)
|
|
||||||
#define MSM_MI2S_SD2 (1 << 2)
|
|
||||||
#define MSM_MI2S_SD3 (1 << 3)
|
|
||||||
#define MSM_MI2S_SD4 (1 << 4)
|
|
||||||
#define MSM_MI2S_SD5 (1 << 5)
|
|
||||||
#define MSM_MI2S_SD6 (1 << 6)
|
|
||||||
#define MSM_MI2S_SD7 (1 << 7)
|
|
||||||
|
|
||||||
#define MSM_MI2S_CAP_RX 0
|
|
||||||
#define MSM_MI2S_CAP_TX 1
|
|
||||||
|
|
||||||
#define MSM_PRIM_MI2S 0
|
|
||||||
#define MSM_SEC_MI2S 1
|
|
||||||
#define MSM_TERT_MI2S 2
|
|
||||||
#define MSM_QUAT_MI2S 3
|
|
||||||
#define MSM_QUIN_MI2S 4
|
|
||||||
#define MSM_SENARY_MI2S 5
|
|
||||||
#define MSM_SEC_MI2S_SD1 6
|
|
||||||
#define MSM_INT0_MI2S 7
|
|
||||||
#define MSM_INT1_MI2S 8
|
|
||||||
#define MSM_INT2_MI2S 9
|
|
||||||
#define MSM_INT3_MI2S 10
|
|
||||||
#define MSM_INT4_MI2S 11
|
|
||||||
#define MSM_INT5_MI2S 12
|
|
||||||
#define MSM_INT6_MI2S 13
|
|
||||||
#define MSM_MI2S_MIN MSM_PRIM_MI2S
|
|
||||||
#define MSM_MI2S_MAX MSM_INT6_MI2S
|
|
||||||
|
|
||||||
#define MSM_DISPLAY_PORT 0
|
|
||||||
#define MSM_DISPLAY_PORT1 1
|
|
||||||
|
|
||||||
#define MSM_PRIM_META_MI2S 0
|
|
||||||
#define MSM_SEC_META_MI2S 1
|
|
||||||
#define MSM_META_MI2S_MIN MSM_PRIM_META_MI2S
|
|
||||||
#define MSM_META_MI2S_MAX MSM_SEC_META_MI2S
|
|
||||||
|
|
||||||
#define MAX_NUM_I2S_META_PORT_MEMBER_PORTS 4
|
|
||||||
|
|
||||||
struct msm_dai_auxpcm_config {
|
|
||||||
u16 mode;
|
|
||||||
u16 sync;
|
|
||||||
u16 frame;
|
|
||||||
u16 quant;
|
|
||||||
u16 num_slots;
|
|
||||||
u16 *slot_mapping;
|
|
||||||
u16 data;
|
|
||||||
u32 pcm_clk_rate;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct msm_dai_auxpcm_pdata {
|
|
||||||
struct msm_dai_auxpcm_config mode_8k;
|
|
||||||
struct msm_dai_auxpcm_config mode_16k;
|
|
||||||
struct msm_dai_auxpcm_config mode_32k;
|
|
||||||
struct msm_dai_auxpcm_config mode_48k;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct msm_mi2s_pdata {
|
|
||||||
u16 rx_sd_lines;
|
|
||||||
u16 tx_sd_lines;
|
|
||||||
u16 intf_id;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct msm_meta_mi2s_pdata {
|
|
||||||
u32 num_member_ports;
|
|
||||||
u32 member_port[MAX_NUM_I2S_META_PORT_MEMBER_PORTS];
|
|
||||||
u32 sd_lines[MAX_NUM_I2S_META_PORT_MEMBER_PORTS];
|
|
||||||
u16 intf_id;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct msm_i2s_data {
|
|
||||||
u32 capability; /* RX or TX */
|
|
||||||
u16 sd_lines;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct msm_dai_tdm_group_config {
|
|
||||||
u16 group_id;
|
|
||||||
u16 num_ports;
|
|
||||||
u16 *port_id;
|
|
||||||
u32 clk_rate;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct msm_dai_tdm_config {
|
|
||||||
u16 sync_mode;
|
|
||||||
u16 sync_src;
|
|
||||||
u16 data_out;
|
|
||||||
u16 invert_sync;
|
|
||||||
u16 data_delay;
|
|
||||||
u32 data_align;
|
|
||||||
u16 header_start_offset;
|
|
||||||
u16 header_width;
|
|
||||||
u16 header_num_frame_repeat;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct msm_dai_tdm_pdata {
|
|
||||||
struct msm_dai_tdm_group_config group_config;
|
|
||||||
struct msm_dai_tdm_config config;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
@@ -1,655 +0,0 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-only
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <linux/init.h>
|
|
||||||
#include <linux/module.h>
|
|
||||||
#include <linux/of.h>
|
|
||||||
#include <linux/bitops.h>
|
|
||||||
#include <linux/slimbus/slimbus.h>
|
|
||||||
#include <sound/soc.h>
|
|
||||||
#include <sound/pcm.h>
|
|
||||||
#include <sound/pcm_params.h>
|
|
||||||
#include "msm-slim-dma.h"
|
|
||||||
|
|
||||||
#define SLIM_DEV_NAME "msm-dai-slim"
|
|
||||||
|
|
||||||
#define SLIM_DAI_RATES (SNDRV_PCM_RATE_48000 | \
|
|
||||||
SNDRV_PCM_RATE_8000 | \
|
|
||||||
SNDRV_PCM_RATE_16000 | \
|
|
||||||
SNDRV_PCM_RATE_96000 | \
|
|
||||||
SNDRV_PCM_RATE_192000 | \
|
|
||||||
SNDRV_PCM_RATE_384000)
|
|
||||||
|
|
||||||
#define SLIM_DAI_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | \
|
|
||||||
SNDRV_PCM_FMTBIT_S24_LE | \
|
|
||||||
SNDRV_PCM_FMTBIT_S32_LE)
|
|
||||||
|
|
||||||
#define DAI_STATE_INITIALIZED (0x01 << 0)
|
|
||||||
#define DAI_STATE_PREPARED (0x01 << 1)
|
|
||||||
#define DAI_STATE_RUNNING (0x01 << 2)
|
|
||||||
|
|
||||||
#define SET_DAI_STATE(status, state) \
|
|
||||||
(status |= state)
|
|
||||||
|
|
||||||
#define CLR_DAI_STATE(status, state) \
|
|
||||||
(status = status & (~state))
|
|
||||||
|
|
||||||
enum {
|
|
||||||
MSM_DAI_SLIM0 = 0,
|
|
||||||
NUM_SLIM_DAIS,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct msm_slim_dai_data {
|
|
||||||
unsigned int dai_id;
|
|
||||||
u16 *chan_h;
|
|
||||||
u16 *sh_ch;
|
|
||||||
u16 grph;
|
|
||||||
u32 rate;
|
|
||||||
u16 bits;
|
|
||||||
u16 ch_cnt;
|
|
||||||
u8 status;
|
|
||||||
struct snd_soc_dai_driver *dai_drv;
|
|
||||||
struct msm_slim_dma_data dma_data;
|
|
||||||
struct slim_port_cfg port_cfg;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct msm_dai_slim_drv_data {
|
|
||||||
struct slim_device *sdev;
|
|
||||||
u16 num_dais;
|
|
||||||
struct msm_slim_dai_data slim_dai_data[NUM_SLIM_DAIS];
|
|
||||||
};
|
|
||||||
|
|
||||||
struct msm_slim_dai_data *msm_slim_get_dai_data(
|
|
||||||
struct msm_dai_slim_drv_data *drv_data,
|
|
||||||
struct snd_soc_dai *dai)
|
|
||||||
{
|
|
||||||
struct msm_slim_dai_data *dai_data_t;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < drv_data->num_dais; i++) {
|
|
||||||
dai_data_t = &drv_data->slim_dai_data[i];
|
|
||||||
if (dai_data_t->dai_id == dai->id)
|
|
||||||
return dai_data_t;
|
|
||||||
}
|
|
||||||
|
|
||||||
dev_err(dai->dev,
|
|
||||||
"%s: no dai data found for dai_id %d\n",
|
|
||||||
__func__, dai->id);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int msm_dai_slim_ch_ctl(struct msm_slim_dma_data *dma_data,
|
|
||||||
struct snd_soc_dai *dai, bool enable)
|
|
||||||
{
|
|
||||||
struct slim_device *sdev;
|
|
||||||
struct msm_dai_slim_drv_data *drv_data;
|
|
||||||
struct msm_slim_dai_data *dai_data;
|
|
||||||
int rc, rc1, i;
|
|
||||||
|
|
||||||
if (!dma_data || !dma_data->sdev) {
|
|
||||||
pr_err("%s: Invalid %s\n", __func__,
|
|
||||||
(!dma_data) ? "dma_data" : "slim_device");
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
sdev = dma_data->sdev;
|
|
||||||
drv_data = dev_get_drvdata(&sdev->dev);
|
|
||||||
dai_data = msm_slim_get_dai_data(drv_data, dai);
|
|
||||||
|
|
||||||
if (!dai_data) {
|
|
||||||
dev_err(dai->dev,
|
|
||||||
"%s: Invalid dai_data for dai_id %d\n",
|
|
||||||
__func__, dai->id);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
dev_dbg(&sdev->dev,
|
|
||||||
"%s: enable = %s, rate = %u\n", __func__,
|
|
||||||
enable ? "true" : "false",
|
|
||||||
dai_data->rate);
|
|
||||||
|
|
||||||
if (enable) {
|
|
||||||
if (!(dai_data->status & DAI_STATE_PREPARED)) {
|
|
||||||
dev_err(&sdev->dev,
|
|
||||||
"%s: dai id (%d) has invalid state 0x%x\n",
|
|
||||||
__func__, dai->id, dai_data->status);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = slim_alloc_mgrports(sdev,
|
|
||||||
SLIM_REQ_DEFAULT, dai_data->ch_cnt,
|
|
||||||
&(dma_data->ph),
|
|
||||||
sizeof(dma_data->ph));
|
|
||||||
if (rc < 0) {
|
|
||||||
dev_err(&sdev->dev,
|
|
||||||
"%s:alloc mgrport failed rc %d\n",
|
|
||||||
__func__, rc);
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = slim_config_mgrports(sdev, &(dma_data->ph),
|
|
||||||
dai_data->ch_cnt,
|
|
||||||
&(dai_data->port_cfg));
|
|
||||||
if (rc < 0) {
|
|
||||||
dev_err(&sdev->dev,
|
|
||||||
"%s: config mgrport failed rc %d\n",
|
|
||||||
__func__, rc);
|
|
||||||
goto err_done;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < dai_data->ch_cnt; i++) {
|
|
||||||
rc = slim_connect_sink(sdev,
|
|
||||||
&dma_data->ph, 1,
|
|
||||||
dai_data->chan_h[i]);
|
|
||||||
if (rc < 0) {
|
|
||||||
dev_err(&sdev->dev,
|
|
||||||
"%s: slim_connect_sink failed, ch = %d, err = %d\n",
|
|
||||||
__func__, i, rc);
|
|
||||||
goto err_done;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = slim_control_ch(sdev,
|
|
||||||
dai_data->grph,
|
|
||||||
SLIM_CH_ACTIVATE, true);
|
|
||||||
if (rc < 0) {
|
|
||||||
dev_err(&sdev->dev,
|
|
||||||
"%s: slim activate ch failed, err = %d\n",
|
|
||||||
__func__, rc);
|
|
||||||
goto err_done;
|
|
||||||
}
|
|
||||||
/* Mark dai status as running */
|
|
||||||
SET_DAI_STATE(dai_data->status, DAI_STATE_RUNNING);
|
|
||||||
} else {
|
|
||||||
if (!(dai_data->status & DAI_STATE_RUNNING)) {
|
|
||||||
dev_err(&sdev->dev,
|
|
||||||
"%s: dai id (%d) has invalid state 0x%x\n",
|
|
||||||
__func__, dai->id, dai_data->status);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = slim_control_ch(sdev,
|
|
||||||
dai_data->grph,
|
|
||||||
SLIM_CH_REMOVE, true);
|
|
||||||
if (rc < 0) {
|
|
||||||
dev_err(&sdev->dev,
|
|
||||||
"%s: slim activate ch failed, err = %d\n",
|
|
||||||
__func__, rc);
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = slim_dealloc_mgrports(sdev,
|
|
||||||
&dma_data->ph, 1);
|
|
||||||
if (rc < 0) {
|
|
||||||
dev_err(&sdev->dev,
|
|
||||||
"%s: dealloc mgrport failed, err = %d\n",
|
|
||||||
__func__, rc);
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
/* clear running state for dai*/
|
|
||||||
CLR_DAI_STATE(dai_data->status, DAI_STATE_RUNNING);
|
|
||||||
}
|
|
||||||
|
|
||||||
return rc;
|
|
||||||
|
|
||||||
err_done:
|
|
||||||
rc1 = slim_dealloc_mgrports(sdev,
|
|
||||||
&dma_data->ph, 1);
|
|
||||||
if (rc1 < 0)
|
|
||||||
dev_err(&sdev->dev,
|
|
||||||
"%s: dealloc mgrport failed, err = %d\n",
|
|
||||||
__func__, rc1);
|
|
||||||
done:
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int msm_dai_slim_hw_params(
|
|
||||||
struct snd_pcm_substream *substream,
|
|
||||||
struct snd_pcm_hw_params *params,
|
|
||||||
struct snd_soc_dai *dai)
|
|
||||||
{
|
|
||||||
struct msm_dai_slim_drv_data *drv_data = dev_get_drvdata(dai->dev);
|
|
||||||
struct msm_slim_dai_data *dai_data;
|
|
||||||
int rc = 0;
|
|
||||||
|
|
||||||
dai_data = msm_slim_get_dai_data(drv_data, dai);
|
|
||||||
if (!dai_data) {
|
|
||||||
dev_err(dai->dev,
|
|
||||||
"%s: Invalid dai_data for dai_id %d\n",
|
|
||||||
__func__, dai->id);
|
|
||||||
rc = -EINVAL;
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!dai_data->ch_cnt || dai_data->ch_cnt != params_channels(params)) {
|
|
||||||
dev_err(dai->dev, "%s: invalid ch_cnt %d %d\n",
|
|
||||||
__func__, dai_data->ch_cnt, params_channels(params));
|
|
||||||
rc = -EINVAL;
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
dai_data->rate = params_rate(params);
|
|
||||||
dai_data->port_cfg.port_opts = SLIM_OPT_NONE;
|
|
||||||
if (dai_data->rate >= SNDRV_PCM_RATE_48000)
|
|
||||||
dai_data->port_cfg.watermark = 16;
|
|
||||||
else
|
|
||||||
dai_data->port_cfg.watermark = 8;
|
|
||||||
|
|
||||||
switch (params_format(params)) {
|
|
||||||
case SNDRV_PCM_FORMAT_S16_LE:
|
|
||||||
dai_data->bits = 16;
|
|
||||||
break;
|
|
||||||
case SNDRV_PCM_FORMAT_S24_LE:
|
|
||||||
dai_data->bits = 24;
|
|
||||||
break;
|
|
||||||
case SNDRV_PCM_FORMAT_S32_LE:
|
|
||||||
dai_data->bits = 32;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
dev_err(dai->dev, "%s: invalid format %d\n", __func__,
|
|
||||||
params_format(params));
|
|
||||||
rc = -EINVAL;
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
dev_dbg(dai->dev, "%s: ch_cnt=%u rate=%u, bit_width = %u\n",
|
|
||||||
__func__, dai_data->ch_cnt, dai_data->rate,
|
|
||||||
dai_data->bits);
|
|
||||||
done:
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int msm_dai_slim_set_channel_map(struct snd_soc_dai *dai,
|
|
||||||
unsigned int tx_num, unsigned int *tx_slot,
|
|
||||||
unsigned int rx_num, unsigned int *rx_slot)
|
|
||||||
{
|
|
||||||
struct msm_dai_slim_drv_data *drv_data = dev_get_drvdata(dai->dev);
|
|
||||||
struct msm_slim_dai_data *dai_data;
|
|
||||||
struct snd_soc_dai_driver *dai_drv;
|
|
||||||
u8 i = 0;
|
|
||||||
|
|
||||||
dev_dbg(dai->dev,
|
|
||||||
"%s: tx_num=%u, rx_num=%u\n",
|
|
||||||
__func__, tx_num, rx_num);
|
|
||||||
|
|
||||||
dai_data = msm_slim_get_dai_data(drv_data, dai);
|
|
||||||
if (!dai_data) {
|
|
||||||
dev_err(dai->dev,
|
|
||||||
"%s: Invalid dai_data for dai_id %d\n",
|
|
||||||
__func__, dai->id);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
dai_drv = dai_data->dai_drv;
|
|
||||||
|
|
||||||
if (tx_num > dai_drv->capture.channels_max) {
|
|
||||||
dev_err(dai->dev, "%s: tx_num %u max out master port cnt\n",
|
|
||||||
__func__, tx_num);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < tx_num; i++)
|
|
||||||
dai_data->sh_ch[i] = tx_slot[i];
|
|
||||||
|
|
||||||
dai_data->ch_cnt = tx_num;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int msm_dai_slim_prepare(struct snd_pcm_substream *substream,
|
|
||||||
struct snd_soc_dai *dai)
|
|
||||||
{
|
|
||||||
struct msm_dai_slim_drv_data *drv_data = dev_get_drvdata(dai->dev);
|
|
||||||
struct msm_slim_dma_data *dma_data;
|
|
||||||
struct msm_slim_dai_data *dai_data = NULL;
|
|
||||||
struct slim_ch prop;
|
|
||||||
int rc;
|
|
||||||
u8 i, j;
|
|
||||||
|
|
||||||
dai_data = msm_slim_get_dai_data(drv_data, dai);
|
|
||||||
if (!dai_data) {
|
|
||||||
dev_err(dai->dev,
|
|
||||||
"%s: Invalid dai_data for dai %d\n",
|
|
||||||
__func__, dai->id);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(dai_data->status & DAI_STATE_INITIALIZED)) {
|
|
||||||
dev_err(dai->dev,
|
|
||||||
"%s: dai id (%d) has invalid state 0x%x\n",
|
|
||||||
__func__, dai->id, dai_data->status);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dai_data->status & DAI_STATE_PREPARED) {
|
|
||||||
dev_dbg(dai->dev,
|
|
||||||
"%s: dai id (%d) has already prepared.\n",
|
|
||||||
__func__, dai->id);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
dma_data = &dai_data->dma_data;
|
|
||||||
snd_soc_dai_set_dma_data(dai, substream, dma_data);
|
|
||||||
|
|
||||||
for (i = 0; i < dai_data->ch_cnt; i++) {
|
|
||||||
rc = slim_query_ch(drv_data->sdev, dai_data->sh_ch[i],
|
|
||||||
&dai_data->chan_h[i]);
|
|
||||||
if (rc) {
|
|
||||||
dev_err(dai->dev, "%s:query chan handle failed rc %d\n",
|
|
||||||
__func__, rc);
|
|
||||||
goto error_chan_query;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
prop.prot = SLIM_AUTO_ISO;
|
|
||||||
prop.baser = SLIM_RATE_4000HZ;
|
|
||||||
prop.dataf = SLIM_CH_DATAF_NOT_DEFINED;
|
|
||||||
prop.auxf = SLIM_CH_AUXF_NOT_APPLICABLE;
|
|
||||||
prop.ratem = (dai_data->rate/4000);
|
|
||||||
prop.sampleszbits = dai_data->bits;
|
|
||||||
|
|
||||||
rc = slim_define_ch(drv_data->sdev, &prop, dai_data->chan_h,
|
|
||||||
dai_data->ch_cnt, true, &dai_data->grph);
|
|
||||||
|
|
||||||
if (rc) {
|
|
||||||
dev_err(dai->dev, "%s:define chan failed rc %d\n",
|
|
||||||
__func__, rc);
|
|
||||||
goto error_define_chan;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Mark stream status as prepared */
|
|
||||||
SET_DAI_STATE(dai_data->status, DAI_STATE_PREPARED);
|
|
||||||
|
|
||||||
return rc;
|
|
||||||
|
|
||||||
error_define_chan:
|
|
||||||
error_chan_query:
|
|
||||||
for (j = 0; j < i; j++)
|
|
||||||
slim_dealloc_ch(drv_data->sdev, dai_data->chan_h[j]);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void msm_dai_slim_shutdown(struct snd_pcm_substream *stream,
|
|
||||||
struct snd_soc_dai *dai)
|
|
||||||
{
|
|
||||||
struct msm_dai_slim_drv_data *drv_data = dev_get_drvdata(dai->dev);
|
|
||||||
struct msm_slim_dma_data *dma_data = NULL;
|
|
||||||
struct msm_slim_dai_data *dai_data;
|
|
||||||
int i, rc = 0;
|
|
||||||
|
|
||||||
dai_data = msm_slim_get_dai_data(drv_data, dai);
|
|
||||||
dma_data = snd_soc_dai_get_dma_data(dai, stream);
|
|
||||||
if (!dma_data || !dai_data) {
|
|
||||||
dev_err(dai->dev,
|
|
||||||
"%s: Invalid %s\n", __func__,
|
|
||||||
(!dma_data) ? "dma_data" : "dai_data");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((!(dai_data->status & DAI_STATE_PREPARED)) ||
|
|
||||||
dai_data->status & DAI_STATE_RUNNING) {
|
|
||||||
dev_err(dai->dev,
|
|
||||||
"%s: dai id (%d) has invalid state 0x%x\n",
|
|
||||||
__func__, dai->id, dai_data->status);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < dai_data->ch_cnt; i++) {
|
|
||||||
rc = slim_dealloc_ch(drv_data->sdev, dai_data->chan_h[i]);
|
|
||||||
if (rc) {
|
|
||||||
dev_err(dai->dev,
|
|
||||||
"%s: dealloc_ch failed, err = %d\n",
|
|
||||||
__func__, rc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
snd_soc_dai_set_dma_data(dai, stream, NULL);
|
|
||||||
/* clear prepared state for the dai */
|
|
||||||
CLR_DAI_STATE(dai_data->status, DAI_STATE_PREPARED);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct snd_soc_component_driver msm_dai_slim_component = {
|
|
||||||
.name = "msm-dai-slim-cmpnt",
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct snd_soc_dai_ops msm_dai_slim_ops = {
|
|
||||||
.prepare = msm_dai_slim_prepare,
|
|
||||||
.hw_params = msm_dai_slim_hw_params,
|
|
||||||
.shutdown = msm_dai_slim_shutdown,
|
|
||||||
.set_channel_map = msm_dai_slim_set_channel_map,
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct snd_soc_dai_driver msm_slim_dais[] = {
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* The first dai name should be same as device name
|
|
||||||
* to support registering single and multile dais.
|
|
||||||
*/
|
|
||||||
.name = SLIM_DEV_NAME,
|
|
||||||
.id = MSM_DAI_SLIM0,
|
|
||||||
.capture = {
|
|
||||||
.rates = SLIM_DAI_RATES,
|
|
||||||
.formats = SLIM_DAI_FORMATS,
|
|
||||||
.channels_min = 1,
|
|
||||||
/*
|
|
||||||
* max channels allowed is
|
|
||||||
* dependent on platform and
|
|
||||||
* will be updated before this
|
|
||||||
* dai driver is registered.
|
|
||||||
*/
|
|
||||||
.channels_max = 1,
|
|
||||||
.rate_min = 8000,
|
|
||||||
.rate_max = 384000,
|
|
||||||
.stream_name = "SLIM_DAI0 Capture",
|
|
||||||
},
|
|
||||||
.ops = &msm_dai_slim_ops,
|
|
||||||
},
|
|
||||||
/*
|
|
||||||
* If multiple dais are needed,
|
|
||||||
* add dais here and update the
|
|
||||||
* dai_id enum.
|
|
||||||
*/
|
|
||||||
};
|
|
||||||
|
|
||||||
static void msm_dai_slim_remove_dai_data(
|
|
||||||
struct device *dev,
|
|
||||||
struct msm_dai_slim_drv_data *drv_data)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
struct msm_slim_dai_data *dai_data_t;
|
|
||||||
|
|
||||||
for (i = 0; i < drv_data->num_dais; i++) {
|
|
||||||
dai_data_t = &drv_data->slim_dai_data[i];
|
|
||||||
|
|
||||||
kfree(dai_data_t->chan_h);
|
|
||||||
dai_data_t->chan_h = NULL;
|
|
||||||
kfree(dai_data_t->sh_ch);
|
|
||||||
dai_data_t->sh_ch = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int msm_dai_slim_populate_dai_data(struct device *dev,
|
|
||||||
struct msm_dai_slim_drv_data *drv_data)
|
|
||||||
{
|
|
||||||
struct snd_soc_dai_driver *dai_drv;
|
|
||||||
struct msm_slim_dai_data *dai_data_t;
|
|
||||||
u8 num_ch;
|
|
||||||
int i, j, rc;
|
|
||||||
|
|
||||||
for (i = 0; i < drv_data->num_dais; i++) {
|
|
||||||
num_ch = 0;
|
|
||||||
dai_drv = &msm_slim_dais[i];
|
|
||||||
num_ch += dai_drv->capture.channels_max;
|
|
||||||
num_ch += dai_drv->playback.channels_max;
|
|
||||||
|
|
||||||
dai_data_t = &drv_data->slim_dai_data[i];
|
|
||||||
dai_data_t->dai_drv = dai_drv;
|
|
||||||
dai_data_t->dai_id = dai_drv->id;
|
|
||||||
dai_data_t->dma_data.sdev = drv_data->sdev;
|
|
||||||
dai_data_t->dma_data.dai_channel_ctl =
|
|
||||||
msm_dai_slim_ch_ctl;
|
|
||||||
SET_DAI_STATE(dai_data_t->status,
|
|
||||||
DAI_STATE_INITIALIZED);
|
|
||||||
|
|
||||||
dai_data_t->chan_h = devm_kzalloc(dev,
|
|
||||||
sizeof(u16) * num_ch,
|
|
||||||
GFP_KERNEL);
|
|
||||||
if (!dai_data_t->chan_h) {
|
|
||||||
dev_err(dev,
|
|
||||||
"%s: DAI ID %d, Failed to alloc channel handles\n",
|
|
||||||
__func__, i);
|
|
||||||
rc = -ENOMEM;
|
|
||||||
goto err_mem_alloc;
|
|
||||||
}
|
|
||||||
|
|
||||||
dai_data_t->sh_ch = devm_kzalloc(dev,
|
|
||||||
sizeof(u16) * num_ch,
|
|
||||||
GFP_KERNEL);
|
|
||||||
if (!dai_data_t->sh_ch) {
|
|
||||||
dev_err(dev,
|
|
||||||
"%s: DAI ID %d, Failed to alloc sh_ch\n",
|
|
||||||
__func__, i);
|
|
||||||
rc = -ENOMEM;
|
|
||||||
goto err_mem_alloc;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
err_mem_alloc:
|
|
||||||
for (j = 0; j < i; j++) {
|
|
||||||
dai_data_t = &drv_data->slim_dai_data[i];
|
|
||||||
|
|
||||||
devm_kfree(dev, dai_data_t->chan_h);
|
|
||||||
dai_data_t->chan_h = NULL;
|
|
||||||
|
|
||||||
devm_kfree(dev, dai_data_t->sh_ch);
|
|
||||||
dai_data_t->sh_ch = NULL;
|
|
||||||
}
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int msm_dai_slim_dev_probe(struct slim_device *sdev)
|
|
||||||
{
|
|
||||||
int rc, i;
|
|
||||||
u8 max_channels;
|
|
||||||
u32 apps_ch_pipes;
|
|
||||||
struct msm_dai_slim_drv_data *drv_data;
|
|
||||||
struct device *dev = &sdev->dev;
|
|
||||||
struct snd_soc_dai_driver *dai_drv;
|
|
||||||
|
|
||||||
if (!dev->of_node ||
|
|
||||||
!dev->of_node->parent) {
|
|
||||||
dev_err(dev,
|
|
||||||
"%s: Invalid %s\n", __func__,
|
|
||||||
(!dev->of_node) ? "of_node" : "parent_of_node");
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = of_property_read_u32(dev->of_node->parent,
|
|
||||||
"qcom,apps-ch-pipes",
|
|
||||||
&apps_ch_pipes);
|
|
||||||
if (rc) {
|
|
||||||
dev_err(dev,
|
|
||||||
"%s: Failed to lookup property %s in node %s, err = %d\n",
|
|
||||||
__func__, "qcom,apps-ch-pipes",
|
|
||||||
dev->of_node->parent->full_name, rc);
|
|
||||||
goto err_ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
max_channels = hweight_long(apps_ch_pipes);
|
|
||||||
if (max_channels <= 0) {
|
|
||||||
dev_err(dev,
|
|
||||||
"%s: Invalid apps owned ports %d\n",
|
|
||||||
__func__, max_channels);
|
|
||||||
goto err_ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
dev_dbg(dev, "%s: max channels = %u\n",
|
|
||||||
__func__, max_channels);
|
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(msm_slim_dais); i++) {
|
|
||||||
dai_drv = &msm_slim_dais[i];
|
|
||||||
dai_drv->capture.channels_max = max_channels;
|
|
||||||
dai_drv->playback.channels_max = max_channels;
|
|
||||||
}
|
|
||||||
|
|
||||||
drv_data = devm_kzalloc(dev, sizeof(*drv_data),
|
|
||||||
GFP_KERNEL);
|
|
||||||
if (!drv_data) {
|
|
||||||
rc = -ENOMEM;
|
|
||||||
goto err_ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
drv_data->sdev = sdev;
|
|
||||||
drv_data->num_dais = NUM_SLIM_DAIS;
|
|
||||||
|
|
||||||
rc = msm_dai_slim_populate_dai_data(dev, drv_data);
|
|
||||||
if (rc) {
|
|
||||||
dev_err(dev,
|
|
||||||
"%s: failed to setup dai_data, err = %d\n",
|
|
||||||
__func__, rc);
|
|
||||||
goto err_populate_dai;
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = snd_soc_register_component(&sdev->dev, &msm_dai_slim_component,
|
|
||||||
msm_slim_dais, NUM_SLIM_DAIS);
|
|
||||||
if (rc < 0) {
|
|
||||||
dev_err(dev, "%s: failed to register DAI, err = %d\n",
|
|
||||||
__func__, rc);
|
|
||||||
goto err_reg_comp;
|
|
||||||
}
|
|
||||||
|
|
||||||
dev_set_drvdata(dev, drv_data);
|
|
||||||
return rc;
|
|
||||||
|
|
||||||
err_reg_comp:
|
|
||||||
msm_dai_slim_remove_dai_data(dev, drv_data);
|
|
||||||
|
|
||||||
err_populate_dai:
|
|
||||||
devm_kfree(dev, drv_data);
|
|
||||||
|
|
||||||
err_ret:
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int msm_dai_slim_dev_remove(struct slim_device *sdev)
|
|
||||||
{
|
|
||||||
snd_soc_unregister_component(&sdev->dev);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct slim_device_id msm_dai_slim_dt_match[] = {
|
|
||||||
{SLIM_DEV_NAME, 0 },
|
|
||||||
{}
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct slim_driver msm_dai_slim_driver = {
|
|
||||||
.driver = {
|
|
||||||
.name = SLIM_DEV_NAME,
|
|
||||||
.owner = THIS_MODULE,
|
|
||||||
},
|
|
||||||
.probe = msm_dai_slim_dev_probe,
|
|
||||||
.remove = msm_dai_slim_dev_remove,
|
|
||||||
.id_table = msm_dai_slim_dt_match,
|
|
||||||
};
|
|
||||||
|
|
||||||
int __init msm_dai_slim_init(void)
|
|
||||||
{
|
|
||||||
int rc;
|
|
||||||
|
|
||||||
rc = slim_driver_register(&msm_dai_slim_driver);
|
|
||||||
if (rc)
|
|
||||||
pr_err("%s: failed to register with slimbus driver rc = %d",
|
|
||||||
__func__, rc);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
void msm_dai_slim_exit(void)
|
|
||||||
{
|
|
||||||
slim_driver_unregister(&msm_dai_slim_driver);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Module information */
|
|
||||||
MODULE_DESCRIPTION("Slimbus apps-owned channel handling driver");
|
|
||||||
MODULE_LICENSE("GPL v2");
|
|
@@ -9,18 +9,12 @@
|
|||||||
|
|
||||||
static int __init audio_platform_init(void)
|
static int __init audio_platform_init(void)
|
||||||
{
|
{
|
||||||
msm_dai_q6_hdmi_init();
|
|
||||||
msm_dai_q6_init();
|
|
||||||
msm_dai_slim_init();
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void audio_platform_exit(void)
|
static void audio_platform_exit(void)
|
||||||
{
|
{
|
||||||
msm_dai_slim_exit();
|
|
||||||
msm_dai_q6_exit();
|
|
||||||
msm_dai_q6_hdmi_exit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module_init(audio_platform_init);
|
module_init(audio_platform_init);
|
||||||
|
Reference in New Issue
Block a user