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()
130 snd_pmac_wait_ack(struct pmac_stream *rec) in snd_pmac_wait_ack() argument
133 while ((in_le32(&rec->dma->status) & RUN) && timeout-- > 0) in snd_pmac_wait_ack()
153 static inline void snd_pmac_dma_stop(struct pmac_stream *rec) in snd_pmac_dma_stop() argument
155 out_le32(&rec->dma->control, (RUN|WAKE|FLUSH|PAUSE) << 16); in snd_pmac_dma_stop()
156 snd_pmac_wait_ack(rec); in snd_pmac_dma_stop()
162 static inline void snd_pmac_dma_set_command(struct pmac_stream *rec, struct pmac_dbdma *cmd) in snd_pmac_dma_set_command() argument
164 out_le32(&rec->dma->cmdptr, cmd->addr); in snd_pmac_dma_set_command()
170 static inline void snd_pmac_dma_run(struct pmac_stream *rec, int status) in snd_pmac_dma_run() argument
172 out_le32(&rec->dma->control, status | (status << 16)); in snd_pmac_dma_run()
179 static int snd_pmac_pcm_prepare(struct snd_pmac *chip, struct pmac_stream *rec, struct snd_pcm_subs… in snd_pmac_pcm_prepare() argument
188 rec->dma_size = snd_pcm_lib_buffer_bytes(subs); in snd_pmac_pcm_prepare()
189 rec->period_size = snd_pcm_lib_period_bytes(subs); in snd_pmac_pcm_prepare()
190 rec->nperiods = rec->dma_size / rec->period_size; in snd_pmac_pcm_prepare()
191 rec->cur_period = 0; in snd_pmac_pcm_prepare()
192 rate_index = snd_pmac_rate_index(chip, rec, runtime->rate); in snd_pmac_pcm_prepare()
195 astr = snd_pmac_get_stream(chip, another_stream(rec->stream)); in snd_pmac_pcm_prepare()
210 snd_pmac_dma_stop(rec); in snd_pmac_pcm_prepare()
212 snd_pmac_dma_set_command(rec, &chip->extra_dma); in snd_pmac_pcm_prepare()
213 snd_pmac_dma_run(rec, RUN); in snd_pmac_pcm_prepare()
221 for (i = 0, cp = rec->cmd.cmds; i < rec->nperiods; i++, cp++) { in snd_pmac_pcm_prepare()
223 cp->req_count = cpu_to_le16(rec->period_size); in snd_pmac_pcm_prepare()
226 offset += rec->period_size; in snd_pmac_pcm_prepare()
230 cp->cmd_dep = cpu_to_le32(rec->cmd.addr); in snd_pmac_pcm_prepare()
232 snd_pmac_dma_stop(rec); in snd_pmac_pcm_prepare()
233 snd_pmac_dma_set_command(rec, &rec->cmd); in snd_pmac_pcm_prepare()
243 static int snd_pmac_pcm_trigger(struct snd_pmac *chip, struct pmac_stream *rec, in snd_pmac_pcm_trigger() argument
252 if (rec->running) in snd_pmac_pcm_trigger()
259 for (i = 0, cp = rec->cmd.cmds; i < rec->nperiods; i++, cp++) in snd_pmac_pcm_trigger()
261 snd_pmac_dma_set_command(rec, &rec->cmd); in snd_pmac_pcm_trigger()
262 (void)in_le32(&rec->dma->status); in snd_pmac_pcm_trigger()
263 snd_pmac_dma_run(rec, RUN|WAKE); in snd_pmac_pcm_trigger()
264 rec->running = 1; in snd_pmac_pcm_trigger()
271 rec->running = 0; in snd_pmac_pcm_trigger()
273 snd_pmac_dma_stop(rec); in snd_pmac_pcm_trigger()
274 for (i = 0, cp = rec->cmd.cmds; i < rec->nperiods; i++, cp++) in snd_pmac_pcm_trigger()
291 struct pmac_stream *rec, in snd_pmac_pcm_pointer() argument
298 volatile struct dbdma_cmd __iomem *cp = &rec->cmd.cmds[rec->cur_period]; in snd_pmac_pcm_pointer()
303 count = rec->period_size - count; in snd_pmac_pcm_pointer()
306 count += rec->cur_period * rec->period_size; in snd_pmac_pcm_pointer()
381 static inline void snd_pmac_pcm_dead_xfer(struct pmac_stream *rec, in snd_pmac_pcm_dead_xfer() argument
391 (void)in_le32(&rec->dma->status); in snd_pmac_pcm_dead_xfer()
392 out_le32(&rec->dma->control, (RUN|PAUSE|FLUSH|WAKE) << 16); in snd_pmac_pcm_dead_xfer()
399 cp->req_count = cpu_to_le16(rec->period_size); in snd_pmac_pcm_dead_xfer()
414 cp->cmd_dep = cpu_to_le32(rec->cmd.addr in snd_pmac_pcm_dead_xfer()
415 + sizeof(struct dbdma_cmd)*((rec->cur_period+1)%rec->nperiods)); in snd_pmac_pcm_dead_xfer()
420 out_le32(&rec->dma->cmdptr, emergency_dbdma.addr); in snd_pmac_pcm_dead_xfer()
423 (void)in_le32(&rec->dma->status); in snd_pmac_pcm_dead_xfer()
425 out_le32(&rec->dma->control, ((RUN|WAKE) << 16) + (RUN|WAKE)); in snd_pmac_pcm_dead_xfer()
431 static void snd_pmac_pcm_update(struct snd_pmac *chip, struct pmac_stream *rec) in snd_pmac_pcm_update() argument
438 if (rec->running) { in snd_pmac_pcm_update()
439 for (c = 0; c < rec->nperiods; c++) { /* at most all fragments */ in snd_pmac_pcm_update()
444 cp = &rec->cmd.cmds[rec->cur_period]; in snd_pmac_pcm_update()
449 snd_pmac_pcm_dead_xfer(rec, cp); in snd_pmac_pcm_update()
461 cp->req_count = cpu_to_le16(rec->period_size); in snd_pmac_pcm_update()
463 rec->cur_period++; in snd_pmac_pcm_update()
464 if (rec->cur_period >= rec->nperiods) { in snd_pmac_pcm_update()
465 rec->cur_period = 0; in snd_pmac_pcm_update()
469 snd_pcm_period_elapsed(rec->substream); in snd_pmac_pcm_update()
525 struct pmac_stream *rec = snd_pmac_get_stream(chip, rule->deps[0]);
528 if (! rec)
532 if (rec->cur_freqs & (1 << i))
544 struct pmac_stream *rec = snd_pmac_get_stream(chip, rule->deps[0]);
546 if (! rec)
549 rec->cur_formats);
553 static int snd_pmac_pcm_open(struct snd_pmac *chip, struct pmac_stream *rec, in snd_pmac_pcm_open() argument
585 runtime->private_data = rec; in snd_pmac_pcm_open()
586 rec->substream = subs; in snd_pmac_pcm_open()
590 snd_pmac_hw_rule_rate, chip, rec->stream, -1); in snd_pmac_pcm_open()
592 snd_pmac_hw_rule_format, chip, rec->stream, -1); in snd_pmac_pcm_open()
595 runtime->hw.periods_max = rec->cmd.size - 1; in snd_pmac_pcm_open()
602 static int snd_pmac_pcm_close(struct snd_pmac *chip, struct pmac_stream *rec, in snd_pmac_pcm_close() argument
607 snd_pmac_dma_stop(rec); in snd_pmac_pcm_close()
609 astr = snd_pmac_get_stream(chip, another_stream(rec->stream)); in snd_pmac_pcm_close()
722 struct pmac_stream *rec = &chip->playback; in snd_pmac_beep_dma_start() local
724 snd_pmac_dma_stop(rec); in snd_pmac_beep_dma_start()
734 snd_pmac_dma_set_command(rec, &chip->extra_dma); in snd_pmac_beep_dma_start()
735 snd_pmac_dma_run(rec, RUN); in snd_pmac_beep_dma_start()