change to get ssp stream format from host via ipc, which make it configurable and easy aligned with codec settings.
set the default format to s24_3le.
Signed-off-by: Keyon Jie yang.jie@linux.intel.com --- src/audio/dai.c | 1 + src/include/reef/dai.h | 1 + src/include/reef/stream.h | 20 ++++++++++++++++++++ src/include/uapi/intel-ipc.h | 1 + src/ipc/intel-ipc.c | 21 +++++++++++++++++---- src/platform/baytrail/include/platform/platform.h | 4 ++-- 6 files changed, 42 insertions(+), 6 deletions(-)
diff --git a/src/audio/dai.c b/src/audio/dai.c index 51ff093..f185569 100644 --- a/src/audio/dai.c +++ b/src/audio/dai.c @@ -451,6 +451,7 @@ static int dai_config(struct comp_dev *dev, struct dai_config *dai_config) { struct dai_data *dd = comp_get_drvdata(dev);
+ dd->stream_format = dai_config->stream_format; return dai_set_config(dd->ssp, dai_config); }
diff --git a/src/include/reef/dai.h b/src/include/reef/dai.h index 5a29e85..095be4c 100644 --- a/src/include/reef/dai.h +++ b/src/include/reef/dai.h @@ -100,6 +100,7 @@ struct dai_slot_map { /* DAI runtime hardware configuration */ struct dai_config { uint32_t format; + uint32_t stream_format; uint32_t frame_size; /* in BCLKs */ struct dai_slot_map tx_slot_map[DAI_NUM_SLOT_MAPS]; struct dai_slot_map rx_slot_map[DAI_NUM_SLOT_MAPS]; diff --git a/src/include/reef/stream.h b/src/include/reef/stream.h index f6101f5..7da7891 100644 --- a/src/include/reef/stream.h +++ b/src/include/reef/stream.h @@ -40,6 +40,26 @@ #define STREAM_TYPE_VORBIS 1 /* other compressed stream types here if supported */
+/* pcm format from host side */ +#define SNDRV_PCM_FORMAT_S8 0 +#define SNDRV_PCM_FORMAT_U8 1 +#define SNDRV_PCM_FORMAT_S16_LE 2 +#define SNDRV_PCM_FORMAT_S16_BE 3 +#define SNDRV_PCM_FORMAT_U16_LE 4 +#define SNDRV_PCM_FORMAT_U16_BE 5 +#define SNDRV_PCM_FORMAT_S24_LE 6 /* low three bytes */ +#define SNDRV_PCM_FORMAT_S24_BE 7 /* low three bytes */ +#define SNDRV_PCM_FORMAT_U24_LE 8 /* low three bytes */ +#define SNDRV_PCM_FORMAT_U24_BE 9 /* low three bytes */ +#define SNDRV_PCM_FORMAT_S32_LE 10 +#define SNDRV_PCM_FORMAT_S32_BE 11 +#define SNDRV_PCM_FORMAT_U32_LE 12 +#define SNDRV_PCM_FORMAT_U32_BE 13 +#define SNDRV_PCM_FORMAT_S24_3LE 32 /* in three bytes */ +#define SNDRV_PCM_FORMAT_S24_3BE 33 /* in three bytes */ +#define SNDRV_PCM_FORMAT_U24_3LE 34 /* in three bytes */ +#define SNDRV_PCM_FORMAT_U24_3BE 35 /* in three bytes */ + /* supported format masks */ #define STREAM_FORMAT_S16_LE 1 #define STREAM_FORMAT_S24_3LE 2 diff --git a/src/include/uapi/intel-ipc.h b/src/include/uapi/intel-ipc.h index 05992e5..c6d3ae8 100644 --- a/src/include/uapi/intel-ipc.h +++ b/src/include/uapi/intel-ipc.h @@ -515,6 +515,7 @@ struct ipc_intel_ipc_device_config_req { uint32_t clock_frequency; uint32_t mode; uint32_t dai_fmt; + uint32_t dai_stream_format; uint16_t clock_divider; uint8_t channels; uint8_t reserved; diff --git a/src/ipc/intel-ipc.c b/src/ipc/intel-ipc.c index 827c9f3..b959baa 100644 --- a/src/ipc/intel-ipc.c +++ b/src/ipc/intel-ipc.c @@ -559,12 +559,25 @@ static uint32_t ipc_device_set_formats(uint32_t header) goto error; }
- /* setup the DAI HW config - TODO hard coded due to IPC limitations */ dai_dev->dai_config.mclk = config_req.clock_frequency; dai_dev->dai_config.format = config_req.dai_fmt; - dai_dev->dai_config.frame_size = 32; /* TODO 16bit stereo hard coded */ - dai_dev->dai_config.bclk_fs = 32; /* 32 BCLKs per frame - */ - dai_dev->dai_config.mclk_fs = 256; + + switch (config_req.dai_stream_format) { + case SNDRV_PCM_FORMAT_S24_3LE: + dai_dev->dai_config.stream_format = STREAM_FORMAT_S24_3LE; + dai_dev->dai_config.frame_size = 24; + dai_dev->dai_config.bclk_fs = 50; /* 50 BCLKs per frame - */ + dai_dev->dai_config.mclk_fs = 400; + break; + case SNDRV_PCM_FORMAT_S16_LE: + dai_dev->dai_config.stream_format = STREAM_FORMAT_S16_LE; + dai_dev->dai_config.frame_size = 16; + dai_dev->dai_config.bclk_fs = 32; /* 50 BCLKs per frame - */ + dai_dev->dai_config.mclk_fs = 256; + break; + default: + goto error; + } dai_dev->dai_config.clk_src = SSP_CLK_EXT;
comp_dai_config(dai_dev->dev.cd, &dai_dev->dai_config); diff --git a/src/platform/baytrail/include/platform/platform.h b/src/platform/baytrail/include/platform/platform.h index e8395a4..7af3b36 100644 --- a/src/platform/baytrail/include/platform/platform.h +++ b/src/platform/baytrail/include/platform/platform.h @@ -39,7 +39,7 @@ #define PLATFORM_SSP_PORT 2
/* default SSP stream format - need aligned with codec setting*/ -#define PLATFORM_SSP_STREAM_FORMAT STREAM_FORMAT_S16_LE +#define PLATFORM_SSP_STREAM_FORMAT STREAM_FORMAT_S24_3LE
/* IPC Interrupt */ #define PLATFORM_IPC_INTERUPT IRQ_NUM_EXT_IA @@ -62,7 +62,7 @@ #define PLAT_HOST_PERIODS 2 /* give enough latency for DMA refill */
/* Platform Dev DMA buffer config - these should align with DMA engine */ -#define PLAT_DEV_PERSIZE 256 /* must be multiple of DMA+DEV burst size */ +#define PLAT_DEV_PERSIZE 512 /* must be multiple of DMA+DEV burst size */ #define PLAT_DEV_PERIODS 2 /* give enough latency for DMA refill */
/* DMA channel drain timeout in microseconds */