Lines Matching refs:rec
63 static int snd_pmac_dbdma_alloc(struct snd_pmac *chip, struct pmac_dbdma *rec, int size) in snd_pmac_dbdma_alloc() argument
67 rec->space = dma_alloc_coherent(&chip->pdev->dev, rsize, in snd_pmac_dbdma_alloc()
68 &rec->dma_base, GFP_KERNEL); in snd_pmac_dbdma_alloc()
69 if (rec->space == NULL) in snd_pmac_dbdma_alloc()
71 rec->size = size; in snd_pmac_dbdma_alloc()
72 memset(rec->space, 0, rsize); in snd_pmac_dbdma_alloc()
73 rec->cmds = (void __iomem *)DBDMA_ALIGN(rec->space); in snd_pmac_dbdma_alloc()
74 rec->addr = rec->dma_base + (unsigned long)((char *)rec->cmds - (char *)rec->space); in snd_pmac_dbdma_alloc()
79 static void snd_pmac_dbdma_free(struct snd_pmac *chip, struct pmac_dbdma *rec) in snd_pmac_dbdma_free() argument
81 if (rec->space) { in snd_pmac_dbdma_free()
82 unsigned int rsize = sizeof(struct dbdma_cmd) * (rec->size + 1); in snd_pmac_dbdma_free()
84 dma_free_coherent(&chip->pdev->dev, rsize, rec->space, rec->dma_base); in snd_pmac_dbdma_free()
97 unsigned int snd_pmac_rate_index(struct snd_pmac *chip, struct pmac_stream *rec, unsigned int rate) in snd_pmac_rate_index() argument
101 ok = rec->cur_freqs; in snd_pmac_rate_index()
161 snd_pmac_wait_ack(struct pmac_stream *rec) in snd_pmac_wait_ack() argument
164 while ((in_le32(&rec->dma->status) & RUN) && timeout-- > 0) in snd_pmac_wait_ack()
184 static inline void snd_pmac_dma_stop(struct pmac_stream *rec) in snd_pmac_dma_stop() argument
186 out_le32(&rec->dma->control, (RUN|WAKE|FLUSH|PAUSE) << 16); in snd_pmac_dma_stop()
187 snd_pmac_wait_ack(rec); in snd_pmac_dma_stop()
193 static inline void snd_pmac_dma_set_command(struct pmac_stream *rec, struct pmac_dbdma *cmd) in snd_pmac_dma_set_command() argument
195 out_le32(&rec->dma->cmdptr, cmd->addr); in snd_pmac_dma_set_command()
201 static inline void snd_pmac_dma_run(struct pmac_stream *rec, int status) in snd_pmac_dma_run() argument
203 out_le32(&rec->dma->control, status | (status << 16)); in snd_pmac_dma_run()
210 static int snd_pmac_pcm_prepare(struct snd_pmac *chip, struct pmac_stream *rec, struct snd_pcm_subs… in snd_pmac_pcm_prepare() argument
219 rec->dma_size = snd_pcm_lib_buffer_bytes(subs); in snd_pmac_pcm_prepare()
220 rec->period_size = snd_pcm_lib_period_bytes(subs); in snd_pmac_pcm_prepare()
221 rec->nperiods = rec->dma_size / rec->period_size; in snd_pmac_pcm_prepare()
222 rec->cur_period = 0; in snd_pmac_pcm_prepare()
223 rate_index = snd_pmac_rate_index(chip, rec, runtime->rate); in snd_pmac_pcm_prepare()
226 astr = snd_pmac_get_stream(chip, another_stream(rec->stream)); in snd_pmac_pcm_prepare()
241 snd_pmac_dma_stop(rec); in snd_pmac_pcm_prepare()
243 snd_pmac_dma_set_command(rec, &chip->extra_dma); in snd_pmac_pcm_prepare()
244 snd_pmac_dma_run(rec, RUN); in snd_pmac_pcm_prepare()
252 for (i = 0, cp = rec->cmd.cmds; i < rec->nperiods; i++, cp++) { in snd_pmac_pcm_prepare()
254 cp->req_count = cpu_to_le16(rec->period_size); in snd_pmac_pcm_prepare()
257 offset += rec->period_size; in snd_pmac_pcm_prepare()
261 cp->cmd_dep = cpu_to_le32(rec->cmd.addr); in snd_pmac_pcm_prepare()
263 snd_pmac_dma_stop(rec); in snd_pmac_pcm_prepare()
264 snd_pmac_dma_set_command(rec, &rec->cmd); in snd_pmac_pcm_prepare()
274 static int snd_pmac_pcm_trigger(struct snd_pmac *chip, struct pmac_stream *rec, in snd_pmac_pcm_trigger() argument
283 if (rec->running) in snd_pmac_pcm_trigger()
290 for (i = 0, cp = rec->cmd.cmds; i < rec->nperiods; i++, cp++) in snd_pmac_pcm_trigger()
292 snd_pmac_dma_set_command(rec, &rec->cmd); in snd_pmac_pcm_trigger()
293 (void)in_le32(&rec->dma->status); in snd_pmac_pcm_trigger()
294 snd_pmac_dma_run(rec, RUN|WAKE); in snd_pmac_pcm_trigger()
295 rec->running = 1; in snd_pmac_pcm_trigger()
302 rec->running = 0; in snd_pmac_pcm_trigger()
304 snd_pmac_dma_stop(rec); in snd_pmac_pcm_trigger()
305 for (i = 0, cp = rec->cmd.cmds; i < rec->nperiods; i++, cp++) in snd_pmac_pcm_trigger()
322 struct pmac_stream *rec, in snd_pmac_pcm_pointer() argument
329 volatile struct dbdma_cmd __iomem *cp = &rec->cmd.cmds[rec->cur_period]; in snd_pmac_pcm_pointer()
334 count = rec->period_size - count; in snd_pmac_pcm_pointer()
337 count += rec->cur_period * rec->period_size; in snd_pmac_pcm_pointer()
412 static inline void snd_pmac_pcm_dead_xfer(struct pmac_stream *rec, in snd_pmac_pcm_dead_xfer() argument
422 (void)in_le32(&rec->dma->status); in snd_pmac_pcm_dead_xfer()
423 out_le32(&rec->dma->control, (RUN|PAUSE|FLUSH|WAKE) << 16); in snd_pmac_pcm_dead_xfer()
430 cp->req_count = cpu_to_le16(rec->period_size); in snd_pmac_pcm_dead_xfer()
445 cp->cmd_dep = cpu_to_le32(rec->cmd.addr in snd_pmac_pcm_dead_xfer()
446 + sizeof(struct dbdma_cmd)*((rec->cur_period+1)%rec->nperiods)); in snd_pmac_pcm_dead_xfer()
451 out_le32(&rec->dma->cmdptr, emergency_dbdma.addr); in snd_pmac_pcm_dead_xfer()
454 (void)in_le32(&rec->dma->status); in snd_pmac_pcm_dead_xfer()
456 out_le32(&rec->dma->control, ((RUN|WAKE) << 16) + (RUN|WAKE)); in snd_pmac_pcm_dead_xfer()
462 static void snd_pmac_pcm_update(struct snd_pmac *chip, struct pmac_stream *rec) in snd_pmac_pcm_update() argument
469 if (rec->running) { in snd_pmac_pcm_update()
470 for (c = 0; c < rec->nperiods; c++) { /* at most all fragments */ in snd_pmac_pcm_update()
475 cp = &rec->cmd.cmds[rec->cur_period]; in snd_pmac_pcm_update()
480 snd_pmac_pcm_dead_xfer(rec, cp); in snd_pmac_pcm_update()
492 cp->req_count = cpu_to_le16(rec->period_size); in snd_pmac_pcm_update()
494 rec->cur_period++; in snd_pmac_pcm_update()
495 if (rec->cur_period >= rec->nperiods) { in snd_pmac_pcm_update()
496 rec->cur_period = 0; in snd_pmac_pcm_update()
500 snd_pcm_period_elapsed(rec->substream); in snd_pmac_pcm_update()
556 struct pmac_stream *rec = snd_pmac_get_stream(chip, rule->deps[0]);
559 if (! rec)
563 if (rec->cur_freqs & (1 << i))
575 struct pmac_stream *rec = snd_pmac_get_stream(chip, rule->deps[0]);
577 if (! rec)
580 rec->cur_formats);
584 static int snd_pmac_pcm_open(struct snd_pmac *chip, struct pmac_stream *rec, in snd_pmac_pcm_open() argument
616 runtime->private_data = rec; in snd_pmac_pcm_open()
617 rec->substream = subs; in snd_pmac_pcm_open()
621 snd_pmac_hw_rule_rate, chip, rec->stream, -1); in snd_pmac_pcm_open()
623 snd_pmac_hw_rule_format, chip, rec->stream, -1); in snd_pmac_pcm_open()
626 runtime->hw.periods_max = rec->cmd.size - 1; in snd_pmac_pcm_open()
633 static int snd_pmac_pcm_close(struct snd_pmac *chip, struct pmac_stream *rec, in snd_pmac_pcm_close() argument
638 snd_pmac_dma_stop(rec); in snd_pmac_pcm_close()
640 astr = snd_pmac_get_stream(chip, another_stream(rec->stream)); in snd_pmac_pcm_close()
759 struct pmac_stream *rec = &chip->playback; in snd_pmac_beep_dma_start() local
761 snd_pmac_dma_stop(rec); in snd_pmac_beep_dma_start()
771 snd_pmac_dma_set_command(rec, &chip->extra_dma); in snd_pmac_beep_dma_start()
772 snd_pmac_dma_run(rec, RUN); in snd_pmac_beep_dma_start()