Lines Matching refs:reader
46 struct uniperif *reader = dev_id; in uni_reader_irq_handler() local
49 spin_lock(&reader->irq_lock); in uni_reader_irq_handler()
50 if (!reader->substream) in uni_reader_irq_handler()
53 snd_pcm_stream_lock(reader->substream); in uni_reader_irq_handler()
54 if (reader->state == UNIPERIF_STATE_STOPPED) { in uni_reader_irq_handler()
56 dev_warn(reader->dev, "unexpected IRQ\n"); in uni_reader_irq_handler()
61 status = GET_UNIPERIF_ITS(reader); in uni_reader_irq_handler()
62 SET_UNIPERIF_ITS_BCLR(reader, status); in uni_reader_irq_handler()
65 if (unlikely(status & UNIPERIF_ITS_FIFO_ERROR_MASK(reader))) { in uni_reader_irq_handler()
66 dev_err(reader->dev, "FIFO error detected\n"); in uni_reader_irq_handler()
68 snd_pcm_stop(reader->substream, SNDRV_PCM_STATE_XRUN); in uni_reader_irq_handler()
74 snd_pcm_stream_unlock(reader->substream); in uni_reader_irq_handler()
76 spin_unlock(&reader->irq_lock); in uni_reader_irq_handler()
82 struct uniperif *reader) in uni_reader_prepare_pcm() argument
87 if ((reader->daifmt & SND_SOC_DAIFMT_FORMAT_MASK) in uni_reader_prepare_pcm()
104 SET_UNIPERIF_I2S_FMT_NBIT_32(reader); in uni_reader_prepare_pcm()
105 SET_UNIPERIF_I2S_FMT_DATA_SIZE_32(reader); in uni_reader_prepare_pcm()
108 SET_UNIPERIF_I2S_FMT_NBIT_16(reader); in uni_reader_prepare_pcm()
109 SET_UNIPERIF_I2S_FMT_DATA_SIZE_16(reader); in uni_reader_prepare_pcm()
112 dev_err(reader->dev, "subframe format not supported\n"); in uni_reader_prepare_pcm()
120 SET_UNIPERIF_CONFIG_MEM_FMT_16_16(reader); in uni_reader_prepare_pcm()
128 SET_UNIPERIF_CONFIG_MEM_FMT_16_0(reader); in uni_reader_prepare_pcm()
132 dev_err(reader->dev, "format not supported\n"); in uni_reader_prepare_pcm()
139 dev_err(reader->dev, "%s: invalid nb of channels\n", __func__); in uni_reader_prepare_pcm()
143 SET_UNIPERIF_I2S_FMT_NUM_CH(reader, runtime->channels / 2); in uni_reader_prepare_pcm()
144 SET_UNIPERIF_I2S_FMT_ORDER_MSB(reader); in uni_reader_prepare_pcm()
150 struct uniperif *reader) in uni_reader_prepare_tdm() argument
160 SET_UNIPERIF_CONFIG_MEM_FMT_16_0(reader); in uni_reader_prepare_tdm()
161 SET_UNIPERIF_I2S_FMT_DATA_SIZE_32(reader); in uni_reader_prepare_tdm()
164 SET_UNIPERIF_I2S_FMT_NUM_CH(reader, frame_size / 4 / 2); in uni_reader_prepare_tdm()
166 SET_UNIPERIF_I2S_FMT_ORDER_MSB(reader); in uni_reader_prepare_tdm()
167 SET_UNIPERIF_I2S_FMT_ALIGN_LEFT(reader); in uni_reader_prepare_tdm()
168 SET_UNIPERIF_TDM_ENABLE_TDM_ENABLE(reader); in uni_reader_prepare_tdm()
177 sti_uniperiph_get_tdm_word_pos(reader, word_pos); in uni_reader_prepare_tdm()
178 SET_UNIPERIF_TDM_WORD_POS(reader, 1_2, word_pos[WORD_1_2]); in uni_reader_prepare_tdm()
179 SET_UNIPERIF_TDM_WORD_POS(reader, 3_4, word_pos[WORD_3_4]); in uni_reader_prepare_tdm()
180 SET_UNIPERIF_TDM_WORD_POS(reader, 5_6, word_pos[WORD_5_6]); in uni_reader_prepare_tdm()
181 SET_UNIPERIF_TDM_WORD_POS(reader, 7_8, word_pos[WORD_7_8]); in uni_reader_prepare_tdm()
190 struct uniperif *reader = priv->dai_data.uni; in uni_reader_prepare() local
195 if (reader->state != UNIPERIF_STATE_STOPPED) { in uni_reader_prepare()
196 dev_err(reader->dev, "%s: invalid reader state %d\n", __func__, in uni_reader_prepare()
197 reader->state); in uni_reader_prepare()
202 if (reader->type == SND_ST_UNIPERIF_TYPE_TDM) { in uni_reader_prepare()
211 if (reader->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0) in uni_reader_prepare()
224 (trigger_limit > UNIPERIF_CONFIG_DMA_TRIG_LIMIT_MASK(reader))) { in uni_reader_prepare()
225 dev_err(reader->dev, "invalid trigger limit %d\n", in uni_reader_prepare()
230 SET_UNIPERIF_CONFIG_DMA_TRIG_LIMIT(reader, trigger_limit); in uni_reader_prepare()
232 if (UNIPERIF_TYPE_IS_TDM(reader)) in uni_reader_prepare()
233 ret = uni_reader_prepare_tdm(runtime, reader); in uni_reader_prepare()
235 ret = uni_reader_prepare_pcm(runtime, reader); in uni_reader_prepare()
239 switch (reader->daifmt & SND_SOC_DAIFMT_FORMAT_MASK) { in uni_reader_prepare()
241 SET_UNIPERIF_I2S_FMT_ALIGN_LEFT(reader); in uni_reader_prepare()
242 SET_UNIPERIF_I2S_FMT_PADDING_I2S_MODE(reader); in uni_reader_prepare()
245 SET_UNIPERIF_I2S_FMT_ALIGN_LEFT(reader); in uni_reader_prepare()
246 SET_UNIPERIF_I2S_FMT_PADDING_SONY_MODE(reader); in uni_reader_prepare()
249 SET_UNIPERIF_I2S_FMT_ALIGN_RIGHT(reader); in uni_reader_prepare()
250 SET_UNIPERIF_I2S_FMT_PADDING_SONY_MODE(reader); in uni_reader_prepare()
253 dev_err(reader->dev, "format not supported\n"); in uni_reader_prepare()
258 switch (reader->daifmt & SND_SOC_DAIFMT_INV_MASK) { in uni_reader_prepare()
260 SET_UNIPERIF_I2S_FMT_LR_POL_LOW(reader); in uni_reader_prepare()
261 SET_UNIPERIF_I2S_FMT_SCLK_EDGE_RISING(reader); in uni_reader_prepare()
264 SET_UNIPERIF_I2S_FMT_LR_POL_HIG(reader); in uni_reader_prepare()
265 SET_UNIPERIF_I2S_FMT_SCLK_EDGE_RISING(reader); in uni_reader_prepare()
268 SET_UNIPERIF_I2S_FMT_LR_POL_LOW(reader); in uni_reader_prepare()
269 SET_UNIPERIF_I2S_FMT_SCLK_EDGE_FALLING(reader); in uni_reader_prepare()
272 SET_UNIPERIF_I2S_FMT_LR_POL_HIG(reader); in uni_reader_prepare()
273 SET_UNIPERIF_I2S_FMT_SCLK_EDGE_FALLING(reader); in uni_reader_prepare()
278 SET_UNIPERIF_ITS_BCLR(reader, GET_UNIPERIF_ITS(reader)); in uni_reader_prepare()
280 SET_UNIPERIF_I2S_FMT_NO_OF_SAMPLES_TO_READ(reader, 0); in uni_reader_prepare()
283 SET_UNIPERIF_ITM_BSET_DMA_ERROR(reader); in uni_reader_prepare()
284 SET_UNIPERIF_ITM_BSET_FIFO_ERROR(reader); in uni_reader_prepare()
285 SET_UNIPERIF_ITM_BSET_MEM_BLK_READ(reader); in uni_reader_prepare()
288 if (reader->underflow_enabled) { in uni_reader_prepare()
289 SET_UNIPERIF_ITM_BSET_UNDERFLOW_REC_DONE(reader); in uni_reader_prepare()
290 SET_UNIPERIF_ITM_BSET_UNDERFLOW_REC_FAILED(reader); in uni_reader_prepare()
294 return sti_uniperiph_reset(reader); in uni_reader_prepare()
297 static int uni_reader_start(struct uniperif *reader) in uni_reader_start() argument
300 if (reader->state != UNIPERIF_STATE_STOPPED) { in uni_reader_start()
301 dev_err(reader->dev, "%s: invalid reader state\n", __func__); in uni_reader_start()
306 SET_UNIPERIF_ITS_BCLR_FIFO_ERROR(reader); in uni_reader_start()
307 SET_UNIPERIF_ITM_BSET_FIFO_ERROR(reader); in uni_reader_start()
310 SET_UNIPERIF_CTRL_OPERATION_PCM_DATA(reader); in uni_reader_start()
313 reader->state = UNIPERIF_STATE_STARTED; in uni_reader_start()
317 static int uni_reader_stop(struct uniperif *reader) in uni_reader_stop() argument
320 if (reader->state == UNIPERIF_STATE_STOPPED) { in uni_reader_stop()
321 dev_err(reader->dev, "%s: invalid reader state\n", __func__); in uni_reader_stop()
326 SET_UNIPERIF_CTRL_OPERATION_OFF(reader); in uni_reader_stop()
329 SET_UNIPERIF_ITM_BCLR(reader, GET_UNIPERIF_ITM(reader)); in uni_reader_stop()
332 reader->state = UNIPERIF_STATE_STOPPED; in uni_reader_stop()
341 struct uniperif *reader = priv->dai_data.uni; in uni_reader_trigger() local
345 return uni_reader_start(reader); in uni_reader_trigger()
347 return uni_reader_stop(reader); in uni_reader_trigger()
357 struct uniperif *reader = priv->dai_data.uni; in uni_reader_startup() local
361 spin_lock_irqsave(&reader->irq_lock, flags); in uni_reader_startup()
362 reader->substream = substream; in uni_reader_startup()
363 spin_unlock_irqrestore(&reader->irq_lock, flags); in uni_reader_startup()
365 if (!UNIPERIF_TYPE_IS_TDM(reader)) in uni_reader_startup()
372 reader, SNDRV_PCM_HW_PARAM_CHANNELS, in uni_reader_startup()
380 reader, SNDRV_PCM_HW_PARAM_FORMAT, in uni_reader_startup()
388 struct uniperif *reader = priv->dai_data.uni; in uni_reader_shutdown() local
391 spin_lock_irqsave(&reader->irq_lock, flags); in uni_reader_shutdown()
392 if (reader->state != UNIPERIF_STATE_STOPPED) { in uni_reader_shutdown()
394 uni_reader_stop(reader); in uni_reader_shutdown()
396 reader->substream = NULL; in uni_reader_shutdown()
397 spin_unlock_irqrestore(&reader->irq_lock, flags); in uni_reader_shutdown()
411 struct uniperif *reader) in uni_reader_init() argument
415 reader->dev = &pdev->dev; in uni_reader_init()
416 reader->state = UNIPERIF_STATE_STOPPED; in uni_reader_init()
417 reader->dai_ops = &uni_reader_dai_ops; in uni_reader_init()
419 if (UNIPERIF_TYPE_IS_TDM(reader)) in uni_reader_init()
420 reader->hw = &uni_tdm_hw; in uni_reader_init()
422 reader->hw = &uni_reader_pcm_hw; in uni_reader_init()
424 ret = devm_request_irq(&pdev->dev, reader->irq, in uni_reader_init()
426 dev_name(&pdev->dev), reader); in uni_reader_init()
432 spin_lock_init(&reader->irq_lock); in uni_reader_init()