Lines Matching defs:rec

171 static inline int emu8k_get_curpos(struct snd_emu8k_pcm *rec, int ch)
173 int val = EMU8000_CCCA_READ(rec->emu, ch) & 0xfffffff;
174 val -= rec->loop_start[ch] - 1;
185 struct snd_emu8k_pcm *rec = from_timer(rec, t, timer);
188 spin_lock(&rec->timer_lock);
190 ptr = emu8k_get_curpos(rec, 0);
191 if (ptr < rec->last_ptr)
192 delta = ptr + rec->buf_size - rec->last_ptr;
194 delta = ptr - rec->last_ptr;
195 rec->period_pos += delta;
196 rec->last_ptr = ptr;
199 mod_timer(&rec->timer, jiffies + 1);
202 if (rec->period_pos >= (int)rec->period_size) {
203 rec->period_pos %= rec->period_size;
204 spin_unlock(&rec->timer_lock);
205 snd_pcm_period_elapsed(rec->substream);
208 spin_unlock(&rec->timer_lock);
219 struct snd_emu8k_pcm *rec;
222 rec = kzalloc(sizeof(*rec), GFP_KERNEL);
223 if (! rec)
226 rec->emu = emu;
227 rec->substream = subs;
228 runtime->private_data = rec;
230 spin_lock_init(&rec->timer_lock);
231 timer_setup(&rec->timer, emu8k_pcm_timer_func, 0);
246 struct snd_emu8k_pcm *rec = subs->runtime->private_data;
247 kfree(rec);
269 static void setup_voice(struct snd_emu8k_pcm *rec, int ch)
271 struct snd_emu8000 *hw = rec->emu;
282 EMU8000_IP_WRITE(hw, ch, rec->pitch);
303 temp = rec->panning[ch];
304 temp = (temp <<24) | ((unsigned int)rec->loop_start[ch] - 1);
308 temp = (temp << 24) | ((unsigned int)rec->loop_start[ch] + rec->buf_size - 1);
312 temp = (temp << 28) | ((unsigned int)rec->loop_start[ch] - 1);
322 static void start_voice(struct snd_emu8k_pcm *rec, int ch)
325 struct snd_emu8000 *hw = rec->emu;
327 int pt = calc_pitch_target(rec->pitch);
337 if (rec->panning[ch] == 0)
340 aux = (-rec->panning[ch]) & 0xff;
346 spin_lock_irqsave(&rec->timer_lock, flags);
347 if (! rec->timer_running) {
348 mod_timer(&rec->timer, jiffies + 1);
349 rec->timer_running = 1;
351 spin_unlock_irqrestore(&rec->timer_lock, flags);
357 static void stop_voice(struct snd_emu8k_pcm *rec, int ch)
360 struct snd_emu8000 *hw = rec->emu;
365 spin_lock_irqsave(&rec->timer_lock, flags);
366 if (rec->timer_running) {
367 del_timer(&rec->timer);
368 rec->timer_running = 0;
370 spin_unlock_irqrestore(&rec->timer_lock, flags);
375 struct snd_emu8k_pcm *rec = subs->runtime->private_data;
380 for (ch = 0; ch < rec->voices; ch++)
381 start_voice(rec, ch);
382 rec->running = 1;
385 rec->running = 0;
386 for (ch = 0; ch < rec->voices; ch++)
387 stop_voice(rec, ch);
422 #define LOOP_WRITE(rec, offset, iter, count) \
424 struct snd_emu8000 *emu = (rec)->emu; \
441 struct snd_emu8k_pcm *rec = subs->runtime->private_data;
444 pos = (pos << 1) + rec->loop_start[voice];
446 LOOP_WRITE(rec, pos, src, count);
454 struct snd_emu8k_pcm *rec = subs->runtime->private_data;
457 pos = (pos << 1) + rec->loop_start[voice];
459 LOOP_WRITE(rec, pos, NULL, count);
465 #define LOOP_WRITE(rec, pos, iter, count) \
467 struct snd_emu8000 *emu = rec->emu; \
469 EMU8000_SMALW_WRITE(emu, pos + rec->loop_start[0]); \
470 if (rec->voices > 1) \
471 EMU8000_SMARW_WRITE(emu, pos + rec->loop_start[1]); \
477 if (rec->voices > 1) { \
495 struct snd_emu8k_pcm *rec = subs->runtime->private_data;
500 LOOP_WRITE(rec, pos, src, count);
507 struct snd_emu8k_pcm *rec = subs->runtime->private_data;
512 LOOP_WRITE(rec, pos, NULL, count);
524 struct snd_emu8k_pcm *rec = subs->runtime->private_data;
526 if (rec->block) {
528 snd_util_mem_free(rec->emu->memhdr, rec->block);
529 rec->block = NULL;
532 rec->allocated_bytes = params_buffer_bytes(hw_params) + LOOP_BLANK_SIZE * 4;
533 rec->block = snd_util_mem_alloc(rec->emu->memhdr, rec->allocated_bytes);
534 if (! rec->block)
536 rec->offset = EMU8000_DRAM_OFFSET + (rec->block->offset >> 1); /* in word */
548 struct snd_emu8k_pcm *rec = subs->runtime->private_data;
550 if (rec->block) {
552 for (ch = 0; ch < rec->voices; ch++)
553 stop_voice(rec, ch); // to be sure
554 if (rec->dram_opened)
555 emu8k_close_dram(rec->emu);
556 snd_util_mem_free(rec->emu->memhdr, rec->block);
557 rec->block = NULL;
566 struct snd_emu8k_pcm *rec = subs->runtime->private_data;
568 rec->pitch = 0xe000 + calc_rate_offset(subs->runtime->rate);
569 rec->last_ptr = 0;
570 rec->period_pos = 0;
572 rec->buf_size = subs->runtime->buffer_size;
573 rec->period_size = subs->runtime->period_size;
574 rec->voices = subs->runtime->channels;
575 rec->loop_start[0] = rec->offset + LOOP_BLANK_SIZE;
576 if (rec->voices > 1)
577 rec->loop_start[1] = rec->loop_start[0] + rec->buf_size + LOOP_BLANK_SIZE;
578 if (rec->voices > 1) {
579 rec->panning[0] = 0xff;
580 rec->panning[1] = 0x00;
582 rec->panning[0] = 0x80;
584 if (! rec->dram_opened) {
587 snd_emux_terminate_all(rec->emu->emu);
588 err = emu8k_open_dram_for_pcm(rec->emu, rec->voices);
591 rec->dram_opened = 1;
594 snd_emu8000_write_wait(rec->emu, 0);
595 EMU8000_SMALW_WRITE(rec->emu, rec->offset);
597 EMU8000_SMLD_WRITE(rec->emu, 0);
598 for (ch = 0; ch < rec->voices; ch++) {
599 EMU8000_SMALW_WRITE(rec->emu, rec->loop_start[ch] + rec->buf_size);
601 EMU8000_SMLD_WRITE(rec->emu, 0);
605 setup_voice(rec, 0);
606 if (rec->voices > 1)
607 setup_voice(rec, 1);
613 struct snd_emu8k_pcm *rec = subs->runtime->private_data;
614 if (rec->running)
615 return emu8k_get_curpos(rec, 0);