Lines Matching refs:chip

36 	struct lola *chip = snd_pcm_substream_chip(substream);  in lola_get_pcm()  local
37 return &chip->pcm[substream->stream]; in lola_get_pcm()
47 static unsigned int lola_get_lrc(struct lola *chip) in lola_get_lrc() argument
49 return lola_readl(chip, BAR1, LRC); in lola_get_lrc()
52 static unsigned int lola_get_tstamp(struct lola *chip, bool quick_no_sync) in lola_get_tstamp() argument
54 unsigned int tstamp = lola_get_lrc(chip) >> 8; in lola_get_tstamp()
55 if (chip->granularity) { in lola_get_tstamp()
57 tstamp += (wait_banks + 1) * chip->granularity - 1; in lola_get_tstamp()
58 tstamp -= tstamp % chip->granularity; in lola_get_tstamp()
64 static void lola_stream_clear_pending_irq(struct lola *chip, in lola_stream_clear_pending_irq() argument
67 unsigned int val = lola_dsd_read(chip, str->dsd, STS); in lola_stream_clear_pending_irq()
70 lola_dsd_write(chip, str->dsd, STS, val); in lola_stream_clear_pending_irq()
73 static void lola_stream_start(struct lola *chip, struct lola_stream *str, in lola_stream_start() argument
76 lola_stream_clear_pending_irq(chip, str); in lola_stream_start()
77 lola_dsd_write(chip, str->dsd, CTL, in lola_stream_start()
85 static void lola_stream_stop(struct lola *chip, struct lola_stream *str, in lola_stream_stop() argument
88 lola_dsd_write(chip, str->dsd, CTL, in lola_stream_stop()
93 lola_stream_clear_pending_irq(chip, str); in lola_stream_stop()
96 static void wait_for_srst_clear(struct lola *chip, struct lola_stream *str) in wait_for_srst_clear() argument
101 val = lola_dsd_read(chip, str->dsd, CTL); in wait_for_srst_clear()
106 dev_warn(chip->card->dev, "SRST not clear (stream %d)\n", str->dsd); in wait_for_srst_clear()
109 static int lola_stream_wait_for_fifo(struct lola *chip, in lola_stream_wait_for_fifo() argument
116 unsigned int reg = lola_dsd_read(chip, str->dsd, STS); in lola_stream_wait_for_fifo()
121 dev_warn(chip->card->dev, "FIFO not ready (stream %d)\n", str->dsd); in lola_stream_wait_for_fifo()
128 static int lola_sync_wait_for_fifo(struct lola *chip, in lola_sync_wait_for_fifo() argument
146 reg = lola_dsd_read(chip, str->dsd, STS); in lola_sync_wait_for_fifo()
159 dev_warn(chip->card->dev, "FIFO not ready (pending %d)\n", pending - 1); in lola_sync_wait_for_fifo()
164 static void lola_sync_pause(struct lola *chip, in lola_sync_pause() argument
169 lola_sync_wait_for_fifo(chip, substream, false); in lola_sync_pause()
176 lola_dsd_write(chip, str->dsd, CTL, LOLA_DSD_CTL_SRUN | in lola_sync_pause()
179 lola_sync_wait_for_fifo(chip, substream, true); in lola_sync_pause()
182 static void lola_stream_reset(struct lola *chip, struct lola_stream *str) in lola_stream_reset() argument
186 lola_sync_pause(chip, str->substream); in lola_stream_reset()
188 lola_dsd_write(chip, str->dsd, CTL, in lola_stream_reset()
190 lola_stream_wait_for_fifo(chip, str, false); in lola_stream_reset()
191 lola_stream_clear_pending_irq(chip, str); in lola_stream_reset()
192 lola_dsd_write(chip, str->dsd, CTL, LOLA_DSD_CTL_SRST); in lola_stream_reset()
193 lola_dsd_write(chip, str->dsd, LVI, 0); in lola_stream_reset()
194 lola_dsd_write(chip, str->dsd, BDPU, 0); in lola_stream_reset()
195 lola_dsd_write(chip, str->dsd, BDPL, 0); in lola_stream_reset()
196 wait_for_srst_clear(chip, str); in lola_stream_reset()
225 struct lola *chip = snd_pcm_substream_chip(substream); in lola_pcm_open() local
230 mutex_lock(&chip->open_mutex); in lola_pcm_open()
232 mutex_unlock(&chip->open_mutex); in lola_pcm_open()
240 if (chip->sample_rate) { in lola_pcm_open()
242 runtime->hw.rate_min = chip->sample_rate; in lola_pcm_open()
243 runtime->hw.rate_max = chip->sample_rate; in lola_pcm_open()
245 runtime->hw.rate_min = chip->sample_rate_min; in lola_pcm_open()
246 runtime->hw.rate_max = chip->sample_rate_max; in lola_pcm_open()
248 chip->ref_count_rate++; in lola_pcm_open()
252 chip->granularity); in lola_pcm_open()
254 chip->granularity); in lola_pcm_open()
255 mutex_unlock(&chip->open_mutex); in lola_pcm_open()
274 struct lola *chip = snd_pcm_substream_chip(substream); in lola_pcm_close() local
277 mutex_lock(&chip->open_mutex); in lola_pcm_close()
282 if (--chip->ref_count_rate == 0) { in lola_pcm_close()
284 chip->sample_rate = 0; in lola_pcm_close()
286 mutex_unlock(&chip->open_mutex); in lola_pcm_close()
304 struct lola *chip = snd_pcm_substream_chip(substream); in lola_pcm_hw_free() local
308 mutex_lock(&chip->open_mutex); in lola_pcm_hw_free()
309 lola_stream_reset(chip, str); in lola_pcm_hw_free()
311 mutex_unlock(&chip->open_mutex); in lola_pcm_hw_free()
354 static int lola_setup_periods(struct lola *chip, struct lola_pcm *pcm, in lola_setup_periods() argument
376 dev_err(chip->card->dev, "Too many BDL entries: buffer=%d, period=%d\n", in lola_setup_periods()
405 static int lola_set_stream_config(struct lola *chip, in lola_set_stream_config() argument
415 err = lola_codec_read(chip, str->nid, LOLA_VERB_SET_STREAM_FORMAT, in lola_set_stream_config()
418 dev_err(chip->card->dev, "Cannot set stream format 0x%x\n", in lola_set_stream_config()
426 err = lola_codec_read(chip, str[i].nid, in lola_set_stream_config()
430 dev_err(chip->card->dev, in lola_set_stream_config()
441 static int lola_setup_controller(struct lola *chip, struct lola_pcm *pcm, in lola_setup_controller() argument
451 lola_dsd_write(chip, str->dsd, BDPL, (u32)bdl); in lola_setup_controller()
452 lola_dsd_write(chip, str->dsd, BDPU, upper_32_bits(bdl)); in lola_setup_controller()
454 lola_dsd_write(chip, str->dsd, LVI, str->frags - 1); in lola_setup_controller()
455 lola_stream_clear_pending_irq(chip, str); in lola_setup_controller()
457 lola_dsd_write(chip, str->dsd, CTL, in lola_setup_controller()
462 return lola_stream_wait_for_fifo(chip, str, true); in lola_setup_controller()
467 struct lola *chip = snd_pcm_substream_chip(substream); in lola_pcm_prepare() local
474 mutex_lock(&chip->open_mutex); in lola_pcm_prepare()
475 lola_stream_reset(chip, str); in lola_pcm_prepare()
478 mutex_unlock(&chip->open_mutex); in lola_pcm_prepare()
485 mutex_unlock(&chip->open_mutex); in lola_pcm_prepare()
495 err = lola_setup_periods(chip, pcm, substream, str); in lola_pcm_prepare()
499 err = lola_set_sample_rate(chip, runtime->rate); in lola_pcm_prepare()
502 chip->sample_rate = runtime->rate; /* sample rate gets locked */ in lola_pcm_prepare()
504 err = lola_set_stream_config(chip, str, runtime->channels); in lola_pcm_prepare()
508 err = lola_setup_controller(chip, pcm, str); in lola_pcm_prepare()
510 lola_stream_reset(chip, str); in lola_pcm_prepare()
519 struct lola *chip = snd_pcm_substream_chip(substream); in lola_pcm_trigger() local
546 tstamp = lola_get_tstamp(chip, !sync_streams); in lola_pcm_trigger()
547 spin_lock(&chip->reg_lock); in lola_pcm_trigger()
553 lola_stream_start(chip, str, tstamp); in lola_pcm_trigger()
555 lola_stream_stop(chip, str, tstamp); in lola_pcm_trigger()
560 spin_unlock(&chip->reg_lock); in lola_pcm_trigger()
566 struct lola *chip = snd_pcm_substream_chip(substream); in lola_pcm_pointer() local
568 unsigned int pos = lola_dsd_read(chip, str->dsd, LPIB); in lola_pcm_pointer()
575 void lola_pcm_update(struct lola *chip, struct lola_pcm *pcm, unsigned int bits) in lola_pcm_update() argument
601 int lola_create_pcm(struct lola *chip) in lola_create_pcm() argument
608 snd_dma_pci_data(chip->pci), in lola_create_pcm()
609 PAGE_SIZE, &chip->pcm[i].bdl); in lola_create_pcm()
614 err = snd_pcm_new(chip->card, "Digigram Lola", 0, in lola_create_pcm()
615 chip->pcm[SNDRV_PCM_STREAM_PLAYBACK].num_streams, in lola_create_pcm()
616 chip->pcm[SNDRV_PCM_STREAM_CAPTURE].num_streams, in lola_create_pcm()
621 pcm->private_data = chip; in lola_create_pcm()
623 if (chip->pcm[i].num_streams) in lola_create_pcm()
628 snd_dma_pci_data(chip->pci), in lola_create_pcm()
633 void lola_free_pcm(struct lola *chip) in lola_free_pcm() argument
635 snd_dma_free_pages(&chip->pcm[0].bdl); in lola_free_pcm()
636 snd_dma_free_pages(&chip->pcm[1].bdl); in lola_free_pcm()
642 static int lola_init_stream(struct lola *chip, struct lola_stream *str, in lola_init_stream() argument
653 err = lola_read_param(chip, nid, LOLA_PAR_AUDIO_WIDGET_CAP, &val); in lola_init_stream()
655 dev_err(chip->card->dev, "Can't read wcaps for 0x%x\n", nid); in lola_init_stream()
661 dev_err(chip->card->dev, in lola_init_stream()
671 dev_err(chip->card->dev, in lola_init_stream()
678 chip->input_src_caps_mask |= (1 << idx); in lola_init_stream()
681 err = lola_read_param(chip, nid, LOLA_PAR_STREAM_FORMATS, &val); in lola_init_stream()
683 dev_err(chip->card->dev, "Can't read FORMATS 0x%x\n", nid); in lola_init_stream()
690 dev_err(chip->card->dev, in lola_init_stream()
697 int lola_init_pcm(struct lola *chip, int dir, int *nidp) in lola_init_pcm() argument
699 struct lola_pcm *pcm = &chip->pcm[dir]; in lola_init_pcm()
704 err = lola_init_stream(chip, &pcm->streams[i], i, nid, dir); in lola_init_pcm()