Lines Matching refs:rec

64 static int snd_pmac_dbdma_alloc(struct snd_pmac *chip, struct pmac_dbdma *rec, int size)  in snd_pmac_dbdma_alloc()  argument
68 rec->space = dma_alloc_coherent(&chip->pdev->dev, rsize, in snd_pmac_dbdma_alloc()
69 &rec->dma_base, GFP_KERNEL); in snd_pmac_dbdma_alloc()
70 if (rec->space == NULL) in snd_pmac_dbdma_alloc()
72 rec->size = size; in snd_pmac_dbdma_alloc()
73 memset(rec->space, 0, rsize); in snd_pmac_dbdma_alloc()
74 rec->cmds = (void __iomem *)DBDMA_ALIGN(rec->space); in snd_pmac_dbdma_alloc()
75 rec->addr = rec->dma_base + (unsigned long)((char *)rec->cmds - (char *)rec->space); in snd_pmac_dbdma_alloc()
80 static void snd_pmac_dbdma_free(struct snd_pmac *chip, struct pmac_dbdma *rec) in snd_pmac_dbdma_free() argument
82 if (rec->space) { in snd_pmac_dbdma_free()
83 unsigned int rsize = sizeof(struct dbdma_cmd) * (rec->size + 1); in snd_pmac_dbdma_free()
85 dma_free_coherent(&chip->pdev->dev, rsize, rec->space, rec->dma_base); in snd_pmac_dbdma_free()
98 unsigned int snd_pmac_rate_index(struct snd_pmac *chip, struct pmac_stream *rec, unsigned int rate) in snd_pmac_rate_index() argument
102 ok = rec->cur_freqs; in snd_pmac_rate_index()
162 snd_pmac_wait_ack(struct pmac_stream *rec) in snd_pmac_wait_ack() argument
165 while ((in_le32(&rec->dma->status) & RUN) && timeout-- > 0) in snd_pmac_wait_ack()
185 static inline void snd_pmac_dma_stop(struct pmac_stream *rec) in snd_pmac_dma_stop() argument
187 out_le32(&rec->dma->control, (RUN|WAKE|FLUSH|PAUSE) << 16); in snd_pmac_dma_stop()
188 snd_pmac_wait_ack(rec); in snd_pmac_dma_stop()
194 static inline void snd_pmac_dma_set_command(struct pmac_stream *rec, struct pmac_dbdma *cmd) in snd_pmac_dma_set_command() argument
196 out_le32(&rec->dma->cmdptr, cmd->addr); in snd_pmac_dma_set_command()
202 static inline void snd_pmac_dma_run(struct pmac_stream *rec, int status) in snd_pmac_dma_run() argument
204 out_le32(&rec->dma->control, status | (status << 16)); in snd_pmac_dma_run()
211 static int snd_pmac_pcm_prepare(struct snd_pmac *chip, struct pmac_stream *rec, struct snd_pcm_subs… in snd_pmac_pcm_prepare() argument
220 rec->dma_size = snd_pcm_lib_buffer_bytes(subs); in snd_pmac_pcm_prepare()
221 rec->period_size = snd_pcm_lib_period_bytes(subs); in snd_pmac_pcm_prepare()
222 rec->nperiods = rec->dma_size / rec->period_size; in snd_pmac_pcm_prepare()
223 rec->cur_period = 0; in snd_pmac_pcm_prepare()
224 rate_index = snd_pmac_rate_index(chip, rec, runtime->rate); in snd_pmac_pcm_prepare()
227 astr = snd_pmac_get_stream(chip, another_stream(rec->stream)); in snd_pmac_pcm_prepare()
242 snd_pmac_dma_stop(rec); in snd_pmac_pcm_prepare()
244 snd_pmac_dma_set_command(rec, &chip->extra_dma); in snd_pmac_pcm_prepare()
245 snd_pmac_dma_run(rec, RUN); in snd_pmac_pcm_prepare()
253 for (i = 0, cp = rec->cmd.cmds; i < rec->nperiods; i++, cp++) { in snd_pmac_pcm_prepare()
255 cp->req_count = cpu_to_le16(rec->period_size); in snd_pmac_pcm_prepare()
258 offset += rec->period_size; in snd_pmac_pcm_prepare()
262 cp->cmd_dep = cpu_to_le32(rec->cmd.addr); in snd_pmac_pcm_prepare()
264 snd_pmac_dma_stop(rec); in snd_pmac_pcm_prepare()
265 snd_pmac_dma_set_command(rec, &rec->cmd); in snd_pmac_pcm_prepare()
275 static int snd_pmac_pcm_trigger(struct snd_pmac *chip, struct pmac_stream *rec, in snd_pmac_pcm_trigger() argument
284 if (rec->running) in snd_pmac_pcm_trigger()
291 for (i = 0, cp = rec->cmd.cmds; i < rec->nperiods; i++, cp++) in snd_pmac_pcm_trigger()
293 snd_pmac_dma_set_command(rec, &rec->cmd); in snd_pmac_pcm_trigger()
294 (void)in_le32(&rec->dma->status); in snd_pmac_pcm_trigger()
295 snd_pmac_dma_run(rec, RUN|WAKE); in snd_pmac_pcm_trigger()
296 rec->running = 1; in snd_pmac_pcm_trigger()
303 rec->running = 0; in snd_pmac_pcm_trigger()
305 snd_pmac_dma_stop(rec); in snd_pmac_pcm_trigger()
306 for (i = 0, cp = rec->cmd.cmds; i < rec->nperiods; i++, cp++) in snd_pmac_pcm_trigger()
323 struct pmac_stream *rec, in snd_pmac_pcm_pointer() argument
330 volatile struct dbdma_cmd __iomem *cp = &rec->cmd.cmds[rec->cur_period]; in snd_pmac_pcm_pointer()
335 count = rec->period_size - count; in snd_pmac_pcm_pointer()
338 count += rec->cur_period * rec->period_size; in snd_pmac_pcm_pointer()
413 static inline void snd_pmac_pcm_dead_xfer(struct pmac_stream *rec, in snd_pmac_pcm_dead_xfer() argument
423 (void)in_le32(&rec->dma->status); in snd_pmac_pcm_dead_xfer()
424 out_le32(&rec->dma->control, (RUN|PAUSE|FLUSH|WAKE) << 16); in snd_pmac_pcm_dead_xfer()
431 cp->req_count = cpu_to_le16(rec->period_size); in snd_pmac_pcm_dead_xfer()
446 cp->cmd_dep = cpu_to_le32(rec->cmd.addr in snd_pmac_pcm_dead_xfer()
447 + sizeof(struct dbdma_cmd)*((rec->cur_period+1)%rec->nperiods)); in snd_pmac_pcm_dead_xfer()
452 out_le32(&rec->dma->cmdptr, emergency_dbdma.addr); in snd_pmac_pcm_dead_xfer()
455 (void)in_le32(&rec->dma->status); in snd_pmac_pcm_dead_xfer()
457 out_le32(&rec->dma->control, ((RUN|WAKE) << 16) + (RUN|WAKE)); in snd_pmac_pcm_dead_xfer()
463 static void snd_pmac_pcm_update(struct snd_pmac *chip, struct pmac_stream *rec) in snd_pmac_pcm_update() argument
470 if (rec->running) { in snd_pmac_pcm_update()
471 for (c = 0; c < rec->nperiods; c++) { /* at most all fragments */ in snd_pmac_pcm_update()
476 cp = &rec->cmd.cmds[rec->cur_period]; in snd_pmac_pcm_update()
481 snd_pmac_pcm_dead_xfer(rec, cp); in snd_pmac_pcm_update()
493 cp->req_count = cpu_to_le16(rec->period_size); in snd_pmac_pcm_update()
495 rec->cur_period++; in snd_pmac_pcm_update()
496 if (rec->cur_period >= rec->nperiods) { in snd_pmac_pcm_update()
497 rec->cur_period = 0; in snd_pmac_pcm_update()
501 snd_pcm_period_elapsed(rec->substream); in snd_pmac_pcm_update()
557 struct pmac_stream *rec = snd_pmac_get_stream(chip, rule->deps[0]);
560 if (! rec)
564 if (rec->cur_freqs & (1 << i))
576 struct pmac_stream *rec = snd_pmac_get_stream(chip, rule->deps[0]);
578 if (! rec)
581 rec->cur_formats);
585 static int snd_pmac_pcm_open(struct snd_pmac *chip, struct pmac_stream *rec, in snd_pmac_pcm_open() argument
617 runtime->private_data = rec; in snd_pmac_pcm_open()
618 rec->substream = subs; in snd_pmac_pcm_open()
622 snd_pmac_hw_rule_rate, chip, rec->stream, -1); in snd_pmac_pcm_open()
624 snd_pmac_hw_rule_format, chip, rec->stream, -1); in snd_pmac_pcm_open()
627 runtime->hw.periods_max = rec->cmd.size - 1; in snd_pmac_pcm_open()
634 static int snd_pmac_pcm_close(struct snd_pmac *chip, struct pmac_stream *rec, in snd_pmac_pcm_close() argument
639 snd_pmac_dma_stop(rec); in snd_pmac_pcm_close()
641 astr = snd_pmac_get_stream(chip, another_stream(rec->stream)); in snd_pmac_pcm_close()
760 struct pmac_stream *rec = &chip->playback; in snd_pmac_beep_dma_start() local
762 snd_pmac_dma_stop(rec); in snd_pmac_beep_dma_start()
772 snd_pmac_dma_set_command(rec, &chip->extra_dma); in snd_pmac_beep_dma_start()
773 snd_pmac_dma_run(rec, RUN); in snd_pmac_beep_dma_start()