Lines Matching refs:prtd
184 struct q6asm_dai_rtd *prtd = priv;
185 struct snd_pcm_substream *substream = prtd->substream;
190 q6asm_write_async(prtd->audio_client, prtd->stream_id,
191 prtd->pcm_count, 0, 0, 0);
194 prtd->state = Q6ASM_STREAM_STOPPED;
197 prtd->pcm_irq_pos += prtd->pcm_count;
199 if (prtd->state == Q6ASM_STREAM_RUNNING)
200 q6asm_write_async(prtd->audio_client, prtd->stream_id,
201 prtd->pcm_count, 0, 0, 0);
206 prtd->pcm_irq_pos += prtd->pcm_count;
208 if (prtd->state == Q6ASM_STREAM_RUNNING)
209 q6asm_read(prtd->audio_client, prtd->stream_id);
222 struct q6asm_dai_rtd *prtd = runtime->private_data;
231 if (!prtd || !prtd->audio_client) {
237 prtd->pcm_count = snd_pcm_lib_period_bytes(substream);
238 prtd->pcm_irq_pos = 0;
240 if (prtd->state) {
242 q6asm_cmd(prtd->audio_client, prtd->stream_id, CMD_CLOSE);
244 prtd->audio_client);
249 ret = q6asm_map_memory_regions(substream->stream, prtd->audio_client,
250 prtd->phys,
251 (prtd->pcm_size / prtd->periods),
252 prtd->periods);
261 ret = q6asm_open_write(prtd->audio_client, prtd->stream_id,
263 0, prtd->bits_per_sample, false);
265 ret = q6asm_open_read(prtd->audio_client, prtd->stream_id,
267 prtd->bits_per_sample);
275 prtd->session_id = q6asm_get_session_id(prtd->audio_client);
277 prtd->session_id, substream->stream);
285 prtd->audio_client, prtd->stream_id,
287 prtd->bits_per_sample);
289 ret = q6asm_enc_cfg_blk_pcm_format_support(prtd->audio_client,
290 prtd->stream_id,
293 prtd->bits_per_sample);
297 q6asm_read(prtd->audio_client, prtd->stream_id);
303 prtd->state = Q6ASM_STREAM_RUNNING;
308 q6asm_cmd(prtd->audio_client, prtd->stream_id, CMD_CLOSE);
310 q6asm_unmap_memory_regions(substream->stream, prtd->audio_client);
311 q6asm_audio_client_free(prtd->audio_client);
312 prtd->audio_client = NULL;
322 struct q6asm_dai_rtd *prtd = runtime->private_data;
328 ret = q6asm_run_nowait(prtd->audio_client, prtd->stream_id,
332 prtd->state = Q6ASM_STREAM_STOPPED;
333 ret = q6asm_cmd_nowait(prtd->audio_client, prtd->stream_id,
338 ret = q6asm_cmd_nowait(prtd->audio_client, prtd->stream_id,
355 struct q6asm_dai_rtd *prtd;
369 prtd = kzalloc(sizeof(struct q6asm_dai_rtd), GFP_KERNEL);
370 if (prtd == NULL)
373 prtd->substream = substream;
374 prtd->audio_client = q6asm_audio_client_alloc(dev,
375 (q6asm_cb)event_handler, prtd, stream_id,
377 if (IS_ERR(prtd->audio_client)) {
379 ret = PTR_ERR(prtd->audio_client);
380 kfree(prtd);
385 prtd->stream_id = 1;
427 runtime->private_data = prtd;
435 prtd->phys = substream->dma_buffer.addr;
437 prtd->phys = substream->dma_buffer.addr | (pdata->sid << 32);
449 struct q6asm_dai_rtd *prtd = runtime->private_data;
451 if (prtd->audio_client) {
452 if (prtd->state)
453 q6asm_cmd(prtd->audio_client, prtd->stream_id,
457 prtd->audio_client);
458 q6asm_audio_client_free(prtd->audio_client);
459 prtd->audio_client = NULL;
463 kfree(prtd);
472 struct q6asm_dai_rtd *prtd = runtime->private_data;
474 if (prtd->pcm_irq_pos >= prtd->pcm_size)
475 prtd->pcm_irq_pos = 0;
477 return bytes_to_frames(runtime, (prtd->pcm_irq_pos));
497 struct q6asm_dai_rtd *prtd = runtime->private_data;
499 prtd->pcm_size = params_buffer_bytes(params);
500 prtd->periods = params_periods(params);
504 prtd->bits_per_sample = 16;
507 prtd->bits_per_sample = 24;
517 struct q6asm_dai_rtd *prtd = priv;
518 struct snd_compr_stream *substream = prtd->cstream;
527 spin_lock_irqsave(&prtd->lock, flags);
528 if (!prtd->bytes_sent) {
529 q6asm_stream_remove_initial_silence(prtd->audio_client,
530 prtd->stream_id,
531 prtd->initial_samples_drop);
533 q6asm_write_async(prtd->audio_client, prtd->stream_id,
534 prtd->pcm_count, 0, 0, 0);
535 prtd->bytes_sent += prtd->pcm_count;
538 spin_unlock_irqrestore(&prtd->lock, flags);
542 spin_lock_irqsave(&prtd->lock, flags);
543 if (prtd->notify_on_drain) {
549 q6asm_cmd_nowait(prtd->audio_client,
550 prtd->stream_id,
556 prtd->stream_id = (prtd->stream_id == 1 ? 2 : 1);
559 snd_compr_drain_notify(prtd->cstream);
560 prtd->notify_on_drain = false;
563 prtd->state = Q6ASM_STREAM_STOPPED;
565 spin_unlock_irqrestore(&prtd->lock, flags);
569 spin_lock_irqsave(&prtd->lock, flags);
572 prtd->copied_total += bytes_written;
575 if (prtd->state != Q6ASM_STREAM_RUNNING) {
576 spin_unlock_irqrestore(&prtd->lock, flags);
580 avail = prtd->bytes_received - prtd->bytes_sent;
581 if (avail > prtd->pcm_count) {
582 bytes_to_write = prtd->pcm_count;
584 if (substream->partial_drain || prtd->notify_on_drain)
592 q6asm_stream_remove_trailing_silence(prtd->audio_client,
593 prtd->stream_id,
594 prtd->trailing_samples_drop);
597 q6asm_write_async(prtd->audio_client, prtd->stream_id,
600 prtd->bytes_sent += bytes_to_write;
603 if (prtd->notify_on_drain && is_last_buffer)
604 q6asm_cmd_nowait(prtd->audio_client,
605 prtd->stream_id, CMD_EOS);
607 spin_unlock_irqrestore(&prtd->lock, flags);
623 struct q6asm_dai_rtd *prtd;
633 prtd = kzalloc(sizeof(*prtd), GFP_KERNEL);
634 if (!prtd)
638 prtd->stream_id = 1;
640 prtd->cstream = stream;
641 prtd->audio_client = q6asm_audio_client_alloc(dev,
643 prtd, stream_id, LEGACY_PCM_MODE);
644 if (IS_ERR(prtd->audio_client)) {
646 ret = PTR_ERR(prtd->audio_client);
653 &prtd->dma_buffer);
660 prtd->phys = prtd->dma_buffer.addr;
662 prtd->phys = prtd->dma_buffer.addr | (pdata->sid << 32);
664 snd_compr_set_runtime_buffer(stream, &prtd->dma_buffer);
665 spin_lock_init(&prtd->lock);
666 runtime->private_data = prtd;
671 q6asm_audio_client_free(prtd->audio_client);
673 kfree(prtd);
682 struct q6asm_dai_rtd *prtd = runtime->private_data;
685 if (prtd->audio_client) {
686 if (prtd->state) {
687 q6asm_cmd(prtd->audio_client, prtd->stream_id,
689 if (prtd->next_track_stream_id) {
690 q6asm_cmd(prtd->audio_client,
691 prtd->next_track_stream_id,
696 snd_dma_free_pages(&prtd->dma_buffer);
698 prtd->audio_client);
699 q6asm_audio_client_free(prtd->audio_client);
700 prtd->audio_client = NULL;
703 kfree(prtd);
714 struct q6asm_dai_rtd *prtd = runtime->private_data;
728 codec_options = &(prtd->codec.options);
730 memcpy(&prtd->codec, codec, sizeof(*codec));
747 ret = q6asm_stream_media_format_block_flac(prtd->audio_client,
765 wma_cfg.bits_per_sample = prtd->bits_per_sample;
808 prtd->audio_client, stream_id,
812 prtd->audio_client, stream_id,
826 alac_cfg.bit_depth = prtd->bits_per_sample;
845 ret = q6asm_stream_media_format_block_alac(prtd->audio_client,
860 ape_cfg.bits_per_sample = prtd->bits_per_sample;
870 ret = q6asm_stream_media_format_block_ape(prtd->audio_client,
891 struct q6asm_dai_rtd *prtd = runtime->private_data;
902 if (!prtd || !prtd->audio_client) {
907 prtd->periods = runtime->fragments;
908 prtd->pcm_count = runtime->fragment_size;
909 prtd->pcm_size = runtime->fragments * runtime->fragment_size;
910 prtd->bits_per_sample = 16;
913 ret = q6asm_open_write(prtd->audio_client, prtd->stream_id, params->codec.id,
914 params->codec.profile, prtd->bits_per_sample,
919 q6asm_audio_client_free(prtd->audio_client);
920 prtd->audio_client = NULL;
925 prtd->session_id = q6asm_get_session_id(prtd->audio_client);
927 prtd->session_id, dir);
935 prtd->stream_id);
941 ret = q6asm_map_memory_regions(dir, prtd->audio_client, prtd->phys,
942 (prtd->pcm_size / prtd->periods),
943 prtd->periods);
950 prtd->state = Q6ASM_STREAM_RUNNING;
960 struct q6asm_dai_rtd *prtd = runtime->private_data;
965 prtd->trailing_samples_drop = metadata->value[0];
968 prtd->initial_samples_drop = metadata->value[0];
969 if (prtd->next_track_stream_id) {
970 ret = q6asm_open_write(prtd->audio_client,
971 prtd->next_track_stream_id,
972 prtd->codec.id,
973 prtd->codec.profile,
974 prtd->bits_per_sample,
981 &prtd->codec,
982 prtd->next_track_stream_id);
988 ret = q6asm_stream_remove_initial_silence(prtd->audio_client,
989 prtd->next_track_stream_id,
990 prtd->initial_samples_drop);
991 prtd->next_track_stream_id = 0;
1008 struct q6asm_dai_rtd *prtd = runtime->private_data;
1015 ret = q6asm_run_nowait(prtd->audio_client, prtd->stream_id,
1019 prtd->state = Q6ASM_STREAM_STOPPED;
1020 ret = q6asm_cmd_nowait(prtd->audio_client, prtd->stream_id,
1025 ret = q6asm_cmd_nowait(prtd->audio_client, prtd->stream_id,
1029 prtd->next_track = true;
1030 prtd->next_track_stream_id = (prtd->stream_id == 1 ? 2 : 1);
1034 prtd->notify_on_drain = true;
1049 struct q6asm_dai_rtd *prtd = runtime->private_data;
1052 spin_lock_irqsave(&prtd->lock, flags);
1054 tstamp->copied_total = prtd->copied_total;
1055 tstamp->byte_offset = prtd->copied_total % prtd->pcm_size;
1057 spin_unlock_irqrestore(&prtd->lock, flags);
1067 struct q6asm_dai_rtd *prtd = runtime->private_data;
1076 bytes_received = prtd->bytes_received;
1082 if (prtd->next_track)
1083 bytes_received = ALIGN(prtd->bytes_received, prtd->pcm_count);
1085 app_pointer = bytes_received/prtd->pcm_size;
1086 app_pointer = bytes_received - (app_pointer * prtd->pcm_size);
1087 dstn = prtd->dma_buffer.area + app_pointer;
1089 if (count < prtd->pcm_size - app_pointer) {
1093 copy = prtd->pcm_size - app_pointer;
1096 if (copy_from_user(prtd->dma_buffer.area, buf + copy,
1101 spin_lock_irqsave(&prtd->lock, flags);
1103 bytes_in_flight = prtd->bytes_received - prtd->copied_total;
1105 if (prtd->next_track) {
1106 prtd->next_track = false;
1107 prtd->copied_total = ALIGN(prtd->copied_total, prtd->pcm_count);
1108 prtd->bytes_sent = ALIGN(prtd->bytes_sent, prtd->pcm_count);
1111 prtd->bytes_received = bytes_received + count;
1114 if (prtd->state == Q6ASM_STREAM_RUNNING && (bytes_in_flight == 0)) {
1115 uint32_t bytes_to_write = prtd->pcm_count;
1117 avail = prtd->bytes_received - prtd->bytes_sent;
1119 if (avail < prtd->pcm_count)
1122 q6asm_write_async(prtd->audio_client, prtd->stream_id,
1124 prtd->bytes_sent += bytes_to_write;
1127 spin_unlock_irqrestore(&prtd->lock, flags);
1137 struct q6asm_dai_rtd *prtd = runtime->private_data;
1141 prtd->dma_buffer.area, prtd->dma_buffer.addr,
1142 prtd->dma_buffer.bytes);