Lines Matching refs:azx_dev

94 void snd_hdac_stream_init(struct hdac_bus *bus, struct hdac_stream *azx_dev,  in snd_hdac_stream_init()  argument
97 azx_dev->bus = bus; in snd_hdac_stream_init()
99 azx_dev->sd_addr = bus->remap_addr + (0x20 * idx + 0x80); in snd_hdac_stream_init()
101 azx_dev->sd_int_sta_mask = 1 << idx; in snd_hdac_stream_init()
102 azx_dev->index = idx; in snd_hdac_stream_init()
103 azx_dev->direction = direction; in snd_hdac_stream_init()
104 azx_dev->stream_tag = tag; in snd_hdac_stream_init()
105 snd_hdac_dsp_lock_init(azx_dev); in snd_hdac_stream_init()
106 list_add_tail(&azx_dev->list, &bus->stream_list); in snd_hdac_stream_init()
109 azx_dev->spib_addr = bus->spbcap + AZX_SPB_BASE + in snd_hdac_stream_init()
113 azx_dev->fifo_addr = bus->spbcap + AZX_SPB_BASE + in snd_hdac_stream_init()
119 azx_dev->dpibr_addr = bus->drsmcap + AZX_DRSM_BASE + in snd_hdac_stream_init()
130 void snd_hdac_stream_start(struct hdac_stream *azx_dev) in snd_hdac_stream_start() argument
132 struct hdac_bus *bus = azx_dev->bus; in snd_hdac_stream_start()
135 trace_snd_hdac_stream_start(bus, azx_dev); in snd_hdac_stream_start()
137 azx_dev->start_wallclk = snd_hdac_chip_readl(bus, WALLCLK); in snd_hdac_stream_start()
141 1 << azx_dev->index, in snd_hdac_stream_start()
142 1 << azx_dev->index); in snd_hdac_stream_start()
144 if (azx_dev->stripe) { in snd_hdac_stream_start()
145 if (azx_dev->substream) in snd_hdac_stream_start()
146 stripe_ctl = snd_hdac_get_stream_stripe_ctl(bus, azx_dev->substream); in snd_hdac_stream_start()
149 snd_hdac_stream_updateb(azx_dev, SD_CTL_3B, SD_CTL_STRIPE_MASK, in snd_hdac_stream_start()
154 snd_hdac_stream_updatel(azx_dev, SD_CTL, in snd_hdac_stream_start()
157 snd_hdac_stream_updateb(azx_dev, SD_CTL, in snd_hdac_stream_start()
159 azx_dev->running = true; in snd_hdac_stream_start()
167 static void snd_hdac_stream_clear(struct hdac_stream *azx_dev) in snd_hdac_stream_clear() argument
169 snd_hdac_stream_updateb(azx_dev, SD_CTL, in snd_hdac_stream_clear()
171 snd_hdac_stream_writeb(azx_dev, SD_STS, SD_INT_MASK); /* to be sure */ in snd_hdac_stream_clear()
172 if (azx_dev->stripe) in snd_hdac_stream_clear()
173 snd_hdac_stream_updateb(azx_dev, SD_CTL_3B, SD_CTL_STRIPE_MASK, 0); in snd_hdac_stream_clear()
174 azx_dev->running = false; in snd_hdac_stream_clear()
183 void snd_hdac_stream_stop(struct hdac_stream *azx_dev) in snd_hdac_stream_stop() argument
185 trace_snd_hdac_stream_stop(azx_dev->bus, azx_dev); in snd_hdac_stream_stop()
187 snd_hdac_stream_clear(azx_dev); in snd_hdac_stream_stop()
189 snd_hdac_chip_updatel(azx_dev->bus, INTCTL, 1 << azx_dev->index, 0); in snd_hdac_stream_stop()
224 void snd_hdac_stream_reset(struct hdac_stream *azx_dev) in snd_hdac_stream_reset() argument
229 snd_hdac_stream_clear(azx_dev); in snd_hdac_stream_reset()
231 dma_run_state = snd_hdac_stream_readb(azx_dev, SD_CTL) & SD_CTL_DMA_START; in snd_hdac_stream_reset()
233 snd_hdac_stream_updateb(azx_dev, SD_CTL, 0, SD_CTL_STREAM_RESET); in snd_hdac_stream_reset()
236 snd_hdac_stream_readb_poll(azx_dev, SD_CTL, val, (val & SD_CTL_STREAM_RESET), 3, 300); in snd_hdac_stream_reset()
238 if (azx_dev->bus->dma_stop_delay && dma_run_state) in snd_hdac_stream_reset()
239 udelay(azx_dev->bus->dma_stop_delay); in snd_hdac_stream_reset()
241 snd_hdac_stream_updateb(azx_dev, SD_CTL, SD_CTL_STREAM_RESET, 0); in snd_hdac_stream_reset()
244 snd_hdac_stream_readb_poll(azx_dev, SD_CTL, val, !(val & SD_CTL_STREAM_RESET), 3, 300); in snd_hdac_stream_reset()
247 if (azx_dev->posbuf) in snd_hdac_stream_reset()
248 *azx_dev->posbuf = 0; in snd_hdac_stream_reset()
257 int snd_hdac_stream_setup(struct hdac_stream *azx_dev, bool code_loading) in snd_hdac_stream_setup() argument
259 struct hdac_bus *bus = azx_dev->bus; in snd_hdac_stream_setup()
265 if (azx_dev->substream) in snd_hdac_stream_setup()
266 runtime = azx_dev->substream->runtime; in snd_hdac_stream_setup()
270 snd_hdac_stream_clear(azx_dev); in snd_hdac_stream_setup()
272 val = snd_hdac_stream_readl(azx_dev, SD_CTL); in snd_hdac_stream_setup()
274 (azx_dev->stream_tag << SD_CTL_STREAM_TAG_SHIFT); in snd_hdac_stream_setup()
277 snd_hdac_stream_writel(azx_dev, SD_CTL, val); in snd_hdac_stream_setup()
280 snd_hdac_stream_writel(azx_dev, SD_CBL, azx_dev->bufsize); in snd_hdac_stream_setup()
284 snd_hdac_stream_writew(azx_dev, SD_FORMAT, azx_dev->format_val); in snd_hdac_stream_setup()
287 snd_hdac_stream_writew(azx_dev, SD_LVI, azx_dev->frags - 1); in snd_hdac_stream_setup()
291 snd_hdac_stream_writel(azx_dev, SD_BDLPL, (u32)azx_dev->bdl.addr); in snd_hdac_stream_setup()
293 snd_hdac_stream_writel(azx_dev, SD_BDLPU, in snd_hdac_stream_setup()
294 upper_32_bits(azx_dev->bdl.addr)); in snd_hdac_stream_setup()
304 snd_hdac_stream_updatel(azx_dev, SD_CTL, 0, SD_INT_MASK); in snd_hdac_stream_setup()
308 ret = snd_hdac_stream_readw_poll(azx_dev, SD_FIFOSIZE, reg, in snd_hdac_stream_setup()
313 azx_dev->fifo_size = reg; in snd_hdac_stream_setup()
321 azx_dev->delay_negative_threshold = in snd_hdac_stream_setup()
324 azx_dev->delay_negative_threshold = 0; in snd_hdac_stream_setup()
328 azx_dev->period_wallclk = (((runtime->period_size * 24000) / in snd_hdac_stream_setup()
339 void snd_hdac_stream_cleanup(struct hdac_stream *azx_dev) in snd_hdac_stream_cleanup() argument
341 snd_hdac_stream_writel(azx_dev, SD_BDLPL, 0); in snd_hdac_stream_cleanup()
342 snd_hdac_stream_writel(azx_dev, SD_BDLPU, 0); in snd_hdac_stream_cleanup()
343 snd_hdac_stream_writel(azx_dev, SD_CTL, 0); in snd_hdac_stream_cleanup()
344 azx_dev->bufsize = 0; in snd_hdac_stream_cleanup()
345 azx_dev->period_bytes = 0; in snd_hdac_stream_cleanup()
346 azx_dev->format_val = 0; in snd_hdac_stream_cleanup()
364 struct hdac_stream *azx_dev; in snd_hdac_stream_assign() local
374 list_for_each_entry(azx_dev, &bus->stream_list, list) { in snd_hdac_stream_assign()
375 if (azx_dev->direction != substream->stream) in snd_hdac_stream_assign()
377 if (azx_dev->opened) in snd_hdac_stream_assign()
379 if (azx_dev->assigned_key == key) { in snd_hdac_stream_assign()
380 res = azx_dev; in snd_hdac_stream_assign()
384 res = azx_dev; in snd_hdac_stream_assign()
404 void snd_hdac_stream_release_locked(struct hdac_stream *azx_dev) in snd_hdac_stream_release_locked() argument
406 azx_dev->opened = 0; in snd_hdac_stream_release_locked()
407 azx_dev->running = 0; in snd_hdac_stream_release_locked()
408 azx_dev->substream = NULL; in snd_hdac_stream_release_locked()
418 void snd_hdac_stream_release(struct hdac_stream *azx_dev) in snd_hdac_stream_release() argument
420 struct hdac_bus *bus = azx_dev->bus; in snd_hdac_stream_release()
423 snd_hdac_stream_release_locked(azx_dev); in snd_hdac_stream_release()
455 struct hdac_stream *azx_dev, __le32 **bdlp, in setup_bdle() argument
464 if (azx_dev->frags >= AZX_MAX_BDL_ENTRIES) in setup_bdle()
487 azx_dev->frags++; in setup_bdle()
503 static int snd_hdac_stream_setup_bdle(struct hdac_stream *azx_dev, struct snd_dma_buffer *dmab, in snd_hdac_stream_setup_bdle() argument
506 struct hdac_bus *bus = azx_dev->bus; in snd_hdac_stream_setup_bdle()
512 snd_hdac_stream_writel(azx_dev, SD_BDLPL, 0); in snd_hdac_stream_setup_bdle()
513 snd_hdac_stream_writel(azx_dev, SD_BDLPU, 0); in snd_hdac_stream_setup_bdle()
515 period_bytes = azx_dev->period_bytes; in snd_hdac_stream_setup_bdle()
516 periods = azx_dev->bufsize / period_bytes; in snd_hdac_stream_setup_bdle()
519 bdl = (__le32 *)azx_dev->bdl.area; in snd_hdac_stream_setup_bdle()
521 azx_dev->frags = 0; in snd_hdac_stream_setup_bdle()
524 if (runtime && !azx_dev->no_period_wakeup && pos_adj > 0) { in snd_hdac_stream_setup_bdle()
537 ofs = setup_bdle(bus, dmab, azx_dev, in snd_hdac_stream_setup_bdle()
547 ofs = setup_bdle(bus, dmab, azx_dev, in snd_hdac_stream_setup_bdle()
550 ofs = setup_bdle(bus, dmab, azx_dev, in snd_hdac_stream_setup_bdle()
552 !azx_dev->no_period_wakeup); in snd_hdac_stream_setup_bdle()
560 azx_dev->bufsize, period_bytes); in snd_hdac_stream_setup_bdle()
571 int snd_hdac_stream_setup_periods(struct hdac_stream *azx_dev) in snd_hdac_stream_setup_periods() argument
573 struct snd_pcm_substream *substream = azx_dev->substream; in snd_hdac_stream_setup_periods()
574 struct snd_compr_stream *cstream = azx_dev->cstream; in snd_hdac_stream_setup_periods()
588 return snd_hdac_stream_setup_bdle(azx_dev, dmab, runtime); in snd_hdac_stream_setup_periods()
600 int snd_hdac_stream_set_params(struct hdac_stream *azx_dev, in snd_hdac_stream_set_params() argument
603 struct snd_pcm_substream *substream = azx_dev->substream; in snd_hdac_stream_set_params()
604 struct snd_compr_stream *cstream = azx_dev->cstream; in snd_hdac_stream_set_params()
621 if (bufsize != azx_dev->bufsize || in snd_hdac_stream_set_params()
622 period_bytes != azx_dev->period_bytes || in snd_hdac_stream_set_params()
623 format_val != azx_dev->format_val || in snd_hdac_stream_set_params()
624 no_period_wakeup != azx_dev->no_period_wakeup) { in snd_hdac_stream_set_params()
625 azx_dev->bufsize = bufsize; in snd_hdac_stream_set_params()
626 azx_dev->period_bytes = period_bytes; in snd_hdac_stream_set_params()
627 azx_dev->format_val = format_val; in snd_hdac_stream_set_params()
628 azx_dev->no_period_wakeup = no_period_wakeup; in snd_hdac_stream_set_params()
629 err = snd_hdac_stream_setup_periods(azx_dev); in snd_hdac_stream_set_params()
639 struct hdac_stream *azx_dev = container_of(cc, struct hdac_stream, cc); in azx_cc_read() local
641 return snd_hdac_chip_readl(azx_dev->bus, WALLCLK); in azx_cc_read()
644 static void azx_timecounter_init(struct hdac_stream *azx_dev, in azx_timecounter_init() argument
647 struct timecounter *tc = &azx_dev->tc; in azx_timecounter_init()
648 struct cyclecounter *cc = &azx_dev->cc; in azx_timecounter_init()
683 void snd_hdac_stream_timecounter_init(struct hdac_stream *azx_dev, in snd_hdac_stream_timecounter_init() argument
686 struct hdac_bus *bus = azx_dev->bus; in snd_hdac_stream_timecounter_init()
687 struct snd_pcm_runtime *runtime = azx_dev->substream->runtime; in snd_hdac_stream_timecounter_init()
718 void snd_hdac_stream_sync_trigger(struct hdac_stream *azx_dev, bool set, in snd_hdac_stream_sync_trigger() argument
721 struct hdac_bus *bus = azx_dev->bus; in snd_hdac_stream_sync_trigger()
744 void snd_hdac_stream_sync(struct hdac_stream *azx_dev, bool start, in snd_hdac_stream_sync() argument
747 struct hdac_bus *bus = azx_dev->bus; in snd_hdac_stream_sync()
815 struct hdac_stream *azx_dev, u32 value) in snd_hdac_stream_set_spib() argument
822 writel(value, azx_dev->spib_addr); in snd_hdac_stream_set_spib()
859 int snd_hdac_stream_wait_drsm(struct hdac_stream *azx_dev) in snd_hdac_stream_wait_drsm() argument
861 struct hdac_bus *bus = azx_dev->bus; in snd_hdac_stream_wait_drsm()
865 mask = 1 << azx_dev->index; in snd_hdac_stream_wait_drsm()
882 struct hdac_stream *azx_dev, u32 value) in snd_hdac_stream_set_dpibr() argument
889 writel(value, azx_dev->dpibr_addr); in snd_hdac_stream_set_dpibr()
900 int snd_hdac_stream_set_lpib(struct hdac_stream *azx_dev, u32 value) in snd_hdac_stream_set_lpib() argument
902 snd_hdac_stream_writel(azx_dev, SD_LPIB, value); in snd_hdac_stream_set_lpib()
919 int snd_hdac_dsp_prepare(struct hdac_stream *azx_dev, unsigned int format, in snd_hdac_dsp_prepare() argument
922 struct hdac_bus *bus = azx_dev->bus; in snd_hdac_dsp_prepare()
925 snd_hdac_dsp_lock(azx_dev); in snd_hdac_dsp_prepare()
927 if (azx_dev->running || azx_dev->locked) { in snd_hdac_dsp_prepare()
932 azx_dev->locked = true; in snd_hdac_dsp_prepare()
940 azx_dev->substream = NULL; in snd_hdac_dsp_prepare()
941 azx_dev->bufsize = byte_size; in snd_hdac_dsp_prepare()
943 azx_dev->period_bytes = byte_size / 2; in snd_hdac_dsp_prepare()
944 azx_dev->format_val = format; in snd_hdac_dsp_prepare()
945 azx_dev->no_period_wakeup = 1; in snd_hdac_dsp_prepare()
947 snd_hdac_stream_reset(azx_dev); in snd_hdac_dsp_prepare()
949 err = snd_hdac_stream_setup_bdle(azx_dev, bufp, NULL); in snd_hdac_dsp_prepare()
953 snd_hdac_stream_setup(azx_dev, true); in snd_hdac_dsp_prepare()
954 snd_hdac_dsp_unlock(azx_dev); in snd_hdac_dsp_prepare()
955 return azx_dev->stream_tag; in snd_hdac_dsp_prepare()
961 azx_dev->locked = false; in snd_hdac_dsp_prepare()
964 snd_hdac_dsp_unlock(azx_dev); in snd_hdac_dsp_prepare()
974 void snd_hdac_dsp_trigger(struct hdac_stream *azx_dev, bool start) in snd_hdac_dsp_trigger() argument
977 snd_hdac_stream_start(azx_dev); in snd_hdac_dsp_trigger()
979 snd_hdac_stream_stop(azx_dev); in snd_hdac_dsp_trigger()
988 void snd_hdac_dsp_cleanup(struct hdac_stream *azx_dev, in snd_hdac_dsp_cleanup() argument
991 struct hdac_bus *bus = azx_dev->bus; in snd_hdac_dsp_cleanup()
993 if (!dmab->area || !azx_dev->locked) in snd_hdac_dsp_cleanup()
996 snd_hdac_dsp_lock(azx_dev); in snd_hdac_dsp_cleanup()
998 snd_hdac_stream_writel(azx_dev, SD_BDLPL, 0); in snd_hdac_dsp_cleanup()
999 snd_hdac_stream_writel(azx_dev, SD_BDLPU, 0); in snd_hdac_dsp_cleanup()
1000 snd_hdac_stream_writel(azx_dev, SD_CTL, 0); in snd_hdac_dsp_cleanup()
1001 azx_dev->bufsize = 0; in snd_hdac_dsp_cleanup()
1002 azx_dev->period_bytes = 0; in snd_hdac_dsp_cleanup()
1003 azx_dev->format_val = 0; in snd_hdac_dsp_cleanup()
1009 azx_dev->locked = false; in snd_hdac_dsp_cleanup()
1011 snd_hdac_dsp_unlock(azx_dev); in snd_hdac_dsp_cleanup()