replace common qcom sources with samsung ones
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* Copyright (c) 2023-2025 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
* Copyright (c) 2023-2024 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <linux/slab.h>
|
||||
@@ -14,7 +14,6 @@
|
||||
#include <linux/module.h>
|
||||
#include "btfm_codec.h"
|
||||
#include "btfm_codec_pkt.h"
|
||||
#include "btfm_codec_btadv_interface.h"
|
||||
|
||||
#define dev_to_btfmcodec(_dev) container_of(_dev, struct btfmcodec_data, dev)
|
||||
|
||||
@@ -68,6 +67,8 @@ static int btfmcodec_dev_open(struct inode *inode, struct file *file)
|
||||
struct btfmcodec_data *btfmcodec = (struct btfmcodec_data *)btfmcodec_dev->btfmcodec;
|
||||
unsigned int active_clients = refcount_read(&btfmcodec_dev->active_clients);
|
||||
|
||||
btfmcodec->states.current_state = IDLE; /* Just a temp*/
|
||||
btfmcodec->states.next_state = IDLE;
|
||||
BTFMCODEC_INFO("for %s by %s:%d active_clients[%d]\n",
|
||||
btfmcodec_dev->dev_name, current->comm,
|
||||
task_pid_nr(current), refcount_read(&btfmcodec_dev->active_clients));
|
||||
@@ -126,6 +127,9 @@ static int btfmcodec_dev_release(struct inode *inode, struct file *file)
|
||||
if (btfmcodec_dev->wq_prepare_bearer.func)
|
||||
cancel_work_sync(&btfmcodec_dev->wq_prepare_bearer);
|
||||
|
||||
btfmcodec->states.current_state = IDLE;
|
||||
btfmcodec->states.next_state = IDLE;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -139,11 +143,10 @@ static void btfmcodec_dev_rxwork(struct work_struct *work)
|
||||
{
|
||||
struct btfmcodec_char_device *btfmcodec_dev = container_of(work, struct btfmcodec_char_device, rx_work);
|
||||
struct sk_buff *skb;
|
||||
struct btfmcodec_state_machine *state = &btfmcodec->states;
|
||||
uint32_t len;
|
||||
uint8_t status;
|
||||
int idx;
|
||||
uint8_t *bearer_switch_ind, *dma_rsp;
|
||||
uint8_t *bearer_switch_ind;
|
||||
|
||||
BTFMCODEC_DBG("start");
|
||||
while ((skb = skb_dequeue(&btfmcodec_dev->rxq))) {
|
||||
@@ -161,16 +164,6 @@ static void btfmcodec_dev_rxwork(struct work_struct *work)
|
||||
&btfmcodec_dev->status[BTM_PKT_TYPE_BEARER_SWITCH_IND];
|
||||
*bearer_switch_ind = BTM_WAITING_RSP;
|
||||
btfmcodec_enqueue_transport(btfmcodec_dev, skb->data[0]);
|
||||
if (skb->data[0] == NONE &&
|
||||
btfmcodec_get_current_transport(state) == BT_Connecting &&
|
||||
btfmcodec_get_prev_transport(state) ==
|
||||
BTADV_AUDIO_Connected) {
|
||||
BTFMCODEC_INFO("KP might be awaiting for codec dma rsp");
|
||||
idx = BTM_PKT_TYPE_DMA_CONFIG_RSP;
|
||||
dma_rsp = &btfmcodec_dev->status[idx];
|
||||
*dma_rsp = BTM_FAIL_RESP_RECV;
|
||||
wake_up_interruptible(&btfmcodec_dev->rsp_wait_q[idx]);
|
||||
}
|
||||
queue_work(btfmcodec_dev->workqueue,
|
||||
&btfmcodec_dev->wq_prepare_bearer);
|
||||
} else {
|
||||
@@ -256,7 +249,7 @@ static void btfmcodec_dev_rxwork(struct work_struct *work)
|
||||
break;
|
||||
case BTM_BTFMCODEC_USECASE_START_RSP:
|
||||
idx = BTM_PKT_TYPE_USECASE_START_RSP;
|
||||
if (len == BTM_USECASE_START_RSP_LEN) {
|
||||
if (len == BTM_USECASE_START_IND_LEN) {
|
||||
status = skb->data[0];
|
||||
if (status == MSG_SUCCESS)
|
||||
btfmcodec_dev->status[idx] = BTM_RSP_RECV;
|
||||
|
||||
@@ -305,11 +305,7 @@ void btfmcodec_prepare_bearer(struct btfmcodec_char_device *btfmcodec_dev,
|
||||
ret = btfmcodec_wait_for_bearer_ind(btfmcodec_dev);
|
||||
if (ret < 0) {
|
||||
BTFMCODEC_ERR("moving back to previous state");
|
||||
if (btfmcodec_get_current_transport(state) == IDLE) {
|
||||
BTFMCODEC_INFO("state moved to IDLE");
|
||||
} else if (current_state == btfmcodec_get_prev_transport(state)) {
|
||||
btfmcodec_revert_current_state(state);
|
||||
}
|
||||
btfmcodec_revert_current_state(state);
|
||||
if (ret == -MSG_INTERNAL_TIMEOUT) {
|
||||
btfmcodec_frame_transport_switch_ind_pkt(
|
||||
btfmcodec_dev, BTADV,
|
||||
@@ -321,7 +317,7 @@ void btfmcodec_prepare_bearer(struct btfmcodec_char_device *btfmcodec_dev,
|
||||
if (ret < 0)
|
||||
return;
|
||||
|
||||
if (current_state != IDLE && btfmcodec_is_valid_cache_avb(btfmcodec)) {
|
||||
if (btfmcodec_is_valid_cache_avb(btfmcodec)) {
|
||||
BTFMCODEC_INFO("Initiating BT port close...");
|
||||
btfmcodec_initiate_hwep_shutdown(btfmcodec_dev);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* Copyright (c) 2023-2025 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
* Copyright (c) 2023-2024 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <linux/kernel.h>
|
||||
@@ -14,7 +14,6 @@
|
||||
static struct snd_soc_dai_driver *btfmcodec_dai_info;
|
||||
uint32_t bits_per_second;
|
||||
uint8_t num_channels;
|
||||
static int btfmcodec_port_state_notify(uint8_t port_state);
|
||||
|
||||
static int btfm_codec_get_mixer_control(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
@@ -286,7 +285,6 @@ void btfmcodec_wq_hwep_shutdown(struct work_struct *work)
|
||||
list_for_each_entry_safe(hwep_configs, tmp, head, dai_list) {
|
||||
BTFMCODEC_INFO("shuting down dai id:%d", hwep_configs->stream_id);
|
||||
ret = btfmcodec_hwep_shutdown(btfmcodec, hwep_configs->stream_id, true);
|
||||
hwep_configs->is_port_opened = 0;
|
||||
if (ret < 0) {
|
||||
BTFMCODEC_ERR("failed to shutdown master with id %d", hwep_configs->stream_id);
|
||||
break;
|
||||
@@ -328,19 +326,6 @@ static void btfmcodec_dai_shutdown(struct snd_pcm_substream *substream,
|
||||
BTFMCODEC_DBG("dai->name: %s, dai->id: %d, dai->rate: %d", dai->name,
|
||||
dai->id, dai->rate);
|
||||
|
||||
if (btfmcodec_get_current_transport(state) == IDLE) {
|
||||
BTFMCODEC_INFO("%s not allowing shutdown as state is IDLE", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((btfmcodec_get_current_transport(state) == BTADV_AUDIO_Connecting &&
|
||||
btfmcodec_get_prev_transport(state) == BT_Connected) ||
|
||||
((btfmcodec_get_current_transport(state) == BT_Connecting &&
|
||||
btfmcodec_get_prev_transport(state) == BTADV_AUDIO_Connected))) {
|
||||
BTFMCODEC_INFO("%s: Informing port closure to upper layers", __func__);
|
||||
btfmcodec_port_state_notify(IDLE);
|
||||
}
|
||||
|
||||
if (btfmcodec_get_current_transport(state) == BTADV_AUDIO_Connecting &&
|
||||
btfmcodec_get_prev_transport(state) == BT_Connected) {
|
||||
BTFMCODEC_INFO("%s: closing these ports as graph stopped when CIS is active",
|
||||
@@ -356,10 +341,10 @@ static void btfmcodec_dai_shutdown(struct snd_pcm_substream *substream,
|
||||
btfmcodec_get_current_transport(state) != BT_Connected) ||
|
||||
(btfmcodec_get_current_transport(state) == BTADV_AUDIO_Connecting &&
|
||||
btfmcodec_get_prev_transport(state) != BT_Connected)) {
|
||||
BTFMCODEC_WARN("Allowing cache retention in current state:%s, prev state: %s",
|
||||
coverttostring(btfmcodec_get_current_transport(state)),
|
||||
coverttostring(btfmcodec_get_prev_transport(state)));
|
||||
return;
|
||||
BTFMCODEC_WARN("not allowing shutdown as state is:%s",
|
||||
coverttostring(btfmcodec_get_current_transport(state)));
|
||||
/* Delete stored configs */
|
||||
btfmcodec_delete_configs(btfmcodec, dai->id);
|
||||
} else {
|
||||
/* first master shutdown has to done */
|
||||
btfmcodec_hwep_shutdown(btfmcodec, dai->id, false);
|
||||
@@ -616,21 +601,11 @@ int btfmcodec_hwep_prepare(struct btfmcodec_data *btfmcodec, uint32_t sampling_r
|
||||
btfmcodec_set_current_state(state, BT_Connected);
|
||||
}
|
||||
} else if (ret == 0 && test_bit(BTADV_CONFIGURE_DMA, &hwep_info->flags)) {
|
||||
/* Don't send request to cp for fm as it is non cp */
|
||||
if (id == 0)
|
||||
return ret;
|
||||
ret = btfmcodec_configure_dma(btfmcodec, (uint8_t)id);
|
||||
if (ret < 0) {
|
||||
BTFMCODEC_ERR("failed to configure Codec DMA %d", ret);
|
||||
if (seamless == false)
|
||||
btfmcodec_set_current_state(state, IDLE);
|
||||
else {
|
||||
if (dai_drv && dai_drv->dai_ops &&
|
||||
dai_drv->dai_ops->hwep_shutdown) {
|
||||
dai_drv->dai_ops->hwep_shutdown((void *)hwep_info,
|
||||
id);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (seamless == false)
|
||||
btfmcodec_set_current_state(state, BT_Connected);
|
||||
@@ -644,7 +619,7 @@ int btfmcodec_hwep_prepare(struct btfmcodec_data *btfmcodec, uint32_t sampling_r
|
||||
}
|
||||
|
||||
static int btfmcodec_notify_usecase_start(struct btfmcodec_data *btfmcodec,
|
||||
uint8_t transport, uint8_t stream_id)
|
||||
uint8_t transport)
|
||||
{
|
||||
struct btfmcodec_char_device *btfmcodec_dev = btfmcodec->btfmcodec_dev;
|
||||
struct btm_usecase_start_ind ind;
|
||||
@@ -657,7 +632,6 @@ static int btfmcodec_notify_usecase_start(struct btfmcodec_data *btfmcodec,
|
||||
ind.opcode = BTM_BTFMCODEC_USECASE_START_REQ;
|
||||
ind.len = BTM_USECASE_START_IND_LEN;
|
||||
ind.transport = transport;
|
||||
ind.stream_id = stream_id;
|
||||
ret = btfmcodec_dev_enqueue_pkt(btfmcodec_dev, &ind, (ind.len + BTM_HEADER_LEN));
|
||||
|
||||
if (ret < 0)
|
||||
@@ -708,7 +682,9 @@ static int btfmcodec_dai_prepare(struct snd_pcm_substream *substream,
|
||||
btfmcodec_get_current_transport(state) != BT_Connected) {
|
||||
BTFMCODEC_WARN("cached required info as state is:%s",
|
||||
coverttostring(btfmcodec_get_current_transport(state)));
|
||||
ret = btfmcodec_notify_usecase_start(btfmcodec, BTADV, (uint8_t)id);
|
||||
if (direction == 0) {
|
||||
ret = btfmcodec_notify_usecase_start(btfmcodec, BTADV);
|
||||
}
|
||||
} else {
|
||||
ret = btfmcodec_hwep_prepare(btfmcodec, sampling_rate, direction, id, false);
|
||||
/* if (ret >= 0) {
|
||||
@@ -821,31 +797,16 @@ void btfmcodec_wq_hwep_configure(struct work_struct *work)
|
||||
if (ret >= 0)
|
||||
ret = btfmcodec_hwep_prepare(btfmcodec, sample_rate, direction, id, true);
|
||||
if (ret < 0) {
|
||||
hwep_configs->is_port_opened = 1;
|
||||
BTFMCODEC_ERR("failed to configure hwep %d", hwep_configs->stream_id);
|
||||
break;
|
||||
} else {
|
||||
hwep_configs->is_port_opened = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (ret < 0) {
|
||||
list_for_each_entry_safe(hwep_configs, tmp, head, dai_list) {
|
||||
if (hwep_configs->is_port_opened) {
|
||||
BTFMCODEC_INFO("shuting down dai id:%d", hwep_configs->stream_id);
|
||||
ret = btfmcodec_hwep_shutdown(btfmcodec, hwep_configs->stream_id,
|
||||
true);
|
||||
hwep_configs->is_port_opened = 0;
|
||||
if (ret < 0) {
|
||||
BTFMCODEC_ERR("failed to shutdown master with id %d",
|
||||
hwep_configs->stream_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ret < 0)
|
||||
btfmcodec_dev->status[idx] = BTM_FAIL_RESP_RECV;
|
||||
} else {
|
||||
else
|
||||
btfmcodec_dev->status[idx] = BTM_RSP_RECV;
|
||||
}
|
||||
|
||||
wake_up_interruptible(&btfmcodec_dev->rsp_wait_q[idx]);
|
||||
}
|
||||
static struct snd_soc_dai_ops btfmcodec_dai_ops = {
|
||||
@@ -891,23 +852,6 @@ static int btfmcodec_adsp_ssr_notify(struct notifier_block *nb,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int btfmcodec_port_state_notify(uint8_t port_state)
|
||||
{
|
||||
struct btm_port_state_ind state_ind;
|
||||
struct btfmcodec_data *btfmcodec;
|
||||
struct btfmcodec_char_device *btfmcodec_dev;
|
||||
|
||||
BTFMCODEC_WARN("%s: port state = %d", __func__, port_state);
|
||||
btfmcodec = btfm_get_btfmcodec();
|
||||
btfmcodec_dev = btfmcodec->btfmcodec_dev;
|
||||
state_ind.opcode = BTM_BTFMCODEC_PORT_STATE_IND;
|
||||
state_ind.len = BTM_PORT_STATE_IND_LEN;
|
||||
state_ind.port_state = (uint8_t)port_state;
|
||||
btfmcodec_dev_enqueue_pkt(btfmcodec_dev, &state_ind,
|
||||
(state_ind.len + BTM_HEADER_LEN));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int btfm_register_codec(struct hwep_data *hwep_info)
|
||||
{
|
||||
struct btfmcodec_data *btfmcodec;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* Copyright (c) 2023-2025 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
* Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef __LINUX_BTFM_CODEC_HW_INTERFACE_H
|
||||
@@ -29,7 +29,6 @@ struct hwep_configurations {
|
||||
uint8_t codectype;
|
||||
uint32_t direction;
|
||||
uint8_t num_channels;
|
||||
uint8_t is_port_opened;
|
||||
struct list_head dai_list;
|
||||
};
|
||||
|
||||
|
||||
@@ -45,11 +45,10 @@ struct btm_ctrl_pkt {
|
||||
#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_BEARER_SWITCH_IND_TIMEOUT 17000
|
||||
#define BTM_MASTER_DMA_CONFIG_RSP_TIMEOUT 5000
|
||||
#define BTM_HEADER_LEN 8
|
||||
#define BTM_PREPARE_AUDIO_BEARER_SWITCH_RSP_LEN 2
|
||||
@@ -61,12 +60,10 @@ struct btm_ctrl_pkt {
|
||||
#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
|
||||
#define BTM_USECASE_START_IND_LEN 1
|
||||
|
||||
enum rx_status {
|
||||
/* Waiting for response */
|
||||
@@ -103,7 +100,7 @@ struct btm_master_config_req {
|
||||
uint8_t num_channels;
|
||||
uint8_t channel_num;
|
||||
uint8_t codec_id;
|
||||
} __packed;
|
||||
}__attribute__((packed));
|
||||
|
||||
struct btm_dma_config_req {
|
||||
btm_opcode opcode;
|
||||
@@ -122,26 +119,19 @@ 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;
|
||||
}__attribute__((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;
|
||||
} __attribute__((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);
|
||||
|
||||
Reference in New Issue
Block a user