Skip to content

Commit bfc7e46

Browse files
authored
Merge pull request #214 from bkokoszx/ssp_slot_padding
drivers: apl-ssp: handle tdm mode in ssp
2 parents 86610e0 + 5562fa3 commit bfc7e46

2 files changed

Lines changed: 32 additions & 36 deletions

File tree

src/drivers/apl-ssp.c

Lines changed: 30 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ static inline int ssp_set_config(struct dai *dai,
137137
uint32_t i2s_m;
138138
uint32_t i2s_n;
139139
uint32_t data_size;
140-
uint32_t start_delay;
140+
uint32_t start_delay = 0;
141141
uint32_t frame_end_padding;
142142
uint32_t slot_end_padding;
143143
uint32_t frame_len = 0;
@@ -536,45 +536,14 @@ static inline int ssp_set_config(struct dai *dai,
536536
break;
537537
case SOF_DAI_FMT_DSP_A:
538538

539-
start_delay = 0;
540-
541-
sscr0 |= SSCR0_MOD | SSCR0_FRDC(config->ssp.tdm_slots);
542-
543-
/* set asserted frame length */
544-
frame_len = 1; /* default */
545-
546-
if (cfs && ssp->params.frame_pulse_width > 0 &&
547-
ssp->params.frame_pulse_width <=
548-
SOF_DAI_INTEL_SSP_FRAME_PULSE_WIDTH_MAX) {
549-
frame_len = ssp->params.frame_pulse_width;
550-
}
551-
552-
/* frame_pulse_width must less or equal 38 */
553-
if (ssp->params.frame_pulse_width >
554-
SOF_DAI_INTEL_SSP_FRAME_PULSE_WIDTH_MAX) {
555-
trace_ssp_error("efa");
556-
ret = -EINVAL;
557-
goto out;
558-
}
559-
560-
/*
561-
* handle frame polarity, DSP_A default is rising/active high,
562-
* non-inverted(inverted_frame=0) -- active high(SFRMP=1),
563-
* inverted(inverted_frame=1) -- falling/active low(SFRMP=0),
564-
* so, we should set SFRMP to !inverted_frame.
565-
*/
566-
sspsp |= SSPSP_SFRMP(!inverted_frame);
539+
start_delay = 1;
567540
sspsp |= SSPSP_FSRT;
568541

569-
active_tx_slots = hweight_32(config->ssp.tx_slots);
570-
active_rx_slots = hweight_32(config->ssp.rx_slots);
571-
572-
sspsp2 |= (frame_end_padding & SSPSP2_FEP_MASK);
542+
/* fallthrough */
573543

574-
break;
575544
case SOF_DAI_FMT_DSP_B:
576545

577-
start_delay = 0;
546+
/* default start_delay value is set to 0 */
578547

579548
sscr0 |= SSCR0_MOD | SSCR0_FRDC(config->ssp.tdm_slots);
580549

@@ -605,6 +574,32 @@ static inline int ssp_set_config(struct dai *dai,
605574
active_tx_slots = hweight_32(config->ssp.tx_slots);
606575
active_rx_slots = hweight_32(config->ssp.rx_slots);
607576

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+
608603
sspsp2 |= (frame_end_padding & SSPSP2_FEP_MASK);
609604

610605
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)