Lines Matching defs:rec

50 static int snd_pmac_dbdma_alloc(struct snd_pmac *chip, struct pmac_dbdma *rec, int size)
54 rec->space = dma_alloc_coherent(&chip->pdev->dev, rsize,
55 &rec->dma_base, GFP_KERNEL);
56 if (rec->space == NULL)
58 rec->size = size;
59 memset(rec->space, 0, rsize);
60 rec->cmds = (void __iomem *)DBDMA_ALIGN(rec->space);
61 rec->addr = rec->dma_base + (unsigned long)((char *)rec->cmds - (char *)rec->space);
66 static void snd_pmac_dbdma_free(struct snd_pmac *chip, struct pmac_dbdma *rec)
68 if (rec->space) {
69 unsigned int rsize = sizeof(struct dbdma_cmd) * (rec->size + 1);
71 dma_free_coherent(&chip->pdev->dev, rsize, rec->space, rec->dma_base);
84 unsigned int snd_pmac_rate_index(struct snd_pmac *chip, struct pmac_stream *rec, unsigned int rate)
88 ok = rec->cur_freqs;
130 snd_pmac_wait_ack(struct pmac_stream *rec)
133 while ((in_le32(&rec->dma->status) & RUN) && timeout-- > 0)
153 static inline void snd_pmac_dma_stop(struct pmac_stream *rec)
155 out_le32(&rec->dma->control, (RUN|WAKE|FLUSH|PAUSE) << 16);
156 snd_pmac_wait_ack(rec);
162 static inline void snd_pmac_dma_set_command(struct pmac_stream *rec, struct pmac_dbdma *cmd)
164 out_le32(&rec->dma->cmdptr, cmd->addr);
170 static inline void snd_pmac_dma_run(struct pmac_stream *rec, int status)
172 out_le32(&rec->dma->control, status | (status << 16));
179 static int snd_pmac_pcm_prepare(struct snd_pmac *chip, struct pmac_stream *rec, struct snd_pcm_substream *subs)
188 rec->dma_size = snd_pcm_lib_buffer_bytes(subs);
189 rec->period_size = snd_pcm_lib_period_bytes(subs);
190 rec->nperiods = rec->dma_size / rec->period_size;
191 rec->cur_period = 0;
192 rate_index = snd_pmac_rate_index(chip, rec, runtime->rate);
195 astr = snd_pmac_get_stream(chip, another_stream(rec->stream));
210 snd_pmac_dma_stop(rec);
212 snd_pmac_dma_set_command(rec, &chip->extra_dma);
213 snd_pmac_dma_run(rec, RUN);
221 for (i = 0, cp = rec->cmd.cmds; i < rec->nperiods; i++, cp++) {
223 cp->req_count = cpu_to_le16(rec->period_size);
226 offset += rec->period_size;
230 cp->cmd_dep = cpu_to_le32(rec->cmd.addr);
232 snd_pmac_dma_stop(rec);
233 snd_pmac_dma_set_command(rec, &rec->cmd);
243 static int snd_pmac_pcm_trigger(struct snd_pmac *chip, struct pmac_stream *rec,
252 if (rec->running)
259 for (i = 0, cp = rec->cmd.cmds; i < rec->nperiods; i++, cp++)
261 snd_pmac_dma_set_command(rec, &rec->cmd);
262 (void)in_le32(&rec->dma->status);
263 snd_pmac_dma_run(rec, RUN|WAKE);
264 rec->running = 1;
271 rec->running = 0;
273 snd_pmac_dma_stop(rec);
274 for (i = 0, cp = rec->cmd.cmds; i < rec->nperiods; i++, cp++)
291 struct pmac_stream *rec,
298 volatile struct dbdma_cmd __iomem *cp = &rec->cmd.cmds[rec->cur_period];
303 count = rec->period_size - count;
306 count += rec->cur_period * rec->period_size;
381 static inline void snd_pmac_pcm_dead_xfer(struct pmac_stream *rec,
391 (void)in_le32(&rec->dma->status);
392 out_le32(&rec->dma->control, (RUN|PAUSE|FLUSH|WAKE) << 16);
399 cp->req_count = cpu_to_le16(rec->period_size);
414 cp->cmd_dep = cpu_to_le32(rec->cmd.addr
415 + sizeof(struct dbdma_cmd)*((rec->cur_period+1)%rec->nperiods));
420 out_le32(&rec->dma->cmdptr, emergency_dbdma.addr);
423 (void)in_le32(&rec->dma->status);
425 out_le32(&rec->dma->control, ((RUN|WAKE) << 16) + (RUN|WAKE));
431 static void snd_pmac_pcm_update(struct snd_pmac *chip, struct pmac_stream *rec)
438 if (rec->running) {
439 for (c = 0; c < rec->nperiods; c++) { /* at most all fragments */
444 cp = &rec->cmd.cmds[rec->cur_period];
449 snd_pmac_pcm_dead_xfer(rec, cp);
459 /*printk(KERN_DEBUG "update frag %d\n", rec->cur_period);*/
461 cp->req_count = cpu_to_le16(rec->period_size);
463 rec->cur_period++;
464 if (rec->cur_period >= rec->nperiods) {
465 rec->cur_period = 0;
469 snd_pcm_period_elapsed(rec->substream);
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,
585 runtime->private_data = rec;
586 rec->substream = subs;
590 snd_pmac_hw_rule_rate, chip, rec->stream, -1);
592 snd_pmac_hw_rule_format, chip, rec->stream, -1);
595 runtime->hw.periods_max = rec->cmd.size - 1;
602 static int snd_pmac_pcm_close(struct snd_pmac *chip, struct pmac_stream *rec,
607 snd_pmac_dma_stop(rec);
609 astr = snd_pmac_get_stream(chip, another_stream(rec->stream));
722 struct pmac_stream *rec = &chip->playback;
724 snd_pmac_dma_stop(rec);
734 snd_pmac_dma_set_command(rec, &chip->extra_dma);
735 snd_pmac_dma_run(rec, RUN);