Lines Matching full:ch

25 static void transfer_mem2mem(struct soc_dma_ch_s *ch)  in transfer_mem2mem()  argument
27 memcpy(ch->paddr[0], ch->paddr[1], ch->bytes); in transfer_mem2mem()
28 ch->paddr[0] += ch->bytes; in transfer_mem2mem()
29 ch->paddr[1] += ch->bytes; in transfer_mem2mem()
32 static void transfer_mem2fifo(struct soc_dma_ch_s *ch) in transfer_mem2fifo() argument
34 ch->io_fn[1](ch->io_opaque[1], ch->paddr[0], ch->bytes); in transfer_mem2fifo()
35 ch->paddr[0] += ch->bytes; in transfer_mem2fifo()
38 static void transfer_fifo2mem(struct soc_dma_ch_s *ch) in transfer_fifo2mem() argument
40 ch->io_fn[0](ch->io_opaque[0], ch->paddr[1], ch->bytes); in transfer_fifo2mem()
41 ch->paddr[1] += ch->bytes; in transfer_fifo2mem()
49 static void transfer_fifo2fifo(struct soc_dma_ch_s *ch) in transfer_fifo2fifo() argument
51 if (ch->bytes > fifo_size) in transfer_fifo2fifo()
52 fifo_buf = g_realloc(fifo_buf, fifo_size = ch->bytes); in transfer_fifo2fifo()
55 ch->io_fn[0](ch->io_opaque[0], fifo_buf, ch->bytes); in transfer_fifo2fifo()
56 ch->io_fn[1](ch->io_opaque[1], fifo_buf, ch->bytes); in transfer_fifo2fifo()
83 struct soc_dma_ch_s ch[]; member
86 static void soc_dma_ch_schedule(struct soc_dma_ch_s *ch, int delay_bytes) in soc_dma_ch_schedule() argument
89 struct dma_s *dma = (struct dma_s *) ch->dma; in soc_dma_ch_schedule()
91 timer_mod(ch->timer, now + delay_bytes / dma->channel_freq); in soc_dma_ch_schedule()
96 struct soc_dma_ch_s *ch = (struct soc_dma_ch_s *) opaque; in soc_dma_ch_run() local
98 ch->running = 1; in soc_dma_ch_run()
99 ch->dma->setup_fn(ch); in soc_dma_ch_run()
100 ch->transfer_fn(ch); in soc_dma_ch_run()
101 ch->running = 0; in soc_dma_ch_run()
103 if (ch->enable) in soc_dma_ch_run()
104 soc_dma_ch_schedule(ch, ch->bytes); in soc_dma_ch_run()
105 ch->bytes = 0; in soc_dma_ch_run()
127 struct soc_dma_ch_s *ch, int port) in soc_dma_ch_update_type() argument
129 struct dma_s *dma = (struct dma_s *) ch->dma; in soc_dma_ch_update_type()
130 struct memmap_entry_s *entry = soc_dma_lookup(dma, ch->vaddr[port]); in soc_dma_ch_update_type()
136 if (entry->addr != ch->vaddr[port] || entry->u.fifo.out != port) in soc_dma_ch_update_type()
139 if (ch->type[port] != soc_dma_access_const) in soc_dma_ch_update_type()
142 ch->io_fn[port] = entry->u.fifo.fn; in soc_dma_ch_update_type()
143 ch->io_opaque[port] = entry->u.fifo.opaque; in soc_dma_ch_update_type()
146 if (entry->addr > ch->vaddr[port] || in soc_dma_ch_update_type()
147 entry->addr + entry->u.mem.size <= ch->vaddr[port]) in soc_dma_ch_update_type()
152 if (ch->type[port] != soc_dma_access_const) in soc_dma_ch_update_type()
155 ch->paddr[port] = (uint8_t *) entry->u.mem.base + in soc_dma_ch_update_type()
156 (ch->vaddr[port] - entry->addr); in soc_dma_ch_update_type()
164 void soc_dma_ch_update(struct soc_dma_ch_s *ch) in soc_dma_ch_update() argument
168 src = soc_dma_ch_update_type(ch, 0); in soc_dma_ch_update()
170 ch->update = 0; in soc_dma_ch_update()
171 ch->transfer_fn = ch->dma->transfer_fn; in soc_dma_ch_update()
174 dst = soc_dma_ch_update_type(ch, 1); in soc_dma_ch_update()
178 ch->transfer_fn = transfer_mem2mem; in soc_dma_ch_update()
180 ch->transfer_fn = transfer_mem2fifo; in soc_dma_ch_update()
182 ch->transfer_fn = transfer_fifo2mem; in soc_dma_ch_update()
184 ch->transfer_fn = transfer_fifo2fifo; in soc_dma_ch_update()
186 ch->transfer_fn = ch->dma->transfer_fn; in soc_dma_ch_update()
188 ch->update = (dst != soc_dma_port_other); in soc_dma_ch_update()
205 void soc_dma_set_request(struct soc_dma_ch_s *ch, int level) in soc_dma_set_request() argument
207 struct dma_s *dma = (struct dma_s *) ch->dma; in soc_dma_set_request()
209 dma->enabled_count += level - ch->enable; in soc_dma_set_request()
212 dma->ch_enable_mask |= (uint64_t)1 << ch->num; in soc_dma_set_request()
214 dma->ch_enable_mask &= ~((uint64_t)1 << ch->num); in soc_dma_set_request()
216 if (level != ch->enable) { in soc_dma_set_request()
218 ch->enable = level; in soc_dma_set_request()
220 if (!ch->enable) in soc_dma_set_request()
221 timer_del(ch->timer); in soc_dma_set_request()
222 else if (!ch->running) in soc_dma_set_request()
223 soc_dma_ch_run(ch); in soc_dma_set_request()
225 soc_dma_ch_schedule(ch, 1); in soc_dma_set_request()
243 struct dma_s *s = g_malloc0(sizeof(*s) + n * sizeof(*s->ch)); in soc_dma_init()
246 s->soc.ch = s->ch; in soc_dma_init()
248 s->ch[i].dma = &s->soc; in soc_dma_init()
249 s->ch[i].num = i; in soc_dma_init()
250 s->ch[i].timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, soc_dma_ch_run, &s->ch[i]); in soc_dma_init()