Lines Matching +full:drv +full:- +full:id
1 // SPDX-License-Identifier: GPL-2.0-only
3 * sst-atom-controls.c - Intel MID Platform driver DPCM ALSA controls for Mrfld
5 * Copyright (C) 2013-14 Intel Corp
20 #include "sst-mfld-platform.h"
21 #include "sst-atom-controls.h"
23 static int sst_fill_byte_control(struct sst_data *drv, in sst_fill_byte_control() argument
28 struct snd_sst_bytes_v2 *byte_data = drv->byte_stream; in sst_fill_byte_control()
30 byte_data->type = SST_CMD_BYTES_SET; in sst_fill_byte_control()
31 byte_data->ipc_msg = ipc_msg; in sst_fill_byte_control()
32 byte_data->block = block; in sst_fill_byte_control()
33 byte_data->task_id = task_id; in sst_fill_byte_control()
34 byte_data->pipe_id = pipe_id; in sst_fill_byte_control()
36 if (len > SST_MAX_BIN_BYTES - sizeof(*byte_data)) { in sst_fill_byte_control()
37 dev_err(&drv->pdev->dev, "command length too big (%u)", len); in sst_fill_byte_control()
38 return -EINVAL; in sst_fill_byte_control()
40 byte_data->len = len; in sst_fill_byte_control()
41 memcpy(byte_data->bytes, cmd_data, len); in sst_fill_byte_control()
47 static int sst_fill_and_send_cmd_unlocked(struct sst_data *drv, in sst_fill_and_send_cmd_unlocked() argument
53 WARN_ON(!mutex_is_locked(&drv->lock)); in sst_fill_and_send_cmd_unlocked()
55 ret = sst_fill_byte_control(drv, ipc_msg, in sst_fill_and_send_cmd_unlocked()
59 return sst->ops->send_byte_stream(sst->dev, drv->byte_stream); in sst_fill_and_send_cmd_unlocked()
63 * sst_fill_and_send_cmd - generate the IPC message and send it to the FW
64 * @drv: sst_data
72 static int sst_fill_and_send_cmd(struct sst_data *drv, in sst_fill_and_send_cmd() argument
78 mutex_lock(&drv->lock); in sst_fill_and_send_cmd()
79 ret = sst_fill_and_send_cmd_unlocked(drv, ipc_msg, block, in sst_fill_and_send_cmd()
81 mutex_unlock(&drv->lock); in sst_fill_and_send_cmd()
92 * e.g. slot 0 rx map = 00001100b -> data from slot 0 goes into codec_in1 L,R
103 * e.g. codec1_0 tx map = 00000101b -> data from codec_out1_0 goes into slot 0, 2
112 static int sst_send_slot_map(struct sst_data *drv) in sst_send_slot_map() argument
119 - sizeof(struct sst_dsp_header); in sst_send_slot_map()
129 return sst_fill_and_send_cmd_unlocked(drv, SST_IPC_IA_SET_PARAMS, in sst_send_slot_map()
137 struct sst_enum *e = (struct sst_enum *)kcontrol->private_value; in sst_slot_enum_info()
139 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; in sst_slot_enum_info()
140 uinfo->count = 1; in sst_slot_enum_info()
141 uinfo->value.enumerated.items = e->max; in sst_slot_enum_info()
143 if (uinfo->value.enumerated.item > e->max - 1) in sst_slot_enum_info()
144 uinfo->value.enumerated.item = e->max - 1; in sst_slot_enum_info()
145 strcpy(uinfo->value.enumerated.name, in sst_slot_enum_info()
146 e->texts[uinfo->value.enumerated.item]); in sst_slot_enum_info()
152 * sst_slot_get - get the status of the interleaver/deinterleaver control
162 struct sst_enum *e = (void *)kcontrol->private_value; in sst_slot_get()
164 struct sst_data *drv = snd_soc_component_get_drvdata(c); in sst_slot_get() local
165 unsigned int ctl_no = e->reg; in sst_slot_get()
166 unsigned int is_tx = e->tx; in sst_slot_get()
170 mutex_lock(&drv->lock); in sst_slot_get()
172 /* search which slot/channel has this bit set - there should be only one */ in sst_slot_get()
173 for (mux = e->max; mux > 0; mux--) in sst_slot_get()
174 if (map[mux - 1] & val) in sst_slot_get()
177 ucontrol->value.enumerated.item[0] = mux; in sst_slot_get()
178 mutex_unlock(&drv->lock); in sst_slot_get()
180 dev_dbg(c->dev, "%s - %s map = %#x\n", in sst_slot_get()
182 e->texts[mux], mux ? map[mux - 1] : -1); in sst_slot_get()
186 /* sst_check_and_send_slot_map - helper for checking power state and sending
191 static int sst_check_and_send_slot_map(struct sst_data *drv, struct snd_kcontrol *kcontrol) in sst_check_and_send_slot_map() argument
193 struct sst_enum *e = (void *)kcontrol->private_value; in sst_check_and_send_slot_map()
196 if (e->w && e->w->power) in sst_check_and_send_slot_map()
197 ret = sst_send_slot_map(drv); in sst_check_and_send_slot_map()
198 else if (!e->w) in sst_check_and_send_slot_map()
199 dev_err(&drv->pdev->dev, "Slot control: %s doesn't have DAPM widget!!!\n", in sst_check_and_send_slot_map()
200 kcontrol->id.name); in sst_check_and_send_slot_map()
205 * sst_slot_put - set the status of interleaver/deinterleaver control
208 * (de)interleaver controls are defined in opposite sense to be user-friendly
222 struct sst_data *drv = snd_soc_component_get_drvdata(c); in sst_slot_put() local
223 struct sst_enum *e = (void *)kcontrol->private_value; in sst_slot_put()
225 unsigned int ctl_no = e->reg; in sst_slot_put()
226 unsigned int is_tx = e->tx; in sst_slot_put()
234 mux = ucontrol->value.enumerated.item[0]; in sst_slot_put()
235 if (mux > e->max - 1) in sst_slot_put()
236 return -EINVAL; in sst_slot_put()
238 mutex_lock(&drv->lock); in sst_slot_put()
240 for (i = 0; i < e->max; i++) in sst_slot_put()
245 ret = sst_check_and_send_slot_map(drv, kcontrol); in sst_slot_put()
247 mutex_unlock(&drv->lock); in sst_slot_put()
252 slot_channel_no = mux - 1; in sst_slot_put()
255 dev_dbg(c->dev, "%s %s map = %#x\n", in sst_slot_put()
257 e->texts[mux], map[slot_channel_no]); in sst_slot_put()
259 ret = sst_check_and_send_slot_map(drv, kcontrol); in sst_slot_put()
261 mutex_unlock(&drv->lock); in sst_slot_put()
265 static int sst_send_algo_cmd(struct sst_data *drv, in sst_send_algo_cmd() argument
271 /*bc->max includes sizeof algos + length field*/ in sst_send_algo_cmd()
272 len = sizeof(cmd->dst) + sizeof(cmd->command_id) + bc->max; in sst_send_algo_cmd()
276 return -ENOMEM; in sst_send_algo_cmd()
278 SST_FILL_DESTINATION(2, cmd->dst, bc->pipe_id, bc->module_id); in sst_send_algo_cmd()
279 cmd->command_id = bc->cmd_id; in sst_send_algo_cmd()
280 memcpy(cmd->params, bc->params, bc->max); in sst_send_algo_cmd()
282 ret = sst_fill_and_send_cmd_unlocked(drv, SST_IPC_IA_SET_PARAMS, in sst_send_algo_cmd()
283 SST_FLAG_BLOCKED, bc->task_id, 0, cmd, len); in sst_send_algo_cmd()
289 * sst_find_and_send_pipe_algo - send all the algo parameters for a pipe
290 * @drv: sst_data
297 static int sst_find_and_send_pipe_algo(struct sst_data *drv, in sst_find_and_send_pipe_algo() argument
304 dev_dbg(&drv->pdev->dev, "Enter: widget=%s\n", pipe); in sst_find_and_send_pipe_algo()
306 list_for_each_entry(algo, &ids->algo_list, node) { in sst_find_and_send_pipe_algo()
307 bc = (void *)algo->kctl->private_value; in sst_find_and_send_pipe_algo()
309 dev_dbg(&drv->pdev->dev, "Found algo control name=%s pipe=%s\n", in sst_find_and_send_pipe_algo()
310 algo->kctl->id.name, pipe); in sst_find_and_send_pipe_algo()
311 ret = sst_send_algo_cmd(drv, bc); in sst_find_and_send_pipe_algo()
321 struct sst_algo_control *bc = (void *)kcontrol->private_value; in sst_algo_bytes_ctl_info()
323 uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES; in sst_algo_bytes_ctl_info()
324 uinfo->count = bc->max; in sst_algo_bytes_ctl_info()
332 struct sst_algo_control *bc = (void *)kcontrol->private_value; in sst_algo_control_get()
335 switch (bc->type) { in sst_algo_control_get()
337 memcpy(ucontrol->value.bytes.data, bc->params, bc->max); in sst_algo_control_get()
340 dev_err(component->dev, "Invalid Input- algo type:%d\n", in sst_algo_control_get()
341 bc->type); in sst_algo_control_get()
342 return -EINVAL; in sst_algo_control_get()
353 struct sst_data *drv = snd_soc_component_get_drvdata(cmpnt); in sst_algo_control_set() local
354 struct sst_algo_control *bc = (void *)kcontrol->private_value; in sst_algo_control_set()
356 dev_dbg(cmpnt->dev, "control_name=%s\n", kcontrol->id.name); in sst_algo_control_set()
357 mutex_lock(&drv->lock); in sst_algo_control_set()
358 switch (bc->type) { in sst_algo_control_set()
360 memcpy(bc->params, ucontrol->value.bytes.data, bc->max); in sst_algo_control_set()
363 mutex_unlock(&drv->lock); in sst_algo_control_set()
364 dev_err(cmpnt->dev, "Invalid Input- algo type:%d\n", in sst_algo_control_set()
365 bc->type); in sst_algo_control_set()
366 return -EINVAL; in sst_algo_control_set()
369 if (bc->w && bc->w->power) in sst_algo_control_set()
370 ret = sst_send_algo_cmd(drv, bc); in sst_algo_control_set()
371 mutex_unlock(&drv->lock); in sst_algo_control_set()
379 struct sst_gain_mixer_control *mc = (void *)kcontrol->private_value; in sst_gain_ctl_info()
381 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in sst_gain_ctl_info()
382 uinfo->count = mc->stereo ? 2 : 1; in sst_gain_ctl_info()
383 uinfo->value.integer.min = mc->min; in sst_gain_ctl_info()
384 uinfo->value.integer.max = mc->max; in sst_gain_ctl_info()
390 * sst_send_gain_cmd - send the gain algorithm IPC to the FW
391 * @drv: sst_data
403 * The user-set gain value is sent only if the user-controllable 'mute' control
404 * is OFF (indicated by gv->mute). Otherwise, the mute value (MIN value) is
407 static int sst_send_gain_cmd(struct sst_data *drv, struct sst_gain_value *gv, in sst_send_gain_cmd() argument
412 dev_dbg(&drv->pdev->dev, "Enter\n"); in sst_send_gain_cmd()
418 if (mute || gv->mute) { in sst_send_gain_cmd()
422 cmd.cell_gains[0].cell_gain_left = gv->l_gain; in sst_send_gain_cmd()
423 cmd.cell_gains[0].cell_gain_right = gv->r_gain; in sst_send_gain_cmd()
428 cmd.cell_gains[0].gain_time_constant = gv->ramp_duration; in sst_send_gain_cmd()
431 - sizeof(struct sst_dsp_header); in sst_send_gain_cmd()
434 return sst_fill_and_send_cmd_unlocked(drv, SST_IPC_IA_SET_PARAMS, in sst_send_gain_cmd()
443 struct sst_gain_mixer_control *mc = (void *)kcontrol->private_value; in sst_gain_get()
444 struct sst_gain_value *gv = mc->gain_val; in sst_gain_get()
446 switch (mc->type) { in sst_gain_get()
448 ucontrol->value.integer.value[0] = gv->l_gain; in sst_gain_get()
449 ucontrol->value.integer.value[1] = gv->r_gain; in sst_gain_get()
453 ucontrol->value.integer.value[0] = gv->mute ? 0 : 1; in sst_gain_get()
457 ucontrol->value.integer.value[0] = gv->ramp_duration; in sst_gain_get()
461 dev_err(component->dev, "Invalid Input- gain type:%d\n", in sst_gain_get()
462 mc->type); in sst_gain_get()
463 return -EINVAL; in sst_gain_get()
474 struct sst_data *drv = snd_soc_component_get_drvdata(cmpnt); in sst_gain_put() local
475 struct sst_gain_mixer_control *mc = (void *)kcontrol->private_value; in sst_gain_put()
476 struct sst_gain_value *gv = mc->gain_val; in sst_gain_put()
478 mutex_lock(&drv->lock); in sst_gain_put()
480 switch (mc->type) { in sst_gain_put()
482 gv->l_gain = ucontrol->value.integer.value[0]; in sst_gain_put()
483 gv->r_gain = ucontrol->value.integer.value[1]; in sst_gain_put()
484 dev_dbg(cmpnt->dev, "%s: Volume %d, %d\n", in sst_gain_put()
485 mc->pname, gv->l_gain, gv->r_gain); in sst_gain_put()
489 gv->mute = !ucontrol->value.integer.value[0]; in sst_gain_put()
490 dev_dbg(cmpnt->dev, "%s: Mute %d\n", mc->pname, gv->mute); in sst_gain_put()
494 gv->ramp_duration = ucontrol->value.integer.value[0]; in sst_gain_put()
495 dev_dbg(cmpnt->dev, "%s: Ramp Delay%d\n", in sst_gain_put()
496 mc->pname, gv->ramp_duration); in sst_gain_put()
500 mutex_unlock(&drv->lock); in sst_gain_put()
501 dev_err(cmpnt->dev, "Invalid Input- gain type:%d\n", in sst_gain_put()
502 mc->type); in sst_gain_put()
503 return -EINVAL; in sst_gain_put()
506 if (mc->w && mc->w->power) in sst_gain_put()
507 ret = sst_send_gain_cmd(drv, gv, mc->task_id, in sst_gain_put()
508 mc->pipe_id | mc->instance_id, mc->module_id, 0); in sst_gain_put()
509 mutex_unlock(&drv->lock); in sst_gain_put()
515 struct sst_data *drv, int mute);
520 struct snd_soc_component *c = snd_soc_dapm_to_component(w->dapm); in sst_send_pipe_module_params()
521 struct sst_data *drv = snd_soc_component_get_drvdata(c); in sst_send_pipe_module_params() local
522 struct sst_ids *ids = w->priv; in sst_send_pipe_module_params()
524 mutex_lock(&drv->lock); in sst_send_pipe_module_params()
525 sst_find_and_send_pipe_algo(drv, w->name, ids); in sst_send_pipe_module_params()
526 sst_set_pipe_gain(ids, drv, 0); in sst_send_pipe_module_params()
527 mutex_unlock(&drv->lock); in sst_send_pipe_module_params()
559 * fill_swm_input - fill in the SWM input ids given the register
562 * @reg: the register value is a bit-field inicated which mixer inputs are ON.
564 * Use the lookup table to get the input-id and fill it in the
573 dev_dbg(cmpnt->dev, "reg: %#x\n", reg); in fill_swm_input()
580 SST_FILL_DESTINATION(2, swm_input->input_id, in fill_swm_input()
584 dev_dbg(cmpnt->dev, "input id: %#x, nb_inputs: %d\n", in fill_swm_input()
588 dev_warn(cmpnt->dev, "SET_SWM cmd max inputs reached"); in fill_swm_input()
600 struct sst_data *drv, int mute) in sst_set_pipe_gain() argument
607 list_for_each_entry(gain, &ids->gain_list, node) { in sst_set_pipe_gain()
608 struct snd_kcontrol *kctl = gain->kctl; in sst_set_pipe_gain()
610 dev_dbg(&drv->pdev->dev, "control name=%s\n", kctl->id.name); in sst_set_pipe_gain()
611 mc = (void *)kctl->private_value; in sst_set_pipe_gain()
612 gv = mc->gain_val; in sst_set_pipe_gain()
614 ret = sst_send_gain_cmd(drv, gv, mc->task_id, in sst_set_pipe_gain()
615 mc->pipe_id | mc->instance_id, mc->module_id, mute); in sst_set_pipe_gain()
626 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in sst_swm_mixer_event()
627 struct sst_data *drv = snd_soc_component_get_drvdata(cmpnt); in sst_swm_mixer_event() local
628 struct sst_ids *ids = w->priv; in sst_swm_mixer_event()
634 dev_dbg(cmpnt->dev, "widget = %s\n", w->name); in sst_swm_mixer_event()
639 for (i = 0; i < w->num_kcontrols; i++) { in sst_swm_mixer_event()
640 if (dapm_kcontrol_get_value(w->kcontrols[i])) { in sst_swm_mixer_event()
641 mc = (struct soc_mixer_control *)(w->kcontrols[i])->private_value; in sst_swm_mixer_event()
642 val |= 1 << mc->shift; in sst_swm_mixer_event()
645 dev_dbg(cmpnt->dev, "val = %#x\n", val); in sst_swm_mixer_event()
653 if (w->power) in sst_swm_mixer_event()
674 ids->location_id, SST_DEFAULT_MODULE_ID); in sst_swm_mixer_event()
677 - sizeof(struct sst_dsp_header) in sst_swm_mixer_event()
680 return sst_fill_and_send_cmd(drv, SST_IPC_IA_CMD, SST_FLAG_BLOCKED, in sst_swm_mixer_event()
681 ids->task_id, 0, &cmd, in sst_swm_mixer_event()
685 /* SBA mixers - 16 inputs */
732 * sst_handle_vb_timer - Start/Stop the DSP scheduler
746 struct sst_data *drv = snd_soc_dai_get_drvdata(dai); in sst_handle_vb_timer() local
753 dev_dbg(dai->dev, "enable=%u, usage=%d\n", enable, timer_usage); in sst_handle_vb_timer()
759 ret = sst->ops->power(sst->dev, true); in sst_handle_vb_timer()
764 mutex_lock(&drv->lock); in sst_handle_vb_timer()
768 timer_usage--; in sst_handle_vb_timer()
776 ret = sst_fill_and_send_cmd_unlocked(drv, SST_IPC_IA_CMD, in sst_handle_vb_timer()
780 timer_usage--; in sst_handle_vb_timer()
784 mutex_unlock(&drv->lock); in sst_handle_vb_timer()
787 sst->ops->power(sst->dev, false); in sst_handle_vb_timer()
796 ctx->ssp_cmd.nb_slots = slots; in sst_fill_ssp_slot()
797 ctx->ssp_cmd.active_tx_slot_map = tx_mask; in sst_fill_ssp_slot()
798 ctx->ssp_cmd.active_rx_slot_map = rx_mask; in sst_fill_ssp_slot()
799 ctx->ssp_cmd.nb_bits_per_slots = slot_width; in sst_fill_ssp_slot()
810 dev_dbg(dai->dev, "Enter:%s, format=%x\n", __func__, format); in sst_get_frame_sync_polarity()
820 dev_err(dai->dev, "Invalid frame sync polarity %d\n", format); in sst_get_frame_sync_polarity()
823 return -EINVAL; in sst_get_frame_sync_polarity()
831 dev_dbg(dai->dev, "Enter:%s, format=%x\n", __func__, format); in sst_get_ssp_mode()
839 dev_err(dai->dev, "Invalid ssp protocol: %d\n", format); in sst_get_ssp_mode()
842 return -EINVAL; in sst_get_ssp_mode()
856 ctx->ssp_cmd.ssp_protocol = SSP_MODE_PCM; in sst_fill_ssp_config()
857 ctx->ssp_cmd.mode = sst_get_ssp_mode(dai, fmt) | (SSP_PCM_MODE_NETWORK << 1); in sst_fill_ssp_config()
858 ctx->ssp_cmd.start_delay = 0; in sst_fill_ssp_config()
859 ctx->ssp_cmd.data_polarity = 1; in sst_fill_ssp_config()
860 ctx->ssp_cmd.frame_sync_width = 1; in sst_fill_ssp_config()
864 ctx->ssp_cmd.ssp_protocol = SSP_MODE_PCM; in sst_fill_ssp_config()
865 ctx->ssp_cmd.mode = sst_get_ssp_mode(dai, fmt) | (SSP_PCM_MODE_NETWORK << 1); in sst_fill_ssp_config()
866 ctx->ssp_cmd.start_delay = 1; in sst_fill_ssp_config()
867 ctx->ssp_cmd.data_polarity = 1; in sst_fill_ssp_config()
868 ctx->ssp_cmd.frame_sync_width = 1; in sst_fill_ssp_config()
872 ctx->ssp_cmd.ssp_protocol = SSP_MODE_I2S; in sst_fill_ssp_config()
873 ctx->ssp_cmd.mode = sst_get_ssp_mode(dai, fmt) | (SSP_PCM_MODE_NORMAL << 1); in sst_fill_ssp_config()
874 ctx->ssp_cmd.start_delay = 1; in sst_fill_ssp_config()
875 ctx->ssp_cmd.data_polarity = 0; in sst_fill_ssp_config()
876 ctx->ssp_cmd.frame_sync_width = ctx->ssp_cmd.nb_bits_per_slots; in sst_fill_ssp_config()
880 ctx->ssp_cmd.ssp_protocol = SSP_MODE_I2S; in sst_fill_ssp_config()
881 ctx->ssp_cmd.mode = sst_get_ssp_mode(dai, fmt) | (SSP_PCM_MODE_NORMAL << 1); in sst_fill_ssp_config()
882 ctx->ssp_cmd.start_delay = 0; in sst_fill_ssp_config()
883 ctx->ssp_cmd.data_polarity = 0; in sst_fill_ssp_config()
884 ctx->ssp_cmd.frame_sync_width = ctx->ssp_cmd.nb_bits_per_slots; in sst_fill_ssp_config()
888 dev_dbg(dai->dev, "using default ssp configs\n"); in sst_fill_ssp_config()
895 ctx->ssp_cmd.frame_sync_polarity = fs_polarity; in sst_fill_ssp_config()
901 * sst_ssp_config - contains SSP configuration for media UC
927 ctx->ssp_cmd.selection = config->ssp_id; in sst_fill_ssp_defaults()
928 ctx->ssp_cmd.nb_bits_per_slots = config->bits_per_slot; in sst_fill_ssp_defaults()
929 ctx->ssp_cmd.nb_slots = config->slots; in sst_fill_ssp_defaults()
930 ctx->ssp_cmd.mode = config->ssp_mode | (config->pcm_mode << 1); in sst_fill_ssp_defaults()
931 ctx->ssp_cmd.duplex = config->duplex; in sst_fill_ssp_defaults()
932 ctx->ssp_cmd.active_tx_slot_map = config->active_slot_map; in sst_fill_ssp_defaults()
933 ctx->ssp_cmd.active_rx_slot_map = config->active_slot_map; in sst_fill_ssp_defaults()
934 ctx->ssp_cmd.frame_sync_frequency = config->fs_frequency; in sst_fill_ssp_defaults()
935 ctx->ssp_cmd.frame_sync_polarity = config->frame_sync_polarity; in sst_fill_ssp_defaults()
936 ctx->ssp_cmd.data_polarity = config->data_polarity; in sst_fill_ssp_defaults()
937 ctx->ssp_cmd.frame_sync_width = config->fs_width; in sst_fill_ssp_defaults()
938 ctx->ssp_cmd.ssp_protocol = config->ssp_protocol; in sst_fill_ssp_defaults()
939 ctx->ssp_cmd.start_delay = config->start_delay; in sst_fill_ssp_defaults()
940 ctx->ssp_cmd.reserved1 = ctx->ssp_cmd.reserved2 = 0xFF; in sst_fill_ssp_defaults()
943 int send_ssp_cmd(struct snd_soc_dai *dai, const char *id, bool enable) in send_ssp_cmd() argument
945 struct sst_data *drv = snd_soc_dai_get_drvdata(dai); in send_ssp_cmd() local
948 dev_dbg(dai->dev, "Enter: enable=%d port_name=%s\n", enable, id); in send_ssp_cmd()
950 if (strcmp(id, "ssp0-port") == 0) in send_ssp_cmd()
952 else if (strcmp(id, "ssp2-port") == 0) in send_ssp_cmd()
955 dev_dbg(dai->dev, "port %s is not supported\n", id); in send_ssp_cmd()
956 return -1; in send_ssp_cmd()
959 SST_FILL_DEFAULT_DESTINATION(drv->ssp_cmd.header.dst); in send_ssp_cmd()
960 drv->ssp_cmd.header.command_id = SBA_HW_SET_SSP; in send_ssp_cmd()
961 drv->ssp_cmd.header.length = sizeof(struct sst_cmd_sba_hw_set_ssp) in send_ssp_cmd()
962 - sizeof(struct sst_dsp_header); in send_ssp_cmd()
964 drv->ssp_cmd.selection = ssp_id; in send_ssp_cmd()
965 dev_dbg(dai->dev, "ssp_id: %u\n", ssp_id); in send_ssp_cmd()
968 drv->ssp_cmd.switch_state = SST_SWITCH_ON; in send_ssp_cmd()
970 drv->ssp_cmd.switch_state = SST_SWITCH_OFF; in send_ssp_cmd()
972 return sst_fill_and_send_cmd(drv, SST_IPC_IA_CMD, SST_FLAG_BLOCKED, in send_ssp_cmd()
973 SST_TASK_SBA, 0, &drv->ssp_cmd, in send_ssp_cmd()
974 sizeof(drv->ssp_cmd.header) + drv->ssp_cmd.header.length); in send_ssp_cmd()
981 struct snd_soc_component *c = snd_soc_dapm_to_component(w->dapm); in sst_set_be_modules()
982 struct sst_data *drv = snd_soc_component_get_drvdata(c); in sst_set_be_modules() local
984 dev_dbg(c->dev, "Enter: widget=%s\n", w->name); in sst_set_be_modules()
987 mutex_lock(&drv->lock); in sst_set_be_modules()
988 ret = sst_send_slot_map(drv); in sst_set_be_modules()
989 mutex_unlock(&drv->lock); in sst_set_be_modules()
1002 struct snd_soc_component *c = snd_soc_dapm_to_component(w->dapm); in sst_set_media_path()
1003 struct sst_data *drv = snd_soc_component_get_drvdata(c); in sst_set_media_path() local
1004 struct sst_ids *ids = w->priv; in sst_set_media_path()
1006 dev_dbg(c->dev, "widget=%s\n", w->name); in sst_set_media_path()
1007 dev_dbg(c->dev, "task=%u, location=%#x\n", in sst_set_media_path()
1008 ids->task_id, ids->location_id); in sst_set_media_path()
1016 ids->location_id, SST_DEFAULT_MODULE_ID); in sst_set_media_path()
1021 - sizeof(struct sst_dsp_header); in sst_set_media_path()
1023 ret = sst_fill_and_send_cmd(drv, SST_IPC_IA_CMD, SST_FLAG_BLOCKED, in sst_set_media_path()
1024 ids->task_id, 0, &cmd, in sst_set_media_path()
1039 struct snd_soc_component *c = snd_soc_dapm_to_component(w->dapm); in sst_set_media_loop()
1040 struct sst_data *drv = snd_soc_component_get_drvdata(c); in sst_set_media_loop() local
1041 struct sst_ids *ids = w->priv; in sst_set_media_loop()
1043 dev_dbg(c->dev, "Enter:widget=%s\n", w->name); in sst_set_media_loop()
1050 ids->location_id, SST_DEFAULT_MODULE_ID); in sst_set_media_loop()
1054 - sizeof(struct sst_dsp_header); in sst_set_media_loop()
1057 cmd.param.part.cfg.format = ids->format; /* stereo/Mono */ in sst_set_media_loop()
1059 cmd.map = 0; /* Algo sequence: Gain - DRP - FIR - IIR */ in sst_set_media_loop()
1061 ret = sst_fill_and_send_cmd(drv, SST_IPC_IA_CMD, SST_FLAG_BLOCKED, in sst_set_media_loop()
1295 bc->params = devm_kzalloc(dev, bc->max, GFP_KERNEL); in sst_algo_control_init()
1296 if (bc->params == NULL) in sst_algo_control_init()
1297 return -ENOMEM; in sst_algo_control_init()
1304 switch (w->id) { in is_sst_dapm_widget()
1318 * sst_send_pipe_gains - send gains for the front-end DAIs
1319 * @dai: front-end dai
1323 * The gains in the pipes connected to the front-ends are muted/unmuted
1325 * gains for the front-end pipes.
1329 struct sst_data *drv = snd_soc_dai_get_drvdata(dai); in sst_send_pipe_gains() local
1333 dev_dbg(dai->dev, "enter, dai-name=%s dir=%d\n", dai->name, stream); in sst_send_pipe_gains()
1334 dev_dbg(dai->dev, "Stream name=%s\n", w->name); in sst_send_pipe_gains()
1338 if (p->connected && !p->connected(w, p->sink)) in sst_send_pipe_gains()
1341 if (p->connect && p->sink->power && in sst_send_pipe_gains()
1342 is_sst_dapm_widget(p->sink)) { in sst_send_pipe_gains()
1343 struct sst_ids *ids = p->sink->priv; in sst_send_pipe_gains()
1345 dev_dbg(dai->dev, "send gains for widget=%s\n", in sst_send_pipe_gains()
1346 p->sink->name); in sst_send_pipe_gains()
1347 mutex_lock(&drv->lock); in sst_send_pipe_gains()
1348 sst_set_pipe_gain(ids, drv, mute); in sst_send_pipe_gains()
1349 mutex_unlock(&drv->lock); in sst_send_pipe_gains()
1354 if (p->connected && !p->connected(w, p->source)) in sst_send_pipe_gains()
1357 if (p->connect && p->source->power && in sst_send_pipe_gains()
1358 is_sst_dapm_widget(p->source)) { in sst_send_pipe_gains()
1359 struct sst_ids *ids = p->source->priv; in sst_send_pipe_gains()
1361 dev_dbg(dai->dev, "send gain for widget=%s\n", in sst_send_pipe_gains()
1362 p->source->name); in sst_send_pipe_gains()
1363 mutex_lock(&drv->lock); in sst_send_pipe_gains()
1364 sst_set_pipe_gain(ids, drv, mute); in sst_send_pipe_gains()
1365 mutex_unlock(&drv->lock); in sst_send_pipe_gains()
1373 * sst_fill_module_list - populate the list of modules/gains for a pipe
1391 struct snd_soc_component *c = snd_soc_dapm_to_component(w->dapm); in sst_fill_module_list()
1392 struct sst_ids *ids = w->priv; in sst_fill_module_list()
1395 module = devm_kzalloc(c->dev, sizeof(*module), GFP_KERNEL); in sst_fill_module_list()
1397 return -ENOMEM; in sst_fill_module_list()
1400 struct sst_gain_mixer_control *mc = (void *)kctl->private_value; in sst_fill_module_list()
1402 mc->w = w; in sst_fill_module_list()
1403 module->kctl = kctl; in sst_fill_module_list()
1404 list_add_tail(&module->node, &ids->gain_list); in sst_fill_module_list()
1406 struct sst_algo_control *bc = (void *)kctl->private_value; in sst_fill_module_list()
1408 bc->w = w; in sst_fill_module_list()
1409 module->kctl = kctl; in sst_fill_module_list()
1410 list_add_tail(&module->node, &ids->algo_list); in sst_fill_module_list()
1412 dev_err(c->dev, "invoked for unknown type %d module %s", in sst_fill_module_list()
1413 type, kctl->id.name); in sst_fill_module_list()
1414 ret = -EINVAL; in sst_fill_module_list()
1421 * sst_fill_widget_module_info - fill list of gains/algos for the pipe
1434 struct snd_card *card = component->card->snd_card; in sst_fill_widget_module_info()
1437 down_read(&card->controls_rwsem); in sst_fill_widget_module_info()
1439 list_for_each_entry(kctl, &card->controls, list) { in sst_fill_widget_module_info()
1440 idx = strchr(kctl->id.name, ' '); in sst_fill_widget_module_info()
1443 index = idx - (char*)kctl->id.name; in sst_fill_widget_module_info()
1444 if (strncmp(kctl->id.name, w->name, index)) in sst_fill_widget_module_info()
1447 if (strstr(kctl->id.name, "Volume")) in sst_fill_widget_module_info()
1450 else if (strstr(kctl->id.name, "params")) in sst_fill_widget_module_info()
1453 else if (strstr(kctl->id.name, "Switch") && in sst_fill_widget_module_info()
1454 strstr(kctl->id.name, "Gain")) { in sst_fill_widget_module_info()
1456 (void *)kctl->private_value; in sst_fill_widget_module_info()
1458 mc->w = w; in sst_fill_widget_module_info()
1460 } else if (strstr(kctl->id.name, "interleaver")) { in sst_fill_widget_module_info()
1461 struct sst_enum *e = (void *)kctl->private_value; in sst_fill_widget_module_info()
1463 e->w = w; in sst_fill_widget_module_info()
1465 } else if (strstr(kctl->id.name, "deinterleaver")) { in sst_fill_widget_module_info()
1466 struct sst_enum *e = (void *)kctl->private_value; in sst_fill_widget_module_info()
1468 e->w = w; in sst_fill_widget_module_info()
1472 up_read(&card->controls_rwsem); in sst_fill_widget_module_info()
1477 up_read(&card->controls_rwsem); in sst_fill_widget_module_info()
1482 * sst_fill_linked_widgets - fill the parent pointer for the linked widget
1490 unsigned int len = strlen(ids->parent_wname); in sst_fill_linked_widgets()
1492 list_for_each_entry(w, &component->card->widgets, list) { in sst_fill_linked_widgets()
1493 if (!strncmp(ids->parent_wname, w->name, len)) { in sst_fill_linked_widgets()
1494 ids->parent_w = w; in sst_fill_linked_widgets()
1501 * sst_map_modules_to_pipe - fill algo/gains list for all pipes
1509 list_for_each_entry(w, &component->card->widgets, list) { in sst_map_modules_to_pipe()
1510 if (is_sst_dapm_widget(w) && (w->priv)) { in sst_map_modules_to_pipe()
1511 struct sst_ids *ids = w->priv; in sst_map_modules_to_pipe()
1513 dev_dbg(component->dev, "widget type=%d name=%s\n", in sst_map_modules_to_pipe()
1514 w->id, w->name); in sst_map_modules_to_pipe()
1515 INIT_LIST_HEAD(&ids->algo_list); in sst_map_modules_to_pipe()
1516 INIT_LIST_HEAD(&ids->gain_list); in sst_map_modules_to_pipe()
1523 if (ids->parent_wname != NULL) in sst_map_modules_to_pipe()
1535 struct sst_data *drv = snd_soc_component_get_drvdata(component); in sst_dsp_init_v2_dpcm() local
1538 drv->byte_stream = devm_kzalloc(component->dev, in sst_dsp_init_v2_dpcm()
1540 if (!drv->byte_stream) in sst_dsp_init_v2_dpcm()
1541 return -ENOMEM; in sst_dsp_init_v2_dpcm()
1547 snd_soc_dapm_new_widgets(dapm->card); in sst_dsp_init_v2_dpcm()
1562 ret = sst_algo_control_init(component->dev); in sst_dsp_init_v2_dpcm()