sm8750: init kernel modules repo
This commit is contained in:
111
qcom/opensource/bt-kernel/btfmcodec/include/btfm_codec.h
Normal file
111
qcom/opensource/bt-kernel/btfmcodec/include/btfm_codec.h
Normal file
@@ -0,0 +1,111 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* Copyright (c) 2023-2024 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef __LINUX_BTFM_CODEC_H
|
||||
#define __LINUX_BTFM_CODEC_H
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/bitops.h>
|
||||
#include <linux/printk.h>
|
||||
#include <linux/cdev.h>
|
||||
#include <linux/skbuff.h>
|
||||
#include "btfm_codec_hw_interface.h"
|
||||
|
||||
#define BTM_BTFMCODEC_DEFAULT_LOG_LVL 0x03
|
||||
#define BTM_BTFMCODEC_DEBUG_LOG_LVL 0x04
|
||||
#define BTM_BTFMCODEC_INFO_LOG_LVL 0x08
|
||||
|
||||
static uint8_t log_lvl = BTM_BTFMCODEC_DEFAULT_LOG_LVL;
|
||||
|
||||
#define BTFMCODEC_ERR(fmt, arg...) pr_err("%s: " fmt "\n", __func__, ## arg)
|
||||
#define BTFMCODEC_WARN(fmt, arg...) pr_warn("%s: " fmt "\n", __func__, ## arg)
|
||||
#define BTFMCODEC_DBG(fmt, arg...) { if(log_lvl >= BTM_BTFMCODEC_DEBUG_LOG_LVL) \
|
||||
pr_err("%s: " fmt "\n", __func__, ## arg); \
|
||||
else \
|
||||
pr_debug("%s: " fmt "\n", __func__, ## arg); \
|
||||
}
|
||||
#define BTFMCODEC_INFO(fmt, arg...) { if(log_lvl >= BTM_BTFMCODEC_INFO_LOG_LVL) \
|
||||
pr_err("%s: " fmt "\n", __func__, ## arg);\
|
||||
else \
|
||||
pr_info("%s: " fmt "\n", __func__, ## arg);\
|
||||
}
|
||||
|
||||
#define DEVICE_NAME_MAX_LEN 64
|
||||
#define BTM_CP_UPDATE 0xbfaf
|
||||
|
||||
typedef enum btfmcodec_states {
|
||||
/*Default state of kernel proxy driver */
|
||||
IDLE = 0,
|
||||
/* Waiting for BT bearer indication after configuring HW ports */
|
||||
BT_Connecting = 1,
|
||||
/* When BT is active transport */
|
||||
BT_Connected = 2,
|
||||
/* Waiting for BTADV Audio bearer switch indications */
|
||||
BTADV_AUDIO_Connecting = 3,
|
||||
/* When BTADV audio is active transport */
|
||||
BTADV_AUDIO_Connected = 4
|
||||
} btfmcodec_state;
|
||||
|
||||
enum btfm_pkt_type {
|
||||
BTM_PKT_TYPE_PREPARE_REQ = 0,
|
||||
BTM_PKT_TYPE_MASTER_CONFIG_RSP,
|
||||
BTM_PKT_TYPE_MASTER_SHUTDOWN_RSP,
|
||||
BTM_PKT_TYPE_BEARER_SWITCH_IND,
|
||||
BTM_PKT_TYPE_HWEP_SHUTDOWN,
|
||||
BTM_PKT_TYPE_HWEP_CONFIG,
|
||||
BTM_PKT_TYPE_DMA_CONFIG_RSP,
|
||||
BTM_PKT_TYPE_USECASE_START_RSP,
|
||||
BTM_PKT_TYPE_MAX,
|
||||
};
|
||||
|
||||
|
||||
char *coverttostring(enum btfmcodec_states);
|
||||
struct btfmcodec_state_machine {
|
||||
struct mutex state_machine_lock;
|
||||
btfmcodec_state prev_state;
|
||||
btfmcodec_state current_state;
|
||||
btfmcodec_state next_state;
|
||||
};
|
||||
|
||||
struct btfmcodec_char_device {
|
||||
struct cdev cdev;
|
||||
refcount_t active_clients;
|
||||
struct mutex lock;
|
||||
struct mutex trans_lock;
|
||||
int reuse_minor;
|
||||
char dev_name[DEVICE_NAME_MAX_LEN];
|
||||
struct workqueue_struct *workqueue;
|
||||
struct sk_buff_head rxq;
|
||||
struct sk_buff_head trans_rxq;
|
||||
struct work_struct rx_work;
|
||||
struct work_struct wq_hwep_shutdown;
|
||||
struct work_struct wq_prepare_bearer;
|
||||
struct work_struct wq_hwep_configure;
|
||||
wait_queue_head_t readq;
|
||||
spinlock_t tx_queue_lock;
|
||||
struct sk_buff_head txq;
|
||||
wait_queue_head_t rsp_wait_q[BTM_PKT_TYPE_MAX];
|
||||
uint8_t status[BTM_PKT_TYPE_MAX];
|
||||
void *btfmcodec;
|
||||
};
|
||||
|
||||
struct adsp_notifier {
|
||||
void *notifier;
|
||||
struct notifier_block nb;
|
||||
};
|
||||
|
||||
struct btfmcodec_data {
|
||||
struct device dev;
|
||||
struct btfmcodec_state_machine states;
|
||||
struct btfmcodec_char_device *btfmcodec_dev;
|
||||
struct hwep_data *hwep_info;
|
||||
struct list_head config_head;
|
||||
struct adsp_notifier notifier;
|
||||
struct mutex hwep_drv_lock;
|
||||
};
|
||||
|
||||
struct btfmcodec_data *btfm_get_btfmcodec(void);
|
||||
bool isCpSupported(void);
|
||||
#endif /*__LINUX_BTFM_CODEC_H */
|
||||
@@ -0,0 +1,23 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* Copyright (c) 2022, 2024 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef __LINUX_BTFM_CODEC_BTADV_INTERFACE_H
|
||||
#define __LINUX_BTFM_CODEC_BTADV_INTERFACE_H
|
||||
|
||||
enum transport_type {
|
||||
BT = 1,
|
||||
BTADV,
|
||||
NONE,
|
||||
};
|
||||
|
||||
static char *transport_type_text[] = {"BT", "BTADV", "NONE"};
|
||||
|
||||
void btfmcodec_set_current_state(struct btfmcodec_state_machine *, btfmcodec_state);
|
||||
void btfmcodec_wq_prepare_bearer(struct work_struct *);
|
||||
void btfmcodec_wq_hwep_shutdown(struct work_struct *);
|
||||
void btfmcodec_initiate_hwep_shutdown(struct btfmcodec_char_device *btfmcodec_dev);
|
||||
btfmcodec_state btfmcodec_get_current_transport(struct btfmcodec_state_machine *state);
|
||||
btfmcodec_state btfmcodec_get_prev_transport(struct btfmcodec_state_machine *state);
|
||||
#endif /* __LINUX_BTFM_CODEC_BTADV_INTERFACE_H */
|
||||
@@ -0,0 +1,117 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* Copyright (c) 2023-2025 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef __LINUX_BTFM_CODEC_HW_INTERFACE_H
|
||||
#define __LINUX_BTFM_CODEC_HW_INTERFACE_H
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/bitops.h>
|
||||
#include <sound/pcm.h>
|
||||
#include <sound/pcm_params.h>
|
||||
#include <sound/soc.h>
|
||||
#include <sound/soc-dapm.h>
|
||||
#include <sound/tlv.h>
|
||||
|
||||
/* This flag is set to indicate btfm codec driver is
|
||||
* responsible to configure master.
|
||||
*/
|
||||
#define BTADV_AUDIO_MASTER_CONFIG 0
|
||||
#define BTADV_CONFIGURE_DMA 1
|
||||
#define DEVICE_NAME_MAX_LEN 64
|
||||
|
||||
struct hwep_configurations {
|
||||
void *btfmcodec;
|
||||
uint8_t stream_id;
|
||||
uint32_t sample_rate;
|
||||
uint8_t bit_width;
|
||||
uint8_t codectype;
|
||||
uint32_t direction;
|
||||
uint8_t num_channels;
|
||||
uint8_t is_port_opened;
|
||||
struct list_head dai_list;
|
||||
};
|
||||
|
||||
struct master_hwep_configurations {
|
||||
uint8_t stream_id;
|
||||
uint32_t device_id;
|
||||
uint32_t sample_rate;
|
||||
uint8_t bit_width;
|
||||
uint8_t num_channels;
|
||||
uint8_t chan_num;
|
||||
uint8_t codectype;
|
||||
uint16_t direction;
|
||||
};
|
||||
|
||||
struct hwep_dma_configurations {
|
||||
uint8_t stream_id;
|
||||
uint32_t sample_rate;
|
||||
uint8_t bit_width;
|
||||
uint8_t num_channels;
|
||||
uint8_t codectype;
|
||||
uint8_t lpaif; // Low power audio interface
|
||||
uint8_t inf_index; // interface index
|
||||
uint8_t active_channel_mask;
|
||||
};
|
||||
|
||||
struct hwep_comp_drv {
|
||||
int (*hwep_probe) (struct snd_soc_component *);
|
||||
void (*hwep_remove) (struct snd_soc_component *);
|
||||
unsigned int (*hwep_read)(struct snd_soc_component *, unsigned int );
|
||||
int (*hwep_write)(struct snd_soc_component *, unsigned int,
|
||||
unsigned int);
|
||||
};
|
||||
|
||||
struct hwep_dai_ops {
|
||||
int (*hwep_startup)(void *);
|
||||
void (*hwep_shutdown)(void *, int);
|
||||
int (*hwep_hw_params)(void *, uint32_t, uint32_t, uint8_t);
|
||||
int (*hwep_prepare)(void *, uint32_t, uint32_t, int);
|
||||
int (*hwep_set_channel_map)(void *, unsigned int, unsigned int *,
|
||||
unsigned int, unsigned int *);
|
||||
int (*hwep_get_channel_map)(void *, unsigned int *, unsigned int *,
|
||||
unsigned int *, unsigned int *, int);
|
||||
int (*hwep_get_configs)(void *a, void *b, uint8_t c);
|
||||
uint8_t *hwep_codectype;
|
||||
};
|
||||
|
||||
struct hwep_dai_driver {
|
||||
const char *dai_name;
|
||||
unsigned int id;
|
||||
struct snd_soc_pcm_stream capture;
|
||||
struct snd_soc_pcm_stream playback;
|
||||
struct hwep_dai_ops *dai_ops;
|
||||
};
|
||||
|
||||
struct hwep_data {
|
||||
struct device *dev;
|
||||
char driver_name [DEVICE_NAME_MAX_LEN];
|
||||
struct hwep_comp_drv *drv;
|
||||
struct hwep_dai_driver *dai_drv;
|
||||
struct snd_kcontrol_new *mixer_ctrl;
|
||||
int num_dai;
|
||||
int num_mixer_ctrl;
|
||||
unsigned long flags;
|
||||
};
|
||||
|
||||
int btfmcodec_register_hw_ep(struct hwep_data *);
|
||||
int btfmcodec_unregister_hw_ep(char *);
|
||||
// ToDo below.
|
||||
/*
|
||||
#if IS_ENABLED(CONFIG_SLIM_BTFM_CODEC_DRV)
|
||||
int btfmcodec_register_hw_ep(struct hwep_data *);
|
||||
int btfmcodec_unregister_hw_ep(char *);
|
||||
#else
|
||||
static inline int btfmcodec_register_hw_ep(struct hwep_data *hwep_info)
|
||||
{
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
static inline int btfmcodec_unregister_hw_ep(char *dev_name)
|
||||
{
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
#endif /*__LINUX_BTFM_CODEC_HW_INTERFACE_H */
|
||||
@@ -0,0 +1,12 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef __LINUX_BTFM_CODEC_INTERFACE
|
||||
#define __LINUX_BTFM_CODEC_INTERFACE
|
||||
|
||||
#include "btfm_codec_hw_interface.h"
|
||||
int btfm_register_codec(struct hwep_data *hwep_info);
|
||||
void btfm_unregister_codec(void);
|
||||
#endif /*__LINUX_BTFM_CODEC_INTERFACE */
|
||||
150
qcom/opensource/bt-kernel/btfmcodec/include/btfm_codec_pkt.h
Normal file
150
qcom/opensource/bt-kernel/btfmcodec/include/btfm_codec_pkt.h
Normal file
@@ -0,0 +1,150 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* Copyright (c) 2023-2024 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef __LINUX_BTFM_CODEC_PKT_H
|
||||
#define __LINUX_BTFM_CODEC_PKT_H
|
||||
|
||||
typedef uint32_t btm_opcode;
|
||||
|
||||
struct btm_req {
|
||||
btm_opcode opcode;
|
||||
uint32_t len;
|
||||
uint8_t *data;
|
||||
}__attribute__((packed));
|
||||
|
||||
struct btm_rsp {
|
||||
btm_opcode opcode;
|
||||
uint8_t status;
|
||||
}__attribute__((packed));
|
||||
|
||||
struct btm_ind {
|
||||
btm_opcode opcode;
|
||||
uint32_t len;
|
||||
uint8_t *data;
|
||||
}__attribute__((packed));
|
||||
|
||||
struct btm_ctrl_pkt {
|
||||
btm_opcode opcode;
|
||||
uint32_t len;
|
||||
uint8_t active_transport;
|
||||
uint8_t status;
|
||||
}__attribute__((packed));
|
||||
|
||||
#define BTM_BTFMCODEC_PREPARE_AUDIO_BEARER_SWITCH_REQ 0x50000000
|
||||
#define BTM_BTFMCODEC_PREPARE_AUDIO_BEARER_SWITCH_RSP 0x50000001
|
||||
#define BTM_BTFMCODEC_MASTER_CONFIG_REQ 0x50000002
|
||||
#define BTM_BTFMCODEC_MASTER_CONFIG_RSP 0x50000003
|
||||
#define BTM_BTFMCODEC_MASTER_SHUTDOWN_REQ 0x50000004
|
||||
#define BTM_BTFMCODEC_CTRL_MASTER_SHUTDOWN_RSP 0x50000005
|
||||
#define BTM_BTFMCODEC_CODEC_CONFIG_DMA_REQ 0x58000006
|
||||
#define BTM_BTFMCODEC_CODEC_CONFIG_DMA_RSP 0x58000007
|
||||
|
||||
#define BTM_BTFMCODEC_BEARER_SWITCH_IND 0x58000001
|
||||
#define BTM_BTFMCODEC_TRANSPORT_SWITCH_FAILED_IND 0x58000002
|
||||
#define BTM_BTFMCODEC_ADSP_STATE_IND 0x58000003
|
||||
#define BTM_BTFMCODEC_CTRL_LOG_LVL_IND 0x58000004
|
||||
#define BTM_BTFMCODEC_PORT_STATE_IND 0x58000005
|
||||
|
||||
#define BTM_MASTER_CONFIG_REQ_LEN 13
|
||||
#define BTM_MASTER_CONFIG_RSP_TIMEOUT 5000
|
||||
#define BTM_BEARER_SWITCH_IND_TIMEOUT 25000
|
||||
#define BTM_MASTER_DMA_CONFIG_RSP_TIMEOUT 5000
|
||||
#define BTM_HEADER_LEN 8
|
||||
#define BTM_PREPARE_AUDIO_BEARER_SWITCH_RSP_LEN 2
|
||||
#define BTM_MASTER_CONFIG_RSP_LEN 2
|
||||
#define BTM_CODEC_CONFIG_DMA_RSP_LEN 2
|
||||
#define BTM_MASTER_SHUTDOWN_REQ_LEN 1
|
||||
#define BTM_PREPARE_AUDIO_BEARER_SWITCH_REQ_LEN 1
|
||||
#define BTM_BEARER_SWITCH_IND_LEN 1
|
||||
#define BTM_LOG_LVL_IND_LEN 1
|
||||
#define BTM_ADSP_STATE_IND_LEN 4
|
||||
#define BTM_CODEC_CONFIG_DMA_REQ_LEN 11
|
||||
#define BTM_PORT_STATE_IND_LEN 1
|
||||
|
||||
#define BTM_BTFMCODEC_USECASE_START_REQ 0x58000008
|
||||
#define BTM_BTFMCODEC_USECASE_START_RSP 0x58000009
|
||||
#define BTM_USECASE_START_IND_LEN 2
|
||||
#define BTM_USECASE_START_RSP_LEN 1
|
||||
|
||||
enum rx_status {
|
||||
/* Waiting for response */
|
||||
BTM_WAITING_RSP,
|
||||
/* Response recevied */
|
||||
BTM_RSP_RECV,
|
||||
/* Response recevied with failure status*/
|
||||
BTM_FAIL_RESP_RECV,
|
||||
/* Response not recevied, but client killed */
|
||||
BTM_RSP_NOT_RECV_CLIENT_KILLED,
|
||||
};
|
||||
|
||||
enum btfm_kp_status {
|
||||
/* KP processed message succesfully */
|
||||
MSG_SUCCESS = 0,
|
||||
/* Error while processing the message */
|
||||
MSG_FAILED,
|
||||
/* Wrong transport type selected by BTADV audio manager */
|
||||
MSG_WRONG_TRANSPORT_TYPE,
|
||||
/* Timeout triggered to receive bearer switch indications*/
|
||||
MSG_INTERNAL_TIMEOUT,
|
||||
MSG_FAILED_TO_CONFIGURE_HWEP,
|
||||
MSG_FAILED_TO_SHUTDOWN_HWEP,
|
||||
MSG_ERR_WHILE_SHUTING_DOWN_HWEP,
|
||||
};
|
||||
|
||||
struct btm_master_config_req {
|
||||
btm_opcode opcode;
|
||||
uint32_t len;
|
||||
uint8_t stream_id;
|
||||
uint32_t device_id;
|
||||
uint32_t sample_rate;
|
||||
uint8_t bit_width;
|
||||
uint8_t num_channels;
|
||||
uint8_t channel_num;
|
||||
uint8_t codec_id;
|
||||
} __packed;
|
||||
|
||||
struct btm_dma_config_req {
|
||||
btm_opcode opcode;
|
||||
uint32_t len;
|
||||
uint8_t stream_id;
|
||||
uint32_t sample_rate;
|
||||
uint8_t bit_width;
|
||||
uint8_t num_channels;
|
||||
uint8_t codec_id;
|
||||
uint8_t lpaif; // Low power audio interface
|
||||
uint8_t inf_index; // interface index
|
||||
uint8_t active_channel_mask;
|
||||
} __packed;
|
||||
|
||||
struct btm_usecase_start_ind {
|
||||
btm_opcode opcode;
|
||||
uint32_t len;
|
||||
uint8_t transport;
|
||||
uint8_t stream_id;
|
||||
} __packed;
|
||||
|
||||
struct btm_master_shutdown_req {
|
||||
btm_opcode opcode;
|
||||
uint32_t len;
|
||||
uint8_t stream_id;
|
||||
} __packed;
|
||||
|
||||
struct btm_adsp_state_ind {
|
||||
btm_opcode opcode;
|
||||
uint32_t len;
|
||||
uint32_t action;
|
||||
} __packed;
|
||||
|
||||
struct btm_port_state_ind {
|
||||
btm_opcode opcode;
|
||||
uint32_t len;
|
||||
uint8_t port_state;
|
||||
} __packed;
|
||||
|
||||
int btfmcodec_dev_enqueue_pkt(struct btfmcodec_char_device *btfmcodec_dev, void *buf, int len);
|
||||
bool btfmcodec_is_valid_cache_avb(struct btfmcodec_data *btfmcodec);
|
||||
int btfmcodec_enqueue_transport(struct btfmcodec_char_device *btfmcodec_dev, uint8_t transport);
|
||||
int btfmcodec_dequeue_transport(struct btfmcodec_char_device *btfmcodec_dev);
|
||||
#endif /* __LINUX_BTFM_CODEC_PKT_H*/
|
||||
Reference in New Issue
Block a user