Lines Matching +full:mic +full:- +full:pos

1 // SPDX-License-Identifier: GPL-2.0-only
81 type = cpu_dai->driver->id; in catpt_get_stream_template()
86 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) in catpt_get_stream_template()
90 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) in catpt_get_stream_template()
103 struct catpt_stream_runtime *pos, *result = NULL; in catpt_stream_find() local
105 spin_lock(&cdev->list_lock); in catpt_stream_find()
106 list_for_each_entry(pos, &cdev->stream_list, node) { in catpt_stream_find()
107 if (pos->info.stream_hw_id == stream_hw_id) { in catpt_stream_find()
108 result = pos; in catpt_stream_find()
113 spin_unlock(&cdev->list_lock); in catpt_stream_find()
120 u32 pos; in catpt_stream_read_position() local
122 memcpy_fromio(&pos, cdev->lpe_ba + stream->info.read_pos_regaddr, in catpt_stream_read_position()
123 sizeof(pos)); in catpt_stream_read_position()
124 return pos; in catpt_stream_read_position()
135 offset = stream->info.volume_regaddr[channel]; in catpt_stream_volume()
136 memcpy_fromio(&volume, cdev->lpe_ba + offset, sizeof(volume)); in catpt_stream_volume()
148 offset = info->volume_regaddr[channel]; in catpt_mixer_volume()
149 memcpy_fromio(&volume, cdev->lpe_ba + offset, sizeof(volume)); in catpt_mixer_volume()
156 struct snd_pcm_runtime *rtm = substream->runtime; in catpt_arrange_page_table()
160 pages = snd_sgbuf_aligned_pages(rtm->dma_bytes); in catpt_arrange_page_table()
169 page_table = (u32 *)(pgtbl->area + offset); in catpt_arrange_page_table()
264 struct catpt_dev *cdev = dev_get_drvdata(dai->dev); in catpt_dai_startup()
272 return -ENOMEM; in catpt_dai_startup()
274 ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, cdev->dev, PAGE_SIZE, in catpt_dai_startup()
275 &stream->pgtbl); in catpt_dai_startup()
279 res = catpt_request_region(&cdev->dram, template->persistent_size); in catpt_dai_startup()
281 ret = -EBUSY; in catpt_dai_startup()
285 catpt_dsp_update_srampge(cdev, &cdev->dram, cdev->spec->dram_mask); in catpt_dai_startup()
287 stream->template = template; in catpt_dai_startup()
288 stream->persistent = res; in catpt_dai_startup()
289 stream->substream = substream; in catpt_dai_startup()
290 INIT_LIST_HEAD(&stream->node); in catpt_dai_startup()
293 spin_lock(&cdev->list_lock); in catpt_dai_startup()
294 list_add_tail(&stream->node, &cdev->stream_list); in catpt_dai_startup()
295 spin_unlock(&cdev->list_lock); in catpt_dai_startup()
300 snd_dma_free_pages(&stream->pgtbl); in catpt_dai_startup()
310 struct catpt_dev *cdev = dev_get_drvdata(dai->dev); in catpt_dai_shutdown()
314 spin_lock(&cdev->list_lock); in catpt_dai_shutdown()
315 list_del(&stream->node); in catpt_dai_shutdown()
316 spin_unlock(&cdev->list_lock); in catpt_dai_shutdown()
318 release_resource(stream->persistent); in catpt_dai_shutdown()
319 kfree(stream->persistent); in catpt_dai_shutdown()
320 catpt_dsp_update_srampge(cdev, &cdev->dram, cdev->spec->dram_mask); in catpt_dai_shutdown()
322 snd_dma_free_pages(&stream->pgtbl); in catpt_dai_shutdown()
332 struct snd_soc_component *component = dai->component; in catpt_dai_apply_usettings()
333 struct snd_kcontrol *pos; in catpt_dai_apply_usettings() local
334 struct catpt_dev *cdev = dev_get_drvdata(dai->dev); in catpt_dai_apply_usettings()
337 u32 id = stream->info.stream_hw_id; in catpt_dai_apply_usettings()
348 name = "Mic Capture Volume"; in catpt_dai_apply_usettings()
357 list_for_each_entry(pos, &component->card->snd_card->controls, list) { in catpt_dai_apply_usettings()
358 if (pos->private_data == component && in catpt_dai_apply_usettings()
359 !strncmp(name, pos->id.name, sizeof(pos->id.name))) in catpt_dai_apply_usettings()
362 if (list_entry_is_head(pos, &component->card->snd_card->controls, list)) in catpt_dai_apply_usettings()
363 return -ENOENT; in catpt_dai_apply_usettings()
365 if (stream->template->type != CATPT_STRM_TYPE_LOOPBACK) in catpt_dai_apply_usettings()
366 return catpt_set_dspvol(cdev, id, (long *)pos->private_value); in catpt_dai_apply_usettings()
367 ret = catpt_ipc_mute_loopback(cdev, id, *(bool *)pos->private_value); in catpt_dai_apply_usettings()
377 struct snd_pcm_runtime *rtm = substream->runtime; in catpt_dai_hw_params()
382 struct catpt_dev *cdev = dev_get_drvdata(dai->dev); in catpt_dai_hw_params()
386 if (stream->allocated) in catpt_dai_hw_params()
399 catpt_arrange_page_table(substream, &stream->pgtbl); in catpt_dai_hw_params()
402 rinfo.page_table_addr = stream->pgtbl.addr; in catpt_dai_hw_params()
403 rinfo.num_pages = DIV_ROUND_UP(rtm->dma_bytes, PAGE_SIZE); in catpt_dai_hw_params()
404 rinfo.size = rtm->dma_bytes; in catpt_dai_hw_params()
408 ret = catpt_ipc_alloc_stream(cdev, stream->template->path_id, in catpt_dai_hw_params()
409 stream->template->type, in catpt_dai_hw_params()
411 stream->template->num_entries, in catpt_dai_hw_params()
412 stream->template->entries, in catpt_dai_hw_params()
413 stream->persistent, in catpt_dai_hw_params()
414 cdev->scratch, in catpt_dai_hw_params()
415 &stream->info); in catpt_dai_hw_params()
423 stream->allocated = true; in catpt_dai_hw_params()
431 struct catpt_dev *cdev = dev_get_drvdata(dai->dev); in catpt_dai_hw_free()
434 if (!stream->allocated) in catpt_dai_hw_free()
437 catpt_ipc_reset_stream(cdev, stream->info.stream_hw_id); in catpt_dai_hw_free()
438 catpt_ipc_free_stream(cdev, stream->info.stream_hw_id); in catpt_dai_hw_free()
440 stream->allocated = false; in catpt_dai_hw_free()
448 struct catpt_dev *cdev = dev_get_drvdata(dai->dev); in catpt_dai_prepare()
452 if (stream->prepared) in catpt_dai_prepare()
455 ret = catpt_ipc_reset_stream(cdev, stream->info.stream_hw_id); in catpt_dai_prepare()
459 ret = catpt_ipc_pause_stream(cdev, stream->info.stream_hw_id); in catpt_dai_prepare()
463 stream->prepared = true; in catpt_dai_prepare()
470 struct snd_pcm_runtime *runtime = substream->runtime; in catpt_dai_trigger()
472 struct catpt_dev *cdev = dev_get_drvdata(dai->dev); in catpt_dai_trigger()
473 snd_pcm_uframes_t pos; in catpt_dai_trigger() local
481 if (stream->template->type != CATPT_STRM_TYPE_RENDER) in catpt_dai_trigger()
484 pos = frames_to_bytes(runtime, runtime->start_threshold); in catpt_dai_trigger()
489 ret = catpt_ipc_set_write_pos(cdev, stream->info.stream_hw_id, in catpt_dai_trigger()
490 pos, false, false); in catpt_dai_trigger()
498 ret = catpt_ipc_resume_stream(cdev, stream->info.stream_hw_id); in catpt_dai_trigger()
504 stream->prepared = false; in catpt_dai_trigger()
508 ret = catpt_ipc_pause_stream(cdev, stream->info.stream_hw_id); in catpt_dai_trigger()
523 struct catpt_notify_position *pos) in catpt_stream_update_position() argument
525 struct snd_pcm_substream *substream = stream->substream; in catpt_stream_update_position()
526 struct snd_pcm_runtime *r = substream->runtime; in catpt_stream_update_position()
530 dsppos = bytes_to_frames(r, pos->stream_position); in catpt_stream_update_position()
532 if (!stream->prepared) in catpt_stream_update_position()
535 if (stream->template->type != CATPT_STRM_TYPE_RENDER) in catpt_stream_update_position()
538 if (dsppos >= r->buffer_size / 2) in catpt_stream_update_position()
539 newpos = r->buffer_size / 2; in catpt_stream_update_position()
546 ret = catpt_ipc_set_write_pos(cdev, stream->info.stream_hw_id, in catpt_stream_update_position()
550 dev_err(cdev->dev, "update position for stream %d failed: %d\n", in catpt_stream_update_position()
551 stream->info.stream_hw_id, ret); in catpt_stream_update_position()
558 /* 200 ms for 2 32-bit channels at 48kHz (native format) */
583 struct catpt_dev *cdev = dev_get_drvdata(component->dev); in catpt_component_pcm_construct()
585 snd_pcm_set_managed_buffer_all(rtm->pcm, SNDRV_DMA_TYPE_DEV_SG, in catpt_component_pcm_construct()
586 cdev->dev, in catpt_component_pcm_construct()
598 if (!rtm->dai_link->no_pcm) in catpt_component_open()
610 struct catpt_dev *cdev = dev_get_drvdata(component->dev); in catpt_component_pointer()
611 u32 pos; in catpt_component_pointer() local
613 if (rtm->dai_link->no_pcm) in catpt_component_pointer()
617 pos = catpt_stream_read_position(cdev, stream); in catpt_component_pointer()
619 return bytes_to_frames(substream->runtime, pos); in catpt_component_pointer()
636 struct catpt_dev *cdev = dev_get_drvdata(dai->dev); in catpt_dai_pcm_new()
639 devfmt.iface = dai->driver->id; in catpt_dai_pcm_new()
640 devfmt.channels = codec_dai->driver->capture.channels_max; in catpt_dai_pcm_new()
667 if (!memcmp(&cdev->devfmt[devfmt.iface], &devfmt, sizeof(devfmt))) in catpt_dai_pcm_new()
670 ret = pm_runtime_resume_and_get(cdev->dev); in catpt_dai_pcm_new()
671 if (ret < 0 && ret != -EACCES) in catpt_dai_pcm_new()
676 pm_runtime_mark_last_busy(cdev->dev); in catpt_dai_pcm_new()
677 pm_runtime_put_autosuspend(cdev->dev); in catpt_dai_pcm_new()
683 memcpy(&cdev->devfmt[devfmt.iface], &devfmt, sizeof(devfmt)); in catpt_dai_pcm_new()
769 .name = "ssp0-port",
782 .name = "ssp1-port",
803 return DSP_VOLUME_MAX >> (DSP_VOLUME_STEP_MAX - value); in ctlvol_to_dspvol()
848 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in catpt_volume_info()
849 uinfo->count = CATPT_CHANNELS_MAX; in catpt_volume_info()
850 uinfo->value.integer.min = 0; in catpt_volume_info()
851 uinfo->value.integer.max = DSP_VOLUME_STEP_MAX; in catpt_volume_info()
860 struct catpt_dev *cdev = dev_get_drvdata(component->dev); in catpt_mixer_volume_get()
865 ret = pm_runtime_resume_and_get(cdev->dev); in catpt_mixer_volume_get()
866 if (ret < 0 && ret != -EACCES) in catpt_mixer_volume_get()
870 dspvol = catpt_mixer_volume(cdev, &cdev->mixer, i); in catpt_mixer_volume_get()
871 ucontrol->value.integer.value[i] = dspvol_to_ctlvol(dspvol); in catpt_mixer_volume_get()
874 pm_runtime_mark_last_busy(cdev->dev); in catpt_mixer_volume_get()
875 pm_runtime_put_autosuspend(cdev->dev); in catpt_mixer_volume_get()
885 struct catpt_dev *cdev = dev_get_drvdata(component->dev); in catpt_mixer_volume_put()
888 ret = pm_runtime_resume_and_get(cdev->dev); in catpt_mixer_volume_put()
889 if (ret < 0 && ret != -EACCES) in catpt_mixer_volume_put()
892 ret = catpt_set_dspvol(cdev, cdev->mixer.mixer_hw_id, in catpt_mixer_volume_put()
893 ucontrol->value.integer.value); in catpt_mixer_volume_put()
895 pm_runtime_mark_last_busy(cdev->dev); in catpt_mixer_volume_put()
896 pm_runtime_put_autosuspend(cdev->dev); in catpt_mixer_volume_put()
908 struct catpt_dev *cdev = dev_get_drvdata(component->dev); in catpt_stream_volume_get()
909 long *ctlvol = (long *)kcontrol->private_value; in catpt_stream_volume_get()
917 ucontrol->value.integer.value[i] = ctlvol[i]; in catpt_stream_volume_get()
921 ret = pm_runtime_resume_and_get(cdev->dev); in catpt_stream_volume_get()
922 if (ret < 0 && ret != -EACCES) in catpt_stream_volume_get()
927 ucontrol->value.integer.value[i] = dspvol_to_ctlvol(dspvol); in catpt_stream_volume_get()
930 pm_runtime_mark_last_busy(cdev->dev); in catpt_stream_volume_get()
931 pm_runtime_put_autosuspend(cdev->dev); in catpt_stream_volume_get()
943 struct catpt_dev *cdev = dev_get_drvdata(component->dev); in catpt_stream_volume_put()
944 long *ctlvol = (long *)kcontrol->private_value; in catpt_stream_volume_put()
950 ctlvol[i] = ucontrol->value.integer.value[i]; in catpt_stream_volume_put()
954 ret = pm_runtime_resume_and_get(cdev->dev); in catpt_stream_volume_put()
955 if (ret < 0 && ret != -EACCES) in catpt_stream_volume_put()
958 ret = catpt_set_dspvol(cdev, stream->info.stream_hw_id, in catpt_stream_volume_put()
959 ucontrol->value.integer.value); in catpt_stream_volume_put()
961 pm_runtime_mark_last_busy(cdev->dev); in catpt_stream_volume_put()
962 pm_runtime_put_autosuspend(cdev->dev); in catpt_stream_volume_put()
968 ctlvol[i] = ucontrol->value.integer.value[i]; in catpt_stream_volume_put()
1011 ucontrol->value.integer.value[0] = *(bool *)kcontrol->private_value; in catpt_loopback_switch_get()
1021 struct catpt_dev *cdev = dev_get_drvdata(component->dev); in catpt_loopback_switch_put()
1025 mute = (bool)ucontrol->value.integer.value[0]; in catpt_loopback_switch_put()
1028 *(bool *)kcontrol->private_value = mute; in catpt_loopback_switch_put()
1032 ret = pm_runtime_resume_and_get(cdev->dev); in catpt_loopback_switch_put()
1033 if (ret < 0 && ret != -EACCES) in catpt_loopback_switch_put()
1036 ret = catpt_ipc_mute_loopback(cdev, stream->info.stream_hw_id, mute); in catpt_loopback_switch_put()
1038 pm_runtime_mark_last_busy(cdev->dev); in catpt_loopback_switch_put()
1039 pm_runtime_put_autosuspend(cdev->dev); in catpt_loopback_switch_put()
1044 *(bool *)kcontrol->private_value = mute; in catpt_loopback_switch_put()
1074 static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(catpt_volume_tlv, -9000, 300, 1);
1094 CATPT_VOLUME_CTL("Mic Capture Volume", capture),
1129 .name = "catpt-platform",
1155 template->persistent_size = 0; in catpt_arm_stream_templates()
1157 for (j = 0; j < template->num_entries; j++) { in catpt_arm_stream_templates()
1158 entry = &template->entries[j]; in catpt_arm_stream_templates()
1159 type = &cdev->modules[entry->module_id]; in catpt_arm_stream_templates()
1161 if (!type->loaded) in catpt_arm_stream_templates()
1162 return -ENOENT; in catpt_arm_stream_templates()
1164 entry->entry_point = type->entry_point; in catpt_arm_stream_templates()
1165 template->persistent_size += type->persistent_size; in catpt_arm_stream_templates()
1166 if (type->scratch_size > scratch_size) in catpt_arm_stream_templates()
1167 scratch_size = type->scratch_size; in catpt_arm_stream_templates()
1173 res = catpt_request_region(&cdev->dram, scratch_size); in catpt_arm_stream_templates()
1175 return -EBUSY; in catpt_arm_stream_templates()
1176 cdev->scratch = res; in catpt_arm_stream_templates()
1187 component = devm_kzalloc(cdev->dev, sizeof(*component), GFP_KERNEL); in catpt_register_plat_component()
1189 return -ENOMEM; in catpt_register_plat_component()
1192 cdev->dev); in catpt_register_plat_component()
1196 component->name = catpt_comp_driver.name; in catpt_register_plat_component()