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);
447 struct q6asm_dai_rtd *prtd = runtime->private_data;
449 if (prtd->audio_client) {
450 if (prtd->state)
451 q6asm_cmd(prtd->audio_client, prtd->stream_id,
455 prtd->audio_client);
456 q6asm_audio_client_free(prtd->audio_client);
457 prtd->audio_client = NULL;
461 kfree(prtd);
470 struct q6asm_dai_rtd *prtd = runtime->private_data;
472 if (prtd->pcm_irq_pos >= prtd->pcm_size)
473 prtd->pcm_irq_pos = 0;
475 return bytes_to_frames(runtime, (prtd->pcm_irq_pos));
483 struct q6asm_dai_rtd *prtd = runtime->private_data;
485 prtd->pcm_size = params_buffer_bytes(params);
486 prtd->periods = params_periods(params);
490 prtd->bits_per_sample = 16;
493 prtd->bits_per_sample = 24;
503 struct q6asm_dai_rtd *prtd = priv;
504 struct snd_compr_stream *substream = prtd->cstream;
513 spin_lock_irqsave(&prtd->lock, flags);
514 if (!prtd->bytes_sent) {
515 q6asm_stream_remove_initial_silence(prtd->audio_client,
516 prtd->stream_id,
517 prtd->initial_samples_drop);
519 q6asm_write_async(prtd->audio_client, prtd->stream_id,
520 prtd->pcm_count, 0, 0, 0);
521 prtd->bytes_sent += prtd->pcm_count;
524 spin_unlock_irqrestore(&prtd->lock, flags);
528 spin_lock_irqsave(&prtd->lock, flags);
529 if (prtd->notify_on_drain) {
535 q6asm_cmd_nowait(prtd->audio_client,
536 prtd->stream_id,
542 prtd->stream_id = (prtd->stream_id == 1 ? 2 : 1);
545 snd_compr_drain_notify(prtd->cstream);
546 prtd->notify_on_drain = false;
549 prtd->state = Q6ASM_STREAM_STOPPED;
551 spin_unlock_irqrestore(&prtd->lock, flags);
555 spin_lock_irqsave(&prtd->lock, flags);
558 prtd->copied_total += bytes_written;
561 if (prtd->state != Q6ASM_STREAM_RUNNING) {
562 spin_unlock_irqrestore(&prtd->lock, flags);
566 avail = prtd->bytes_received - prtd->bytes_sent;
567 if (avail > prtd->pcm_count) {
568 bytes_to_write = prtd->pcm_count;
570 if (substream->partial_drain || prtd->notify_on_drain)
578 q6asm_stream_remove_trailing_silence(prtd->audio_client,
579 prtd->stream_id,
580 prtd->trailing_samples_drop);
583 q6asm_write_async(prtd->audio_client, prtd->stream_id,
586 prtd->bytes_sent += bytes_to_write;
589 if (prtd->notify_on_drain && is_last_buffer)
590 q6asm_cmd_nowait(prtd->audio_client,
591 prtd->stream_id, CMD_EOS);
593 spin_unlock_irqrestore(&prtd->lock, flags);
609 struct q6asm_dai_rtd *prtd;
619 prtd = kzalloc(sizeof(*prtd), GFP_KERNEL);
620 if (!prtd)
624 prtd->stream_id = 1;
626 prtd->cstream = stream;
627 prtd->audio_client = q6asm_audio_client_alloc(dev,
629 prtd, stream_id, LEGACY_PCM_MODE);
630 if (IS_ERR(prtd->audio_client)) {
632 ret = PTR_ERR(prtd->audio_client);
639 &prtd->dma_buffer);
646 prtd->phys = prtd->dma_buffer.addr;
648 prtd->phys = prtd->dma_buffer.addr | (pdata->sid << 32);
650 snd_compr_set_runtime_buffer(stream, &prtd->dma_buffer);
651 spin_lock_init(&prtd->lock);
652 runtime->private_data = prtd;
657 q6asm_audio_client_free(prtd->audio_client);
659 kfree(prtd);
668 struct q6asm_dai_rtd *prtd = runtime->private_data;
671 if (prtd->audio_client) {
672 if (prtd->state) {
673 q6asm_cmd(prtd->audio_client, prtd->stream_id,
675 if (prtd->next_track_stream_id) {
676 q6asm_cmd(prtd->audio_client,
677 prtd->next_track_stream_id,
682 snd_dma_free_pages(&prtd->dma_buffer);
684 prtd->audio_client);
685 q6asm_audio_client_free(prtd->audio_client);
686 prtd->audio_client = NULL;
689 kfree(prtd);
700 struct q6asm_dai_rtd *prtd = runtime->private_data;
714 codec_options = &(prtd->codec.options);
716 memcpy(&prtd->codec, codec, sizeof(*codec));
733 ret = q6asm_stream_media_format_block_flac(prtd->audio_client,
751 wma_cfg.bits_per_sample = prtd->bits_per_sample;
794 prtd->audio_client, stream_id,
798 prtd->audio_client, stream_id,
812 alac_cfg.bit_depth = prtd->bits_per_sample;
831 ret = q6asm_stream_media_format_block_alac(prtd->audio_client,
846 ape_cfg.bits_per_sample = prtd->bits_per_sample;
856 ret = q6asm_stream_media_format_block_ape(prtd->audio_client,
877 struct q6asm_dai_rtd *prtd = runtime->private_data;
888 if (!prtd || !prtd->audio_client) {
893 prtd->periods = runtime->fragments;
894 prtd->pcm_count = runtime->fragment_size;
895 prtd->pcm_size = runtime->fragments * runtime->fragment_size;
896 prtd->bits_per_sample = 16;
899 ret = q6asm_open_write(prtd->audio_client, prtd->stream_id, params->codec.id,
900 params->codec.profile, prtd->bits_per_sample,
905 q6asm_audio_client_free(prtd->audio_client);
906 prtd->audio_client = NULL;
911 prtd->session_id = q6asm_get_session_id(prtd->audio_client);
913 prtd->session_id, dir);
921 prtd->stream_id);
927 ret = q6asm_map_memory_regions(dir, prtd->audio_client, prtd->phys,
928 (prtd->pcm_size / prtd->periods),
929 prtd->periods);
936 prtd->state = Q6ASM_STREAM_RUNNING;
946 struct q6asm_dai_rtd *prtd = runtime->private_data;
951 prtd->trailing_samples_drop = metadata->value[0];
954 prtd->initial_samples_drop = metadata->value[0];
955 if (prtd->next_track_stream_id) {
956 ret = q6asm_open_write(prtd->audio_client,
957 prtd->next_track_stream_id,
958 prtd->codec.id,
959 prtd->codec.profile,
960 prtd->bits_per_sample,
967 &prtd->codec,
968 prtd->next_track_stream_id);
974 ret = q6asm_stream_remove_initial_silence(prtd->audio_client,
975 prtd->next_track_stream_id,
976 prtd->initial_samples_drop);
977 prtd->next_track_stream_id = 0;
994 struct q6asm_dai_rtd *prtd = runtime->private_data;
1001 ret = q6asm_run_nowait(prtd->audio_client, prtd->stream_id,
1005 prtd->state = Q6ASM_STREAM_STOPPED;
1006 ret = q6asm_cmd_nowait(prtd->audio_client, prtd->stream_id,
1011 ret = q6asm_cmd_nowait(prtd->audio_client, prtd->stream_id,
1015 prtd->next_track = true;
1016 prtd->next_track_stream_id = (prtd->stream_id == 1 ? 2 : 1);
1020 prtd->notify_on_drain = true;
1035 struct q6asm_dai_rtd *prtd = runtime->private_data;
1038 spin_lock_irqsave(&prtd->lock, flags);
1040 tstamp->copied_total = prtd->copied_total;
1041 tstamp->byte_offset = prtd->copied_total % prtd->pcm_size;
1043 spin_unlock_irqrestore(&prtd->lock, flags);
1053 struct q6asm_dai_rtd *prtd = runtime->private_data;
1062 bytes_received = prtd->bytes_received;
1068 if (prtd->next_track)
1069 bytes_received = ALIGN(prtd->bytes_received, prtd->pcm_count);
1071 app_pointer = bytes_received/prtd->pcm_size;
1072 app_pointer = bytes_received - (app_pointer * prtd->pcm_size);
1073 dstn = prtd->dma_buffer.area + app_pointer;
1075 if (count < prtd->pcm_size - app_pointer) {
1079 copy = prtd->pcm_size - app_pointer;
1082 if (copy_from_user(prtd->dma_buffer.area, buf + copy,
1087 spin_lock_irqsave(&prtd->lock, flags);
1089 bytes_in_flight = prtd->bytes_received - prtd->copied_total;
1091 if (prtd->next_track) {
1092 prtd->next_track = false;
1093 prtd->copied_total = ALIGN(prtd->copied_total, prtd->pcm_count);
1094 prtd->bytes_sent = ALIGN(prtd->bytes_sent, prtd->pcm_count);
1097 prtd->bytes_received = bytes_received + count;
1100 if (prtd->state == Q6ASM_STREAM_RUNNING && (bytes_in_flight == 0)) {
1101 uint32_t bytes_to_write = prtd->pcm_count;
1103 avail = prtd->bytes_received - prtd->bytes_sent;
1105 if (avail < prtd->pcm_count)
1108 q6asm_write_async(prtd->audio_client, prtd->stream_id,
1110 prtd->bytes_sent += bytes_to_write;
1113 spin_unlock_irqrestore(&prtd->lock, flags);
1123 struct q6asm_dai_rtd *prtd = runtime->private_data;
1127 prtd->dma_buffer.area, prtd->dma_buffer.addr,
1128 prtd->dma_buffer.bytes);