Lines Matching refs:azx_dev
54 * @azx_dev: HD-audio core stream object to initialize
61 void snd_hdac_stream_init(struct hdac_bus *bus, struct hdac_stream *azx_dev,
64 azx_dev->bus = bus;
66 azx_dev->sd_addr = bus->remap_addr + (0x20 * idx + 0x80);
68 azx_dev->sd_int_sta_mask = 1 << idx;
69 azx_dev->index = idx;
70 azx_dev->direction = direction;
71 azx_dev->stream_tag = tag;
72 snd_hdac_dsp_lock_init(azx_dev);
73 list_add_tail(&azx_dev->list, &bus->stream_list);
79 * @azx_dev: HD-audio core stream to start
84 void snd_hdac_stream_start(struct hdac_stream *azx_dev, bool fresh_start)
86 struct hdac_bus *bus = azx_dev->bus;
90 trace_snd_hdac_stream_start(bus, azx_dev);
92 azx_dev->start_wallclk = snd_hdac_chip_readl(bus, WALLCLK);
94 azx_dev->start_wallclk -= azx_dev->period_wallclk;
98 1 << azx_dev->index,
99 1 << azx_dev->index);
101 if (azx_dev->stripe) {
102 if (azx_dev->substream)
103 stripe_ctl = snd_hdac_get_stream_stripe_ctl(bus, azx_dev->substream);
107 snd_hdac_stream_updatel(azx_dev, SD_CTL_3B, SD_CTL_STRIPE_MASK,
110 snd_hdac_stream_updateb(azx_dev, SD_CTL_3B, SD_CTL_STRIPE_MASK,
115 snd_hdac_stream_updatel(azx_dev, SD_CTL,
118 snd_hdac_stream_updateb(azx_dev, SD_CTL,
120 azx_dev->running = true;
126 * @azx_dev: HD-audio core stream to stop
128 void snd_hdac_stream_clear(struct hdac_stream *azx_dev)
131 struct azx *chip = bus_to_azx(azx_dev->bus);
132 struct snd_pcm_substream *substream = azx_dev->substream;
135 snd_hdac_stream_updatel(azx_dev, SD_CTL,
137 snd_hdac_stream_writeb(azx_dev, SD_STS, SD_INT_MASK); /* to be sure */
138 if (azx_dev->stripe)
139 snd_hdac_stream_updatel(azx_dev, SD_CTL_3B, SD_CTL_STRIPE_MASK, 0);
142 stream_to_azx_dev(azx_dev)->fix_prvpos = 0;
145 stream_to_azx_dev(azx_dev)->fix_prvpos =
146 chip->get_position[stream](chip, stream_to_azx_dev(azx_dev));
149 snd_hdac_stream_updateb(azx_dev, SD_CTL,
151 snd_hdac_stream_writeb(azx_dev, SD_STS, SD_INT_MASK); /* to be sure */
152 if (azx_dev->stripe)
153 snd_hdac_stream_updateb(azx_dev, SD_CTL_3B, SD_CTL_STRIPE_MASK, 0);
155 azx_dev->running = false;
161 * @azx_dev: HD-audio core stream to stop
165 void snd_hdac_stream_stop(struct hdac_stream *azx_dev)
167 trace_snd_hdac_stream_stop(azx_dev->bus, azx_dev);
169 snd_hdac_stream_clear(azx_dev);
171 snd_hdac_chip_updatel(azx_dev->bus, INTCTL, 1 << azx_dev->index, 0);
204 * @azx_dev: HD-audio core stream to reset
206 void snd_hdac_stream_reset(struct hdac_stream *azx_dev)
211 struct azx *chip = bus_to_azx(azx_dev->bus);
216 snd_hdac_stream_clear(azx_dev);
218 dma_run_state = snd_hdac_stream_readb(azx_dev, SD_CTL) & SD_CTL_DMA_START;
220 snd_hdac_stream_updateb(azx_dev, SD_CTL, 0, SD_CTL_STREAM_RESET);
224 val = snd_hdac_stream_readb(azx_dev, SD_CTL) &
230 if (azx_dev->bus->dma_stop_delay && dma_run_state)
231 udelay(azx_dev->bus->dma_stop_delay);
234 snd_hdac_stream_writeb(azx_dev, SD_CTL, val);
240 val = snd_hdac_stream_readb(azx_dev, SD_CTL) &
248 if (azx_dev->posbuf)
249 *azx_dev->posbuf = 0;
255 * @azx_dev: HD-audio core stream to set up
257 int snd_hdac_stream_setup(struct hdac_stream *azx_dev)
259 struct hdac_bus *bus = azx_dev->bus;
264 if (azx_dev->substream)
265 runtime = azx_dev->substream->runtime;
269 snd_hdac_stream_clear(azx_dev);
271 val = snd_hdac_stream_readl(azx_dev, SD_CTL);
273 (azx_dev->stream_tag << SD_CTL_STREAM_TAG_SHIFT);
276 snd_hdac_stream_writel(azx_dev, SD_CTL, val);
280 if(azx_dev->substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
281 snd_hdac_stream_writel(azx_dev, SD_CBL, azx_dev->bufsize - 64);
283 snd_hdac_stream_writel(azx_dev, SD_CBL, azx_dev->bufsize - 16);
286 snd_hdac_stream_writel(azx_dev, SD_CBL, azx_dev->bufsize);
290 snd_hdac_stream_writew(azx_dev, SD_FORMAT, azx_dev->format_val);
293 snd_hdac_stream_writew(azx_dev, SD_LVI, azx_dev->frags - 1);
297 snd_hdac_stream_writel(azx_dev, SD_BDLPL, (u32)azx_dev->bdl.addr);
299 snd_hdac_stream_writel(azx_dev, SD_BDLPU,
300 upper_32_bits(azx_dev->bdl.addr));
310 snd_hdac_stream_updatel(azx_dev, SD_CTL, 0, SD_INT_MASK);
312 azx_dev->fifo_size = snd_hdac_stream_readw(azx_dev, SD_FIFOSIZE) + 1;
319 azx_dev->delay_negative_threshold =
322 azx_dev->delay_negative_threshold = 0;
326 azx_dev->period_wallclk = (((runtime->period_size * 24000) /
335 * @azx_dev: HD-audio core stream to clean up
337 void snd_hdac_stream_cleanup(struct hdac_stream *azx_dev)
339 snd_hdac_stream_writel(azx_dev, SD_BDLPL, 0);
340 snd_hdac_stream_writel(azx_dev, SD_BDLPU, 0);
341 snd_hdac_stream_writel(azx_dev, SD_CTL, 0);
342 azx_dev->bufsize = 0;
343 azx_dev->period_bytes = 0;
344 azx_dev->format_val = 0;
362 struct hdac_stream *azx_dev;
372 list_for_each_entry(azx_dev, &bus->stream_list, list) {
373 if (azx_dev->direction != substream->stream)
375 if (azx_dev->opened)
377 if (azx_dev->assigned_key == key) {
378 res = azx_dev;
382 res = azx_dev;
397 * @azx_dev: HD-audio core stream to release
401 void snd_hdac_stream_release(struct hdac_stream *azx_dev)
403 struct hdac_bus *bus = azx_dev->bus;
406 azx_dev->opened = 0;
407 azx_dev->running = 0;
408 azx_dev->substream = NULL;
440 struct hdac_stream *azx_dev, __le32 **bdlp,
449 if (azx_dev->frags >= AZX_MAX_BDL_ENTRIES)
472 azx_dev->frags++;
481 * @azx_dev: HD-audio core stream to set up
486 int snd_hdac_stream_setup_periods(struct hdac_stream *azx_dev)
488 struct hdac_bus *bus = azx_dev->bus;
489 struct snd_pcm_substream *substream = azx_dev->substream;
497 snd_hdac_stream_writel(azx_dev, SD_BDLPL, 0);
498 snd_hdac_stream_writel(azx_dev, SD_BDLPU, 0);
500 period_bytes = azx_dev->period_bytes;
501 periods = azx_dev->bufsize / period_bytes;
504 bdl = (__le32 *)azx_dev->bdl.area;
506 azx_dev->frags = 0;
511 if (!azx_dev->no_period_wakeup && pos_adj > 0) {
526 azx_dev,
537 azx_dev, &bdl, ofs,
541 azx_dev, &bdl, ofs,
543 !azx_dev->no_period_wakeup);
551 azx_dev->bufsize, period_bytes);
558 * @azx_dev: HD-audio core stream for which parameters are to be set
564 int snd_hdac_stream_set_params(struct hdac_stream *azx_dev,
569 struct snd_pcm_substream *substream = azx_dev->substream;
579 if (bufsize != azx_dev->bufsize ||
580 period_bytes != azx_dev->period_bytes ||
581 format_val != azx_dev->format_val ||
582 runtime->no_period_wakeup != azx_dev->no_period_wakeup) {
583 azx_dev->bufsize = bufsize;
584 azx_dev->period_bytes = period_bytes;
585 azx_dev->format_val = format_val;
586 azx_dev->no_period_wakeup = runtime->no_period_wakeup;
587 err = snd_hdac_stream_setup_periods(azx_dev);
597 struct hdac_stream *azx_dev = container_of(cc, struct hdac_stream, cc);
599 return snd_hdac_chip_readl(azx_dev->bus, WALLCLK);
602 static void azx_timecounter_init(struct hdac_stream *azx_dev,
605 struct timecounter *tc = &azx_dev->tc;
606 struct cyclecounter *cc = &azx_dev->cc;
638 * @azx_dev: HD-audio core stream (master stream)
646 void snd_hdac_stream_timecounter_init(struct hdac_stream *azx_dev,
649 struct hdac_bus *bus = azx_dev->bus;
650 struct snd_pcm_runtime *runtime = azx_dev->substream->runtime;
672 * @azx_dev: HD-audio core stream (master stream)
677 void snd_hdac_stream_sync_trigger(struct hdac_stream *azx_dev, bool set,
680 struct hdac_bus *bus = azx_dev->bus;
696 * @azx_dev: HD-audio core stream (master stream)
703 void snd_hdac_stream_sync(struct hdac_stream *azx_dev, bool start,
706 struct hdac_bus *bus = azx_dev->bus;
745 * @azx_dev: HD-audio core stream used for DSP loading
753 int snd_hdac_dsp_prepare(struct hdac_stream *azx_dev, unsigned int format,
756 struct hdac_bus *bus = azx_dev->bus;
760 snd_hdac_dsp_lock(azx_dev);
762 if (azx_dev->running || azx_dev->locked) {
767 azx_dev->locked = true;
775 azx_dev->substream = NULL;
776 azx_dev->bufsize = byte_size;
777 azx_dev->period_bytes = byte_size;
778 azx_dev->format_val = format;
780 snd_hdac_stream_reset(azx_dev);
783 snd_hdac_stream_writel(azx_dev, SD_BDLPL, 0);
784 snd_hdac_stream_writel(azx_dev, SD_BDLPU, 0);
786 azx_dev->frags = 0;
787 bdl = (__le32 *)azx_dev->bdl.area;
788 err = setup_bdle(bus, bufp, azx_dev, &bdl, 0, byte_size, 0);
792 snd_hdac_stream_setup(azx_dev);
793 snd_hdac_dsp_unlock(azx_dev);
794 return azx_dev->stream_tag;
800 azx_dev->locked = false;
803 snd_hdac_dsp_unlock(azx_dev);
810 * @azx_dev: HD-audio core stream used for DSP loading
813 void snd_hdac_dsp_trigger(struct hdac_stream *azx_dev, bool start)
816 snd_hdac_stream_start(azx_dev, true);
818 snd_hdac_stream_stop(azx_dev);
824 * @azx_dev: HD-audio core stream used for DSP loading
827 void snd_hdac_dsp_cleanup(struct hdac_stream *azx_dev,
830 struct hdac_bus *bus = azx_dev->bus;
832 if (!dmab->area || !azx_dev->locked)
835 snd_hdac_dsp_lock(azx_dev);
837 snd_hdac_stream_writel(azx_dev, SD_BDLPL, 0);
838 snd_hdac_stream_writel(azx_dev, SD_BDLPU, 0);
839 snd_hdac_stream_writel(azx_dev, SD_CTL, 0);
840 azx_dev->bufsize = 0;
841 azx_dev->period_bytes = 0;
842 azx_dev->format_val = 0;
848 azx_dev->locked = false;
850 snd_hdac_dsp_unlock(azx_dev);