Lines Matching full:tx
27 /* TX */
130 spinlock_t tx_lock; /* spinlock for bt tx stream control */
135 struct mtk_btcvsd_snd_stream *tx; member
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()
234 memset(bt->tx, 0, sizeof(*bt->tx)); 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()
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()
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()
332 /* write mute data to bt tx sram buffer */ in btcvsd_tx_clean_buffer()
334 num_valid_addr = bt->tx->buffer_info.num_valid_addr; 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()
435 memcpy(bt->tx->temp_packet_buf + (bt->tx->packet_size * i), 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()
447 if (!bt->tx->mute) { in mtk_btcvsd_write_to_bt()
449 bt->tx->temp_packet_buf, dst, in mtk_btcvsd_write_to_bt()
453 /* store bt tx buffer sram info */ 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()
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()
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()
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()
517 if (bt->tx->state == BT_SCO_STATE_LOOPBACK) { 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()
550 bt->tx->rw_cnt++; in mtk_btcvsd_snd_irq_handler()
584 /* tx */ 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()
591 * interrupt tx data size 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()
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()
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()
628 snd_pcm_period_elapsed(bt->tx->substream); in mtk_btcvsd_snd_irq_handler()
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()
798 /* free space of TX packet buffer */ 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()
807 int ret = wait_for_bt_irq(bt, bt->tx); in mtk_btcvsd_snd_write()
815 /* count must be multiple of bt->tx->packet_size */ in mtk_btcvsd_snd_write()
830 cont = bt->tx->buf_size - cur_write_idx; in mtk_btcvsd_snd_write()
842 bt->tx->packet_w += write_size / packet_size; in mtk_btcvsd_snd_write()
854 return bt->tx; in get_bt_stream()
884 bt->tx->substream = substream; in mtk_pcm_btcvsd_open()
913 params_buffer_bytes(hw_params) % bt->tx->packet_size != 0) { in mtk_pcm_btcvsd_hw_params()
992 bt_stream = bt->tx; in mtk_pcm_btcvsd_pointer()
1000 bt->tx->packet_r : bt->rx->packet_w; in mtk_pcm_btcvsd_pointer()
1076 bool lpbk_en = bt->tx->state == BT_SCO_STATE_LOOPBACK; in btcvsd_loopback_get()
1089 mtk_btcvsd_snd_set_state(bt, bt->tx, 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()
1104 if (!bt->tx) { in btcvsd_tx_mute_get()
1109 ucontrol->value.integer.value[0] = bt->tx->mute; in btcvsd_tx_mute_get()
1119 if (!bt->tx) in btcvsd_tx_mute_set()
1122 bt->tx->mute = ucontrol->value.integer.value[0]; in btcvsd_tx_mute_set()
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()
1199 ucontrol->value.integer.value[0] = bt->tx->timeout; in btcvsd_tx_timeout_get()
1235 SOC_SINGLE_BOOL_EXT("BTCVSD Tx Mute Switch", 0,
1237 SOC_SINGLE_BOOL_EXT("BTCVSD Tx Irq Received Switch", 0,
1239 SOC_SINGLE_BOOL_EXT("BTCVSD Tx Timeout Switch", 0,
1248 SND_SOC_BYTES_TLV("BTCVSD Tx Timestamp",
1288 /* init tx/rx */ in mtk_btcvsd_snd_probe()
1293 btcvsd->tx = devm_kzalloc(btcvsd->dev, sizeof(*btcvsd->tx), GFP_KERNEL); in mtk_btcvsd_snd_probe()
1294 if (!btcvsd->tx) in mtk_btcvsd_snd_probe()
1366 mtk_btcvsd_snd_set_state(btcvsd, btcvsd->tx, BT_SCO_STATE_IDLE); in mtk_btcvsd_snd_probe()