Lines Matching +full:port +full:- +full:phys

1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (c) 2011-2017, The Linux Foundation. All rights reserved.
5 #include <dt-bindings/sound/qcom,q6asm.h>
22 #include "q6dsp-errno.h"
23 #include "q6dsp-common.h"
242 phys_addr_t phys; member
271 /* idx:1 out port, 0: in port */
272 struct audio_port_data port[2]; member
284 hdr->hdr_field = APR_SEQ_CMD_HDR_FIELD; in q6asm_add_hdr()
285 hdr->src_port = ((ac->session << 8) & 0xFF00) | (stream_id); in q6asm_add_hdr()
286 hdr->dest_port = ((ac->session << 8) & 0xFF00) | (stream_id); in q6asm_add_hdr()
287 hdr->pkt_size = pkt_size; in q6asm_add_hdr()
289 hdr->token = ac->session; in q6asm_add_hdr()
295 struct apr_hdr *hdr = &pkt->hdr; in q6asm_apr_send_session_pkt()
298 mutex_lock(&ac->cmd_lock); in q6asm_apr_send_session_pkt()
299 ac->result.opcode = 0; in q6asm_apr_send_session_pkt()
300 ac->result.status = 0; in q6asm_apr_send_session_pkt()
301 rc = apr_send_pkt(a->adev, pkt); in q6asm_apr_send_session_pkt()
306 rc = wait_event_timeout(a->mem_wait, in q6asm_apr_send_session_pkt()
307 (ac->result.opcode == hdr->opcode) || in q6asm_apr_send_session_pkt()
308 (ac->result.opcode == rsp_opcode), in q6asm_apr_send_session_pkt()
311 rc = wait_event_timeout(a->mem_wait, in q6asm_apr_send_session_pkt()
312 (ac->result.opcode == hdr->opcode), in q6asm_apr_send_session_pkt()
316 dev_err(a->dev, "CMD %x timeout\n", hdr->opcode); in q6asm_apr_send_session_pkt()
317 rc = -ETIMEDOUT; in q6asm_apr_send_session_pkt()
318 } else if (ac->result.status > 0) { in q6asm_apr_send_session_pkt()
319 dev_err(a->dev, "DSP returned error[%x]\n", in q6asm_apr_send_session_pkt()
320 ac->result.status); in q6asm_apr_send_session_pkt()
321 rc = -EINVAL; in q6asm_apr_send_session_pkt()
325 mutex_unlock(&ac->cmd_lock); in q6asm_apr_send_session_pkt()
333 struct q6asm *a = dev_get_drvdata(ac->dev->parent); in __q6asm_memory_unmap()
338 if (ac->port[dir].mem_map_handle == 0) { in __q6asm_memory_unmap()
339 dev_err(ac->dev, "invalid mem handle\n"); in __q6asm_memory_unmap()
340 return -EINVAL; in __q6asm_memory_unmap()
346 return -ENOMEM; in __q6asm_memory_unmap()
351 pkt->hdr.hdr_field = APR_SEQ_CMD_HDR_FIELD; in __q6asm_memory_unmap()
352 pkt->hdr.src_port = 0; in __q6asm_memory_unmap()
353 pkt->hdr.dest_port = 0; in __q6asm_memory_unmap()
354 pkt->hdr.pkt_size = pkt_size; in __q6asm_memory_unmap()
355 pkt->hdr.token = ((ac->session << 8) | dir); in __q6asm_memory_unmap()
357 pkt->hdr.opcode = ASM_CMD_SHARED_MEM_UNMAP_REGIONS; in __q6asm_memory_unmap()
358 mem_unmap->mem_map_handle = ac->port[dir].mem_map_handle; in __q6asm_memory_unmap()
366 ac->port[dir].mem_map_handle = 0; in __q6asm_memory_unmap()
374 struct audio_port_data *port) in q6asm_audio_client_free_buf() argument
378 spin_lock_irqsave(&ac->lock, flags); in q6asm_audio_client_free_buf()
379 port->num_periods = 0; in q6asm_audio_client_free_buf()
380 kfree(port->buf); in q6asm_audio_client_free_buf()
381 port->buf = NULL; in q6asm_audio_client_free_buf()
382 spin_unlock_irqrestore(&ac->lock, flags); in q6asm_audio_client_free_buf()
386 * q6asm_unmap_memory_regions() - unmap memory regions in the dsp.
395 struct audio_port_data *port; in q6asm_unmap_memory_regions() local
399 port = &ac->port[dir]; in q6asm_unmap_memory_regions()
400 if (!port->buf) { in q6asm_unmap_memory_regions()
401 rc = -EINVAL; in q6asm_unmap_memory_regions()
405 cnt = port->num_periods - 1; in q6asm_unmap_memory_regions()
407 rc = __q6asm_memory_unmap(ac, port->buf[dir].phys, dir); in q6asm_unmap_memory_regions()
409 dev_err(ac->dev, "%s: Memory_unmap_regions failed %d\n", in q6asm_unmap_memory_regions()
415 q6asm_audio_client_free_buf(ac, port); in q6asm_unmap_memory_regions()
428 struct q6asm *a = dev_get_drvdata(ac->dev->parent); in __q6asm_memory_map_regions()
429 struct audio_port_data *port = NULL; in __q6asm_memory_map_regions() local
453 return -ENOMEM; in __q6asm_memory_map_regions()
459 pkt->hdr.hdr_field = APR_SEQ_CMD_HDR_FIELD; in __q6asm_memory_map_regions()
460 pkt->hdr.src_port = 0; in __q6asm_memory_map_regions()
461 pkt->hdr.dest_port = 0; in __q6asm_memory_map_regions()
462 pkt->hdr.pkt_size = pkt_size; in __q6asm_memory_map_regions()
463 pkt->hdr.token = ((ac->session << 8) | dir); in __q6asm_memory_map_regions()
464 pkt->hdr.opcode = ASM_CMD_SHARED_MEM_MAP_REGIONS; in __q6asm_memory_map_regions()
466 cmd->mem_pool_id = ADSP_MEMORY_MAP_SHMEM8_4K_POOL; in __q6asm_memory_map_regions()
467 cmd->num_regions = num_regions; in __q6asm_memory_map_regions()
468 cmd->property_flag = 0x00; in __q6asm_memory_map_regions()
470 spin_lock_irqsave(&ac->lock, flags); in __q6asm_memory_map_regions()
471 port = &ac->port[dir]; in __q6asm_memory_map_regions()
474 ab = &port->buf[i]; in __q6asm_memory_map_regions()
475 mregions->shm_addr_lsw = lower_32_bits(ab->phys); in __q6asm_memory_map_regions()
476 mregions->shm_addr_msw = upper_32_bits(ab->phys); in __q6asm_memory_map_regions()
477 mregions->mem_size_bytes = buf_sz; in __q6asm_memory_map_regions()
480 spin_unlock_irqrestore(&ac->lock, flags); in __q6asm_memory_map_regions()
491 * q6asm_map_memory_regions() - map memory regions in the dsp.
495 * @phys: physical address that needs mapping.
502 phys_addr_t phys, in q6asm_map_memory_regions() argument
510 spin_lock_irqsave(&ac->lock, flags); in q6asm_map_memory_regions()
511 if (ac->port[dir].buf) { in q6asm_map_memory_regions()
512 dev_err(ac->dev, "Buffer already allocated\n"); in q6asm_map_memory_regions()
513 spin_unlock_irqrestore(&ac->lock, flags); in q6asm_map_memory_regions()
519 spin_unlock_irqrestore(&ac->lock, flags); in q6asm_map_memory_regions()
520 return -ENOMEM; in q6asm_map_memory_regions()
524 ac->port[dir].buf = buf; in q6asm_map_memory_regions()
526 buf[0].phys = phys; in q6asm_map_memory_regions()
531 buf[cnt].phys = buf[0].phys + (cnt * period_sz); in q6asm_map_memory_regions()
535 ac->port[dir].num_periods = periods; in q6asm_map_memory_regions()
537 spin_unlock_irqrestore(&ac->lock, flags); in q6asm_map_memory_regions()
541 dev_err(ac->dev, "Memory_map_regions failed\n"); in q6asm_map_memory_regions()
542 q6asm_audio_client_free_buf(ac, &ac->port[dir]); in q6asm_map_memory_regions()
556 a = ac->q6asm; in q6asm_audio_client_release()
558 spin_lock_irqsave(&a->slock, flags); in q6asm_audio_client_release()
559 a->session[ac->session] = NULL; in q6asm_audio_client_release()
560 spin_unlock_irqrestore(&a->slock, flags); in q6asm_audio_client_release()
566 * q6asm_audio_client_free() - Freee allocated audio client
572 kref_put(&ac->refcount, q6asm_audio_client_release); in q6asm_audio_client_free()
582 spin_lock_irqsave(&a->slock, flags); in q6asm_get_audio_client()
584 dev_err(a->dev, "invalid session: %d\n", session_id); in q6asm_get_audio_client()
589 if (!a->session[session_id]) in q6asm_get_audio_client()
591 else if (a->session[session_id]->session != session_id) in q6asm_get_audio_client()
594 ac = a->session[session_id]; in q6asm_get_audio_client()
595 kref_get(&ac->refcount); in q6asm_get_audio_client()
597 spin_unlock_irqrestore(&a->slock, flags); in q6asm_get_audio_client()
605 struct q6asm *q6asm = dev_get_drvdata(&adev->dev); in q6asm_stream_callback()
607 struct apr_hdr *hdr = &data->hdr; in q6asm_stream_callback()
608 struct audio_port_data *port; in q6asm_stream_callback() local
617 result = data->payload; in q6asm_stream_callback()
619 switch (hdr->opcode) { in q6asm_stream_callback()
621 switch (result->opcode) { in q6asm_stream_callback()
647 if (result->status != 0) { in q6asm_stream_callback()
648 dev_err(ac->dev, in q6asm_stream_callback()
650 result->opcode, result->status); in q6asm_stream_callback()
651 ac->result = *result; in q6asm_stream_callback()
652 wake_up(&ac->cmd_wait); in q6asm_stream_callback()
658 dev_err(ac->dev, "command[0x%x] not expecting rsp\n", in q6asm_stream_callback()
659 result->opcode); in q6asm_stream_callback()
663 ac->result = *result; in q6asm_stream_callback()
664 wake_up(&ac->cmd_wait); in q6asm_stream_callback()
666 if (ac->cb) in q6asm_stream_callback()
667 ac->cb(client_event, hdr->token, in q6asm_stream_callback()
668 data->payload, ac->priv); in q6asm_stream_callback()
675 if (ac->io_mode & ASM_SYNC_IO_MODE) { in q6asm_stream_callback()
676 phys_addr_t phys; in q6asm_stream_callback() local
678 int token = hdr->token & ASM_WRITE_TOKEN_MASK; in q6asm_stream_callback()
680 spin_lock_irqsave(&ac->lock, flags); in q6asm_stream_callback()
682 port = &ac->port[SNDRV_PCM_STREAM_PLAYBACK]; in q6asm_stream_callback()
684 if (!port->buf) { in q6asm_stream_callback()
685 spin_unlock_irqrestore(&ac->lock, flags); in q6asm_stream_callback()
690 phys = port->buf[token].phys; in q6asm_stream_callback()
692 if (lower_32_bits(phys) != result->opcode || in q6asm_stream_callback()
693 upper_32_bits(phys) != result->status) { in q6asm_stream_callback()
694 dev_err(ac->dev, "Expected addr %pa\n", in q6asm_stream_callback()
695 &port->buf[token].phys); in q6asm_stream_callback()
696 spin_unlock_irqrestore(&ac->lock, flags); in q6asm_stream_callback()
697 ret = -EINVAL; in q6asm_stream_callback()
700 spin_unlock_irqrestore(&ac->lock, flags); in q6asm_stream_callback()
705 if (ac->io_mode & ASM_SYNC_IO_MODE) { in q6asm_stream_callback()
706 struct asm_data_cmd_read_v2_done *done = data->payload; in q6asm_stream_callback()
708 phys_addr_t phys; in q6asm_stream_callback() local
710 spin_lock_irqsave(&ac->lock, flags); in q6asm_stream_callback()
711 port = &ac->port[SNDRV_PCM_STREAM_CAPTURE]; in q6asm_stream_callback()
712 if (!port->buf) { in q6asm_stream_callback()
713 spin_unlock_irqrestore(&ac->lock, flags); in q6asm_stream_callback()
718 phys = port->buf[hdr->token].phys; in q6asm_stream_callback()
720 if (upper_32_bits(phys) != done->buf_addr_msw || in q6asm_stream_callback()
721 lower_32_bits(phys) != done->buf_addr_lsw) { in q6asm_stream_callback()
722 dev_err(ac->dev, "Expected addr %pa %08x-%08x\n", in q6asm_stream_callback()
723 &port->buf[hdr->token].phys, in q6asm_stream_callback()
724 done->buf_addr_lsw, in q6asm_stream_callback()
725 done->buf_addr_msw); in q6asm_stream_callback()
726 spin_unlock_irqrestore(&ac->lock, flags); in q6asm_stream_callback()
727 ret = -EINVAL; in q6asm_stream_callback()
730 spin_unlock_irqrestore(&ac->lock, flags); in q6asm_stream_callback()
739 if (ac->cb) in q6asm_stream_callback()
740 ac->cb(client_event, hdr->token, data->payload, ac->priv); in q6asm_stream_callback()
743 kref_put(&ac->refcount, q6asm_audio_client_release); in q6asm_stream_callback()
750 struct q6asm *q6asm = dev_get_drvdata(&adev->dev); in q6asm_srvc_callback()
752 struct audio_port_data *port; in q6asm_srvc_callback() local
754 struct apr_hdr *hdr = &data->hdr; in q6asm_srvc_callback()
760 session_id = (hdr->dest_port >> 8) & 0xFF; in q6asm_srvc_callback()
764 sid = (hdr->token >> 8) & 0x0F; in q6asm_srvc_callback()
767 dev_err(&adev->dev, "Audio Client not active\n"); in q6asm_srvc_callback()
771 a = dev_get_drvdata(ac->dev->parent); in q6asm_srvc_callback()
772 dir = (hdr->token & 0x0F); in q6asm_srvc_callback()
773 port = &ac->port[dir]; in q6asm_srvc_callback()
774 result = data->payload; in q6asm_srvc_callback()
776 switch (hdr->opcode) { in q6asm_srvc_callback()
778 switch (result->opcode) { in q6asm_srvc_callback()
781 ac->result = *result; in q6asm_srvc_callback()
782 wake_up(&a->mem_wait); in q6asm_srvc_callback()
785 dev_err(&adev->dev, "command[0x%x] not expecting rsp\n", in q6asm_srvc_callback()
786 result->opcode); in q6asm_srvc_callback()
791 ac->result.status = 0; in q6asm_srvc_callback()
792 ac->result.opcode = hdr->opcode; in q6asm_srvc_callback()
793 port->mem_map_handle = result->opcode; in q6asm_srvc_callback()
794 wake_up(&a->mem_wait); in q6asm_srvc_callback()
797 ac->result.opcode = hdr->opcode; in q6asm_srvc_callback()
798 ac->result.status = 0; in q6asm_srvc_callback()
799 port->mem_map_handle = 0; in q6asm_srvc_callback()
800 wake_up(&a->mem_wait); in q6asm_srvc_callback()
803 dev_dbg(&adev->dev, "command[0x%x]success [0x%x]\n", in q6asm_srvc_callback()
804 result->opcode, result->status); in q6asm_srvc_callback()
808 if (ac->cb) in q6asm_srvc_callback()
809 ac->cb(hdr->opcode, hdr->token, data->payload, ac->priv); in q6asm_srvc_callback()
812 kref_put(&ac->refcount, q6asm_audio_client_release); in q6asm_srvc_callback()
818 * q6asm_get_session_id() - get session id for audio client
826 return c->session; in q6asm_get_session_id()
831 * q6asm_audio_client_alloc() - Allocate a new audio client
846 struct q6asm *a = dev_get_drvdata(dev->parent); in q6asm_audio_client_alloc()
858 return ERR_PTR(-ENOMEM); in q6asm_audio_client_alloc()
860 spin_lock_irqsave(&a->slock, flags); in q6asm_audio_client_alloc()
861 a->session[session_id + 1] = ac; in q6asm_audio_client_alloc()
862 spin_unlock_irqrestore(&a->slock, flags); in q6asm_audio_client_alloc()
863 ac->session = session_id + 1; in q6asm_audio_client_alloc()
864 ac->cb = cb; in q6asm_audio_client_alloc()
865 ac->dev = dev; in q6asm_audio_client_alloc()
866 ac->q6asm = a; in q6asm_audio_client_alloc()
867 ac->priv = priv; in q6asm_audio_client_alloc()
868 ac->io_mode = ASM_SYNC_IO_MODE; in q6asm_audio_client_alloc()
869 ac->perf_mode = perf_mode; in q6asm_audio_client_alloc()
870 ac->adev = a->adev; in q6asm_audio_client_alloc()
871 kref_init(&ac->refcount); in q6asm_audio_client_alloc()
873 init_waitqueue_head(&ac->cmd_wait); in q6asm_audio_client_alloc()
874 mutex_init(&ac->cmd_lock); in q6asm_audio_client_alloc()
875 spin_lock_init(&ac->lock); in q6asm_audio_client_alloc()
883 struct apr_hdr *hdr = &pkt->hdr; in q6asm_ac_send_cmd_sync()
886 mutex_lock(&ac->cmd_lock); in q6asm_ac_send_cmd_sync()
887 ac->result.opcode = 0; in q6asm_ac_send_cmd_sync()
888 ac->result.status = 0; in q6asm_ac_send_cmd_sync()
890 rc = apr_send_pkt(ac->adev, pkt); in q6asm_ac_send_cmd_sync()
894 rc = wait_event_timeout(ac->cmd_wait, in q6asm_ac_send_cmd_sync()
895 (ac->result.opcode == hdr->opcode), 5 * HZ); in q6asm_ac_send_cmd_sync()
897 dev_err(ac->dev, "CMD %x timeout\n", hdr->opcode); in q6asm_ac_send_cmd_sync()
898 rc = -ETIMEDOUT; in q6asm_ac_send_cmd_sync()
902 if (ac->result.status > 0) { in q6asm_ac_send_cmd_sync()
903 dev_err(ac->dev, "DSP returned error[%x]\n", in q6asm_ac_send_cmd_sync()
904 ac->result.status); in q6asm_ac_send_cmd_sync()
905 rc = -EINVAL; in q6asm_ac_send_cmd_sync()
912 mutex_unlock(&ac->cmd_lock); in q6asm_ac_send_cmd_sync()
917 * q6asm_open_write() - Open audio client for writing
940 return -ENOMEM; in q6asm_open_write()
944 q6asm_add_hdr(ac, &pkt->hdr, pkt_size, true, stream_id); in q6asm_open_write()
946 pkt->hdr.opcode = ASM_STREAM_CMD_OPEN_WRITE_V3; in q6asm_open_write()
947 open->mode_flags = 0x00; in q6asm_open_write()
948 open->mode_flags |= ASM_LEGACY_STREAM_SESSION; in q6asm_open_write()
950 open->mode_flags |= BIT(ASM_SHIFT_GAPLESS_MODE_FLAG); in q6asm_open_write()
953 open->sink_endpointype = ASM_END_POINT_DEVICE_MATRIX; in q6asm_open_write()
954 open->bits_per_sample = bits_per_sample; in q6asm_open_write()
955 open->postprocopo_id = ASM_NULL_POPP_TOPOLOGY; in q6asm_open_write()
959 open->dec_fmt_id = ASM_MEDIA_FMT_MP3; in q6asm_open_write()
962 open->dec_fmt_id = ASM_MEDIA_FMT_MULTI_CHANNEL_PCM_V2; in q6asm_open_write()
965 open->dec_fmt_id = ASM_MEDIA_FMT_FLAC; in q6asm_open_write()
970 open->dec_fmt_id = ASM_MEDIA_FMT_WMA_V9; in q6asm_open_write()
976 open->dec_fmt_id = ASM_MEDIA_FMT_WMA_V10; in q6asm_open_write()
979 dev_err(ac->dev, "Invalid codec profile 0x%x\n", in q6asm_open_write()
981 rc = -EINVAL; in q6asm_open_write()
986 open->dec_fmt_id = ASM_MEDIA_FMT_ALAC; in q6asm_open_write()
989 open->dec_fmt_id = ASM_MEDIA_FMT_APE; in q6asm_open_write()
992 dev_err(ac->dev, "Invalid format 0x%x\n", format); in q6asm_open_write()
993 rc = -EINVAL; in q6asm_open_write()
1001 ac->io_mode |= ASM_TUN_WRITE_IO_MODE; in q6asm_open_write()
1021 return -ENOMEM; in __q6asm_run()
1026 q6asm_add_hdr(ac, &pkt->hdr, pkt_size, true, stream_id); in __q6asm_run()
1028 pkt->hdr.opcode = ASM_SESSION_CMD_RUN_V2; in __q6asm_run()
1029 run->flags = flags; in __q6asm_run()
1030 run->time_lsw = lsw_ts; in __q6asm_run()
1031 run->time_msw = msw_ts; in __q6asm_run()
1035 rc = apr_send_pkt(ac->adev, pkt); in __q6asm_run()
1045 * q6asm_run() - start the audio client
1063 * q6asm_run_nowait() - start the audio client withou blocking
1081 * q6asm_media_format_block_multi_ch_pcm() - setup pcm configuration
1107 return -ENOMEM; in q6asm_media_format_block_multi_ch_pcm()
1112 q6asm_add_hdr(ac, &pkt->hdr, pkt_size, true, stream_id); in q6asm_media_format_block_multi_ch_pcm()
1114 pkt->hdr.opcode = ASM_DATA_CMD_MEDIA_FMT_UPDATE_V2; in q6asm_media_format_block_multi_ch_pcm()
1115 fmt->fmt_blk.fmt_blk_size = sizeof(*fmt) - sizeof(fmt->fmt_blk); in q6asm_media_format_block_multi_ch_pcm()
1116 fmt->num_channels = channels; in q6asm_media_format_block_multi_ch_pcm()
1117 fmt->bits_per_sample = bits_per_sample; in q6asm_media_format_block_multi_ch_pcm()
1118 fmt->sample_rate = rate; in q6asm_media_format_block_multi_ch_pcm()
1119 fmt->is_signed = 1; in q6asm_media_format_block_multi_ch_pcm()
1121 channel_mapping = fmt->channel_mapping; in q6asm_media_format_block_multi_ch_pcm()
1127 dev_err(ac->dev, " map channels failed %d\n", channels); in q6asm_media_format_block_multi_ch_pcm()
1128 rc = -EINVAL; in q6asm_media_format_block_multi_ch_pcm()
1153 return -ENOMEM; in q6asm_stream_media_format_block_flac()
1158 q6asm_add_hdr(ac, &pkt->hdr, pkt_size, true, stream_id); in q6asm_stream_media_format_block_flac()
1160 pkt->hdr.opcode = ASM_DATA_CMD_MEDIA_FMT_UPDATE_V2; in q6asm_stream_media_format_block_flac()
1161 fmt->fmt_blk.fmt_blk_size = sizeof(*fmt) - sizeof(fmt->fmt_blk); in q6asm_stream_media_format_block_flac()
1162 fmt->is_stream_info_present = cfg->stream_info_present; in q6asm_stream_media_format_block_flac()
1163 fmt->num_channels = cfg->ch_cfg; in q6asm_stream_media_format_block_flac()
1164 fmt->min_blk_size = cfg->min_blk_size; in q6asm_stream_media_format_block_flac()
1165 fmt->max_blk_size = cfg->max_blk_size; in q6asm_stream_media_format_block_flac()
1166 fmt->sample_rate = cfg->sample_rate; in q6asm_stream_media_format_block_flac()
1167 fmt->min_frame_size = cfg->min_frame_size; in q6asm_stream_media_format_block_flac()
1168 fmt->max_frame_size = cfg->max_frame_size; in q6asm_stream_media_format_block_flac()
1169 fmt->sample_size = cfg->sample_size; in q6asm_stream_media_format_block_flac()
1190 return -ENOMEM; in q6asm_stream_media_format_block_wma_v9()
1195 q6asm_add_hdr(ac, &pkt->hdr, pkt_size, true, stream_id); in q6asm_stream_media_format_block_wma_v9()
1197 pkt->hdr.opcode = ASM_DATA_CMD_MEDIA_FMT_UPDATE_V2; in q6asm_stream_media_format_block_wma_v9()
1198 fmt->fmt_blk.fmt_blk_size = sizeof(*fmt) - sizeof(fmt->fmt_blk); in q6asm_stream_media_format_block_wma_v9()
1199 fmt->fmtag = cfg->fmtag; in q6asm_stream_media_format_block_wma_v9()
1200 fmt->num_channels = cfg->num_channels; in q6asm_stream_media_format_block_wma_v9()
1201 fmt->sample_rate = cfg->sample_rate; in q6asm_stream_media_format_block_wma_v9()
1202 fmt->bytes_per_sec = cfg->bytes_per_sec; in q6asm_stream_media_format_block_wma_v9()
1203 fmt->blk_align = cfg->block_align; in q6asm_stream_media_format_block_wma_v9()
1204 fmt->bits_per_sample = cfg->bits_per_sample; in q6asm_stream_media_format_block_wma_v9()
1205 fmt->channel_mask = cfg->channel_mask; in q6asm_stream_media_format_block_wma_v9()
1206 fmt->enc_options = cfg->enc_options; in q6asm_stream_media_format_block_wma_v9()
1207 fmt->reserved = 0; in q6asm_stream_media_format_block_wma_v9()
1228 return -ENOMEM; in q6asm_stream_media_format_block_wma_v10()
1233 q6asm_add_hdr(ac, &pkt->hdr, pkt_size, true, stream_id); in q6asm_stream_media_format_block_wma_v10()
1235 pkt->hdr.opcode = ASM_DATA_CMD_MEDIA_FMT_UPDATE_V2; in q6asm_stream_media_format_block_wma_v10()
1236 fmt->fmt_blk.fmt_blk_size = sizeof(*fmt) - sizeof(fmt->fmt_blk); in q6asm_stream_media_format_block_wma_v10()
1237 fmt->fmtag = cfg->fmtag; in q6asm_stream_media_format_block_wma_v10()
1238 fmt->num_channels = cfg->num_channels; in q6asm_stream_media_format_block_wma_v10()
1239 fmt->sample_rate = cfg->sample_rate; in q6asm_stream_media_format_block_wma_v10()
1240 fmt->bytes_per_sec = cfg->bytes_per_sec; in q6asm_stream_media_format_block_wma_v10()
1241 fmt->blk_align = cfg->block_align; in q6asm_stream_media_format_block_wma_v10()
1242 fmt->bits_per_sample = cfg->bits_per_sample; in q6asm_stream_media_format_block_wma_v10()
1243 fmt->channel_mask = cfg->channel_mask; in q6asm_stream_media_format_block_wma_v10()
1244 fmt->enc_options = cfg->enc_options; in q6asm_stream_media_format_block_wma_v10()
1245 fmt->advanced_enc_options1 = cfg->adv_enc_options; in q6asm_stream_media_format_block_wma_v10()
1246 fmt->advanced_enc_options2 = cfg->adv_enc_options2; in q6asm_stream_media_format_block_wma_v10()
1267 return -ENOMEM; in q6asm_stream_media_format_block_alac()
1272 q6asm_add_hdr(ac, &pkt->hdr, pkt_size, true, stream_id); in q6asm_stream_media_format_block_alac()
1274 pkt->hdr.opcode = ASM_DATA_CMD_MEDIA_FMT_UPDATE_V2; in q6asm_stream_media_format_block_alac()
1275 fmt->fmt_blk.fmt_blk_size = sizeof(*fmt) - sizeof(fmt->fmt_blk); in q6asm_stream_media_format_block_alac()
1277 fmt->frame_length = cfg->frame_length; in q6asm_stream_media_format_block_alac()
1278 fmt->compatible_version = cfg->compatible_version; in q6asm_stream_media_format_block_alac()
1279 fmt->bit_depth = cfg->bit_depth; in q6asm_stream_media_format_block_alac()
1280 fmt->num_channels = cfg->num_channels; in q6asm_stream_media_format_block_alac()
1281 fmt->max_run = cfg->max_run; in q6asm_stream_media_format_block_alac()
1282 fmt->max_frame_bytes = cfg->max_frame_bytes; in q6asm_stream_media_format_block_alac()
1283 fmt->avg_bit_rate = cfg->avg_bit_rate; in q6asm_stream_media_format_block_alac()
1284 fmt->sample_rate = cfg->sample_rate; in q6asm_stream_media_format_block_alac()
1285 fmt->channel_layout_tag = cfg->channel_layout_tag; in q6asm_stream_media_format_block_alac()
1286 fmt->pb = cfg->pb; in q6asm_stream_media_format_block_alac()
1287 fmt->mb = cfg->mb; in q6asm_stream_media_format_block_alac()
1288 fmt->kb = cfg->kb; in q6asm_stream_media_format_block_alac()
1309 return -ENOMEM; in q6asm_stream_media_format_block_ape()
1314 q6asm_add_hdr(ac, &pkt->hdr, pkt_size, true, stream_id); in q6asm_stream_media_format_block_ape()
1316 pkt->hdr.opcode = ASM_DATA_CMD_MEDIA_FMT_UPDATE_V2; in q6asm_stream_media_format_block_ape()
1317 fmt->fmt_blk.fmt_blk_size = sizeof(*fmt) - sizeof(fmt->fmt_blk); in q6asm_stream_media_format_block_ape()
1319 fmt->compatible_version = cfg->compatible_version; in q6asm_stream_media_format_block_ape()
1320 fmt->compression_level = cfg->compression_level; in q6asm_stream_media_format_block_ape()
1321 fmt->format_flags = cfg->format_flags; in q6asm_stream_media_format_block_ape()
1322 fmt->blocks_per_frame = cfg->blocks_per_frame; in q6asm_stream_media_format_block_ape()
1323 fmt->final_frame_blocks = cfg->final_frame_blocks; in q6asm_stream_media_format_block_ape()
1324 fmt->total_frames = cfg->total_frames; in q6asm_stream_media_format_block_ape()
1325 fmt->bits_per_sample = cfg->bits_per_sample; in q6asm_stream_media_format_block_ape()
1326 fmt->num_channels = cfg->num_channels; in q6asm_stream_media_format_block_ape()
1327 fmt->sample_rate = cfg->sample_rate; in q6asm_stream_media_format_block_ape()
1328 fmt->seek_table_present = cfg->seek_table_present; in q6asm_stream_media_format_block_ape()
1349 return -ENOMEM; in q6asm_stream_remove_silence()
1354 q6asm_add_hdr(ac, &pkt->hdr, pkt_size, true, stream_id); in q6asm_stream_remove_silence()
1356 pkt->hdr.opcode = cmd; in q6asm_stream_remove_silence()
1358 rc = apr_send_pkt(ac->adev, pkt); in q6asm_stream_remove_silence()
1387 * q6asm_enc_cfg_blk_pcm_format_support() - setup pcm configuration for capture
1412 return -ENOMEM; in q6asm_enc_cfg_blk_pcm_format_support()
1416 q6asm_add_hdr(ac, &pkt->hdr, pkt_size, true, stream_id); in q6asm_enc_cfg_blk_pcm_format_support()
1418 pkt->hdr.opcode = ASM_STREAM_CMD_SET_ENCDEC_PARAM; in q6asm_enc_cfg_blk_pcm_format_support()
1419 enc_cfg->encdec.param_id = ASM_PARAM_ID_ENCDEC_ENC_CFG_BLK_V2; in q6asm_enc_cfg_blk_pcm_format_support()
1420 enc_cfg->encdec.param_size = sizeof(*enc_cfg) - sizeof(enc_cfg->encdec); in q6asm_enc_cfg_blk_pcm_format_support()
1421 enc_cfg->encblk.frames_per_buf = frames_per_buf; in q6asm_enc_cfg_blk_pcm_format_support()
1422 enc_cfg->encblk.enc_cfg_blk_size = enc_cfg->encdec.param_size - in q6asm_enc_cfg_blk_pcm_format_support()
1425 enc_cfg->num_channels = channels; in q6asm_enc_cfg_blk_pcm_format_support()
1426 enc_cfg->bits_per_sample = bits_per_sample; in q6asm_enc_cfg_blk_pcm_format_support()
1427 enc_cfg->sample_rate = rate; in q6asm_enc_cfg_blk_pcm_format_support()
1428 enc_cfg->is_signed = 1; in q6asm_enc_cfg_blk_pcm_format_support()
1429 channel_mapping = enc_cfg->channel_mapping; in q6asm_enc_cfg_blk_pcm_format_support()
1432 rc = -EINVAL; in q6asm_enc_cfg_blk_pcm_format_support()
1445 * q6asm_read() - read data of period size from audio client
1455 struct audio_port_data *port; in q6asm_read() local
1466 return -ENOMEM; in q6asm_read()
1471 spin_lock_irqsave(&ac->lock, flags); in q6asm_read()
1472 port = &ac->port[SNDRV_PCM_STREAM_CAPTURE]; in q6asm_read()
1473 q6asm_add_hdr(ac, &pkt->hdr, pkt_size, false, stream_id); in q6asm_read()
1474 ab = &port->buf[port->dsp_buf]; in q6asm_read()
1475 pkt->hdr.opcode = ASM_DATA_CMD_READ_V2; in q6asm_read()
1476 read->buf_addr_lsw = lower_32_bits(ab->phys); in q6asm_read()
1477 read->buf_addr_msw = upper_32_bits(ab->phys); in q6asm_read()
1478 read->mem_map_handle = port->mem_map_handle; in q6asm_read()
1480 read->buf_size = ab->size; in q6asm_read()
1481 read->seq_id = port->dsp_buf; in q6asm_read()
1482 pkt->hdr.token = port->dsp_buf; in q6asm_read()
1484 port->dsp_buf++; in q6asm_read()
1486 if (port->dsp_buf >= port->num_periods) in q6asm_read()
1487 port->dsp_buf = 0; in q6asm_read()
1489 spin_unlock_irqrestore(&ac->lock, flags); in q6asm_read()
1490 rc = apr_send_pkt(ac->adev, pkt); in q6asm_read()
1494 pr_err("read op[0x%x]rc[%d]\n", pkt->hdr.opcode, rc); in q6asm_read()
1512 return -ENOMEM; in __q6asm_open_read()
1517 q6asm_add_hdr(ac, &pkt->hdr, pkt_size, true, stream_id); in __q6asm_open_read()
1518 pkt->hdr.opcode = ASM_STREAM_CMD_OPEN_READ_V3; in __q6asm_open_read()
1520 open->src_endpointype = ASM_END_POINT_DEVICE_MATRIX; in __q6asm_open_read()
1522 open->preprocopo_id = ASM_STREAM_POSTPROC_TOPO_ID_NONE; in __q6asm_open_read()
1523 open->bits_per_sample = bits_per_sample; in __q6asm_open_read()
1524 open->mode_flags = 0x0; in __q6asm_open_read()
1526 open->mode_flags |= ASM_LEGACY_STREAM_SESSION << in __q6asm_open_read()
1531 open->mode_flags |= 0x00; in __q6asm_open_read()
1532 open->enc_cfg_id = ASM_MEDIA_FMT_MULTI_CHANNEL_PCM_V2; in __q6asm_open_read()
1545 * q6asm_open_read() - Open audio client for reading
1562 * q6asm_write_async() - non blocking write
1577 struct audio_port_data *port; in q6asm_write_async() local
1588 return -ENOMEM; in q6asm_write_async()
1593 spin_lock_irqsave(&ac->lock, flags); in q6asm_write_async()
1594 port = &ac->port[SNDRV_PCM_STREAM_PLAYBACK]; in q6asm_write_async()
1595 q6asm_add_hdr(ac, &pkt->hdr, pkt_size, false, stream_id); in q6asm_write_async()
1597 ab = &port->buf[port->dsp_buf]; in q6asm_write_async()
1598 pkt->hdr.token = port->dsp_buf | (len << ASM_WRITE_TOKEN_LEN_SHIFT); in q6asm_write_async()
1599 pkt->hdr.opcode = ASM_DATA_CMD_WRITE_V2; in q6asm_write_async()
1600 write->buf_addr_lsw = lower_32_bits(ab->phys); in q6asm_write_async()
1601 write->buf_addr_msw = upper_32_bits(ab->phys); in q6asm_write_async()
1602 write->buf_size = len; in q6asm_write_async()
1603 write->seq_id = port->dsp_buf; in q6asm_write_async()
1604 write->timestamp_lsw = lsw_ts; in q6asm_write_async()
1605 write->timestamp_msw = msw_ts; in q6asm_write_async()
1606 write->mem_map_handle = in q6asm_write_async()
1607 ac->port[SNDRV_PCM_STREAM_PLAYBACK].mem_map_handle; in q6asm_write_async()
1609 write->flags = wflags; in q6asm_write_async()
1611 port->dsp_buf++; in q6asm_write_async()
1613 if (port->dsp_buf >= port->num_periods) in q6asm_write_async()
1614 port->dsp_buf = 0; in q6asm_write_async()
1616 spin_unlock_irqrestore(&ac->lock, flags); in q6asm_write_async()
1617 rc = apr_send_pkt(ac->adev, pkt); in q6asm_write_async()
1628 struct audio_port_data *port; in q6asm_reset_buf_state() local
1631 spin_lock_irqsave(&ac->lock, flags); in q6asm_reset_buf_state()
1632 port = &ac->port[SNDRV_PCM_STREAM_PLAYBACK]; in q6asm_reset_buf_state()
1633 port->dsp_buf = 0; in q6asm_reset_buf_state()
1634 port = &ac->port[SNDRV_PCM_STREAM_CAPTURE]; in q6asm_reset_buf_state()
1635 port->dsp_buf = 0; in q6asm_reset_buf_state()
1636 spin_unlock_irqrestore(&ac->lock, flags); in q6asm_reset_buf_state()
1667 return -EINVAL; in __q6asm_cmd()
1673 return apr_send_pkt(ac->adev, &pkt); in __q6asm_cmd()
1685 * q6asm_cmd() - run cmd on audio client
1700 * q6asm_cmd_nowait() - non blocking, run cmd on audio client
1716 struct device *dev = &adev->dev; in q6asm_probe()
1721 return -ENOMEM; in q6asm_probe()
1723 q6core_get_svc_api_info(adev->svc_id, &q6asm->ainfo); in q6asm_probe()
1725 q6asm->dev = dev; in q6asm_probe()
1726 q6asm->adev = adev; in q6asm_probe()
1727 init_waitqueue_head(&q6asm->mem_wait); in q6asm_probe()
1728 spin_lock_init(&q6asm->slock); in q6asm_probe()
1746 .name = "qcom-q6asm",