diff options
Diffstat (limited to 'sound/soc/intel')
41 files changed, 1861 insertions, 464 deletions
diff --git a/sound/soc/intel/atom/sst-atom-controls.c b/sound/soc/intel/atom/sst-atom-controls.c index 0f3604b55942..3672d36b4b66 100644 --- a/sound/soc/intel/atom/sst-atom-controls.c +++ b/sound/soc/intel/atom/sst-atom-controls.c @@ -1414,11 +1414,11 @@ static int sst_fill_module_list(struct snd_kcontrol *kctl, * name. First part of control name contains the pipe name (widget name). */ static int sst_fill_widget_module_info(struct snd_soc_dapm_widget *w, - struct snd_soc_platform *platform) + struct snd_soc_component *component) { struct snd_kcontrol *kctl; int index, ret = 0; - struct snd_card *card = platform->component.card->snd_card; + struct snd_card *card = component->card->snd_card; char *idx; down_read(&card->controls_rwsem); @@ -1468,13 +1468,13 @@ static int sst_fill_widget_module_info(struct snd_soc_dapm_widget *w, /** * sst_fill_linked_widgets - fill the parent pointer for the linked widget */ -static void sst_fill_linked_widgets(struct snd_soc_platform *platform, +static void sst_fill_linked_widgets(struct snd_soc_component *component, struct sst_ids *ids) { struct snd_soc_dapm_widget *w; unsigned int len = strlen(ids->parent_wname); - list_for_each_entry(w, &platform->component.card->widgets, list) { + list_for_each_entry(w, &component->card->widgets, list) { if (!strncmp(ids->parent_wname, w->name, len)) { ids->parent_w = w; break; @@ -1485,41 +1485,41 @@ static void sst_fill_linked_widgets(struct snd_soc_platform *platform, /** * sst_map_modules_to_pipe - fill algo/gains list for all pipes */ -static int sst_map_modules_to_pipe(struct snd_soc_platform *platform) +static int sst_map_modules_to_pipe(struct snd_soc_component *component) { struct snd_soc_dapm_widget *w; int ret = 0; - list_for_each_entry(w, &platform->component.card->widgets, list) { + list_for_each_entry(w, &component->card->widgets, list) { if (is_sst_dapm_widget(w) && (w->priv)) { struct sst_ids *ids = w->priv; - dev_dbg(platform->dev, "widget type=%d name=%s\n", + dev_dbg(component->dev, "widget type=%d name=%s\n", w->id, w->name); INIT_LIST_HEAD(&ids->algo_list); INIT_LIST_HEAD(&ids->gain_list); - ret = sst_fill_widget_module_info(w, platform); + ret = sst_fill_widget_module_info(w, component); if (ret < 0) return ret; /* fill linked widgets */ if (ids->parent_wname != NULL) - sst_fill_linked_widgets(platform, ids); + sst_fill_linked_widgets(component, ids); } } return 0; } -int sst_dsp_init_v2_dpcm(struct snd_soc_platform *platform) +int sst_dsp_init_v2_dpcm(struct snd_soc_component *component) { int i, ret = 0; struct snd_soc_dapm_context *dapm = - snd_soc_component_get_dapm(&platform->component); - struct sst_data *drv = snd_soc_platform_get_drvdata(platform); + snd_soc_component_get_dapm(component); + struct sst_data *drv = snd_soc_component_get_drvdata(component); unsigned int gains = ARRAY_SIZE(sst_gain_controls)/3; - drv->byte_stream = devm_kzalloc(platform->dev, + drv->byte_stream = devm_kzalloc(component->dev, SST_MAX_BIN_BYTES, GFP_KERNEL); if (!drv->byte_stream) return -ENOMEM; @@ -1537,26 +1537,26 @@ int sst_dsp_init_v2_dpcm(struct snd_soc_platform *platform) sst_gains[i].ramp_duration = SST_GAIN_RAMP_DURATION_DEFAULT; } - ret = snd_soc_add_platform_controls(platform, sst_gain_controls, + ret = snd_soc_add_component_controls(component, sst_gain_controls, ARRAY_SIZE(sst_gain_controls)); if (ret) return ret; /* Initialize algo control params */ - ret = sst_algo_control_init(platform->dev); + ret = sst_algo_control_init(component->dev); if (ret) return ret; - ret = snd_soc_add_platform_controls(platform, sst_algo_controls, + ret = snd_soc_add_component_controls(component, sst_algo_controls, ARRAY_SIZE(sst_algo_controls)); if (ret) return ret; - ret = snd_soc_add_platform_controls(platform, sst_slot_controls, + ret = snd_soc_add_component_controls(component, sst_slot_controls, ARRAY_SIZE(sst_slot_controls)); if (ret) return ret; - ret = sst_map_modules_to_pipe(platform); + ret = sst_map_modules_to_pipe(component); return ret; } diff --git a/sound/soc/intel/atom/sst-mfld-platform-compress.c b/sound/soc/intel/atom/sst-mfld-platform-compress.c index 1dbcab5a6ff0..6a44b19423cf 100644 --- a/sound/soc/intel/atom/sst-mfld-platform-compress.c +++ b/sound/soc/intel/atom/sst-mfld-platform-compress.c @@ -107,8 +107,8 @@ static int sst_platform_compr_set_params(struct snd_compr_stream *cstream, struct snd_sst_params str_params; struct sst_compress_cb cb; struct snd_soc_pcm_runtime *rtd = cstream->private_data; - struct snd_soc_platform *platform = rtd->platform; - struct sst_data *ctx = snd_soc_platform_get_drvdata(platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_data *ctx = snd_soc_component_get_drvdata(component); stream = cstream->runtime->private_data; /* construct fw structure for this*/ diff --git a/sound/soc/intel/atom/sst-mfld-platform-pcm.c b/sound/soc/intel/atom/sst-mfld-platform-pcm.c index 43e7fdd19f29..6c36da560877 100644 --- a/sound/soc/intel/atom/sst-mfld-platform-pcm.c +++ b/sound/soc/intel/atom/sst-mfld-platform-pcm.c @@ -697,26 +697,22 @@ static int sst_pcm_new(struct snd_soc_pcm_runtime *rtd) return retval; } -static int sst_soc_probe(struct snd_soc_platform *platform) +static int sst_soc_probe(struct snd_soc_component *component) { - struct sst_data *drv = dev_get_drvdata(platform->dev); + struct sst_data *drv = dev_get_drvdata(component->dev); - drv->soc_card = platform->component.card; - return sst_dsp_init_v2_dpcm(platform); + drv->soc_card = component->card; + return sst_dsp_init_v2_dpcm(component); } -static const struct snd_soc_platform_driver sst_soc_platform_drv = { +static const struct snd_soc_component_driver sst_soc_platform_drv = { + .name = DRV_NAME, .probe = sst_soc_probe, .ops = &sst_platform_ops, .compr_ops = &sst_platform_compr_ops, .pcm_new = sst_pcm_new, }; -static const struct snd_soc_component_driver sst_component = { - .name = "sst", -}; - - static int sst_platform_probe(struct platform_device *pdev) { struct sst_data *drv; @@ -740,26 +736,16 @@ static int sst_platform_probe(struct platform_device *pdev) mutex_init(&drv->lock); dev_set_drvdata(&pdev->dev, drv); - ret = snd_soc_register_platform(&pdev->dev, &sst_soc_platform_drv); - if (ret) { - dev_err(&pdev->dev, "registering soc platform failed\n"); - return ret; - } - - ret = snd_soc_register_component(&pdev->dev, &sst_component, + ret = devm_snd_soc_register_component(&pdev->dev, &sst_soc_platform_drv, sst_platform_dai, ARRAY_SIZE(sst_platform_dai)); - if (ret) { + if (ret) dev_err(&pdev->dev, "registering cpu dais failed\n"); - snd_soc_unregister_platform(&pdev->dev); - } + return ret; } static int sst_platform_remove(struct platform_device *pdev) { - - snd_soc_unregister_component(&pdev->dev); - snd_soc_unregister_platform(&pdev->dev); dev_dbg(&pdev->dev, "sst_platform_remove success\n"); return 0; } diff --git a/sound/soc/intel/atom/sst-mfld-platform.h b/sound/soc/intel/atom/sst-mfld-platform.h index 31a58c25472c..5f729df57bb5 100644 --- a/sound/soc/intel/atom/sst-mfld-platform.h +++ b/sound/soc/intel/atom/sst-mfld-platform.h @@ -27,6 +27,8 @@ extern struct sst_device *sst; extern const struct snd_compr_ops sst_platform_compr_ops; +#define DRV_NAME "sst" + #define SST_MONO 1 #define SST_STEREO 2 #define SST_MAX_CAP 5 @@ -155,7 +157,7 @@ struct sst_device { struct sst_data; -int sst_dsp_init_v2_dpcm(struct snd_soc_platform *platform); +int sst_dsp_init_v2_dpcm(struct snd_soc_component *component); int sst_send_pipe_gains(struct snd_soc_dai *dai, int stream, int mute); int send_ssp_cmd(struct snd_soc_dai *dai, const char *id, bool enable); int sst_handle_vb_timer(struct snd_soc_dai *dai, bool enable); diff --git a/sound/soc/intel/atom/sst/sst.c b/sound/soc/intel/atom/sst/sst.c index 8afdff457579..0962bc9adc62 100644 --- a/sound/soc/intel/atom/sst/sst.c +++ b/sound/soc/intel/atom/sst/sst.c @@ -449,6 +449,13 @@ static int intel_sst_suspend(struct device *dev) dev_err(dev, "stream %d is running, can't suspend, abort\n", i); return -EBUSY; } + + if (ctx->pdata->streams_lost_on_suspend) { + stream->resume_status = stream->status; + stream->resume_prev = stream->prev; + if (stream->status != STREAM_UN_INIT) + sst_free_stream(ctx, i); + } } synchronize_irq(ctx->irq_num); flush_workqueue(ctx->post_msg_wq); @@ -509,8 +516,8 @@ static int intel_sst_resume(struct device *dev) { struct intel_sst_drv *ctx = dev_get_drvdata(dev); struct sst_fw_save *fw_save = ctx->fw_save; - int ret = 0; struct sst_block *block; + int i, ret = 0; if (!fw_save) return 0; @@ -550,6 +557,21 @@ static int intel_sst_resume(struct device *dev) sst_set_fw_state_locked(ctx, SST_FW_RUNNING); } + if (ctx->pdata->streams_lost_on_suspend) { + for (i = 1; i <= ctx->info.max_streams; i++) { + struct stream_info *stream = &ctx->streams[i]; + + if (stream->resume_status != STREAM_UN_INIT) { + dev_dbg(ctx->dev, "Re-allocing stream %d status %d prev %d\n", + i, stream->resume_status, + stream->resume_prev); + sst_realloc_stream(ctx, i); + stream->status = stream->resume_status; + stream->prev = stream->resume_prev; + } + } + } + sst_free_block(ctx, block); return ret; } diff --git a/sound/soc/intel/atom/sst/sst.h b/sound/soc/intel/atom/sst/sst.h index e02e2b4cc08f..b2a705dc9304 100644 --- a/sound/soc/intel/atom/sst/sst.h +++ b/sound/soc/intel/atom/sst/sst.h @@ -65,9 +65,7 @@ enum sst_stream_states { STREAM_UN_INIT = 0, /* Freed/Not used stream */ STREAM_RUNNING = 1, /* Running */ STREAM_PAUSED = 2, /* Paused stream */ - STREAM_DECODE = 3, /* stream is in decoding only state */ - STREAM_INIT = 4, /* stream init, waiting for data */ - STREAM_RESET = 5, /* force reset on recovery */ + STREAM_INIT = 3, /* stream init, waiting for data */ }; enum sst_ram_type { @@ -181,22 +179,22 @@ struct sst_block { * * @status : stream current state * @prev : stream prev state - * @ops : stream operation pb/cp/drm... - * @bufs: stream buffer list + * @resume_status : stream current state to restore on resume + * @resume_prev : stream prev state to restore on resume * @lock : stream mutex for protecting state + * @alloc_param : parameters used for stream (re-)allocation * @pcm_substream : PCM substream * @period_elapsed : PCM period elapsed callback * @sfreq : stream sampling freq - * @str_type : stream type * @cumm_bytes : cummulative bytes decoded - * @str_type : stream type - * @src : stream source */ struct stream_info { unsigned int status; unsigned int prev; - unsigned int ops; + unsigned int resume_status; + unsigned int resume_prev; struct mutex lock; + struct snd_sst_alloc_mrfld alloc_param; void *pcm_substream; void (*period_elapsed)(void *pcm_substream); @@ -212,7 +210,6 @@ struct stream_info { unsigned int num_ch; unsigned int pipe_id; - unsigned int str_id; unsigned int task_id; }; @@ -438,6 +435,7 @@ struct intel_sst_ops { void (*post_download)(struct intel_sst_drv *sst); }; +int sst_realloc_stream(struct intel_sst_drv *sst_drv_ctx, int str_id); int sst_pause_stream(struct intel_sst_drv *sst_drv_ctx, int id); int sst_resume_stream(struct intel_sst_drv *sst_drv_ctx, int id); int sst_drop_stream(struct intel_sst_drv *sst_drv_ctx, int id); @@ -501,8 +499,6 @@ int sst_prepare_and_post_msg(struct intel_sst_drv *sst, void sst_process_pending_msg(struct work_struct *work); int sst_assign_pvt_id(struct intel_sst_drv *sst_drv_ctx); -void sst_init_stream(struct stream_info *stream, - int codec, int sst_id, int ops, u8 slot); int sst_validate_strid(struct intel_sst_drv *sst_drv_ctx, int str_id); struct stream_info *get_stream_info(struct intel_sst_drv *sst_drv_ctx, int str_id); diff --git a/sound/soc/intel/atom/sst/sst_acpi.c b/sound/soc/intel/atom/sst/sst_acpi.c index 6cd481bec275..c90b04cc071d 100644 --- a/sound/soc/intel/atom/sst/sst_acpi.c +++ b/sound/soc/intel/atom/sst/sst_acpi.c @@ -143,10 +143,11 @@ static struct sst_platform_info byt_rvp_platform_data = { .lib_info = &byt_lib_dnld_info, .res_info = &byt_rvp_res_info, .platform = "sst-mfld-platform", + .streams_lost_on_suspend = true, }; /* Cherryview (Cherrytrail and Braswell) uses same mrfld dpcm fw as Baytrail, - * so pdata is same as Baytrail. + * so pdata is same as Baytrail, minus the streams_lost_on_suspend quirk. */ static struct sst_platform_info chv_platform_data = { .probe_data = &byt_fwparse_info, diff --git a/sound/soc/intel/atom/sst/sst_drv_interface.c b/sound/soc/intel/atom/sst/sst_drv_interface.c index 71af5449be90..6a8b253c58d2 100644 --- a/sound/soc/intel/atom/sst/sst_drv_interface.c +++ b/sound/soc/intel/atom/sst/sst_drv_interface.c @@ -238,16 +238,7 @@ static int sst_cdev_close(struct device *dev, unsigned int str_id) return -EINVAL; } - if (stream->status == STREAM_RESET) { - dev_dbg(dev, "stream in reset state...\n"); - stream->status = STREAM_UN_INIT; - - retval = 0; - goto put; - } - retval = sst_free_stream(ctx, str_id); -put: stream->compr_cb_param = NULL; stream->compr_cb = NULL; @@ -256,7 +247,6 @@ put: dev_dbg(dev, "End\n"); return retval; - } static int sst_cdev_ack(struct device *dev, unsigned int str_id, @@ -486,16 +476,7 @@ static int sst_close_pcm_stream(struct device *dev, unsigned int str_id) return -EINVAL; } - if (stream->status == STREAM_RESET) { - /* silently fail here as we have cleaned the stream earlier */ - dev_dbg(ctx->dev, "stream in reset state...\n"); - - retval = 0; - goto put; - } - retval = free_stream_context(ctx, str_id); -put: stream->pcm_substream = NULL; stream->status = STREAM_UN_INIT; stream->period_elapsed = NULL; diff --git a/sound/soc/intel/atom/sst/sst_pvt.c b/sound/soc/intel/atom/sst/sst_pvt.c index b1e6b8f34a6a..af93244b4868 100644 --- a/sound/soc/intel/atom/sst/sst_pvt.c +++ b/sound/soc/intel/atom/sst/sst_pvt.c @@ -360,14 +360,6 @@ int sst_assign_pvt_id(struct intel_sst_drv *drv) return local; } -void sst_init_stream(struct stream_info *stream, - int codec, int sst_id, int ops, u8 slot) -{ - stream->status = STREAM_INIT; - stream->prev = STREAM_UN_INIT; - stream->ops = ops; -} - int sst_validate_strid( struct intel_sst_drv *sst_drv_ctx, int str_id) { diff --git a/sound/soc/intel/atom/sst/sst_stream.c b/sound/soc/intel/atom/sst/sst_stream.c index 7ee6aeb7e0af..107271f7dd63 100644 --- a/sound/soc/intel/atom/sst/sst_stream.c +++ b/sound/soc/intel/atom/sst/sst_stream.c @@ -35,29 +35,31 @@ int sst_alloc_stream_mrfld(struct intel_sst_drv *sst_drv_ctx, void *params) { - struct snd_sst_alloc_mrfld alloc_param; + struct snd_pcm_params *pcm_params; struct snd_sst_params *str_params; struct snd_sst_tstamp fw_tstamp; struct stream_info *str_info; - struct snd_sst_alloc_response *response; - unsigned int str_id, pipe_id, task_id; - int i, num_ch, ret = 0; - void *data = NULL; + int i, num_ch, str_id; dev_dbg(sst_drv_ctx->dev, "Enter\n"); str_params = (struct snd_sst_params *)params; - memset(&alloc_param, 0, sizeof(alloc_param)); - alloc_param.operation = str_params->ops; - alloc_param.codec_type = str_params->codec; - alloc_param.sg_count = str_params->aparams.sg_count; - alloc_param.ring_buf_info[0].addr = + str_id = str_params->stream_id; + str_info = get_stream_info(sst_drv_ctx, str_id); + if (!str_info) + return -EINVAL; + + memset(&str_info->alloc_param, 0, sizeof(str_info->alloc_param)); + str_info->alloc_param.operation = str_params->ops; + str_info->alloc_param.codec_type = str_params->codec; + str_info->alloc_param.sg_count = str_params->aparams.sg_count; + str_info->alloc_param.ring_buf_info[0].addr = str_params->aparams.ring_buf_info[0].addr; - alloc_param.ring_buf_info[0].size = + str_info->alloc_param.ring_buf_info[0].size = str_params->aparams.ring_buf_info[0].size; - alloc_param.frag_size = str_params->aparams.frag_size; + str_info->alloc_param.frag_size = str_params->aparams.frag_size; - memcpy(&alloc_param.codec_params, &str_params->sparams, + memcpy(&str_info->alloc_param.codec_params, &str_params->sparams, sizeof(struct snd_sst_stream_params)); /* @@ -67,47 +69,62 @@ int sst_alloc_stream_mrfld(struct intel_sst_drv *sst_drv_ctx, void *params) * Currently hardcoding as per FW reqm. */ num_ch = sst_get_num_channel(str_params); + pcm_params = &str_info->alloc_param.codec_params.uc.pcm_params; for (i = 0; i < 8; i++) { if (i < num_ch) - alloc_param.codec_params.uc.pcm_params.channel_map[i] = i; + pcm_params->channel_map[i] = i; else - alloc_param.codec_params.uc.pcm_params.channel_map[i] = 0xFF; + pcm_params->channel_map[i] = 0xff; } - str_id = str_params->stream_id; - str_info = get_stream_info(sst_drv_ctx, str_id); - if (str_info == NULL) { - dev_err(sst_drv_ctx->dev, "get stream info returned null\n"); - return -EINVAL; - } - - pipe_id = str_params->device_type; - task_id = str_params->task; - sst_drv_ctx->streams[str_id].pipe_id = pipe_id; - sst_drv_ctx->streams[str_id].task_id = task_id; + sst_drv_ctx->streams[str_id].status = STREAM_INIT; + sst_drv_ctx->streams[str_id].prev = STREAM_UN_INIT; + sst_drv_ctx->streams[str_id].pipe_id = str_params->device_type; + sst_drv_ctx->streams[str_id].task_id = str_params->task; sst_drv_ctx->streams[str_id].num_ch = num_ch; if (sst_drv_ctx->info.lpe_viewpt_rqd) - alloc_param.ts = sst_drv_ctx->info.mailbox_start + + str_info->alloc_param.ts = sst_drv_ctx->info.mailbox_start + sst_drv_ctx->tstamp + (str_id * sizeof(fw_tstamp)); else - alloc_param.ts = sst_drv_ctx->mailbox_add + + str_info->alloc_param.ts = sst_drv_ctx->mailbox_add + sst_drv_ctx->tstamp + (str_id * sizeof(fw_tstamp)); dev_dbg(sst_drv_ctx->dev, "alloc tstamp location = 0x%x\n", - alloc_param.ts); + str_info->alloc_param.ts); dev_dbg(sst_drv_ctx->dev, "assigned pipe id 0x%x to task %d\n", - pipe_id, task_id); + str_info->pipe_id, str_info->task_id); + + return sst_realloc_stream(sst_drv_ctx, str_id); +} + +/** + * sst_realloc_stream - Send msg for (re-)allocating a stream using the + * @sst_drv_ctx intel_sst_drv context pointer + * @str_id: stream ID + * + * Send a msg for (re-)allocating a stream using the parameters previously + * passed to sst_alloc_stream_mrfld() for the same stream ID. + * Return: 0 or negative errno value. + */ +int sst_realloc_stream(struct intel_sst_drv *sst_drv_ctx, int str_id) +{ + struct snd_sst_alloc_response *response; + struct stream_info *str_info; + void *data = NULL; + int ret; - /* allocate device type context */ - sst_init_stream(&sst_drv_ctx->streams[str_id], alloc_param.codec_type, - str_id, alloc_param.operation, 0); + str_info = get_stream_info(sst_drv_ctx, str_id); + if (!str_info) + return -EINVAL; dev_dbg(sst_drv_ctx->dev, "Alloc for str %d pipe %#x\n", - str_id, pipe_id); - ret = sst_prepare_and_post_msg(sst_drv_ctx, task_id, IPC_CMD, - IPC_IA_ALLOC_STREAM_MRFLD, pipe_id, sizeof(alloc_param), - &alloc_param, &data, true, true, false, true); + str_id, str_info->pipe_id); + + ret = sst_prepare_and_post_msg(sst_drv_ctx, str_info->task_id, IPC_CMD, + IPC_IA_ALLOC_STREAM_MRFLD, str_info->pipe_id, + sizeof(str_info->alloc_param), &str_info->alloc_param, + &data, true, true, false, true); if (ret < 0) { dev_err(sst_drv_ctx->dev, "FW alloc failed ret %d\n", ret); @@ -253,7 +270,7 @@ int sst_pause_stream(struct intel_sst_drv *sst_drv_ctx, int str_id) if (retval == 0) { str_info->prev = str_info->status; str_info->status = STREAM_PAUSED; - } else if (retval == SST_ERR_INVALID_STREAM_ID) { + } else if (retval == -SST_ERR_INVALID_STREAM_ID) { retval = -EINVAL; mutex_lock(&sst_drv_ctx->sst_lock); sst_clean_stream(str_info); @@ -285,7 +302,29 @@ int sst_resume_stream(struct intel_sst_drv *sst_drv_ctx, int str_id) return -EINVAL; if (str_info->status == STREAM_RUNNING) return 0; - if (str_info->status == STREAM_PAUSED) { + + if (str_info->resume_status == STREAM_PAUSED && + str_info->resume_prev == STREAM_RUNNING) { + /* + * Stream was running before suspend and re-created on resume, + * start it to get back to running state. + */ + dev_dbg(sst_drv_ctx->dev, "restart recreated stream after resume\n"); + str_info->status = STREAM_RUNNING; + str_info->prev = STREAM_PAUSED; + retval = sst_start_stream(sst_drv_ctx, str_id); + str_info->resume_status = STREAM_UN_INIT; + } else if (str_info->resume_status == STREAM_PAUSED && + str_info->resume_prev == STREAM_INIT) { + /* + * Stream was idle before suspend and re-created on resume, + * keep it as is. + */ + dev_dbg(sst_drv_ctx->dev, "leaving recreated stream idle after resume\n"); + str_info->status = STREAM_INIT; + str_info->prev = STREAM_PAUSED; + str_info->resume_status = STREAM_UN_INIT; + } else if (str_info->status == STREAM_PAUSED) { retval = sst_prepare_and_post_msg(sst_drv_ctx, str_info->task_id, IPC_CMD, IPC_IA_RESUME_STREAM_MRFLD, str_info->pipe_id, 0, NULL, NULL, diff --git a/sound/soc/intel/baytrail/sst-baytrail-pcm.c b/sound/soc/intel/baytrail/sst-baytrail-pcm.c index c54529320f07..aabb35bf6b96 100644 --- a/sound/soc/intel/baytrail/sst-baytrail-pcm.c +++ b/sound/soc/intel/baytrail/sst-baytrail-pcm.c @@ -23,6 +23,7 @@ #include "../common/sst-dsp-priv.h" #include "../common/sst-dsp.h" +#define DRV_NAME "byt-dai" #define BYT_PCM_COUNT 2 static const struct snd_pcm_hardware sst_byt_pcm_hardware = { @@ -69,8 +70,8 @@ static int sst_byt_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct sst_byt_priv_data *pdata = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_byt_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_byt_pcm_data *pcm_data = &pdata->pcm[substream->stream]; struct sst_byt *byt = pdata->byt; u32 rate, bits; @@ -141,8 +142,8 @@ static int sst_byt_pcm_hw_free(struct snd_pcm_substream *substream) static int sst_byt_pcm_restore_stream_context(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct sst_byt_priv_data *pdata = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_byt_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_byt_pcm_data *pcm_data = &pdata->pcm[substream->stream]; struct sst_byt *byt = pdata->byt; int ret; @@ -174,8 +175,8 @@ static void sst_byt_pcm_work(struct work_struct *work) static int sst_byt_pcm_trigger(struct snd_pcm_substream *substream, int cmd) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct sst_byt_priv_data *pdata = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_byt_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_byt_pcm_data *pcm_data = &pdata->pcm[substream->stream]; struct sst_byt *byt = pdata->byt; @@ -216,8 +217,8 @@ static u32 byt_notify_pointer(struct sst_byt_stream *stream, void *data) struct snd_pcm_substream *substream = pcm_data->substream; struct snd_pcm_runtime *runtime = substream->runtime; struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct sst_byt_priv_data *pdata = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_byt_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_byt *byt = pdata->byt; u32 pos, hw_pos; @@ -238,8 +239,8 @@ static snd_pcm_uframes_t sst_byt_pcm_pointer(struct snd_pcm_substream *substream { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_pcm_runtime *runtime = substream->runtime; - struct sst_byt_priv_data *pdata = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_byt_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_byt_pcm_data *pcm_data = &pdata->pcm[substream->stream]; dev_dbg(rtd->dev, "PCM: DMA pointer %u bytes\n", pcm_data->hw_ptr); @@ -250,8 +251,8 @@ static snd_pcm_uframes_t sst_byt_pcm_pointer(struct snd_pcm_substream *substream static int sst_byt_pcm_open(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct sst_byt_priv_data *pdata = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_byt_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_byt_pcm_data *pcm_data = &pdata->pcm[substream->stream]; struct sst_byt *byt = pdata->byt; @@ -278,8 +279,8 @@ static int sst_byt_pcm_open(struct snd_pcm_substream *substream) static int sst_byt_pcm_close(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct sst_byt_priv_data *pdata = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_byt_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_byt_pcm_data *pcm_data = &pdata->pcm[substream->stream]; struct sst_byt *byt = pdata->byt; int ret; @@ -324,8 +325,8 @@ static int sst_byt_pcm_new(struct snd_soc_pcm_runtime *rtd) { struct snd_pcm *pcm = rtd->pcm; size_t size; - struct snd_soc_platform *platform = rtd->platform; - struct sst_pdata *pdata = dev_get_platdata(platform->dev); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_pdata *pdata = dev_get_platdata(component->dev); int ret = 0; if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream || @@ -366,21 +367,21 @@ static struct snd_soc_dai_driver byt_dais[] = { }, }; -static int sst_byt_pcm_probe(struct snd_soc_platform *platform) +static int sst_byt_pcm_probe(struct snd_soc_component *component) { - struct sst_pdata *plat_data = dev_get_platdata(platform->dev); + struct sst_pdata *plat_data = dev_get_platdata(component->dev); struct sst_byt_priv_data *priv_data; int i; if (!plat_data) return -ENODEV; - priv_data = devm_kzalloc(platform->dev, sizeof(*priv_data), + priv_data = devm_kzalloc(component->dev, sizeof(*priv_data), GFP_KERNEL); if (!priv_data) return -ENOMEM; priv_data->byt = plat_data->dsp; - snd_soc_platform_set_drvdata(platform, priv_data); + snd_soc_component_set_drvdata(component, priv_data); for (i = 0; i < BYT_PCM_COUNT; i++) { mutex_init(&priv_data->pcm[i].mutex); @@ -390,22 +391,13 @@ static int sst_byt_pcm_probe(struct snd_soc_platform *platform) return 0; } -static int sst_byt_pcm_remove(struct snd_soc_platform *platform) -{ - return 0; -} - -static const struct snd_soc_platform_driver byt_soc_platform = { +static const struct snd_soc_component_driver byt_dai_component = { + .name = DRV_NAME, .probe = sst_byt_pcm_probe, - .remove = sst_byt_pcm_remove, .ops = &sst_byt_pcm_ops, .pcm_new = sst_byt_pcm_new, }; -static const struct snd_soc_component_driver byt_dai_component = { - .name = "byt-dai", -}; - #ifdef CONFIG_PM static int sst_byt_pcm_dev_suspend_late(struct device *dev) { @@ -461,19 +453,13 @@ static int sst_byt_pcm_dev_probe(struct platform_device *pdev) if (ret < 0) return -ENODEV; - ret = snd_soc_register_platform(&pdev->dev, &byt_soc_platform); - if (ret < 0) - goto err_plat; - - ret = snd_soc_register_component(&pdev->dev, &byt_dai_component, + ret = devm_snd_soc_register_component(&pdev->dev, &byt_dai_component, byt_dais, ARRAY_SIZE(byt_dais)); if (ret < 0) - goto err_comp; + goto err_plat; return 0; -err_comp: - snd_soc_unregister_platform(&pdev->dev); err_plat: sst_byt_dsp_free(&pdev->dev, sst_pdata); return ret; @@ -483,8 +469,6 @@ static int sst_byt_pcm_dev_remove(struct platform_device *pdev) { struct sst_pdata *sst_pdata = dev_get_platdata(&pdev->dev); - snd_soc_unregister_platform(&pdev->dev); - snd_soc_unregister_component(&pdev->dev); sst_byt_dsp_free(&pdev->dev, sst_pdata); return 0; diff --git a/sound/soc/intel/boards/Kconfig b/sound/soc/intel/boards/Kconfig index fefb1ee9fec6..24797482a3d2 100644 --- a/sound/soc/intel/boards/Kconfig +++ b/sound/soc/intel/boards/Kconfig @@ -125,6 +125,17 @@ config SND_SOC_INTEL_CHT_BSW_MAX98090_TI_MACH Say Y or m if you have such a device. This is a recommended option. If unsure select "N". +config SND_SOC_INTEL_CHT_BSW_NAU8824_MACH + tristate "Cherrytrail & Braswell with NAU88L24 codec" + depends on X86_INTEL_LPSS && I2C && ACPI + select SND_SOC_ACPI + select SND_SOC_NAU8824 + help + This adds support for ASoC machine driver for Intel(R) Cherrytrail & Braswell + platforms with NAU88L24 audio codec. + Say Y or m if you have such a device. This is a recommended option. + If unsure select "N". + config SND_SOC_INTEL_BYT_CHT_DA7213_MACH tristate "Baytrail & Cherrytrail with DA7212/7213 codec" depends on X86_INTEL_LPSS && I2C && ACPI @@ -256,6 +267,20 @@ config SND_SOC_INTEL_KBL_RT5663_RT5514_MAX98927_MACH create an alsa sound card for RT5663 + RT5514 + MAX98927. Say Y or m if you have such a device. This is a recommended option. If unsure select "N". + +config SND_SOC_INTEL_KBL_DA7219_MAX98357A_MACH + tristate "KBL with DA7219 and MAX98357A in I2S Mode" + depends on MFD_INTEL_LPSS && I2C && ACPI + select SND_SOC_DA7219 + select SND_SOC_MAX98357A + select SND_SOC_DMIC + select SND_SOC_HDAC_HDMI + help + This adds support for ASoC Onboard Codec I2S machine driver. This will + create an alsa sound card for DA7219 + MAX98357A I2S audio codec. + Say Y if you have such a device. + If unsure select "N". + endif ## SND_SOC_INTEL_SKYLAKE endif ## SND_SOC_INTEL_MACH diff --git a/sound/soc/intel/boards/Makefile b/sound/soc/intel/boards/Makefile index 69d2dfaeb00c..92b5507291af 100644 --- a/sound/soc/intel/boards/Makefile +++ b/sound/soc/intel/boards/Makefile @@ -11,9 +11,11 @@ snd-soc-sst-bytcr-rt5651-objs := bytcr_rt5651.o snd-soc-sst-cht-bsw-rt5672-objs := cht_bsw_rt5672.o snd-soc-sst-cht-bsw-rt5645-objs := cht_bsw_rt5645.o snd-soc-sst-cht-bsw-max98090_ti-objs := cht_bsw_max98090_ti.o +snd-soc-sst-cht-bsw-nau8824-objs := cht_bsw_nau8824.o snd-soc-sst-byt-cht-da7213-objs := bytcht_da7213.o snd-soc-sst-byt-cht-es8316-objs := bytcht_es8316.o snd-soc-sst-byt-cht-nocodec-objs := bytcht_nocodec.o +snd-soc-kbl_da7219_max98357a-objs := kbl_da7219_max98357a.o snd-soc-kbl_rt5663_max98927-objs := kbl_rt5663_max98927.o snd-soc-kbl_rt5663_rt5514_max98927-objs := kbl_rt5663_rt5514_max98927.o snd-soc-skl_rt286-objs := skl_rt286.o @@ -32,9 +34,11 @@ obj-$(CONFIG_SND_SOC_INTEL_BYTCR_RT5651_MACH) += snd-soc-sst-bytcr-rt5651.o obj-$(CONFIG_SND_SOC_INTEL_CHT_BSW_RT5672_MACH) += snd-soc-sst-cht-bsw-rt5672.o obj-$(CONFIG_SND_SOC_INTEL_CHT_BSW_RT5645_MACH) += snd-soc-sst-cht-bsw-rt5645.o obj-$(CONFIG_SND_SOC_INTEL_CHT_BSW_MAX98090_TI_MACH) += snd-soc-sst-cht-bsw-max98090_ti.o +obj-$(CONFIG_SND_SOC_INTEL_CHT_BSW_NAU8824_MACH) += snd-soc-sst-cht-bsw-nau8824.o obj-$(CONFIG_SND_SOC_INTEL_BYT_CHT_DA7213_MACH) += snd-soc-sst-byt-cht-da7213.o obj-$(CONFIG_SND_SOC_INTEL_BYT_CHT_ES8316_MACH) += snd-soc-sst-byt-cht-es8316.o obj-$(CONFIG_SND_SOC_INTEL_BYT_CHT_NOCODEC_MACH) += snd-soc-sst-byt-cht-nocodec.o +obj-$(CONFIG_SND_SOC_INTEL_KBL_DA7219_MAX98357A_MACH) += snd-soc-kbl_da7219_max98357a.o obj-$(CONFIG_SND_SOC_INTEL_KBL_RT5663_MAX98927_MACH) += snd-soc-kbl_rt5663_max98927.o obj-$(CONFIG_SND_SOC_INTEL_KBL_RT5663_RT5514_MAX98927_MACH) += snd-soc-kbl_rt5663_rt5514_max98927.o obj-$(CONFIG_SND_SOC_INTEL_SKL_RT286_MACH) += snd-soc-skl_rt286.o diff --git a/sound/soc/intel/boards/bdw-rt5677.c b/sound/soc/intel/boards/bdw-rt5677.c index 058b8ccedf02..6ea360f33575 100644 --- a/sound/soc/intel/boards/bdw-rt5677.c +++ b/sound/soc/intel/boards/bdw-rt5677.c @@ -34,7 +34,7 @@ struct bdw_rt5677_priv { struct gpio_desc *gpio_hp_en; - struct snd_soc_codec *codec; + struct snd_soc_component *component; }; static int bdw_rt5677_event_hp(struct snd_soc_dapm_widget *w, @@ -183,7 +183,8 @@ static const struct snd_soc_ops bdw_rt5677_ops = { static int bdw_rt5677_rtd_init(struct snd_soc_pcm_runtime *rtd) { - struct sst_pdata *pdata = dev_get_platdata(rtd->platform->dev); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_pdata *pdata = dev_get_platdata(component->dev); struct sst_hsw *broadwell = pdata->dsp; int ret; @@ -203,26 +204,26 @@ static int bdw_rt5677_init(struct snd_soc_pcm_runtime *rtd) { struct bdw_rt5677_priv *bdw_rt5677 = snd_soc_card_get_drvdata(rtd->card); - struct snd_soc_codec *codec = rtd->codec; - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_component *component = rtd->codec_dai->component; + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); int ret; - ret = devm_acpi_dev_add_driver_gpios(codec->dev, bdw_rt5677_gpios); + ret = devm_acpi_dev_add_driver_gpios(component->dev, bdw_rt5677_gpios); if (ret) - dev_warn(codec->dev, "Failed to add driver gpios\n"); + dev_warn(component->dev, "Failed to add driver gpios\n"); /* Enable codec ASRC function for Stereo DAC/Stereo1 ADC/DMIC/I2S1. * The ASRC clock source is clk_i2s1_asrc. */ - rt5677_sel_asrc_clk_src(codec, RT5677_DA_STEREO_FILTER | + rt5677_sel_asrc_clk_src(component, RT5677_DA_STEREO_FILTER | RT5677_AD_STEREO1_FILTER | RT5677_I2S1_SOURCE, RT5677_CLK_SEL_I2S1_ASRC); /* Request rt5677 GPIO for headphone amp control */ - bdw_rt5677->gpio_hp_en = devm_gpiod_get(codec->dev, "headphone-enable", + bdw_rt5677->gpio_hp_en = devm_gpiod_get(component->dev, "headphone-enable", GPIOD_OUT_LOW); if (IS_ERR(bdw_rt5677->gpio_hp_en)) { - dev_err(codec->dev, "Can't find HP_AMP_SHDN_L gpio\n"); + dev_err(component->dev, "Can't find HP_AMP_SHDN_L gpio\n"); return PTR_ERR(bdw_rt5677->gpio_hp_en); } @@ -230,25 +231,25 @@ static int bdw_rt5677_init(struct snd_soc_pcm_runtime *rtd) if (!snd_soc_card_jack_new(rtd->card, "Headphone Jack", SND_JACK_HEADPHONE, &headphone_jack, &headphone_jack_pin, 1)) { - headphone_jack_gpio.gpiod_dev = codec->dev; + headphone_jack_gpio.gpiod_dev = component->dev; if (snd_soc_jack_add_gpios(&headphone_jack, 1, &headphone_jack_gpio)) - dev_err(codec->dev, "Can't add headphone jack gpio\n"); + dev_err(component->dev, "Can't add headphone jack gpio\n"); } else { - dev_err(codec->dev, "Can't create headphone jack\n"); + dev_err(component->dev, "Can't create headphone jack\n"); } /* Create and initialize mic jack */ if (!snd_soc_card_jack_new(rtd->card, "Mic Jack", SND_JACK_MICROPHONE, &mic_jack, &mic_jack_pin, 1)) { - mic_jack_gpio.gpiod_dev = codec->dev; + mic_jack_gpio.gpiod_dev = component->dev; if (snd_soc_jack_add_gpios(&mic_jack, 1, &mic_jack_gpio)) - dev_err(codec->dev, "Can't add mic jack gpio\n"); + dev_err(component->dev, "Can't add mic jack gpio\n"); } else { - dev_err(codec->dev, "Can't create mic jack\n"); + dev_err(component->dev, "Can't create mic jack\n"); } - bdw_rt5677->codec = codec; + bdw_rt5677->component = component; snd_soc_dapm_force_enable_pin(dapm, "MICBIAS1"); return 0; @@ -301,8 +302,8 @@ static int bdw_rt5677_suspend_pre(struct snd_soc_card *card) struct bdw_rt5677_priv *bdw_rt5677 = snd_soc_card_get_drvdata(card); struct snd_soc_dapm_context *dapm; - if (bdw_rt5677->codec) { - dapm = snd_soc_codec_get_dapm(bdw_rt5677->codec); + if (bdw_rt5677->component) { + dapm = snd_soc_component_get_dapm(bdw_rt5677->component); snd_soc_dapm_disable_pin(dapm, "MICBIAS1"); } return 0; @@ -313,8 +314,8 @@ static int bdw_rt5677_resume_post(struct snd_soc_card *card) struct bdw_rt5677_priv *bdw_rt5677 = snd_soc_card_get_drvdata(card); struct snd_soc_dapm_context *dapm; - if (bdw_rt5677->codec) { - dapm = snd_soc_codec_get_dapm(bdw_rt5677->codec); + if (bdw_rt5677->component) { + dapm = snd_soc_component_get_dapm(bdw_rt5677->component); snd_soc_dapm_force_enable_pin(dapm, "MICBIAS1"); } return 0; diff --git a/sound/soc/intel/boards/broadwell.c b/sound/soc/intel/boards/broadwell.c index 6dcbbcefc25b..7b0ee67b4fc8 100644 --- a/sound/soc/intel/boards/broadwell.c +++ b/sound/soc/intel/boards/broadwell.c @@ -78,7 +78,7 @@ static const struct snd_soc_dapm_route broadwell_rt286_map[] = { static int broadwell_rt286_codec_init(struct snd_soc_pcm_runtime *rtd) { - struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_component *component = rtd->codec_dai->component; int ret = 0; ret = snd_soc_card_jack_new(rtd->card, "Headset", SND_JACK_HEADSET | SND_JACK_BTN_0, &broadwell_headset, @@ -86,7 +86,7 @@ static int broadwell_rt286_codec_init(struct snd_soc_pcm_runtime *rtd) if (ret) return ret; - rt286_mic_detect(codec, &broadwell_headset); + rt286_mic_detect(component, &broadwell_headset); return 0; } @@ -132,7 +132,8 @@ static const struct snd_soc_ops broadwell_rt286_ops = { static int broadwell_rtd_init(struct snd_soc_pcm_runtime *rtd) { - struct sst_pdata *pdata = dev_get_platdata(rtd->platform->dev); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_pdata *pdata = dev_get_platdata(component->dev); struct sst_hsw *broadwell = pdata->dsp; int ret; @@ -224,10 +225,9 @@ static int broadwell_suspend(struct snd_soc_card *card){ list_for_each_entry(component, &card->component_dev_list, card_list) { if (!strcmp(component->name, "i2c-INT343A:00")) { - struct snd_soc_codec *codec = snd_soc_component_to_codec(component); - dev_dbg(codec->dev, "disabling jack detect before going to suspend.\n"); - rt286_mic_detect(codec, NULL); + dev_dbg(component->dev, "disabling jack detect before going to suspend.\n"); + rt286_mic_detect(component, NULL); break; } } @@ -239,10 +239,9 @@ static int broadwell_resume(struct snd_soc_card *card){ list_for_each_entry(component, &card->component_dev_list, card_list) { if (!strcmp(component->name, "i2c-INT343A:00")) { - struct snd_soc_codec *codec = snd_soc_component_to_codec(component); - dev_dbg(codec->dev, "enabling jack detect for resume.\n"); - rt286_mic_detect(codec, &broadwell_headset); + dev_dbg(component->dev, "enabling jack detect for resume.\n"); + rt286_mic_detect(component, &broadwell_headset); break; } } diff --git a/sound/soc/intel/boards/bxt_da7219_max98357a.c b/sound/soc/intel/boards/bxt_da7219_max98357a.c index f8a91a6f2a17..668c0934e942 100644 --- a/sound/soc/intel/boards/bxt_da7219_max98357a.c +++ b/sound/soc/intel/boards/bxt_da7219_max98357a.c @@ -169,7 +169,7 @@ static int broxton_da7219_codec_init(struct snd_soc_pcm_runtime *rtd) { int ret; struct snd_soc_dai *codec_dai = rtd->codec_dai; - struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_component *component = rtd->codec_dai->component; /* Configure sysclk for codec */ ret = snd_soc_dai_set_sysclk(codec_dai, DA7219_CLKSRC_MCLK, 19200000, @@ -192,7 +192,7 @@ static int broxton_da7219_codec_init(struct snd_soc_pcm_runtime *rtd) return ret; } - da7219_aad_jack_det(codec, &broxton_headset); + da7219_aad_jack_det(component, &broxton_headset); snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC"); @@ -522,12 +522,12 @@ static int bxt_card_late_probe(struct snd_soc_card *card) { struct bxt_card_private *ctx = snd_soc_card_get_drvdata(card); struct bxt_hdmi_pcm *pcm; - struct snd_soc_codec *codec = NULL; + struct snd_soc_component *component = NULL; int err, i = 0; char jack_name[NAME_SIZE]; list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { - codec = pcm->codec_dai->codec; + component = pcm->codec_dai->component; snprintf(jack_name, sizeof(jack_name), "HDMI/DP, pcm=%d Jack", pcm->device); err = snd_soc_card_jack_new(card, jack_name, @@ -545,10 +545,10 @@ static int bxt_card_late_probe(struct snd_soc_card *card) i++; } - if (!codec) + if (!component) return -EINVAL; - return hdac_hdmi_jack_port_init(codec, &card->dapm); + return hdac_hdmi_jack_port_init(component, &card->dapm); } /* broxton audio machine driver for SPT + da7219 */ diff --git a/sound/soc/intel/boards/bxt_rt298.c b/sound/soc/intel/boards/bxt_rt298.c index 7843104fadcb..c7e9024e65ef 100644 --- a/sound/soc/intel/boards/bxt_rt298.c +++ b/sound/soc/intel/boards/bxt_rt298.c @@ -146,6 +146,9 @@ static const struct snd_soc_dapm_route geminilake_rt298_map[] = { { "dmic01_hifi", NULL, "DMIC01 Rx" }, { "DMIC01 Rx", NULL, "Capture" }, + { "dmic_voice", NULL, "DMIC16k Rx" }, + { "DMIC16k Rx", NULL, "Capture" }, + { "hifi3", NULL, "iDisp3 Tx"}, { "iDisp3 Tx", NULL, "iDisp3_out"}, { "hifi2", NULL, "iDisp2 Tx"}, @@ -167,7 +170,7 @@ static int broxton_rt298_fe_init(struct snd_soc_pcm_runtime *rtd) static int broxton_rt298_codec_init(struct snd_soc_pcm_runtime *rtd) { - struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_component *component = rtd->codec_dai->component; int ret = 0; ret = snd_soc_card_jack_new(rtd->card, "Headset", @@ -178,7 +181,7 @@ static int broxton_rt298_codec_init(struct snd_soc_pcm_runtime *rtd) if (ret) return ret; - rt298_mic_detect(codec, &broxton_headset); + rt298_mic_detect(component, &broxton_headset); snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC"); @@ -457,6 +460,18 @@ static struct snd_soc_dai_link broxton_rt298_dais[] = { .no_pcm = 1, }, { + .name = "dmic16k", + .id = 2, + .cpu_dai_name = "DMIC16k Pin", + .codec_name = "dmic-codec", + .codec_dai_name = "dmic-hifi", + .platform_name = "0000:00:0e.0", + .be_hw_params_fixup = broxton_dmic_fixup, + .ignore_suspend = 1, + .dpcm_capture = 1, + .no_pcm = 1, + }, + { .name = "iDisp1", .id = 3, .cpu_dai_name = "iDisp1 Pin", @@ -496,12 +511,12 @@ static int bxt_card_late_probe(struct snd_soc_card *card) { struct bxt_rt286_private *ctx = snd_soc_card_get_drvdata(card); struct bxt_hdmi_pcm *pcm; - struct snd_soc_codec *codec = NULL; + struct snd_soc_component *component = NULL; int err, i = 0; char jack_name[NAME_SIZE]; list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { - codec = pcm->codec_dai->codec; + component = pcm->codec_dai->component; snprintf(jack_name, sizeof(jack_name), "HDMI/DP, pcm=%d Jack", pcm->device); err = snd_soc_card_jack_new(card, jack_name, @@ -519,10 +534,10 @@ static int bxt_card_late_probe(struct snd_soc_card *card) i++; } - if (!codec) + if (!component) return -EINVAL; - return hdac_hdmi_jack_port_init(codec, &card->dapm); + return hdac_hdmi_jack_port_init(component, &card->dapm); } diff --git a/sound/soc/intel/boards/byt-rt5640.c b/sound/soc/intel/boards/byt-rt5640.c index de9788a3fd06..df902d82145e 100644 --- a/sound/soc/intel/boards/byt-rt5640.c +++ b/sound/soc/intel/boards/byt-rt5640.c @@ -131,7 +131,7 @@ static const struct dmi_system_id byt_rt5640_quirk_table[] = { static int byt_rt5640_init(struct snd_soc_pcm_runtime *runtime) { int ret; - struct snd_soc_codec *codec = runtime->codec; + struct snd_soc_component *component = runtime->codec_dai->component; struct snd_soc_card *card = runtime->card; const struct snd_soc_dapm_route *custom_map; int num_routes; @@ -165,7 +165,7 @@ static int byt_rt5640_init(struct snd_soc_pcm_runtime *runtime) return ret; if (byt_rt5640_quirk & BYT_RT5640_DMIC_EN) { - ret = rt5640_dmic_enable(codec, 0, 0); + ret = rt5640_dmic_enable(component, 0, 0); if (ret) return ret; } diff --git a/sound/soc/intel/boards/bytcr_rt5640.c b/sound/soc/intel/boards/bytcr_rt5640.c index b6a1cfeec830..a8d8bff788e7 100644 --- a/sound/soc/intel/boards/bytcr_rt5640.c +++ b/sound/soc/intel/boards/bytcr_rt5640.c @@ -444,14 +444,14 @@ static int byt_rt5640_init(struct snd_soc_pcm_runtime *runtime) { struct snd_soc_card *card = runtime->card; struct byt_rt5640_private *priv = snd_soc_card_get_drvdata(card); - struct snd_soc_codec *codec = runtime->codec; + struct snd_soc_component *component = runtime->codec_dai->component; const struct snd_soc_dapm_route *custom_map; int num_routes; int ret; card->dapm.idle_bias_off = true; - rt5640_sel_asrc_clk_src(codec, + rt5640_sel_asrc_clk_src(component, RT5640_DA_STEREO_FILTER | RT5640_DA_MONO_L_FILTER | RT5640_DA_MONO_R_FILTER | @@ -522,12 +522,12 @@ static int byt_rt5640_init(struct snd_soc_pcm_runtime *runtime) return ret; if (byt_rt5640_quirk & BYT_RT5640_DIFF_MIC) { - snd_soc_update_bits(codec, RT5640_IN1_IN2, RT5640_IN_DF1, + snd_soc_component_update_bits(component, RT5640_IN1_IN2, RT5640_IN_DF1, RT5640_IN_DF1); } if (byt_rt5640_quirk & BYT_RT5640_DMIC_EN) { - ret = rt5640_dmic_enable(codec, 0, 0); + ret = rt5640_dmic_enable(component, 0, 0); if (ret) return ret; } diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c index 456526a93dd5..1b1997f1d60c 100644 --- a/sound/soc/intel/boards/bytcr_rt5651.c +++ b/sound/soc/intel/boards/bytcr_rt5651.c @@ -18,13 +18,16 @@ */ #include <linux/init.h> +#include <linux/i2c.h> #include <linux/module.h> #include <linux/platform_device.h> +#include <linux/property.h> #include <linux/acpi.h> #include <linux/clk.h> #include <linux/device.h> #include <linux/dmi.h> #include <linux/slab.h> +#include <asm/cpu_device_id.h> #include <asm/platform_sst_audio.h> #include <sound/pcm.h> #include <sound/pcm_params.h> @@ -39,22 +42,55 @@ enum { BYT_RT5651_IN1_MAP, BYT_RT5651_IN2_MAP, BYT_RT5651_IN1_IN2_MAP, - BYT_RT5651_IN3_MAP, + BYT_RT5651_IN1_HS_IN3_MAP, + BYT_RT5651_IN2_HS_IN3_MAP, }; -#define BYT_RT5651_MAP(quirk) ((quirk) & GENMASK(7, 0)) -#define BYT_RT5651_DMIC_EN BIT(16) -#define BYT_RT5651_MCLK_EN BIT(17) -#define BYT_RT5651_MCLK_25MHZ BIT(18) +enum { + BYT_RT5651_JD_NULL = (RT5651_JD_NULL << 4), + BYT_RT5651_JD1_1 = (RT5651_JD1_1 << 4), + BYT_RT5651_JD1_2 = (RT5651_JD1_2 << 4), + BYT_RT5651_JD2 = (RT5651_JD2 << 4), +}; + +enum { + BYT_RT5651_OVCD_TH_600UA = (6 << 8), + BYT_RT5651_OVCD_TH_1500UA = (15 << 8), + BYT_RT5651_OVCD_TH_2000UA = (20 << 8), +}; + +enum { + BYT_RT5651_OVCD_SF_0P5 = (RT5651_OVCD_SF_0P5 << 13), + BYT_RT5651_OVCD_SF_0P75 = (RT5651_OVCD_SF_0P75 << 13), + BYT_RT5651_OVCD_SF_1P0 = (RT5651_OVCD_SF_1P0 << 13), + BYT_RT5651_OVCD_SF_1P5 = (RT5651_OVCD_SF_1P5 << 13), +}; + +#define BYT_RT5651_MAP(quirk) ((quirk) & GENMASK(3, 0)) +#define BYT_RT5651_JDSRC(quirk) (((quirk) & GENMASK(7, 4)) >> 4) +#define BYT_RT5651_OVCD_TH(quirk) (((quirk) & GENMASK(12, 8)) >> 8) +#define BYT_RT5651_OVCD_SF(quirk) (((quirk) & GENMASK(14, 13)) >> 13) +#define BYT_RT5651_DMIC_EN BIT(16) +#define BYT_RT5651_MCLK_EN BIT(17) +#define BYT_RT5651_MCLK_25MHZ BIT(18) +#define BYT_RT5651_SSP2_AIF2 BIT(19) /* default is using AIF1 */ +#define BYT_RT5651_SSP0_AIF1 BIT(20) +#define BYT_RT5651_SSP0_AIF2 BIT(21) + +/* jack-detect-source + dmic-en + ovcd-th + -sf + terminating empty entry */ +#define MAX_NO_PROPS 5 struct byt_rt5651_private { struct clk *mclk; struct snd_soc_jack jack; }; -static unsigned long byt_rt5651_quirk = BYT_RT5651_DMIC_MAP | - BYT_RT5651_DMIC_EN | - BYT_RT5651_MCLK_EN; +/* Default: jack-detect on JD1_1, internal mic on in2, headsetmic on in3 */ +static unsigned long byt_rt5651_quirk = BYT_RT5651_MCLK_EN | + BYT_RT5651_JD1_1 | + BYT_RT5651_OVCD_TH_2000UA | + BYT_RT5651_OVCD_SF_0P75 | + BYT_RT5651_IN2_HS_IN3_MAP; static void log_quirks(struct device *dev) { @@ -64,17 +100,66 @@ static void log_quirks(struct device *dev) dev_info(dev, "quirk IN1_MAP enabled"); if (BYT_RT5651_MAP(byt_rt5651_quirk) == BYT_RT5651_IN2_MAP) dev_info(dev, "quirk IN2_MAP enabled"); - if (BYT_RT5651_MAP(byt_rt5651_quirk) == BYT_RT5651_IN3_MAP) - dev_info(dev, "quirk IN3_MAP enabled"); + if (BYT_RT5651_MAP(byt_rt5651_quirk) == BYT_RT5651_IN1_HS_IN3_MAP) + dev_info(dev, "quirk IN1_HS_IN3_MAP enabled"); + if (BYT_RT5651_MAP(byt_rt5651_quirk) == BYT_RT5651_IN2_HS_IN3_MAP) + dev_info(dev, "quirk IN2_HS_IN3_MAP enabled"); + if (BYT_RT5651_JDSRC(byt_rt5651_quirk)) { + dev_info(dev, "quirk realtek,jack-detect-source %ld\n", + BYT_RT5651_JDSRC(byt_rt5651_quirk)); + dev_info(dev, "quirk realtek,over-current-threshold-microamp %ld\n", + BYT_RT5651_OVCD_TH(byt_rt5651_quirk) * 100); + dev_info(dev, "quirk realtek,over-current-scale-factor %ld\n", + BYT_RT5651_OVCD_SF(byt_rt5651_quirk)); + } if (byt_rt5651_quirk & BYT_RT5651_DMIC_EN) dev_info(dev, "quirk DMIC enabled"); if (byt_rt5651_quirk & BYT_RT5651_MCLK_EN) dev_info(dev, "quirk MCLK_EN enabled"); if (byt_rt5651_quirk & BYT_RT5651_MCLK_25MHZ) dev_info(dev, "quirk MCLK_25MHZ enabled"); + if (byt_rt5651_quirk & BYT_RT5651_SSP2_AIF2) + dev_info(dev, "quirk SSP2_AIF2 enabled\n"); + if (byt_rt5651_quirk & BYT_RT5651_SSP0_AIF1) + dev_info(dev, "quirk SSP0_AIF1 enabled\n"); + if (byt_rt5651_quirk & BYT_RT5651_SSP0_AIF2) + dev_info(dev, "quirk SSP0_AIF2 enabled\n"); } #define BYT_CODEC_DAI1 "rt5651-aif1" +#define BYT_CODEC_DAI2 "rt5651-aif2" + +static int byt_rt5651_prepare_and_enable_pll1(struct snd_soc_dai *codec_dai, + int rate, int bclk_ratio) +{ + int clk_id, clk_freq, ret; + + /* Configure the PLL before selecting it */ + if (!(byt_rt5651_quirk & BYT_RT5651_MCLK_EN)) { + clk_id = RT5651_PLL1_S_BCLK1, + clk_freq = rate * bclk_ratio; + } else { + clk_id = RT5651_PLL1_S_MCLK; + if (byt_rt5651_quirk & BYT_RT5651_MCLK_25MHZ) + clk_freq = 25000000; + else + clk_freq = 19200000; + } + ret = snd_soc_dai_set_pll(codec_dai, 0, clk_id, clk_freq, rate * 512); + if (ret < 0) { + dev_err(codec_dai->component->dev, "can't set pll: %d\n", ret); + return ret; + } + + ret = snd_soc_dai_set_sysclk(codec_dai, RT5651_SCLK_S_PLL1, + rate * 512, SND_SOC_CLOCK_IN); + if (ret < 0) { + dev_err(codec_dai->component->dev, "can't set clock %d\n", ret); + return ret; + } + + return 0; +} static int platform_clock_control(struct snd_soc_dapm_widget *w, struct snd_kcontrol *k, int event) @@ -86,6 +171,8 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w, int ret; codec_dai = snd_soc_card_get_codec_dai(card, BYT_CODEC_DAI1); + if (!codec_dai) + codec_dai = snd_soc_card_get_codec_dai(card, BYT_CODEC_DAI2); if (!codec_dai) { dev_err(card->dev, "Codec dai not found; Unable to set platform clock\n"); @@ -101,9 +188,7 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w, return ret; } } - ret = snd_soc_dai_set_sysclk(codec_dai, RT5651_SCLK_S_PLL1, - 48000 * 512, - SND_SOC_CLOCK_IN); + ret = byt_rt5651_prepare_and_enable_pll1(codec_dai, 48000, 50); } else { /* * Set codec clock source to internal clock before @@ -145,13 +230,6 @@ static const struct snd_soc_dapm_route byt_rt5651_audio_map[] = { {"Speaker", NULL, "Platform Clock"}, {"Line In", NULL, "Platform Clock"}, - {"AIF1 Playback", NULL, "ssp2 Tx"}, - {"ssp2 Tx", NULL, "codec_out0"}, - {"ssp2 Tx", NULL, "codec_out1"}, - {"codec_in0", NULL, "ssp2 Rx"}, - {"codec_in1", NULL, "ssp2 Rx"}, - {"ssp2 Rx", NULL, "AIF1 Capture"}, - {"Headset Mic", NULL, "micbias1"}, /* lowercase for rt5651 */ {"Headphone", NULL, "HPOL"}, {"Headphone", NULL, "HPOR"}, @@ -170,8 +248,8 @@ static const struct snd_soc_dapm_route byt_rt5651_intmic_dmic_map[] = { static const struct snd_soc_dapm_route byt_rt5651_intmic_in1_map[] = { {"Internal Mic", NULL, "micbias1"}, - {"IN2P", NULL, "Headset Mic"}, {"IN1P", NULL, "Internal Mic"}, + {"IN2P", NULL, "Headset Mic"}, }; static const struct snd_soc_dapm_route byt_rt5651_intmic_in2_map[] = { @@ -187,10 +265,52 @@ static const struct snd_soc_dapm_route byt_rt5651_intmic_in1_in2_map[] = { {"IN3P", NULL, "Headset Mic"}, }; -static const struct snd_soc_dapm_route byt_rt5651_intmic_in3_map[] = { +static const struct snd_soc_dapm_route byt_rt5651_intmic_in1_hs_in3_map[] = { {"Internal Mic", NULL, "micbias1"}, - {"IN3P", NULL, "Headset Mic"}, {"IN1P", NULL, "Internal Mic"}, + {"IN3P", NULL, "Headset Mic"}, +}; + +static const struct snd_soc_dapm_route byt_rt5651_intmic_in2_hs_in3_map[] = { + {"Internal Mic", NULL, "micbias1"}, + {"IN2P", NULL, "Internal Mic"}, + {"IN3P", NULL, "Headset Mic"}, +}; + +static const struct snd_soc_dapm_route byt_rt5651_ssp0_aif1_map[] = { + {"ssp0 Tx", NULL, "modem_out"}, + {"modem_in", NULL, "ssp0 Rx"}, + + {"AIF1 Playback", NULL, "ssp0 Tx"}, + {"ssp0 Rx", NULL, "AIF1 Capture"}, +}; + +static const struct snd_soc_dapm_route byt_rt5651_ssp0_aif2_map[] = { + {"ssp0 Tx", NULL, "modem_out"}, + {"modem_in", NULL, "ssp0 Rx"}, + + {"AIF2 Playback", NULL, "ssp0 Tx"}, + {"ssp0 Rx", NULL, "AIF2 Capture"}, +}; + +static const struct snd_soc_dapm_route byt_rt5651_ssp2_aif1_map[] = { + {"ssp2 Tx", NULL, "codec_out0"}, + {"ssp2 Tx", NULL, "codec_out1"}, + {"codec_in0", NULL, "ssp2 Rx"}, + {"codec_in1", NULL, "ssp2 Rx"}, + + {"AIF1 Playback", NULL, "ssp2 Tx"}, + {"ssp2 Rx", NULL, "AIF1 Capture"}, +}; + +static const struct snd_soc_dapm_route byt_rt5651_ssp2_aif2_map[] = { + {"ssp2 Tx", NULL, "codec_out0"}, + {"ssp2 Tx", NULL, "codec_out1"}, + {"codec_in0", NULL, "ssp2 Rx"}, + {"codec_in1", NULL, "ssp2 Rx"}, + + {"AIF2 Playback", NULL, "ssp2 Tx"}, + {"ssp2 Rx", NULL, "AIF2 Capture"}, }; static const struct snd_kcontrol_new byt_rt5651_controls[] = { @@ -217,44 +337,16 @@ static int byt_rt5651_aif1_hw_params(struct snd_pcm_substream *substream, { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->codec_dai; - int ret; - - snd_soc_dai_set_bclk_ratio(codec_dai, 50); + snd_pcm_format_t format = params_format(params); + int rate = params_rate(params); + int bclk_ratio; - ret = snd_soc_dai_set_sysclk(codec_dai, RT5651_SCLK_S_PLL1, - params_rate(params) * 512, - SND_SOC_CLOCK_IN); - if (ret < 0) { - dev_err(rtd->dev, "can't set codec clock %d\n", ret); - return ret; - } + if (format == SNDRV_PCM_FORMAT_S16_LE) + bclk_ratio = 32; + else + bclk_ratio = 50; - if (!(byt_rt5651_quirk & BYT_RT5651_MCLK_EN)) { - /* 2x25 bit slots on SSP2 */ - ret = snd_soc_dai_set_pll(codec_dai, 0, - RT5651_PLL1_S_BCLK1, - params_rate(params) * 50, - params_rate(params) * 512); - } else { - if (byt_rt5651_quirk & BYT_RT5651_MCLK_25MHZ) { - ret = snd_soc_dai_set_pll(codec_dai, 0, - RT5651_PLL1_S_MCLK, - 25000000, - params_rate(params) * 512); - } else { - ret = snd_soc_dai_set_pll(codec_dai, 0, - RT5651_PLL1_S_MCLK, - 19200000, - params_rate(params) * 512); - } - } - - if (ret < 0) { - dev_err(rtd->dev, "can't set codec pll: %d\n", ret); - return ret; - } - - return 0; + return byt_rt5651_prepare_and_enable_pll1(codec_dai, rate, bclk_ratio); } static int byt_rt5651_quirk_cb(const struct dmi_system_id *id) @@ -270,7 +362,7 @@ static const struct dmi_system_id byt_rt5651_quirk_table[] = { DMI_MATCH(DMI_SYS_VENDOR, "Circuitco"), DMI_MATCH(DMI_PRODUCT_NAME, "Minnowboard Max B3 PLATFORM"), }, - .driver_data = (void *)(BYT_RT5651_IN3_MAP), + .driver_data = (void *)(BYT_RT5651_IN1_HS_IN3_MAP), }, { .callback = byt_rt5651_quirk_cb, @@ -279,7 +371,7 @@ static const struct dmi_system_id byt_rt5651_quirk_table[] = { DMI_MATCH(DMI_PRODUCT_NAME, "Minnowboard Turbot"), }, .driver_data = (void *)(BYT_RT5651_MCLK_EN | - BYT_RT5651_IN3_MAP), + BYT_RT5651_IN1_HS_IN3_MAP), }, { .callback = byt_rt5651_quirk_cb, @@ -288,15 +380,76 @@ static const struct dmi_system_id byt_rt5651_quirk_table[] = { DMI_MATCH(DMI_PRODUCT_NAME, "KIANO SlimNote 14.2"), }, .driver_data = (void *)(BYT_RT5651_MCLK_EN | + BYT_RT5651_JD1_1 | + BYT_RT5651_OVCD_TH_2000UA | + BYT_RT5651_OVCD_SF_0P75 | + BYT_RT5651_IN1_IN2_MAP), + }, + { + /* Chuwi Vi8 Plus (CWI519) */ + .callback = byt_rt5651_quirk_cb, + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Hampoo"), + DMI_MATCH(DMI_PRODUCT_NAME, "D2D3_Vi8A1"), + }, + .driver_data = (void *)(BYT_RT5651_MCLK_EN | + BYT_RT5651_JD1_1 | + BYT_RT5651_OVCD_TH_2000UA | + BYT_RT5651_OVCD_SF_0P75 | + BYT_RT5651_IN2_HS_IN3_MAP), + }, + { + /* VIOS LTH17 */ + .callback = byt_rt5651_quirk_cb, + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "VIOS"), + DMI_MATCH(DMI_PRODUCT_NAME, "LTH17"), + }, + .driver_data = (void *)(BYT_RT5651_MCLK_EN | + BYT_RT5651_JD1_1 | + BYT_RT5651_OVCD_TH_2000UA | + BYT_RT5651_OVCD_SF_1P0 | BYT_RT5651_IN1_IN2_MAP), }, {} }; +/* + * Note this MUST be called before snd_soc_register_card(), so that the props + * are in place before the codec component driver's probe function parses them. + */ +static int byt_rt5651_add_codec_device_props(const char *i2c_dev_name) +{ + struct property_entry props[MAX_NO_PROPS] = {}; + struct device *i2c_dev; + int ret, cnt = 0; + + i2c_dev = bus_find_device_by_name(&i2c_bus_type, NULL, i2c_dev_name); + if (!i2c_dev) + return -EPROBE_DEFER; + + props[cnt++] = PROPERTY_ENTRY_U32("realtek,jack-detect-source", + BYT_RT5651_JDSRC(byt_rt5651_quirk)); + + props[cnt++] = PROPERTY_ENTRY_U32("realtek,over-current-threshold-microamp", + BYT_RT5651_OVCD_TH(byt_rt5651_quirk) * 100); + + props[cnt++] = PROPERTY_ENTRY_U32("realtek,over-current-scale-factor", + BYT_RT5651_OVCD_SF(byt_rt5651_quirk)); + + if (byt_rt5651_quirk & BYT_RT5651_DMIC_EN) + props[cnt++] = PROPERTY_ENTRY_BOOL("realtek,dmic-en"); + + ret = device_add_properties(i2c_dev, props); + put_device(i2c_dev); + + return ret; +} + static int byt_rt5651_init(struct snd_soc_pcm_runtime *runtime) { struct snd_soc_card *card = runtime->card; - struct snd_soc_codec *codec = runtime->codec; + struct snd_soc_component *codec = runtime->codec_dai->component; struct byt_rt5651_private *priv = snd_soc_card_get_drvdata(card); const struct snd_soc_dapm_route *custom_map; int num_routes; @@ -304,6 +457,11 @@ static int byt_rt5651_init(struct snd_soc_pcm_runtime *runtime) card->dapm.idle_bias_off = true; + /* Start with RC clk for jack-detect (we disable MCLK below) */ + if (byt_rt5651_quirk & BYT_RT5651_MCLK_EN) + snd_soc_component_update_bits(codec, RT5651_GLB_CLK, + RT5651_SCLK_SRC_MASK, RT5651_SCLK_SRC_RCCLK); + switch (BYT_RT5651_MAP(byt_rt5651_quirk)) { case BYT_RT5651_IN1_MAP: custom_map = byt_rt5651_intmic_in1_map; @@ -317,9 +475,13 @@ static int byt_rt5651_init(struct snd_soc_pcm_runtime *runtime) custom_map = byt_rt5651_intmic_in1_in2_map; num_routes = ARRAY_SIZE(byt_rt5651_intmic_in1_in2_map); break; - case BYT_RT5651_IN3_MAP: - custom_map = byt_rt5651_intmic_in3_map; - num_routes = ARRAY_SIZE(byt_rt5651_intmic_in3_map); + case BYT_RT5651_IN1_HS_IN3_MAP: + custom_map = byt_rt5651_intmic_in1_hs_in3_map; + num_routes = ARRAY_SIZE(byt_rt5651_intmic_in1_hs_in3_map); + break; + case BYT_RT5651_IN2_HS_IN3_MAP: + custom_map = byt_rt5651_intmic_in2_hs_in3_map; + num_routes = ARRAY_SIZE(byt_rt5651_intmic_in2_hs_in3_map); break; default: custom_map = byt_rt5651_intmic_dmic_map; @@ -329,6 +491,26 @@ static int byt_rt5651_init(struct snd_soc_pcm_runtime *runtime) if (ret) return ret; + if (byt_rt5651_quirk & BYT_RT5651_SSP2_AIF2) { + ret = snd_soc_dapm_add_routes(&card->dapm, + byt_rt5651_ssp2_aif2_map, + ARRAY_SIZE(byt_rt5651_ssp2_aif2_map)); + } else if (byt_rt5651_quirk & BYT_RT5651_SSP0_AIF1) { + ret = snd_soc_dapm_add_routes(&card->dapm, + byt_rt5651_ssp0_aif1_map, + ARRAY_SIZE(byt_rt5651_ssp0_aif1_map)); + } else if (byt_rt5651_quirk & BYT_RT5651_SSP0_AIF2) { + ret = snd_soc_dapm_add_routes(&card->dapm, + byt_rt5651_ssp0_aif2_map, + ARRAY_SIZE(byt_rt5651_ssp0_aif2_map)); + } else { + ret = snd_soc_dapm_add_routes(&card->dapm, + byt_rt5651_ssp2_aif1_map, + ARRAY_SIZE(byt_rt5651_ssp2_aif1_map)); + } + if (ret) + return ret; + ret = snd_soc_add_card_controls(card, byt_rt5651_controls, ARRAY_SIZE(byt_rt5651_controls)); if (ret) { @@ -362,17 +544,21 @@ static int byt_rt5651_init(struct snd_soc_pcm_runtime *runtime) dev_err(card->dev, "unable to set MCLK rate\n"); } - ret = snd_soc_card_jack_new(runtime->card, "Headset", + if (BYT_RT5651_JDSRC(byt_rt5651_quirk)) { + ret = snd_soc_card_jack_new(runtime->card, "Headset", SND_JACK_HEADSET, &priv->jack, bytcr_jack_pins, ARRAY_SIZE(bytcr_jack_pins)); - if (ret) { - dev_err(runtime->dev, "Headset jack creation failed %d\n", ret); - return ret; - } + if (ret) { + dev_err(runtime->dev, "jack creation failed %d\n", ret); + return ret; + } - rt5651_set_jack_detect(codec, &priv->jack); + ret = snd_soc_component_set_jack(codec, &priv->jack, NULL); + if (ret) + return ret; + } - return ret; + return 0; } static const struct snd_soc_pcm_stream byt_rt5651_dai_params = { @@ -390,18 +576,26 @@ static int byt_rt5651_codec_fixup(struct snd_soc_pcm_runtime *rtd, SNDRV_PCM_HW_PARAM_RATE); struct snd_interval *channels = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); - int ret; + int ret, bits; - /* The DSP will covert the FE rate to 48k, stereo, 24bits */ + /* The DSP will covert the FE rate to 48k, stereo */ rate->min = rate->max = 48000; channels->min = channels->max = 2; - /* set SSP2 to 24-bit */ - params_set_format(params, SNDRV_PCM_FORMAT_S24_LE); + if ((byt_rt5651_quirk & BYT_RT5651_SSP0_AIF1) || + (byt_rt5651_quirk & BYT_RT5651_SSP0_AIF2)) { + /* set SSP0 to 16-bit */ + params_set_format(params, SNDRV_PCM_FORMAT_S16_LE); + bits = 16; + } else { + /* set SSP2 to 24-bit */ + params_set_format(params, SNDRV_PCM_FORMAT_S24_LE); + bits = 24; + } /* * Default mode for SSP configuration is TDM 4 slot, override config - * with explicit setting to I2S 2ch 24-bit. The word length is set with + * with explicit setting to I2S 2ch. The word length is set with * dai_set_tdm_slot() since there is no other API exposed */ ret = snd_soc_dai_set_fmt(rtd->cpu_dai, @@ -415,7 +609,7 @@ static int byt_rt5651_codec_fixup(struct snd_soc_pcm_runtime *rtd, return ret; } - ret = snd_soc_dai_set_tdm_slot(rtd->cpu_dai, 0x3, 0x3, 2, 24); + ret = snd_soc_dai_set_tdm_slot(rtd->cpu_dai, 0x3, 0x3, 2, bits); if (ret < 0) { dev_err(rtd->dev, "can't set I2S config, err %d\n", ret); return ret; @@ -510,12 +704,32 @@ static struct snd_soc_card byt_rt5651_card = { }; static char byt_rt5651_codec_name[SND_ACPI_I2C_ID_LEN]; +static char byt_rt5651_codec_aif_name[12]; /* = "rt5651-aif[1|2]" */ +static char byt_rt5651_cpu_dai_name[10]; /* = "ssp[0|2]-port" */ + +static bool is_valleyview(void) +{ + static const struct x86_cpu_id cpu_ids[] = { + { X86_VENDOR_INTEL, 6, 55 }, /* Valleyview, Bay Trail */ + {} + }; + + if (!x86_match_cpu(cpu_ids)) + return false; + return true; +} + +struct acpi_chan_package { /* ACPICA seems to require 64 bit integers */ + u64 aif_value; /* 1: AIF1, 2: AIF2 */ + u64 mclock_value; /* usually 25MHz (0x17d7940), ignored */ +}; static int snd_byt_rt5651_mc_probe(struct platform_device *pdev) { struct byt_rt5651_private *priv; struct snd_soc_acpi_mach *mach; const char *i2c_name = NULL; + bool is_bytcr = false; int ret_val = 0; int dai_index = 0; int i; @@ -540,17 +754,105 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev) /* fixup codec name based on HID */ i2c_name = acpi_dev_get_first_match_name(mach->id, NULL, -1); - if (i2c_name) { - snprintf(byt_rt5651_codec_name, sizeof(byt_rt5651_codec_name), - "%s%s", "i2c-", i2c_name); + if (!i2c_name) { + dev_err(&pdev->dev, "Error cannot find '%s' dev\n", mach->id); + return -ENODEV; + } + snprintf(byt_rt5651_codec_name, sizeof(byt_rt5651_codec_name), + "%s%s", "i2c-", i2c_name); + byt_rt5651_dais[dai_index].codec_name = byt_rt5651_codec_name; - byt_rt5651_dais[dai_index].codec_name = byt_rt5651_codec_name; + /* + * swap SSP0 if bytcr is detected + * (will be overridden if DMI quirk is detected) + */ + if (is_valleyview()) { + struct sst_platform_info *p_info = mach->pdata; + const struct sst_res_info *res_info = p_info->res_info; + + if (res_info->acpi_ipc_irq_index == 0) + is_bytcr = true; + } + + if (is_bytcr) { + /* + * Baytrail CR platforms may have CHAN package in BIOS, try + * to find relevant routing quirk based as done on Windows + * platforms. We have to read the information directly from the + * BIOS, at this stage the card is not created and the links + * with the codec driver/pdata are non-existent + */ + + struct acpi_chan_package chan_package; + + /* format specified: 2 64-bit integers */ + struct acpi_buffer format = {sizeof("NN"), "NN"}; + struct acpi_buffer state = {0, NULL}; + struct snd_soc_acpi_package_context pkg_ctx; + bool pkg_found = false; + + state.length = sizeof(chan_package); + state.pointer = &chan_package; + + pkg_ctx.name = "CHAN"; + pkg_ctx.length = 2; + pkg_ctx.format = &format; + pkg_ctx.state = &state; + pkg_ctx.data_valid = false; + + pkg_found = snd_soc_acpi_find_package_from_hid(mach->id, + &pkg_ctx); + if (pkg_found) { + if (chan_package.aif_value == 1) { + dev_info(&pdev->dev, "BIOS Routing: AIF1 connected\n"); + byt_rt5651_quirk |= BYT_RT5651_SSP0_AIF1; + } else if (chan_package.aif_value == 2) { + dev_info(&pdev->dev, "BIOS Routing: AIF2 connected\n"); + byt_rt5651_quirk |= BYT_RT5651_SSP0_AIF2; + } else { + dev_info(&pdev->dev, "BIOS Routing isn't valid, ignored\n"); + pkg_found = false; + } + } + + if (!pkg_found) { + /* no BIOS indications, assume SSP0-AIF2 connection */ + byt_rt5651_quirk |= BYT_RT5651_SSP0_AIF2; + } } /* check quirks before creating card */ dmi_check_system(byt_rt5651_quirk_table); + + /* Must be called before register_card, also see declaration comment. */ + ret_val = byt_rt5651_add_codec_device_props(byt_rt5651_codec_name); + if (ret_val) + return ret_val; + log_quirks(&pdev->dev); + if ((byt_rt5651_quirk & BYT_RT5651_SSP2_AIF2) || + (byt_rt5651_quirk & BYT_RT5651_SSP0_AIF2)) { + /* fixup codec aif name */ + snprintf(byt_rt5651_codec_aif_name, + sizeof(byt_rt5651_codec_aif_name), + "%s", "rt5651-aif2"); + + byt_rt5651_dais[dai_index].codec_dai_name = + byt_rt5651_codec_aif_name; + } + + if ((byt_rt5651_quirk & BYT_RT5651_SSP0_AIF1) || + (byt_rt5651_quirk & BYT_RT5651_SSP0_AIF2)) { + /* fixup cpu dai name name */ + snprintf(byt_rt5651_cpu_dai_name, + sizeof(byt_rt5651_cpu_dai_name), + "%s", "ssp0-port"); + + byt_rt5651_dais[dai_index].cpu_dai_name = + byt_rt5651_cpu_dai_name; + } + if (byt_rt5651_quirk & BYT_RT5651_MCLK_EN) { priv->mclk = devm_clk_get(&pdev->dev, "pmc_plt_clk_3"); if (IS_ERR(priv->mclk)) { diff --git a/sound/soc/intel/boards/cht_bsw_nau8824.c b/sound/soc/intel/boards/cht_bsw_nau8824.c new file mode 100644 index 000000000000..680f2b3a24f9 --- /dev/null +++ b/sound/soc/intel/boards/cht_bsw_nau8824.c @@ -0,0 +1,282 @@ +/* + * cht-bsw-nau8824.c - ASoc Machine driver for Intel Cherryview-based + * platforms Cherrytrail and Braswell, with nau8824 codec. + * + * Copyright (C) 2018 Intel Corp + * Copyright (C) 2018 Nuvoton Technology Corp + * + * Author: Wang, Joseph C <joequant@gmail.com> + * Co-author: John Hsu <KCHSU0@nuvoton.com> + * This file is based on cht_bsw_rt5672.c and cht-bsw-max98090.c + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ + +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/slab.h> +#include <sound/pcm.h> +#include <sound/pcm_params.h> +#include <sound/soc.h> +#include <sound/jack.h> +#include <linux/input.h> +#include "../atom/sst-atom-controls.h" +#include "../../codecs/nau8824.h" + +struct cht_mc_private { + struct snd_soc_jack jack; +}; + +static struct snd_soc_jack_pin cht_bsw_jack_pins[] = { + { + .pin = "Headphone", + .mask = SND_JACK_HEADPHONE, + }, + { + .pin = "Headset Mic", + .mask = SND_JACK_MICROPHONE, + }, +}; + +static const struct snd_soc_dapm_widget cht_dapm_widgets[] = { + SND_SOC_DAPM_HP("Headphone", NULL), + SND_SOC_DAPM_MIC("Headset Mic", NULL), + SND_SOC_DAPM_MIC("Int Mic", NULL), + SND_SOC_DAPM_SPK("Ext Spk", NULL), +}; + +static const struct snd_soc_dapm_route cht_audio_map[] = { + {"Ext Spk", NULL, "SPKOUTL"}, + {"Ext Spk", NULL, "SPKOUTR"}, + {"Headphone", NULL, "HPOL"}, + {"Headphone", NULL, "HPOR"}, + {"MIC1", NULL, "Int Mic"}, + {"MIC2", NULL, "Int Mic"}, + {"HSMIC1", NULL, "Headset Mic"}, + {"HSMIC2", NULL, "Headset Mic"}, + {"Playback", NULL, "ssp2 Tx"}, + {"ssp2 Tx", NULL, "codec_out0"}, + {"ssp2 Tx", NULL, "codec_out1"}, + {"codec_in0", NULL, "ssp2 Rx" }, + {"codec_in1", NULL, "ssp2 Rx" }, + {"ssp2 Rx", NULL, "Capture"}, +}; + +static const struct snd_kcontrol_new cht_mc_controls[] = { + SOC_DAPM_PIN_SWITCH("Headphone"), + SOC_DAPM_PIN_SWITCH("Headset Mic"), + SOC_DAPM_PIN_SWITCH("Int Mic"), + SOC_DAPM_PIN_SWITCH("Ext Spk"), +}; + +static int cht_aif1_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_dai *codec_dai = rtd->codec_dai; + int ret; + + ret = snd_soc_dai_set_sysclk(codec_dai, NAU8824_CLK_FLL_FS, 0, + SND_SOC_CLOCK_IN); + if (ret < 0) { + dev_err(codec_dai->dev, "can't set FS clock %d\n", ret); + return ret; + } + ret = snd_soc_dai_set_pll(codec_dai, 0, 0, params_rate(params), + params_rate(params) * 256); + if (ret < 0) { + dev_err(codec_dai->dev, "can't set FLL: %d\n", ret); + return ret; + } + + return 0; +} + +static int cht_codec_init(struct snd_soc_pcm_runtime *runtime) +{ + struct cht_mc_private *ctx = snd_soc_card_get_drvdata(runtime->card); + struct snd_soc_jack *jack = &ctx->jack; + struct snd_soc_dai *codec_dai = runtime->codec_dai; + struct snd_soc_component *component = codec_dai->component; + int ret, jack_type; + + /* TDM 4 slots 24 bit, set Rx & Tx bitmask to 4 active slots */ + ret = snd_soc_dai_set_tdm_slot(codec_dai, 0xf, 0x1, 4, 24); + if (ret < 0) { + dev_err(runtime->dev, "can't set codec TDM slot %d\n", ret); + return ret; + } + + /* NAU88L24 supports 4 butons headset detection + * KEY_MEDIA + * KEY_VOICECOMMAND + * KEY_VOLUMEUP + * KEY_VOLUMEDOWN + */ + jack_type = SND_JACK_HEADPHONE | SND_JACK_BTN_0 | SND_JACK_BTN_1 | + SND_JACK_BTN_2 | SND_JACK_BTN_3; + ret = snd_soc_card_jack_new(runtime->card, "Headset", jack_type, jack, + cht_bsw_jack_pins, ARRAY_SIZE(cht_bsw_jack_pins)); + if (ret) { + dev_err(runtime->dev, + "Headset Jack creation failed %d\n", ret); + return ret; + } + snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_MEDIA); + snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOICECOMMAND); + snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEUP); + snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN); + + nau8824_enable_jack_detect(component, jack); + + return ret; +} + +static int cht_codec_fixup(struct snd_soc_pcm_runtime *rtd, + struct snd_pcm_hw_params *params) +{ + struct snd_interval *rate = hw_param_interval(params, + SNDRV_PCM_HW_PARAM_RATE); + struct snd_interval *channels = hw_param_interval(params, + SNDRV_PCM_HW_PARAM_CHANNELS); + struct snd_mask *fmt = + hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); + + /* The DSP will covert the FE rate to 48k, stereo, 24bits */ + rate->min = rate->max = 48000; + channels->min = channels->max = 2; + + /* set SSP2 to 24-bit */ + snd_mask_none(fmt); + params_set_format(params, SNDRV_PCM_FORMAT_S24_LE); + + return 0; +} + +static int cht_aif1_startup(struct snd_pcm_substream *substream) +{ + return snd_pcm_hw_constraint_single(substream->runtime, + SNDRV_PCM_HW_PARAM_RATE, 48000); +} + +static const struct snd_soc_ops cht_aif1_ops = { + .startup = cht_aif1_startup, +}; + +static const struct snd_soc_ops cht_be_ssp2_ops = { + .hw_params = cht_aif1_hw_params, +}; + +static struct snd_soc_dai_link cht_dailink[] = { + /* Front End DAI links */ + [MERR_DPCM_AUDIO] = { + .name = "Audio Port", + .stream_name = "Audio", + .cpu_dai_name = "media-cpu-dai", + .codec_dai_name = "snd-soc-dummy-dai", + .codec_name = "snd-soc-dummy", + .platform_name = "sst-mfld-platform", + .nonatomic = true, + .dynamic = 1, + .dpcm_playback = 1, + .dpcm_capture = 1, + .ops = &cht_aif1_ops, + }, + [MERR_DPCM_DEEP_BUFFER] = { + .name = "Deep-Buffer Audio Port", + .stream_name = "Deep-Buffer Audio", + .cpu_dai_name = "deepbuffer-cpu-dai", + .codec_dai_name = "snd-soc-dummy-dai", + .codec_name = "snd-soc-dummy", + .platform_name = "sst-mfld-platform", + .nonatomic = true, + .dynamic = 1, + .dpcm_playback = 1, + .ops = &cht_aif1_ops, + }, + [MERR_DPCM_COMPR] = { + .name = "Compressed Port", + .stream_name = "Compress", + .cpu_dai_name = "compress-cpu-dai", + .codec_dai_name = "snd-soc-dummy-dai", + .codec_name = "snd-soc-dummy", + .platform_name = "sst-mfld-platform", + }, + /* Back End DAI links */ + { + /* SSP2 - Codec */ + .name = "SSP2-Codec", + .id = 1, + .cpu_dai_name = "ssp2-port", + .platform_name = "sst-mfld-platform", + .no_pcm = 1, + .codec_dai_name = NAU8824_CODEC_DAI, + .codec_name = "i2c-10508824:00", + .dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_IB_NF + | SND_SOC_DAIFMT_CBS_CFS, + .init = cht_codec_init, + .be_hw_params_fixup = cht_codec_fixup, + .dpcm_playback = 1, + .dpcm_capture = 1, + .ops = &cht_be_ssp2_ops, + }, +}; + +/* SoC card */ +static struct snd_soc_card snd_soc_card_cht = { + .name = "chtnau8824", + .owner = THIS_MODULE, + .dai_link = cht_dailink, + .num_links = ARRAY_SIZE(cht_dailink), + .dapm_widgets = cht_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(cht_dapm_widgets), + .dapm_routes = cht_audio_map, + .num_dapm_routes = ARRAY_SIZE(cht_audio_map), + .controls = cht_mc_controls, + .num_controls = ARRAY_SIZE(cht_mc_controls), +}; + +static int snd_cht_mc_probe(struct platform_device *pdev) +{ + struct cht_mc_private *drv; + int ret_val; + + drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_ATOMIC); + if (!drv) + return -ENOMEM; + snd_soc_card_set_drvdata(&snd_soc_card_cht, drv); + + /* register the soc card */ + snd_soc_card_cht.dev = &pdev->dev; + ret_val = devm_snd_soc_register_card(&pdev->dev, &snd_soc_card_cht); + if (ret_val) { + dev_err(&pdev->dev, + "snd_soc_register_card failed %d\n", ret_val); + return ret_val; + } + platform_set_drvdata(pdev, &snd_soc_card_cht); + + return ret_val; +} + +static struct platform_driver snd_cht_mc_driver = { + .driver = { + .name = "cht-bsw-nau8824", + }, + .probe = snd_cht_mc_probe, +}; + +module_platform_driver(snd_cht_mc_driver); + +MODULE_DESCRIPTION("ASoC Intel(R) Baytrail CR Machine driver"); +MODULE_AUTHOR("Wang, Joseph C <joequant@gmail.com>"); +MODULE_AUTHOR("John Hsu <KCHSU0@nuvoton.com>"); +MODULE_LICENSE("GPL v2"); +MODULE_ALIAS("platform:cht-bsw-nau8824"); diff --git a/sound/soc/intel/boards/cht_bsw_rt5645.c b/sound/soc/intel/boards/cht_bsw_rt5645.c index 31641aab62cd..49ba1a956a06 100644 --- a/sound/soc/intel/boards/cht_bsw_rt5645.c +++ b/sound/soc/intel/boards/cht_bsw_rt5645.c @@ -252,14 +252,14 @@ static int cht_codec_init(struct snd_soc_pcm_runtime *runtime) { struct snd_soc_card *card = runtime->card; struct cht_mc_private *ctx = snd_soc_card_get_drvdata(runtime->card); - struct snd_soc_codec *codec = runtime->codec; + struct snd_soc_component *component = runtime->codec_dai->component; int jack_type; int ret; if ((cht_rt5645_quirk & CHT_RT5645_SSP2_AIF2) || (cht_rt5645_quirk & CHT_RT5645_SSP0_AIF2)) { /* Select clk_i2s2_asrc as ASRC clock source */ - rt5645_sel_asrc_clk_src(codec, + rt5645_sel_asrc_clk_src(component, RT5645_DA_STEREO_FILTER | RT5645_DA_MONO_L_FILTER | RT5645_DA_MONO_R_FILTER | @@ -267,7 +267,7 @@ static int cht_codec_init(struct snd_soc_pcm_runtime *runtime) RT5645_CLK_SEL_I2S2_ASRC); } else { /* Select clk_i2s1_asrc as ASRC clock source */ - rt5645_sel_asrc_clk_src(codec, + rt5645_sel_asrc_clk_src(component, RT5645_DA_STEREO_FILTER | RT5645_DA_MONO_L_FILTER | RT5645_DA_MONO_R_FILTER | @@ -310,7 +310,7 @@ static int cht_codec_init(struct snd_soc_pcm_runtime *runtime) return ret; } - rt5645_set_jack_detect(codec, &ctx->jack, &ctx->jack, &ctx->jack); + rt5645_set_jack_detect(component, &ctx->jack, &ctx->jack, &ctx->jack); /* diff --git a/sound/soc/intel/boards/haswell.c b/sound/soc/intel/boards/haswell.c index 3c5160779204..eab1f439dd3f 100644 --- a/sound/soc/intel/boards/haswell.c +++ b/sound/soc/intel/boards/haswell.c @@ -87,7 +87,8 @@ static const struct snd_soc_ops haswell_rt5640_ops = { static int haswell_rtd_init(struct snd_soc_pcm_runtime *rtd) { - struct sst_pdata *pdata = dev_get_platdata(rtd->platform->dev); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_pdata *pdata = dev_get_platdata(component->dev); struct sst_hsw *haswell = pdata->dsp; int ret; diff --git a/sound/soc/intel/boards/kbl_da7219_max98357a.c b/sound/soc/intel/boards/kbl_da7219_max98357a.c new file mode 100644 index 000000000000..e84baafd5f63 --- /dev/null +++ b/sound/soc/intel/boards/kbl_da7219_max98357a.c @@ -0,0 +1,613 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright(c) 2017-18 Intel Corporation. + +/* + * Intel Kabylake I2S Machine Driver with MAX98357A & DA7219 Codecs + * + * Modified from: + * Intel Kabylake I2S Machine driver supporting MAXIM98927 and + * RT5663 codecs + */ + +#include <linux/input.h> +#include <linux/module.h> +#include <linux/platform_device.h> +#include <sound/core.h> +#include <sound/jack.h> +#include <sound/pcm.h> +#include <sound/pcm_params.h> +#include <sound/soc.h> +#include "../../codecs/da7219.h" +#include "../../codecs/hdac_hdmi.h" +#include "../skylake/skl.h" +#include "../../codecs/da7219-aad.h" + +#define KBL_DIALOG_CODEC_DAI "da7219-hifi" +#define KBL_MAXIM_CODEC_DAI "HiFi" +#define MAXIM_DEV0_NAME "MX98357A:00" +#define DUAL_CHANNEL 2 +#define QUAD_CHANNEL 4 + +static struct snd_soc_card *kabylake_audio_card; +static struct snd_soc_jack skylake_hdmi[3]; + +struct kbl_hdmi_pcm { + struct list_head head; + struct snd_soc_dai *codec_dai; + int device; +}; + +struct kbl_codec_private { + struct snd_soc_jack kabylake_headset; + struct list_head hdmi_pcm_list; +}; + +enum { + KBL_DPCM_AUDIO_PB = 0, + KBL_DPCM_AUDIO_CP, + KBL_DPCM_AUDIO_DMIC_CP, + KBL_DPCM_AUDIO_HDMI1_PB, + KBL_DPCM_AUDIO_HDMI2_PB, + KBL_DPCM_AUDIO_HDMI3_PB, +}; + +static int platform_clock_control(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *k, int event) +{ + struct snd_soc_dapm_context *dapm = w->dapm; + struct snd_soc_card *card = dapm->card; + struct snd_soc_dai *codec_dai; + int ret = 0; + + codec_dai = snd_soc_card_get_codec_dai(card, KBL_DIALOG_CODEC_DAI); + if (!codec_dai) { + dev_err(card->dev, "Codec dai not found; Unable to set/unset codec pll\n"); + return -EIO; + } + + /* Configure sysclk for codec */ + ret = snd_soc_dai_set_sysclk(codec_dai, DA7219_CLKSRC_MCLK, 24576000, + SND_SOC_CLOCK_IN); + if (ret) { + dev_err(card->dev, "can't set codec sysclk configuration\n"); + return ret; + } + + if (SND_SOC_DAPM_EVENT_OFF(event)) { + ret = snd_soc_dai_set_pll(codec_dai, 0, + DA7219_SYSCLK_MCLK, 0, 0); + if (ret) + dev_err(card->dev, "failed to stop PLL: %d\n", ret); + } else if (SND_SOC_DAPM_EVENT_ON(event)) { + ret = snd_soc_dai_set_pll(codec_dai, 0, DA7219_SYSCLK_PLL_SRM, + 0, DA7219_PLL_FREQ_OUT_98304); + if (ret) + dev_err(card->dev, "failed to start PLL: %d\n", ret); + } + + return ret; +} + +static const struct snd_kcontrol_new kabylake_controls[] = { + SOC_DAPM_PIN_SWITCH("Headphone Jack"), + SOC_DAPM_PIN_SWITCH("Headset Mic"), + SOC_DAPM_PIN_SWITCH("Spk"), +}; + +static const struct snd_soc_dapm_widget kabylake_widgets[] = { + SND_SOC_DAPM_HP("Headphone Jack", NULL), + SND_SOC_DAPM_MIC("Headset Mic", NULL), + SND_SOC_DAPM_SPK("Spk", NULL), + SND_SOC_DAPM_MIC("SoC DMIC", NULL), + SND_SOC_DAPM_SPK("DP", NULL), + SND_SOC_DAPM_SPK("HDMI", NULL), + SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0, + platform_clock_control, SND_SOC_DAPM_PRE_PMU | + SND_SOC_DAPM_POST_PMD), +}; + +static const struct snd_soc_dapm_route kabylake_map[] = { + { "Headphone Jack", NULL, "HPL" }, + { "Headphone Jack", NULL, "HPR" }, + + /* speaker */ + { "Spk", NULL, "Speaker" }, + + /* other jacks */ + { "MIC", NULL, "Headset Mic" }, + { "DMic", NULL, "SoC DMIC" }, + + { "HDMI", NULL, "hif5 Output" }, + { "DP", NULL, "hif6 Output" }, + + /* CODEC BE connections */ + { "HiFi Playback", NULL, "ssp0 Tx" }, + { "ssp0 Tx", NULL, "codec0_out" }, + + { "Playback", NULL, "ssp1 Tx" }, + { "ssp1 Tx", NULL, "codec1_out" }, + + { "codec0_in", NULL, "ssp1 Rx" }, + { "ssp1 Rx", NULL, "Capture" }, + + /* DMIC */ + { "dmic01_hifi", NULL, "DMIC01 Rx" }, + { "DMIC01 Rx", NULL, "DMIC AIF" }, + + { "hifi1", NULL, "iDisp1 Tx" }, + { "iDisp1 Tx", NULL, "iDisp1_out" }, + { "hifi2", NULL, "iDisp2 Tx" }, + { "iDisp2 Tx", NULL, "iDisp2_out" }, + { "hifi3", NULL, "iDisp3 Tx"}, + { "iDisp3 Tx", NULL, "iDisp3_out"}, + + { "Headphone Jack", NULL, "Platform Clock" }, + { "Headset Mic", NULL, "Platform Clock" }, +}; + +static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd, + struct snd_pcm_hw_params *params) +{ + struct snd_interval *rate = hw_param_interval(params, + SNDRV_PCM_HW_PARAM_RATE); + struct snd_interval *channels = hw_param_interval(params, + SNDRV_PCM_HW_PARAM_CHANNELS); + struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); + + /* The ADSP will convert the FE rate to 48k, stereo */ + rate->min = rate->max = 48000; + channels->min = channels->max = DUAL_CHANNEL; + + /* set SSP to 24 bit */ + snd_mask_none(fmt); + snd_mask_set(fmt, SNDRV_PCM_FORMAT_S24_LE); + + return 0; +} + +static int kabylake_da7219_codec_init(struct snd_soc_pcm_runtime *rtd) +{ + struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(rtd->card); + struct snd_soc_component *component = rtd->codec_dai->component; + struct snd_soc_jack *jack; + int ret; + + /* + * Headset buttons map to the google Reference headset. + * These can be configured by userspace. + */ + ret = snd_soc_card_jack_new(kabylake_audio_card, "Headset Jack", + SND_JACK_HEADSET | SND_JACK_BTN_0 | SND_JACK_BTN_1 | + SND_JACK_BTN_2 | SND_JACK_BTN_3 | SND_JACK_LINEOUT, + &ctx->kabylake_headset, NULL, 0); + if (ret) { + dev_err(rtd->dev, "Headset Jack creation failed: %d\n", ret); + return ret; + } + + jack = &ctx->kabylake_headset; + + snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_MEDIA); + snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOLUMEUP); + snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEDOWN); + snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOICECOMMAND); + da7219_aad_jack_det(component, &ctx->kabylake_headset); + + ret = snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC"); + if (ret) + dev_err(rtd->dev, "SoC DMIC - Ignore suspend failed %d\n", ret); + + return ret; +} + +static int kabylake_hdmi_init(struct snd_soc_pcm_runtime *rtd, int device) +{ + struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(rtd->card); + struct snd_soc_dai *dai = rtd->codec_dai; + struct kbl_hdmi_pcm *pcm; + + pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL); + if (!pcm) + return -ENOMEM; + + pcm->device = device; + pcm->codec_dai = dai; + + list_add_tail(&pcm->head, &ctx->hdmi_pcm_list); + + return 0; +} + +static int kabylake_hdmi1_init(struct snd_soc_pcm_runtime *rtd) +{ + return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_HDMI1_PB); +} + +static int kabylake_hdmi2_init(struct snd_soc_pcm_runtime *rtd) +{ + return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_HDMI2_PB); +} + +static int kabylake_hdmi3_init(struct snd_soc_pcm_runtime *rtd) +{ + return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_HDMI3_PB); +} + +static int kabylake_da7219_fe_init(struct snd_soc_pcm_runtime *rtd) +{ + struct snd_soc_dapm_context *dapm; + struct snd_soc_component *component = rtd->cpu_dai->component; + + dapm = snd_soc_component_get_dapm(component); + snd_soc_dapm_ignore_suspend(dapm, "Reference Capture"); + + return 0; +} + +static const unsigned int rates[] = { + 48000, +}; + +static const struct snd_pcm_hw_constraint_list constraints_rates = { + .count = ARRAY_SIZE(rates), + .list = rates, + .mask = 0, +}; + +static const unsigned int channels[] = { + DUAL_CHANNEL, +}; + +static const struct snd_pcm_hw_constraint_list constraints_channels = { + .count = ARRAY_SIZE(channels), + .list = channels, + .mask = 0, +}; + +static unsigned int channels_quad[] = { + QUAD_CHANNEL, +}; + +static struct snd_pcm_hw_constraint_list constraints_channels_quad = { + .count = ARRAY_SIZE(channels_quad), + .list = channels_quad, + .mask = 0, +}; + +static int kbl_fe_startup(struct snd_pcm_substream *substream) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + + /* + * On this platform for PCM device we support, + * 48Khz + * stereo + * 16 bit audio + */ + + runtime->hw.channels_max = DUAL_CHANNEL; + snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, + &constraints_channels); + + runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE; + snd_pcm_hw_constraint_msbits(runtime, 0, 16, 16); + + snd_pcm_hw_constraint_list(runtime, 0, + SNDRV_PCM_HW_PARAM_RATE, &constraints_rates); + + return 0; +} + +static const struct snd_soc_ops kabylake_da7219_fe_ops = { + .startup = kbl_fe_startup, +}; + +static int kabylake_dmic_fixup(struct snd_soc_pcm_runtime *rtd, + struct snd_pcm_hw_params *params) +{ + struct snd_interval *channels = hw_param_interval(params, + SNDRV_PCM_HW_PARAM_CHANNELS); + + /* + * set BE channel constraint as user FE channels + */ + + if (params_channels(params) == 2) + channels->min = channels->max = 2; + else + channels->min = channels->max = 4; + + return 0; +} + +static int kabylake_dmic_startup(struct snd_pcm_substream *substream) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + + runtime->hw.channels_min = runtime->hw.channels_max = QUAD_CHANNEL; + snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, + &constraints_channels_quad); + + return snd_pcm_hw_constraint_list(substream->runtime, 0, + SNDRV_PCM_HW_PARAM_RATE, &constraints_rates); +} + +static struct snd_soc_ops kabylake_dmic_ops = { + .startup = kabylake_dmic_startup, +}; + +static const unsigned int rates_16000[] = { + 16000, +}; + +static const struct snd_pcm_hw_constraint_list constraints_16000 = { + .count = ARRAY_SIZE(rates_16000), + .list = rates_16000, +}; + +static const unsigned int ch_mono[] = { + 1, +}; + +/* kabylake digital audio interface glue - connects codec <--> CPU */ +static struct snd_soc_dai_link kabylake_dais[] = { + /* Front End DAI links */ + [KBL_DPCM_AUDIO_PB] = { + .name = "Kbl Audio Port", + .stream_name = "Audio", + .cpu_dai_name = "System Pin", + .platform_name = "0000:00:1f.3", + .dynamic = 1, + .codec_name = "snd-soc-dummy", + .codec_dai_name = "snd-soc-dummy-dai", + .nonatomic = 1, + .init = kabylake_da7219_fe_init, + .trigger = { + SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, + .dpcm_playback = 1, + .ops = &kabylake_da7219_fe_ops, + }, + [KBL_DPCM_AUDIO_CP] = { + .name = "Kbl Audio Capture Port", + .stream_name = "Audio Record", + .cpu_dai_name = "System Pin", + .platform_name = "0000:00:1f.3", + .dynamic = 1, + .codec_name = "snd-soc-dummy", + .codec_dai_name = "snd-soc-dummy-dai", + .nonatomic = 1, + .trigger = { + SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, + .dpcm_capture = 1, + }, + [KBL_DPCM_AUDIO_DMIC_CP] = { + .name = "Kbl Audio DMIC cap", + .stream_name = "dmiccap", + .cpu_dai_name = "DMIC Pin", + .codec_name = "snd-soc-dummy", + .codec_dai_name = "snd-soc-dummy-dai", + .platform_name = "0000:00:1f.3", + .init = NULL, + .dpcm_capture = 1, + .nonatomic = 1, + .dynamic = 1, + .ops = &kabylake_dmic_ops, + }, + [KBL_DPCM_AUDIO_HDMI1_PB] = { + .name = "Kbl HDMI Port1", + .stream_name = "Hdmi1", + .cpu_dai_name = "HDMI1 Pin", + .codec_name = "snd-soc-dummy", + .codec_dai_name = "snd-soc-dummy-dai", + .platform_name = "0000:00:1f.3", + .dpcm_playback = 1, + .init = NULL, + .trigger = { + SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, + .nonatomic = 1, + .dynamic = 1, + }, + [KBL_DPCM_AUDIO_HDMI2_PB] = { + .name = "Kbl HDMI Port2", + .stream_name = "Hdmi2", + .cpu_dai_name = "HDMI2 Pin", + .codec_name = "snd-soc-dummy", + .codec_dai_name = "snd-soc-dummy-dai", + .platform_name = "0000:00:1f.3", + .dpcm_playback = 1, + .init = NULL, + .trigger = { + SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, + .nonatomic = 1, + .dynamic = 1, + }, + [KBL_DPCM_AUDIO_HDMI3_PB] = { + .name = "Kbl HDMI Port3", + .stream_name = "Hdmi3", + .cpu_dai_name = "HDMI3 Pin", + .codec_name = "snd-soc-dummy", + .codec_dai_name = "snd-soc-dummy-dai", + .platform_name = "0000:00:1f.3", + .trigger = { + SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, + .dpcm_playback = 1, + .init = NULL, + .nonatomic = 1, + .dynamic = 1, + }, + + /* Back End DAI links */ + { + /* SSP0 - Codec */ + .name = "SSP0-Codec", + .id = 0, + .cpu_dai_name = "SSP0 Pin", + .platform_name = "0000:00:1f.3", + .no_pcm = 1, + .codec_name = MAXIM_DEV0_NAME, + .codec_dai_name = KBL_MAXIM_CODEC_DAI, + .dai_fmt = SND_SOC_DAIFMT_I2S | + SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBS_CFS, + .ignore_pmdown_time = 1, + .be_hw_params_fixup = kabylake_ssp_fixup, + .dpcm_playback = 1, + }, + { + /* SSP1 - Codec */ + .name = "SSP1-Codec", + .id = 1, + .cpu_dai_name = "SSP1 Pin", + .platform_name = "0000:00:1f.3", + .no_pcm = 1, + .codec_name = "i2c-DLGS7219:00", + .codec_dai_name = KBL_DIALOG_CODEC_DAI, + .init = kabylake_da7219_codec_init, + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBS_CFS, + .ignore_pmdown_time = 1, + .be_hw_params_fixup = kabylake_ssp_fixup, + .dpcm_playback = 1, + .dpcm_capture = 1, + }, + { + .name = "dmic01", + .id = 2, + .cpu_dai_name = "DMIC01 Pin", + .codec_name = "dmic-codec", + .codec_dai_name = "dmic-hifi", + .platform_name = "0000:00:1f.3", + .be_hw_params_fixup = kabylake_dmic_fixup, + .ignore_suspend = 1, + .dpcm_capture = 1, + .no_pcm = 1, + }, + { + .name = "iDisp1", + .id = 3, + .cpu_dai_name = "iDisp1 Pin", + .codec_name = "ehdaudio0D2", + .codec_dai_name = "intel-hdmi-hifi1", + .platform_name = "0000:00:1f.3", + .dpcm_playback = 1, + .init = kabylake_hdmi1_init, + .no_pcm = 1, + }, + { + .name = "iDisp2", + .id = 4, + .cpu_dai_name = "iDisp2 Pin", + .codec_name = "ehdaudio0D2", + .codec_dai_name = "intel-hdmi-hifi2", + .platform_name = "0000:00:1f.3", + .init = kabylake_hdmi2_init, + .dpcm_playback = 1, + .no_pcm = 1, + }, + { + .name = "iDisp3", + .id = 5, + .cpu_dai_name = "iDisp3 Pin", + .codec_name = "ehdaudio0D2", + .codec_dai_name = "intel-hdmi-hifi3", + .platform_name = "0000:00:1f.3", + .init = kabylake_hdmi3_init, + .dpcm_playback = 1, + .no_pcm = 1, + }, +}; + +#define NAME_SIZE 32 +static int kabylake_card_late_probe(struct snd_soc_card *card) +{ + struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(card); + struct kbl_hdmi_pcm *pcm; + struct snd_soc_component *component = NULL; + int err, i = 0; + char jack_name[NAME_SIZE]; + + list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { + component = pcm->codec_dai->component; + snprintf(jack_name, sizeof(jack_name), + "HDMI/DP, pcm=%d Jack", pcm->device); + err = snd_soc_card_jack_new(card, jack_name, + SND_JACK_AVOUT, &skylake_hdmi[i], + NULL, 0); + + if (err) + return err; + + err = hdac_hdmi_jack_init(pcm->codec_dai, pcm->device, + &skylake_hdmi[i]); + if (err < 0) + return err; + + i++; + + } + + if (!component) + return -EINVAL; + + return hdac_hdmi_jack_port_init(component, &card->dapm); +} + +/* kabylake audio machine driver for SPT + DA7219 */ +static struct snd_soc_card kabylake_audio_card_da7219_m98357a = { + .name = "kblda7219max", + .owner = THIS_MODULE, + .dai_link = kabylake_dais, + .num_links = ARRAY_SIZE(kabylake_dais), + .controls = kabylake_controls, + .num_controls = ARRAY_SIZE(kabylake_controls), + .dapm_widgets = kabylake_widgets, + .num_dapm_widgets = ARRAY_SIZE(kabylake_widgets), + .dapm_routes = kabylake_map, + .num_dapm_routes = ARRAY_SIZE(kabylake_map), + .fully_routed = true, + .late_probe = kabylake_card_late_probe, +}; + +static int kabylake_audio_probe(struct platform_device *pdev) +{ + struct kbl_codec_private *ctx; + + ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_ATOMIC); + if (!ctx) + return -ENOMEM; + + INIT_LIST_HEAD(&ctx->hdmi_pcm_list); + + kabylake_audio_card = + (struct snd_soc_card *)pdev->id_entry->driver_data; + + kabylake_audio_card->dev = &pdev->dev; + snd_soc_card_set_drvdata(kabylake_audio_card, ctx); + return devm_snd_soc_register_card(&pdev->dev, kabylake_audio_card); +} + +static const struct platform_device_id kbl_board_ids[] = { + { + .name = "kbl_da7219_max98357a", + .driver_data = + (kernel_ulong_t)&kabylake_audio_card_da7219_m98357a, + }, + { } +}; + +static struct platform_driver kabylake_audio = { + .probe = kabylake_audio_probe, + .driver = { + .name = "kbl_da7219_max98357a", + .pm = &snd_soc_pm_ops, + }, + .id_table = kbl_board_ids, +}; + +module_platform_driver(kabylake_audio) + +/* Module information */ +MODULE_DESCRIPTION("Audio Machine driver-DA7219 & MAX98357A in I2S mode"); +MODULE_AUTHOR("Naveen Manohar <naveen.m@intel.com>"); +MODULE_LICENSE("GPL v2"); +MODULE_ALIAS("platform:kbl_da7219_max98357a"); diff --git a/sound/soc/intel/boards/kbl_rt5663_max98927.c b/sound/soc/intel/boards/kbl_rt5663_max98927.c index f5df6bca3156..0e6b7e79441c 100644 --- a/sound/soc/intel/boards/kbl_rt5663_max98927.c +++ b/sound/soc/intel/boards/kbl_rt5663_max98927.c @@ -204,13 +204,18 @@ static const struct snd_soc_dapm_widget kabylake_5663_widgets[] = { SND_SOC_DAPM_MIC("Headset Mic", NULL), SND_SOC_DAPM_SPK("DP", NULL), SND_SOC_DAPM_SPK("HDMI", NULL), + SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0, + platform_clock_control, SND_SOC_DAPM_PRE_PMU | + SND_SOC_DAPM_POST_PMD), }; static const struct snd_soc_dapm_route kabylake_5663_map[] = { + { "Headphone Jack", NULL, "Platform Clock" }, { "Headphone Jack", NULL, "HPOL" }, { "Headphone Jack", NULL, "HPOR" }, /* other jacks */ + { "Headset Mic", NULL, "Platform Clock" }, { "IN1P", NULL, "Headset Mic" }, { "IN1N", NULL, "Headset Mic" }, @@ -272,7 +277,7 @@ static int kabylake_rt5663_codec_init(struct snd_soc_pcm_runtime *rtd) { int ret; struct kbl_rt5663_private *ctx = snd_soc_card_get_drvdata(rtd->card); - struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_component *component = rtd->codec_dai->component; struct snd_soc_jack *jack; /* @@ -294,7 +299,7 @@ static int kabylake_rt5663_codec_init(struct snd_soc_pcm_runtime *rtd) snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEUP); snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN); - rt5663_set_jack_detect(codec, &ctx->kabylake_headset); + rt5663_set_jack_detect(component, &ctx->kabylake_headset); return ret; } @@ -448,7 +453,7 @@ static int kabylake_rt5663_hw_params(struct snd_pcm_substream *substream, int ret; /* use ASRC for internal clocks, as PLL rate isn't multiple of BCLK */ - rt5663_sel_asrc_clk_src(codec_dai->codec, + rt5663_sel_asrc_clk_src(codec_dai->component, RT5663_DA_STEREO_FILTER | RT5663_AD_STEREO_FILTER, RT5663_CLK_SEL_I2S1_ASRC); @@ -898,12 +903,12 @@ static int kabylake_card_late_probe(struct snd_soc_card *card) { struct kbl_rt5663_private *ctx = snd_soc_card_get_drvdata(card); struct kbl_hdmi_pcm *pcm; - struct snd_soc_codec *codec = NULL; + struct snd_soc_component *component = NULL; int err, i = 0; char jack_name[NAME_SIZE]; list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { - codec = pcm->codec_dai->codec; + component = pcm->codec_dai->component; snprintf(jack_name, sizeof(jack_name), "HDMI/DP, pcm=%d Jack", pcm->device); err = snd_soc_card_jack_new(card, jack_name, @@ -921,10 +926,10 @@ static int kabylake_card_late_probe(struct snd_soc_card *card) i++; } - if (!codec) + if (!component) return -EINVAL; - return hdac_hdmi_jack_port_init(codec, &card->dapm); + return hdac_hdmi_jack_port_init(component, &card->dapm); } /* kabylake audio machine driver for SPT + RT5663 */ diff --git a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c index 90ea98f01c4c..69c3d8446f06 100644 --- a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c +++ b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c @@ -178,7 +178,7 @@ static int kabylake_rt5663_codec_init(struct snd_soc_pcm_runtime *rtd) { int ret; struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(rtd->card); - struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_component *component = rtd->codec_dai->component; struct snd_soc_jack *jack; /* @@ -200,7 +200,7 @@ static int kabylake_rt5663_codec_init(struct snd_soc_pcm_runtime *rtd) snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEUP); snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN); - rt5663_set_jack_detect(codec, &ctx->kabylake_headset); + rt5663_set_jack_detect(component, &ctx->kabylake_headset); ret = snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "DMIC"); if (ret) @@ -333,7 +333,7 @@ static int kabylake_rt5663_hw_params(struct snd_pcm_substream *substream, int ret; /* use ASRC for internal clocks, as PLL rate isn't multiple of BCLK */ - rt5663_sel_asrc_clk_src(codec_dai->codec, + rt5663_sel_asrc_clk_src(codec_dai->component, RT5663_DA_STEREO_FILTER | RT5663_AD_STEREO_FILTER, RT5663_CLK_SEL_I2S1_ASRC); @@ -599,12 +599,12 @@ static int kabylake_card_late_probe(struct snd_soc_card *card) { struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(card); struct kbl_hdmi_pcm *pcm; - struct snd_soc_codec *codec = NULL; + struct snd_soc_component *component = NULL; int err, i = 0; char jack_name[NAME_SIZE]; list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { - codec = pcm->codec_dai->codec; + component = pcm->codec_dai->component; snprintf(jack_name, sizeof(jack_name), "HDMI/DP,pcm=%d Jack", pcm->device); err = snd_soc_card_jack_new(card, jack_name, @@ -620,10 +620,10 @@ static int kabylake_card_late_probe(struct snd_soc_card *card) i++; } - if (!codec) + if (!component) return -EINVAL; - return hdac_hdmi_jack_port_init(codec, &card->dapm); + return hdac_hdmi_jack_port_init(component, &card->dapm); } /* diff --git a/sound/soc/intel/boards/skl_nau88l25_max98357a.c b/sound/soc/intel/boards/skl_nau88l25_max98357a.c index 1b5a689dc99b..9a7a0646bffe 100644 --- a/sound/soc/intel/boards/skl_nau88l25_max98357a.c +++ b/sound/soc/intel/boards/skl_nau88l25_max98357a.c @@ -165,7 +165,7 @@ static int skylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd, static int skylake_nau8825_codec_init(struct snd_soc_pcm_runtime *rtd) { int ret; - struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_component *component = rtd->codec_dai->component; /* * Headset buttons map to the google Reference headset. @@ -180,7 +180,7 @@ static int skylake_nau8825_codec_init(struct snd_soc_pcm_runtime *rtd) return ret; } - nau8825_enable_jack_detect(codec, &skylake_headset); + nau8825_enable_jack_detect(component, &skylake_headset); snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC"); @@ -592,12 +592,12 @@ static int skylake_card_late_probe(struct snd_soc_card *card) { struct skl_nau8825_private *ctx = snd_soc_card_get_drvdata(card); struct skl_hdmi_pcm *pcm; - struct snd_soc_codec *codec = NULL; + struct snd_soc_component *component = NULL; int err, i = 0; char jack_name[NAME_SIZE]; list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { - codec = pcm->codec_dai->codec; + component = pcm->codec_dai->component; snprintf(jack_name, sizeof(jack_name), "HDMI/DP, pcm=%d Jack", pcm->device); err = snd_soc_card_jack_new(card, jack_name, @@ -616,10 +616,10 @@ static int skylake_card_late_probe(struct snd_soc_card *card) i++; } - if (!codec) + if (!component) return -EINVAL; - return hdac_hdmi_jack_port_init(codec, &card->dapm); + return hdac_hdmi_jack_port_init(component, &card->dapm); } /* skylake audio machine driver for SPT + NAU88L25 */ diff --git a/sound/soc/intel/boards/skl_nau88l25_ssm4567.c b/sound/soc/intel/boards/skl_nau88l25_ssm4567.c index 7bea4bc77481..212ac8971e55 100644 --- a/sound/soc/intel/boards/skl_nau88l25_ssm4567.c +++ b/sound/soc/intel/boards/skl_nau88l25_ssm4567.c @@ -195,7 +195,7 @@ static int skylake_ssm4567_codec_init(struct snd_soc_pcm_runtime *rtd) static int skylake_nau8825_codec_init(struct snd_soc_pcm_runtime *rtd) { int ret; - struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_component *component = rtd->codec_dai->component; /* * 4 buttons here map to the google Reference headset @@ -210,7 +210,7 @@ static int skylake_nau8825_codec_init(struct snd_soc_pcm_runtime *rtd) return ret; } - nau8825_enable_jack_detect(codec, &skylake_headset); + nau8825_enable_jack_detect(component, &skylake_headset); snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC"); @@ -643,12 +643,12 @@ static int skylake_card_late_probe(struct snd_soc_card *card) { struct skl_nau88125_private *ctx = snd_soc_card_get_drvdata(card); struct skl_hdmi_pcm *pcm; - struct snd_soc_codec *codec = NULL; + struct snd_soc_component *component = NULL; int err, i = 0; char jack_name[NAME_SIZE]; list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { - codec = pcm->codec_dai->codec; + component = pcm->codec_dai->component; snprintf(jack_name, sizeof(jack_name), "HDMI/DP, pcm=%d Jack", pcm->device); err = snd_soc_card_jack_new(card, jack_name, @@ -667,10 +667,10 @@ static int skylake_card_late_probe(struct snd_soc_card *card) i++; } - if (!codec) + if (!component) return -EINVAL; - return hdac_hdmi_jack_port_init(codec, &card->dapm); + return hdac_hdmi_jack_port_init(component, &card->dapm); } /* skylake audio machine driver for SPT + NAU88L25 */ diff --git a/sound/soc/intel/boards/skl_rt286.c b/sound/soc/intel/boards/skl_rt286.c index 2bc4cfca594e..737d5615b0ef 100644 --- a/sound/soc/intel/boards/skl_rt286.c +++ b/sound/soc/intel/boards/skl_rt286.c @@ -130,7 +130,7 @@ static int skylake_rt286_fe_init(struct snd_soc_pcm_runtime *rtd) static int skylake_rt286_codec_init(struct snd_soc_pcm_runtime *rtd) { - struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_component *component = rtd->codec_dai->component; int ret; ret = snd_soc_card_jack_new(rtd->card, "Headset", @@ -141,7 +141,7 @@ static int skylake_rt286_codec_init(struct snd_soc_pcm_runtime *rtd) if (ret) return ret; - rt286_mic_detect(codec, &skylake_headset); + rt286_mic_detect(component, &skylake_headset); snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC"); @@ -478,12 +478,12 @@ static int skylake_card_late_probe(struct snd_soc_card *card) { struct skl_rt286_private *ctx = snd_soc_card_get_drvdata(card); struct skl_hdmi_pcm *pcm; - struct snd_soc_codec *codec = NULL; + struct snd_soc_component *component = NULL; int err, i = 0; char jack_name[NAME_SIZE]; list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { - codec = pcm->codec_dai->codec; + component = pcm->codec_dai->component; snprintf(jack_name, sizeof(jack_name), "HDMI/DP, pcm=%d Jack", pcm->device); err = snd_soc_card_jack_new(card, jack_name, @@ -501,10 +501,10 @@ static int skylake_card_late_probe(struct snd_soc_card *card) i++; } - if (!codec) + if (!component) return -EINVAL; - return hdac_hdmi_jack_port_init(codec, &card->dapm); + return hdac_hdmi_jack_port_init(component, &card->dapm); } /* skylake audio machine driver for SPT + RT286S */ diff --git a/sound/soc/intel/common/soc-acpi-intel-cht-match.c b/sound/soc/intel/common/soc-acpi-intel-cht-match.c index b50a0d53846b..ad1eb2d644be 100644 --- a/sound/soc/intel/common/soc-acpi-intel-cht-match.c +++ b/sound/soc/intel/common/soc-acpi-intel-cht-match.c @@ -118,6 +118,15 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_cherrytrail_machines[] = { .asoc_plat_name = "sst-mfld-platform", }, { + .id = "10508824", + .drv_name = "cht-bsw-nau8824", + .fw_filename = "intel/fw_sst_22a8.bin", + .board = "cht-bsw", + .sof_fw_filename = "intel/reef-cht.ri", + .sof_tplg_filename = "intel/reef-cht-nau8824.tplg", + .asoc_plat_name = "sst-mfld-platform", + }, + { .id = "DLGS7212", .drv_name = "bytcht_da7213", .fw_filename = "intel/fw_sst_22a8.bin", diff --git a/sound/soc/intel/haswell/sst-haswell-ipc.h b/sound/soc/intel/haswell/sst-haswell-ipc.h index 06d71aefa1fe..fbc14df139e4 100644 --- a/sound/soc/intel/haswell/sst-haswell-ipc.h +++ b/sound/soc/intel/haswell/sst-haswell-ipc.h @@ -22,6 +22,8 @@ #include <linux/platform_device.h> #include <sound/asound.h> +#define DRV_NAME "haswell-dai" + #define SST_HSW_NO_CHANNELS 4 #define SST_HSW_MAX_DX_REGIONS 14 #define SST_HSW_DX_CONTEXT_SIZE (640 * 1024) diff --git a/sound/soc/intel/haswell/sst-haswell-pcm.c b/sound/soc/intel/haswell/sst-haswell-pcm.c index c044400540ec..fe2c826e710c 100644 --- a/sound/soc/intel/haswell/sst-haswell-pcm.c +++ b/sound/soc/intel/haswell/sst-haswell-pcm.c @@ -181,11 +181,11 @@ static inline unsigned int hsw_ipc_to_mixer(u32 value) static int hsw_stream_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; struct hsw_priv_data *pdata = - snd_soc_platform_get_drvdata(platform); + snd_soc_component_get_drvdata(component); struct hsw_pcm_data *pcm_data; struct sst_hsw *hsw = pdata->hsw; u32 volume; @@ -230,11 +230,11 @@ static int hsw_stream_volume_put(struct snd_kcontrol *kcontrol, static int hsw_stream_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; struct hsw_priv_data *pdata = - snd_soc_platform_get_drvdata(platform); + snd_soc_component_get_drvdata(component); struct hsw_pcm_data *pcm_data; struct sst_hsw *hsw = pdata->hsw; u32 volume; @@ -273,8 +273,8 @@ static int hsw_stream_volume_get(struct snd_kcontrol *kcontrol, static int hsw_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol); - struct hsw_priv_data *pdata = snd_soc_platform_get_drvdata(platform); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_hsw *hsw = pdata->hsw; u32 volume; @@ -302,8 +302,8 @@ static int hsw_volume_put(struct snd_kcontrol *kcontrol, static int hsw_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol); - struct hsw_priv_data *pdata = snd_soc_platform_get_drvdata(platform); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_hsw *hsw = pdata->hsw; unsigned int volume = 0; @@ -322,8 +322,8 @@ static int hsw_volume_get(struct snd_kcontrol *kcontrol, static int hsw_waves_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol); - struct hsw_priv_data *pdata = snd_soc_platform_get_drvdata(platform); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_hsw *hsw = pdata->hsw; enum sst_hsw_module_id id = SST_HSW_MODULE_WAVES; @@ -336,8 +336,8 @@ static int hsw_waves_switch_get(struct snd_kcontrol *kcontrol, static int hsw_waves_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol); - struct hsw_priv_data *pdata = snd_soc_platform_get_drvdata(platform); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_hsw *hsw = pdata->hsw; int ret = 0; enum sst_hsw_module_id id = SST_HSW_MODULE_WAVES; @@ -370,8 +370,8 @@ static int hsw_waves_switch_put(struct snd_kcontrol *kcontrol, static int hsw_waves_param_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol); - struct hsw_priv_data *pdata = snd_soc_platform_get_drvdata(platform); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_hsw *hsw = pdata->hsw; /* return a matching line from param buffer */ @@ -381,8 +381,8 @@ static int hsw_waves_param_get(struct snd_kcontrol *kcontrol, static int hsw_waves_param_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol); - struct hsw_priv_data *pdata = snd_soc_platform_get_drvdata(platform); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_hsw *hsw = pdata->hsw; int ret; enum sst_hsw_module_id id = SST_HSW_MODULE_WAVES; @@ -472,8 +472,8 @@ static int hsw_pcm_hw_params(struct snd_pcm_substream *substream, { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_pcm_runtime *runtime = substream->runtime; - struct hsw_priv_data *pdata = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(component); struct hsw_pcm_data *pcm_data; struct sst_hsw *hsw = pdata->hsw; struct sst_module *module_data; @@ -674,8 +674,8 @@ static int hsw_pcm_hw_free(struct snd_pcm_substream *substream) static int hsw_pcm_trigger(struct snd_pcm_substream *substream, int cmd) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct hsw_priv_data *pdata = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(component); struct hsw_pcm_data *pcm_data; struct sst_hsw_stream *sst_stream; struct sst_hsw *hsw = pdata->hsw; @@ -718,8 +718,8 @@ static u32 hsw_notify_pointer(struct sst_hsw_stream *stream, void *data) struct snd_pcm_substream *substream = pcm_data->substream; struct snd_pcm_runtime *runtime = substream->runtime; struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct hsw_priv_data *pdata = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_hsw *hsw = pdata->hsw; u32 pos; snd_pcm_uframes_t position = bytes_to_frames(runtime, @@ -783,8 +783,8 @@ static snd_pcm_uframes_t hsw_pcm_pointer(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_pcm_runtime *runtime = substream->runtime; - struct hsw_priv_data *pdata = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(component); struct hsw_pcm_data *pcm_data; struct sst_hsw *hsw = pdata->hsw; snd_pcm_uframes_t offset; @@ -807,8 +807,8 @@ static snd_pcm_uframes_t hsw_pcm_pointer(struct snd_pcm_substream *substream) static int hsw_pcm_open(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct hsw_priv_data *pdata = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(component); struct hsw_pcm_data *pcm_data; struct sst_hsw *hsw = pdata->hsw; int dai; @@ -840,8 +840,8 @@ static int hsw_pcm_open(struct snd_pcm_substream *substream) static int hsw_pcm_close(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct hsw_priv_data *pdata = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(component); struct hsw_pcm_data *pcm_data; struct sst_hsw *hsw = pdata->hsw; int ret, dai; @@ -942,9 +942,9 @@ static void hsw_pcm_free_modules(struct hsw_priv_data *pdata) static int hsw_pcm_new(struct snd_soc_pcm_runtime *rtd) { struct snd_pcm *pcm = rtd->pcm; - struct snd_soc_platform *platform = rtd->platform; - struct sst_pdata *pdata = dev_get_platdata(platform->dev); - struct hsw_priv_data *priv_data = dev_get_drvdata(platform->dev); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_pdata *pdata = dev_get_platdata(component->dev); + struct hsw_priv_data *priv_data = dev_get_drvdata(component->dev); struct device *dev = pdata->dma_dev; int ret = 0; @@ -1052,23 +1052,23 @@ static const struct snd_soc_dapm_route graph[] = { {"Analog Capture", NULL, "SSP0 CODEC IN"}, }; -static int hsw_pcm_probe(struct snd_soc_platform *platform) +static int hsw_pcm_probe(struct snd_soc_component *component) { - struct hsw_priv_data *priv_data = snd_soc_platform_get_drvdata(platform); - struct sst_pdata *pdata = dev_get_platdata(platform->dev); + struct hsw_priv_data *priv_data = snd_soc_component_get_drvdata(component); + struct sst_pdata *pdata = dev_get_platdata(component->dev); struct device *dma_dev, *dev; int i, ret = 0; if (!pdata) return -ENODEV; - dev = platform->dev; + dev = component->dev; dma_dev = pdata->dma_dev; priv_data->hsw = pdata->dsp; - priv_data->dev = platform->dev; + priv_data->dev = dev; priv_data->pm_state = HSW_PM_STATE_D0; - priv_data->soc_card = platform->component.card; + priv_data->soc_card = component->card; /* allocate DSP buffer page tables */ for (i = 0; i < ARRAY_SIZE(hsw_dais); i++) { @@ -1098,11 +1098,10 @@ static int hsw_pcm_probe(struct snd_soc_platform *platform) goto err; /* enable runtime PM with auto suspend */ - pm_runtime_set_autosuspend_delay(platform->dev, - SST_RUNTIME_SUSPEND_DELAY); - pm_runtime_use_autosuspend(platform->dev); - pm_runtime_enable(platform->dev); - pm_runtime_idle(platform->dev); + pm_runtime_set_autosuspend_delay(dev, SST_RUNTIME_SUSPEND_DELAY); + pm_runtime_use_autosuspend(dev); + pm_runtime_enable(dev); + pm_runtime_idle(dev); return 0; @@ -1116,13 +1115,13 @@ err: return ret; } -static int hsw_pcm_remove(struct snd_soc_platform *platform) +static void hsw_pcm_remove(struct snd_soc_component *component) { struct hsw_priv_data *priv_data = - snd_soc_platform_get_drvdata(platform); + snd_soc_component_get_drvdata(component); int i; - pm_runtime_disable(platform->dev); + pm_runtime_disable(component->dev); hsw_pcm_free_modules(priv_data); for (i = 0; i < ARRAY_SIZE(hsw_dais); i++) { @@ -1131,24 +1130,19 @@ static int hsw_pcm_remove(struct snd_soc_platform *platform) if (hsw_dais[i].capture.channels_min) snd_dma_free_pages(&priv_data->dmab[i][1]); } - - return 0; } -static const struct snd_soc_platform_driver hsw_soc_platform = { +static const struct snd_soc_component_driver hsw_dai_component = { + .name = DRV_NAME, .probe = hsw_pcm_probe, .remove = hsw_pcm_remove, .ops = &hsw_pcm_ops, .pcm_new = hsw_pcm_new, -}; - -static const struct snd_soc_component_driver hsw_dai_component = { - .name = "haswell-dai", - .controls = hsw_volume_controls, - .num_controls = ARRAY_SIZE(hsw_volume_controls), - .dapm_widgets = widgets, + .controls = hsw_volume_controls, + .num_controls = ARRAY_SIZE(hsw_volume_controls), + .dapm_widgets = widgets, .num_dapm_widgets = ARRAY_SIZE(widgets), - .dapm_routes = graph, + .dapm_routes = graph, .num_dapm_routes = ARRAY_SIZE(graph), }; @@ -1172,19 +1166,13 @@ static int hsw_pcm_dev_probe(struct platform_device *pdev) priv_data->hsw = sst_pdata->dsp; platform_set_drvdata(pdev, priv_data); - ret = snd_soc_register_platform(&pdev->dev, &hsw_soc_platform); - if (ret < 0) - goto err_plat; - - ret = snd_soc_register_component(&pdev->dev, &hsw_dai_component, + ret = devm_snd_soc_register_component(&pdev->dev, &hsw_dai_component, hsw_dais, ARRAY_SIZE(hsw_dais)); if (ret < 0) - goto err_comp; + goto err_plat; return 0; -err_comp: - snd_soc_unregister_platform(&pdev->dev); err_plat: sst_hsw_dsp_free(&pdev->dev, sst_pdata); return 0; @@ -1194,8 +1182,6 @@ static int hsw_pcm_dev_remove(struct platform_device *pdev) { struct sst_pdata *sst_pdata = dev_get_platdata(&pdev->dev); - snd_soc_unregister_platform(&pdev->dev); - snd_soc_unregister_component(&pdev->dev); sst_hsw_dsp_free(&pdev->dev, sst_pdata); return 0; diff --git a/sound/soc/intel/skylake/skl-debug.c b/sound/soc/intel/skylake/skl-debug.c index dc20d91f62e6..a016455a6ddb 100644 --- a/sound/soc/intel/skylake/skl-debug.c +++ b/sound/soc/intel/skylake/skl-debug.c @@ -231,7 +231,7 @@ struct skl_debug *skl_debugfs_init(struct skl *skl) /* create the debugfs dir with platform component's debugfs as parent */ d->fs = debugfs_create_dir("dsp", - skl->platform->component.debugfs_root); + skl->component->debugfs_root); if (IS_ERR(d->fs) || !d->fs) { dev_err(&skl->pci->dev, "debugfs root creation failed\n"); return NULL; diff --git a/sound/soc/intel/skylake/skl-messages.c b/sound/soc/intel/skylake/skl-messages.c index 60d76adade43..57d4a58522a6 100644 --- a/sound/soc/intel/skylake/skl-messages.c +++ b/sound/soc/intel/skylake/skl-messages.c @@ -417,11 +417,16 @@ int skl_resume_dsp(struct skl *skl) if (skl->skl_sst->is_first_boot == true) return 0; - /* disable dynamic clock gating during fw and lib download */ + /* + * Disable dynamic clock and power gating during firmware + * and library download + */ ctx->enable_miscbdcge(ctx->dev, false); + ctx->clock_power_gating(ctx->dev, false); ret = skl_dsp_wake(ctx->dsp); ctx->enable_miscbdcge(ctx->dev, true); + ctx->clock_power_gating(ctx->dev, true); if (ret < 0) return ret; @@ -1210,7 +1215,7 @@ out: static int skl_set_pipe_state(struct skl_sst *ctx, struct skl_pipe *pipe, enum skl_ipc_pipeline_state state) { - dev_dbg(ctx->dev, "%s: pipe_satate = %d\n", __func__, state); + dev_dbg(ctx->dev, "%s: pipe_state = %d\n", __func__, state); return skl_ipc_set_pipeline_state(&ctx->ipc, pipe->ppl_id, state); } diff --git a/sound/soc/intel/skylake/skl-pcm.c b/sound/soc/intel/skylake/skl-pcm.c index e46828533826..15cb8ac3e374 100644 --- a/sound/soc/intel/skylake/skl-pcm.c +++ b/sound/soc/intel/skylake/skl-pcm.c @@ -959,6 +959,17 @@ static struct snd_soc_dai_driver skl_platform_dai[] = { }, }, { + .name = "DMIC16k Pin", + .ops = &skl_dmic_dai_ops, + .capture = { + .stream_name = "DMIC16k Rx", + .channels_min = HDA_MONO, + .channels_max = HDA_QUAD, + .rates = SNDRV_PCM_RATE_16000, + .formats = SNDRV_PCM_FMTBIT_S16_LE, + }, +}, +{ .name = "HD-Codec Pin", .ops = &skl_link_dai_ops, .playback = { @@ -1307,29 +1318,31 @@ static int skl_populate_modules(struct skl *skl) "query module info failed\n"); return ret; } + + skl_tplg_add_moduleid_in_bind_params(skl, w); } } return ret; } -static int skl_platform_soc_probe(struct snd_soc_platform *platform) +static int skl_platform_soc_probe(struct snd_soc_component *component) { - struct hdac_ext_bus *ebus = dev_get_drvdata(platform->dev); + struct hdac_ext_bus *ebus = dev_get_drvdata(component->dev); struct skl *skl = ebus_to_skl(ebus); const struct skl_dsp_ops *ops; int ret; - pm_runtime_get_sync(platform->dev); + pm_runtime_get_sync(component->dev); if ((ebus_to_hbus(ebus))->ppcap) { - skl->platform = platform; + skl->component = component; /* init debugfs */ skl->debugfs = skl_debugfs_init(skl); - ret = skl_tplg_init(platform, ebus); + ret = skl_tplg_init(component, ebus); if (ret < 0) { - dev_err(platform->dev, "Failed to init topology!\n"); + dev_err(component->dev, "Failed to init topology!\n"); return ret; } @@ -1339,17 +1352,22 @@ static int skl_platform_soc_probe(struct snd_soc_platform *platform) return -EIO; if (skl->skl_sst->is_first_boot == false) { - dev_err(platform->dev, "DSP reports first boot done!!!\n"); + dev_err(component->dev, "DSP reports first boot done!!!\n"); return -EIO; } - /* disable dynamic clock gating during fw and lib download */ - skl->skl_sst->enable_miscbdcge(platform->dev, false); + /* + * Disable dynamic clock and power gating during firmware + * and library download + */ + skl->skl_sst->enable_miscbdcge(component->dev, false); + skl->skl_sst->clock_power_gating(component->dev, false); - ret = ops->init_fw(platform->dev, skl->skl_sst); - skl->skl_sst->enable_miscbdcge(platform->dev, true); + ret = ops->init_fw(component->dev, skl->skl_sst); + skl->skl_sst->enable_miscbdcge(component->dev, true); + skl->skl_sst->clock_power_gating(component->dev, true); if (ret < 0) { - dev_err(platform->dev, "Failed to boot first fw: %d\n", ret); + dev_err(component->dev, "Failed to boot first fw: %d\n", ret); return ret; } skl_populate_modules(skl); @@ -1362,22 +1380,20 @@ static int skl_platform_soc_probe(struct snd_soc_platform *platform) skl->cfg.astate_cfg); } } - pm_runtime_mark_last_busy(platform->dev); - pm_runtime_put_autosuspend(platform->dev); + pm_runtime_mark_last_busy(component->dev); + pm_runtime_put_autosuspend(component->dev); return 0; } -static const struct snd_soc_platform_driver skl_platform_drv = { + +static const struct snd_soc_component_driver skl_component = { + .name = "pcm", .probe = skl_platform_soc_probe, .ops = &skl_platform_ops, .pcm_new = skl_pcm_new, .pcm_free = skl_pcm_free, }; -static const struct snd_soc_component_driver skl_component = { - .name = "pcm", -}; - int skl_platform_register(struct device *dev) { int ret; @@ -1389,12 +1405,6 @@ int skl_platform_register(struct device *dev) INIT_LIST_HEAD(&skl->ppl_list); INIT_LIST_HEAD(&skl->bind_list); - ret = snd_soc_register_platform(dev, &skl_platform_drv); - if (ret) { - dev_err(dev, "soc platform registration failed %d\n", ret); - return ret; - } - skl->dais = kmemdup(skl_platform_dai, sizeof(skl_platform_dai), GFP_KERNEL); if (!skl->dais) { @@ -1416,18 +1426,12 @@ int skl_platform_register(struct device *dev) num_dais += ARRAY_SIZE(skl_fe_dai); } - ret = snd_soc_register_component(dev, &skl_component, + ret = devm_snd_soc_register_component(dev, &skl_component, skl->dais, num_dais); - if (ret) { + if (ret) dev_err(dev, "soc component registration failed %d\n", ret); - goto err; - } - - return 0; err: - snd_soc_unregister_platform(dev); return ret; - } int skl_platform_unregister(struct device *dev) @@ -1443,8 +1447,6 @@ int skl_platform_unregister(struct device *dev) } } - snd_soc_unregister_component(dev); - snd_soc_unregister_platform(dev); kfree(skl->dais); return 0; diff --git a/sound/soc/intel/skylake/skl-ssp-clk.c b/sound/soc/intel/skylake/skl-ssp-clk.c index 7fbddf5e3b00..cda1b5fa7436 100644 --- a/sound/soc/intel/skylake/skl-ssp-clk.c +++ b/sound/soc/intel/skylake/skl-ssp-clk.c @@ -247,8 +247,8 @@ static unsigned long skl_clk_recalc_rate(struct clk_hw *hw, } /* Not supported by clk driver. Implemented to satisfy clk fw */ -long skl_clk_round_rate(struct clk_hw *hw, unsigned long rate, - unsigned long *parent_rate) +static long skl_clk_round_rate(struct clk_hw *hw, unsigned long rate, + unsigned long *parent_rate) { return rate; } diff --git a/sound/soc/intel/skylake/skl-sst-ipc.h b/sound/soc/intel/skylake/skl-sst-ipc.h index 55f2d2ce09df..f74f040dfd83 100644 --- a/sound/soc/intel/skylake/skl-sst-ipc.h +++ b/sound/soc/intel/skylake/skl-sst-ipc.h @@ -118,6 +118,9 @@ struct skl_sst { struct skl_d0i3_data d0i3; const struct skl_dsp_ops *dsp_ops; + + /* Callback to update dynamic clock and power gating registers */ + void (*clock_power_gating)(struct device *dev, bool enable); }; struct skl_ipc_init_instance_msg { diff --git a/sound/soc/intel/skylake/skl-topology.c b/sound/soc/intel/skylake/skl-topology.c index 73af6e19ebbd..3b1dca419883 100644 --- a/sound/soc/intel/skylake/skl-topology.c +++ b/sound/soc/intel/skylake/skl-topology.c @@ -94,8 +94,12 @@ void skl_tplg_d0i3_put(struct skl *skl, enum d0i3_capability caps) * SKL DSP driver modelling uses only few DAPM widgets so for rest we will * ignore. This helpers checks if the SKL driver handles this widget type */ -static int is_skl_dsp_widget_type(struct snd_soc_dapm_widget *w) +static int is_skl_dsp_widget_type(struct snd_soc_dapm_widget *w, + struct device *dev) { + if (w->dapm->dev != dev) + return false; + switch (w->id) { case snd_soc_dapm_dai_link: case snd_soc_dapm_dai_in: @@ -826,7 +830,7 @@ static int skl_fill_sink_instance_id(struct skl_sst *ctx, u32 *params, if (mcfg->m_type == SKL_MODULE_TYPE_KPB) { struct skl_kpb_params *kpb_params = (struct skl_kpb_params *)params; - struct skl_mod_inst_map *inst = kpb_params->map; + struct skl_mod_inst_map *inst = kpb_params->u.map; for (i = 0; i < kpb_params->num_modules; i++) { pvt_id = skl_get_pvt_instance_id_map(ctx, inst->mod_id, @@ -911,6 +915,87 @@ static int skl_tplg_set_module_bind_params(struct snd_soc_dapm_widget *w, return 0; } +static int skl_get_module_id(struct skl_sst *ctx, uuid_le *uuid) +{ + struct uuid_module *module; + + list_for_each_entry(module, &ctx->uuid_list, list) { + if (uuid_le_cmp(*uuid, module->uuid) == 0) + return module->id; + } + + return -EINVAL; +} + +static int skl_tplg_find_moduleid_from_uuid(struct skl *skl, + const struct snd_kcontrol_new *k) +{ + struct soc_bytes_ext *sb = (void *) k->private_value; + struct skl_algo_data *bc = (struct skl_algo_data *)sb->dobj.private; + struct skl_kpb_params *uuid_params, *params; + struct hdac_bus *bus = ebus_to_hbus(skl_to_ebus(skl)); + int i, size, module_id; + + if (bc->set_params == SKL_PARAM_BIND && bc->max) { + uuid_params = (struct skl_kpb_params *)bc->params; + size = uuid_params->num_modules * + sizeof(struct skl_mod_inst_map) + + sizeof(uuid_params->num_modules); + + params = devm_kzalloc(bus->dev, size, GFP_KERNEL); + if (!params) + return -ENOMEM; + + params->num_modules = uuid_params->num_modules; + + for (i = 0; i < uuid_params->num_modules; i++) { + module_id = skl_get_module_id(skl->skl_sst, + &uuid_params->u.map_uuid[i].mod_uuid); + if (module_id < 0) { + devm_kfree(bus->dev, params); + return -EINVAL; + } + + params->u.map[i].mod_id = module_id; + params->u.map[i].inst_id = + uuid_params->u.map_uuid[i].inst_id; + } + + devm_kfree(bus->dev, bc->params); + bc->params = (char *)params; + bc->max = size; + } + + return 0; +} + +/* + * Retrieve the module id from UUID mentioned in the + * post bind params + */ +void skl_tplg_add_moduleid_in_bind_params(struct skl *skl, + struct snd_soc_dapm_widget *w) +{ + struct skl_module_cfg *mconfig = w->priv; + int i; + + /* + * Post bind params are used for only for KPB + * to set copier instances to drain the data + * in fast mode + */ + if (mconfig->m_type != SKL_MODULE_TYPE_KPB) + return; + + for (i = 0; i < w->num_kcontrols; i++) + if ((w->kcontrol_news[i].access & + SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK) && + (skl_tplg_find_moduleid_from_uuid(skl, + &w->kcontrol_news[i]) < 0)) + dev_err(skl->skl_sst->dev, + "%s: invalid kpb post bind params\n", + __func__); +} static int skl_tplg_module_add_deferred_bind(struct skl *skl, struct skl_module_cfg *src, struct skl_module_cfg *dst) @@ -969,7 +1054,7 @@ static int skl_tplg_bind_sinks(struct snd_soc_dapm_widget *w, next_sink = p->sink; - if (!is_skl_dsp_widget_type(p->sink)) + if (!is_skl_dsp_widget_type(p->sink, ctx->dev)) return skl_tplg_bind_sinks(p->sink, skl, src_w, src_mconfig); /* @@ -978,7 +1063,7 @@ static int skl_tplg_bind_sinks(struct snd_soc_dapm_widget *w, * they are ones used for SKL so check that first */ if ((p->sink->priv != NULL) && - is_skl_dsp_widget_type(p->sink)) { + is_skl_dsp_widget_type(p->sink, ctx->dev)) { sink = p->sink; sink_mconfig = sink->priv; @@ -1092,7 +1177,7 @@ static struct snd_soc_dapm_widget *skl_get_src_dsp_widget( * ones used for SKL so check that first */ if ((p->source->priv != NULL) && - is_skl_dsp_widget_type(p->source)) { + is_skl_dsp_widget_type(p->source, ctx->dev)) { return p->source; } } @@ -1654,7 +1739,7 @@ skl_tplg_fe_get_cpr_module(struct snd_soc_dai *dai, int stream) w = dai->playback_widget; snd_soc_dapm_widget_for_each_sink_path(w, p) { if (p->connect && p->sink->power && - !is_skl_dsp_widget_type(p->sink)) + !is_skl_dsp_widget_type(p->sink, dai->dev)) continue; if (p->sink->priv) { @@ -1667,7 +1752,7 @@ skl_tplg_fe_get_cpr_module(struct snd_soc_dai *dai, int stream) w = dai->capture_widget; snd_soc_dapm_widget_for_each_source_path(w, p) { if (p->connect && p->source->power && - !is_skl_dsp_widget_type(p->source)) + !is_skl_dsp_widget_type(p->source, dai->dev)) continue; if (p->source->priv) { @@ -1819,7 +1904,7 @@ static int skl_tplg_be_set_src_pipe_params(struct snd_soc_dai *dai, int ret = -EIO; snd_soc_dapm_widget_for_each_source_path(w, p) { - if (p->connect && is_skl_dsp_widget_type(p->source) && + if (p->connect && is_skl_dsp_widget_type(p->source, dai->dev) && p->source->priv) { ret = skl_tplg_be_fill_pipe_params(dai, @@ -1844,7 +1929,7 @@ static int skl_tplg_be_set_sink_pipe_params(struct snd_soc_dai *dai, int ret = -EIO; snd_soc_dapm_widget_for_each_sink_path(w, p) { - if (p->connect && is_skl_dsp_widget_type(p->sink) && + if (p->connect && is_skl_dsp_widget_type(p->sink, dai->dev) && p->sink->priv) { ret = skl_tplg_be_fill_pipe_params(dai, @@ -2710,15 +2795,15 @@ static int skl_tplg_get_pvt_data(struct snd_soc_tplg_dapm_widget *tplg_w, return 0; } -static void skl_clear_pin_config(struct snd_soc_platform *platform, +static void skl_clear_pin_config(struct snd_soc_component *component, struct snd_soc_dapm_widget *w) { int i; struct skl_module_cfg *mconfig; struct skl_pipe *pipe; - if (!strncmp(w->dapm->component->name, platform->component.name, - strlen(platform->component.name))) { + if (!strncmp(w->dapm->component->name, component->name, + strlen(component->name))) { mconfig = w->priv; pipe = mconfig->pipe; for (i = 0; i < mconfig->module->max_input_pins; i++) { @@ -2737,14 +2822,14 @@ static void skl_clear_pin_config(struct snd_soc_platform *platform, void skl_cleanup_resources(struct skl *skl) { struct skl_sst *ctx = skl->skl_sst; - struct snd_soc_platform *soc_platform = skl->platform; + struct snd_soc_component *soc_component = skl->component; struct snd_soc_dapm_widget *w; struct snd_soc_card *card; - if (soc_platform == NULL) + if (soc_component == NULL) return; - card = soc_platform->component.card; + card = soc_component->card; if (!card || !card->instantiated) return; @@ -2752,8 +2837,8 @@ void skl_cleanup_resources(struct skl *skl) skl->resource.mcps = 0; list_for_each_entry(w, &card->widgets, list) { - if (is_skl_dsp_widget_type(w) && (w->priv != NULL)) - skl_clear_pin_config(soc_platform, w); + if (is_skl_dsp_widget_type(w, ctx->dev) && w->priv != NULL) + skl_clear_pin_config(soc_component, w); } skl_clear_module_cnt(ctx->dsp); @@ -3400,19 +3485,19 @@ static struct snd_soc_tplg_ops skl_tplg_ops = { * widgets in a pipelines, so this helper - skl_tplg_create_pipe_widget_list() * helps to get the SKL type widgets in that pipeline */ -static int skl_tplg_create_pipe_widget_list(struct snd_soc_platform *platform) +static int skl_tplg_create_pipe_widget_list(struct snd_soc_component *component) { struct snd_soc_dapm_widget *w; struct skl_module_cfg *mcfg = NULL; struct skl_pipe_module *p_module = NULL; struct skl_pipe *pipe; - list_for_each_entry(w, &platform->component.card->widgets, list) { - if (is_skl_dsp_widget_type(w) && w->priv != NULL) { + list_for_each_entry(w, &component->card->widgets, list) { + if (is_skl_dsp_widget_type(w, component->dev) && w->priv) { mcfg = w->priv; pipe = mcfg->pipe; - p_module = devm_kzalloc(platform->dev, + p_module = devm_kzalloc(component->dev, sizeof(*p_module), GFP_KERNEL); if (!p_module) return -ENOMEM; @@ -3455,7 +3540,7 @@ static void skl_tplg_set_pipe_type(struct skl *skl, struct skl_pipe *pipe) /* * SKL topology init routine */ -int skl_tplg_init(struct snd_soc_platform *platform, struct hdac_ext_bus *ebus) +int skl_tplg_init(struct snd_soc_component *component, struct hdac_ext_bus *ebus) { int ret; const struct firmware *fw; @@ -3479,7 +3564,7 @@ int skl_tplg_init(struct snd_soc_platform *platform, struct hdac_ext_bus *ebus) * The complete tplg for SKL is loaded as index 0, we don't use * any other index */ - ret = snd_soc_tplg_component_load(&platform->component, + ret = snd_soc_tplg_component_load(component, &skl_tplg_ops, fw, 0); if (ret < 0) { dev_err(bus->dev, "tplg component load failed%d\n", ret); @@ -3491,7 +3576,7 @@ int skl_tplg_init(struct snd_soc_platform *platform, struct hdac_ext_bus *ebus) skl->resource.max_mem = SKL_FW_MAX_MEM; skl->tplg = fw; - ret = skl_tplg_create_pipe_widget_list(platform); + ret = skl_tplg_create_pipe_widget_list(component); if (ret < 0) return ret; diff --git a/sound/soc/intel/skylake/skl-topology.h b/sound/soc/intel/skylake/skl-topology.h index b6496513fe55..b1e0667c0ae0 100644 --- a/sound/soc/intel/skylake/skl-topology.h +++ b/sound/soc/intel/skylake/skl-topology.h @@ -221,9 +221,18 @@ struct skl_mod_inst_map { u16 inst_id; }; +struct skl_uuid_inst_map { + u16 inst_id; + u16 reserved; + uuid_le mod_uuid; +} __packed; + struct skl_kpb_params { u32 num_modules; - struct skl_mod_inst_map map[0]; + union { + struct skl_mod_inst_map map[0]; + struct skl_uuid_inst_map map_uuid[0]; + } u; }; struct skl_module_inst_id { @@ -460,7 +469,7 @@ int skl_dsp_set_dma_control(struct skl_sst *ctx, u32 *caps, u32 caps_size, u32 node_id); void skl_tplg_set_be_dmic_config(struct snd_soc_dai *dai, struct skl_pipe_params *params, int stream); -int skl_tplg_init(struct snd_soc_platform *platform, +int skl_tplg_init(struct snd_soc_component *component, struct hdac_ext_bus *ebus); struct skl_module_cfg *skl_tplg_fe_get_cpr_module( struct snd_soc_dai *dai, int stream); @@ -505,4 +514,6 @@ int skl_pcm_link_dma_prepare(struct device *dev, int skl_dai_load(struct snd_soc_component *cmp, struct snd_soc_dai_driver *pcm_dai); +void skl_tplg_add_moduleid_in_bind_params(struct skl *skl, + struct snd_soc_dapm_widget *w); #endif diff --git a/sound/soc/intel/skylake/skl.c b/sound/soc/intel/skylake/skl.c index 32ce64c6b2dc..abf324747b29 100644 --- a/sound/soc/intel/skylake/skl.c +++ b/sound/soc/intel/skylake/skl.c @@ -94,6 +94,32 @@ static void skl_enable_miscbdcge(struct device *dev, bool enable) update_pci_dword(pci, AZX_PCIREG_CGCTL, AZX_CGCTL_MISCBDCGE_MASK, val); } +/** + * skl_clock_power_gating: Enable/Disable clock and power gating + * + * @dev: Device pointer + * @enable: Enable/Disable flag + */ +static void skl_clock_power_gating(struct device *dev, bool enable) +{ + struct pci_dev *pci = to_pci_dev(dev); + struct hdac_ext_bus *ebus = pci_get_drvdata(pci); + struct hdac_bus *bus = ebus_to_hbus(ebus); + u32 val; + + /* Update PDCGE bit of CGCTL register */ + val = enable ? AZX_CGCTL_ADSPDCGE : 0; + update_pci_dword(pci, AZX_PCIREG_CGCTL, AZX_CGCTL_ADSPDCGE, val); + + /* Update L1SEN bit of EM2 register */ + val = enable ? AZX_REG_VS_EM2_L1SEN : 0; + snd_hdac_chip_updatel(bus, VS_EM2, AZX_REG_VS_EM2_L1SEN, val); + + /* Update ADSPPGD bit of PGCTL register */ + val = enable ? 0 : AZX_PGCTL_ADSPPGD; + update_pci_dword(pci, AZX_PCIREG_PGCTL, AZX_PGCTL_ADSPPGD, val); +} + /* * While performing reset, controller may not come back properly causing * issues, so recommendation is to set CGCTL.MISCBDCGE to 0 then do reset @@ -916,6 +942,7 @@ static int skl_probe(struct pci_dev *pci, goto out_nhlt_free; } skl->skl_sst->enable_miscbdcge = skl_enable_miscbdcge; + skl->skl_sst->clock_power_gating = skl_clock_power_gating; } if (bus->mlcap) snd_hdac_ext_bus_get_ml_capabilities(ebus); @@ -1017,6 +1044,11 @@ static struct snd_soc_acpi_codecs kbl_5663_5514_codecs = { .codecs = {"10EC5663", "10EC5514"} }; +static struct snd_soc_acpi_codecs kbl_7219_98357_codecs = { + .num_codecs = 1, + .codecs = {"MX98357A"} +}; + static struct skl_machine_pdata cnl_pdata = { .use_tplg_pcm = true, }; @@ -1105,6 +1137,14 @@ static struct snd_soc_acpi_mach sst_kbl_devdata[] = { .drv_name = "kbl_rt5663", .fw_filename = "intel/dsp_fw_kbl.bin", }, + { + .id = "DLGS7219", + .drv_name = "kbl_da7219_max98357a", + .fw_filename = "intel/dsp_fw_kbl.bin", + .machine_quirk = snd_soc_acpi_codec_list, + .quirk_data = &kbl_7219_98357_codecs, + .pdata = &skl_dmic_data + }, {} }; diff --git a/sound/soc/intel/skylake/skl.h b/sound/soc/intel/skylake/skl.h index 2d13f3fd988a..0d5375cbcf6e 100644 --- a/sound/soc/intel/skylake/skl.h +++ b/sound/soc/intel/skylake/skl.h @@ -33,8 +33,10 @@ #define AZX_PCIREG_PGCTL 0x44 #define AZX_PGCTL_LSRMD_MASK (1 << 4) +#define AZX_PGCTL_ADSPPGD BIT(2) #define AZX_PCIREG_CGCTL 0x48 #define AZX_CGCTL_MISCBDCGE_MASK (1 << 6) +#define AZX_CGCTL_ADSPDCGE BIT(1) /* D0I3C Register fields */ #define AZX_REG_VS_D0I3C_CIP 0x1 /* Command in progress */ #define AZX_REG_VS_D0I3C_I3 0x4 /* D0i3 enable */ @@ -43,6 +45,8 @@ #define DMA_TRANSMITION_START 2 #define DMA_TRANSMITION_STOP 3 +#define AZX_REG_VS_EM2_L1SEN BIT(13) + struct skl_dsp_resource { u32 max_mcps; u32 max_mem; @@ -74,7 +78,7 @@ struct skl { struct platform_device *dmic_dev; struct platform_device *i2s_dev; struct platform_device *clk_dev; - struct snd_soc_platform *platform; + struct snd_soc_component *component; struct snd_soc_dai_driver *dais; struct nhlt_acpi_table *nhlt; /* nhlt ptr */ |