Skip to content

Commit 5562fa3

Browse files
committed
drivers: apl-ssp: handle tdm mode in ssp
I've added tdm support in ssp. Tdm mode has padding at the end of each slot. Tdm mode is enabled by tdm_per_slot_padding flag in sof_ipc_dai_ssp_params struct. Signed-off-by: Bartosz Kokoszko <bartoszx.kokoszko@linux.intel.com>
1 parent 9fe51a4 commit 5562fa3

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

src/drivers/apl-ssp.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,32 @@ static inline int ssp_set_config(struct dai *dai,
574574
active_tx_slots = hweight_32(config->ssp.tx_slots);
575575
active_rx_slots = hweight_32(config->ssp.rx_slots);
576576

577+
/*
578+
* handle TDM mode, TDM mode has padding at the end of
579+
* each slot. The amount of padding is equal to result of
580+
* subtracting slot width and valid bits per slot.
581+
*/
582+
if (ssp->params.tdm_per_slot_padding_flag) {
583+
frame_end_padding = bdiv - config->ssp.tdm_slots *
584+
config->ssp.tdm_slot_width;
585+
586+
slot_end_padding = config->ssp.tdm_slot_width -
587+
config->ssp.sample_valid_bits;
588+
589+
if (slot_end_padding >
590+
SOF_DAI_INTEL_SSP_SLOT_PADDING_MAX) {
591+
trace_ssp_error("esb");
592+
ret = -EINVAL;
593+
goto out;
594+
}
595+
596+
sspsp |= SSPSP_DMYSTOP(slot_end_padding &
597+
SSPSP_DMYSTOP_MASK);
598+
slot_end_padding >>= SSPSP_DMYSTOP_BITS;
599+
sspsp |= SSPSP_EDMYSTOP(slot_end_padding &
600+
SSPSP_EDMYSTOP_MASK);
601+
}
602+
577603
sspsp2 |= (frame_end_padding & SSPSP2_FEP_MASK);
578604

579605
break;

src/include/uapi/ipc.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ struct sof_ipc_compound_hdr {
241241
/* here is the possibility to define others aux macros */
242242

243243
#define SOF_DAI_INTEL_SSP_FRAME_PULSE_WIDTH_MAX 38
244+
#define SOF_DAI_INTEL_SSP_SLOT_PADDING_MAX 31
244245

245246
/** \brief Types of DAI */
246247
enum sof_ipc_dai_type {
@@ -278,7 +279,7 @@ struct sof_ipc_dai_ssp_params {
278279
uint16_t frame_pulse_width;
279280
uint32_t quirks; // FIXME: is 32 bits enough ?
280281

281-
uint16_t padding;
282+
uint16_t tdm_per_slot_padding_flag;
282283
/* private data, e.g. for quirks */
283284
//uint32_t pdata[10]; // FIXME: would really need ~16 u32
284285
} __attribute__((packed));

0 commit comments

Comments
 (0)