Lines Matching refs:ac

279 static inline void q6asm_add_hdr(struct audio_client *ac, struct apr_hdr *hdr,  in q6asm_add_hdr()  argument
284 hdr->src_port = ((ac->session << 8) & 0xFF00) | (stream_id); in q6asm_add_hdr()
285 hdr->dest_port = ((ac->session << 8) & 0xFF00) | (stream_id); in q6asm_add_hdr()
288 hdr->token = ac->session; in q6asm_add_hdr()
291 static int q6asm_apr_send_session_pkt(struct q6asm *a, struct audio_client *ac, in q6asm_apr_send_session_pkt() argument
297 mutex_lock(&ac->cmd_lock); in q6asm_apr_send_session_pkt()
298 ac->result.opcode = 0; in q6asm_apr_send_session_pkt()
299 ac->result.status = 0; in q6asm_apr_send_session_pkt()
306 (ac->result.opcode == hdr->opcode) || in q6asm_apr_send_session_pkt()
307 (ac->result.opcode == rsp_opcode), in q6asm_apr_send_session_pkt()
311 (ac->result.opcode == hdr->opcode), in q6asm_apr_send_session_pkt()
317 } else if (ac->result.status > 0) { in q6asm_apr_send_session_pkt()
319 ac->result.status); in q6asm_apr_send_session_pkt()
324 mutex_unlock(&ac->cmd_lock); in q6asm_apr_send_session_pkt()
328 static int __q6asm_memory_unmap(struct audio_client *ac, in __q6asm_memory_unmap() argument
332 struct q6asm *a = dev_get_drvdata(ac->dev->parent); in __q6asm_memory_unmap()
337 if (ac->port[dir].mem_map_handle == 0) { in __q6asm_memory_unmap()
338 dev_err(ac->dev, "invalid mem handle\n"); in __q6asm_memory_unmap()
354 pkt->hdr.token = ((ac->session << 8) | dir); in __q6asm_memory_unmap()
357 mem_unmap->mem_map_handle = ac->port[dir].mem_map_handle; in __q6asm_memory_unmap()
359 rc = q6asm_apr_send_session_pkt(a, ac, pkt, 0); in __q6asm_memory_unmap()
365 ac->port[dir].mem_map_handle = 0; in __q6asm_memory_unmap()
372 static void q6asm_audio_client_free_buf(struct audio_client *ac, in q6asm_audio_client_free_buf() argument
377 spin_lock_irqsave(&ac->lock, flags); in q6asm_audio_client_free_buf()
381 spin_unlock_irqrestore(&ac->lock, flags); in q6asm_audio_client_free_buf()
392 int q6asm_unmap_memory_regions(unsigned int dir, struct audio_client *ac) in q6asm_unmap_memory_regions() argument
398 port = &ac->port[dir]; in q6asm_unmap_memory_regions()
406 rc = __q6asm_memory_unmap(ac, port->buf[dir].phys, dir); in q6asm_unmap_memory_regions()
408 dev_err(ac->dev, "%s: Memory_unmap_regions failed %d\n", in q6asm_unmap_memory_regions()
414 q6asm_audio_client_free_buf(ac, port); in q6asm_unmap_memory_regions()
421 static int __q6asm_memory_map_regions(struct audio_client *ac, int dir, in __q6asm_memory_map_regions() argument
427 struct q6asm *a = dev_get_drvdata(ac->dev->parent); in __q6asm_memory_map_regions()
462 pkt->hdr.token = ((ac->session << 8) | dir); in __q6asm_memory_map_regions()
469 spin_lock_irqsave(&ac->lock, flags); in __q6asm_memory_map_regions()
470 port = &ac->port[dir]; in __q6asm_memory_map_regions()
479 spin_unlock_irqrestore(&ac->lock, flags); in __q6asm_memory_map_regions()
481 rc = q6asm_apr_send_session_pkt(a, ac, pkt, in __q6asm_memory_map_regions()
500 int q6asm_map_memory_regions(unsigned int dir, struct audio_client *ac, in q6asm_map_memory_regions() argument
509 spin_lock_irqsave(&ac->lock, flags); in q6asm_map_memory_regions()
510 if (ac->port[dir].buf) { in q6asm_map_memory_regions()
511 dev_err(ac->dev, "Buffer already allocated\n"); in q6asm_map_memory_regions()
512 spin_unlock_irqrestore(&ac->lock, flags); in q6asm_map_memory_regions()
518 spin_unlock_irqrestore(&ac->lock, flags); in q6asm_map_memory_regions()
523 ac->port[dir].buf = buf; in q6asm_map_memory_regions()
534 ac->port[dir].num_periods = periods; in q6asm_map_memory_regions()
536 spin_unlock_irqrestore(&ac->lock, flags); in q6asm_map_memory_regions()
538 rc = __q6asm_memory_map_regions(ac, dir, period_sz, periods, 1); in q6asm_map_memory_regions()
540 dev_err(ac->dev, "Memory_map_regions failed\n"); in q6asm_map_memory_regions()
541 q6asm_audio_client_free_buf(ac, &ac->port[dir]); in q6asm_map_memory_regions()
550 struct audio_client *ac; in q6asm_audio_client_release() local
554 ac = container_of(ref, struct audio_client, refcount); in q6asm_audio_client_release()
555 a = ac->q6asm; in q6asm_audio_client_release()
558 a->session[ac->session] = NULL; in q6asm_audio_client_release()
561 kfree(ac); in q6asm_audio_client_release()
569 void q6asm_audio_client_free(struct audio_client *ac) in q6asm_audio_client_free() argument
571 kref_put(&ac->refcount, q6asm_audio_client_release); in q6asm_audio_client_free()
578 struct audio_client *ac = NULL; in q6asm_get_audio_client() local
593 ac = a->session[session_id]; in q6asm_get_audio_client()
594 kref_get(&ac->refcount); in q6asm_get_audio_client()
597 return ac; in q6asm_get_audio_client()
608 struct audio_client *ac; in q6asm_stream_callback() local
612 ac = q6asm_get_audio_client(q6asm, session_id); in q6asm_stream_callback()
613 if (!ac)/* Audio client might already be freed by now */ in q6asm_stream_callback()
647 dev_err(ac->dev, in q6asm_stream_callback()
650 ac->result = *result; in q6asm_stream_callback()
651 wake_up(&ac->cmd_wait); in q6asm_stream_callback()
657 dev_err(ac->dev, "command[0x%x] not expecting rsp\n", in q6asm_stream_callback()
662 ac->result = *result; in q6asm_stream_callback()
663 wake_up(&ac->cmd_wait); in q6asm_stream_callback()
665 if (ac->cb) in q6asm_stream_callback()
666 ac->cb(client_event, hdr->token, in q6asm_stream_callback()
667 data->payload, ac->priv); in q6asm_stream_callback()
674 if (ac->io_mode & ASM_SYNC_IO_MODE) { in q6asm_stream_callback()
679 spin_lock_irqsave(&ac->lock, flags); in q6asm_stream_callback()
681 port = &ac->port[SNDRV_PCM_STREAM_PLAYBACK]; in q6asm_stream_callback()
684 spin_unlock_irqrestore(&ac->lock, flags); in q6asm_stream_callback()
693 dev_err(ac->dev, "Expected addr %pa\n", in q6asm_stream_callback()
695 spin_unlock_irqrestore(&ac->lock, flags); in q6asm_stream_callback()
699 spin_unlock_irqrestore(&ac->lock, flags); in q6asm_stream_callback()
704 if (ac->io_mode & ASM_SYNC_IO_MODE) { in q6asm_stream_callback()
709 spin_lock_irqsave(&ac->lock, flags); in q6asm_stream_callback()
710 port = &ac->port[SNDRV_PCM_STREAM_CAPTURE]; in q6asm_stream_callback()
712 spin_unlock_irqrestore(&ac->lock, flags); in q6asm_stream_callback()
721 dev_err(ac->dev, "Expected addr %pa %08x-%08x\n", in q6asm_stream_callback()
725 spin_unlock_irqrestore(&ac->lock, flags); in q6asm_stream_callback()
729 spin_unlock_irqrestore(&ac->lock, flags); in q6asm_stream_callback()
738 if (ac->cb) in q6asm_stream_callback()
739 ac->cb(client_event, hdr->token, data->payload, ac->priv); in q6asm_stream_callback()
742 kref_put(&ac->refcount, q6asm_audio_client_release); in q6asm_stream_callback()
752 struct audio_client *ac = NULL; in q6asm_srvc_callback() local
764 ac = q6asm_get_audio_client(q6asm, sid); in q6asm_srvc_callback()
765 if (!ac) { in q6asm_srvc_callback()
770 a = dev_get_drvdata(ac->dev->parent); in q6asm_srvc_callback()
772 port = &ac->port[dir]; in q6asm_srvc_callback()
780 ac->result = *result; in q6asm_srvc_callback()
790 ac->result.status = 0; in q6asm_srvc_callback()
791 ac->result.opcode = hdr->opcode; in q6asm_srvc_callback()
796 ac->result.opcode = hdr->opcode; in q6asm_srvc_callback()
797 ac->result.status = 0; in q6asm_srvc_callback()
807 if (ac->cb) in q6asm_srvc_callback()
808 ac->cb(hdr->opcode, hdr->token, data->payload, ac->priv); in q6asm_srvc_callback()
811 kref_put(&ac->refcount, q6asm_audio_client_release); in q6asm_srvc_callback()
846 struct audio_client *ac; in q6asm_audio_client_alloc() local
849 ac = q6asm_get_audio_client(a, session_id + 1); in q6asm_audio_client_alloc()
850 if (ac) { in q6asm_audio_client_alloc()
852 return ac; in q6asm_audio_client_alloc()
855 ac = kzalloc(sizeof(*ac), GFP_KERNEL); in q6asm_audio_client_alloc()
856 if (!ac) in q6asm_audio_client_alloc()
860 a->session[session_id + 1] = ac; in q6asm_audio_client_alloc()
862 ac->session = session_id + 1; in q6asm_audio_client_alloc()
863 ac->cb = cb; in q6asm_audio_client_alloc()
864 ac->dev = dev; in q6asm_audio_client_alloc()
865 ac->q6asm = a; in q6asm_audio_client_alloc()
866 ac->priv = priv; in q6asm_audio_client_alloc()
867 ac->io_mode = ASM_SYNC_IO_MODE; in q6asm_audio_client_alloc()
868 ac->perf_mode = perf_mode; in q6asm_audio_client_alloc()
869 ac->adev = a->adev; in q6asm_audio_client_alloc()
870 kref_init(&ac->refcount); in q6asm_audio_client_alloc()
872 init_waitqueue_head(&ac->cmd_wait); in q6asm_audio_client_alloc()
873 mutex_init(&ac->cmd_lock); in q6asm_audio_client_alloc()
874 spin_lock_init(&ac->lock); in q6asm_audio_client_alloc()
876 return ac; in q6asm_audio_client_alloc()
880 static int q6asm_ac_send_cmd_sync(struct audio_client *ac, struct apr_pkt *pkt) in q6asm_ac_send_cmd_sync() argument
885 mutex_lock(&ac->cmd_lock); in q6asm_ac_send_cmd_sync()
886 ac->result.opcode = 0; in q6asm_ac_send_cmd_sync()
887 ac->result.status = 0; in q6asm_ac_send_cmd_sync()
889 rc = apr_send_pkt(ac->adev, pkt); in q6asm_ac_send_cmd_sync()
893 rc = wait_event_timeout(ac->cmd_wait, in q6asm_ac_send_cmd_sync()
894 (ac->result.opcode == hdr->opcode), 5 * HZ); in q6asm_ac_send_cmd_sync()
896 dev_err(ac->dev, "CMD %x timeout\n", hdr->opcode); in q6asm_ac_send_cmd_sync()
901 if (ac->result.status > 0) { in q6asm_ac_send_cmd_sync()
902 dev_err(ac->dev, "DSP returned error[%x]\n", in q6asm_ac_send_cmd_sync()
903 ac->result.status); in q6asm_ac_send_cmd_sync()
911 mutex_unlock(&ac->cmd_lock); in q6asm_ac_send_cmd_sync()
926 int q6asm_open_write(struct audio_client *ac, uint32_t stream_id, in q6asm_open_write() argument
943 q6asm_add_hdr(ac, &pkt->hdr, pkt_size, true, stream_id); in q6asm_open_write()
978 dev_err(ac->dev, "Invalid codec profile 0x%x\n", in q6asm_open_write()
991 dev_err(ac->dev, "Invalid format 0x%x\n", format); in q6asm_open_write()
996 rc = q6asm_ac_send_cmd_sync(ac, pkt); in q6asm_open_write()
1000 ac->io_mode |= ASM_TUN_WRITE_IO_MODE; in q6asm_open_write()
1008 static int __q6asm_run(struct audio_client *ac, uint32_t stream_id, in __q6asm_run() argument
1025 q6asm_add_hdr(ac, &pkt->hdr, pkt_size, true, stream_id); in __q6asm_run()
1032 rc = q6asm_ac_send_cmd_sync(ac, pkt); in __q6asm_run()
1034 rc = apr_send_pkt(ac->adev, pkt); in __q6asm_run()
1054 int q6asm_run(struct audio_client *ac, uint32_t stream_id, uint32_t flags, in q6asm_run() argument
1057 return __q6asm_run(ac, stream_id, flags, msw_ts, lsw_ts, true); in q6asm_run()
1072 int q6asm_run_nowait(struct audio_client *ac, uint32_t stream_id, in q6asm_run_nowait() argument
1075 return __q6asm_run(ac, stream_id, flags, msw_ts, lsw_ts, false); in q6asm_run_nowait()
1091 int q6asm_media_format_block_multi_ch_pcm(struct audio_client *ac, in q6asm_media_format_block_multi_ch_pcm() argument
1111 q6asm_add_hdr(ac, &pkt->hdr, pkt_size, true, stream_id); in q6asm_media_format_block_multi_ch_pcm()
1126 dev_err(ac->dev, " map channels failed %d\n", channels); in q6asm_media_format_block_multi_ch_pcm()
1132 rc = q6asm_ac_send_cmd_sync(ac, pkt); in q6asm_media_format_block_multi_ch_pcm()
1140 int q6asm_stream_media_format_block_flac(struct audio_client *ac, in q6asm_stream_media_format_block_flac() argument
1157 q6asm_add_hdr(ac, &pkt->hdr, pkt_size, true, stream_id); in q6asm_stream_media_format_block_flac()
1170 rc = q6asm_ac_send_cmd_sync(ac, pkt); in q6asm_stream_media_format_block_flac()
1177 int q6asm_stream_media_format_block_wma_v9(struct audio_client *ac, in q6asm_stream_media_format_block_wma_v9() argument
1194 q6asm_add_hdr(ac, &pkt->hdr, pkt_size, true, stream_id); in q6asm_stream_media_format_block_wma_v9()
1208 rc = q6asm_ac_send_cmd_sync(ac, pkt); in q6asm_stream_media_format_block_wma_v9()
1215 int q6asm_stream_media_format_block_wma_v10(struct audio_client *ac, in q6asm_stream_media_format_block_wma_v10() argument
1232 q6asm_add_hdr(ac, &pkt->hdr, pkt_size, true, stream_id); in q6asm_stream_media_format_block_wma_v10()
1247 rc = q6asm_ac_send_cmd_sync(ac, pkt); in q6asm_stream_media_format_block_wma_v10()
1254 int q6asm_stream_media_format_block_alac(struct audio_client *ac, in q6asm_stream_media_format_block_alac() argument
1271 q6asm_add_hdr(ac, &pkt->hdr, pkt_size, true, stream_id); in q6asm_stream_media_format_block_alac()
1289 rc = q6asm_ac_send_cmd_sync(ac, pkt); in q6asm_stream_media_format_block_alac()
1296 int q6asm_stream_media_format_block_ape(struct audio_client *ac, in q6asm_stream_media_format_block_ape() argument
1313 q6asm_add_hdr(ac, &pkt->hdr, pkt_size, true, stream_id); in q6asm_stream_media_format_block_ape()
1329 rc = q6asm_ac_send_cmd_sync(ac, pkt); in q6asm_stream_media_format_block_ape()
1336 static int q6asm_stream_remove_silence(struct audio_client *ac, uint32_t stream_id, in q6asm_stream_remove_silence() argument
1353 q6asm_add_hdr(ac, &pkt->hdr, pkt_size, true, stream_id); in q6asm_stream_remove_silence()
1357 rc = apr_send_pkt(ac->adev, pkt); in q6asm_stream_remove_silence()
1366 int q6asm_stream_remove_initial_silence(struct audio_client *ac, in q6asm_stream_remove_initial_silence() argument
1370 return q6asm_stream_remove_silence(ac, stream_id, in q6asm_stream_remove_initial_silence()
1376 int q6asm_stream_remove_trailing_silence(struct audio_client *ac, uint32_t stream_id, in q6asm_stream_remove_trailing_silence() argument
1379 return q6asm_stream_remove_silence(ac, stream_id, in q6asm_stream_remove_trailing_silence()
1396 int q6asm_enc_cfg_blk_pcm_format_support(struct audio_client *ac, in q6asm_enc_cfg_blk_pcm_format_support() argument
1415 q6asm_add_hdr(ac, &pkt->hdr, pkt_size, true, stream_id); in q6asm_enc_cfg_blk_pcm_format_support()
1435 rc = q6asm_ac_send_cmd_sync(ac, pkt); in q6asm_enc_cfg_blk_pcm_format_support()
1451 int q6asm_read(struct audio_client *ac, uint32_t stream_id) in q6asm_read() argument
1470 spin_lock_irqsave(&ac->lock, flags); in q6asm_read()
1471 port = &ac->port[SNDRV_PCM_STREAM_CAPTURE]; in q6asm_read()
1472 q6asm_add_hdr(ac, &pkt->hdr, pkt_size, false, stream_id); in q6asm_read()
1488 spin_unlock_irqrestore(&ac->lock, flags); in q6asm_read()
1489 rc = apr_send_pkt(ac->adev, pkt); in q6asm_read()
1500 static int __q6asm_open_read(struct audio_client *ac, uint32_t stream_id, in __q6asm_open_read() argument
1516 q6asm_add_hdr(ac, &pkt->hdr, pkt_size, true, stream_id); in __q6asm_open_read()
1537 rc = q6asm_ac_send_cmd_sync(ac, pkt); in __q6asm_open_read()
1553 int q6asm_open_read(struct audio_client *ac, uint32_t stream_id, in q6asm_open_read() argument
1556 return __q6asm_open_read(ac, stream_id, format, bits_per_sample); in q6asm_open_read()
1572 int q6asm_write_async(struct audio_client *ac, uint32_t stream_id, uint32_t len, in q6asm_write_async() argument
1592 spin_lock_irqsave(&ac->lock, flags); in q6asm_write_async()
1593 port = &ac->port[SNDRV_PCM_STREAM_PLAYBACK]; in q6asm_write_async()
1594 q6asm_add_hdr(ac, &pkt->hdr, pkt_size, false, stream_id); in q6asm_write_async()
1606 ac->port[SNDRV_PCM_STREAM_PLAYBACK].mem_map_handle; in q6asm_write_async()
1615 spin_unlock_irqrestore(&ac->lock, flags); in q6asm_write_async()
1616 rc = apr_send_pkt(ac->adev, pkt); in q6asm_write_async()
1625 static void q6asm_reset_buf_state(struct audio_client *ac) in q6asm_reset_buf_state() argument
1630 spin_lock_irqsave(&ac->lock, flags); in q6asm_reset_buf_state()
1631 port = &ac->port[SNDRV_PCM_STREAM_PLAYBACK]; in q6asm_reset_buf_state()
1633 port = &ac->port[SNDRV_PCM_STREAM_CAPTURE]; in q6asm_reset_buf_state()
1635 spin_unlock_irqrestore(&ac->lock, flags); in q6asm_reset_buf_state()
1638 static int __q6asm_cmd(struct audio_client *ac, uint32_t stream_id, int cmd, in __q6asm_cmd() argument
1644 q6asm_add_hdr(ac, &pkt.hdr, APR_HDR_SIZE, true, stream_id); in __q6asm_cmd()
1670 rc = q6asm_ac_send_cmd_sync(ac, &pkt); in __q6asm_cmd()
1672 return apr_send_pkt(ac->adev, &pkt); in __q6asm_cmd()
1678 q6asm_reset_buf_state(ac); in __q6asm_cmd()
1692 int q6asm_cmd(struct audio_client *ac, uint32_t stream_id, int cmd) in q6asm_cmd() argument
1694 return __q6asm_cmd(ac, stream_id, cmd, true); in q6asm_cmd()
1707 int q6asm_cmd_nowait(struct audio_client *ac, uint32_t stream_id, int cmd) in q6asm_cmd_nowait() argument
1709 return __q6asm_cmd(ac, stream_id, cmd, false); in q6asm_cmd_nowait()