driver: dai: implement get_hw_params() for specific dai's

Implements get_hw_params() function for specific DAI's (SSP, HDA,
ALH etc.) in order to fetch hardware stream parameters (set in
ipc_dai_config()). In case the specific DAI is able to support
different formats (e.g. HDA - it is configured via dma_set_config()
in dai_params()) params are set to 0 to indicate that they can vary.

Signed-off-by: Bartosz Kokoszko <bartoszx.kokoszko@linux.intel.com>
This commit is contained in:
Bartosz Kokoszko 2020-01-08 12:51:24 +01:00 committed by Liam Girdwood
parent b0ad9578a7
commit cf820a7445
6 changed files with 153 additions and 0 deletions

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -10,6 +10,7 @@
#include <sof/lib/dai.h>
#include <sof/lib/dma.h>
#include <ipc/dai.h>
#include <ipc/stream.h>
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,

View File

@ -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,

View File

@ -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,