Lines Matching refs:dw
160 static void dw_hdmi_reformat_iec958(struct snd_dw_hdmi *dw, in dw_hdmi_reformat_iec958() argument
163 u32 *src = dw->buf_src + offset; in dw_hdmi_reformat_iec958()
164 u32 *dst = dw->buf_dst + offset; in dw_hdmi_reformat_iec958()
165 u32 *end = dw->buf_src + offset + bytes; in dw_hdmi_reformat_iec958()
188 static void dw_hdmi_reformat_s24(struct snd_dw_hdmi *dw, in dw_hdmi_reformat_s24() argument
191 u32 *src = dw->buf_src + offset; in dw_hdmi_reformat_s24()
192 u32 *dst = dw->buf_dst + offset; in dw_hdmi_reformat_s24()
193 u32 *end = dw->buf_src + offset + bytes; in dw_hdmi_reformat_s24()
199 cs = dw->cs[dw->iec_offset++]; in dw_hdmi_reformat_s24()
200 if (dw->iec_offset >= 192) in dw_hdmi_reformat_s24()
201 dw->iec_offset = 0; in dw_hdmi_reformat_s24()
203 i = dw->channels; in dw_hdmi_reformat_s24()
216 static void dw_hdmi_create_cs(struct snd_dw_hdmi *dw, in dw_hdmi_create_cs() argument
224 memset(dw->cs, 0, sizeof(dw->cs)); in dw_hdmi_create_cs()
234 dw->cs[i * 8 + j][ch] = (c & 1) << 2; in dw_hdmi_create_cs()
237 dw->cs[0][0] |= BIT(4); in dw_hdmi_create_cs()
240 static void dw_hdmi_start_dma(struct snd_dw_hdmi *dw) in dw_hdmi_start_dma() argument
242 void __iomem *base = dw->data.base; in dw_hdmi_start_dma()
243 unsigned offset = dw->buf_offset; in dw_hdmi_start_dma()
244 unsigned period = dw->buf_period; in dw_hdmi_start_dma()
247 dw->reformat(dw, offset, period); in dw_hdmi_start_dma()
253 start = dw->buf_addr + offset; in dw_hdmi_start_dma()
264 if (offset >= dw->buf_size) in dw_hdmi_start_dma()
266 dw->buf_offset = offset; in dw_hdmi_start_dma()
269 static void dw_hdmi_stop_dma(struct snd_dw_hdmi *dw) in dw_hdmi_stop_dma() argument
272 writeb_relaxed(~0, dw->data.base + HDMI_AHB_DMA_MASK); in dw_hdmi_stop_dma()
273 writeb_relaxed(HDMI_AHB_DMA_STOP_STOP, dw->data.base + HDMI_AHB_DMA_STOP); in dw_hdmi_stop_dma()
278 struct snd_dw_hdmi *dw = data; in snd_dw_hdmi_irq() local
282 stat = readb_relaxed(dw->data.base + HDMI_IH_AHBDMAAUD_STAT0); in snd_dw_hdmi_irq()
286 writeb_relaxed(stat, dw->data.base + HDMI_IH_AHBDMAAUD_STAT0); in snd_dw_hdmi_irq()
288 substream = dw->substream; in snd_dw_hdmi_irq()
292 spin_lock(&dw->lock); in snd_dw_hdmi_irq()
293 if (dw->substream) in snd_dw_hdmi_irq()
294 dw_hdmi_start_dma(dw); in snd_dw_hdmi_irq()
295 spin_unlock(&dw->lock); in snd_dw_hdmi_irq()
328 struct snd_dw_hdmi *dw = substream->private_data; in dw_hdmi_open() local
329 void __iomem *base = dw->data.base; in dw_hdmi_open()
334 ret = snd_pcm_hw_constraint_eld(runtime, dw->data.eld); in dw_hdmi_open()
366 ret = request_irq(dw->data.irq, snd_dw_hdmi_irq, IRQF_SHARED, in dw_hdmi_open()
367 "dw-hdmi-audio", dw); in dw_hdmi_open()
381 struct snd_dw_hdmi *dw = substream->private_data; in dw_hdmi_close() local
385 dw->data.base + HDMI_IH_MUTE_AHBDMAAUD_STAT0); in dw_hdmi_close()
387 free_irq(dw->data.irq, dw); in dw_hdmi_close()
408 struct snd_dw_hdmi *dw = substream->private_data; in dw_hdmi_prepare() local
412 switch (dw->revision) { in dw_hdmi_prepare()
431 dw_hdmi_set_sample_rate(dw->data.hdmi, runtime->rate); in dw_hdmi_prepare()
449 writeb_relaxed(threshold, dw->data.base + HDMI_AHB_DMA_THRSLD); in dw_hdmi_prepare()
450 writeb_relaxed(conf0, dw->data.base + HDMI_AHB_DMA_CONF0); in dw_hdmi_prepare()
451 writeb_relaxed(conf1, dw->data.base + HDMI_AHB_DMA_CONF1); in dw_hdmi_prepare()
452 writeb_relaxed(layout, dw->data.base + HDMI_FC_AUDSCONF); in dw_hdmi_prepare()
453 writeb_relaxed(ca, dw->data.base + HDMI_FC_AUDICONF2); in dw_hdmi_prepare()
457 dw->reformat = dw_hdmi_reformat_iec958; in dw_hdmi_prepare()
460 dw_hdmi_create_cs(dw, runtime); in dw_hdmi_prepare()
461 dw->reformat = dw_hdmi_reformat_s24; in dw_hdmi_prepare()
464 dw->iec_offset = 0; in dw_hdmi_prepare()
465 dw->channels = runtime->channels; in dw_hdmi_prepare()
466 dw->buf_src = runtime->dma_area; in dw_hdmi_prepare()
467 dw->buf_dst = substream->dma_buffer.area; in dw_hdmi_prepare()
468 dw->buf_addr = substream->dma_buffer.addr; in dw_hdmi_prepare()
469 dw->buf_period = snd_pcm_lib_period_bytes(substream); in dw_hdmi_prepare()
470 dw->buf_size = snd_pcm_lib_buffer_bytes(substream); in dw_hdmi_prepare()
477 struct snd_dw_hdmi *dw = substream->private_data; in dw_hdmi_trigger() local
483 spin_lock_irqsave(&dw->lock, flags); in dw_hdmi_trigger()
484 dw->buf_offset = 0; in dw_hdmi_trigger()
485 dw->substream = substream; in dw_hdmi_trigger()
486 dw_hdmi_start_dma(dw); in dw_hdmi_trigger()
487 dw_hdmi_audio_enable(dw->data.hdmi); in dw_hdmi_trigger()
488 spin_unlock_irqrestore(&dw->lock, flags); in dw_hdmi_trigger()
493 spin_lock_irqsave(&dw->lock, flags); in dw_hdmi_trigger()
494 dw->substream = NULL; in dw_hdmi_trigger()
495 dw_hdmi_stop_dma(dw); in dw_hdmi_trigger()
496 dw_hdmi_audio_disable(dw->data.hdmi); in dw_hdmi_trigger()
497 spin_unlock_irqrestore(&dw->lock, flags); in dw_hdmi_trigger()
511 struct snd_dw_hdmi *dw = substream->private_data; in dw_hdmi_pointer() local
517 return bytes_to_frames(runtime, dw->buf_offset); in dw_hdmi_pointer()
536 struct snd_dw_hdmi *dw; in snd_dw_hdmi_probe() local
562 dw = card->private_data; in snd_dw_hdmi_probe()
563 dw->card = card; in snd_dw_hdmi_probe()
564 dw->data = *data; in snd_dw_hdmi_probe()
565 dw->revision = revision; in snd_dw_hdmi_probe()
567 spin_lock_init(&dw->lock); in snd_dw_hdmi_probe()
573 dw->pcm = pcm; in snd_dw_hdmi_probe()
574 pcm->private_data = dw; in snd_dw_hdmi_probe()
589 platform_set_drvdata(pdev, dw); in snd_dw_hdmi_probe()
600 struct snd_dw_hdmi *dw = platform_get_drvdata(pdev); in snd_dw_hdmi_remove() local
602 snd_card_free(dw->card); in snd_dw_hdmi_remove()
614 struct snd_dw_hdmi *dw = dev_get_drvdata(dev); in snd_dw_hdmi_suspend() local
616 snd_power_change_state(dw->card, SNDRV_CTL_POWER_D3cold); in snd_dw_hdmi_suspend()
617 snd_pcm_suspend_all(dw->pcm); in snd_dw_hdmi_suspend()
624 struct snd_dw_hdmi *dw = dev_get_drvdata(dev); in snd_dw_hdmi_resume() local
626 snd_power_change_state(dw->card, SNDRV_CTL_POWER_D0); in snd_dw_hdmi_resume()