// SPDX-License-Identifier: GPL-2.0
// Copyright (c) 2011-2017, The Linux Foundation. All rights reserved.
// Copyright (c) 2018, Linaro Limited
#include <linux/err.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/device.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <sound/pcm.h>
#include <sound/soc.h>
#include <sound/pcm_params.h>
#include "q6afe.h"
#define Q6AFE_TDM_PB_DAI(pre, num, did) { \
.playback = { \
.stream_name = pre" TDM"#num" Playback", \
.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |\
SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |\
SNDRV_PCM_RATE_176400, \
.formats = SNDRV_PCM_FMTBIT_S16_LE | \
SNDRV_PCM_FMTBIT_S24_LE | \
SNDRV_PCM_FMTBIT_S32_LE, \
.channels_min = 1, \
.channels_max = 8, \
.rate_min = 8000, \
.rate_max = 176400, \
}, \
.name = #did, \
.ops = &q6tdm_ops, \
.id = did, \
.probe = msm_dai_q6_dai_probe, \
.remove = msm_dai_q6_dai_remove, \
}
#define Q6AFE_TDM_CAP_DAI(pre, num, did) { \
.capture = { \
.stream_name = pre" TDM"#num" Capture", \
.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |\
SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |\
SNDRV_PCM_RATE_176400, \
.formats = SNDRV_PCM_FMTBIT_S16_LE | \
SNDRV_PCM_FMTBIT_S24_LE | \
SNDRV_PCM_FMTBIT_S32_LE, \
.channels_min = 1, \
.channels_max = 8, \
.rate_min = 8000, \
.rate_max = 176400, \
}, \
.name = #did, \
.ops = &q6tdm_ops, \
.id = did, \
.probe = msm_dai_q6_dai_probe, \
.remove = msm_dai_q6_dai_remove, \
}
struct q6afe_dai_priv_data {
uint32_t sd_line_mask;
uint32_t sync_mode;
uint32_t sync_src;
uint32_t data_out_enable;
uint32_t invert_sync;
uint32_t data_delay;
uint32_t data_align;
};
struct q6afe_dai_data {
struct q6afe_port *port[AFE_PORT_MAX];
struct q6afe_port_config port_config[AFE_PORT_MAX];
bool is_port_started[AFE_PORT_MAX];
struct q6afe_dai_priv_data priv[AFE_PORT_MAX];
};
static int q6slim_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct