diff --git a/src/drivers/intel/baytrail/ssp.c b/src/drivers/intel/baytrail/ssp.c index 7431ce439..aeaa3b973 100644 --- a/src/drivers/intel/baytrail/ssp.c +++ b/src/drivers/intel/baytrail/ssp.c @@ -480,6 +480,34 @@ out: return ret; } +/* get SSP hw params */ +static int ssp_get_hw_params(struct dai *dai, + struct sof_ipc_stream_params *params) +{ + struct ssp_pdata *ssp = dai_get_drvdata(dai); + + params->rate = ssp->params.fsync_rate; + params->channels = ssp->params.tdm_slots; + params->buffer_fmt = 0; + + switch (ssp->params.sample_valid_bits) { + case 16: + params->frame_fmt = SOF_IPC_FRAME_S16_LE; + break; + case 24: + params->frame_fmt = SOF_IPC_FRAME_S24_4LE; + break; + case 32: + params->frame_fmt = SOF_IPC_FRAME_S32_LE; + break; + default: + dai_err(dai, "ssp_get_hw_params(): not supported format"); + return -EINVAL; + } + + return 0; +} + /* start the SSP for either playback or capture */ static void ssp_start(struct dai *dai, int direction) { @@ -607,6 +635,7 @@ const struct dai_driver ssp_driver = { .set_config = ssp_set_config, .pm_context_store = ssp_context_store, .pm_context_restore = ssp_context_restore, + .get_hw_params = ssp_get_hw_params, .get_handshake = ssp_get_handshake, .get_fifo = ssp_get_fifo, .probe = ssp_probe, diff --git a/src/drivers/intel/cavs/alh.c b/src/drivers/intel/cavs/alh.c index 24eb373ef..05e538474 100644 --- a/src/drivers/intel/cavs/alh.c +++ b/src/drivers/intel/cavs/alh.c @@ -30,6 +30,19 @@ static int alh_set_config(struct dai *dai, struct sof_ipc_dai_config *config) return 0; } +/* get ALH hw params */ +static int alh_get_hw_params(struct dai *dai, + struct sof_ipc_stream_params *params) +{ + /* 0 means variable */ + params->rate = 0; + params->channels = 0; + params->buffer_fmt = 0; + params->frame_fmt = 0; + + return 0; +} + static int alh_context_store(struct dai *dai) { dai_info(dai, "alh_context_store()"); @@ -87,6 +100,7 @@ const struct dai_driver alh_driver = { .set_config = alh_set_config, .pm_context_store = alh_context_store, .pm_context_restore = alh_context_restore, + .get_hw_params = alh_get_hw_params, .get_handshake = alh_get_handshake, .get_fifo = alh_get_fifo, .probe = alh_probe, diff --git a/src/drivers/intel/cavs/dmic.c b/src/drivers/intel/cavs/dmic.c index 3c0f4989d..2983809b4 100644 --- a/src/drivers/intel/cavs/dmic.c +++ b/src/drivers/intel/cavs/dmic.c @@ -1046,6 +1046,42 @@ static int configure_registers(struct dai *dai, return 0; } +/* get DMIC hw params */ +static int dmic_get_hw_params(struct dai *dai, + struct sof_ipc_stream_params *params) +{ + int di = dai->index; + + params->rate = dmic_prm[di]->fifo_fs; + params->buffer_fmt = 0; + + switch (dmic_prm[di]->num_pdm_active) { + case 1: + params->channels = 2; + break; + case 2: + params->channels = 4; + break; + default: + dai_info(dai, "dmic_get_hw_params(): not supported channels amount"); + return -EINVAL; + } + + switch (dmic_prm[di]->fifo_bits) { + case 16: + params->frame_fmt = SOF_IPC_FRAME_S16_LE; + break; + case 32: + params->frame_fmt = SOF_IPC_FRAME_S32_LE; + break; + default: + dai_err(dai, "dmic_get_hw_params(): not supported format"); + return -EINVAL; + } + + return 0; +} + static int dmic_set_config(struct dai *dai, struct sof_ipc_dai_config *config) { struct dmic_pdata *dmic = dai_get_drvdata(dai); @@ -1679,6 +1715,7 @@ const struct dai_driver dmic_driver = { .ops = { .trigger = dmic_trigger, .set_config = dmic_set_config, + .get_hw_params = dmic_get_hw_params, .pm_context_store = dmic_context_store, .pm_context_restore = dmic_context_restore, .get_handshake = dmic_get_handshake, diff --git a/src/drivers/intel/cavs/hda.c b/src/drivers/intel/cavs/hda.c index 918221ebc..0a3ad19b9 100644 --- a/src/drivers/intel/cavs/hda.c +++ b/src/drivers/intel/cavs/hda.c @@ -10,6 +10,7 @@ #include #include #include +#include static int hda_trigger(struct dai *dai, int cmd, int direction) { @@ -22,6 +23,19 @@ static int hda_set_config(struct dai *dai, return 0; } +/* get HDA hw params */ +static int hda_get_hw_params(struct dai *dai, + struct sof_ipc_stream_params *params) +{ + /* 0 means variable */ + params->rate = 0; + params->channels = 0; + params->buffer_fmt = 0; + params->frame_fmt = 0; + + return 0; +} + static int hda_dummy(struct dai *dai) { return 0; @@ -152,6 +166,7 @@ const struct dai_driver hda_driver = { .set_config = hda_set_config, .pm_context_store = hda_dummy, .pm_context_restore = hda_dummy, + .get_hw_params = hda_get_hw_params, .get_handshake = hda_get_handshake, .get_fifo = hda_get_fifo, .probe = hda_dummy, diff --git a/src/drivers/intel/cavs/ssp.c b/src/drivers/intel/cavs/ssp.c index abaa4165c..78b9aa612 100644 --- a/src/drivers/intel/cavs/ssp.c +++ b/src/drivers/intel/cavs/ssp.c @@ -617,6 +617,34 @@ out: return ret; } +/* get SSP hw params */ +static int ssp_get_hw_params(struct dai *dai, + struct sof_ipc_stream_params *params) +{ + struct ssp_pdata *ssp = dai_get_drvdata(dai); + + params->rate = ssp->params.fsync_rate; + params->channels = ssp->params.tdm_slots; + params->buffer_fmt = 0; + + switch (ssp->params.sample_valid_bits) { + case 16: + params->frame_fmt = SOF_IPC_FRAME_S16_LE; + break; + case 24: + params->frame_fmt = SOF_IPC_FRAME_S24_4LE; + break; + case 32: + params->frame_fmt = SOF_IPC_FRAME_S32_LE; + break; + default: + dai_err(dai, "ssp_get_hw_params(): not supported format"); + return -EINVAL; + } + + return 0; +} + /* start the SSP for either playback or capture */ static void ssp_start(struct dai *dai, int direction) { @@ -957,6 +985,7 @@ const struct dai_driver ssp_driver = { .set_config = ssp_set_config, .pm_context_store = ssp_context_store, .pm_context_restore = ssp_context_restore, + .get_hw_params = ssp_get_hw_params, .get_handshake = ssp_get_handshake, .get_fifo = ssp_get_fifo, .probe = ssp_probe, diff --git a/src/drivers/intel/haswell/ssp.c b/src/drivers/intel/haswell/ssp.c index 297b7155e..2f75e2f84 100644 --- a/src/drivers/intel/haswell/ssp.c +++ b/src/drivers/intel/haswell/ssp.c @@ -388,6 +388,34 @@ out: return ret; } +/* get SSP hw params */ +static int ssp_get_hw_params(struct dai *dai, + struct sof_ipc_stream_params *params) +{ + struct ssp_pdata *ssp = dai_get_drvdata(dai); + + params->rate = ssp->params.fsync_rate; + params->channels = ssp->params.tdm_slots; + params->buffer_fmt = 0; + + switch (ssp->params.sample_valid_bits) { + case 16: + params->frame_fmt = SOF_IPC_FRAME_S16_LE; + break; + case 24: + params->frame_fmt = SOF_IPC_FRAME_S24_4LE; + break; + case 32: + params->frame_fmt = SOF_IPC_FRAME_S32_LE; + break; + default: + dai_err(dai, "ssp_get_hw_params(): not supported format"); + return -EINVAL; + } + + return 0; +} + /* start the SSP for either playback or capture */ static void ssp_start(struct dai *dai, int direction) { @@ -523,6 +551,7 @@ const struct dai_driver ssp_driver = { .set_config = ssp_set_config, .pm_context_store = ssp_context_store, .pm_context_restore = ssp_context_restore, + .get_hw_params = ssp_get_hw_params, .get_handshake = ssp_get_handshake, .get_fifo = ssp_get_fifo, .probe = ssp_probe,