Lines Matching refs:bt
193 static void mtk_btcvsd_snd_irq_enable(struct mtk_btcvsd_snd *bt) in mtk_btcvsd_snd_irq_enable() argument
195 regmap_update_bits(bt->infra, bt->infra_misc_offset, in mtk_btcvsd_snd_irq_enable()
196 bt->conn_bt_cvsd_mask, 0); in mtk_btcvsd_snd_irq_enable()
199 static void mtk_btcvsd_snd_irq_disable(struct mtk_btcvsd_snd *bt) in mtk_btcvsd_snd_irq_disable() argument
201 regmap_update_bits(bt->infra, bt->infra_misc_offset, in mtk_btcvsd_snd_irq_disable()
202 bt->conn_bt_cvsd_mask, bt->conn_bt_cvsd_mask); in mtk_btcvsd_snd_irq_disable()
205 static void mtk_btcvsd_snd_set_state(struct mtk_btcvsd_snd *bt, in mtk_btcvsd_snd_set_state() argument
209 dev_dbg(bt->dev, "%s(), stream %d, state %d, tx->state %d, rx->state %d, irq_disabled %d\n", in mtk_btcvsd_snd_set_state()
212 bt->tx->state, bt->rx->state, bt->irq_disabled); in mtk_btcvsd_snd_set_state()
216 if (bt->tx->state == BT_SCO_STATE_IDLE && in mtk_btcvsd_snd_set_state()
217 bt->rx->state == BT_SCO_STATE_IDLE) { in mtk_btcvsd_snd_set_state()
218 if (!bt->irq_disabled) { in mtk_btcvsd_snd_set_state()
219 disable_irq(bt->irq_id); in mtk_btcvsd_snd_set_state()
220 mtk_btcvsd_snd_irq_disable(bt); in mtk_btcvsd_snd_set_state()
221 bt->irq_disabled = 1; in mtk_btcvsd_snd_set_state()
224 if (bt->irq_disabled) { in mtk_btcvsd_snd_set_state()
225 enable_irq(bt->irq_id); in mtk_btcvsd_snd_set_state()
226 mtk_btcvsd_snd_irq_enable(bt); in mtk_btcvsd_snd_set_state()
227 bt->irq_disabled = 0; in mtk_btcvsd_snd_set_state()
232 static int mtk_btcvsd_snd_tx_init(struct mtk_btcvsd_snd *bt) in mtk_btcvsd_snd_tx_init() argument
234 memset(bt->tx, 0, sizeof(*bt->tx)); in mtk_btcvsd_snd_tx_init()
235 memset(bt->tx_packet_buf, 0, sizeof(bt->tx_packet_buf)); in mtk_btcvsd_snd_tx_init()
237 bt->tx->packet_size = BTCVSD_TX_PACKET_SIZE; in mtk_btcvsd_snd_tx_init()
238 bt->tx->buf_size = BTCVSD_TX_BUF_SIZE; in mtk_btcvsd_snd_tx_init()
239 bt->tx->timeout = 0; in mtk_btcvsd_snd_tx_init()
240 bt->tx->rw_cnt = 0; in mtk_btcvsd_snd_tx_init()
241 bt->tx->stream = SNDRV_PCM_STREAM_PLAYBACK; in mtk_btcvsd_snd_tx_init()
245 static int mtk_btcvsd_snd_rx_init(struct mtk_btcvsd_snd *bt) in mtk_btcvsd_snd_rx_init() argument
247 memset(bt->rx, 0, sizeof(*bt->rx)); in mtk_btcvsd_snd_rx_init()
248 memset(bt->rx_packet_buf, 0, sizeof(bt->rx_packet_buf)); in mtk_btcvsd_snd_rx_init()
250 bt->rx->packet_size = BTCVSD_RX_PACKET_SIZE; in mtk_btcvsd_snd_rx_init()
251 bt->rx->buf_size = BTCVSD_RX_BUF_SIZE; in mtk_btcvsd_snd_rx_init()
252 bt->rx->timeout = 0; in mtk_btcvsd_snd_rx_init()
253 bt->rx->rw_cnt = 0; in mtk_btcvsd_snd_rx_init()
254 bt->rx->stream = SNDRV_PCM_STREAM_CAPTURE; in mtk_btcvsd_snd_rx_init()
258 static void get_tx_time_stamp(struct mtk_btcvsd_snd *bt, in get_tx_time_stamp() argument
261 ts->time_stamp_us = bt->tx->time_stamp; in get_tx_time_stamp()
262 ts->data_count_equi_time = bt->tx->buf_data_equivalent_time; in get_tx_time_stamp()
265 static void get_rx_time_stamp(struct mtk_btcvsd_snd *bt, in get_rx_time_stamp() argument
268 ts->time_stamp_us = bt->rx->time_stamp; in get_rx_time_stamp()
269 ts->data_count_equi_time = bt->rx->buf_data_equivalent_time; in get_rx_time_stamp()
318 static int btcvsd_tx_clean_buffer(struct mtk_btcvsd_snd *bt) in btcvsd_tx_clean_buffer() argument
323 enum BT_SCO_BAND band = bt->band; in btcvsd_tx_clean_buffer()
327 memset(bt->tx->temp_packet_buf, 170, SCO_PACKET_180); in btcvsd_tx_clean_buffer()
329 memcpy(bt->tx->temp_packet_buf, in btcvsd_tx_clean_buffer()
333 spin_lock_irqsave(&bt->tx_lock, flags); in btcvsd_tx_clean_buffer()
334 num_valid_addr = bt->tx->buffer_info.num_valid_addr; in btcvsd_tx_clean_buffer()
336 dev_info(bt->dev, "%s(), band %d, num_valid_addr %u\n", in btcvsd_tx_clean_buffer()
342 dev_info(bt->dev, "%s(), clean addr 0x%lx\n", __func__, in btcvsd_tx_clean_buffer()
343 bt->tx->buffer_info.bt_sram_addr[i]); in btcvsd_tx_clean_buffer()
345 dst = (void *)bt->tx->buffer_info.bt_sram_addr[i]; in btcvsd_tx_clean_buffer()
348 bt->tx->temp_packet_buf, dst, in btcvsd_tx_clean_buffer()
349 bt->tx->buffer_info.packet_length, in btcvsd_tx_clean_buffer()
350 bt->tx->buffer_info.packet_num); in btcvsd_tx_clean_buffer()
352 spin_unlock_irqrestore(&bt->tx_lock, flags); in btcvsd_tx_clean_buffer()
357 static int mtk_btcvsd_read_from_bt(struct mtk_btcvsd_snd *bt, in mtk_btcvsd_read_from_bt() argument
371 connsys_addr_rx = *bt->bt_reg_pkt_r; in mtk_btcvsd_read_from_bt()
372 ap_addr_rx = (unsigned long)bt->bt_sram_bank2_base + in mtk_btcvsd_read_from_bt()
377 dev_warn(bt->dev, "%s(), connsys_addr_rx == 0xdeadfeed", in mtk_btcvsd_read_from_bt()
385 bt->rx->temp_packet_buf, packet_length, in mtk_btcvsd_read_from_bt()
388 spin_lock_irqsave(&bt->rx_lock, flags); in mtk_btcvsd_read_from_bt()
390 packet_buf_ofs = (bt->rx->packet_w & SCO_RX_PACKET_MASK) * in mtk_btcvsd_read_from_bt()
391 bt->rx->packet_size; in mtk_btcvsd_read_from_bt()
392 memcpy(bt->rx_packet_buf + packet_buf_ofs, in mtk_btcvsd_read_from_bt()
393 bt->rx->temp_packet_buf + (SCO_RX_PLC_SIZE * i), in mtk_btcvsd_read_from_bt()
402 memcpy(bt->rx_packet_buf + packet_buf_ofs, (void *)&pv, in mtk_btcvsd_read_from_bt()
404 bt->rx->packet_w++; in mtk_btcvsd_read_from_bt()
406 spin_unlock_irqrestore(&bt->rx_lock, flags); in mtk_btcvsd_read_from_bt()
410 static int mtk_btcvsd_write_to_bt(struct mtk_btcvsd_snd *bt, in mtk_btcvsd_write_to_bt() argument
422 connsys_addr_tx = *bt->bt_reg_pkt_w; in mtk_btcvsd_write_to_bt()
423 ap_addr_tx = (unsigned long)bt->bt_sram_bank2_base + in mtk_btcvsd_write_to_bt()
428 dev_warn(bt->dev, "%s(), connsys_addr_tx == 0xdeadfeed\n", in mtk_btcvsd_write_to_bt()
433 spin_lock_irqsave(&bt->tx_lock, flags); in mtk_btcvsd_write_to_bt()
435 memcpy(bt->tx->temp_packet_buf + (bt->tx->packet_size * i), in mtk_btcvsd_write_to_bt()
436 (bt->tx_packet_buf + in mtk_btcvsd_write_to_bt()
437 (bt->tx->packet_r % SCO_TX_PACKER_BUF_NUM) * in mtk_btcvsd_write_to_bt()
438 bt->tx->packet_size), in mtk_btcvsd_write_to_bt()
439 bt->tx->packet_size); in mtk_btcvsd_write_to_bt()
441 bt->tx->packet_r++; in mtk_btcvsd_write_to_bt()
443 spin_unlock_irqrestore(&bt->tx_lock, flags); in mtk_btcvsd_write_to_bt()
447 if (!bt->tx->mute) { in mtk_btcvsd_write_to_bt()
449 bt->tx->temp_packet_buf, dst, in mtk_btcvsd_write_to_bt()
454 bt->tx->buffer_info.packet_length = packet_length; in mtk_btcvsd_write_to_bt()
455 bt->tx->buffer_info.packet_num = packet_num; in mtk_btcvsd_write_to_bt()
456 for (i = 0; i < bt->tx->buffer_info.num_valid_addr; i++) { in mtk_btcvsd_write_to_bt()
457 if (bt->tx->buffer_info.bt_sram_addr[i] == ap_addr_tx) { in mtk_btcvsd_write_to_bt()
465 spin_lock_irqsave(&bt->tx_lock, flags); in mtk_btcvsd_write_to_bt()
466 bt->tx->buffer_info.num_valid_addr++; in mtk_btcvsd_write_to_bt()
467 next_idx = bt->tx->buffer_info.num_valid_addr - 1; in mtk_btcvsd_write_to_bt()
468 bt->tx->buffer_info.bt_sram_addr[next_idx] = ap_addr_tx; in mtk_btcvsd_write_to_bt()
469 spin_unlock_irqrestore(&bt->tx_lock, flags); in mtk_btcvsd_write_to_bt()
470 dev_info(bt->dev, "%s(), new ap_addr_tx = 0x%lx, num_valid_addr %d\n", in mtk_btcvsd_write_to_bt()
472 bt->tx->buffer_info.num_valid_addr); in mtk_btcvsd_write_to_bt()
475 if (bt->tx->mute) in mtk_btcvsd_write_to_bt()
476 btcvsd_tx_clean_buffer(bt); in mtk_btcvsd_write_to_bt()
483 struct mtk_btcvsd_snd *bt = dev; in mtk_btcvsd_snd_irq_handler() local
487 if (bt->rx->state != BT_SCO_STATE_RUNNING && in mtk_btcvsd_snd_irq_handler()
488 bt->rx->state != BT_SCO_STATE_ENDING && in mtk_btcvsd_snd_irq_handler()
489 bt->tx->state != BT_SCO_STATE_RUNNING && in mtk_btcvsd_snd_irq_handler()
490 bt->tx->state != BT_SCO_STATE_ENDING && in mtk_btcvsd_snd_irq_handler()
491 bt->tx->state != BT_SCO_STATE_LOOPBACK) { in mtk_btcvsd_snd_irq_handler()
492 dev_warn(bt->dev, "%s(), in idle state: rx->state: %d, tx->state: %d\n", in mtk_btcvsd_snd_irq_handler()
493 __func__, bt->rx->state, bt->tx->state); in mtk_btcvsd_snd_irq_handler()
497 control = *bt->bt_reg_ctl; in mtk_btcvsd_snd_irq_handler()
501 dev_warn(bt->dev, "%s(), ((control >> 31) & 1) == 0, control 0x%x\n", in mtk_btcvsd_snd_irq_handler()
507 dev_warn(bt->dev, "%s(), invalid packet_type %u, exit\n", in mtk_btcvsd_snd_irq_handler()
517 if (bt->tx->state == BT_SCO_STATE_LOOPBACK) { in mtk_btcvsd_snd_irq_handler()
522 connsys_addr_rx = *bt->bt_reg_pkt_r; in mtk_btcvsd_snd_irq_handler()
523 ap_addr_rx = (unsigned long)bt->bt_sram_bank2_base + in mtk_btcvsd_snd_irq_handler()
526 connsys_addr_tx = *bt->bt_reg_pkt_w; in mtk_btcvsd_snd_irq_handler()
527 ap_addr_tx = (unsigned long)bt->bt_sram_bank2_base + in mtk_btcvsd_snd_irq_handler()
533 dev_warn(bt->dev, "%s(), connsys_addr_tx == 0xdeadfeed\n", in mtk_btcvsd_snd_irq_handler()
542 bt->tx->temp_packet_buf, in mtk_btcvsd_snd_irq_handler()
546 bt->tx->temp_packet_buf, dst, in mtk_btcvsd_snd_irq_handler()
549 bt->rx->rw_cnt++; in mtk_btcvsd_snd_irq_handler()
550 bt->tx->rw_cnt++; in mtk_btcvsd_snd_irq_handler()
553 if (bt->rx->state == BT_SCO_STATE_RUNNING || in mtk_btcvsd_snd_irq_handler()
554 bt->rx->state == BT_SCO_STATE_ENDING) { in mtk_btcvsd_snd_irq_handler()
555 if (bt->rx->xrun) { in mtk_btcvsd_snd_irq_handler()
556 if (bt->rx->packet_w - bt->rx->packet_r <= in mtk_btcvsd_snd_irq_handler()
562 bt->rx->xrun = 0; in mtk_btcvsd_snd_irq_handler()
563 dev_warn(bt->dev, "%s(), rx->xrun 0!\n", in mtk_btcvsd_snd_irq_handler()
568 if (!bt->rx->xrun && in mtk_btcvsd_snd_irq_handler()
569 (bt->rx->packet_w - bt->rx->packet_r <= in mtk_btcvsd_snd_irq_handler()
571 mtk_btcvsd_read_from_bt(bt, in mtk_btcvsd_snd_irq_handler()
577 bt->rx->rw_cnt++; in mtk_btcvsd_snd_irq_handler()
579 bt->rx->xrun = 1; in mtk_btcvsd_snd_irq_handler()
580 dev_warn(bt->dev, "%s(), rx->xrun 1\n", __func__); in mtk_btcvsd_snd_irq_handler()
585 bt->tx->timeout = 0; in mtk_btcvsd_snd_irq_handler()
586 if ((bt->tx->state == BT_SCO_STATE_RUNNING || in mtk_btcvsd_snd_irq_handler()
587 bt->tx->state == BT_SCO_STATE_ENDING) && in mtk_btcvsd_snd_irq_handler()
588 bt->tx->trigger_start) { in mtk_btcvsd_snd_irq_handler()
589 if (bt->tx->xrun) { in mtk_btcvsd_snd_irq_handler()
593 if (bt->tx->packet_w - bt->tx->packet_r >= in mtk_btcvsd_snd_irq_handler()
595 bt->tx->xrun = 0; in mtk_btcvsd_snd_irq_handler()
596 dev_warn(bt->dev, "%s(), tx->xrun 0\n", in mtk_btcvsd_snd_irq_handler()
601 if ((!bt->tx->xrun && in mtk_btcvsd_snd_irq_handler()
602 (bt->tx->packet_w - bt->tx->packet_r >= buf_cnt_tx)) || in mtk_btcvsd_snd_irq_handler()
603 bt->tx->state == BT_SCO_STATE_ENDING) { in mtk_btcvsd_snd_irq_handler()
604 mtk_btcvsd_write_to_bt(bt, in mtk_btcvsd_snd_irq_handler()
609 bt->tx->rw_cnt++; in mtk_btcvsd_snd_irq_handler()
611 bt->tx->xrun = 1; in mtk_btcvsd_snd_irq_handler()
612 dev_warn(bt->dev, "%s(), tx->xrun 1\n", __func__); in mtk_btcvsd_snd_irq_handler()
616 *bt->bt_reg_ctl &= ~BT_CVSD_CLEAR; in mtk_btcvsd_snd_irq_handler()
618 if (bt->rx->state == BT_SCO_STATE_RUNNING || in mtk_btcvsd_snd_irq_handler()
619 bt->rx->state == BT_SCO_STATE_ENDING) { in mtk_btcvsd_snd_irq_handler()
620 bt->rx->wait_flag = 1; in mtk_btcvsd_snd_irq_handler()
621 wake_up_interruptible(&bt->rx_wait); in mtk_btcvsd_snd_irq_handler()
622 snd_pcm_period_elapsed(bt->rx->substream); in mtk_btcvsd_snd_irq_handler()
624 if (bt->tx->state == BT_SCO_STATE_RUNNING || in mtk_btcvsd_snd_irq_handler()
625 bt->tx->state == BT_SCO_STATE_ENDING) { in mtk_btcvsd_snd_irq_handler()
626 bt->tx->wait_flag = 1; in mtk_btcvsd_snd_irq_handler()
627 wake_up_interruptible(&bt->tx_wait); in mtk_btcvsd_snd_irq_handler()
628 snd_pcm_period_elapsed(bt->tx->substream); in mtk_btcvsd_snd_irq_handler()
633 *bt->bt_reg_ctl &= ~BT_CVSD_CLEAR; in mtk_btcvsd_snd_irq_handler()
637 static int wait_for_bt_irq(struct mtk_btcvsd_snd *bt, in wait_for_bt_irq() argument
651 ret = wait_event_interruptible_timeout(bt->tx_wait, in wait_for_bt_irq()
655 ret = wait_event_interruptible_timeout(bt->rx_wait, in wait_for_bt_irq()
664 dev_warn(bt->dev, "%s(), stream %d, timeout %llu, limit %llu, ret %d, flag %d\n", in wait_for_bt_irq()
675 dev_warn(bt->dev, "%s(), stream %d, error, trial left %d\n", in wait_for_bt_irq()
684 dev_warn(bt->dev, "%s(), stream %d, error, timeout, condition is false, trial left %d\n", in wait_for_bt_irq()
698 static ssize_t mtk_btcvsd_snd_read(struct mtk_btcvsd_snd *bt, in mtk_btcvsd_snd_read() argument
705 unsigned int packet_size = bt->rx->packet_size; in mtk_btcvsd_snd_read()
708 spin_lock_irqsave(&bt->rx_lock, flags); in mtk_btcvsd_snd_read()
710 avail = (bt->rx->packet_w - bt->rx->packet_r) * packet_size; in mtk_btcvsd_snd_read()
712 cur_read_idx = (bt->rx->packet_r & SCO_RX_PACKET_MASK) * in mtk_btcvsd_snd_read()
714 spin_unlock_irqrestore(&bt->rx_lock, flags); in mtk_btcvsd_snd_read()
717 int ret = wait_for_bt_irq(bt, bt->rx); in mtk_btcvsd_snd_read()
728 dev_warn(bt->dev, "%s(), count %zu or d %lu is not multiple of packet_size %dd\n", in mtk_btcvsd_snd_read()
741 cont = bt->rx->buf_size - cur_read_idx; in mtk_btcvsd_snd_read()
745 if (copy_to_iter(bt->rx_packet_buf + cur_read_idx, in mtk_btcvsd_snd_read()
747 dev_warn(bt->dev, "%s(), copy_to_iter fail\n", in mtk_btcvsd_snd_read()
752 spin_lock_irqsave(&bt->rx_lock, flags); in mtk_btcvsd_snd_read()
753 bt->rx->packet_r += read_size / packet_size; in mtk_btcvsd_snd_read()
754 spin_unlock_irqrestore(&bt->rx_lock, flags); in mtk_btcvsd_snd_read()
764 bt->rx->time_stamp = sched_clock(); in mtk_btcvsd_snd_read()
765 bt->rx->buf_data_equivalent_time = in mtk_btcvsd_snd_read()
766 (unsigned long long)(bt->rx->packet_w - bt->rx->packet_r) * in mtk_btcvsd_snd_read()
768 bt->rx->buf_data_equivalent_time += read_count * SCO_RX_PLC_SIZE * in mtk_btcvsd_snd_read()
771 bt->rx->buf_data_equivalent_time *= 1000; in mtk_btcvsd_snd_read()
776 static ssize_t mtk_btcvsd_snd_write(struct mtk_btcvsd_snd *bt, in mtk_btcvsd_snd_write() argument
782 unsigned int packet_size = bt->tx->packet_size; in mtk_btcvsd_snd_write()
788 bt->tx->time_stamp = sched_clock(); in mtk_btcvsd_snd_write()
789 bt->tx->buf_data_equivalent_time = in mtk_btcvsd_snd_write()
790 (unsigned long long)(bt->tx->packet_w - bt->tx->packet_r) * in mtk_btcvsd_snd_write()
794 bt->tx->buf_data_equivalent_time *= 1000; in mtk_btcvsd_snd_write()
797 spin_lock_irqsave(&bt->tx_lock, flags); in mtk_btcvsd_snd_write()
799 avail = bt->tx->buf_size - in mtk_btcvsd_snd_write()
800 (bt->tx->packet_w - bt->tx->packet_r) * packet_size; in mtk_btcvsd_snd_write()
802 cur_write_idx = (bt->tx->packet_w % SCO_TX_PACKER_BUF_NUM) * in mtk_btcvsd_snd_write()
804 spin_unlock_irqrestore(&bt->tx_lock, flags); in mtk_btcvsd_snd_write()
807 int ret = wait_for_bt_irq(bt, bt->tx); in mtk_btcvsd_snd_write()
818 dev_warn(bt->dev, "%s(), count %zu or avail %d is not multiple of packet_size %d\n", in mtk_btcvsd_snd_write()
830 cont = bt->tx->buf_size - cur_write_idx; in mtk_btcvsd_snd_write()
834 if (copy_from_iter(bt->tx_packet_buf + cur_write_idx, in mtk_btcvsd_snd_write()
836 dev_warn(bt->dev, "%s(), copy_from_iter fail\n", in mtk_btcvsd_snd_write()
841 spin_lock_irqsave(&bt->tx_lock, flags); in mtk_btcvsd_snd_write()
842 bt->tx->packet_w += write_size / packet_size; in mtk_btcvsd_snd_write()
843 spin_unlock_irqrestore(&bt->tx_lock, flags); in mtk_btcvsd_snd_write()
851 (struct mtk_btcvsd_snd *bt, struct snd_pcm_substream *substream) in get_bt_stream() argument
854 return bt->tx; in get_bt_stream()
856 return bt->rx; in get_bt_stream()
874 struct mtk_btcvsd_snd *bt = snd_soc_component_get_drvdata(component); in mtk_pcm_btcvsd_open() local
877 dev_dbg(bt->dev, "%s(), stream %d, substream %p\n", in mtk_pcm_btcvsd_open()
883 ret = mtk_btcvsd_snd_tx_init(bt); in mtk_pcm_btcvsd_open()
884 bt->tx->substream = substream; in mtk_pcm_btcvsd_open()
886 ret = mtk_btcvsd_snd_rx_init(bt); in mtk_pcm_btcvsd_open()
887 bt->rx->substream = substream; in mtk_pcm_btcvsd_open()
896 struct mtk_btcvsd_snd *bt = snd_soc_component_get_drvdata(component); in mtk_pcm_btcvsd_close() local
897 struct mtk_btcvsd_snd_stream *bt_stream = get_bt_stream(bt, substream); in mtk_pcm_btcvsd_close()
899 dev_dbg(bt->dev, "%s(), stream %d\n", __func__, substream->stream); in mtk_pcm_btcvsd_close()
901 mtk_btcvsd_snd_set_state(bt, bt_stream, BT_SCO_STATE_IDLE); in mtk_pcm_btcvsd_close()
910 struct mtk_btcvsd_snd *bt = snd_soc_component_get_drvdata(component); in mtk_pcm_btcvsd_hw_params() local
913 params_buffer_bytes(hw_params) % bt->tx->packet_size != 0) { in mtk_pcm_btcvsd_hw_params()
914 dev_warn(bt->dev, "%s(), error, buffer size %d not valid\n", in mtk_pcm_btcvsd_hw_params()
927 struct mtk_btcvsd_snd *bt = snd_soc_component_get_drvdata(component); in mtk_pcm_btcvsd_hw_free() local
930 btcvsd_tx_clean_buffer(bt); in mtk_pcm_btcvsd_hw_free()
938 struct mtk_btcvsd_snd *bt = snd_soc_component_get_drvdata(component); in mtk_pcm_btcvsd_prepare() local
939 struct mtk_btcvsd_snd_stream *bt_stream = get_bt_stream(bt, substream); in mtk_pcm_btcvsd_prepare()
941 dev_dbg(bt->dev, "%s(), stream %d\n", __func__, substream->stream); in mtk_pcm_btcvsd_prepare()
943 mtk_btcvsd_snd_set_state(bt, bt_stream, BT_SCO_STATE_RUNNING); in mtk_pcm_btcvsd_prepare()
950 struct mtk_btcvsd_snd *bt = snd_soc_component_get_drvdata(component); in mtk_pcm_btcvsd_trigger() local
951 struct mtk_btcvsd_snd_stream *bt_stream = get_bt_stream(bt, substream); in mtk_pcm_btcvsd_trigger()
955 dev_dbg(bt->dev, "%s(), stream %d, cmd %d\n", in mtk_pcm_btcvsd_trigger()
970 mtk_btcvsd_snd_set_state(bt, bt_stream, BT_SCO_STATE_ENDING); in mtk_pcm_btcvsd_trigger()
981 struct mtk_btcvsd_snd *bt = snd_soc_component_get_drvdata(component); in mtk_pcm_btcvsd_pointer() local
991 lock = &bt->tx_lock; in mtk_pcm_btcvsd_pointer()
992 bt_stream = bt->tx; in mtk_pcm_btcvsd_pointer()
994 lock = &bt->rx_lock; in mtk_pcm_btcvsd_pointer()
995 bt_stream = bt->rx; in mtk_pcm_btcvsd_pointer()
1000 bt->tx->packet_r : bt->rx->packet_w; in mtk_pcm_btcvsd_pointer()
1031 struct mtk_btcvsd_snd *bt = snd_soc_component_get_drvdata(component); in mtk_pcm_btcvsd_copy() local
1034 return mtk_btcvsd_snd_write(bt, buf, count); in mtk_pcm_btcvsd_copy()
1036 return mtk_btcvsd_snd_read(bt, buf, count); in mtk_pcm_btcvsd_copy()
1050 struct mtk_btcvsd_snd *bt = snd_soc_component_get_drvdata(cmpnt); in btcvsd_band_get() local
1052 ucontrol->value.integer.value[0] = bt->band; in btcvsd_band_get()
1060 struct mtk_btcvsd_snd *bt = snd_soc_component_get_drvdata(cmpnt); in btcvsd_band_set() local
1066 bt->band = ucontrol->value.integer.value[0]; in btcvsd_band_set()
1067 dev_dbg(bt->dev, "%s(), band %d\n", __func__, bt->band); in btcvsd_band_set()
1075 struct mtk_btcvsd_snd *bt = snd_soc_component_get_drvdata(cmpnt); in btcvsd_loopback_get() local
1076 bool lpbk_en = bt->tx->state == BT_SCO_STATE_LOOPBACK; in btcvsd_loopback_get()
1086 struct mtk_btcvsd_snd *bt = snd_soc_component_get_drvdata(cmpnt); in btcvsd_loopback_set() local
1089 mtk_btcvsd_snd_set_state(bt, bt->tx, BT_SCO_STATE_LOOPBACK); in btcvsd_loopback_set()
1090 mtk_btcvsd_snd_set_state(bt, bt->rx, BT_SCO_STATE_LOOPBACK); in btcvsd_loopback_set()
1092 mtk_btcvsd_snd_set_state(bt, bt->tx, BT_SCO_STATE_RUNNING); in btcvsd_loopback_set()
1093 mtk_btcvsd_snd_set_state(bt, bt->rx, BT_SCO_STATE_RUNNING); in btcvsd_loopback_set()
1102 struct mtk_btcvsd_snd *bt = snd_soc_component_get_drvdata(cmpnt); in btcvsd_tx_mute_get() local
1104 if (!bt->tx) { in btcvsd_tx_mute_get()
1109 ucontrol->value.integer.value[0] = bt->tx->mute; in btcvsd_tx_mute_get()
1117 struct mtk_btcvsd_snd *bt = snd_soc_component_get_drvdata(cmpnt); in btcvsd_tx_mute_set() local
1119 if (!bt->tx) in btcvsd_tx_mute_set()
1122 bt->tx->mute = ucontrol->value.integer.value[0]; in btcvsd_tx_mute_set()
1130 struct mtk_btcvsd_snd *bt = snd_soc_component_get_drvdata(cmpnt); in btcvsd_rx_irq_received_get() local
1132 if (!bt->rx) in btcvsd_rx_irq_received_get()
1135 ucontrol->value.integer.value[0] = bt->rx->rw_cnt ? 1 : 0; in btcvsd_rx_irq_received_get()
1143 struct mtk_btcvsd_snd *bt = snd_soc_component_get_drvdata(cmpnt); in btcvsd_rx_timeout_get() local
1145 if (!bt->rx) in btcvsd_rx_timeout_get()
1148 ucontrol->value.integer.value[0] = bt->rx->timeout; in btcvsd_rx_timeout_get()
1149 bt->rx->timeout = 0; in btcvsd_rx_timeout_get()
1157 struct mtk_btcvsd_snd *bt = snd_soc_component_get_drvdata(cmpnt); in btcvsd_rx_timestamp_get() local
1164 get_rx_time_stamp(bt, &time_buffer_info_rx); in btcvsd_rx_timestamp_get()
1166 dev_dbg(bt->dev, "%s(), time_stamp_us %llu, data_count_equi_time %llu", in btcvsd_rx_timestamp_get()
1173 dev_warn(bt->dev, "%s(), copy_to_user fail", __func__); in btcvsd_rx_timestamp_get()
1184 struct mtk_btcvsd_snd *bt = snd_soc_component_get_drvdata(cmpnt); in btcvsd_tx_irq_received_get() local
1186 if (!bt->tx) in btcvsd_tx_irq_received_get()
1189 ucontrol->value.integer.value[0] = bt->tx->rw_cnt ? 1 : 0; in btcvsd_tx_irq_received_get()
1197 struct mtk_btcvsd_snd *bt = snd_soc_component_get_drvdata(cmpnt); in btcvsd_tx_timeout_get() local
1199 ucontrol->value.integer.value[0] = bt->tx->timeout; in btcvsd_tx_timeout_get()
1207 struct mtk_btcvsd_snd *bt = snd_soc_component_get_drvdata(cmpnt); in btcvsd_tx_timestamp_get() local
1214 get_tx_time_stamp(bt, &time_buffer_info_tx); in btcvsd_tx_timestamp_get()
1216 dev_dbg(bt->dev, "%s(), time_stamp_us %llu, data_count_equi_time %llu", in btcvsd_tx_timestamp_get()
1223 dev_warn(bt->dev, "%s(), copy_to_user fail", __func__); in btcvsd_tx_timestamp_get()