1 // SPDX-License-Identifier: GPL-2.0-or-later 1 // SPDX-License-Identifier: GPL-2.0-or-later 2 /* 2 /* 3 * Copyright (c) by Lee Revell <rlrevell@joe- 3 * Copyright (c) by Lee Revell <rlrevell@joe-job.com> 4 * Clemens Ladisch <clemens@ 4 * Clemens Ladisch <clemens@ladisch.de> 5 * Oswald Buddenhagen <oswal << 6 * << 7 * Routines for control of EMU10K1 chips 5 * Routines for control of EMU10K1 chips >> 6 * >> 7 * BUGS: >> 8 * -- >> 9 * >> 10 * TODO: >> 11 * -- 8 */ 12 */ 9 13 10 #include <linux/time.h> 14 #include <linux/time.h> 11 #include <sound/core.h> 15 #include <sound/core.h> 12 #include <sound/emu10k1.h> 16 #include <sound/emu10k1.h> 13 17 14 static int snd_emu10k1_timer_start(struct snd_ 18 static int snd_emu10k1_timer_start(struct snd_timer *timer) 15 { 19 { 16 struct snd_emu10k1 *emu; 20 struct snd_emu10k1 *emu; >> 21 unsigned long flags; 17 unsigned int delay; 22 unsigned int delay; 18 23 19 emu = snd_timer_chip(timer); 24 emu = snd_timer_chip(timer); 20 delay = timer->sticks - 1; 25 delay = timer->sticks - 1; 21 if (delay < 5 ) /* minimum time is 5 t 26 if (delay < 5 ) /* minimum time is 5 ticks */ 22 delay = 5; 27 delay = 5; >> 28 spin_lock_irqsave(&emu->reg_lock, flags); 23 snd_emu10k1_intr_enable(emu, INTE_INTE 29 snd_emu10k1_intr_enable(emu, INTE_INTERVALTIMERENB); 24 outw(delay & TIMER_RATE_MASK, emu->por 30 outw(delay & TIMER_RATE_MASK, emu->port + TIMER); >> 31 spin_unlock_irqrestore(&emu->reg_lock, flags); 25 return 0; 32 return 0; 26 } 33 } 27 34 28 static int snd_emu10k1_timer_stop(struct snd_t 35 static int snd_emu10k1_timer_stop(struct snd_timer *timer) 29 { 36 { 30 struct snd_emu10k1 *emu; 37 struct snd_emu10k1 *emu; >> 38 unsigned long flags; 31 39 32 emu = snd_timer_chip(timer); 40 emu = snd_timer_chip(timer); >> 41 spin_lock_irqsave(&emu->reg_lock, flags); 33 snd_emu10k1_intr_disable(emu, INTE_INT 42 snd_emu10k1_intr_disable(emu, INTE_INTERVALTIMERENB); >> 43 spin_unlock_irqrestore(&emu->reg_lock, flags); 34 return 0; 44 return 0; 35 } 45 } 36 46 37 static unsigned long snd_emu10k1_timer_c_resol << 38 { << 39 struct snd_emu10k1 *emu = snd_timer_ch << 40 << 41 if (emu->card_capabilities->emu_model << 42 emu->emu1010.word_clock == 44100) << 43 return 22676; // 1 sample @ 4 << 44 else << 45 return 20833; // 1 sample @ 4 << 46 } << 47 << 48 static int snd_emu10k1_timer_precise_resolutio 47 static int snd_emu10k1_timer_precise_resolution(struct snd_timer *timer, 49 48 unsigned long *num, unsigned long *den) 50 { 49 { 51 struct snd_emu10k1 *emu = snd_timer_ch << 52 << 53 *num = 1; 50 *num = 1; 54 if (emu->card_capabilities->emu_model) !! 51 *den = 48000; 55 *den = emu->emu1010.word_clock << 56 else << 57 *den = 48000; << 58 return 0; 52 return 0; 59 } 53 } 60 54 61 static const struct snd_timer_hardware snd_emu !! 55 static struct snd_timer_hardware snd_emu10k1_timer_hw = { 62 .flags = SNDRV_TIMER_HW_AUTO, 56 .flags = SNDRV_TIMER_HW_AUTO, >> 57 .resolution = 20833, /* 1 sample @ 48KHZ = 20.833...us */ 63 .ticks = 1024, 58 .ticks = 1024, 64 .start = snd_emu10k1_timer_start, 59 .start = snd_emu10k1_timer_start, 65 .stop = snd_emu10k1_timer_stop, 60 .stop = snd_emu10k1_timer_stop, 66 .c_resolution = snd_emu10k1_timer_c_re << 67 .precise_resolution = snd_emu10k1_time 61 .precise_resolution = snd_emu10k1_timer_precise_resolution, 68 }; 62 }; 69 63 70 int snd_emu10k1_timer(struct snd_emu10k1 *emu, 64 int snd_emu10k1_timer(struct snd_emu10k1 *emu, int device) 71 { 65 { 72 struct snd_timer *timer = NULL; 66 struct snd_timer *timer = NULL; 73 struct snd_timer_id tid; 67 struct snd_timer_id tid; 74 int err; 68 int err; 75 69 76 tid.dev_class = SNDRV_TIMER_CLASS_CARD 70 tid.dev_class = SNDRV_TIMER_CLASS_CARD; 77 tid.dev_sclass = SNDRV_TIMER_SCLASS_NO 71 tid.dev_sclass = SNDRV_TIMER_SCLASS_NONE; 78 tid.card = emu->card->number; 72 tid.card = emu->card->number; 79 tid.device = device; 73 tid.device = device; 80 tid.subdevice = 0; 74 tid.subdevice = 0; 81 err = snd_timer_new(emu->card, "EMU10K !! 75 if ((err = snd_timer_new(emu->card, "EMU10K1", &tid, &timer)) >= 0) { 82 if (err >= 0) { << 83 strcpy(timer->name, "EMU10K1 t 76 strcpy(timer->name, "EMU10K1 timer"); 84 timer->private_data = emu; 77 timer->private_data = emu; 85 timer->hw = snd_emu10k1_timer_ 78 timer->hw = snd_emu10k1_timer_hw; 86 } 79 } 87 emu->timer = timer; 80 emu->timer = timer; 88 return err; 81 return err; 89 } 82 } 90 83
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.