Lines Matching full:graph
21 /* Graph Management */
43 struct audioreach_graph *graph; in q6apm_get_audioreach_graph() local
47 graph = idr_find(&apm->graph_idr, graph_id); in q6apm_get_audioreach_graph()
50 if (graph) { in q6apm_get_audioreach_graph()
51 kref_get(&graph->refcount); in q6apm_get_audioreach_graph()
52 return graph; in q6apm_get_audioreach_graph()
60 graph = kzalloc(sizeof(*graph), GFP_KERNEL); in q6apm_get_audioreach_graph()
61 if (!graph) in q6apm_get_audioreach_graph()
64 graph->apm = apm; in q6apm_get_audioreach_graph()
65 graph->info = info; in q6apm_get_audioreach_graph()
66 graph->id = graph_id; in q6apm_get_audioreach_graph()
68 graph->graph = audioreach_alloc_graph_pkt(apm, info); in q6apm_get_audioreach_graph()
69 if (IS_ERR(graph->graph)) { in q6apm_get_audioreach_graph()
70 void *err = graph->graph; in q6apm_get_audioreach_graph()
72 kfree(graph); in q6apm_get_audioreach_graph()
77 id = idr_alloc(&apm->graph_idr, graph, graph_id, graph_id + 1, GFP_KERNEL); in q6apm_get_audioreach_graph()
79 dev_err(apm->dev, "Unable to allocate graph id (%d)\n", graph_id); in q6apm_get_audioreach_graph()
80 kfree(graph->graph); in q6apm_get_audioreach_graph()
81 kfree(graph); in q6apm_get_audioreach_graph()
87 kref_init(&graph->refcount); in q6apm_get_audioreach_graph()
89 q6apm_send_cmd_sync(apm, graph->graph, 0); in q6apm_get_audioreach_graph()
91 return graph; in q6apm_get_audioreach_graph()
94 static int audioreach_graph_mgmt_cmd(struct audioreach_graph *graph, uint32_t opcode) in audioreach_graph_mgmt_cmd() argument
96 struct audioreach_graph_info *info = graph->info; in audioreach_graph_mgmt_cmd()
101 struct q6apm *apm = graph->apm; in audioreach_graph_mgmt_cmd()
132 struct audioreach_graph *graph; in q6apm_put_audioreach_graph() local
135 graph = container_of(ref, struct audioreach_graph, refcount); in q6apm_put_audioreach_graph()
136 apm = graph->apm; in q6apm_put_audioreach_graph()
138 audioreach_graph_mgmt_cmd(graph, APM_CMD_GRAPH_CLOSE); in q6apm_put_audioreach_graph()
141 graph = idr_remove(&apm->graph_idr, graph->id); in q6apm_put_audioreach_graph()
144 kfree(graph->graph); in q6apm_put_audioreach_graph()
145 kfree(graph); in q6apm_put_audioreach_graph()
193 int q6apm_graph_media_format_shmem(struct q6apm_graph *graph, in q6apm_graph_media_format_shmem() argument
199 module = q6apm_find_module_by_mid(graph, MODULE_ID_RD_SHARED_MEM_EP); in q6apm_graph_media_format_shmem()
201 module = q6apm_find_module_by_mid(graph, MODULE_ID_WR_SHARED_MEM_EP); in q6apm_graph_media_format_shmem()
206 audioreach_set_media_format(graph, module, cfg); in q6apm_graph_media_format_shmem()
213 int q6apm_map_memory_regions(struct q6apm_graph *graph, unsigned int dir, phys_addr_t phys, in q6apm_map_memory_regions() argument
222 data = &graph->rx_data; in q6apm_map_memory_regions()
224 data = &graph->tx_data; in q6apm_map_memory_regions()
226 mutex_lock(&graph->lock); in q6apm_map_memory_regions()
229 mutex_unlock(&graph->lock); in q6apm_map_memory_regions()
235 mutex_unlock(&graph->lock); in q6apm_map_memory_regions()
240 data = &graph->rx_data; in q6apm_map_memory_regions()
242 data = &graph->tx_data; in q6apm_map_memory_regions()
257 mutex_unlock(&graph->lock); in q6apm_map_memory_regions()
259 rc = audioreach_map_memory_regions(graph, dir, period_sz, periods, 1); in q6apm_map_memory_regions()
261 dev_err(graph->dev, "Memory_map_regions failed\n"); in q6apm_map_memory_regions()
262 audioreach_graph_free_buf(graph); in q6apm_map_memory_regions()
269 int q6apm_unmap_memory_regions(struct q6apm_graph *graph, unsigned int dir) in q6apm_unmap_memory_regions() argument
277 data = &graph->rx_data; in q6apm_unmap_memory_regions()
279 data = &graph->tx_data; in q6apm_unmap_memory_regions()
285 graph->port->id); in q6apm_unmap_memory_regions()
292 rc = audioreach_graph_send_cmd_sync(graph, pkt, APM_CMD_SHARED_MEM_UNMAP_REGIONS); in q6apm_unmap_memory_regions()
295 audioreach_graph_free_buf(graph); in q6apm_unmap_memory_regions()
301 int q6apm_remove_initial_silence(struct device *dev, struct q6apm_graph *graph, uint32_t samples) in q6apm_remove_initial_silence() argument
305 module = q6apm_find_module_by_mid(graph, MODULE_ID_PLACEHOLDER_DECODER); in q6apm_remove_initial_silence()
309 return audioreach_send_u32_param(graph, module, PARAM_ID_REMOVE_INITIAL_SILENCE, samples); in q6apm_remove_initial_silence()
313 int q6apm_remove_trailing_silence(struct device *dev, struct q6apm_graph *graph, uint32_t samples) in q6apm_remove_trailing_silence() argument
317 module = q6apm_find_module_by_mid(graph, MODULE_ID_PLACEHOLDER_DECODER); in q6apm_remove_trailing_silence()
321 return audioreach_send_u32_param(graph, module, PARAM_ID_REMOVE_TRAILING_SILENCE, samples); in q6apm_remove_trailing_silence()
325 int q6apm_enable_compress_module(struct device *dev, struct q6apm_graph *graph, bool en) in q6apm_enable_compress_module() argument
329 module = q6apm_find_module_by_mid(graph, MODULE_ID_PLACEHOLDER_DECODER); in q6apm_enable_compress_module()
333 return audioreach_send_u32_param(graph, module, PARAM_ID_MODULE_ENABLE, en); in q6apm_enable_compress_module()
337 int q6apm_set_real_module_id(struct device *dev, struct q6apm_graph *graph, in q6apm_set_real_module_id() argument
343 module = q6apm_find_module_by_mid(graph, MODULE_ID_PLACEHOLDER_DECODER); in q6apm_set_real_module_id()
361 return audioreach_send_u32_param(graph, module, PARAM_ID_REAL_MODULE_ID, in q6apm_set_real_module_id()
366 int q6apm_graph_media_format_pcm(struct q6apm_graph *graph, struct audioreach_module_config *cfg) in q6apm_graph_media_format_pcm() argument
368 struct audioreach_graph_info *info = graph->info; in q6apm_graph_media_format_pcm()
380 audioreach_set_media_format(graph, module, cfg); in q6apm_graph_media_format_pcm()
390 static int q6apm_graph_get_tx_shmem_module_iid(struct q6apm_graph *graph) in q6apm_graph_get_tx_shmem_module_iid() argument
394 module = q6apm_find_module_by_mid(graph, MODULE_ID_RD_SHARED_MEM_EP); in q6apm_graph_get_tx_shmem_module_iid()
402 int q6apm_graph_get_rx_shmem_module_iid(struct q6apm_graph *graph) in q6apm_graph_get_rx_shmem_module_iid() argument
406 module = q6apm_find_module_by_mid(graph, MODULE_ID_WR_SHARED_MEM_EP); in q6apm_graph_get_rx_shmem_module_iid()
415 int q6apm_write_async(struct q6apm_graph *graph, uint32_t len, uint32_t msw_ts, in q6apm_write_async() argument
423 iid = q6apm_graph_get_rx_shmem_module_iid(graph); in q6apm_write_async()
425 graph->rx_data.dsp_buf | (len << APM_WRITE_TOKEN_LEN_SHIFT), in q6apm_write_async()
426 graph->port->id, iid); in q6apm_write_async()
432 mutex_lock(&graph->lock); in q6apm_write_async()
433 ab = &graph->rx_data.buf[graph->rx_data.dsp_buf]; in q6apm_write_async()
440 write_buffer->mem_map_handle = graph->rx_data.mem_map_handle; in q6apm_write_async()
443 graph->rx_data.dsp_buf++; in q6apm_write_async()
445 if (graph->rx_data.dsp_buf >= graph->rx_data.num_periods) in q6apm_write_async()
446 graph->rx_data.dsp_buf = 0; in q6apm_write_async()
448 mutex_unlock(&graph->lock); in q6apm_write_async()
450 rc = gpr_send_port_pkt(graph->port, pkt); in q6apm_write_async()
458 int q6apm_read(struct q6apm_graph *graph) in q6apm_read() argument
466 iid = q6apm_graph_get_tx_shmem_module_iid(graph); in q6apm_read()
468 graph->tx_data.dsp_buf, graph->port->id, iid); in q6apm_read()
474 mutex_lock(&graph->lock); in q6apm_read()
475 port = &graph->tx_data; in q6apm_read()
488 mutex_unlock(&graph->lock); in q6apm_read()
490 rc = gpr_send_port_pkt(graph->port, pkt); in q6apm_read()
503 struct q6apm_graph *graph = priv; in graph_callback() local
505 struct device *dev = graph->dev; in graph_callback()
514 if (!graph->ar_graph) in graph_callback()
517 mutex_lock(&graph->lock); in graph_callback()
521 phys = graph->rx_data.buf[token].phys; in graph_callback()
522 mutex_unlock(&graph->lock); in graph_callback()
526 graph->result.opcode = hdr->opcode; in graph_callback()
527 graph->result.status = done->status; in graph_callback()
528 if (graph->cb) in graph_callback()
529 graph->cb(client_event, hdr->token, data->payload, graph->priv); in graph_callback()
537 graph->result.opcode = hdr->opcode; in graph_callback()
538 graph->result.status = 0; in graph_callback()
542 graph->rx_data.mem_map_handle = rsp->mem_map_handle; in graph_callback()
544 graph->tx_data.mem_map_handle = rsp->mem_map_handle; in graph_callback()
546 wake_up(&graph->cmd_wait); in graph_callback()
549 if (!graph->ar_graph) in graph_callback()
552 mutex_lock(&graph->lock); in graph_callback()
554 phys = graph->tx_data.buf[hdr->token].phys; in graph_callback()
555 mutex_unlock(&graph->lock); in graph_callback()
559 graph->result.opcode = hdr->opcode; in graph_callback()
560 graph->result.status = rd_done->status; in graph_callback()
561 if (graph->cb) in graph_callback()
562 graph->cb(client_event, hdr->token, data->payload, graph->priv); in graph_callback()
570 if (graph->cb) in graph_callback()
571 graph->cb(client_event, hdr->token, data->payload, graph->priv); in graph_callback()
576 graph->result.opcode = result->opcode; in graph_callback()
577 graph->result.status = 0; in graph_callback()
579 graph->rx_data.mem_map_handle = 0; in graph_callback()
581 graph->tx_data.mem_map_handle = 0; in graph_callback()
583 wake_up(&graph->cmd_wait); in graph_callback()
588 graph->result.opcode = result->opcode; in graph_callback()
589 graph->result.status = result->status; in graph_callback()
593 wake_up(&graph->cmd_wait); in graph_callback()
610 struct q6apm_graph *graph; in q6apm_graph_open() local
615 dev_err(dev, "No graph found with id %d\n", graph_id); in q6apm_graph_open()
619 graph = kzalloc(sizeof(*graph), GFP_KERNEL); in q6apm_graph_open()
620 if (!graph) { in q6apm_graph_open()
625 graph->apm = apm; in q6apm_graph_open()
626 graph->priv = priv; in q6apm_graph_open()
627 graph->cb = cb; in q6apm_graph_open()
628 graph->info = ar_graph->info; in q6apm_graph_open()
629 graph->ar_graph = ar_graph; in q6apm_graph_open()
630 graph->id = ar_graph->id; in q6apm_graph_open()
631 graph->dev = dev; in q6apm_graph_open()
633 mutex_init(&graph->lock); in q6apm_graph_open()
634 init_waitqueue_head(&graph->cmd_wait); in q6apm_graph_open()
636 graph->port = gpr_alloc_port(apm->gdev, dev, graph_callback, graph); in q6apm_graph_open()
637 if (IS_ERR(graph->port)) { in q6apm_graph_open()
638 ret = PTR_ERR(graph->port); in q6apm_graph_open()
642 return graph; in q6apm_graph_open()
645 kfree(graph); in q6apm_graph_open()
652 int q6apm_graph_close(struct q6apm_graph *graph) in q6apm_graph_close() argument
654 struct audioreach_graph *ar_graph = graph->ar_graph; in q6apm_graph_close()
656 graph->ar_graph = NULL; in q6apm_graph_close()
658 gpr_free_port(graph->port); in q6apm_graph_close()
659 kfree(graph); in q6apm_graph_close()
665 int q6apm_graph_prepare(struct q6apm_graph *graph) in q6apm_graph_prepare() argument
667 return audioreach_graph_mgmt_cmd(graph->ar_graph, APM_CMD_GRAPH_PREPARE); in q6apm_graph_prepare()
671 int q6apm_graph_start(struct q6apm_graph *graph) in q6apm_graph_start() argument
673 struct audioreach_graph *ar_graph = graph->ar_graph; in q6apm_graph_start()
685 int q6apm_graph_stop(struct q6apm_graph *graph) in q6apm_graph_stop() argument
687 struct audioreach_graph *ar_graph = graph->ar_graph; in q6apm_graph_stop()
696 int q6apm_graph_flush(struct q6apm_graph *graph) in q6apm_graph_flush() argument
698 return audioreach_graph_mgmt_cmd(graph->ar_graph, APM_CMD_GRAPH_FLUSH); in q6apm_graph_flush()
759 struct audioreach_module *q6apm_find_module_by_mid(struct q6apm_graph *graph, uint32_t mid) in q6apm_find_module_by_mid() argument
761 struct audioreach_graph_info *info = graph->info; in q6apm_find_module_by_mid()
762 struct q6apm *apm = graph->apm; in q6apm_find_module_by_mid()