Lines Matching refs:azx_dev
60 void snd_hdac_stream_init(struct hdac_bus *bus, struct hdac_stream *azx_dev, in snd_hdac_stream_init() argument
63 azx_dev->bus = bus; in snd_hdac_stream_init()
65 azx_dev->sd_addr = bus->remap_addr + (0x20 * idx + 0x80); in snd_hdac_stream_init()
67 azx_dev->sd_int_sta_mask = 1 << idx; in snd_hdac_stream_init()
68 azx_dev->index = idx; in snd_hdac_stream_init()
69 azx_dev->direction = direction; in snd_hdac_stream_init()
70 azx_dev->stream_tag = tag; in snd_hdac_stream_init()
71 snd_hdac_dsp_lock_init(azx_dev); in snd_hdac_stream_init()
72 list_add_tail(&azx_dev->list, &bus->stream_list); in snd_hdac_stream_init()
83 void snd_hdac_stream_start(struct hdac_stream *azx_dev, bool fresh_start) in snd_hdac_stream_start() argument
85 struct hdac_bus *bus = azx_dev->bus; in snd_hdac_stream_start()
88 trace_snd_hdac_stream_start(bus, azx_dev); in snd_hdac_stream_start()
90 azx_dev->start_wallclk = snd_hdac_chip_readl(bus, WALLCLK); in snd_hdac_stream_start()
92 azx_dev->start_wallclk -= azx_dev->period_wallclk; in snd_hdac_stream_start()
96 1 << azx_dev->index, in snd_hdac_stream_start()
97 1 << azx_dev->index); in snd_hdac_stream_start()
99 if (azx_dev->substream) in snd_hdac_stream_start()
100 stripe_ctl = snd_hdac_get_stream_stripe_ctl(bus, azx_dev->substream); in snd_hdac_stream_start()
103 snd_hdac_stream_updateb(azx_dev, SD_CTL_3B, SD_CTL_STRIPE_MASK, in snd_hdac_stream_start()
106 snd_hdac_stream_updateb(azx_dev, SD_CTL, in snd_hdac_stream_start()
108 azx_dev->running = true; in snd_hdac_stream_start()
116 void snd_hdac_stream_clear(struct hdac_stream *azx_dev) in snd_hdac_stream_clear() argument
118 snd_hdac_stream_updateb(azx_dev, SD_CTL, in snd_hdac_stream_clear()
120 snd_hdac_stream_writeb(azx_dev, SD_STS, SD_INT_MASK); /* to be sure */ in snd_hdac_stream_clear()
121 snd_hdac_stream_updateb(azx_dev, SD_CTL_3B, SD_CTL_STRIPE_MASK, 0); in snd_hdac_stream_clear()
122 azx_dev->running = false; in snd_hdac_stream_clear()
132 void snd_hdac_stream_stop(struct hdac_stream *azx_dev) in snd_hdac_stream_stop() argument
134 trace_snd_hdac_stream_stop(azx_dev->bus, azx_dev); in snd_hdac_stream_stop()
136 snd_hdac_stream_clear(azx_dev); in snd_hdac_stream_stop()
138 snd_hdac_chip_updatel(azx_dev->bus, INTCTL, 1 << azx_dev->index, 0); in snd_hdac_stream_stop()
146 void snd_hdac_stream_reset(struct hdac_stream *azx_dev) in snd_hdac_stream_reset() argument
151 snd_hdac_stream_clear(azx_dev); in snd_hdac_stream_reset()
153 snd_hdac_stream_updateb(azx_dev, SD_CTL, 0, SD_CTL_STREAM_RESET); in snd_hdac_stream_reset()
157 val = snd_hdac_stream_readb(azx_dev, SD_CTL) & in snd_hdac_stream_reset()
163 snd_hdac_stream_writeb(azx_dev, SD_CTL, val); in snd_hdac_stream_reset()
169 val = snd_hdac_stream_readb(azx_dev, SD_CTL) & in snd_hdac_stream_reset()
176 if (azx_dev->posbuf) in snd_hdac_stream_reset()
177 *azx_dev->posbuf = 0; in snd_hdac_stream_reset()
185 int snd_hdac_stream_setup(struct hdac_stream *azx_dev) in snd_hdac_stream_setup() argument
187 struct hdac_bus *bus = azx_dev->bus; in snd_hdac_stream_setup()
191 if (azx_dev->substream) in snd_hdac_stream_setup()
192 runtime = azx_dev->substream->runtime; in snd_hdac_stream_setup()
196 snd_hdac_stream_clear(azx_dev); in snd_hdac_stream_setup()
198 val = snd_hdac_stream_readl(azx_dev, SD_CTL); in snd_hdac_stream_setup()
200 (azx_dev->stream_tag << SD_CTL_STREAM_TAG_SHIFT); in snd_hdac_stream_setup()
203 snd_hdac_stream_writel(azx_dev, SD_CTL, val); in snd_hdac_stream_setup()
206 snd_hdac_stream_writel(azx_dev, SD_CBL, azx_dev->bufsize); in snd_hdac_stream_setup()
210 snd_hdac_stream_writew(azx_dev, SD_FORMAT, azx_dev->format_val); in snd_hdac_stream_setup()
213 snd_hdac_stream_writew(azx_dev, SD_LVI, azx_dev->frags - 1); in snd_hdac_stream_setup()
217 snd_hdac_stream_writel(azx_dev, SD_BDLPL, (u32)azx_dev->bdl.addr); in snd_hdac_stream_setup()
219 snd_hdac_stream_writel(azx_dev, SD_BDLPU, in snd_hdac_stream_setup()
220 upper_32_bits(azx_dev->bdl.addr)); in snd_hdac_stream_setup()
230 snd_hdac_stream_updatel(azx_dev, SD_CTL, 0, SD_INT_MASK); in snd_hdac_stream_setup()
232 azx_dev->fifo_size = snd_hdac_stream_readw(azx_dev, SD_FIFOSIZE) + 1; in snd_hdac_stream_setup()
239 azx_dev->delay_negative_threshold = in snd_hdac_stream_setup()
242 azx_dev->delay_negative_threshold = 0; in snd_hdac_stream_setup()
246 azx_dev->period_wallclk = (((runtime->period_size * 24000) / in snd_hdac_stream_setup()
257 void snd_hdac_stream_cleanup(struct hdac_stream *azx_dev) in snd_hdac_stream_cleanup() argument
259 snd_hdac_stream_writel(azx_dev, SD_BDLPL, 0); in snd_hdac_stream_cleanup()
260 snd_hdac_stream_writel(azx_dev, SD_BDLPU, 0); in snd_hdac_stream_cleanup()
261 snd_hdac_stream_writel(azx_dev, SD_CTL, 0); in snd_hdac_stream_cleanup()
262 azx_dev->bufsize = 0; in snd_hdac_stream_cleanup()
263 azx_dev->period_bytes = 0; in snd_hdac_stream_cleanup()
264 azx_dev->format_val = 0; in snd_hdac_stream_cleanup()
282 struct hdac_stream *azx_dev; in snd_hdac_stream_assign() local
289 list_for_each_entry(azx_dev, &bus->stream_list, list) { in snd_hdac_stream_assign()
290 if (azx_dev->direction != substream->stream) in snd_hdac_stream_assign()
292 if (azx_dev->opened) in snd_hdac_stream_assign()
294 if (azx_dev->assigned_key == key) { in snd_hdac_stream_assign()
295 res = azx_dev; in snd_hdac_stream_assign()
299 res = azx_dev; in snd_hdac_stream_assign()
319 void snd_hdac_stream_release(struct hdac_stream *azx_dev) in snd_hdac_stream_release() argument
321 struct hdac_bus *bus = azx_dev->bus; in snd_hdac_stream_release()
324 azx_dev->opened = 0; in snd_hdac_stream_release()
325 azx_dev->running = 0; in snd_hdac_stream_release()
326 azx_dev->substream = NULL; in snd_hdac_stream_release()
358 struct hdac_stream *azx_dev, __le32 **bdlp, in setup_bdle() argument
367 if (azx_dev->frags >= AZX_MAX_BDL_ENTRIES) in setup_bdle()
390 azx_dev->frags++; in setup_bdle()
404 int snd_hdac_stream_setup_periods(struct hdac_stream *azx_dev) in snd_hdac_stream_setup_periods() argument
406 struct hdac_bus *bus = azx_dev->bus; in snd_hdac_stream_setup_periods()
407 struct snd_pcm_substream *substream = azx_dev->substream; in snd_hdac_stream_setup_periods()
414 snd_hdac_stream_writel(azx_dev, SD_BDLPL, 0); in snd_hdac_stream_setup_periods()
415 snd_hdac_stream_writel(azx_dev, SD_BDLPU, 0); in snd_hdac_stream_setup_periods()
417 period_bytes = azx_dev->period_bytes; in snd_hdac_stream_setup_periods()
418 periods = azx_dev->bufsize / period_bytes; in snd_hdac_stream_setup_periods()
421 bdl = (__le32 *)azx_dev->bdl.area; in snd_hdac_stream_setup_periods()
423 azx_dev->frags = 0; in snd_hdac_stream_setup_periods()
426 if (!azx_dev->no_period_wakeup && pos_adj > 0) { in snd_hdac_stream_setup_periods()
441 azx_dev, in snd_hdac_stream_setup_periods()
452 azx_dev, &bdl, ofs, in snd_hdac_stream_setup_periods()
456 azx_dev, &bdl, ofs, in snd_hdac_stream_setup_periods()
458 !azx_dev->no_period_wakeup); in snd_hdac_stream_setup_periods()
466 azx_dev->bufsize, period_bytes); in snd_hdac_stream_setup_periods()
479 int snd_hdac_stream_set_params(struct hdac_stream *azx_dev, in snd_hdac_stream_set_params() argument
484 struct snd_pcm_substream *substream = azx_dev->substream; in snd_hdac_stream_set_params()
494 if (bufsize != azx_dev->bufsize || in snd_hdac_stream_set_params()
495 period_bytes != azx_dev->period_bytes || in snd_hdac_stream_set_params()
496 format_val != azx_dev->format_val || in snd_hdac_stream_set_params()
497 runtime->no_period_wakeup != azx_dev->no_period_wakeup) { in snd_hdac_stream_set_params()
498 azx_dev->bufsize = bufsize; in snd_hdac_stream_set_params()
499 azx_dev->period_bytes = period_bytes; in snd_hdac_stream_set_params()
500 azx_dev->format_val = format_val; in snd_hdac_stream_set_params()
501 azx_dev->no_period_wakeup = runtime->no_period_wakeup; in snd_hdac_stream_set_params()
502 err = snd_hdac_stream_setup_periods(azx_dev); in snd_hdac_stream_set_params()
512 struct hdac_stream *azx_dev = container_of(cc, struct hdac_stream, cc); in azx_cc_read() local
514 return snd_hdac_chip_readl(azx_dev->bus, WALLCLK); in azx_cc_read()
517 static void azx_timecounter_init(struct hdac_stream *azx_dev, in azx_timecounter_init() argument
520 struct timecounter *tc = &azx_dev->tc; in azx_timecounter_init()
521 struct cyclecounter *cc = &azx_dev->cc; in azx_timecounter_init()
561 void snd_hdac_stream_timecounter_init(struct hdac_stream *azx_dev, in snd_hdac_stream_timecounter_init() argument
564 struct hdac_bus *bus = azx_dev->bus; in snd_hdac_stream_timecounter_init()
565 struct snd_pcm_runtime *runtime = azx_dev->substream->runtime; in snd_hdac_stream_timecounter_init()
592 void snd_hdac_stream_sync_trigger(struct hdac_stream *azx_dev, bool set, in snd_hdac_stream_sync_trigger() argument
595 struct hdac_bus *bus = azx_dev->bus; in snd_hdac_stream_sync_trigger()
618 void snd_hdac_stream_sync(struct hdac_stream *azx_dev, bool start, in snd_hdac_stream_sync() argument
621 struct hdac_bus *bus = azx_dev->bus; in snd_hdac_stream_sync()
662 int snd_hdac_dsp_prepare(struct hdac_stream *azx_dev, unsigned int format, in snd_hdac_dsp_prepare() argument
665 struct hdac_bus *bus = azx_dev->bus; in snd_hdac_dsp_prepare()
669 snd_hdac_dsp_lock(azx_dev); in snd_hdac_dsp_prepare()
671 if (azx_dev->running || azx_dev->locked) { in snd_hdac_dsp_prepare()
676 azx_dev->locked = true; in snd_hdac_dsp_prepare()
684 azx_dev->substream = NULL; in snd_hdac_dsp_prepare()
685 azx_dev->bufsize = byte_size; in snd_hdac_dsp_prepare()
686 azx_dev->period_bytes = byte_size; in snd_hdac_dsp_prepare()
687 azx_dev->format_val = format; in snd_hdac_dsp_prepare()
689 snd_hdac_stream_reset(azx_dev); in snd_hdac_dsp_prepare()
692 snd_hdac_stream_writel(azx_dev, SD_BDLPL, 0); in snd_hdac_dsp_prepare()
693 snd_hdac_stream_writel(azx_dev, SD_BDLPU, 0); in snd_hdac_dsp_prepare()
695 azx_dev->frags = 0; in snd_hdac_dsp_prepare()
696 bdl = (__le32 *)azx_dev->bdl.area; in snd_hdac_dsp_prepare()
697 err = setup_bdle(bus, bufp, azx_dev, &bdl, 0, byte_size, 0); in snd_hdac_dsp_prepare()
701 snd_hdac_stream_setup(azx_dev); in snd_hdac_dsp_prepare()
702 snd_hdac_dsp_unlock(azx_dev); in snd_hdac_dsp_prepare()
703 return azx_dev->stream_tag; in snd_hdac_dsp_prepare()
709 azx_dev->locked = false; in snd_hdac_dsp_prepare()
712 snd_hdac_dsp_unlock(azx_dev); in snd_hdac_dsp_prepare()
722 void snd_hdac_dsp_trigger(struct hdac_stream *azx_dev, bool start) in snd_hdac_dsp_trigger() argument
725 snd_hdac_stream_start(azx_dev, true); in snd_hdac_dsp_trigger()
727 snd_hdac_stream_stop(azx_dev); in snd_hdac_dsp_trigger()
736 void snd_hdac_dsp_cleanup(struct hdac_stream *azx_dev, in snd_hdac_dsp_cleanup() argument
739 struct hdac_bus *bus = azx_dev->bus; in snd_hdac_dsp_cleanup()
741 if (!dmab->area || !azx_dev->locked) in snd_hdac_dsp_cleanup()
744 snd_hdac_dsp_lock(azx_dev); in snd_hdac_dsp_cleanup()
746 snd_hdac_stream_writel(azx_dev, SD_BDLPL, 0); in snd_hdac_dsp_cleanup()
747 snd_hdac_stream_writel(azx_dev, SD_BDLPU, 0); in snd_hdac_dsp_cleanup()
748 snd_hdac_stream_writel(azx_dev, SD_CTL, 0); in snd_hdac_dsp_cleanup()
749 azx_dev->bufsize = 0; in snd_hdac_dsp_cleanup()
750 azx_dev->period_bytes = 0; in snd_hdac_dsp_cleanup()
751 azx_dev->format_val = 0; in snd_hdac_dsp_cleanup()
757 azx_dev->locked = false; in snd_hdac_dsp_cleanup()
759 snd_hdac_dsp_unlock(azx_dev); in snd_hdac_dsp_cleanup()