#include <linux/mfd/syscon.h>
#include <linux/module.h>
#include <linux/of_address.h>
#include <linux/sched/clock.h>
#include <sound/soc.h>
#define BTCVSD_SND_NAME …
#define BT_CVSD_TX_NREADY …
#define BT_CVSD_RX_READY …
#define BT_CVSD_TX_UNDERFLOW …
#define BT_CVSD_RX_OVERFLOW …
#define BT_CVSD_INTERRUPT …
#define BT_CVSD_CLEAR …
#define SCO_TX_ENCODE_SIZE …
#define SCO_TX_PACKER_BUF_NUM …
#define SCO_RX_PLC_SIZE …
#define SCO_RX_PACKER_BUF_NUM …
#define SCO_RX_PACKET_MASK …
#define SCO_CVSD_PACKET_VALID_SIZE …
#define SCO_PACKET_120 …
#define SCO_PACKET_180 …
#define BTCVSD_RX_PACKET_SIZE …
#define BTCVSD_TX_PACKET_SIZE …
#define BTCVSD_RX_BUF_SIZE …
#define BTCVSD_TX_BUF_SIZE …
enum bt_sco_state { … };
enum bt_sco_direct { … };
enum bt_sco_packet_len { … };
enum BT_SCO_BAND { … };
struct mtk_btcvsd_snd_hw_info { … };
struct mtk_btcvsd_snd_stream { … };
struct mtk_btcvsd_snd { … };
struct mtk_btcvsd_snd_time_buffer_info { … };
static const unsigned int btsco_packet_valid_mask[BT_SCO_CVSD_MAX][6] = …;
static const unsigned int btsco_packet_info[BT_SCO_CVSD_MAX][4] = …;
static const u8 table_msbc_silence[SCO_PACKET_180] = …;
static void mtk_btcvsd_snd_irq_enable(struct mtk_btcvsd_snd *bt)
{ … }
static void mtk_btcvsd_snd_irq_disable(struct mtk_btcvsd_snd *bt)
{ … }
static void mtk_btcvsd_snd_set_state(struct mtk_btcvsd_snd *bt,
struct mtk_btcvsd_snd_stream *bt_stream,
int state)
{ … }
static int mtk_btcvsd_snd_tx_init(struct mtk_btcvsd_snd *bt)
{ … }
static int mtk_btcvsd_snd_rx_init(struct mtk_btcvsd_snd *bt)
{ … }
static void get_tx_time_stamp(struct mtk_btcvsd_snd *bt,
struct mtk_btcvsd_snd_time_buffer_info *ts)
{ … }
static void get_rx_time_stamp(struct mtk_btcvsd_snd *bt,
struct mtk_btcvsd_snd_time_buffer_info *ts)
{ … }
static int btcvsd_bytes_to_frame(struct snd_pcm_substream *substream,
int bytes)
{ … }
static void mtk_btcvsd_snd_data_transfer(enum bt_sco_direct dir,
u8 *src, u8 *dst,
unsigned int blk_size,
unsigned int blk_num)
{ … }
static int btcvsd_tx_clean_buffer(struct mtk_btcvsd_snd *bt)
{ … }
static int mtk_btcvsd_read_from_bt(struct mtk_btcvsd_snd *bt,
enum bt_sco_packet_len packet_type,
unsigned int packet_length,
unsigned int packet_num,
unsigned int blk_size,
unsigned int control)
{ … }
static int mtk_btcvsd_write_to_bt(struct mtk_btcvsd_snd *bt,
enum bt_sco_packet_len packet_type,
unsigned int packet_length,
unsigned int packet_num,
unsigned int blk_size)
{ … }
static irqreturn_t mtk_btcvsd_snd_irq_handler(int irq_id, void *dev)
{ … }
static int wait_for_bt_irq(struct mtk_btcvsd_snd *bt,
struct mtk_btcvsd_snd_stream *bt_stream)
{ … }
static ssize_t mtk_btcvsd_snd_read(struct mtk_btcvsd_snd *bt,
struct iov_iter *buf,
size_t count)
{ … }
static ssize_t mtk_btcvsd_snd_write(struct mtk_btcvsd_snd *bt,
struct iov_iter *buf,
size_t count)
{ … }
static struct mtk_btcvsd_snd_stream *get_bt_stream
(struct mtk_btcvsd_snd *bt, struct snd_pcm_substream *substream)
{ … }
static const struct snd_pcm_hardware mtk_btcvsd_hardware = …;
static int mtk_pcm_btcvsd_open(struct snd_soc_component *component,
struct snd_pcm_substream *substream)
{ … }
static int mtk_pcm_btcvsd_close(struct snd_soc_component *component,
struct snd_pcm_substream *substream)
{ … }
static int mtk_pcm_btcvsd_hw_params(struct snd_soc_component *component,
struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *hw_params)
{ … }
static int mtk_pcm_btcvsd_hw_free(struct snd_soc_component *component,
struct snd_pcm_substream *substream)
{ … }
static int mtk_pcm_btcvsd_prepare(struct snd_soc_component *component,
struct snd_pcm_substream *substream)
{ … }
static int mtk_pcm_btcvsd_trigger(struct snd_soc_component *component,
struct snd_pcm_substream *substream, int cmd)
{ … }
static snd_pcm_uframes_t mtk_pcm_btcvsd_pointer(
struct snd_soc_component *component,
struct snd_pcm_substream *substream)
{ … }
static int mtk_pcm_btcvsd_copy(struct snd_soc_component *component,
struct snd_pcm_substream *substream,
int channel, unsigned long pos,
struct iov_iter *buf, unsigned long count)
{ … }
static const char *const btsco_band_str[] = …;
static const struct soc_enum btcvsd_enum[] = …;
static int btcvsd_band_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static int btcvsd_band_set(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static int btcvsd_loopback_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static int btcvsd_loopback_set(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static int btcvsd_tx_mute_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static int btcvsd_tx_mute_set(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static int btcvsd_rx_irq_received_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static int btcvsd_rx_timeout_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static int btcvsd_rx_timestamp_get(struct snd_kcontrol *kcontrol,
unsigned int __user *data, unsigned int size)
{ … }
static int btcvsd_tx_irq_received_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static int btcvsd_tx_timeout_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static int btcvsd_tx_timestamp_get(struct snd_kcontrol *kcontrol,
unsigned int __user *data, unsigned int size)
{ … }
static const struct snd_kcontrol_new mtk_btcvsd_snd_controls[] = …;
static int mtk_btcvsd_snd_component_probe(struct snd_soc_component *component)
{ … }
static const struct snd_soc_component_driver mtk_btcvsd_snd_platform = …;
static int mtk_btcvsd_snd_probe(struct platform_device *pdev)
{ … }
static void mtk_btcvsd_snd_remove(struct platform_device *pdev)
{ … }
static const struct of_device_id mtk_btcvsd_snd_dt_match[] = …;
MODULE_DEVICE_TABLE(of, mtk_btcvsd_snd_dt_match);
static struct platform_driver mtk_btcvsd_snd_driver = …;
module_platform_driver(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_AUTHOR(…) …;
MODULE_LICENSE(…) …;