• Home
  • Raw
  • Download

Lines Matching refs:rec

171 static inline int emu8k_get_curpos(struct snd_emu8k_pcm *rec, int ch)  in emu8k_get_curpos()  argument
173 int val = EMU8000_CCCA_READ(rec->emu, ch) & 0xfffffff; in emu8k_get_curpos()
174 val -= rec->loop_start[ch] - 1; in emu8k_get_curpos()
185 struct snd_emu8k_pcm *rec = from_timer(rec, t, timer); in emu8k_pcm_timer_func() local
188 spin_lock(&rec->timer_lock); in emu8k_pcm_timer_func()
190 ptr = emu8k_get_curpos(rec, 0); in emu8k_pcm_timer_func()
191 if (ptr < rec->last_ptr) in emu8k_pcm_timer_func()
192 delta = ptr + rec->buf_size - rec->last_ptr; in emu8k_pcm_timer_func()
194 delta = ptr - rec->last_ptr; in emu8k_pcm_timer_func()
195 rec->period_pos += delta; in emu8k_pcm_timer_func()
196 rec->last_ptr = ptr; in emu8k_pcm_timer_func()
199 mod_timer(&rec->timer, jiffies + 1); in emu8k_pcm_timer_func()
202 if (rec->period_pos >= (int)rec->period_size) { in emu8k_pcm_timer_func()
203 rec->period_pos %= rec->period_size; in emu8k_pcm_timer_func()
204 spin_unlock(&rec->timer_lock); in emu8k_pcm_timer_func()
205 snd_pcm_period_elapsed(rec->substream); in emu8k_pcm_timer_func()
208 spin_unlock(&rec->timer_lock); in emu8k_pcm_timer_func()
219 struct snd_emu8k_pcm *rec; in emu8k_pcm_open() local
222 rec = kzalloc(sizeof(*rec), GFP_KERNEL); in emu8k_pcm_open()
223 if (! rec) in emu8k_pcm_open()
226 rec->emu = emu; in emu8k_pcm_open()
227 rec->substream = subs; in emu8k_pcm_open()
228 runtime->private_data = rec; in emu8k_pcm_open()
230 spin_lock_init(&rec->timer_lock); in emu8k_pcm_open()
231 timer_setup(&rec->timer, emu8k_pcm_timer_func, 0); in emu8k_pcm_open()
246 struct snd_emu8k_pcm *rec = subs->runtime->private_data; in emu8k_pcm_close() local
247 kfree(rec); in emu8k_pcm_close()
269 static void setup_voice(struct snd_emu8k_pcm *rec, int ch) in setup_voice() argument
271 struct snd_emu8000 *hw = rec->emu; in setup_voice()
282 EMU8000_IP_WRITE(hw, ch, rec->pitch); in setup_voice()
303 temp = rec->panning[ch]; in setup_voice()
304 temp = (temp <<24) | ((unsigned int)rec->loop_start[ch] - 1); in setup_voice()
308 temp = (temp << 24) | ((unsigned int)rec->loop_start[ch] + rec->buf_size - 1); in setup_voice()
312 temp = (temp << 28) | ((unsigned int)rec->loop_start[ch] - 1); in setup_voice()
322 static void start_voice(struct snd_emu8k_pcm *rec, int ch) in start_voice() argument
325 struct snd_emu8000 *hw = rec->emu; in start_voice()
327 int pt = calc_pitch_target(rec->pitch); in start_voice()
337 if (rec->panning[ch] == 0) in start_voice()
340 aux = (-rec->panning[ch]) & 0xff; in start_voice()
346 spin_lock_irqsave(&rec->timer_lock, flags); in start_voice()
347 if (! rec->timer_running) { in start_voice()
348 mod_timer(&rec->timer, jiffies + 1); in start_voice()
349 rec->timer_running = 1; in start_voice()
351 spin_unlock_irqrestore(&rec->timer_lock, flags); in start_voice()
357 static void stop_voice(struct snd_emu8k_pcm *rec, int ch) in stop_voice() argument
360 struct snd_emu8000 *hw = rec->emu; in stop_voice()
365 spin_lock_irqsave(&rec->timer_lock, flags); in stop_voice()
366 if (rec->timer_running) { in stop_voice()
367 del_timer(&rec->timer); in stop_voice()
368 rec->timer_running = 0; in stop_voice()
370 spin_unlock_irqrestore(&rec->timer_lock, flags); in stop_voice()
375 struct snd_emu8k_pcm *rec = subs->runtime->private_data; in emu8k_pcm_trigger() local
380 for (ch = 0; ch < rec->voices; ch++) in emu8k_pcm_trigger()
381 start_voice(rec, ch); in emu8k_pcm_trigger()
382 rec->running = 1; in emu8k_pcm_trigger()
385 rec->running = 0; in emu8k_pcm_trigger()
386 for (ch = 0; ch < rec->voices; ch++) in emu8k_pcm_trigger()
387 stop_voice(rec, ch); in emu8k_pcm_trigger()
435 #define LOOP_WRITE(rec, offset, _buf, count, mode) \ argument
437 struct snd_emu8000 *emu = (rec)->emu; \
455 struct snd_emu8k_pcm *rec = subs->runtime->private_data; in emu8k_pcm_copy() local
458 pos = (pos << 1) + rec->loop_start[voice]; in emu8k_pcm_copy()
460 LOOP_WRITE(rec, pos, src, count, COPY_USER); in emu8k_pcm_copy()
468 struct snd_emu8k_pcm *rec = subs->runtime->private_data; in emu8k_pcm_copy_kernel() local
471 pos = (pos << 1) + rec->loop_start[voice]; in emu8k_pcm_copy_kernel()
473 LOOP_WRITE(rec, pos, src, count, COPY_KERNEL); in emu8k_pcm_copy_kernel()
481 struct snd_emu8k_pcm *rec = subs->runtime->private_data; in emu8k_pcm_silence() local
484 pos = (pos << 1) + rec->loop_start[voice]; in emu8k_pcm_silence()
486 LOOP_WRITE(rec, pos, NULL, count, FILL_SILENCE); in emu8k_pcm_silence()
492 #define LOOP_WRITE(rec, pos, _buf, count, mode) \ argument
494 struct snd_emu8000 *emu = rec->emu; \
497 EMU8000_SMALW_WRITE(emu, pos + rec->loop_start[0]); \
498 if (rec->voices > 1) \
499 EMU8000_SMARW_WRITE(emu, pos + rec->loop_start[1]); \
505 if (rec->voices > 1) { \
523 struct snd_emu8k_pcm *rec = subs->runtime->private_data; in emu8k_pcm_copy() local
528 LOOP_WRITE(rec, pos, src, count, COPY_USER); in emu8k_pcm_copy()
536 struct snd_emu8k_pcm *rec = subs->runtime->private_data; in emu8k_pcm_copy_kernel() local
541 LOOP_WRITE(rec, pos, src, count, COPY_KERNEL); in emu8k_pcm_copy_kernel()
548 struct snd_emu8k_pcm *rec = subs->runtime->private_data; in emu8k_pcm_silence() local
553 LOOP_WRITE(rec, pos, NULL, count, FILL_SILENCE); in emu8k_pcm_silence()
565 struct snd_emu8k_pcm *rec = subs->runtime->private_data; in emu8k_pcm_hw_params() local
567 if (rec->block) { in emu8k_pcm_hw_params()
569 snd_util_mem_free(rec->emu->memhdr, rec->block); in emu8k_pcm_hw_params()
570 rec->block = NULL; in emu8k_pcm_hw_params()
573 rec->allocated_bytes = params_buffer_bytes(hw_params) + LOOP_BLANK_SIZE * 4; in emu8k_pcm_hw_params()
574 rec->block = snd_util_mem_alloc(rec->emu->memhdr, rec->allocated_bytes); in emu8k_pcm_hw_params()
575 if (! rec->block) in emu8k_pcm_hw_params()
577 rec->offset = EMU8000_DRAM_OFFSET + (rec->block->offset >> 1); /* in word */ in emu8k_pcm_hw_params()
589 struct snd_emu8k_pcm *rec = subs->runtime->private_data; in emu8k_pcm_hw_free() local
591 if (rec->block) { in emu8k_pcm_hw_free()
593 for (ch = 0; ch < rec->voices; ch++) in emu8k_pcm_hw_free()
594 stop_voice(rec, ch); // to be sure in emu8k_pcm_hw_free()
595 if (rec->dram_opened) in emu8k_pcm_hw_free()
596 emu8k_close_dram(rec->emu); in emu8k_pcm_hw_free()
597 snd_util_mem_free(rec->emu->memhdr, rec->block); in emu8k_pcm_hw_free()
598 rec->block = NULL; in emu8k_pcm_hw_free()
607 struct snd_emu8k_pcm *rec = subs->runtime->private_data; in emu8k_pcm_prepare() local
609 rec->pitch = 0xe000 + calc_rate_offset(subs->runtime->rate); in emu8k_pcm_prepare()
610 rec->last_ptr = 0; in emu8k_pcm_prepare()
611 rec->period_pos = 0; in emu8k_pcm_prepare()
613 rec->buf_size = subs->runtime->buffer_size; in emu8k_pcm_prepare()
614 rec->period_size = subs->runtime->period_size; in emu8k_pcm_prepare()
615 rec->voices = subs->runtime->channels; in emu8k_pcm_prepare()
616 rec->loop_start[0] = rec->offset + LOOP_BLANK_SIZE; in emu8k_pcm_prepare()
617 if (rec->voices > 1) in emu8k_pcm_prepare()
618 rec->loop_start[1] = rec->loop_start[0] + rec->buf_size + LOOP_BLANK_SIZE; in emu8k_pcm_prepare()
619 if (rec->voices > 1) { in emu8k_pcm_prepare()
620 rec->panning[0] = 0xff; in emu8k_pcm_prepare()
621 rec->panning[1] = 0x00; in emu8k_pcm_prepare()
623 rec->panning[0] = 0x80; in emu8k_pcm_prepare()
625 if (! rec->dram_opened) { in emu8k_pcm_prepare()
628 snd_emux_terminate_all(rec->emu->emu); in emu8k_pcm_prepare()
629 err = emu8k_open_dram_for_pcm(rec->emu, rec->voices); in emu8k_pcm_prepare()
632 rec->dram_opened = 1; in emu8k_pcm_prepare()
635 snd_emu8000_write_wait(rec->emu, 0); in emu8k_pcm_prepare()
636 EMU8000_SMALW_WRITE(rec->emu, rec->offset); in emu8k_pcm_prepare()
638 EMU8000_SMLD_WRITE(rec->emu, 0); in emu8k_pcm_prepare()
639 for (ch = 0; ch < rec->voices; ch++) { in emu8k_pcm_prepare()
640 EMU8000_SMALW_WRITE(rec->emu, rec->loop_start[ch] + rec->buf_size); in emu8k_pcm_prepare()
642 EMU8000_SMLD_WRITE(rec->emu, 0); in emu8k_pcm_prepare()
646 setup_voice(rec, 0); in emu8k_pcm_prepare()
647 if (rec->voices > 1) in emu8k_pcm_prepare()
648 setup_voice(rec, 1); in emu8k_pcm_prepare()
654 struct snd_emu8k_pcm *rec = subs->runtime->private_data; in emu8k_pcm_pointer() local
655 if (rec->running) in emu8k_pcm_pointer()
656 return emu8k_get_curpos(rec, 0); in emu8k_pcm_pointer()