Lines Matching refs:hsw

229 	struct sst_hsw *hsw;  member
276 struct sst_hsw *hsw; member
422 static struct sst_hsw_stream *get_stream_by_id(struct sst_hsw *hsw, in get_stream_by_id() argument
427 list_for_each_entry(stream, &hsw->stream_list, node) { in get_stream_by_id()
435 static void hsw_fw_ready(struct sst_hsw *hsw, u32 header) in hsw_fw_ready() argument
445 dev_dbg(hsw->dev, "ipc: DSP is ready 0x%8.8x offset %d\n", in hsw_fw_ready()
449 sst_dsp_read(hsw->dsp, &fw_ready, offset, sizeof(fw_ready)); in hsw_fw_ready()
451 sst_dsp_mailbox_init(hsw->dsp, fw_ready.inbox_offset, in hsw_fw_ready()
455 hsw->boot_complete = true; in hsw_fw_ready()
456 wake_up(&hsw->boot_wait); in hsw_fw_ready()
458 dev_dbg(hsw->dev, " mailbox upstream 0x%x - size 0x%x\n", in hsw_fw_ready()
460 dev_dbg(hsw->dev, " mailbox downstream 0x%x - size 0x%x\n", in hsw_fw_ready()
464 dev_dbg(hsw->dev, " Firmware info: %s \n", fw_ready.fw_info); in hsw_fw_ready()
471 dev_info(hsw->dev, "FW loaded, mailbox readback FW info: type %s, - " in hsw_fw_ready()
483 struct sst_hsw *hsw = stream->hsw; in hsw_notification_work() local
492 sst_dsp_inbox_read(hsw->dsp, glitch, sizeof(*glitch)); in hsw_notification_work()
494 dev_err(hsw->dev, "glitch %d pos 0x%x write pos 0x%x\n", in hsw_notification_work()
502 sst_dsp_inbox_read(hsw->dsp, pos, sizeof(*pos)); in hsw_notification_work()
509 dev_err(hsw->dev, "error: unknown notification 0x%x\n", in hsw_notification_work()
515 sst_dsp_shim_update_bits(hsw->dsp, SST_IPCD, in hsw_notification_work()
519 sst_dsp_shim_update_bits(hsw->dsp, SST_IMRX, SST_IMRX_BUSY, 0); in hsw_notification_work()
522 static void hsw_stream_update(struct sst_hsw *hsw, struct ipc_message *msg) in hsw_stream_update() argument
529 stream = get_stream_by_id(hsw, stream_id); in hsw_stream_update()
553 static int hsw_process_reply(struct sst_hsw *hsw, u32 header) in hsw_process_reply() argument
560 msg = sst_ipc_reply_find_msg(&hsw->ipc, header); in hsw_process_reply()
571 hsw->ipc.pending = true; in hsw_process_reply()
576 sst_dsp_inbox_read(hsw->dsp, msg->rx_data, in hsw_process_reply()
578 hsw->ipc.pending = false; in hsw_process_reply()
581 sst_dsp_outbox_read(hsw->dsp, msg->rx_data, in hsw_process_reply()
630 hsw_stream_update(hsw, msg); in hsw_process_reply()
634 sst_ipc_tx_msg_reply_complete(&hsw->ipc, msg); in hsw_process_reply()
639 static int hsw_module_message(struct sst_hsw *hsw, u32 header) in hsw_module_message() argument
646 dev_dbg(hsw->dev, "received module message header: 0x%8.8x\n", in hsw_module_message()
648 dev_dbg(hsw->dev, "operation: 0x%8.8x module_id: 0x%8.8x\n", in hsw_module_message()
653 dev_dbg(hsw->dev, "module notification received"); in hsw_module_message()
657 handled = hsw_process_reply(hsw, header); in hsw_module_message()
664 static int hsw_stream_message(struct sst_hsw *hsw, u32 header) in hsw_stream_message() argument
674 stream = get_stream_by_id(hsw, stream_id); in hsw_stream_message()
682 dev_err(hsw->dev, "error: stage msg not implemented 0x%8.8x\n", in hsw_stream_message()
690 handled = hsw_process_reply(hsw, header); in hsw_stream_message()
697 static int hsw_log_message(struct sst_hsw *hsw, u32 header) in hsw_log_message() argument
700 struct sst_hsw_log_stream *stream = &hsw->log_stream; in hsw_log_message()
704 dev_err(hsw->dev, in hsw_log_message()
712 hsw->dsp, &stream->curr_pos, sizeof(stream->curr_pos)); in hsw_log_message()
720 static int hsw_process_notification(struct sst_hsw *hsw) in hsw_process_notification() argument
722 struct sst_dsp *sst = hsw->dsp; in hsw_process_notification()
732 if (!hsw->boot_complete && header & IPC_FW_READY) { in hsw_process_notification()
733 hsw_fw_ready(hsw, header); in hsw_process_notification()
750 dev_err(hsw->dev, "error: message type %d header 0x%x\n", in hsw_process_notification()
754 handled = hsw_stream_message(hsw, header); in hsw_process_notification()
757 handled = hsw_log_message(hsw, header); in hsw_process_notification()
760 handled = hsw_module_message(hsw, header); in hsw_process_notification()
763 dev_err(hsw->dev, "error: unexpected type %d hdr 0x%8.8x\n", in hsw_process_notification()
774 struct sst_hsw *hsw = sst_dsp_get_thread_context(sst); in hsw_irq_thread() local
775 struct sst_generic_ipc *ipc = &hsw->ipc; in hsw_irq_thread()
782 ipcx = sst_dsp_ipc_msg_rx(hsw->dsp); in hsw_irq_thread()
789 handled = hsw_process_reply(hsw, ipcx); in hsw_irq_thread()
806 handled = hsw_process_notification(hsw); in hsw_irq_thread()
827 int sst_hsw_fw_get_version(struct sst_hsw *hsw, in sst_hsw_fw_get_version() argument
832 ret = sst_ipc_tx_message_wait(&hsw->ipc, in sst_hsw_fw_get_version()
836 dev_err(hsw->dev, "error: get version failed\n"); in sst_hsw_fw_get_version()
842 int sst_hsw_stream_get_volume(struct sst_hsw *hsw, struct sst_hsw_stream *stream, in sst_hsw_stream_get_volume() argument
848 sst_dsp_read(hsw->dsp, volume, in sst_hsw_stream_get_volume()
856 int sst_hsw_stream_set_volume(struct sst_hsw *hsw, in sst_hsw_stream_set_volume() argument
879 if (hsw->mute[0] && hsw->mute[1]) { in sst_hsw_stream_set_volume()
880 hsw->mute_volume[0] = hsw->mute_volume[1] = volume; in sst_hsw_stream_set_volume()
882 } else if (hsw->mute[0]) in sst_hsw_stream_set_volume()
884 else if (hsw->mute[1]) in sst_hsw_stream_set_volume()
890 if (hsw->mute[channel]) { in sst_hsw_stream_set_volume()
891 hsw->mute_volume[channel] = volume; in sst_hsw_stream_set_volume()
897 ret = sst_ipc_tx_message_wait(&hsw->ipc, header, req, in sst_hsw_stream_set_volume()
900 dev_err(hsw->dev, "error: set stream volume failed\n"); in sst_hsw_stream_set_volume()
907 int sst_hsw_mixer_get_volume(struct sst_hsw *hsw, u32 stage_id, u32 channel, in sst_hsw_mixer_get_volume() argument
913 sst_dsp_read(hsw->dsp, volume, in sst_hsw_mixer_get_volume()
914 hsw->mixer_info.volume_register_address[channel], in sst_hsw_mixer_get_volume()
921 int sst_hsw_mixer_set_volume(struct sst_hsw *hsw, u32 stage_id, u32 channel, in sst_hsw_mixer_set_volume() argument
935 if (hsw->mute[0] && hsw->mute[1]) { in sst_hsw_mixer_set_volume()
936 hsw->mute_volume[0] = hsw->mute_volume[1] = volume; in sst_hsw_mixer_set_volume()
938 } else if (hsw->mute[0]) in sst_hsw_mixer_set_volume()
940 else if (hsw->mute[1]) in sst_hsw_mixer_set_volume()
946 if (hsw->mute[channel]) { in sst_hsw_mixer_set_volume()
947 hsw->mute_volume[channel] = volume; in sst_hsw_mixer_set_volume()
955 header |= (hsw->mixer_info.mixer_hw_id << IPC_STR_ID_SHIFT); in sst_hsw_mixer_set_volume()
959 req.curve_duration = hsw->curve_duration; in sst_hsw_mixer_set_volume()
960 req.curve_type = hsw->curve_type; in sst_hsw_mixer_set_volume()
963 ret = sst_ipc_tx_message_wait(&hsw->ipc, header, &req, in sst_hsw_mixer_set_volume()
966 dev_err(hsw->dev, "error: set mixer volume failed\n"); in sst_hsw_mixer_set_volume()
974 struct sst_hsw_stream *sst_hsw_stream_new(struct sst_hsw *hsw, int id, in sst_hsw_stream_new() argument
979 struct sst_dsp *sst = hsw->dsp; in sst_hsw_stream_new()
988 list_add(&stream->node, &hsw->stream_list); in sst_hsw_stream_new()
991 stream->hsw = hsw; in sst_hsw_stream_new()
1001 int sst_hsw_stream_free(struct sst_hsw *hsw, struct sst_hsw_stream *stream) in sst_hsw_stream_free() argument
1005 struct sst_dsp *sst = hsw->dsp; in sst_hsw_stream_free()
1009 dev_warn(hsw->dev, "warning: stream is NULL, no stream to free, ignore it.\n"); in sst_hsw_stream_free()
1022 ret = sst_ipc_tx_message_wait(&hsw->ipc, header, &stream->free_req, in sst_hsw_stream_free()
1025 dev_err(hsw->dev, "error: free stream %d failed\n", in sst_hsw_stream_free()
1042 int sst_hsw_stream_set_bits(struct sst_hsw *hsw, in sst_hsw_stream_set_bits() argument
1046 dev_err(hsw->dev, "error: stream committed for set bits\n"); in sst_hsw_stream_set_bits()
1054 int sst_hsw_stream_set_channels(struct sst_hsw *hsw, in sst_hsw_stream_set_channels() argument
1058 dev_err(hsw->dev, "error: stream committed for set channels\n"); in sst_hsw_stream_set_channels()
1066 int sst_hsw_stream_set_rate(struct sst_hsw *hsw, in sst_hsw_stream_set_rate() argument
1070 dev_err(hsw->dev, "error: stream committed for set rate\n"); in sst_hsw_stream_set_rate()
1078 int sst_hsw_stream_set_map_config(struct sst_hsw *hsw, in sst_hsw_stream_set_map_config() argument
1083 dev_err(hsw->dev, "error: stream committed for set map\n"); in sst_hsw_stream_set_map_config()
1092 int sst_hsw_stream_set_style(struct sst_hsw *hsw, in sst_hsw_stream_set_style() argument
1096 dev_err(hsw->dev, "error: stream committed for set style\n"); in sst_hsw_stream_set_style()
1104 int sst_hsw_stream_set_valid(struct sst_hsw *hsw, in sst_hsw_stream_set_valid() argument
1108 dev_err(hsw->dev, "error: stream committed for set valid bits\n"); in sst_hsw_stream_set_valid()
1117 int sst_hsw_stream_format(struct sst_hsw *hsw, struct sst_hsw_stream *stream, in sst_hsw_stream_format() argument
1123 dev_err(hsw->dev, "error: stream committed for set format\n"); in sst_hsw_stream_format()
1136 int sst_hsw_stream_buffer(struct sst_hsw *hsw, struct sst_hsw_stream *stream, in sst_hsw_stream_buffer() argument
1141 dev_err(hsw->dev, "error: stream committed for buffer\n"); in sst_hsw_stream_buffer()
1156 int sst_hsw_stream_set_module_info(struct sst_hsw *hsw, in sst_hsw_stream_set_module_info() argument
1160 struct sst_dsp *dsp = sst_hsw_get_dsp(hsw); in sst_hsw_stream_set_module_info()
1164 dev_err(hsw->dev, "error: stream committed for set module\n"); in sst_hsw_stream_set_module_info()
1181 dev_dbg(hsw->dev, "module %d runtime %d using:\n", module->id, in sst_hsw_stream_set_module_info()
1183 dev_dbg(hsw->dev, " persistent offset 0x%x bytes 0x%x\n", in sst_hsw_stream_set_module_info()
1186 dev_dbg(hsw->dev, " scratch offset 0x%x bytes 0x%x\n", in sst_hsw_stream_set_module_info()
1193 int sst_hsw_stream_commit(struct sst_hsw *hsw, struct sst_hsw_stream *stream) in sst_hsw_stream_commit() argument
1201 dev_warn(hsw->dev, "warning: stream is NULL, no stream to commit, ignore it.\n"); in sst_hsw_stream_commit()
1206 dev_warn(hsw->dev, "warning: stream is already committed, ignore it.\n"); in sst_hsw_stream_commit()
1214 ret = sst_ipc_tx_message_wait(&hsw->ipc, header, str_req, in sst_hsw_stream_commit()
1217 dev_err(hsw->dev, "error: stream commit failed\n"); in sst_hsw_stream_commit()
1227 snd_pcm_uframes_t sst_hsw_stream_get_old_position(struct sst_hsw *hsw, in sst_hsw_stream_get_old_position() argument
1233 void sst_hsw_stream_set_old_position(struct sst_hsw *hsw, in sst_hsw_stream_set_old_position() argument
1239 bool sst_hsw_stream_get_silence_start(struct sst_hsw *hsw, in sst_hsw_stream_get_silence_start() argument
1245 void sst_hsw_stream_set_silence_start(struct sst_hsw *hsw, in sst_hsw_stream_set_silence_start() argument
1253 int sst_hsw_mixer_get_info(struct sst_hsw *hsw) in sst_hsw_mixer_get_info() argument
1259 reply = &hsw->mixer_info; in sst_hsw_mixer_get_info()
1264 ret = sst_ipc_tx_message_wait(&hsw->ipc, header, NULL, 0, in sst_hsw_mixer_get_info()
1267 dev_err(hsw->dev, "error: get stream info failed\n"); in sst_hsw_mixer_get_info()
1277 static int sst_hsw_stream_operations(struct sst_hsw *hsw, int type, in sst_hsw_stream_operations() argument
1286 return sst_ipc_tx_message_wait(&hsw->ipc, header, in sst_hsw_stream_operations()
1289 return sst_ipc_tx_message_nowait(&hsw->ipc, header, NULL, 0); in sst_hsw_stream_operations()
1293 int sst_hsw_stream_pause(struct sst_hsw *hsw, struct sst_hsw_stream *stream, in sst_hsw_stream_pause() argument
1299 dev_warn(hsw->dev, "warning: stream is NULL, no stream to pause, ignore it.\n"); in sst_hsw_stream_pause()
1305 ret = sst_hsw_stream_operations(hsw, IPC_STR_PAUSE, in sst_hsw_stream_pause()
1308 dev_err(hsw->dev, "error: failed to pause stream %d\n", in sst_hsw_stream_pause()
1314 int sst_hsw_stream_resume(struct sst_hsw *hsw, struct sst_hsw_stream *stream, in sst_hsw_stream_resume() argument
1320 dev_warn(hsw->dev, "warning: stream is NULL, no stream to resume, ignore it.\n"); in sst_hsw_stream_resume()
1326 ret = sst_hsw_stream_operations(hsw, IPC_STR_RESUME, in sst_hsw_stream_resume()
1329 dev_err(hsw->dev, "error: failed to resume stream %d\n", in sst_hsw_stream_resume()
1335 int sst_hsw_stream_reset(struct sst_hsw *hsw, struct sst_hsw_stream *stream) in sst_hsw_stream_reset() argument
1340 dev_warn(hsw->dev, "warning: stream is NULL, no stream to reset, ignore it.\n"); in sst_hsw_stream_reset()
1352 dev_err(hsw->dev, "error: reset stream %d still running\n", in sst_hsw_stream_reset()
1359 ret = sst_hsw_stream_operations(hsw, IPC_STR_RESET, in sst_hsw_stream_reset()
1362 dev_err(hsw->dev, "error: failed to reset stream %d\n", in sst_hsw_stream_reset()
1368 u32 sst_hsw_get_dsp_position(struct sst_hsw *hsw, in sst_hsw_get_dsp_position() argument
1373 sst_dsp_read(hsw->dsp, &rpos, in sst_hsw_get_dsp_position()
1380 u64 sst_hsw_get_dsp_presentation_position(struct sst_hsw *hsw, in sst_hsw_get_dsp_presentation_position() argument
1385 sst_dsp_read(hsw->dsp, &ppos, in sst_hsw_get_dsp_presentation_position()
1393 int sst_hsw_device_set_config(struct sst_hsw *hsw, in sst_hsw_device_set_config() argument
1416 ret = sst_ipc_tx_message_wait(&hsw->ipc, header, &config, in sst_hsw_device_set_config()
1419 dev_err(hsw->dev, "error: set device formats failed\n"); in sst_hsw_device_set_config()
1426 int sst_hsw_dx_set_state(struct sst_hsw *hsw, in sst_hsw_dx_set_state() argument
1437 ret = sst_ipc_tx_message_wait(&hsw->ipc, header, &state_, in sst_hsw_dx_set_state()
1440 dev_err(hsw->dev, "ipc: error set dx state %d failed\n", state); in sst_hsw_dx_set_state()
1445 dev_dbg(hsw->dev, in sst_hsw_dx_set_state()
1451 dev_dbg(hsw->dev, "ipc: got %d entry numbers for state %d\n", in sst_hsw_dx_set_state()
1457 struct sst_module_runtime *sst_hsw_runtime_module_create(struct sst_hsw *hsw, in sst_hsw_runtime_module_create() argument
1460 struct sst_dsp *dsp = hsw->dsp; in sst_hsw_runtime_module_create()
1499 static int sst_hsw_dx_state_dump(struct sst_hsw *hsw) in sst_hsw_dx_state_dump() argument
1501 struct sst_dsp *sst = hsw->dsp; in sst_hsw_dx_state_dump()
1507 if (hsw->dx.entries_no > SST_HSW_MAX_DX_REGIONS) { in sst_hsw_dx_state_dump()
1508 dev_err(hsw->dev, in sst_hsw_dx_state_dump()
1511 memset(&hsw->dx, 0, sizeof(hsw->dx)); in sst_hsw_dx_state_dump()
1517 dev_err(hsw->dev, "error: cant allocate dma channel %d\n", ret); in sst_hsw_dx_state_dump()
1526 for (item = 0; item < hsw->dx.entries_no; item++) { in sst_hsw_dx_state_dump()
1527 if (hsw->dx.mem_info[item].source == SST_HSW_DX_TYPE_MEMORY_DUMP in sst_hsw_dx_state_dump()
1528 && hsw->dx.mem_info[item].offset > DSP_DRAM_ADDR_OFFSET in sst_hsw_dx_state_dump()
1529 && hsw->dx.mem_info[item].offset < in sst_hsw_dx_state_dump()
1532 offset = hsw->dx.mem_info[item].offset in sst_hsw_dx_state_dump()
1534 size = (hsw->dx.mem_info[item].size + 3) & (~3); in sst_hsw_dx_state_dump()
1536 ret = sst_dsp_dma_copyfrom(sst, hsw->dx_context_paddr + offset, in sst_hsw_dx_state_dump()
1539 dev_err(hsw->dev, in sst_hsw_dx_state_dump()
1541 memset(&hsw->dx, 0, sizeof(hsw->dx)); in sst_hsw_dx_state_dump()
1552 static int sst_hsw_dx_state_restore(struct sst_hsw *hsw) in sst_hsw_dx_state_restore() argument
1554 struct sst_dsp *sst = hsw->dsp; in sst_hsw_dx_state_restore()
1558 for (item = 0; item < hsw->dx.entries_no; item++) { in sst_hsw_dx_state_restore()
1559 if (hsw->dx.mem_info[item].source == SST_HSW_DX_TYPE_MEMORY_DUMP in sst_hsw_dx_state_restore()
1560 && hsw->dx.mem_info[item].offset > DSP_DRAM_ADDR_OFFSET in sst_hsw_dx_state_restore()
1561 && hsw->dx.mem_info[item].offset < in sst_hsw_dx_state_restore()
1564 offset = hsw->dx.mem_info[item].offset in sst_hsw_dx_state_restore()
1566 size = (hsw->dx.mem_info[item].size + 3) & (~3); in sst_hsw_dx_state_restore()
1569 hsw->dx_context_paddr + offset, size); in sst_hsw_dx_state_restore()
1571 dev_err(hsw->dev, in sst_hsw_dx_state_restore()
1581 int sst_hsw_dsp_load(struct sst_hsw *hsw) in sst_hsw_dsp_load() argument
1583 struct sst_dsp *dsp = hsw->dsp; in sst_hsw_dsp_load()
1587 dev_dbg(hsw->dev, "loading audio DSP...."); in sst_hsw_dsp_load()
1591 dev_err(hsw->dev, "error: failed to wake audio DSP\n"); in sst_hsw_dsp_load()
1597 dev_err(hsw->dev, "error: cant allocate dma channel %d\n", ret); in sst_hsw_dsp_load()
1604 dev_err(hsw->dev, "error: SST FW reload failed\n"); in sst_hsw_dsp_load()
1609 ret = sst_block_alloc_scratch(hsw->dsp); in sst_hsw_dsp_load()
1617 static int sst_hsw_dsp_restore(struct sst_hsw *hsw) in sst_hsw_dsp_restore() argument
1619 struct sst_dsp *dsp = hsw->dsp; in sst_hsw_dsp_restore()
1622 dev_dbg(hsw->dev, "restoring audio DSP...."); in sst_hsw_dsp_restore()
1626 dev_err(hsw->dev, "error: cant allocate dma channel %d\n", ret); in sst_hsw_dsp_restore()
1630 ret = sst_hsw_dx_state_restore(hsw); in sst_hsw_dsp_restore()
1632 dev_err(hsw->dev, "error: SST FW context restore failed\n"); in sst_hsw_dsp_restore()
1644 int sst_hsw_dsp_runtime_suspend(struct sst_hsw *hsw) in sst_hsw_dsp_runtime_suspend() argument
1648 dev_dbg(hsw->dev, "audio dsp runtime suspend\n"); in sst_hsw_dsp_runtime_suspend()
1650 ret = sst_hsw_dx_set_state(hsw, SST_HSW_DX_STATE_D3, &hsw->dx); in sst_hsw_dsp_runtime_suspend()
1654 sst_dsp_stall(hsw->dsp); in sst_hsw_dsp_runtime_suspend()
1656 ret = sst_hsw_dx_state_dump(hsw); in sst_hsw_dsp_runtime_suspend()
1660 sst_ipc_drop_all(&hsw->ipc); in sst_hsw_dsp_runtime_suspend()
1665 int sst_hsw_dsp_runtime_sleep(struct sst_hsw *hsw) in sst_hsw_dsp_runtime_sleep() argument
1668 struct sst_dsp *dsp = hsw->dsp; in sst_hsw_dsp_runtime_sleep()
1675 hsw->boot_complete = false; in sst_hsw_dsp_runtime_sleep()
1682 int sst_hsw_dsp_runtime_resume(struct sst_hsw *hsw) in sst_hsw_dsp_runtime_resume() argument
1684 struct device *dev = hsw->dev; in sst_hsw_dsp_runtime_resume()
1689 if (hsw->boot_complete) in sst_hsw_dsp_runtime_resume()
1692 ret = sst_hsw_dsp_restore(hsw); in sst_hsw_dsp_runtime_resume()
1696 sst_hsw_init_module_state(hsw); in sst_hsw_dsp_runtime_resume()
1698 ret = wait_event_timeout(hsw->boot_wait, hsw->boot_complete, in sst_hsw_dsp_runtime_resume()
1701 dev_err(hsw->dev, "error: audio DSP boot timeout IPCD 0x%x IPCX 0x%x\n", in sst_hsw_dsp_runtime_resume()
1702 sst_dsp_shim_read_unlocked(hsw->dsp, SST_IPCD), in sst_hsw_dsp_runtime_resume()
1703 sst_dsp_shim_read_unlocked(hsw->dsp, SST_IPCX)); in sst_hsw_dsp_runtime_resume()
1708 ret = sst_hsw_device_set_config(hsw, SST_HSW_DEVICE_SSP_0, in sst_hsw_dsp_runtime_resume()
1718 struct sst_dsp *sst_hsw_get_dsp(struct sst_hsw *hsw) in sst_hsw_get_dsp() argument
1720 return hsw->dsp; in sst_hsw_get_dsp()
1723 void sst_hsw_init_module_state(struct sst_hsw *hsw) in sst_hsw_init_module_state() argument
1730 module = sst_module_get_from_id(hsw->dsp, id); in sst_hsw_init_module_state()
1741 bool sst_hsw_is_module_loaded(struct sst_hsw *hsw, u32 module_id) in sst_hsw_is_module_loaded() argument
1745 module = sst_module_get_from_id(hsw->dsp, module_id); in sst_hsw_is_module_loaded()
1752 bool sst_hsw_is_module_active(struct sst_hsw *hsw, u32 module_id) in sst_hsw_is_module_active() argument
1756 module = sst_module_get_from_id(hsw->dsp, module_id); in sst_hsw_is_module_active()
1763 void sst_hsw_set_module_enabled_rtd3(struct sst_hsw *hsw, u32 module_id) in sst_hsw_set_module_enabled_rtd3() argument
1765 hsw->enabled_modules_rtd3 |= (1 << module_id); in sst_hsw_set_module_enabled_rtd3()
1768 void sst_hsw_set_module_disabled_rtd3(struct sst_hsw *hsw, u32 module_id) in sst_hsw_set_module_disabled_rtd3() argument
1770 hsw->enabled_modules_rtd3 &= ~(1 << module_id); in sst_hsw_set_module_disabled_rtd3()
1773 bool sst_hsw_is_module_enabled_rtd3(struct sst_hsw *hsw, u32 module_id) in sst_hsw_is_module_enabled_rtd3() argument
1775 return hsw->enabled_modules_rtd3 & (1 << module_id); in sst_hsw_is_module_enabled_rtd3()
1778 void sst_hsw_reset_param_buf(struct sst_hsw *hsw) in sst_hsw_reset_param_buf() argument
1780 hsw->param_idx_w = 0; in sst_hsw_reset_param_buf()
1781 hsw->param_idx_r = 0; in sst_hsw_reset_param_buf()
1782 memset((void *)hsw->param_buf, 0, sizeof(hsw->param_buf)); in sst_hsw_reset_param_buf()
1785 int sst_hsw_store_param_line(struct sst_hsw *hsw, u8 *buf) in sst_hsw_store_param_line() argument
1788 if (hsw->param_idx_w > WAVES_PARAM_LINES - 1) { in sst_hsw_store_param_line()
1789 dev_warn(hsw->dev, "warning: param buffer overflow!\n"); in sst_hsw_store_param_line()
1792 memcpy(hsw->param_buf[hsw->param_idx_w], buf, WAVES_PARAM_COUNT); in sst_hsw_store_param_line()
1793 hsw->param_idx_w++; in sst_hsw_store_param_line()
1797 int sst_hsw_load_param_line(struct sst_hsw *hsw, u8 *buf) in sst_hsw_load_param_line() argument
1802 while (hsw->param_idx_r < WAVES_PARAM_LINES) { in sst_hsw_load_param_line()
1803 id = hsw->param_buf[hsw->param_idx_r][0]; in sst_hsw_load_param_line()
1804 hsw->param_idx_r++; in sst_hsw_load_param_line()
1806 memcpy(buf, hsw->param_buf[hsw->param_idx_r], in sst_hsw_load_param_line()
1811 if (hsw->param_idx_r > WAVES_PARAM_LINES - 1) { in sst_hsw_load_param_line()
1812 dev_dbg(hsw->dev, "end of buffer, roll to the beginning\n"); in sst_hsw_load_param_line()
1813 hsw->param_idx_r = 0; in sst_hsw_load_param_line()
1819 int sst_hsw_launch_param_buf(struct sst_hsw *hsw) in sst_hsw_launch_param_buf() argument
1823 if (!sst_hsw_is_module_active(hsw, SST_HSW_MODULE_WAVES)) { in sst_hsw_launch_param_buf()
1824 dev_dbg(hsw->dev, "module waves is not active\n"); in sst_hsw_launch_param_buf()
1829 for (idx = 0; idx < hsw->param_idx_w; idx++) { in sst_hsw_launch_param_buf()
1830 ret = sst_hsw_module_set_param(hsw, in sst_hsw_launch_param_buf()
1831 SST_HSW_MODULE_WAVES, 0, hsw->param_buf[idx][0], in sst_hsw_launch_param_buf()
1832 WAVES_PARAM_COUNT, hsw->param_buf[idx]); in sst_hsw_launch_param_buf()
1839 int sst_hsw_module_load(struct sst_hsw *hsw, in sst_hsw_module_load() argument
1846 struct device *dev = hsw->dev; in sst_hsw_module_load()
1847 struct sst_dsp *dsp = hsw->dsp; in sst_hsw_module_load()
1872 hsw_sst_fw = sst_fw_new(dsp, fw, hsw); in sst_hsw_module_load()
1894 int sst_hsw_module_enable(struct sst_hsw *hsw, in sst_hsw_module_enable() argument
1902 struct device *dev = hsw->dev; in sst_hsw_module_enable()
1903 struct sst_dsp *dsp = hsw->dsp; in sst_hsw_module_enable()
1905 if (!sst_hsw_is_module_loaded(hsw, module_id)) { in sst_hsw_module_enable()
1910 if (sst_hsw_is_module_active(hsw, module_id)) { in sst_hsw_module_enable()
1952 ret = sst_ipc_tx_message_wait(&hsw->ipc, header, in sst_hsw_module_enable()
1962 int sst_hsw_module_disable(struct sst_hsw *hsw, in sst_hsw_module_disable() argument
1968 struct device *dev = hsw->dev; in sst_hsw_module_disable()
1969 struct sst_dsp *dsp = hsw->dsp; in sst_hsw_module_disable()
1971 if (!sst_hsw_is_module_loaded(hsw, module_id)) { in sst_hsw_module_disable()
1976 if (!sst_hsw_is_module_active(hsw, module_id)) { in sst_hsw_module_disable()
1991 ret = sst_ipc_tx_message_wait(&hsw->ipc, header, NULL, 0, NULL, 0); in sst_hsw_module_disable()
2000 int sst_hsw_module_set_param(struct sst_hsw *hsw, in sst_hsw_module_set_param() argument
2010 struct device *dev = hsw->dev; in sst_hsw_module_set_param()
2045 ret = sst_ipc_tx_message_wait(&hsw->ipc, header, in sst_hsw_module_set_param()
2053 dma_free_coherent(hsw->dsp->dma_dev, in sst_hsw_module_set_param()
2104 struct sst_hsw *hsw; in sst_hsw_dsp_init() local
2110 hsw = devm_kzalloc(dev, sizeof(*hsw), GFP_KERNEL); in sst_hsw_dsp_init()
2111 if (hsw == NULL) in sst_hsw_dsp_init()
2114 ipc = &hsw->ipc; in sst_hsw_dsp_init()
2125 INIT_LIST_HEAD(&hsw->stream_list); in sst_hsw_dsp_init()
2126 init_waitqueue_head(&hsw->boot_wait); in sst_hsw_dsp_init()
2127 hsw_dev.thread_context = hsw; in sst_hsw_dsp_init()
2130 hsw->dsp = sst_dsp_new(dev, &hsw_dev, pdata); in sst_hsw_dsp_init()
2131 if (hsw->dsp == NULL) { in sst_hsw_dsp_init()
2136 ipc->dsp = hsw->dsp; in sst_hsw_dsp_init()
2139 hsw->dx_context = dma_alloc_coherent(hsw->dsp->dma_dev, in sst_hsw_dsp_init()
2140 SST_HSW_DX_CONTEXT_SIZE, &hsw->dx_context_paddr, GFP_KERNEL); in sst_hsw_dsp_init()
2141 if (hsw->dx_context == NULL) { in sst_hsw_dsp_init()
2147 sst_dsp_reset(hsw->dsp); in sst_hsw_dsp_init()
2150 ret = sst_hsw_module_load(hsw, SST_HSW_MODULE_BASE_FW, 0, "Base"); in sst_hsw_dsp_init()
2155 sst_hsw_module_load(hsw, SST_HSW_MODULE_WAVES, 0, "intel/IntcPP01.bin"); in sst_hsw_dsp_init()
2158 ret = sst_block_alloc_scratch(hsw->dsp); in sst_hsw_dsp_init()
2163 sst_hsw_reset_param_buf(hsw); in sst_hsw_dsp_init()
2166 sst_dsp_boot(hsw->dsp); in sst_hsw_dsp_init()
2167 ret = wait_event_timeout(hsw->boot_wait, hsw->boot_complete, in sst_hsw_dsp_init()
2171 dev_err(hsw->dev, "error: audio DSP boot timeout IPCD 0x%x IPCX 0x%x\n", in sst_hsw_dsp_init()
2172 sst_dsp_shim_read_unlocked(hsw->dsp, SST_IPCD), in sst_hsw_dsp_init()
2173 sst_dsp_shim_read_unlocked(hsw->dsp, SST_IPCX)); in sst_hsw_dsp_init()
2178 sst_hsw_init_module_state(hsw); in sst_hsw_dsp_init()
2181 sst_hsw_fw_get_version(hsw, &version); in sst_hsw_dsp_init()
2184 ret = sst_hsw_mixer_get_info(hsw); in sst_hsw_dsp_init()
2186 dev_err(hsw->dev, "error: failed to get stream info\n"); in sst_hsw_dsp_init()
2190 pdata->dsp = hsw; in sst_hsw_dsp_init()
2194 sst_dsp_reset(hsw->dsp); in sst_hsw_dsp_init()
2195 sst_fw_free_all(hsw->dsp); in sst_hsw_dsp_init()
2197 dma_free_coherent(hsw->dsp->dma_dev, SST_HSW_DX_CONTEXT_SIZE, in sst_hsw_dsp_init()
2198 hsw->dx_context, hsw->dx_context_paddr); in sst_hsw_dsp_init()
2200 sst_dsp_free(hsw->dsp); in sst_hsw_dsp_init()
2210 struct sst_hsw *hsw = pdata->dsp; in sst_hsw_dsp_free() local
2212 sst_dsp_reset(hsw->dsp); in sst_hsw_dsp_free()
2213 sst_fw_free_all(hsw->dsp); in sst_hsw_dsp_free()
2214 dma_free_coherent(hsw->dsp->dma_dev, SST_HSW_DX_CONTEXT_SIZE, in sst_hsw_dsp_free()
2215 hsw->dx_context, hsw->dx_context_paddr); in sst_hsw_dsp_free()
2216 sst_dsp_free(hsw->dsp); in sst_hsw_dsp_free()
2217 sst_ipc_fini(&hsw->ipc); in sst_hsw_dsp_free()