Lines Matching refs:rec

50 static int snd_pmac_dbdma_alloc(struct snd_pmac *chip, struct pmac_dbdma *rec, int size)  in snd_pmac_dbdma_alloc()  argument
54 rec->space = dma_alloc_coherent(&chip->pdev->dev, rsize, in snd_pmac_dbdma_alloc()
55 &rec->dma_base, GFP_KERNEL); in snd_pmac_dbdma_alloc()
56 if (rec->space == NULL) in snd_pmac_dbdma_alloc()
58 rec->size = size; in snd_pmac_dbdma_alloc()
59 memset(rec->space, 0, rsize); in snd_pmac_dbdma_alloc()
60 rec->cmds = (void __iomem *)DBDMA_ALIGN(rec->space); in snd_pmac_dbdma_alloc()
61 rec->addr = rec->dma_base + (unsigned long)((char *)rec->cmds - (char *)rec->space); in snd_pmac_dbdma_alloc()
66 static void snd_pmac_dbdma_free(struct snd_pmac *chip, struct pmac_dbdma *rec) in snd_pmac_dbdma_free() argument
68 if (rec->space) { in snd_pmac_dbdma_free()
69 unsigned int rsize = sizeof(struct dbdma_cmd) * (rec->size + 1); in snd_pmac_dbdma_free()
71 dma_free_coherent(&chip->pdev->dev, rsize, rec->space, rec->dma_base); in snd_pmac_dbdma_free()
84 unsigned int snd_pmac_rate_index(struct snd_pmac *chip, struct pmac_stream *rec, unsigned int rate) in snd_pmac_rate_index() argument
88 ok = rec->cur_freqs; in snd_pmac_rate_index()
148 snd_pmac_wait_ack(struct pmac_stream *rec) in snd_pmac_wait_ack() argument
151 while ((in_le32(&rec->dma->status) & RUN) && timeout-- > 0) in snd_pmac_wait_ack()
171 static inline void snd_pmac_dma_stop(struct pmac_stream *rec) in snd_pmac_dma_stop() argument
173 out_le32(&rec->dma->control, (RUN|WAKE|FLUSH|PAUSE) << 16); in snd_pmac_dma_stop()
174 snd_pmac_wait_ack(rec); in snd_pmac_dma_stop()
180 static inline void snd_pmac_dma_set_command(struct pmac_stream *rec, struct pmac_dbdma *cmd) in snd_pmac_dma_set_command() argument
182 out_le32(&rec->dma->cmdptr, cmd->addr); in snd_pmac_dma_set_command()
188 static inline void snd_pmac_dma_run(struct pmac_stream *rec, int status) in snd_pmac_dma_run() argument
190 out_le32(&rec->dma->control, status | (status << 16)); in snd_pmac_dma_run()
197 static int snd_pmac_pcm_prepare(struct snd_pmac *chip, struct pmac_stream *rec, struct snd_pcm_subs… in snd_pmac_pcm_prepare() argument
206 rec->dma_size = snd_pcm_lib_buffer_bytes(subs); in snd_pmac_pcm_prepare()
207 rec->period_size = snd_pcm_lib_period_bytes(subs); in snd_pmac_pcm_prepare()
208 rec->nperiods = rec->dma_size / rec->period_size; in snd_pmac_pcm_prepare()
209 rec->cur_period = 0; in snd_pmac_pcm_prepare()
210 rate_index = snd_pmac_rate_index(chip, rec, runtime->rate); in snd_pmac_pcm_prepare()
213 astr = snd_pmac_get_stream(chip, another_stream(rec->stream)); in snd_pmac_pcm_prepare()
228 snd_pmac_dma_stop(rec); in snd_pmac_pcm_prepare()
230 snd_pmac_dma_set_command(rec, &chip->extra_dma); in snd_pmac_pcm_prepare()
231 snd_pmac_dma_run(rec, RUN); in snd_pmac_pcm_prepare()
239 for (i = 0, cp = rec->cmd.cmds; i < rec->nperiods; i++, cp++) { in snd_pmac_pcm_prepare()
241 cp->req_count = cpu_to_le16(rec->period_size); in snd_pmac_pcm_prepare()
244 offset += rec->period_size; in snd_pmac_pcm_prepare()
248 cp->cmd_dep = cpu_to_le32(rec->cmd.addr); in snd_pmac_pcm_prepare()
250 snd_pmac_dma_stop(rec); in snd_pmac_pcm_prepare()
251 snd_pmac_dma_set_command(rec, &rec->cmd); in snd_pmac_pcm_prepare()
261 static int snd_pmac_pcm_trigger(struct snd_pmac *chip, struct pmac_stream *rec, in snd_pmac_pcm_trigger() argument
270 if (rec->running) in snd_pmac_pcm_trigger()
277 for (i = 0, cp = rec->cmd.cmds; i < rec->nperiods; i++, cp++) in snd_pmac_pcm_trigger()
279 snd_pmac_dma_set_command(rec, &rec->cmd); in snd_pmac_pcm_trigger()
280 (void)in_le32(&rec->dma->status); in snd_pmac_pcm_trigger()
281 snd_pmac_dma_run(rec, RUN|WAKE); in snd_pmac_pcm_trigger()
282 rec->running = 1; in snd_pmac_pcm_trigger()
289 rec->running = 0; in snd_pmac_pcm_trigger()
291 snd_pmac_dma_stop(rec); in snd_pmac_pcm_trigger()
292 for (i = 0, cp = rec->cmd.cmds; i < rec->nperiods; i++, cp++) in snd_pmac_pcm_trigger()
309 struct pmac_stream *rec, in snd_pmac_pcm_pointer() argument
316 volatile struct dbdma_cmd __iomem *cp = &rec->cmd.cmds[rec->cur_period]; in snd_pmac_pcm_pointer()
321 count = rec->period_size - count; in snd_pmac_pcm_pointer()
324 count += rec->cur_period * rec->period_size; in snd_pmac_pcm_pointer()
399 static inline void snd_pmac_pcm_dead_xfer(struct pmac_stream *rec, in snd_pmac_pcm_dead_xfer() argument
409 (void)in_le32(&rec->dma->status); in snd_pmac_pcm_dead_xfer()
410 out_le32(&rec->dma->control, (RUN|PAUSE|FLUSH|WAKE) << 16); in snd_pmac_pcm_dead_xfer()
417 cp->req_count = cpu_to_le16(rec->period_size); in snd_pmac_pcm_dead_xfer()
432 cp->cmd_dep = cpu_to_le32(rec->cmd.addr in snd_pmac_pcm_dead_xfer()
433 + sizeof(struct dbdma_cmd)*((rec->cur_period+1)%rec->nperiods)); in snd_pmac_pcm_dead_xfer()
438 out_le32(&rec->dma->cmdptr, emergency_dbdma.addr); in snd_pmac_pcm_dead_xfer()
441 (void)in_le32(&rec->dma->status); in snd_pmac_pcm_dead_xfer()
443 out_le32(&rec->dma->control, ((RUN|WAKE) << 16) + (RUN|WAKE)); in snd_pmac_pcm_dead_xfer()
449 static void snd_pmac_pcm_update(struct snd_pmac *chip, struct pmac_stream *rec) in snd_pmac_pcm_update() argument
456 if (rec->running) { in snd_pmac_pcm_update()
457 for (c = 0; c < rec->nperiods; c++) { /* at most all fragments */ in snd_pmac_pcm_update()
462 cp = &rec->cmd.cmds[rec->cur_period]; in snd_pmac_pcm_update()
467 snd_pmac_pcm_dead_xfer(rec, cp); in snd_pmac_pcm_update()
479 cp->req_count = cpu_to_le16(rec->period_size); in snd_pmac_pcm_update()
481 rec->cur_period++; in snd_pmac_pcm_update()
482 if (rec->cur_period >= rec->nperiods) { in snd_pmac_pcm_update()
483 rec->cur_period = 0; in snd_pmac_pcm_update()
487 snd_pcm_period_elapsed(rec->substream); in snd_pmac_pcm_update()
543 struct pmac_stream *rec = snd_pmac_get_stream(chip, rule->deps[0]);
546 if (! rec)
550 if (rec->cur_freqs & (1 << i))
562 struct pmac_stream *rec = snd_pmac_get_stream(chip, rule->deps[0]);
564 if (! rec)
567 rec->cur_formats);
571 static int snd_pmac_pcm_open(struct snd_pmac *chip, struct pmac_stream *rec, in snd_pmac_pcm_open() argument
603 runtime->private_data = rec; in snd_pmac_pcm_open()
604 rec->substream = subs; in snd_pmac_pcm_open()
608 snd_pmac_hw_rule_rate, chip, rec->stream, -1); in snd_pmac_pcm_open()
610 snd_pmac_hw_rule_format, chip, rec->stream, -1); in snd_pmac_pcm_open()
613 runtime->hw.periods_max = rec->cmd.size - 1; in snd_pmac_pcm_open()
620 static int snd_pmac_pcm_close(struct snd_pmac *chip, struct pmac_stream *rec, in snd_pmac_pcm_close() argument
625 snd_pmac_dma_stop(rec); in snd_pmac_pcm_close()
627 astr = snd_pmac_get_stream(chip, another_stream(rec->stream)); in snd_pmac_pcm_close()
746 struct pmac_stream *rec = &chip->playback; in snd_pmac_beep_dma_start() local
748 snd_pmac_dma_stop(rec); in snd_pmac_beep_dma_start()
758 snd_pmac_dma_set_command(rec, &chip->extra_dma); in snd_pmac_beep_dma_start()
759 snd_pmac_dma_run(rec, RUN); in snd_pmac_beep_dma_start()