#include <linux/interrupt.h>
#include <linux/slab.h>
#include <linux/pci.h>
+#include <linux/firmware.h>
#include <linux/moduleparam.h>
#include <sound/core.h>
static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
-static int precise_ptr[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = 0 }; /* Enable precise pointer */
-static int line_outs_monitor[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = 0}; /* Send all inputs/playback to line outs */
-static int boot_devs;
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
MODULE_PARM_DESC(index, "Index value for RME Hammerfall DSP interface.");
-MODULE_PARM_SYNTAX(index, SNDRV_INDEX_DESC);
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
MODULE_PARM_DESC(id, "ID string for RME Hammerfall DSP interface.");
-MODULE_PARM_SYNTAX(id, SNDRV_ID_DESC);
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
MODULE_PARM_DESC(enable, "Enable/disable specific Hammerfall DSP soundcards.");
-MODULE_PARM_SYNTAX(enable, SNDRV_ENABLE_DESC);
-module_param_array(precise_ptr, bool, boot_devs, 0444);
-MODULE_PARM_DESC(precise_ptr, "Enable precise pointer (doesn't work reliably).");
-MODULE_PARM_SYNTAX(precise_ptr, SNDRV_ENABLED "," SNDRV_BOOLEAN_FALSE_DESC);
-module_param_array(line_outs_monitor, bool, boot_devs, 0444);
-MODULE_PARM_DESC(line_outs_monitor, "Send all input and playback streams to line outs by default.");
-MODULE_PARM_SYNTAX(line_outs_monitor, SNDRV_ENABLED "," SNDRV_BOOLEAN_FALSE_DESC);
MODULE_AUTHOR("Paul Davis <paul@linuxaudiosystems.com>, Marcus Andersson, Thomas Charbonnel <thomas@undata.org>");
MODULE_DESCRIPTION("RME Hammerfall DSP");
MODULE_LICENSE("GPL");
-MODULE_CLASSES("{sound}");
-MODULE_DEVICES("{{RME Hammerfall-DSP},"
+MODULE_SUPPORTED_DEVICE("{{RME Hammerfall-DSP},"
"{RME HDSP-9652},"
"{RME HDSP-9632}}");
#define UNITY_GAIN 32768
#define MINUS_INFINITY_GAIN 0
-#ifndef PCI_VENDOR_ID_XILINX
-#define PCI_VENDOR_ID_XILINX 0x10ee
-#endif
-#ifndef PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP
-#define PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP 0x3fc5
-#endif
-
/* the size of a substream (1 mono data stream) */
#define HDSP_CHANNEL_BUFFER_SAMPLES (16*1024)
#define HDSP_DMA_AREA_BYTES ((HDSP_MAX_CHANNELS+1) * HDSP_CHANNEL_BUFFER_BYTES)
#define HDSP_DMA_AREA_KILOBYTES (HDSP_DMA_AREA_BYTES/1024)
-typedef struct _hdsp hdsp_t;
-typedef struct _hdsp_midi hdsp_midi_t;
-typedef struct _hdsp_9632_meters hdsp_9632_meters_t;
+/* use hotplug firmeare loader? */
+#if defined(CONFIG_FW_LOADER) || defined(CONFIG_FW_LOADER_MODULE)
+#ifndef HDSP_USE_HWDEP_LOADER
+#define HDSP_FW_LOADER
+#endif
+#endif
-struct _hdsp_9632_meters {
+struct hdsp_9632_meters {
u32 input_peak[16];
u32 playback_peak[16];
u32 output_peak[16];
u32 xxx_rms_high[16];
};
-struct _hdsp_midi {
- hdsp_t *hdsp;
+struct hdsp_midi {
+ struct hdsp *hdsp;
int id;
- snd_rawmidi_t *rmidi;
- snd_rawmidi_substream_t *input;
- snd_rawmidi_substream_t *output;
+ struct snd_rawmidi *rmidi;
+ struct snd_rawmidi_substream *input;
+ struct snd_rawmidi_substream *output;
char istimer; /* timer in use */
struct timer_list timer;
spinlock_t lock;
int pending;
};
-struct _hdsp {
+struct hdsp {
spinlock_t lock;
- snd_pcm_substream_t *capture_substream;
- snd_pcm_substream_t *playback_substream;
- hdsp_midi_t midi[2];
+ struct snd_pcm_substream *capture_substream;
+ struct snd_pcm_substream *playback_substream;
+ struct hdsp_midi midi[2];
struct tasklet_struct midi_tasklet;
+ int use_midi_tasklet;
int precise_ptr;
u32 control_register; /* cached value */
u32 control2_register; /* cached value */
u32 creg_spdif;
u32 creg_spdif_stream;
+ int clock_source_locked;
char *card_name; /* digiface/multiface */
- HDSP_IO_Type io_type; /* ditto, but for code use */
+ enum HDSP_IO_Type io_type; /* ditto, but for code use */
unsigned short firmware_rev;
unsigned short state; /* stores state bits */
u32 firmware_cache[24413]; /* this helps recover from accidental iobox power failure */
unsigned char qs_out_channels;
unsigned char ds_out_channels;
unsigned char ss_out_channels;
- void *capture_buffer_unaligned; /* original buffer addresses */
- void *playback_buffer_unaligned; /* original buffer addresses */
+
+ struct snd_dma_buffer capture_dma_buf;
+ struct snd_dma_buffer playback_dma_buf;
unsigned char *capture_buffer; /* suitably aligned address */
unsigned char *playback_buffer; /* suitably aligned address */
- dma_addr_t capture_buffer_addr;
- dma_addr_t playback_buffer_addr;
+
pid_t capture_pid;
pid_t playback_pid;
int running;
- int passthru; /* non-zero if doing pass-thru */
int system_sample_rate;
char *channel_map;
int dev;
int irq;
unsigned long port;
- struct resource *res_port;
- unsigned long iobase;
- snd_card_t *card;
- snd_pcm_t *pcm;
- snd_hwdep_t *hwdep;
+ void __iomem *iobase;
+ struct snd_card *card;
+ struct snd_pcm *pcm;
+ struct snd_hwdep *hwdep;
struct pci_dev *pci;
- snd_kcontrol_t *spdif_ctl;
+ struct snd_kcontrol *spdif_ctl;
unsigned short mixer_matrix[HDSP_MATRIX_MIXER_SIZE];
};
-1, -1
};
-#define HDSP_PREALLOCATE_MEMORY /* via module snd-hdsp_mem */
-
-#ifdef HDSP_PREALLOCATE_MEMORY
-static void *snd_hammerfall_get_buffer(struct pci_dev *pci, size_t size, dma_addr_t *addrp, int capture)
+static int snd_hammerfall_get_buffer(struct pci_dev *pci, struct snd_dma_buffer *dmab, size_t size)
{
- struct snd_dma_device pdev;
- struct snd_dma_buffer dmbuf;
-
- memset(&pdev, 0, sizeof(pdev));
- pdev.type = SNDRV_DMA_TYPE_DEV;
- pdev.dev = snd_dma_pci_data(pci);
- pdev.id = capture;
- dmbuf.bytes = 0;
- if (! snd_dma_get_reserved(&pdev, &dmbuf)) {
- if (snd_dma_alloc_pages(&pdev, size, &dmbuf) < 0)
- return NULL;
- snd_dma_set_reserved(&pdev, &dmbuf);
+ dmab->dev.type = SNDRV_DMA_TYPE_DEV;
+ dmab->dev.dev = snd_dma_pci_data(pci);
+ if (snd_dma_get_reserved_buf(dmab, snd_dma_pci_buf_id(pci))) {
+ if (dmab->bytes >= size)
+ return 0;
}
- *addrp = dmbuf.addr;
- return dmbuf.area;
-}
-
-static void snd_hammerfall_free_buffer(struct pci_dev *pci, size_t size, void *ptr, dma_addr_t addr, int capture)
-{
- struct snd_dma_device pdev;
-
- memset(&pdev, 0, sizeof(pdev));
- pdev.type = SNDRV_DMA_TYPE_DEV;
- pdev.dev = snd_dma_pci_data(pci);
- pdev.id = capture;
- snd_dma_free_reserved(&pdev);
+ if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
+ size, dmab) < 0)
+ return -ENOMEM;
+ return 0;
}
-#else
-static void *snd_hammerfall_get_buffer(struct pci_dev *pci, size_t size, dma_addr_t *addrp, int capture)
+static void snd_hammerfall_free_buffer(struct snd_dma_buffer *dmab, struct pci_dev *pci)
{
- return snd_malloc_pci_pages(pci, size, addrp);
+ if (dmab->area) {
+ dmab->dev.dev = NULL; /* make it anonymous */
+ snd_dma_reserve_buf(dmab, snd_dma_pci_buf_id(pci));
+ }
}
-static void snd_hammerfall_free_buffer(struct pci_dev *pci, size_t size, void *ptr, dma_addr_t addr, int capture)
-{
- snd_free_pci_pages(pci, size, ptr, addr);
-}
-#endif
static struct pci_device_id snd_hdsp_ids[] = {
{
MODULE_DEVICE_TABLE(pci, snd_hdsp_ids);
/* prototypes */
-static int __devinit snd_hdsp_create_alsa_devices(snd_card_t *card, hdsp_t *hdsp);
-static int __devinit snd_hdsp_create_pcm(snd_card_t *card, hdsp_t *hdsp);
-static inline int snd_hdsp_enable_io (hdsp_t *hdsp);
-static inline void snd_hdsp_initialize_midi_flush (hdsp_t *hdsp);
-static inline void snd_hdsp_initialize_channels (hdsp_t *hdsp);
-static inline int hdsp_fifo_wait(hdsp_t *hdsp, int count, int timeout);
-static int hdsp_autosync_ref(hdsp_t *hdsp);
-static int snd_hdsp_set_defaults(hdsp_t *hdsp);
-static inline void snd_hdsp_9652_enable_mixer (hdsp_t *hdsp);
-
-static inline int hdsp_playback_to_output_key (hdsp_t *hdsp, int in, int out)
+static int snd_hdsp_create_alsa_devices(struct snd_card *card, struct hdsp *hdsp);
+static int snd_hdsp_create_pcm(struct snd_card *card, struct hdsp *hdsp);
+static int snd_hdsp_enable_io (struct hdsp *hdsp);
+static void snd_hdsp_initialize_midi_flush (struct hdsp *hdsp);
+static void snd_hdsp_initialize_channels (struct hdsp *hdsp);
+static int hdsp_fifo_wait(struct hdsp *hdsp, int count, int timeout);
+static int hdsp_autosync_ref(struct hdsp *hdsp);
+static int snd_hdsp_set_defaults(struct hdsp *hdsp);
+static void snd_hdsp_9652_enable_mixer (struct hdsp *hdsp);
+
+static int hdsp_playback_to_output_key (struct hdsp *hdsp, int in, int out)
{
switch (hdsp->firmware_rev) {
case 0xa:
}
}
-static inline int hdsp_input_to_output_key (hdsp_t *hdsp, int in, int out)
+static int hdsp_input_to_output_key (struct hdsp *hdsp, int in, int out)
{
switch (hdsp->firmware_rev) {
case 0xa:
}
}
-static inline void hdsp_write(hdsp_t *hdsp, int reg, int val)
+static void hdsp_write(struct hdsp *hdsp, int reg, int val)
{
writel(val, hdsp->iobase + reg);
}
-static inline unsigned int hdsp_read(hdsp_t *hdsp, int reg)
+static unsigned int hdsp_read(struct hdsp *hdsp, int reg)
{
return readl (hdsp->iobase + reg);
}
-static inline int hdsp_check_for_iobox (hdsp_t *hdsp)
+static int hdsp_check_for_iobox (struct hdsp *hdsp)
{
if (hdsp->io_type == H9652 || hdsp->io_type == H9632) return 0;
}
-static int snd_hdsp_load_firmware_from_cache(hdsp_t *hdsp) {
+static int snd_hdsp_load_firmware_from_cache(struct hdsp *hdsp) {
int i;
unsigned long flags;
if ((hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DllError) != 0) {
- snd_printk ("loading firmware\n");
+ snd_printk ("Hammerfall-DSP: loading firmware\n");
hdsp_write (hdsp, HDSP_control2Reg, HDSP_S_PROGRAM);
hdsp_write (hdsp, HDSP_fifoData, 0);
if (hdsp_fifo_wait (hdsp, 0, HDSP_LONG_WAIT)) {
- snd_printk ("timeout waiting for download preparation\n");
+ snd_printk ("Hammerfall-DSP: timeout waiting for download preparation\n");
return -EIO;
}
for (i = 0; i < 24413; ++i) {
hdsp_write(hdsp, HDSP_fifoData, hdsp->firmware_cache[i]);
if (hdsp_fifo_wait (hdsp, 127, HDSP_LONG_WAIT)) {
- snd_printk ("timeout during firmware loading\n");
+ snd_printk ("Hammerfall-DSP: timeout during firmware loading\n");
return -EIO;
}
}
- if ((1000 / HZ) < 3000) {
- set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout((3000 * HZ + 999) / 1000);
- } else {
- mdelay(3000);
- }
+ ssleep(3);
if (hdsp_fifo_wait (hdsp, 0, HDSP_LONG_WAIT)) {
- snd_printk ("timeout at end of firmware loading\n");
+ snd_printk ("Hammerfall-DSP: timeout at end of firmware loading\n");
return -EIO;
}
hdsp->control2_register = 0;
#endif
hdsp_write (hdsp, HDSP_control2Reg, hdsp->control2_register);
- snd_printk ("finished firmware loading\n");
+ snd_printk ("Hammerfall-DSP: finished firmware loading\n");
}
if (hdsp->state & HDSP_InitializationComplete) {
- snd_printk("firmware loaded from cache, restoring defaults\n");
+ snd_printk(KERN_INFO "Hammerfall-DSP: firmware loaded from cache, restoring defaults\n");
spin_lock_irqsave(&hdsp->lock, flags);
snd_hdsp_set_defaults(hdsp);
spin_unlock_irqrestore(&hdsp->lock, flags);
return 0;
}
-static inline int hdsp_get_iobox_version (hdsp_t *hdsp)
+static int hdsp_get_iobox_version (struct hdsp *hdsp)
{
- int err;
-
- if (hdsp_check_for_iobox (hdsp)) {
- return -EIO;
- }
-
- if ((err = snd_hdsp_enable_io(hdsp)) < 0) {
- return err;
- }
-
if ((hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DllError) != 0) {
hdsp_write (hdsp, HDSP_control2Reg, HDSP_PROGRAM);
hdsp_write (hdsp, HDSP_fifoData, 0);
- if (hdsp_fifo_wait (hdsp, 0, HDSP_SHORT_WAIT) < 0) {
+ if (hdsp_fifo_wait (hdsp, 0, HDSP_SHORT_WAIT) < 0)
return -EIO;
- }
hdsp_write (hdsp, HDSP_control2Reg, HDSP_S_LOAD);
hdsp_write (hdsp, HDSP_fifoData, 0);
}
} else {
/* firmware was already loaded, get iobox type */
- if (hdsp_read(hdsp, HDSP_status2Register) & HDSP_version1) {
+ if (hdsp_read(hdsp, HDSP_status2Register) & HDSP_version1)
hdsp->io_type = Multiface;
- } else {
+ else
hdsp->io_type = Digiface;
- }
}
return 0;
}
-static inline int hdsp_check_for_firmware (hdsp_t *hdsp)
+static int hdsp_check_for_firmware (struct hdsp *hdsp, int show_err)
{
if (hdsp->io_type == H9652 || hdsp->io_type == H9632) return 0;
if ((hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DllError) != 0) {
- snd_printk("firmware not present.\n");
+ snd_printk(KERN_ERR "Hammerfall-DSP: firmware not present.\n");
hdsp->state &= ~HDSP_FirmwareLoaded;
+ if (! show_err)
+ return -EIO;
+ /* try to load firmware */
+ if (hdsp->state & HDSP_FirmwareCached) {
+ if (snd_hdsp_load_firmware_from_cache(hdsp) != 0)
+ snd_printk(KERN_ERR "Hammerfall-DSP: Firmware loading from cache failed, please upload manually.\n");
+ } else {
+ snd_printk(KERN_ERR "Hammerfall-DSP: No firmware loaded nor cached, please upload firmware.\n");
+ }
return -EIO;
}
return 0;
}
-static inline int hdsp_fifo_wait(hdsp_t *hdsp, int count, int timeout)
+static int hdsp_fifo_wait(struct hdsp *hdsp, int count, int timeout)
{
int i;
udelay (100);
}
- snd_printk ("wait for FIFO status <= %d failed after %d iterations\n",
+ snd_printk ("Hammerfall-DSP: wait for FIFO status <= %d failed after %d iterations\n",
count, timeout);
return -1;
}
-static inline int hdsp_read_gain (hdsp_t *hdsp, unsigned int addr)
+static int hdsp_read_gain (struct hdsp *hdsp, unsigned int addr)
{
- if (addr >= HDSP_MATRIX_MIXER_SIZE) {
+ if (addr >= HDSP_MATRIX_MIXER_SIZE)
return 0;
- }
+
return hdsp->mixer_matrix[addr];
}
-static inline int hdsp_write_gain(hdsp_t *hdsp, unsigned int addr, unsigned short data)
+static int hdsp_write_gain(struct hdsp *hdsp, unsigned int addr, unsigned short data)
{
unsigned int ad;
if (hdsp->io_type == H9652 || hdsp->io_type == H9632) {
- /* from martin björnsen:
+ /* from martin bjornsen:
"You can only write dwords to the
mixer memory which contain two
memory."
*/
- if (hdsp->io_type == H9632 && addr >= 512) {
+ if (hdsp->io_type == H9632 && addr >= 512)
return 0;
- }
- if (hdsp->io_type == H9652 && addr >= 1352) {
+ if (hdsp->io_type == H9652 && addr >= 1352)
return 0;
- }
hdsp->mixer_matrix[addr] = data;
ad = (addr << 16) + data;
- if (hdsp_fifo_wait(hdsp, 127, HDSP_LONG_WAIT)) {
+ if (hdsp_fifo_wait(hdsp, 127, HDSP_LONG_WAIT))
return -1;
- }
hdsp_write (hdsp, HDSP_fifoData, ad);
hdsp->mixer_matrix[addr] = data;
return 0;
}
-static inline int snd_hdsp_use_is_exclusive(hdsp_t *hdsp)
+static int snd_hdsp_use_is_exclusive(struct hdsp *hdsp)
{
unsigned long flags;
int ret = 1;
spin_lock_irqsave(&hdsp->lock, flags);
if ((hdsp->playback_pid != hdsp->capture_pid) &&
- (hdsp->playback_pid >= 0) && (hdsp->capture_pid >= 0)) {
+ (hdsp->playback_pid >= 0) && (hdsp->capture_pid >= 0))
ret = 0;
- }
spin_unlock_irqrestore(&hdsp->lock, flags);
return ret;
}
-static inline int hdsp_external_sample_rate (hdsp_t *hdsp)
+static int hdsp_external_sample_rate (struct hdsp *hdsp)
{
unsigned int status2 = hdsp_read(hdsp, HDSP_status2Register);
unsigned int rate_bits = status2 & HDSP_systemFrequencyMask;
}
}
-static inline int hdsp_spdif_sample_rate(hdsp_t *hdsp)
+static int hdsp_spdif_sample_rate(struct hdsp *hdsp)
{
unsigned int status = hdsp_read(hdsp, HDSP_statusRegister);
unsigned int rate_bits = (status & HDSP_spdifFrequencyMask);
- if (status & HDSP_SPDIFErrorFlag) {
+ if (status & HDSP_SPDIFErrorFlag)
return 0;
- }
switch (rate_bits) {
case HDSP_spdifFrequency32KHz: return 32000;
default:
break;
}
- snd_printk ("unknown spdif frequency status; bits = 0x%x, status = 0x%x\n", rate_bits, status);
+ snd_printk ("Hammerfall-DSP: unknown spdif frequency status; bits = 0x%x, status = 0x%x\n", rate_bits, status);
return 0;
}
-static inline void hdsp_compute_period_size(hdsp_t *hdsp)
+static void hdsp_compute_period_size(struct hdsp *hdsp)
{
hdsp->period_bytes = 1 << ((hdsp_decode_latency(hdsp->control_register) + 8));
}
-static snd_pcm_uframes_t hdsp_hw_pointer(hdsp_t *hdsp)
+static snd_pcm_uframes_t hdsp_hw_pointer(struct hdsp *hdsp)
{
int position;
position = hdsp_read(hdsp, HDSP_statusRegister);
- if (!hdsp->precise_ptr) {
+ if (!hdsp->precise_ptr)
return (position & HDSP_BufferID) ? (hdsp->period_bytes / 4) : 0;
- }
position &= HDSP_BufferPositionMask;
position /= 4;
- position -= 32;
- position &= (HDSP_CHANNEL_BUFFER_SAMPLES-1);
+ position &= (hdsp->period_bytes/2) - 1;
return position;
}
-static inline void hdsp_reset_hw_pointer(hdsp_t *hdsp)
+static void hdsp_reset_hw_pointer(struct hdsp *hdsp)
{
hdsp_write (hdsp, HDSP_resetPointer, 0);
}
-static inline void hdsp_start_audio(hdsp_t *s)
+static void hdsp_start_audio(struct hdsp *s)
{
s->control_register |= (HDSP_AudioInterruptEnable | HDSP_Start);
hdsp_write(s, HDSP_controlRegister, s->control_register);
}
-static inline void hdsp_stop_audio(hdsp_t *s)
+static void hdsp_stop_audio(struct hdsp *s)
{
s->control_register &= ~(HDSP_Start | HDSP_AudioInterruptEnable);
hdsp_write(s, HDSP_controlRegister, s->control_register);
}
-static inline void hdsp_silence_playback(hdsp_t *hdsp)
+static void hdsp_silence_playback(struct hdsp *hdsp)
{
memset(hdsp->playback_buffer, 0, HDSP_DMA_AREA_BYTES);
}
-static int hdsp_set_interrupt_interval(hdsp_t *s, unsigned int frames)
+static int hdsp_set_interrupt_interval(struct hdsp *s, unsigned int frames)
{
int n;
return 0;
}
-static int hdsp_set_rate(hdsp_t *hdsp, int rate, int called_internally)
+static int hdsp_set_rate(struct hdsp *hdsp, int rate, int called_internally)
{
int reject_if_open = 0;
int current_rate;
if (!(hdsp->control_register & HDSP_ClockModeMaster)) {
if (called_internally) {
/* request from ctl or card initialization */
- snd_printk("device is not running as a clock master: cannot set sample rate.\n");
+ snd_printk(KERN_ERR "Hammerfall-DSP: device is not running as a clock master: cannot set sample rate.\n");
return -1;
} else {
/* hw_param request while in AutoSync mode */
int external_freq = hdsp_external_sample_rate(hdsp);
int spdif_freq = hdsp_spdif_sample_rate(hdsp);
- if ((spdif_freq == external_freq*2) && (hdsp_autosync_ref(hdsp) >= HDSP_AUTOSYNC_FROM_ADAT1)) {
- snd_printk("Detected ADAT in double speed mode\n");
- } else if (hdsp->io_type == H9632 && (spdif_freq == external_freq*4) && (hdsp_autosync_ref(hdsp) >= HDSP_AUTOSYNC_FROM_ADAT1)) {
- snd_printk("Detected ADAT in quad speed mode\n");
- } else if (rate != external_freq) {
- snd_printk("No AutoSync source for requested rate\n");
+ if ((spdif_freq == external_freq*2) && (hdsp_autosync_ref(hdsp) >= HDSP_AUTOSYNC_FROM_ADAT1))
+ snd_printk(KERN_INFO "Hammerfall-DSP: Detected ADAT in double speed mode\n");
+ else if (hdsp->io_type == H9632 && (spdif_freq == external_freq*4) && (hdsp_autosync_ref(hdsp) >= HDSP_AUTOSYNC_FROM_ADAT1))
+ snd_printk(KERN_INFO "Hammerfall-DSP: Detected ADAT in quad speed mode\n");
+ else if (rate != external_freq) {
+ snd_printk(KERN_INFO "Hammerfall-DSP: No AutoSync source for requested rate\n");
return -1;
}
}
exists for externally-driven rate changes. All we can do
is to flag rate changes in the read/write routines. */
- if (rate > 96000 && hdsp->io_type != H9632) {
+ if (rate > 96000 && hdsp->io_type != H9632)
return -EINVAL;
- }
switch (rate) {
case 32000:
- if (current_rate > 48000) {
+ if (current_rate > 48000)
reject_if_open = 1;
- }
rate_bits = HDSP_Frequency32KHz;
break;
case 44100:
- if (current_rate > 48000) {
+ if (current_rate > 48000)
reject_if_open = 1;
- }
rate_bits = HDSP_Frequency44_1KHz;
break;
case 48000:
- if (current_rate > 48000) {
+ if (current_rate > 48000)
reject_if_open = 1;
- }
rate_bits = HDSP_Frequency48KHz;
break;
case 64000:
- if (current_rate <= 48000 || current_rate > 96000) {
+ if (current_rate <= 48000 || current_rate > 96000)
reject_if_open = 1;
- }
rate_bits = HDSP_Frequency64KHz;
break;
case 88200:
- if (current_rate <= 48000 || current_rate > 96000) {
+ if (current_rate <= 48000 || current_rate > 96000)
reject_if_open = 1;
- }
rate_bits = HDSP_Frequency88_2KHz;
break;
case 96000:
- if (current_rate <= 48000 || current_rate > 96000) {
+ if (current_rate <= 48000 || current_rate > 96000)
reject_if_open = 1;
- }
rate_bits = HDSP_Frequency96KHz;
break;
case 128000:
- if (current_rate < 128000) {
+ if (current_rate < 128000)
reject_if_open = 1;
- }
rate_bits = HDSP_Frequency128KHz;
break;
case 176400:
- if (current_rate < 128000) {
+ if (current_rate < 128000)
reject_if_open = 1;
- }
rate_bits = HDSP_Frequency176_4KHz;
break;
case 192000:
- if (current_rate < 128000) {
+ if (current_rate < 128000)
reject_if_open = 1;
- }
rate_bits = HDSP_Frequency192KHz;
break;
default:
}
if (reject_if_open && (hdsp->capture_pid >= 0 || hdsp->playback_pid >= 0)) {
- snd_printk ("cannot change speed mode (capture PID = %d, playback PID = %d)\n",
+ snd_printk ("Hammerfall-DSP: cannot change speed mode (capture PID = %d, playback PID = %d)\n",
hdsp->capture_pid,
hdsp->playback_pid);
return -EBUSY;
if (rate >= 128000) {
hdsp->channel_map = channel_map_H9632_qs;
} else if (rate > 48000) {
- if (hdsp->io_type == H9632) {
+ if (hdsp->io_type == H9632)
hdsp->channel_map = channel_map_H9632_ds;
- } else {
+ else
hdsp->channel_map = channel_map_ds;
- }
} else {
switch (hdsp->io_type) {
case Multiface:
return 0;
}
-static void hdsp_set_thru(hdsp_t *hdsp, int channel, int enable)
-{
-
- hdsp->passthru = 0;
-
- if (channel < 0) {
-
- int i;
-
- /* set thru for all channels */
-
- if (enable) {
- for (i = 0; i < hdsp->max_channels; i++) {
- hdsp_write_gain (hdsp, hdsp_input_to_output_key(hdsp,i,i), UNITY_GAIN);
- }
- } else {
- for (i = 0; i < hdsp->max_channels; i++) {
- hdsp_write_gain (hdsp, hdsp_input_to_output_key(hdsp,i,i), MINUS_INFINITY_GAIN);
- }
- }
-
- } else {
- int mapped_channel;
-
- snd_assert(channel < hdsp->max_channels, return);
-
- mapped_channel = hdsp->channel_map[channel];
-
- snd_assert(mapped_channel > -1, return);
-
- if (enable) {
- hdsp_write_gain (hdsp, hdsp_input_to_output_key(hdsp,mapped_channel,mapped_channel), UNITY_GAIN);
- } else {
- hdsp_write_gain (hdsp, hdsp_input_to_output_key(hdsp,mapped_channel,mapped_channel), MINUS_INFINITY_GAIN);
- }
- }
-}
-
-static int hdsp_set_passthru(hdsp_t *hdsp, int onoff)
-{
- if (onoff) {
- hdsp_set_thru(hdsp, -1, 1);
- hdsp_reset_hw_pointer(hdsp);
- hdsp_silence_playback(hdsp);
-
- /* we don't want interrupts, so do a
- custom version of hdsp_start_audio().
- */
-
- hdsp->control_register |= (HDSP_Start|HDSP_AudioInterruptEnable|hdsp_encode_latency(7));
-
- hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register);
- hdsp->passthru = 1;
- } else {
- hdsp_set_thru(hdsp, -1, 0);
- hdsp_stop_audio(hdsp);
- hdsp->passthru = 0;
- }
-
- return 0;
-}
-
/*----------------------------------------------------------------------------
MIDI
----------------------------------------------------------------------------*/
-static inline unsigned char snd_hdsp_midi_read_byte (hdsp_t *hdsp, int id)
+static unsigned char snd_hdsp_midi_read_byte (struct hdsp *hdsp, int id)
{
/* the hardware already does the relevant bit-mask with 0xff */
- if (id) {
+ if (id)
return hdsp_read(hdsp, HDSP_midiDataIn1);
- } else {
+ else
return hdsp_read(hdsp, HDSP_midiDataIn0);
- }
}
-static inline void snd_hdsp_midi_write_byte (hdsp_t *hdsp, int id, int val)
+static void snd_hdsp_midi_write_byte (struct hdsp *hdsp, int id, int val)
{
/* the hardware already does the relevant bit-mask with 0xff */
- if (id) {
+ if (id)
hdsp_write(hdsp, HDSP_midiDataOut1, val);
- } else {
+ else
hdsp_write(hdsp, HDSP_midiDataOut0, val);
- }
}
-static inline int snd_hdsp_midi_input_available (hdsp_t *hdsp, int id)
+static int snd_hdsp_midi_input_available (struct hdsp *hdsp, int id)
{
- if (id) {
+ if (id)
return (hdsp_read(hdsp, HDSP_midiStatusIn1) & 0xff);
- } else {
+ else
return (hdsp_read(hdsp, HDSP_midiStatusIn0) & 0xff);
- }
}
-static inline int snd_hdsp_midi_output_possible (hdsp_t *hdsp, int id)
+static int snd_hdsp_midi_output_possible (struct hdsp *hdsp, int id)
{
int fifo_bytes_used;
- if (id) {
+ if (id)
fifo_bytes_used = hdsp_read(hdsp, HDSP_midiStatusOut1) & 0xff;
- } else {
+ else
fifo_bytes_used = hdsp_read(hdsp, HDSP_midiStatusOut0) & 0xff;
- }
- if (fifo_bytes_used < 128) {
+ if (fifo_bytes_used < 128)
return 128 - fifo_bytes_used;
- } else {
+ else
return 0;
- }
}
-static inline void snd_hdsp_flush_midi_input (hdsp_t *hdsp, int id)
+static void snd_hdsp_flush_midi_input (struct hdsp *hdsp, int id)
{
- while (snd_hdsp_midi_input_available (hdsp, id)) {
+ while (snd_hdsp_midi_input_available (hdsp, id))
snd_hdsp_midi_read_byte (hdsp, id);
- }
}
-static int snd_hdsp_midi_output_write (hdsp_midi_t *hmidi)
+static int snd_hdsp_midi_output_write (struct hdsp_midi *hmidi)
{
unsigned long flags;
int n_pending;
return 0;
}
-static int snd_hdsp_midi_input_read (hdsp_midi_t *hmidi)
+static int snd_hdsp_midi_input_read (struct hdsp_midi *hmidi)
{
unsigned char buf[128]; /* this buffer is designed to match the MIDI input FIFO size */
unsigned long flags;
spin_lock_irqsave (&hmidi->lock, flags);
if ((n_pending = snd_hdsp_midi_input_available (hmidi->hdsp, hmidi->id)) > 0) {
if (hmidi->input) {
- if (n_pending > (int)sizeof (buf)) {
+ if (n_pending > (int)sizeof (buf))
n_pending = sizeof (buf);
- }
- for (i = 0; i < n_pending; ++i) {
+ for (i = 0; i < n_pending; ++i)
buf[i] = snd_hdsp_midi_read_byte (hmidi->hdsp, hmidi->id);
- }
- if (n_pending) {
+ if (n_pending)
snd_rawmidi_receive (hmidi->input, buf, n_pending);
- }
} else {
/* flush the MIDI input FIFO */
- while (--n_pending) {
+ while (--n_pending)
snd_hdsp_midi_read_byte (hmidi->hdsp, hmidi->id);
- }
}
}
hmidi->pending = 0;
- if (hmidi->id) {
+ if (hmidi->id)
hmidi->hdsp->control_register |= HDSP_Midi1InterruptEnable;
- } else {
+ else
hmidi->hdsp->control_register |= HDSP_Midi0InterruptEnable;
- }
hdsp_write(hmidi->hdsp, HDSP_controlRegister, hmidi->hdsp->control_register);
spin_unlock_irqrestore (&hmidi->lock, flags);
return snd_hdsp_midi_output_write (hmidi);
}
-static void snd_hdsp_midi_input_trigger(snd_rawmidi_substream_t * substream, int up)
+static void snd_hdsp_midi_input_trigger(struct snd_rawmidi_substream *substream, int up)
{
- hdsp_t *hdsp;
- hdsp_midi_t *hmidi;
+ struct hdsp *hdsp;
+ struct hdsp_midi *hmidi;
unsigned long flags;
u32 ie;
- hmidi = (hdsp_midi_t *) substream->rmidi->private_data;
+ hmidi = (struct hdsp_midi *) substream->rmidi->private_data;
hdsp = hmidi->hdsp;
ie = hmidi->id ? HDSP_Midi1InterruptEnable : HDSP_Midi0InterruptEnable;
spin_lock_irqsave (&hdsp->lock, flags);
}
} else {
hdsp->control_register &= ~ie;
+ tasklet_kill(&hdsp->midi_tasklet);
}
hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register);
static void snd_hdsp_midi_output_timer(unsigned long data)
{
- hdsp_midi_t *hmidi = (hdsp_midi_t *) data;
+ struct hdsp_midi *hmidi = (struct hdsp_midi *) data;
unsigned long flags;
snd_hdsp_midi_output_write(hmidi);
spin_unlock_irqrestore (&hmidi->lock, flags);
}
-static void snd_hdsp_midi_output_trigger(snd_rawmidi_substream_t * substream, int up)
+static void snd_hdsp_midi_output_trigger(struct snd_rawmidi_substream *substream, int up)
{
- hdsp_midi_t *hmidi;
+ struct hdsp_midi *hmidi;
unsigned long flags;
- hmidi = (hdsp_midi_t *) substream->rmidi->private_data;
+ hmidi = (struct hdsp_midi *) substream->rmidi->private_data;
spin_lock_irqsave (&hmidi->lock, flags);
if (up) {
if (!hmidi->istimer) {
hmidi->istimer++;
}
} else {
- if (hmidi->istimer && --hmidi->istimer <= 0) {
+ if (hmidi->istimer && --hmidi->istimer <= 0)
del_timer (&hmidi->timer);
- }
}
spin_unlock_irqrestore (&hmidi->lock, flags);
if (up)
snd_hdsp_midi_output_write(hmidi);
}
-static int snd_hdsp_midi_input_open(snd_rawmidi_substream_t * substream)
+static int snd_hdsp_midi_input_open(struct snd_rawmidi_substream *substream)
{
- hdsp_midi_t *hmidi;
- unsigned long flags;
+ struct hdsp_midi *hmidi;
- hmidi = (hdsp_midi_t *) substream->rmidi->private_data;
- spin_lock_irqsave (&hmidi->lock, flags);
+ hmidi = (struct hdsp_midi *) substream->rmidi->private_data;
+ spin_lock_irq (&hmidi->lock);
snd_hdsp_flush_midi_input (hmidi->hdsp, hmidi->id);
hmidi->input = substream;
- spin_unlock_irqrestore (&hmidi->lock, flags);
+ spin_unlock_irq (&hmidi->lock);
return 0;
}
-static int snd_hdsp_midi_output_open(snd_rawmidi_substream_t * substream)
+static int snd_hdsp_midi_output_open(struct snd_rawmidi_substream *substream)
{
- hdsp_midi_t *hmidi;
- unsigned long flags;
+ struct hdsp_midi *hmidi;
- hmidi = (hdsp_midi_t *) substream->rmidi->private_data;
- spin_lock_irqsave (&hmidi->lock, flags);
+ hmidi = (struct hdsp_midi *) substream->rmidi->private_data;
+ spin_lock_irq (&hmidi->lock);
hmidi->output = substream;
- spin_unlock_irqrestore (&hmidi->lock, flags);
+ spin_unlock_irq (&hmidi->lock);
return 0;
}
-static int snd_hdsp_midi_input_close(snd_rawmidi_substream_t * substream)
+static int snd_hdsp_midi_input_close(struct snd_rawmidi_substream *substream)
{
- hdsp_midi_t *hmidi;
- unsigned long flags;
+ struct hdsp_midi *hmidi;
snd_hdsp_midi_input_trigger (substream, 0);
- hmidi = (hdsp_midi_t *) substream->rmidi->private_data;
- spin_lock_irqsave (&hmidi->lock, flags);
+ hmidi = (struct hdsp_midi *) substream->rmidi->private_data;
+ spin_lock_irq (&hmidi->lock);
hmidi->input = NULL;
- spin_unlock_irqrestore (&hmidi->lock, flags);
+ spin_unlock_irq (&hmidi->lock);
return 0;
}
-static int snd_hdsp_midi_output_close(snd_rawmidi_substream_t * substream)
+static int snd_hdsp_midi_output_close(struct snd_rawmidi_substream *substream)
{
- hdsp_midi_t *hmidi;
- unsigned long flags;
+ struct hdsp_midi *hmidi;
snd_hdsp_midi_output_trigger (substream, 0);
- hmidi = (hdsp_midi_t *) substream->rmidi->private_data;
- spin_lock_irqsave (&hmidi->lock, flags);
+ hmidi = (struct hdsp_midi *) substream->rmidi->private_data;
+ spin_lock_irq (&hmidi->lock);
hmidi->output = NULL;
- spin_unlock_irqrestore (&hmidi->lock, flags);
+ spin_unlock_irq (&hmidi->lock);
return 0;
}
-snd_rawmidi_ops_t snd_hdsp_midi_output =
+static struct snd_rawmidi_ops snd_hdsp_midi_output =
{
.open = snd_hdsp_midi_output_open,
.close = snd_hdsp_midi_output_close,
.trigger = snd_hdsp_midi_output_trigger,
};
-snd_rawmidi_ops_t snd_hdsp_midi_input =
+static struct snd_rawmidi_ops snd_hdsp_midi_input =
{
.open = snd_hdsp_midi_input_open,
.close = snd_hdsp_midi_input_close,
.trigger = snd_hdsp_midi_input_trigger,
};
-static int __devinit snd_hdsp_create_midi (snd_card_t *card, hdsp_t *hdsp, int id)
+static int __devinit snd_hdsp_create_midi (struct snd_card *card, struct hdsp *hdsp, int id)
{
char buf[32];
spin_lock_init (&hdsp->midi[id].lock);
sprintf (buf, "%s MIDI %d", card->shortname, id+1);
- if (snd_rawmidi_new (card, buf, id, 1, 1, &hdsp->midi[id].rmidi) < 0) {
+ if (snd_rawmidi_new (card, buf, id, 1, 1, &hdsp->midi[id].rmidi) < 0)
return -1;
- }
sprintf (hdsp->midi[id].rmidi->name, "%s MIDI %d", card->id, id+1);
hdsp->midi[id].rmidi->private_data = &hdsp->midi[id];
Control Interface
----------------------------------------------------------------------------*/
-static u32 snd_hdsp_convert_from_aes(snd_aes_iec958_t *aes)
+static u32 snd_hdsp_convert_from_aes(struct snd_aes_iec958 *aes)
{
u32 val = 0;
val |= (aes->status[0] & IEC958_AES0_PROFESSIONAL) ? HDSP_SPDIFProfessional : 0;
return val;
}
-static void snd_hdsp_convert_to_aes(snd_aes_iec958_t *aes, u32 val)
+static void snd_hdsp_convert_to_aes(struct snd_aes_iec958 *aes, u32 val)
{
aes->status[0] = ((val & HDSP_SPDIFProfessional) ? IEC958_AES0_PROFESSIONAL : 0) |
((val & HDSP_SPDIFNonAudio) ? IEC958_AES0_NONAUDIO : 0);
aes->status[0] |= (val & HDSP_SPDIFEmphasis) ? IEC958_AES0_CON_EMPHASIS_5015 : 0;
}
-static int snd_hdsp_control_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_hdsp_control_spdif_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
{
uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958;
uinfo->count = 1;
return 0;
}
-static int snd_hdsp_control_spdif_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_control_spdif_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
- hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
+ struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
snd_hdsp_convert_to_aes(&ucontrol->value.iec958, hdsp->creg_spdif);
return 0;
}
-static int snd_hdsp_control_spdif_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_control_spdif_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
- hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
- unsigned long flags;
+ struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
int change;
u32 val;
val = snd_hdsp_convert_from_aes(&ucontrol->value.iec958);
- spin_lock_irqsave(&hdsp->lock, flags);
+ spin_lock_irq(&hdsp->lock);
change = val != hdsp->creg_spdif;
hdsp->creg_spdif = val;
- spin_unlock_irqrestore(&hdsp->lock, flags);
+ spin_unlock_irq(&hdsp->lock);
return change;
}
-static int snd_hdsp_control_spdif_stream_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_hdsp_control_spdif_stream_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
{
uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958;
uinfo->count = 1;
return 0;
}
-static int snd_hdsp_control_spdif_stream_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_control_spdif_stream_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
- hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
+ struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
snd_hdsp_convert_to_aes(&ucontrol->value.iec958, hdsp->creg_spdif_stream);
return 0;
}
-static int snd_hdsp_control_spdif_stream_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_control_spdif_stream_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
- hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
- unsigned long flags;
+ struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
int change;
u32 val;
val = snd_hdsp_convert_from_aes(&ucontrol->value.iec958);
- spin_lock_irqsave(&hdsp->lock, flags);
+ spin_lock_irq(&hdsp->lock);
change = val != hdsp->creg_spdif_stream;
hdsp->creg_spdif_stream = val;
hdsp->control_register &= ~(HDSP_SPDIFProfessional | HDSP_SPDIFNonAudio | HDSP_SPDIFEmphasis);
hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register |= val);
- spin_unlock_irqrestore(&hdsp->lock, flags);
+ spin_unlock_irq(&hdsp->lock);
return change;
}
-static int snd_hdsp_control_spdif_mask_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_hdsp_control_spdif_mask_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
{
uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958;
uinfo->count = 1;
return 0;
}
-static int snd_hdsp_control_spdif_mask_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_control_spdif_mask_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
ucontrol->value.iec958.status[0] = kcontrol->private_value;
return 0;
}
#define HDSP_SPDIF_IN(xname, xindex) \
-{ .iface = SNDRV_CTL_ELEM_IFACE_PCM, \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
.name = xname, \
.index = xindex, \
.info = snd_hdsp_info_spdif_in, \
.get = snd_hdsp_get_spdif_in, \
.put = snd_hdsp_put_spdif_in }
-static unsigned int hdsp_spdif_in(hdsp_t *hdsp)
+static unsigned int hdsp_spdif_in(struct hdsp *hdsp)
{
return hdsp_decode_spdif_in(hdsp->control_register & HDSP_SPDIFInputMask);
}
-static int hdsp_set_spdif_input(hdsp_t *hdsp, int in)
+static int hdsp_set_spdif_input(struct hdsp *hdsp, int in)
{
hdsp->control_register &= ~HDSP_SPDIFInputMask;
hdsp->control_register |= hdsp_encode_spdif_in(in);
return 0;
}
-static int snd_hdsp_info_spdif_in(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_hdsp_info_spdif_in(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
{
static char *texts[4] = {"Optical", "Coaxial", "Internal", "AES"};
- hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
+ struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
uinfo->count = 1;
return 0;
}
-static int snd_hdsp_get_spdif_in(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_get_spdif_in(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
- hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
+ struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
ucontrol->value.enumerated.item[0] = hdsp_spdif_in(hdsp);
return 0;
}
-static int snd_hdsp_put_spdif_in(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_put_spdif_in(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
- hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
- unsigned long flags;
+ struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
int change;
unsigned int val;
if (!snd_hdsp_use_is_exclusive(hdsp))
return -EBUSY;
val = ucontrol->value.enumerated.item[0] % ((hdsp->io_type == H9632) ? 4 : 3);
- spin_lock_irqsave(&hdsp->lock, flags);
+ spin_lock_irq(&hdsp->lock);
change = val != hdsp_spdif_in(hdsp);
if (change)
hdsp_set_spdif_input(hdsp, val);
- spin_unlock_irqrestore(&hdsp->lock, flags);
+ spin_unlock_irq(&hdsp->lock);
return change;
}
#define HDSP_SPDIF_OUT(xname, xindex) \
-{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, .name = xname, .index = xindex, \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
.info = snd_hdsp_info_spdif_bits, \
.get = snd_hdsp_get_spdif_out, .put = snd_hdsp_put_spdif_out }
-static int hdsp_spdif_out(hdsp_t *hdsp)
+static int hdsp_spdif_out(struct hdsp *hdsp)
{
return (hdsp->control_register & HDSP_SPDIFOpticalOut) ? 1 : 0;
}
-static int hdsp_set_spdif_output(hdsp_t *hdsp, int out)
+static int hdsp_set_spdif_output(struct hdsp *hdsp, int out)
{
- if (out) {
+ if (out)
hdsp->control_register |= HDSP_SPDIFOpticalOut;
- } else {
+ else
hdsp->control_register &= ~HDSP_SPDIFOpticalOut;
- }
hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register);
return 0;
}
-static int snd_hdsp_info_spdif_bits(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_hdsp_info_spdif_bits(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
{
uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
uinfo->count = 1;
return 0;
}
-static int snd_hdsp_get_spdif_out(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_get_spdif_out(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
- hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
+ struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
ucontrol->value.integer.value[0] = hdsp_spdif_out(hdsp);
return 0;
}
-static int snd_hdsp_put_spdif_out(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_put_spdif_out(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
- hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
- unsigned long flags;
+ struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
int change;
unsigned int val;
if (!snd_hdsp_use_is_exclusive(hdsp))
return -EBUSY;
val = ucontrol->value.integer.value[0] & 1;
- spin_lock_irqsave(&hdsp->lock, flags);
+ spin_lock_irq(&hdsp->lock);
change = (int)val != hdsp_spdif_out(hdsp);
hdsp_set_spdif_output(hdsp, val);
- spin_unlock_irqrestore(&hdsp->lock, flags);
+ spin_unlock_irq(&hdsp->lock);
return change;
}
#define HDSP_SPDIF_PROFESSIONAL(xname, xindex) \
-{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, .name = xname, .index = xindex, \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
.info = snd_hdsp_info_spdif_bits, \
.get = snd_hdsp_get_spdif_professional, .put = snd_hdsp_put_spdif_professional }
-static int hdsp_spdif_professional(hdsp_t *hdsp)
+static int hdsp_spdif_professional(struct hdsp *hdsp)
{
return (hdsp->control_register & HDSP_SPDIFProfessional) ? 1 : 0;
}
-static int hdsp_set_spdif_professional(hdsp_t *hdsp, int val)
+static int hdsp_set_spdif_professional(struct hdsp *hdsp, int val)
{
- if (val) {
+ if (val)
hdsp->control_register |= HDSP_SPDIFProfessional;
- } else {
+ else
hdsp->control_register &= ~HDSP_SPDIFProfessional;
- }
hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register);
return 0;
}
-static int snd_hdsp_get_spdif_professional(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_get_spdif_professional(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
- hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
+ struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
ucontrol->value.integer.value[0] = hdsp_spdif_professional(hdsp);
return 0;
}
-static int snd_hdsp_put_spdif_professional(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_put_spdif_professional(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
- hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
- unsigned long flags;
+ struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
int change;
unsigned int val;
if (!snd_hdsp_use_is_exclusive(hdsp))
return -EBUSY;
val = ucontrol->value.integer.value[0] & 1;
- spin_lock_irqsave(&hdsp->lock, flags);
+ spin_lock_irq(&hdsp->lock);
change = (int)val != hdsp_spdif_professional(hdsp);
hdsp_set_spdif_professional(hdsp, val);
- spin_unlock_irqrestore(&hdsp->lock, flags);
+ spin_unlock_irq(&hdsp->lock);
return change;
}
#define HDSP_SPDIF_EMPHASIS(xname, xindex) \
-{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, .name = xname, .index = xindex, \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
.info = snd_hdsp_info_spdif_bits, \
.get = snd_hdsp_get_spdif_emphasis, .put = snd_hdsp_put_spdif_emphasis }
-static int hdsp_spdif_emphasis(hdsp_t *hdsp)
+static int hdsp_spdif_emphasis(struct hdsp *hdsp)
{
return (hdsp->control_register & HDSP_SPDIFEmphasis) ? 1 : 0;
}
-static int hdsp_set_spdif_emphasis(hdsp_t *hdsp, int val)
+static int hdsp_set_spdif_emphasis(struct hdsp *hdsp, int val)
{
- if (val) {
+ if (val)
hdsp->control_register |= HDSP_SPDIFEmphasis;
- } else {
+ else
hdsp->control_register &= ~HDSP_SPDIFEmphasis;
- }
hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register);
return 0;
}
-static int snd_hdsp_get_spdif_emphasis(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_get_spdif_emphasis(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
- hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
+ struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
ucontrol->value.integer.value[0] = hdsp_spdif_emphasis(hdsp);
return 0;
}
-static int snd_hdsp_put_spdif_emphasis(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_put_spdif_emphasis(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
- hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
- unsigned long flags;
+ struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
int change;
unsigned int val;
if (!snd_hdsp_use_is_exclusive(hdsp))
return -EBUSY;
val = ucontrol->value.integer.value[0] & 1;
- spin_lock_irqsave(&hdsp->lock, flags);
+ spin_lock_irq(&hdsp->lock);
change = (int)val != hdsp_spdif_emphasis(hdsp);
hdsp_set_spdif_emphasis(hdsp, val);
- spin_unlock_irqrestore(&hdsp->lock, flags);
+ spin_unlock_irq(&hdsp->lock);
return change;
}
#define HDSP_SPDIF_NON_AUDIO(xname, xindex) \
-{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, .name = xname, .index = xindex, \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
.info = snd_hdsp_info_spdif_bits, \
.get = snd_hdsp_get_spdif_nonaudio, .put = snd_hdsp_put_spdif_nonaudio }
-static int hdsp_spdif_nonaudio(hdsp_t *hdsp)
+static int hdsp_spdif_nonaudio(struct hdsp *hdsp)
{
return (hdsp->control_register & HDSP_SPDIFNonAudio) ? 1 : 0;
}
-static int hdsp_set_spdif_nonaudio(hdsp_t *hdsp, int val)
+static int hdsp_set_spdif_nonaudio(struct hdsp *hdsp, int val)
{
- if (val) {
+ if (val)
hdsp->control_register |= HDSP_SPDIFNonAudio;
- } else {
+ else
hdsp->control_register &= ~HDSP_SPDIFNonAudio;
- }
hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register);
return 0;
}
-static int snd_hdsp_get_spdif_nonaudio(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_get_spdif_nonaudio(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
- hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
+ struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
ucontrol->value.integer.value[0] = hdsp_spdif_nonaudio(hdsp);
return 0;
}
-static int snd_hdsp_put_spdif_nonaudio(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_put_spdif_nonaudio(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
- hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
- unsigned long flags;
+ struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
int change;
unsigned int val;
if (!snd_hdsp_use_is_exclusive(hdsp))
return -EBUSY;
val = ucontrol->value.integer.value[0] & 1;
- spin_lock_irqsave(&hdsp->lock, flags);
+ spin_lock_irq(&hdsp->lock);
change = (int)val != hdsp_spdif_nonaudio(hdsp);
hdsp_set_spdif_nonaudio(hdsp, val);
- spin_unlock_irqrestore(&hdsp->lock, flags);
+ spin_unlock_irq(&hdsp->lock);
return change;
}
#define HDSP_SPDIF_SAMPLE_RATE(xname, xindex) \
-{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
.name = xname, \
.index = xindex, \
.access = SNDRV_CTL_ELEM_ACCESS_READ, \
.get = snd_hdsp_get_spdif_sample_rate \
}
-static int snd_hdsp_info_spdif_sample_rate(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_hdsp_info_spdif_sample_rate(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
{
static char *texts[] = {"32000", "44100", "48000", "64000", "88200", "96000", "None", "128000", "176400", "192000"};
- hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
+ struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
uinfo->count = 1;
return 0;
}
-static int snd_hdsp_get_spdif_sample_rate(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_get_spdif_sample_rate(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
- hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
+ struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
switch (hdsp_spdif_sample_rate(hdsp)) {
case 32000:
}
#define HDSP_SYSTEM_SAMPLE_RATE(xname, xindex) \
-{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
.name = xname, \
.index = xindex, \
.access = SNDRV_CTL_ELEM_ACCESS_READ, \
.get = snd_hdsp_get_system_sample_rate \
}
-static int snd_hdsp_info_system_sample_rate(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_hdsp_info_system_sample_rate(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
{
uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
uinfo->count = 1;
return 0;
}
-static int snd_hdsp_get_system_sample_rate(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_get_system_sample_rate(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
- hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
+ struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
ucontrol->value.enumerated.item[0] = hdsp->system_sample_rate;
return 0;
}
#define HDSP_AUTOSYNC_SAMPLE_RATE(xname, xindex) \
-{ .iface = SNDRV_CTL_ELEM_IFACE_PCM, \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
.name = xname, \
.index = xindex, \
.access = SNDRV_CTL_ELEM_ACCESS_READ, \
.get = snd_hdsp_get_autosync_sample_rate \
}
-static int snd_hdsp_info_autosync_sample_rate(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_hdsp_info_autosync_sample_rate(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
{
- hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
+ struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
static char *texts[] = {"32000", "44100", "48000", "64000", "88200", "96000", "None", "128000", "176400", "192000"};
uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
uinfo->count = 1;
return 0;
}
-static int snd_hdsp_get_autosync_sample_rate(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_get_autosync_sample_rate(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
- hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
+ struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
switch (hdsp_external_sample_rate(hdsp)) {
case 32000:
}
#define HDSP_SYSTEM_CLOCK_MODE(xname, xindex) \
-{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
.name = xname, \
.index = xindex, \
.access = SNDRV_CTL_ELEM_ACCESS_READ, \
.get = snd_hdsp_get_system_clock_mode \
}
-static int hdsp_system_clock_mode(hdsp_t *hdsp)
+static int hdsp_system_clock_mode(struct hdsp *hdsp)
{
- if (hdsp->control_register & HDSP_ClockModeMaster) {
+ if (hdsp->control_register & HDSP_ClockModeMaster)
return 0;
- } else if (hdsp_external_sample_rate(hdsp) != hdsp->system_sample_rate) {
+ else if (hdsp_external_sample_rate(hdsp) != hdsp->system_sample_rate)
return 0;
- }
return 1;
}
-static int snd_hdsp_info_system_clock_mode(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_hdsp_info_system_clock_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
{
static char *texts[] = {"Master", "Slave" };
return 0;
}
-static int snd_hdsp_get_system_clock_mode(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_get_system_clock_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
- hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
+ struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
ucontrol->value.enumerated.item[0] = hdsp_system_clock_mode(hdsp);
return 0;
}
#define HDSP_CLOCK_SOURCE(xname, xindex) \
-{ .iface = SNDRV_CTL_ELEM_IFACE_PCM, \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
.name = xname, \
.index = xindex, \
.info = snd_hdsp_info_clock_source, \
.put = snd_hdsp_put_clock_source \
}
-static int hdsp_clock_source(hdsp_t *hdsp)
+static int hdsp_clock_source(struct hdsp *hdsp)
{
if (hdsp->control_register & HDSP_ClockModeMaster) {
switch (hdsp->system_sample_rate) {
}
}
-static int hdsp_set_clock_source(hdsp_t *hdsp, int mode)
+static int hdsp_set_clock_source(struct hdsp *hdsp, int mode)
{
int rate;
switch (mode) {
return 0;
}
-static int snd_hdsp_info_clock_source(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_hdsp_info_clock_source(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
{
static char *texts[] = {"AutoSync", "Internal 32.0 kHz", "Internal 44.1 kHz", "Internal 48.0 kHz", "Internal 64.0 kHz", "Internal 88.2 kHz", "Internal 96.0 kHz", "Internal 128 kHz", "Internal 176.4 kHz", "Internal 192.0 KHz" };
- hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
+ struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
uinfo->count = 1;
return 0;
}
-static int snd_hdsp_get_clock_source(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_get_clock_source(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
- hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
+ struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
ucontrol->value.enumerated.item[0] = hdsp_clock_source(hdsp);
return 0;
}
-static int snd_hdsp_put_clock_source(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_put_clock_source(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
- hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
- unsigned long flags;
+ struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
int change;
int val;
val = ucontrol->value.enumerated.item[0];
if (val < 0) val = 0;
if (hdsp->io_type == H9632) {
- if (val > 9) val = 9;
+ if (val > 9)
+ val = 9;
} else {
- if (val > 6) val = 6;
+ if (val > 6)
+ val = 6;
}
- spin_lock_irqsave(&hdsp->lock, flags);
- if (val != hdsp_clock_source(hdsp)) {
+ spin_lock_irq(&hdsp->lock);
+ if (val != hdsp_clock_source(hdsp))
change = (hdsp_set_clock_source(hdsp, val) == 0) ? 1 : 0;
- } else {
+ else
change = 0;
- }
- spin_unlock_irqrestore(&hdsp->lock, flags);
+ spin_unlock_irq(&hdsp->lock);
+ return change;
+}
+
+static int snd_hdsp_info_clock_source_lock(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
+{
+ uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
+ uinfo->count = 1;
+ uinfo->value.integer.min = 0;
+ uinfo->value.integer.max = 1;
+ return 0;
+}
+
+static int snd_hdsp_get_clock_source_lock(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
+{
+ struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
+
+ ucontrol->value.integer.value[0] = hdsp->clock_source_locked;
+ return 0;
+}
+
+static int snd_hdsp_put_clock_source_lock(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
+{
+ struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
+ int change;
+
+ change = (int)ucontrol->value.integer.value[0] != hdsp->clock_source_locked;
+ if (change)
+ hdsp->clock_source_locked = ucontrol->value.integer.value[0];
return change;
}
#define HDSP_DA_GAIN(xname, xindex) \
-{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
.name = xname, \
.index = xindex, \
.info = snd_hdsp_info_da_gain, \
.put = snd_hdsp_put_da_gain \
}
-static int hdsp_da_gain(hdsp_t *hdsp)
+static int hdsp_da_gain(struct hdsp *hdsp)
{
switch (hdsp->control_register & HDSP_DAGainMask) {
case HDSP_DAGainHighGain:
}
}
-static int hdsp_set_da_gain(hdsp_t *hdsp, int mode)
+static int hdsp_set_da_gain(struct hdsp *hdsp, int mode)
{
hdsp->control_register &= ~HDSP_DAGainMask;
switch (mode) {
return 0;
}
-static int snd_hdsp_info_da_gain(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_hdsp_info_da_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
{
static char *texts[] = {"Hi Gain", "+4 dBu", "-10 dbV"};
return 0;
}
-static int snd_hdsp_get_da_gain(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_get_da_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
- hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
+ struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
ucontrol->value.enumerated.item[0] = hdsp_da_gain(hdsp);
return 0;
}
-static int snd_hdsp_put_da_gain(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_put_da_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
- hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
- unsigned long flags;
+ struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
int change;
int val;
val = ucontrol->value.enumerated.item[0];
if (val < 0) val = 0;
if (val > 2) val = 2;
- spin_lock_irqsave(&hdsp->lock, flags);
- if (val != hdsp_da_gain(hdsp)) {
+ spin_lock_irq(&hdsp->lock);
+ if (val != hdsp_da_gain(hdsp))
change = (hdsp_set_da_gain(hdsp, val) == 0) ? 1 : 0;
- } else {
+ else
change = 0;
- }
- spin_unlock_irqrestore(&hdsp->lock, flags);
+ spin_unlock_irq(&hdsp->lock);
return change;
}
#define HDSP_AD_GAIN(xname, xindex) \
-{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
.name = xname, \
.index = xindex, \
.info = snd_hdsp_info_ad_gain, \
.put = snd_hdsp_put_ad_gain \
}
-static int hdsp_ad_gain(hdsp_t *hdsp)
+static int hdsp_ad_gain(struct hdsp *hdsp)
{
switch (hdsp->control_register & HDSP_ADGainMask) {
case HDSP_ADGainMinus10dBV:
}
}
-static int hdsp_set_ad_gain(hdsp_t *hdsp, int mode)
+static int hdsp_set_ad_gain(struct hdsp *hdsp, int mode)
{
hdsp->control_register &= ~HDSP_ADGainMask;
switch (mode) {
return 0;
}
-static int snd_hdsp_info_ad_gain(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_hdsp_info_ad_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
{
static char *texts[] = {"-10 dBV", "+4 dBu", "Lo Gain"};
return 0;
}
-static int snd_hdsp_get_ad_gain(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_get_ad_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
- hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
+ struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
ucontrol->value.enumerated.item[0] = hdsp_ad_gain(hdsp);
return 0;
}
-static int snd_hdsp_put_ad_gain(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_put_ad_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
- hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
- unsigned long flags;
+ struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
int change;
int val;
val = ucontrol->value.enumerated.item[0];
if (val < 0) val = 0;
if (val > 2) val = 2;
- spin_lock_irqsave(&hdsp->lock, flags);
- if (val != hdsp_ad_gain(hdsp)) {
+ spin_lock_irq(&hdsp->lock);
+ if (val != hdsp_ad_gain(hdsp))
change = (hdsp_set_ad_gain(hdsp, val) == 0) ? 1 : 0;
- } else {
+ else
change = 0;
- }
- spin_unlock_irqrestore(&hdsp->lock, flags);
+ spin_unlock_irq(&hdsp->lock);
return change;
}
#define HDSP_PHONE_GAIN(xname, xindex) \
-{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
.name = xname, \
.index = xindex, \
.info = snd_hdsp_info_phone_gain, \
.put = snd_hdsp_put_phone_gain \
}
-static int hdsp_phone_gain(hdsp_t *hdsp)
+static int hdsp_phone_gain(struct hdsp *hdsp)
{
switch (hdsp->control_register & HDSP_PhoneGainMask) {
case HDSP_PhoneGain0dB:
}
}
-static int hdsp_set_phone_gain(hdsp_t *hdsp, int mode)
+static int hdsp_set_phone_gain(struct hdsp *hdsp, int mode)
{
hdsp->control_register &= ~HDSP_PhoneGainMask;
switch (mode) {
return 0;
}
-static int snd_hdsp_info_phone_gain(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_hdsp_info_phone_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
{
static char *texts[] = {"0 dB", "-6 dB", "-12 dB"};
return 0;
}
-static int snd_hdsp_get_phone_gain(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_get_phone_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
- hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
+ struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
ucontrol->value.enumerated.item[0] = hdsp_phone_gain(hdsp);
return 0;
}
-static int snd_hdsp_put_phone_gain(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_put_phone_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
- hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
- unsigned long flags;
+ struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
int change;
int val;
val = ucontrol->value.enumerated.item[0];
if (val < 0) val = 0;
if (val > 2) val = 2;
- spin_lock_irqsave(&hdsp->lock, flags);
- if (val != hdsp_phone_gain(hdsp)) {
+ spin_lock_irq(&hdsp->lock);
+ if (val != hdsp_phone_gain(hdsp))
change = (hdsp_set_phone_gain(hdsp, val) == 0) ? 1 : 0;
- } else {
+ else
change = 0;
- }
- spin_unlock_irqrestore(&hdsp->lock, flags);
+ spin_unlock_irq(&hdsp->lock);
return change;
}
#define HDSP_XLR_BREAKOUT_CABLE(xname, xindex) \
-{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
.name = xname, \
.index = xindex, \
.info = snd_hdsp_info_xlr_breakout_cable, \
.put = snd_hdsp_put_xlr_breakout_cable \
}
-static int hdsp_xlr_breakout_cable(hdsp_t *hdsp)
+static int hdsp_xlr_breakout_cable(struct hdsp *hdsp)
{
- if (hdsp->control_register & HDSP_XLRBreakoutCable) {
+ if (hdsp->control_register & HDSP_XLRBreakoutCable)
return 1;
- }
return 0;
}
-static int hdsp_set_xlr_breakout_cable(hdsp_t *hdsp, int mode)
+static int hdsp_set_xlr_breakout_cable(struct hdsp *hdsp, int mode)
{
- if (mode) {
+ if (mode)
hdsp->control_register |= HDSP_XLRBreakoutCable;
- } else {
+ else
hdsp->control_register &= ~HDSP_XLRBreakoutCable;
- }
hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register);
return 0;
}
-static int snd_hdsp_info_xlr_breakout_cable(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_hdsp_info_xlr_breakout_cable(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
{
uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
uinfo->count = 1;
return 0;
}
-static int snd_hdsp_get_xlr_breakout_cable(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_get_xlr_breakout_cable(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
- hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
+ struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
ucontrol->value.enumerated.item[0] = hdsp_xlr_breakout_cable(hdsp);
return 0;
}
-static int snd_hdsp_put_xlr_breakout_cable(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_put_xlr_breakout_cable(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
- hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
- unsigned long flags;
+ struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
int change;
int val;
if (!snd_hdsp_use_is_exclusive(hdsp))
return -EBUSY;
val = ucontrol->value.integer.value[0] & 1;
- spin_lock_irqsave(&hdsp->lock, flags);
+ spin_lock_irq(&hdsp->lock);
change = (int)val != hdsp_xlr_breakout_cable(hdsp);
hdsp_set_xlr_breakout_cable(hdsp, val);
- spin_unlock_irqrestore(&hdsp->lock, flags);
+ spin_unlock_irq(&hdsp->lock);
return change;
}
Switching this on desactivates external ADAT
*/
#define HDSP_AEB(xname, xindex) \
-{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
.name = xname, \
.index = xindex, \
.info = snd_hdsp_info_aeb, \
.put = snd_hdsp_put_aeb \
}
-static int hdsp_aeb(hdsp_t *hdsp)
+static int hdsp_aeb(struct hdsp *hdsp)
{
- if (hdsp->control_register & HDSP_AnalogExtensionBoard) {
+ if (hdsp->control_register & HDSP_AnalogExtensionBoard)
return 1;
- }
return 0;
}
-static int hdsp_set_aeb(hdsp_t *hdsp, int mode)
+static int hdsp_set_aeb(struct hdsp *hdsp, int mode)
{
- if (mode) {
+ if (mode)
hdsp->control_register |= HDSP_AnalogExtensionBoard;
- } else {
+ else
hdsp->control_register &= ~HDSP_AnalogExtensionBoard;
- }
hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register);
return 0;
}
-static int snd_hdsp_info_aeb(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_hdsp_info_aeb(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
{
uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
uinfo->count = 1;
return 0;
}
-static int snd_hdsp_get_aeb(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_get_aeb(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
- hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
+ struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
ucontrol->value.enumerated.item[0] = hdsp_aeb(hdsp);
return 0;
}
-static int snd_hdsp_put_aeb(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_put_aeb(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
- hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
- unsigned long flags;
+ struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
int change;
int val;
if (!snd_hdsp_use_is_exclusive(hdsp))
return -EBUSY;
val = ucontrol->value.integer.value[0] & 1;
- spin_lock_irqsave(&hdsp->lock, flags);
+ spin_lock_irq(&hdsp->lock);
change = (int)val != hdsp_aeb(hdsp);
hdsp_set_aeb(hdsp, val);
- spin_unlock_irqrestore(&hdsp->lock, flags);
+ spin_unlock_irq(&hdsp->lock);
return change;
}
#define HDSP_PREF_SYNC_REF(xname, xindex) \
-{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
.name = xname, \
.index = xindex, \
.info = snd_hdsp_info_pref_sync_ref, \
.put = snd_hdsp_put_pref_sync_ref \
}
-static int hdsp_pref_sync_ref(hdsp_t *hdsp)
+static int hdsp_pref_sync_ref(struct hdsp *hdsp)
{
/* Notice that this looks at the requested sync source,
not the one actually in use.
return 0;
}
-static int hdsp_set_pref_sync_ref(hdsp_t *hdsp, int pref)
+static int hdsp_set_pref_sync_ref(struct hdsp *hdsp, int pref)
{
hdsp->control_register &= ~HDSP_SyncRefMask;
switch (pref) {
return 0;
}
-static int snd_hdsp_info_pref_sync_ref(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_hdsp_info_pref_sync_ref(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
{
static char *texts[] = {"Word", "IEC958", "ADAT1", "ADAT Sync", "ADAT2", "ADAT3" };
- hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
+ struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
uinfo->count = 1;
return 0;
}
-static int snd_hdsp_get_pref_sync_ref(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_get_pref_sync_ref(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
- hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
+ struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
ucontrol->value.enumerated.item[0] = hdsp_pref_sync_ref(hdsp);
return 0;
}
-static int snd_hdsp_put_pref_sync_ref(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_put_pref_sync_ref(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
- hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
- unsigned long flags;
+ struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
int change, max;
unsigned int val;
}
val = ucontrol->value.enumerated.item[0] % max;
- spin_lock_irqsave(&hdsp->lock, flags);
+ spin_lock_irq(&hdsp->lock);
change = (int)val != hdsp_pref_sync_ref(hdsp);
hdsp_set_pref_sync_ref(hdsp, val);
- spin_unlock_irqrestore(&hdsp->lock, flags);
+ spin_unlock_irq(&hdsp->lock);
return change;
}
#define HDSP_AUTOSYNC_REF(xname, xindex) \
-{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
.name = xname, \
.index = xindex, \
.access = SNDRV_CTL_ELEM_ACCESS_READ, \
.get = snd_hdsp_get_autosync_ref, \
}
-static int hdsp_autosync_ref(hdsp_t *hdsp)
+static int hdsp_autosync_ref(struct hdsp *hdsp)
{
/* This looks at the autosync selected sync reference */
unsigned int status2 = hdsp_read(hdsp, HDSP_status2Register);
return 0;
}
-static int snd_hdsp_info_autosync_ref(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_hdsp_info_autosync_ref(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
{
static char *texts[] = {"Word", "ADAT Sync", "IEC958", "None", "ADAT1", "ADAT2", "ADAT3" };
return 0;
}
-static int snd_hdsp_get_autosync_ref(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_get_autosync_ref(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
- hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
+ struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
- ucontrol->value.enumerated.item[0] = hdsp_pref_sync_ref(hdsp);
+ ucontrol->value.enumerated.item[0] = hdsp_autosync_ref(hdsp);
return 0;
}
-#define HDSP_PASSTHRU(xname, xindex) \
-{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
+#define HDSP_LINE_OUT(xname, xindex) \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
.name = xname, \
.index = xindex, \
- .info = snd_hdsp_info_passthru, \
- .put = snd_hdsp_put_passthru, \
- .get = snd_hdsp_get_passthru \
+ .info = snd_hdsp_info_line_out, \
+ .get = snd_hdsp_get_line_out, \
+ .put = snd_hdsp_put_line_out \
+}
+
+static int hdsp_line_out(struct hdsp *hdsp)
+{
+ return (hdsp->control_register & HDSP_LineOut) ? 1 : 0;
+}
+
+static int hdsp_set_line_output(struct hdsp *hdsp, int out)
+{
+ if (out)
+ hdsp->control_register |= HDSP_LineOut;
+ else
+ hdsp->control_register &= ~HDSP_LineOut;
+ hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register);
+ return 0;
}
-static int snd_hdsp_info_passthru(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_hdsp_info_line_out(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
{
uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
uinfo->count = 1;
return 0;
}
-static int snd_hdsp_get_passthru(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_get_line_out(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
- hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
- unsigned long flags;
-
- spin_lock_irqsave(&hdsp->lock, flags);
- ucontrol->value.integer.value[0] = hdsp->passthru;
- spin_unlock_irqrestore(&hdsp->lock, flags);
+ struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
+
+ spin_lock_irq(&hdsp->lock);
+ ucontrol->value.integer.value[0] = hdsp_line_out(hdsp);
+ spin_unlock_irq(&hdsp->lock);
return 0;
}
-static int snd_hdsp_put_passthru(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_put_line_out(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
- hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
- unsigned long flags;
+ struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
int change;
unsigned int val;
- int err = 0;
-
+
if (!snd_hdsp_use_is_exclusive(hdsp))
return -EBUSY;
-
val = ucontrol->value.integer.value[0] & 1;
- spin_lock_irqsave(&hdsp->lock, flags);
- change = (ucontrol->value.integer.value[0] != hdsp->passthru);
- if (change)
- err = hdsp_set_passthru(hdsp, val);
- spin_unlock_irqrestore(&hdsp->lock, flags);
- return err ? err : change;
+ spin_lock_irq(&hdsp->lock);
+ change = (int)val != hdsp_line_out(hdsp);
+ hdsp_set_line_output(hdsp, val);
+ spin_unlock_irq(&hdsp->lock);
+ return change;
}
-#define HDSP_LINE_OUT(xname, xindex) \
-{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
+#define HDSP_PRECISE_POINTER(xname, xindex) \
+{ .iface = SNDRV_CTL_ELEM_IFACE_CARD, \
.name = xname, \
.index = xindex, \
- .info = snd_hdsp_info_line_out, \
- .get = snd_hdsp_get_line_out, \
- .put = snd_hdsp_put_line_out \
+ .info = snd_hdsp_info_precise_pointer, \
+ .get = snd_hdsp_get_precise_pointer, \
+ .put = snd_hdsp_put_precise_pointer \
}
-static int hdsp_line_out(hdsp_t *hdsp)
+static int hdsp_set_precise_pointer(struct hdsp *hdsp, int precise)
{
- return (hdsp->control_register & HDSP_LineOut) ? 1 : 0;
+ if (precise)
+ hdsp->precise_ptr = 1;
+ else
+ hdsp->precise_ptr = 0;
+ return 0;
}
-static int hdsp_set_line_output(hdsp_t *hdsp, int out)
+static int snd_hdsp_info_precise_pointer(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
{
- if (out) {
- hdsp->control_register |= HDSP_LineOut;
- } else {
- hdsp->control_register &= ~HDSP_LineOut;
- }
- hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register);
+ uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
+ uinfo->count = 1;
+ uinfo->value.integer.min = 0;
+ uinfo->value.integer.max = 1;
return 0;
}
-static int snd_hdsp_info_line_out(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_hdsp_get_precise_pointer(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
+{
+ struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
+
+ spin_lock_irq(&hdsp->lock);
+ ucontrol->value.integer.value[0] = hdsp->precise_ptr;
+ spin_unlock_irq(&hdsp->lock);
+ return 0;
+}
+
+static int snd_hdsp_put_precise_pointer(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
+{
+ struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
+ int change;
+ unsigned int val;
+
+ if (!snd_hdsp_use_is_exclusive(hdsp))
+ return -EBUSY;
+ val = ucontrol->value.integer.value[0] & 1;
+ spin_lock_irq(&hdsp->lock);
+ change = (int)val != hdsp->precise_ptr;
+ hdsp_set_precise_pointer(hdsp, val);
+ spin_unlock_irq(&hdsp->lock);
+ return change;
+}
+
+#define HDSP_USE_MIDI_TASKLET(xname, xindex) \
+{ .iface = SNDRV_CTL_ELEM_IFACE_CARD, \
+ .name = xname, \
+ .index = xindex, \
+ .info = snd_hdsp_info_use_midi_tasklet, \
+ .get = snd_hdsp_get_use_midi_tasklet, \
+ .put = snd_hdsp_put_use_midi_tasklet \
+}
+
+static int hdsp_set_use_midi_tasklet(struct hdsp *hdsp, int use_tasklet)
+{
+ if (use_tasklet)
+ hdsp->use_midi_tasklet = 1;
+ else
+ hdsp->use_midi_tasklet = 0;
+ return 0;
+}
+
+static int snd_hdsp_info_use_midi_tasklet(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
{
uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
uinfo->count = 1;
return 0;
}
-static int snd_hdsp_get_line_out(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_get_use_midi_tasklet(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
- hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
- unsigned long flags;
+ struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
- spin_lock_irqsave(&hdsp->lock, flags);
- ucontrol->value.integer.value[0] = hdsp_line_out(hdsp);
- spin_unlock_irqrestore(&hdsp->lock, flags);
+ spin_lock_irq(&hdsp->lock);
+ ucontrol->value.integer.value[0] = hdsp->use_midi_tasklet;
+ spin_unlock_irq(&hdsp->lock);
return 0;
}
-static int snd_hdsp_put_line_out(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_put_use_midi_tasklet(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
- hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
- unsigned long flags;
+ struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
int change;
unsigned int val;
if (!snd_hdsp_use_is_exclusive(hdsp))
return -EBUSY;
val = ucontrol->value.integer.value[0] & 1;
- spin_lock_irqsave(&hdsp->lock, flags);
- change = (int)val != hdsp_line_out(hdsp);
- hdsp_set_line_output(hdsp, val);
- spin_unlock_irqrestore(&hdsp->lock, flags);
+ spin_lock_irq(&hdsp->lock);
+ change = (int)val != hdsp->use_midi_tasklet;
+ hdsp_set_use_midi_tasklet(hdsp, val);
+ spin_unlock_irq(&hdsp->lock);
return change;
}
{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
.name = xname, \
.index = xindex, \
+ .device = 0, \
.access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
SNDRV_CTL_ELEM_ACCESS_VOLATILE, \
.info = snd_hdsp_info_mixer, \
.put = snd_hdsp_put_mixer \
}
-static int snd_hdsp_info_mixer(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_hdsp_info_mixer(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
{
uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
uinfo->count = 3;
return 0;
}
-static int snd_hdsp_get_mixer(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_get_mixer(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
- hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
- unsigned long flags;
+ struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
int source;
int destination;
int addr;
source = ucontrol->value.integer.value[0];
destination = ucontrol->value.integer.value[1];
- if (source >= hdsp->max_channels) {
+ if (source >= hdsp->max_channels)
addr = hdsp_playback_to_output_key(hdsp,source-hdsp->max_channels,destination);
- } else {
+ else
addr = hdsp_input_to_output_key(hdsp,source, destination);
- }
- spin_lock_irqsave(&hdsp->lock, flags);
+ spin_lock_irq(&hdsp->lock);
ucontrol->value.integer.value[2] = hdsp_read_gain (hdsp, addr);
- spin_unlock_irqrestore(&hdsp->lock, flags);
+ spin_unlock_irq(&hdsp->lock);
return 0;
}
-static int snd_hdsp_put_mixer(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_put_mixer(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
- hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
- unsigned long flags;
+ struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
int change;
int source;
int destination;
source = ucontrol->value.integer.value[0];
destination = ucontrol->value.integer.value[1];
- if (source >= hdsp->max_channels) {
+ if (source >= hdsp->max_channels)
addr = hdsp_playback_to_output_key(hdsp,source-hdsp->max_channels, destination);
- } else {
+ else
addr = hdsp_input_to_output_key(hdsp,source, destination);
- }
gain = ucontrol->value.integer.value[2];
- spin_lock_irqsave(&hdsp->lock, flags);
+ spin_lock_irq(&hdsp->lock);
change = gain != hdsp_read_gain(hdsp, addr);
if (change)
hdsp_write_gain(hdsp, addr, gain);
- spin_unlock_irqrestore(&hdsp->lock, flags);
+ spin_unlock_irq(&hdsp->lock);
return change;
}
#define HDSP_WC_SYNC_CHECK(xname, xindex) \
-{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
.name = xname, \
.index = xindex, \
.access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, \
.get = snd_hdsp_get_wc_sync_check \
}
-static int snd_hdsp_info_sync_check(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_hdsp_info_sync_check(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
{
static char *texts[] = {"No Lock", "Lock", "Sync" };
uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
return 0;
}
-static int hdsp_wc_sync_check(hdsp_t *hdsp)
+static int hdsp_wc_sync_check(struct hdsp *hdsp)
{
int status2 = hdsp_read(hdsp, HDSP_status2Register);
if (status2 & HDSP_wc_lock) {
- if (status2 & HDSP_wc_sync) {
+ if (status2 & HDSP_wc_sync)
return 2;
- } else {
+ else
return 1;
- }
- } else {
+ } else
return 0;
- }
return 0;
}
-static int snd_hdsp_get_wc_sync_check(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_get_wc_sync_check(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
- hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
+ struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
ucontrol->value.enumerated.item[0] = hdsp_wc_sync_check(hdsp);
return 0;
}
#define HDSP_SPDIF_SYNC_CHECK(xname, xindex) \
-{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
.name = xname, \
.index = xindex, \
.access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, \
.get = snd_hdsp_get_spdif_sync_check \
}
-static int hdsp_spdif_sync_check(hdsp_t *hdsp)
+static int hdsp_spdif_sync_check(struct hdsp *hdsp)
{
int status = hdsp_read(hdsp, HDSP_statusRegister);
- if (status & HDSP_SPDIFErrorFlag) {
+ if (status & HDSP_SPDIFErrorFlag)
return 0;
- } else {
- if (status & HDSP_SPDIFSync) {
+ else {
+ if (status & HDSP_SPDIFSync)
return 2;
- } else {
+ else
return 1;
- }
}
return 0;
}
-static int snd_hdsp_get_spdif_sync_check(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_get_spdif_sync_check(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
- hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
+ struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
ucontrol->value.enumerated.item[0] = hdsp_spdif_sync_check(hdsp);
return 0;
}
#define HDSP_ADATSYNC_SYNC_CHECK(xname, xindex) \
-{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
.name = xname, \
.index = xindex, \
.access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, \
.get = snd_hdsp_get_adatsync_sync_check \
}
-static int hdsp_adatsync_sync_check(hdsp_t *hdsp)
+static int hdsp_adatsync_sync_check(struct hdsp *hdsp)
{
int status = hdsp_read(hdsp, HDSP_statusRegister);
if (status & HDSP_TimecodeLock) {
- if (status & HDSP_TimecodeSync) {
+ if (status & HDSP_TimecodeSync)
return 2;
- } else {
+ else
return 1;
- }
- } else {
+ } else
return 0;
- }
}
-static int snd_hdsp_get_adatsync_sync_check(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_get_adatsync_sync_check(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
- hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
+ struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
ucontrol->value.enumerated.item[0] = hdsp_adatsync_sync_check(hdsp);
return 0;
}
#define HDSP_ADAT_SYNC_CHECK \
-{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
.access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, \
.info = snd_hdsp_info_sync_check, \
.get = snd_hdsp_get_adat_sync_check \
}
-static int hdsp_adat_sync_check(hdsp_t *hdsp, int idx)
+static int hdsp_adat_sync_check(struct hdsp *hdsp, int idx)
{
int status = hdsp_read(hdsp, HDSP_statusRegister);
if (status & (HDSP_Lock0>>idx)) {
- if (status & (HDSP_Sync0>>idx)) {
+ if (status & (HDSP_Sync0>>idx))
return 2;
- } else {
+ else
return 1;
- }
- } else {
+ } else
return 0;
- }
}
-static int snd_hdsp_get_adat_sync_check(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_get_adat_sync_check(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
int offset;
- hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
+ struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
offset = ucontrol->id.index - 1;
snd_assert(offset >= 0);
return 0;
}
-static snd_kcontrol_new_t snd_hdsp_9632_controls[] = {
+static struct snd_kcontrol_new snd_hdsp_9632_controls[] = {
HDSP_DA_GAIN("DA Gain", 0),
HDSP_AD_GAIN("AD Gain", 0),
HDSP_PHONE_GAIN("Phones Gain", 0),
HDSP_XLR_BREAKOUT_CABLE("XLR Breakout Cable", 0)
};
-static snd_kcontrol_new_t snd_hdsp_controls[] = {
+static struct snd_kcontrol_new snd_hdsp_controls[] = {
{
.iface = SNDRV_CTL_ELEM_IFACE_PCM,
.name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT),
},
{
.access = SNDRV_CTL_ELEM_ACCESS_READ,
- .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+ .iface = SNDRV_CTL_ELEM_IFACE_PCM,
.name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,CON_MASK),
.info = snd_hdsp_control_spdif_mask_info,
.get = snd_hdsp_control_spdif_mask_get,
},
{
.access = SNDRV_CTL_ELEM_ACCESS_READ,
- .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+ .iface = SNDRV_CTL_ELEM_IFACE_PCM,
.name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,PRO_MASK),
.info = snd_hdsp_control_spdif_mask_info,
.get = snd_hdsp_control_spdif_mask_get,
HDSP_SPDIF_NON_AUDIO("IEC958 Non-audio Bit", 0),
/* 'Sample Clock Source' complies with the alsa control naming scheme */
HDSP_CLOCK_SOURCE("Sample Clock Source", 0),
+{
+ .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+ .name = "Sample Clock Source Locking",
+ .info = snd_hdsp_info_clock_source_lock,
+ .get = snd_hdsp_get_clock_source_lock,
+ .put = snd_hdsp_put_clock_source_lock,
+},
HDSP_SYSTEM_CLOCK_MODE("System Clock Mode", 0),
HDSP_PREF_SYNC_REF("Preferred Sync Reference", 0),
HDSP_AUTOSYNC_REF("AutoSync Reference", 0),
HDSP_WC_SYNC_CHECK("Word Clock Lock Status", 0),
HDSP_SPDIF_SYNC_CHECK("SPDIF Lock Status", 0),
HDSP_ADATSYNC_SYNC_CHECK("ADAT Sync Lock Status", 0),
-HDSP_PASSTHRU("Passthru", 0),
HDSP_LINE_OUT("Line Out", 0),
+HDSP_PRECISE_POINTER("Precise Pointer", 0),
+HDSP_USE_MIDI_TASKLET("Use Midi Tasklet", 0),
};
-#define HDSP_CONTROLS (sizeof(snd_hdsp_controls)/sizeof(snd_kcontrol_new_t))
-
-#define HDSP_9632_CONTROLS (sizeof(snd_hdsp_9632_controls)/sizeof(snd_kcontrol_new_t))
-
-static snd_kcontrol_new_t snd_hdsp_96xx_aeb = HDSP_AEB("Analog Extension Board", 0);
-static snd_kcontrol_new_t snd_hdsp_adat_sync_check = HDSP_ADAT_SYNC_CHECK;
+static struct snd_kcontrol_new snd_hdsp_96xx_aeb = HDSP_AEB("Analog Extension Board", 0);
+static struct snd_kcontrol_new snd_hdsp_adat_sync_check = HDSP_ADAT_SYNC_CHECK;
-int snd_hdsp_create_controls(snd_card_t *card, hdsp_t *hdsp)
+static int snd_hdsp_create_controls(struct snd_card *card, struct hdsp *hdsp)
{
unsigned int idx;
int err;
- snd_kcontrol_t *kctl;
+ struct snd_kcontrol *kctl;
- for (idx = 0; idx < HDSP_CONTROLS; idx++) {
- if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_hdsp_controls[idx], hdsp))) < 0) {
+ for (idx = 0; idx < ARRAY_SIZE(snd_hdsp_controls); idx++) {
+ if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_hdsp_controls[idx], hdsp))) < 0)
return err;
- }
if (idx == 1) /* IEC958 (S/PDIF) Stream */
hdsp->spdif_ctl = kctl;
}
/* ADAT SyncCheck status */
snd_hdsp_adat_sync_check.name = "ADAT Lock Status";
snd_hdsp_adat_sync_check.index = 1;
- if ((err = snd_ctl_add (card, kctl = snd_ctl_new1(&snd_hdsp_adat_sync_check, hdsp)))) {
+ if ((err = snd_ctl_add (card, kctl = snd_ctl_new1(&snd_hdsp_adat_sync_check, hdsp))))
return err;
- }
if (hdsp->io_type == Digiface || hdsp->io_type == H9652) {
for (idx = 1; idx < 3; ++idx) {
snd_hdsp_adat_sync_check.index = idx+1;
- if ((err = snd_ctl_add (card, kctl = snd_ctl_new1(&snd_hdsp_adat_sync_check, hdsp)))) {
+ if ((err = snd_ctl_add (card, kctl = snd_ctl_new1(&snd_hdsp_adat_sync_check, hdsp))))
return err;
- }
}
}
/* DA, AD and Phone gain and XLR breakout cable controls for H9632 cards */
if (hdsp->io_type == H9632) {
- for (idx = 0; idx < HDSP_9632_CONTROLS; idx++) {
- if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_hdsp_9632_controls[idx], hdsp))) < 0) {
+ for (idx = 0; idx < ARRAY_SIZE(snd_hdsp_9632_controls); idx++) {
+ if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_hdsp_9632_controls[idx], hdsp))) < 0)
return err;
- }
}
}
/* AEB control for H96xx card */
if (hdsp->io_type == H9632 || hdsp->io_type == H9652) {
- if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_hdsp_96xx_aeb, hdsp))) < 0) {
+ if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_hdsp_96xx_aeb, hdsp))) < 0)
return err;
- }
}
return 0;
------------------------------------------------------------*/
static void
-snd_hdsp_proc_read(snd_info_entry_t *entry, snd_info_buffer_t *buffer)
+snd_hdsp_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer)
{
- hdsp_t *hdsp = (hdsp_t *) entry->private_data;
+ struct hdsp *hdsp = (struct hdsp *) entry->private_data;
unsigned int status;
unsigned int status2;
char *pref_sync_ref;
if (hdsp_check_for_iobox (hdsp)) {
snd_iprintf(buffer, "No I/O box connected.\nPlease connect one and upload firmware.\n");
return;
- }
+ }
- if (hdsp_check_for_firmware(hdsp)) {
+ if (hdsp_check_for_firmware(hdsp, 0)) {
if (hdsp->state & HDSP_FirmwareCached) {
if (snd_hdsp_load_firmware_from_cache(hdsp) != 0) {
snd_iprintf(buffer, "Firmware loading from cache failed, please upload manually.\n");
snd_iprintf(buffer, "Buffers: capture %p playback %p\n",
hdsp->capture_buffer, hdsp->playback_buffer);
snd_iprintf(buffer, "IRQ: %d Registers bus: 0x%lx VM: 0x%lx\n",
- hdsp->irq, hdsp->port, hdsp->iobase);
+ hdsp->irq, hdsp->port, (unsigned long)hdsp->iobase);
snd_iprintf(buffer, "Control register: 0x%x\n", hdsp->control_register);
snd_iprintf(buffer, "Control2 register: 0x%x\n", hdsp->control2_register);
snd_iprintf(buffer, "Status register: 0x%x\n", status);
snd_iprintf(buffer, "Status2 register: 0x%x\n", status2);
snd_iprintf(buffer, "FIFO status: %d\n", hdsp_read(hdsp, HDSP_fifoStatus) & 0xff);
-
snd_iprintf(buffer, "MIDI1 Output status: 0x%x\n", hdsp_read(hdsp, HDSP_midiStatusOut0));
snd_iprintf(buffer, "MIDI1 Input status: 0x%x\n", hdsp_read(hdsp, HDSP_midiStatusIn0));
snd_iprintf(buffer, "MIDI2 Output status: 0x%x\n", hdsp_read(hdsp, HDSP_midiStatusOut1));
snd_iprintf(buffer, "MIDI2 Input status: 0x%x\n", hdsp_read(hdsp, HDSP_midiStatusIn1));
+ snd_iprintf(buffer, "Use Midi Tasklet: %s\n", hdsp->use_midi_tasklet ? "on" : "off");
snd_iprintf(buffer, "\n");
snd_iprintf(buffer, "Buffer Size (Latency): %d samples (2 periods of %lu bytes)\n", x, (unsigned long) hdsp->period_bytes);
snd_iprintf(buffer, "Hardware pointer (frames): %ld\n", hdsp_hw_pointer(hdsp));
- snd_iprintf(buffer, "Passthru: %s\n", hdsp->passthru ? "yes" : "no");
+ snd_iprintf(buffer, "Precise pointer: %s\n", hdsp->precise_ptr ? "on" : "off");
snd_iprintf(buffer, "Line out: %s\n", (hdsp->control_register & HDSP_LineOut) ? "on" : "off");
snd_iprintf(buffer, "Firmware version: %d\n", (status2&HDSP_version0)|(status2&HDSP_version1)<<1|(status2&HDSP_version2)<<2);
}
snd_iprintf (buffer, "Sample Clock Source: %s\n", clock_source);
- if (hdsp_system_clock_mode(hdsp)) {
+ if (hdsp_system_clock_mode(hdsp))
system_clock_mode = "Slave";
- } else {
+ else
system_clock_mode = "Master";
- }
switch (hdsp_pref_sync_ref (hdsp)) {
case HDSP_SYNC_FROM_WORD:
snd_iprintf (buffer, "System Clock Mode: %s\n", system_clock_mode);
snd_iprintf (buffer, "System Clock Frequency: %d\n", hdsp->system_sample_rate);
+ snd_iprintf (buffer, "System Clock Locked: %s\n", hdsp->clock_source_locked ? "Yes" : "No");
snd_iprintf(buffer, "\n");
break;
}
- if (hdsp->control_register & HDSP_SPDIFOpticalOut) {
+ if (hdsp->control_register & HDSP_SPDIFOpticalOut)
snd_iprintf(buffer, "IEC958 output: Coaxial & ADAT1\n");
- } else {
+ else
snd_iprintf(buffer, "IEC958 output: Coaxial only\n");
- }
- if (hdsp->control_register & HDSP_SPDIFProfessional) {
+ if (hdsp->control_register & HDSP_SPDIFProfessional)
snd_iprintf(buffer, "IEC958 quality: Professional\n");
- } else {
+ else
snd_iprintf(buffer, "IEC958 quality: Consumer\n");
- }
- if (hdsp->control_register & HDSP_SPDIFEmphasis) {
+ if (hdsp->control_register & HDSP_SPDIFEmphasis)
snd_iprintf(buffer, "IEC958 emphasis: on\n");
- } else {
+ else
snd_iprintf(buffer, "IEC958 emphasis: off\n");
- }
- if (hdsp->control_register & HDSP_SPDIFNonAudio) {
+ if (hdsp->control_register & HDSP_SPDIFNonAudio)
snd_iprintf(buffer, "IEC958 NonAudio: on\n");
- } else {
+ else
snd_iprintf(buffer, "IEC958 NonAudio: off\n");
- }
- if ((x = hdsp_spdif_sample_rate (hdsp)) != 0) {
+ if ((x = hdsp_spdif_sample_rate (hdsp)) != 0)
snd_iprintf (buffer, "IEC958 sample rate: %d\n", x);
- } else {
+ else
snd_iprintf (buffer, "IEC958 sample rate: Error flag set\n");
- }
snd_iprintf(buffer, "\n");
/* Sync Check */
x = status & HDSP_Sync0;
- if (status & HDSP_Lock0) {
+ if (status & HDSP_Lock0)
snd_iprintf(buffer, "ADAT1: %s\n", x ? "Sync" : "Lock");
- } else {
+ else
snd_iprintf(buffer, "ADAT1: No Lock\n");
- }
switch (hdsp->io_type) {
case Digiface:
case H9652:
x = status & HDSP_Sync1;
- if (status & HDSP_Lock1) {
+ if (status & HDSP_Lock1)
snd_iprintf(buffer, "ADAT2: %s\n", x ? "Sync" : "Lock");
- } else {
+ else
snd_iprintf(buffer, "ADAT2: No Lock\n");
- }
x = status & HDSP_Sync2;
- if (status & HDSP_Lock2) {
+ if (status & HDSP_Lock2)
snd_iprintf(buffer, "ADAT3: %s\n", x ? "Sync" : "Lock");
- } else {
+ else
snd_iprintf(buffer, "ADAT3: No Lock\n");
- }
+ break;
default:
/* relax */
break;
}
x = status & HDSP_SPDIFSync;
- if (status & HDSP_SPDIFErrorFlag) {
+ if (status & HDSP_SPDIFErrorFlag)
snd_iprintf (buffer, "SPDIF: No Lock\n");
- } else {
+ else
snd_iprintf (buffer, "SPDIF: %s\n", x ? "Sync" : "Lock");
- }
x = status2 & HDSP_wc_sync;
- if (status2 & HDSP_wc_lock) {
+ if (status2 & HDSP_wc_lock)
snd_iprintf (buffer, "Word Clock: %s\n", x ? "Sync" : "Lock");
- } else {
+ else
snd_iprintf (buffer, "Word Clock: No Lock\n");
- }
x = status & HDSP_TimecodeSync;
- if (status & HDSP_TimecodeLock) {
+ if (status & HDSP_TimecodeLock)
snd_iprintf(buffer, "ADAT Sync: %s\n", x ? "Sync" : "Lock");
- } else {
+ else
snd_iprintf(buffer, "ADAT Sync: No Lock\n");
- }
snd_iprintf(buffer, "\n");
snd_iprintf(buffer, "XLR Breakout Cable : %s\n", hdsp_xlr_breakout_cable(hdsp) ? "yes" : "no");
- if (hdsp->control_register & HDSP_AnalogExtensionBoard) {
+ if (hdsp->control_register & HDSP_AnalogExtensionBoard)
snd_iprintf(buffer, "AEB : on (ADAT1 internal)\n");
- } else {
+ else
snd_iprintf(buffer, "AEB : off (ADAT1 external)\n");
- }
snd_iprintf(buffer, "\n");
}
}
-static void __devinit snd_hdsp_proc_init(hdsp_t *hdsp)
+static void __devinit snd_hdsp_proc_init(struct hdsp *hdsp)
{
- snd_info_entry_t *entry;
+ struct snd_info_entry *entry;
if (! snd_card_proc_new(hdsp->card, "hdsp", &entry))
snd_info_set_text_ops(entry, hdsp, 1024, snd_hdsp_proc_read);
}
-static void snd_hdsp_free_buffers(hdsp_t *hdsp)
+static void snd_hdsp_free_buffers(struct hdsp *hdsp)
{
- if (hdsp->capture_buffer_unaligned) {
- snd_hammerfall_free_buffer(hdsp->pci, HDSP_DMA_AREA_BYTES,
- hdsp->capture_buffer_unaligned,
- hdsp->capture_buffer_addr, 1);
- }
-
- if (hdsp->playback_buffer_unaligned) {
- snd_hammerfall_free_buffer(hdsp->pci, HDSP_DMA_AREA_BYTES,
- hdsp->playback_buffer_unaligned,
- hdsp->playback_buffer_addr, 0);
- }
+ snd_hammerfall_free_buffer(&hdsp->capture_dma_buf, hdsp->pci);
+ snd_hammerfall_free_buffer(&hdsp->playback_dma_buf, hdsp->pci);
}
-static int __devinit snd_hdsp_initialize_memory(hdsp_t *hdsp)
+static int __devinit snd_hdsp_initialize_memory(struct hdsp *hdsp)
{
- void *pb, *cb;
- dma_addr_t pb_addr, cb_addr;
unsigned long pb_bus, cb_bus;
- cb = snd_hammerfall_get_buffer(hdsp->pci, HDSP_DMA_AREA_BYTES, &cb_addr, 1);
- pb = snd_hammerfall_get_buffer(hdsp->pci, HDSP_DMA_AREA_BYTES, &pb_addr, 0);
-
- if (cb == 0 || pb == 0) {
- if (cb) {
- snd_hammerfall_free_buffer(hdsp->pci, HDSP_DMA_AREA_BYTES, cb, cb_addr, 1);
- }
- if (pb) {
- snd_hammerfall_free_buffer(hdsp->pci, HDSP_DMA_AREA_BYTES, pb, pb_addr, 0);
- }
-
+ if (snd_hammerfall_get_buffer(hdsp->pci, &hdsp->capture_dma_buf, HDSP_DMA_AREA_BYTES) < 0 ||
+ snd_hammerfall_get_buffer(hdsp->pci, &hdsp->playback_dma_buf, HDSP_DMA_AREA_BYTES) < 0) {
+ if (hdsp->capture_dma_buf.area)
+ snd_dma_free_pages(&hdsp->capture_dma_buf);
printk(KERN_ERR "%s: no buffers available\n", hdsp->card_name);
return -ENOMEM;
}
- /* save raw addresses for use when freeing memory later */
-
- hdsp->capture_buffer_unaligned = cb;
- hdsp->playback_buffer_unaligned = pb;
- hdsp->capture_buffer_addr = cb_addr;
- hdsp->playback_buffer_addr = pb_addr;
-
/* Align to bus-space 64K boundary */
- cb_bus = (cb_addr + 0xFFFF) & ~0xFFFFl;
- pb_bus = (pb_addr + 0xFFFF) & ~0xFFFFl;
+ cb_bus = (hdsp->capture_dma_buf.addr + 0xFFFF) & ~0xFFFFl;
+ pb_bus = (hdsp->playback_dma_buf.addr + 0xFFFF) & ~0xFFFFl;
/* Tell the card where it is */
hdsp_write(hdsp, HDSP_inputBufferAddress, cb_bus);
hdsp_write(hdsp, HDSP_outputBufferAddress, pb_bus);
- hdsp->capture_buffer = cb + (cb_bus - cb_addr);
- hdsp->playback_buffer = pb + (pb_bus - pb_addr);
+ hdsp->capture_buffer = hdsp->capture_dma_buf.area + (cb_bus - hdsp->capture_dma_buf.addr);
+ hdsp->playback_buffer = hdsp->playback_dma_buf.area + (pb_bus - hdsp->playback_dma_buf.addr);
return 0;
}
-static int snd_hdsp_set_defaults(hdsp_t *hdsp)
+static int snd_hdsp_set_defaults(struct hdsp *hdsp)
{
unsigned int i;
#else
hdsp->control2_register = 0;
#endif
- if (hdsp->io_type == H9652) {
+ if (hdsp->io_type == H9652)
snd_hdsp_9652_enable_mixer (hdsp);
- } else {
- hdsp_write (hdsp, HDSP_control2Reg, hdsp->control2_register);
- }
+ else
+ hdsp_write (hdsp, HDSP_control2Reg, hdsp->control2_register);
hdsp_reset_hw_pointer(hdsp);
hdsp_compute_period_size(hdsp);
/* silence everything */
- for (i = 0; i < HDSP_MATRIX_MIXER_SIZE; ++i) {
+ for (i = 0; i < HDSP_MATRIX_MIXER_SIZE; ++i)
hdsp->mixer_matrix[i] = MINUS_INFINITY_GAIN;
- }
for (i = 0; i < ((hdsp->io_type == H9652 || hdsp->io_type == H9632) ? 1352 : HDSP_MATRIX_MIXER_SIZE); ++i) {
- if (hdsp_write_gain (hdsp, i, MINUS_INFINITY_GAIN)) {
+ if (hdsp_write_gain (hdsp, i, MINUS_INFINITY_GAIN))
return -EIO;
- }
}
- if ((hdsp->io_type != H9652) && line_outs_monitor[hdsp->dev]) {
-
- int lineouts_base;
-
- snd_printk ("sending all inputs and playback streams to line outs.\n");
-
- /* route all inputs to the line outs for easy monitoring. send
- odd numbered channels to right, even to left.
- */
- if (hdsp->io_type == H9632) {
- /* this is the phones/analog output */
- lineouts_base = 10;
- } else {
- lineouts_base = 26;
- }
-
- for (i = 0; i < hdsp->max_channels; i++) {
- if (i & 1) {
- if (hdsp_write_gain (hdsp, hdsp_input_to_output_key (hdsp, i, lineouts_base), UNITY_GAIN) ||
- hdsp_write_gain (hdsp, hdsp_playback_to_output_key (hdsp, i, lineouts_base), UNITY_GAIN)) {
- return -EIO;
- }
- } else {
- if (hdsp_write_gain (hdsp, hdsp_input_to_output_key (hdsp, i, lineouts_base+1), UNITY_GAIN) ||
- hdsp_write_gain (hdsp, hdsp_playback_to_output_key (hdsp, i, lineouts_base+1), UNITY_GAIN)) {
-
- return -EIO;
- }
- }
- }
- }
-
- hdsp->passthru = 0;
-
/* H9632 specific defaults */
if (hdsp->io_type == H9632) {
hdsp->control_register |= (HDSP_DAGainPlus4dBu | HDSP_ADGainPlus4dBu | HDSP_PhoneGain0dB);
return 0;
}
-void hdsp_midi_tasklet(unsigned long arg)
+static void hdsp_midi_tasklet(unsigned long arg)
{
- hdsp_t *hdsp = (hdsp_t *)arg;
+ struct hdsp *hdsp = (struct hdsp *)arg;
- if (hdsp->midi[0].pending) {
+ if (hdsp->midi[0].pending)
snd_hdsp_midi_input_read (&hdsp->midi[0]);
- }
- if (hdsp->midi[1].pending) {
+ if (hdsp->midi[1].pending)
snd_hdsp_midi_input_read (&hdsp->midi[1]);
- }
}
static irqreturn_t snd_hdsp_interrupt(int irq, void *dev_id, struct pt_regs *regs)
{
- hdsp_t *hdsp = (hdsp_t *) dev_id;
+ struct hdsp *hdsp = (struct hdsp *) dev_id;
unsigned int status;
int audio;
int midi0;
midi0 = status & HDSP_midi0IRQPending;
midi1 = status & HDSP_midi1IRQPending;
- if (!audio && !midi0 && !midi1) {
+ if (!audio && !midi0 && !midi1)
return IRQ_NONE;
- }
hdsp_write(hdsp, HDSP_interruptConfirmation, 0);
midi1status = hdsp_read (hdsp, HDSP_midiStatusIn1) & 0xff;
if (audio) {
- if (hdsp->capture_substream) {
+ if (hdsp->capture_substream)
snd_pcm_period_elapsed(hdsp->pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream);
- }
- if (hdsp->playback_substream) {
+ if (hdsp->playback_substream)
snd_pcm_period_elapsed(hdsp->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream);
- }
}
if (midi0 && midi0status) {
- /* we disable interrupts for this input until processing is done */
- hdsp->control_register &= ~HDSP_Midi0InterruptEnable;
- hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register);
- hdsp->midi[0].pending = 1;
- schedule = 1;
+ if (hdsp->use_midi_tasklet) {
+ /* we disable interrupts for this input until processing is done */
+ hdsp->control_register &= ~HDSP_Midi0InterruptEnable;
+ hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register);
+ hdsp->midi[0].pending = 1;
+ schedule = 1;
+ } else {
+ snd_hdsp_midi_input_read (&hdsp->midi[0]);
+ }
}
- if (midi1 && midi1status) {
- /* we disable interrupts for this input until processing is done */
- hdsp->control_register &= ~HDSP_Midi1InterruptEnable;
- hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register);
- hdsp->midi[1].pending = 1;
- schedule = 1;
+ if (hdsp->io_type != Multiface && hdsp->io_type != H9632 && midi1 && midi1status) {
+ if (hdsp->use_midi_tasklet) {
+ /* we disable interrupts for this input until processing is done */
+ hdsp->control_register &= ~HDSP_Midi1InterruptEnable;
+ hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register);
+ hdsp->midi[1].pending = 1;
+ schedule = 1;
+ } else {
+ snd_hdsp_midi_input_read (&hdsp->midi[1]);
+ }
}
- if (schedule)
- tasklet_hi_schedule(&hdsp->midi_tasklet);
+ if (hdsp->use_midi_tasklet && schedule)
+ tasklet_hi_schedule(&hdsp->midi_tasklet);
return IRQ_HANDLED;
}
-static snd_pcm_uframes_t snd_hdsp_hw_pointer(snd_pcm_substream_t *substream)
+static snd_pcm_uframes_t snd_hdsp_hw_pointer(struct snd_pcm_substream *substream)
{
- hdsp_t *hdsp = _snd_pcm_substream_chip(substream);
+ struct hdsp *hdsp = snd_pcm_substream_chip(substream);
return hdsp_hw_pointer(hdsp);
}
-static char *hdsp_channel_buffer_location(hdsp_t *hdsp,
+static char *hdsp_channel_buffer_location(struct hdsp *hdsp,
int stream,
int channel)
snd_assert(channel >= 0 && channel < hdsp->max_channels, return NULL);
- if ((mapped_channel = hdsp->channel_map[channel]) < 0) {
+ if ((mapped_channel = hdsp->channel_map[channel]) < 0)
return NULL;
- }
- if (stream == SNDRV_PCM_STREAM_CAPTURE) {
+ if (stream == SNDRV_PCM_STREAM_CAPTURE)
return hdsp->capture_buffer + (mapped_channel * HDSP_CHANNEL_BUFFER_BYTES);
- } else {
+ else
return hdsp->playback_buffer + (mapped_channel * HDSP_CHANNEL_BUFFER_BYTES);
- }
}
-static int snd_hdsp_playback_copy(snd_pcm_substream_t *substream, int channel,
+static int snd_hdsp_playback_copy(struct snd_pcm_substream *substream, int channel,
snd_pcm_uframes_t pos, void __user *src, snd_pcm_uframes_t count)
{
- hdsp_t *hdsp = _snd_pcm_substream_chip(substream);
+ struct hdsp *hdsp = snd_pcm_substream_chip(substream);
char *channel_buf;
snd_assert(pos + count <= HDSP_CHANNEL_BUFFER_BYTES / 4, return -EINVAL);
return count;
}
-static int snd_hdsp_capture_copy(snd_pcm_substream_t *substream, int channel,
+static int snd_hdsp_capture_copy(struct snd_pcm_substream *substream, int channel,
snd_pcm_uframes_t pos, void __user *dst, snd_pcm_uframes_t count)
{
- hdsp_t *hdsp = _snd_pcm_substream_chip(substream);
+ struct hdsp *hdsp = snd_pcm_substream_chip(substream);
char *channel_buf;
snd_assert(pos + count <= HDSP_CHANNEL_BUFFER_BYTES / 4, return -EINVAL);
return count;
}
-static int snd_hdsp_hw_silence(snd_pcm_substream_t *substream, int channel,
+static int snd_hdsp_hw_silence(struct snd_pcm_substream *substream, int channel,
snd_pcm_uframes_t pos, snd_pcm_uframes_t count)
{
- hdsp_t *hdsp = _snd_pcm_substream_chip(substream);
+ struct hdsp *hdsp = snd_pcm_substream_chip(substream);
char *channel_buf;
channel_buf = hdsp_channel_buffer_location (hdsp, substream->pstr->stream, channel);
return count;
}
-static int snd_hdsp_reset(snd_pcm_substream_t *substream)
+static int snd_hdsp_reset(struct snd_pcm_substream *substream)
{
- snd_pcm_runtime_t *runtime = substream->runtime;
- hdsp_t *hdsp = _snd_pcm_substream_chip(substream);
- snd_pcm_substream_t *other;
+ struct snd_pcm_runtime *runtime = substream->runtime;
+ struct hdsp *hdsp = snd_pcm_substream_chip(substream);
+ struct snd_pcm_substream *other;
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
other = hdsp->capture_substream;
else
runtime->status->hw_ptr = 0;
if (other) {
struct list_head *pos;
- snd_pcm_substream_t *s;
- snd_pcm_runtime_t *oruntime = other->runtime;
+ struct snd_pcm_substream *s;
+ struct snd_pcm_runtime *oruntime = other->runtime;
snd_pcm_group_for_each(pos, substream) {
s = snd_pcm_group_substream_entry(pos);
if (s == other) {
return 0;
}
-static int snd_hdsp_hw_params(snd_pcm_substream_t *substream,
- snd_pcm_hw_params_t *params)
+static int snd_hdsp_hw_params(struct snd_pcm_substream *substream,
+ struct snd_pcm_hw_params *params)
{
- hdsp_t *hdsp = _snd_pcm_substream_chip(substream);
+ struct hdsp *hdsp = snd_pcm_substream_chip(substream);
int err;
pid_t this_pid;
pid_t other_pid;
- if (hdsp_check_for_iobox (hdsp)) {
+ if (hdsp_check_for_iobox (hdsp))
return -EIO;
- }
- if (hdsp_check_for_firmware(hdsp)) {
- if (hdsp->state & HDSP_FirmwareCached) {
- if (snd_hdsp_load_firmware_from_cache(hdsp) != 0) {
- snd_printk("Firmware loading from cache failed, please upload manually.\n");
- }
- } else {
- snd_printk("No firmware loaded nor cached, please upload firmware.\n");
- }
+ if (hdsp_check_for_firmware(hdsp, 1))
return -EIO;
- }
spin_lock_irq(&hdsp->lock);
*/
spin_lock_irq(&hdsp->lock);
- if ((err = hdsp_set_rate(hdsp, params_rate(params), 0)) < 0) {
- spin_unlock_irq(&hdsp->lock);
- _snd_pcm_hw_param_setempty(params, SNDRV_PCM_HW_PARAM_RATE);
- return err;
- } else {
- spin_unlock_irq(&hdsp->lock);
+ if (! hdsp->clock_source_locked) {
+ if ((err = hdsp_set_rate(hdsp, params_rate(params), 0)) < 0) {
+ spin_unlock_irq(&hdsp->lock);
+ _snd_pcm_hw_param_setempty(params, SNDRV_PCM_HW_PARAM_RATE);
+ return err;
+ }
}
+ spin_unlock_irq(&hdsp->lock);
if ((err = hdsp_set_interrupt_interval(hdsp, params_period_size(params))) < 0) {
_snd_pcm_hw_param_setempty(params, SNDRV_PCM_HW_PARAM_PERIOD_SIZE);
return 0;
}
-static int snd_hdsp_channel_info(snd_pcm_substream_t *substream,
- snd_pcm_channel_info_t *info)
+static int snd_hdsp_channel_info(struct snd_pcm_substream *substream,
+ struct snd_pcm_channel_info *info)
{
- hdsp_t *hdsp = _snd_pcm_substream_chip(substream);
+ struct hdsp *hdsp = snd_pcm_substream_chip(substream);
int mapped_channel;
snd_assert(info->channel < hdsp->max_channels, return -EINVAL);
- if ((mapped_channel = hdsp->channel_map[info->channel]) < 0) {
+ if ((mapped_channel = hdsp->channel_map[info->channel]) < 0)
return -EINVAL;
- }
info->offset = mapped_channel * HDSP_CHANNEL_BUFFER_BYTES;
info->first = 0;
return 0;
}
-static int snd_hdsp_ioctl(snd_pcm_substream_t *substream,
+static int snd_hdsp_ioctl(struct snd_pcm_substream *substream,
unsigned int cmd, void *arg)
{
switch (cmd) {
case SNDRV_PCM_IOCTL1_RESET:
- {
return snd_hdsp_reset(substream);
- }
case SNDRV_PCM_IOCTL1_CHANNEL_INFO:
- {
- snd_pcm_channel_info_t *info = arg;
- return snd_hdsp_channel_info(substream, info);
- }
+ return snd_hdsp_channel_info(substream, arg);
default:
break;
}
return snd_pcm_lib_ioctl(substream, cmd, arg);
}
-static int snd_hdsp_trigger(snd_pcm_substream_t *substream, int cmd)
+static int snd_hdsp_trigger(struct snd_pcm_substream *substream, int cmd)
{
- hdsp_t *hdsp = _snd_pcm_substream_chip(substream);
- snd_pcm_substream_t *other;
+ struct hdsp *hdsp = snd_pcm_substream_chip(substream);
+ struct snd_pcm_substream *other;
int running;
- if (hdsp_check_for_iobox (hdsp)) {
+ if (hdsp_check_for_iobox (hdsp))
return -EIO;
- }
- if (hdsp_check_for_firmware(hdsp)) {
- if (hdsp->state & HDSP_FirmwareCached) {
- if (snd_hdsp_load_firmware_from_cache(hdsp) != 0) {
- snd_printk("Firmware loading from cache failed, please upload manually.\n");
- }
- } else {
- snd_printk("No firmware loaded nor cached, please upload firmware.\n");
- }
+ if (hdsp_check_for_firmware(hdsp, 1))
return -EIO;
- }
spin_lock(&hdsp->lock);
running = hdsp->running;
if (other) {
struct list_head *pos;
- snd_pcm_substream_t *s;
+ struct snd_pcm_substream *s;
snd_pcm_group_for_each(pos, substream) {
s = snd_pcm_group_substream_entry(pos);
if (s == other) {
return 0;
}
-static int snd_hdsp_prepare(snd_pcm_substream_t *substream)
+static int snd_hdsp_prepare(struct snd_pcm_substream *substream)
{
- hdsp_t *hdsp = _snd_pcm_substream_chip(substream);
+ struct hdsp *hdsp = snd_pcm_substream_chip(substream);
int result = 0;
- if (hdsp_check_for_iobox (hdsp)) {
+ if (hdsp_check_for_iobox (hdsp))
return -EIO;
- }
- if (hdsp_check_for_firmware(hdsp)) {
- if (hdsp->state & HDSP_FirmwareCached) {
- if (snd_hdsp_load_firmware_from_cache(hdsp) != 0) {
- snd_printk("Firmware loading from cache failed, please upload manually.\n");
- }
- } else {
- snd_printk("No firmware loaded nor cached, please upload firmware.\n");
- }
+ if (hdsp_check_for_firmware(hdsp, 1))
return -EIO;
- }
- spin_lock(&hdsp->lock);
+ spin_lock_irq(&hdsp->lock);
if (!hdsp->running)
hdsp_reset_hw_pointer(hdsp);
- spin_unlock(&hdsp->lock);
+ spin_unlock_irq(&hdsp->lock);
return result;
}
-static snd_pcm_hardware_t snd_hdsp_playback_subinfo =
+static struct snd_pcm_hardware snd_hdsp_playback_subinfo =
{
.info = (SNDRV_PCM_INFO_MMAP |
SNDRV_PCM_INFO_MMAP_VALID |
SNDRV_PCM_INFO_NONINTERLEAVED |
SNDRV_PCM_INFO_SYNC_START |
SNDRV_PCM_INFO_DOUBLE),
+#ifdef SNDRV_BIG_ENDIAN
+ .formats = SNDRV_PCM_FMTBIT_S32_BE,
+#else
.formats = SNDRV_PCM_FMTBIT_S32_LE,
+#endif
.rates = (SNDRV_PCM_RATE_32000 |
SNDRV_PCM_RATE_44100 |
SNDRV_PCM_RATE_48000 |
.fifo_size = 0
};
-static snd_pcm_hardware_t snd_hdsp_capture_subinfo =
+static struct snd_pcm_hardware snd_hdsp_capture_subinfo =
{
.info = (SNDRV_PCM_INFO_MMAP |
SNDRV_PCM_INFO_MMAP_VALID |
SNDRV_PCM_INFO_NONINTERLEAVED |
SNDRV_PCM_INFO_SYNC_START),
+#ifdef SNDRV_BIG_ENDIAN
+ .formats = SNDRV_PCM_FMTBIT_S32_BE,
+#else
.formats = SNDRV_PCM_FMTBIT_S32_LE,
+#endif
.rates = (SNDRV_PCM_RATE_32000 |
SNDRV_PCM_RATE_44100 |
SNDRV_PCM_RATE_48000 |
static unsigned int hdsp_period_sizes[] = { 64, 128, 256, 512, 1024, 2048, 4096, 8192 };
-#define HDSP_PERIOD_SIZES sizeof(hdsp_period_sizes) / sizeof(hdsp_period_sizes[0])
-
-static snd_pcm_hw_constraint_list_t hdsp_hw_constraints_period_sizes = {
- .count = HDSP_PERIOD_SIZES,
+static struct snd_pcm_hw_constraint_list hdsp_hw_constraints_period_sizes = {
+ .count = ARRAY_SIZE(hdsp_period_sizes),
.list = hdsp_period_sizes,
.mask = 0
};
static unsigned int hdsp_9632_sample_rates[] = { 32000, 44100, 48000, 64000, 88200, 96000, 128000, 176400, 192000 };
-#define HDSP_9632_SAMPLE_RATES sizeof(hdsp_9632_sample_rates) / sizeof(hdsp_9632_sample_rates[0])
-
-static snd_pcm_hw_constraint_list_t hdsp_hw_constraints_9632_sample_rates = {
- .count = HDSP_9632_SAMPLE_RATES,
+static struct snd_pcm_hw_constraint_list hdsp_hw_constraints_9632_sample_rates = {
+ .count = ARRAY_SIZE(hdsp_9632_sample_rates),
.list = hdsp_9632_sample_rates,
.mask = 0
};
-static int snd_hdsp_hw_rule_in_channels(snd_pcm_hw_params_t *params,
- snd_pcm_hw_rule_t *rule)
+static int snd_hdsp_hw_rule_in_channels(struct snd_pcm_hw_params *params,
+ struct snd_pcm_hw_rule *rule)
{
- hdsp_t *hdsp = rule->private;
- snd_interval_t *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
+ struct hdsp *hdsp = rule->private;
+ struct snd_interval *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
if (hdsp->io_type == H9632) {
unsigned int list[3];
list[0] = hdsp->qs_in_channels;
}
}
-static int snd_hdsp_hw_rule_out_channels(snd_pcm_hw_params_t *params,
- snd_pcm_hw_rule_t *rule)
+static int snd_hdsp_hw_rule_out_channels(struct snd_pcm_hw_params *params,
+ struct snd_pcm_hw_rule *rule)
{
unsigned int list[3];
- hdsp_t *hdsp = rule->private;
- snd_interval_t *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
+ struct hdsp *hdsp = rule->private;
+ struct snd_interval *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
if (hdsp->io_type == H9632) {
list[0] = hdsp->qs_out_channels;
list[1] = hdsp->ds_out_channels;
return snd_interval_list(c, 2, list, 0);
}
-static int snd_hdsp_hw_rule_in_channels_rate(snd_pcm_hw_params_t *params,
- snd_pcm_hw_rule_t *rule)
+static int snd_hdsp_hw_rule_in_channels_rate(struct snd_pcm_hw_params *params,
+ struct snd_pcm_hw_rule *rule)
{
- hdsp_t *hdsp = rule->private;
- snd_interval_t *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
- snd_interval_t *r = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
+ struct hdsp *hdsp = rule->private;
+ struct snd_interval *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
+ struct snd_interval *r = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
if (r->min > 96000 && hdsp->io_type == H9632) {
- snd_interval_t t = {
+ struct snd_interval t = {
.min = hdsp->qs_in_channels,
.max = hdsp->qs_in_channels,
.integer = 1,
};
return snd_interval_refine(c, &t);
} else if (r->min > 48000 && r->max <= 96000) {
- snd_interval_t t = {
+ struct snd_interval t = {
.min = hdsp->ds_in_channels,
.max = hdsp->ds_in_channels,
.integer = 1,
};
return snd_interval_refine(c, &t);
} else if (r->max < 64000) {
- snd_interval_t t = {
+ struct snd_interval t = {
.min = hdsp->ss_in_channels,
.max = hdsp->ss_in_channels,
.integer = 1,
return 0;
}
-static int snd_hdsp_hw_rule_out_channels_rate(snd_pcm_hw_params_t *params,
- snd_pcm_hw_rule_t *rule)
+static int snd_hdsp_hw_rule_out_channels_rate(struct snd_pcm_hw_params *params,
+ struct snd_pcm_hw_rule *rule)
{
- hdsp_t *hdsp = rule->private;
- snd_interval_t *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
- snd_interval_t *r = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
+ struct hdsp *hdsp = rule->private;
+ struct snd_interval *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
+ struct snd_interval *r = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
if (r->min > 96000 && hdsp->io_type == H9632) {
- snd_interval_t t = {
+ struct snd_interval t = {
.min = hdsp->qs_out_channels,
.max = hdsp->qs_out_channels,
.integer = 1,
};
return snd_interval_refine(c, &t);
} else if (r->min > 48000 && r->max <= 96000) {
- snd_interval_t t = {
+ struct snd_interval t = {
.min = hdsp->ds_out_channels,
.max = hdsp->ds_out_channels,
.integer = 1,
};
return snd_interval_refine(c, &t);
} else if (r->max < 64000) {
- snd_interval_t t = {
+ struct snd_interval t = {
.min = hdsp->ss_out_channels,
.max = hdsp->ss_out_channels,
.integer = 1,
return 0;
}
-static int snd_hdsp_hw_rule_rate_out_channels(snd_pcm_hw_params_t *params,
- snd_pcm_hw_rule_t *rule)
+static int snd_hdsp_hw_rule_rate_out_channels(struct snd_pcm_hw_params *params,
+ struct snd_pcm_hw_rule *rule)
{
- hdsp_t *hdsp = rule->private;
- snd_interval_t *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
- snd_interval_t *r = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
+ struct hdsp *hdsp = rule->private;
+ struct snd_interval *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
+ struct snd_interval *r = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
if (c->min >= hdsp->ss_out_channels) {
- snd_interval_t t = {
+ struct snd_interval t = {
.min = 32000,
.max = 48000,
.integer = 1,
};
return snd_interval_refine(r, &t);
} else if (c->max <= hdsp->qs_out_channels && hdsp->io_type == H9632) {
- snd_interval_t t = {
+ struct snd_interval t = {
.min = 128000,
.max = 192000,
.integer = 1,
};
return snd_interval_refine(r, &t);
} else if (c->max <= hdsp->ds_out_channels) {
- snd_interval_t t = {
+ struct snd_interval t = {
.min = 64000,
.max = 96000,
.integer = 1,
return 0;
}
-static int snd_hdsp_hw_rule_rate_in_channels(snd_pcm_hw_params_t *params,
- snd_pcm_hw_rule_t *rule)
+static int snd_hdsp_hw_rule_rate_in_channels(struct snd_pcm_hw_params *params,
+ struct snd_pcm_hw_rule *rule)
{
- hdsp_t *hdsp = rule->private;
- snd_interval_t *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
- snd_interval_t *r = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
+ struct hdsp *hdsp = rule->private;
+ struct snd_interval *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
+ struct snd_interval *r = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
if (c->min >= hdsp->ss_in_channels) {
- snd_interval_t t = {
+ struct snd_interval t = {
.min = 32000,
.max = 48000,
.integer = 1,
};
return snd_interval_refine(r, &t);
} else if (c->max <= hdsp->qs_in_channels && hdsp->io_type == H9632) {
- snd_interval_t t = {
+ struct snd_interval t = {
.min = 128000,
.max = 192000,
.integer = 1,
};
return snd_interval_refine(r, &t);
} else if (c->max <= hdsp->ds_in_channels) {
- snd_interval_t t = {
+ struct snd_interval t = {
.min = 64000,
.max = 96000,
.integer = 1,
return 0;
}
-static int snd_hdsp_playback_open(snd_pcm_substream_t *substream)
+static int snd_hdsp_playback_open(struct snd_pcm_substream *substream)
{
- hdsp_t *hdsp = _snd_pcm_substream_chip(substream);
- unsigned long flags;
- snd_pcm_runtime_t *runtime = substream->runtime;
+ struct hdsp *hdsp = snd_pcm_substream_chip(substream);
+ struct snd_pcm_runtime *runtime = substream->runtime;
- if (hdsp_check_for_iobox (hdsp)) {
+ if (hdsp_check_for_iobox (hdsp))
return -EIO;
- }
- if (hdsp_check_for_firmware(hdsp)) {
- if (hdsp->state & HDSP_FirmwareCached) {
- if (snd_hdsp_load_firmware_from_cache(hdsp) != 0) {
- snd_printk("Firmware loading from cache failed, please upload manually.\n");
- }
- } else {
- snd_printk("No firmware loaded nor cached, please upload firmware.\n");
- }
+ if (hdsp_check_for_firmware(hdsp, 1))
return -EIO;
- }
- spin_lock_irqsave(&hdsp->lock, flags);
+ spin_lock_irq(&hdsp->lock);
snd_pcm_set_sync(substream);
runtime->dma_area = hdsp->playback_buffer;
runtime->dma_bytes = HDSP_DMA_AREA_BYTES;
- if (hdsp->capture_substream == NULL) {
- hdsp_stop_audio(hdsp);
- hdsp_set_thru(hdsp, -1, 0);
- }
-
hdsp->playback_pid = current->pid;
hdsp->playback_substream = substream;
- spin_unlock_irqrestore(&hdsp->lock, flags);
+ spin_unlock_irq(&hdsp->lock);
snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24);
snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, &hdsp_hw_constraints_period_sizes);
- if (hdsp->io_type == H9632) {
- runtime->hw.channels_min = hdsp->qs_out_channels;
- runtime->hw.channels_max = hdsp->ss_out_channels;
+ if (hdsp->clock_source_locked) {
+ runtime->hw.rate_min = runtime->hw.rate_max = hdsp->system_sample_rate;
+ } else if (hdsp->io_type == H9632) {
runtime->hw.rate_max = 192000;
runtime->hw.rates = SNDRV_PCM_RATE_KNOT;
snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hdsp_hw_constraints_9632_sample_rates);
}
+ if (hdsp->io_type == H9632) {
+ runtime->hw.channels_min = hdsp->qs_out_channels;
+ runtime->hw.channels_max = hdsp->ss_out_channels;
+ }
snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
snd_hdsp_hw_rule_out_channels, hdsp,
return 0;
}
-static int snd_hdsp_playback_release(snd_pcm_substream_t *substream)
+static int snd_hdsp_playback_release(struct snd_pcm_substream *substream)
{
- hdsp_t *hdsp = _snd_pcm_substream_chip(substream);
- unsigned long flags;
+ struct hdsp *hdsp = snd_pcm_substream_chip(substream);
- spin_lock_irqsave(&hdsp->lock, flags);
+ spin_lock_irq(&hdsp->lock);
hdsp->playback_pid = -1;
hdsp->playback_substream = NULL;
- spin_unlock_irqrestore(&hdsp->lock, flags);
+ spin_unlock_irq(&hdsp->lock);
hdsp->spdif_ctl->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_INACTIVE;
snd_ctl_notify(hdsp->card, SNDRV_CTL_EVENT_MASK_VALUE |
}
-static int snd_hdsp_capture_open(snd_pcm_substream_t *substream)
+static int snd_hdsp_capture_open(struct snd_pcm_substream *substream)
{
- hdsp_t *hdsp = _snd_pcm_substream_chip(substream);
- unsigned long flags;
- snd_pcm_runtime_t *runtime = substream->runtime;
+ struct hdsp *hdsp = snd_pcm_substream_chip(substream);
+ struct snd_pcm_runtime *runtime = substream->runtime;
- if (hdsp_check_for_iobox (hdsp)) {
+ if (hdsp_check_for_iobox (hdsp))
return -EIO;
- }
- if (hdsp_check_for_firmware(hdsp)) {
- if (hdsp->state & HDSP_FirmwareCached) {
- if (snd_hdsp_load_firmware_from_cache(hdsp) != 0) {
- snd_printk("Firmware loading from cache failed, please upload manually.\n");
- }
- } else {
- snd_printk("No firmware loaded nor cached, please upload firmware.\n");
- }
+ if (hdsp_check_for_firmware(hdsp, 1))
return -EIO;
- }
- spin_lock_irqsave(&hdsp->lock, flags);
+ spin_lock_irq(&hdsp->lock);
snd_pcm_set_sync(substream);
runtime->dma_area = hdsp->capture_buffer;
runtime->dma_bytes = HDSP_DMA_AREA_BYTES;
- if (hdsp->playback_substream == NULL) {
- hdsp_stop_audio(hdsp);
- hdsp_set_thru(hdsp, -1, 0);
- }
-
hdsp->capture_pid = current->pid;
hdsp->capture_substream = substream;
- spin_unlock_irqrestore(&hdsp->lock, flags);
+ spin_unlock_irq(&hdsp->lock);
snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24);
snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, &hdsp_hw_constraints_period_sizes);
return 0;
}
-static int snd_hdsp_capture_release(snd_pcm_substream_t *substream)
+static int snd_hdsp_capture_release(struct snd_pcm_substream *substream)
{
- hdsp_t *hdsp = _snd_pcm_substream_chip(substream);
- unsigned long flags;
+ struct hdsp *hdsp = snd_pcm_substream_chip(substream);
- spin_lock_irqsave(&hdsp->lock, flags);
+ spin_lock_irq(&hdsp->lock);
hdsp->capture_pid = -1;
hdsp->capture_substream = NULL;
- spin_unlock_irqrestore(&hdsp->lock, flags);
+ spin_unlock_irq(&hdsp->lock);
return 0;
}
-static int snd_hdsp_hwdep_dummy_op(snd_hwdep_t *hw, struct file *file)
+static int snd_hdsp_hwdep_dummy_op(struct snd_hwdep *hw, struct file *file)
{
/* we have nothing to initialize but the call is required */
return 0;
}
-static int snd_hdsp_hwdep_ioctl(snd_hwdep_t *hw, struct file *file, unsigned int cmd, unsigned long arg)
+/* helper functions for copying meter values */
+static inline int copy_u32_le(void __user *dest, void __iomem *src)
+{
+ u32 val = readl(src);
+ return copy_to_user(dest, &val, 4);
+}
+
+static inline int copy_u64_le(void __user *dest, void __iomem *src_low, void __iomem *src_high)
+{
+ u32 rms_low, rms_high;
+ u64 rms;
+ rms_low = readl(src_low);
+ rms_high = readl(src_high);
+ rms = ((u64)rms_high << 32) | rms_low;
+ return copy_to_user(dest, &rms, 8);
+}
+
+static inline int copy_u48_le(void __user *dest, void __iomem *src_low, void __iomem *src_high)
+{
+ u32 rms_low, rms_high;
+ u64 rms;
+ rms_low = readl(src_low) & 0xffffff00;
+ rms_high = readl(src_high) & 0xffffff00;
+ rms = ((u64)rms_high << 32) | rms_low;
+ return copy_to_user(dest, &rms, 8);
+}
+
+static int hdsp_9652_get_peak(struct hdsp *hdsp, struct hdsp_peak_rms __user *peak_rms)
+{
+ int doublespeed = 0;
+ int i, j, channels, ofs;
+
+ if (hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DoubleSpeedStatus)
+ doublespeed = 1;
+ channels = doublespeed ? 14 : 26;
+ for (i = 0, j = 0; i < 26; ++i) {
+ if (doublespeed && (i & 4))
+ continue;
+ ofs = HDSP_9652_peakBase - j * 4;
+ if (copy_u32_le(&peak_rms->input_peaks[i], hdsp->iobase + ofs))
+ return -EFAULT;
+ ofs -= channels * 4;
+ if (copy_u32_le(&peak_rms->playback_peaks[i], hdsp->iobase + ofs))
+ return -EFAULT;
+ ofs -= channels * 4;
+ if (copy_u32_le(&peak_rms->output_peaks[i], hdsp->iobase + ofs))
+ return -EFAULT;
+ ofs = HDSP_9652_rmsBase + j * 8;
+ if (copy_u48_le(&peak_rms->input_rms[i], hdsp->iobase + ofs,
+ hdsp->iobase + ofs + 4))
+ return -EFAULT;
+ ofs += channels * 8;
+ if (copy_u48_le(&peak_rms->playback_rms[i], hdsp->iobase + ofs,
+ hdsp->iobase + ofs + 4))
+ return -EFAULT;
+ ofs += channels * 8;
+ if (copy_u48_le(&peak_rms->output_rms[i], hdsp->iobase + ofs,
+ hdsp->iobase + ofs + 4))
+ return -EFAULT;
+ j++;
+ }
+ return 0;
+}
+
+static int hdsp_9632_get_peak(struct hdsp *hdsp, struct hdsp_peak_rms __user *peak_rms)
{
- hdsp_t *hdsp = (hdsp_t *)hw->private_data;
+ int i, j;
+ struct hdsp_9632_meters __iomem *m;
+ int doublespeed = 0;
+
+ if (hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DoubleSpeedStatus)
+ doublespeed = 1;
+ m = (struct hdsp_9632_meters __iomem *)(hdsp->iobase+HDSP_9632_metersBase);
+ for (i = 0, j = 0; i < 16; ++i, ++j) {
+ if (copy_u32_le(&peak_rms->input_peaks[i], &m->input_peak[j]))
+ return -EFAULT;
+ if (copy_u32_le(&peak_rms->playback_peaks[i], &m->playback_peak[j]))
+ return -EFAULT;
+ if (copy_u32_le(&peak_rms->output_peaks[i], &m->output_peak[j]))
+ return -EFAULT;
+ if (copy_u64_le(&peak_rms->input_rms[i], &m->input_rms_low[j],
+ &m->input_rms_high[j]))
+ return -EFAULT;
+ if (copy_u64_le(&peak_rms->playback_rms[i], &m->playback_rms_low[j],
+ &m->playback_rms_high[j]))
+ return -EFAULT;
+ if (copy_u64_le(&peak_rms->output_rms[i], &m->output_rms_low[j],
+ &m->output_rms_high[j]))
+ return -EFAULT;
+ if (doublespeed && i == 3) i += 4;
+ }
+ return 0;
+}
+
+static int hdsp_get_peak(struct hdsp *hdsp, struct hdsp_peak_rms __user *peak_rms)
+{
+ int i;
+
+ for (i = 0; i < 26; i++) {
+ if (copy_u32_le(&peak_rms->playback_peaks[i],
+ hdsp->iobase + HDSP_playbackPeakLevel + i * 4))
+ return -EFAULT;
+ if (copy_u32_le(&peak_rms->input_peaks[i],
+ hdsp->iobase + HDSP_inputPeakLevel + i * 4))
+ return -EFAULT;
+ }
+ for (i = 0; i < 28; i++) {
+ if (copy_u32_le(&peak_rms->output_peaks[i],
+ hdsp->iobase + HDSP_outputPeakLevel + i * 4))
+ return -EFAULT;
+ }
+ for (i = 0; i < 26; ++i) {
+ if (copy_u64_le(&peak_rms->playback_rms[i],
+ hdsp->iobase + HDSP_playbackRmsLevel + i * 8 + 4,
+ hdsp->iobase + HDSP_playbackRmsLevel + i * 8))
+ return -EFAULT;
+ if (copy_u64_le(&peak_rms->input_rms[i],
+ hdsp->iobase + HDSP_inputRmsLevel + i * 8 + 4,
+ hdsp->iobase + HDSP_inputRmsLevel + i * 8))
+ return -EFAULT;
+ }
+ return 0;
+}
+
+static int snd_hdsp_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, unsigned int cmd, unsigned long arg)
+{
+ struct hdsp *hdsp = (struct hdsp *)hw->private_data;
void __user *argp = (void __user *)arg;
switch (cmd) {
case SNDRV_HDSP_IOCTL_GET_PEAK_RMS: {
- hdsp_peak_rms_t __user *peak_rms;
- int i;
-
- if (hdsp->io_type == H9652) {
- unsigned long rms_low, rms_high;
- int doublespeed = 0;
- if (hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DoubleSpeedStatus)
- doublespeed = 1;
- peak_rms = (hdsp_peak_rms_t __user *)arg;
- for (i = 0; i < 26; ++i) {
- if (!(doublespeed && (i & 4))) {
- if (copy_to_user_fromio((void __user *)peak_rms->input_peaks+i*4, hdsp->iobase+HDSP_9652_peakBase-i*4, 4) != 0)
- return -EFAULT;
- if (copy_to_user_fromio((void __user *)peak_rms->playback_peaks+i*4, hdsp->iobase+HDSP_9652_peakBase-(doublespeed ? 14 : 26)*4-i*4, 4) != 0)
- return -EFAULT;
- if (copy_to_user_fromio((void __user *)peak_rms->output_peaks+i*4, hdsp->iobase+HDSP_9652_peakBase-2*(doublespeed ? 14 : 26)*4-i*4, 4) != 0)
- return -EFAULT;
- rms_low = *(u32 *)(hdsp->iobase+HDSP_9652_rmsBase+i*8) & 0xFFFFFF00;
- rms_high = *(u32 *)(hdsp->iobase+HDSP_9652_rmsBase+i*8+4) & 0xFFFFFF00;
- rms_high += (rms_low >> 24);
- rms_low <<= 8;
- if (copy_to_user((void __user *)peak_rms->input_rms+i*8, &rms_low, 4) != 0)
- return -EFAULT;
- if (copy_to_user((void __user *)peak_rms->input_rms+i*8+4, &rms_high, 4) != 0)
- return -EFAULT;
- rms_low = *(u32 *)(hdsp->iobase+HDSP_9652_rmsBase+(doublespeed ? 14 : 26)*8+i*8) & 0xFFFFFF00;
- rms_high = *(u32 *)(hdsp->iobase+HDSP_9652_rmsBase+(doublespeed ? 14 : 26)*8+i*8+4) & 0xFFFFFF00;
- rms_high += (rms_low >> 24);
- rms_low <<= 8;
- if (copy_to_user((void __user *)peak_rms->playback_rms+i*8, &rms_low, 4) != 0)
- return -EFAULT;
- if (copy_to_user((void __user *)peak_rms->playback_rms+i*8+4, &rms_high, 4) != 0)
- return -EFAULT;
- rms_low = *(u32 *)(hdsp->iobase+HDSP_9652_rmsBase+2*(doublespeed ? 14 : 26)*8+i*8) & 0xFFFFFF00;
- rms_high = *(u32 *)(hdsp->iobase+HDSP_9652_rmsBase+2*(doublespeed ? 14 : 26)*8+i*8+4) & 0xFFFFFF00;
- rms_high += (rms_low >> 24);
- rms_low <<= 8;
- if (copy_to_user((void __user *)peak_rms->output_rms+i*8, &rms_low, 4) != 0)
- return -EFAULT;
- if (copy_to_user((void __user *)peak_rms->output_rms+i*8+4, &rms_high, 4) != 0)
- return -EFAULT;
- }
- }
- return 0;
- }
- if (hdsp->io_type == H9632) {
- int j;
- hdsp_9632_meters_t *m;
- int doublespeed = 0;
- if (hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DoubleSpeedStatus)
- doublespeed = 1;
- m = (hdsp_9632_meters_t *)(hdsp->iobase+HDSP_9632_metersBase);
- peak_rms = (hdsp_peak_rms_t __user *)arg;
- for (i = 0, j = 0; i < 16; ++i, ++j) {
- if (copy_to_user((void __user *)peak_rms->input_peaks+i*4, &(m->input_peak[j]), 4) != 0)
- return -EFAULT;
- if (copy_to_user((void __user *)peak_rms->playback_peaks+i*4, &(m->playback_peak[j]), 4) != 0)
- return -EFAULT;
- if (copy_to_user((void __user *)peak_rms->output_peaks+i*4, &(m->output_peak[j]), 4) != 0)
- return -EFAULT;
- if (copy_to_user((void __user *)peak_rms->input_rms+i*8, &(m->input_rms_low[j]), 4) != 0)
- return -EFAULT;
- if (copy_to_user((void __user *)peak_rms->playback_rms+i*8, &(m->playback_rms_low[j]), 4) != 0)
- return -EFAULT;
- if (copy_to_user((void __user *)peak_rms->output_rms+i*8, &(m->output_rms_low[j]), 4) != 0)
- return -EFAULT;
- if (copy_to_user((void __user *)peak_rms->input_rms+i*8+4, &(m->input_rms_high[j]), 4) != 0)
- return -EFAULT;
- if (copy_to_user((void __user *)peak_rms->playback_rms+i*8+4, &(m->playback_rms_high[j]), 4) != 0)
- return -EFAULT;
- if (copy_to_user((void __user *)peak_rms->output_rms+i*8+4, &(m->output_rms_high[j]), 4) != 0)
- return -EFAULT;
- if (doublespeed && i == 3) i += 4;
- }
- return 0;
- }
+ struct hdsp_peak_rms __user *peak_rms = (struct hdsp_peak_rms __user *)arg;
+
if (!(hdsp->state & HDSP_FirmwareLoaded)) {
- snd_printk("firmware needs to be uploaded to the card.\n");
+ snd_printk(KERN_ERR "Hammerfall-DSP: firmware needs to be uploaded to the card.\n");
return -EINVAL;
}
- peak_rms = (hdsp_peak_rms_t __user *)arg;
- for (i = 0; i < 26; ++i) {
- if (copy_to_user((void __user *)peak_rms->playback_peaks+i*4, (void *)hdsp->iobase+HDSP_playbackPeakLevel+i*4, 4) != 0)
- return -EFAULT;
- if (copy_to_user((void __user *)peak_rms->input_peaks+i*4, (void *)hdsp->iobase+HDSP_inputPeakLevel+i*4, 4) != 0)
- return -EFAULT;
- }
- for (i = 0; i < 26; ++i) {
- if (copy_to_user((void __user *)peak_rms->playback_rms+i*8+4, (void *)hdsp->iobase+HDSP_playbackRmsLevel+i*8, 4) != 0)
- return -EFAULT;
- if (copy_to_user((void __user *)peak_rms->playback_rms+i*8, (void *)hdsp->iobase+HDSP_playbackRmsLevel+i*8+4, 4) != 0)
- return -EFAULT;
- if (copy_to_user((void __user *)peak_rms->input_rms+i*8+4, (void *)hdsp->iobase+HDSP_inputRmsLevel+i*8, 4) != 0)
- return -EFAULT;
- if (copy_to_user((void __user *)peak_rms->input_rms+i*8, (void *)hdsp->iobase+HDSP_inputRmsLevel+i*8+4, 4) != 0)
- return -EFAULT;
- }
- for (i = 0; i < 28; ++i) {
- if (copy_to_user((void __user *)peak_rms->output_peaks+i*4, (void *)hdsp->iobase+HDSP_outputPeakLevel+i*4, 4) != 0)
- return -EFAULT;
+
+ switch (hdsp->io_type) {
+ case H9652:
+ return hdsp_9652_get_peak(hdsp, peak_rms);
+ case H9632:
+ return hdsp_9632_get_peak(hdsp, peak_rms);
+ default:
+ return hdsp_get_peak(hdsp, peak_rms);
}
- break;
}
case SNDRV_HDSP_IOCTL_GET_CONFIG_INFO: {
- hdsp_config_info_t info;
+ struct hdsp_config_info info;
unsigned long flags;
int i;
if (!(hdsp->state & HDSP_FirmwareLoaded)) {
- snd_printk("Firmware needs to be uploaded to the card.\n");
+ snd_printk(KERN_ERR "Hammerfall-DSP: Firmware needs to be uploaded to the card.\n");
return -EINVAL;
}
spin_lock_irqsave(&hdsp->lock, flags);
info.pref_sync_ref = (unsigned char)hdsp_pref_sync_ref(hdsp);
info.wordclock_sync_check = (unsigned char)hdsp_wc_sync_check(hdsp);
- if (hdsp->io_type != H9632) {
+ if (hdsp->io_type != H9632)
info.adatsync_sync_check = (unsigned char)hdsp_adatsync_sync_check(hdsp);
- }
info.spdif_sync_check = (unsigned char)hdsp_spdif_sync_check(hdsp);
- for (i = 0; i < ((hdsp->io_type != Multiface && hdsp->io_type != H9632) ? 3 : 1); ++i) {
+ for (i = 0; i < ((hdsp->io_type != Multiface && hdsp->io_type != H9632) ? 3 : 1); ++i)
info.adat_sync_check[i] = (unsigned char)hdsp_adat_sync_check(hdsp, i);
- }
info.spdif_in = (unsigned char)hdsp_spdif_in(hdsp);
info.spdif_out = (unsigned char)hdsp_spdif_out(hdsp);
info.spdif_professional = (unsigned char)hdsp_spdif_professional(hdsp);
info.clock_source = (unsigned char)hdsp_clock_source(hdsp);
info.autosync_ref = (unsigned char)hdsp_autosync_ref(hdsp);
info.line_out = (unsigned char)hdsp_line_out(hdsp);
- info.passthru = (unsigned char)hdsp->passthru;
if (hdsp->io_type == H9632) {
info.da_gain = (unsigned char)hdsp_da_gain(hdsp);
info.ad_gain = (unsigned char)hdsp_ad_gain(hdsp);
info.xlr_breakout_cable = (unsigned char)hdsp_xlr_breakout_cable(hdsp);
}
- if (hdsp->io_type == H9632 || hdsp->io_type == H9652) {
+ if (hdsp->io_type == H9632 || hdsp->io_type == H9652)
info.analog_extension_board = (unsigned char)hdsp_aeb(hdsp);
- }
spin_unlock_irqrestore(&hdsp->lock, flags);
if (copy_to_user(argp, &info, sizeof(info)))
return -EFAULT;
break;
}
case SNDRV_HDSP_IOCTL_GET_9632_AEB: {
- hdsp_9632_aeb_t h9632_aeb;
+ struct hdsp_9632_aeb h9632_aeb;
if (hdsp->io_type != H9632) return -EINVAL;
h9632_aeb.aebi = hdsp->ss_in_channels - H9632_SS_CHANNELS;
break;
}
case SNDRV_HDSP_IOCTL_GET_VERSION: {
- hdsp_version_t hdsp_version;
+ struct hdsp_version hdsp_version;
int err;
if (hdsp->io_type == H9652 || hdsp->io_type == H9632) return -EINVAL;
if (hdsp->io_type == Undefined) {
- if ((err = hdsp_get_iobox_version(hdsp)) < 0) {
+ if ((err = hdsp_get_iobox_version(hdsp)) < 0)
return err;
- }
}
hdsp_version.io_type = hdsp->io_type;
hdsp_version.firmware_rev = hdsp->firmware_rev;
- if ((err = copy_to_user(argp, &hdsp_version, sizeof(hdsp_version)))) {
+ if ((err = copy_to_user(argp, &hdsp_version, sizeof(hdsp_version))))
return -EFAULT;
- }
break;
}
case SNDRV_HDSP_IOCTL_UPLOAD_FIRMWARE: {
- hdsp_firmware_t __user *firmware;
- unsigned long __user *firmware_data;
+ struct hdsp_firmware __user *firmware;
+ u32 __user *firmware_data;
int err;
if (hdsp->io_type == H9652 || hdsp->io_type == H9632) return -EINVAL;
/* SNDRV_HDSP_IOCTL_GET_VERSION must have been called */
if (hdsp->io_type == Undefined) return -EINVAL;
- snd_printk("initializing firmware upload\n");
- firmware = (hdsp_firmware_t __user *)argp;
+ if (hdsp->state & (HDSP_FirmwareCached | HDSP_FirmwareLoaded))
+ return -EBUSY;
+
+ snd_printk(KERN_INFO "Hammerfall-DSP: initializing firmware upload\n");
+ firmware = (struct hdsp_firmware __user *)argp;
- if (get_user(firmware_data, &firmware->firmware_data)) {
+ if (get_user(firmware_data, &firmware->firmware_data))
return -EFAULT;
- }
- if (hdsp_check_for_iobox (hdsp)) {
+ if (hdsp_check_for_iobox (hdsp))
return -EIO;
- }
- if (copy_from_user(hdsp->firmware_cache, firmware_data, sizeof(unsigned long)*24413) != 0) {
+ if (copy_from_user(hdsp->firmware_cache, firmware_data, sizeof(hdsp->firmware_cache)) != 0)
return -EFAULT;
- }
hdsp->state |= HDSP_FirmwareCached;
- if ((err = snd_hdsp_load_firmware_from_cache(hdsp)) < 0) {
+ if ((err = snd_hdsp_load_firmware_from_cache(hdsp)) < 0)
return err;
- }
if (!(hdsp->state & HDSP_InitializationComplete)) {
- snd_hdsp_initialize_channels(hdsp);
-
+ if ((err = snd_hdsp_enable_io(hdsp)) < 0)
+ return err;
+
+ snd_hdsp_initialize_channels(hdsp);
snd_hdsp_initialize_midi_flush(hdsp);
if ((err = snd_hdsp_create_alsa_devices(hdsp->card, hdsp)) < 0) {
- snd_printk("error creating alsa devices\n");
- return err;
+ snd_printk(KERN_ERR "Hammerfall-DSP: error creating alsa devices\n");
+ return err;
}
}
break;
}
case SNDRV_HDSP_IOCTL_GET_MIXER: {
- hdsp_mixer_t __user *mixer = (hdsp_mixer_t __user *)argp;
+ struct hdsp_mixer __user *mixer = (struct hdsp_mixer __user *)argp;
if (copy_to_user(mixer->matrix, hdsp->mixer_matrix, sizeof(unsigned short)*HDSP_MATRIX_MIXER_SIZE))
return -EFAULT;
break;
return 0;
}
-static snd_pcm_ops_t snd_hdsp_playback_ops = {
+static struct snd_pcm_ops snd_hdsp_playback_ops = {
.open = snd_hdsp_playback_open,
.close = snd_hdsp_playback_release,
.ioctl = snd_hdsp_ioctl,
.silence = snd_hdsp_hw_silence,
};
-static snd_pcm_ops_t snd_hdsp_capture_ops = {
+static struct snd_pcm_ops snd_hdsp_capture_ops = {
.open = snd_hdsp_capture_open,
.close = snd_hdsp_capture_release,
.ioctl = snd_hdsp_ioctl,
.copy = snd_hdsp_capture_copy,
};
-static int __devinit snd_hdsp_create_hwdep(snd_card_t *card,
- hdsp_t *hdsp)
+static int __devinit snd_hdsp_create_hwdep(struct snd_card *card,
+ struct hdsp *hdsp)
{
- snd_hwdep_t *hw;
+ struct snd_hwdep *hw;
int err;
if ((err = snd_hwdep_new(card, "HDSP hwdep", 0, &hw)) < 0)
return 0;
}
-static int __devinit snd_hdsp_create_pcm(snd_card_t *card,
- hdsp_t *hdsp)
+static int snd_hdsp_create_pcm(struct snd_card *card, struct hdsp *hdsp)
{
- snd_pcm_t *pcm;
+ struct snd_pcm *pcm;
int err;
if ((err = snd_pcm_new(card, hdsp->card_name, 0, 1, 1, &pcm)) < 0)
return 0;
}
-static inline void snd_hdsp_9652_enable_mixer (hdsp_t *hdsp)
+static void snd_hdsp_9652_enable_mixer (struct hdsp *hdsp)
{
hdsp->control2_register |= HDSP_9652_ENABLE_MIXER;
hdsp_write (hdsp, HDSP_control2Reg, hdsp->control2_register);
}
-static inline void snd_hdsp_9652_disable_mixer (hdsp_t *hdsp)
-{
- hdsp->control2_register &= ~HDSP_9652_ENABLE_MIXER;
- hdsp_write (hdsp, HDSP_control2Reg, hdsp->control2_register);
-}
-
-static inline int snd_hdsp_enable_io (hdsp_t *hdsp)
+static int snd_hdsp_enable_io (struct hdsp *hdsp)
{
int i;
if (hdsp_fifo_wait (hdsp, 0, 100)) {
+ snd_printk(KERN_ERR "Hammerfall-DSP: enable_io fifo_wait failed\n");
return -EIO;
}
return 0;
}
-static inline void snd_hdsp_initialize_channels(hdsp_t *hdsp)
+static void snd_hdsp_initialize_channels(struct hdsp *hdsp)
{
int status, aebi_channels, aebo_channels;
}
}
-static inline void snd_hdsp_initialize_midi_flush (hdsp_t *hdsp)
+static void snd_hdsp_initialize_midi_flush (struct hdsp *hdsp)
{
snd_hdsp_flush_midi_input (hdsp, 0);
snd_hdsp_flush_midi_input (hdsp, 1);
}
-static int __devinit snd_hdsp_create_alsa_devices(snd_card_t *card, hdsp_t *hdsp)
+static int snd_hdsp_create_alsa_devices(struct snd_card *card, struct hdsp *hdsp)
{
int err;
if ((err = snd_hdsp_create_pcm(card, hdsp)) < 0) {
- snd_printk("Error creating pcm interface\n");
+ snd_printk(KERN_ERR "Hammerfall-DSP: Error creating pcm interface\n");
return err;
}
if ((err = snd_hdsp_create_midi(card, hdsp, 0)) < 0) {
- snd_printk("Error creating first midi interface\n");
+ snd_printk(KERN_ERR "Hammerfall-DSP: Error creating first midi interface\n");
return err;
}
-
- if ((err = snd_hdsp_create_midi(card, hdsp, 1)) < 0) {
- snd_printk("Error creating second midi interface\n");
- return err;
+ if (hdsp->io_type == Digiface || hdsp->io_type == H9652) {
+ if ((err = snd_hdsp_create_midi(card, hdsp, 1)) < 0) {
+ snd_printk(KERN_ERR "Hammerfall-DSP: Error creating second midi interface\n");
+ return err;
+ }
}
if ((err = snd_hdsp_create_controls(card, hdsp)) < 0) {
- snd_printk("Error creating ctl interface\n");
+ snd_printk(KERN_ERR "Hammerfall-DSP: Error creating ctl interface\n");
return err;
}
hdsp->playback_substream = NULL;
if ((err = snd_hdsp_set_defaults(hdsp)) < 0) {
- snd_printk("Error setting default values\n");
+ snd_printk(KERN_ERR "Hammerfall-DSP: Error setting default values\n");
return err;
}
if (!(hdsp->state & HDSP_InitializationComplete)) {
+ strcpy(card->shortname, "Hammerfall DSP");
sprintf(card->longname, "%s at 0x%lx, irq %d", hdsp->card_name,
hdsp->port, hdsp->irq);
if ((err = snd_card_register(card)) < 0) {
- snd_printk("error registering card\n");
+ snd_printk(KERN_ERR "Hammerfall-DSP: error registering card\n");
return err;
}
hdsp->state |= HDSP_InitializationComplete;
return 0;
}
-static int __devinit snd_hdsp_create(snd_card_t *card,
- hdsp_t *hdsp,
- int precise_ptr)
+#ifdef HDSP_FW_LOADER
+/* load firmware via hotplug fw loader */
+static int __devinit hdsp_request_fw_loader(struct hdsp *hdsp)
+{
+ const char *fwfile;
+ const struct firmware *fw;
+ int err;
+
+ if (hdsp->io_type == H9652 || hdsp->io_type == H9632)
+ return 0;
+ if (hdsp->io_type == Undefined) {
+ if ((err = hdsp_get_iobox_version(hdsp)) < 0)
+ return err;
+ if (hdsp->io_type == H9652 || hdsp->io_type == H9632)
+ return 0;
+ }
+
+ /* caution: max length of firmware filename is 30! */
+ switch (hdsp->io_type) {
+ case Multiface:
+ if (hdsp->firmware_rev == 0xa)
+ fwfile = "multiface_firmware.bin";
+ else
+ fwfile = "multiface_firmware_rev11.bin";
+ break;
+ case Digiface:
+ if (hdsp->firmware_rev == 0xa)
+ fwfile = "digiface_firmware.bin";
+ else
+ fwfile = "digiface_firmware_rev11.bin";
+ break;
+ default:
+ snd_printk(KERN_ERR "Hammerfall-DSP: invalid io_type %d\n", hdsp->io_type);
+ return -EINVAL;
+ }
+
+ if (request_firmware(&fw, fwfile, &hdsp->pci->dev)) {
+ snd_printk(KERN_ERR "Hammerfall-DSP: cannot load firmware %s\n", fwfile);
+ return -ENOENT;
+ }
+ if (fw->size < sizeof(hdsp->firmware_cache)) {
+ snd_printk(KERN_ERR "Hammerfall-DSP: too short firmware size %d (expected %d)\n",
+ (int)fw->size, (int)sizeof(hdsp->firmware_cache));
+ release_firmware(fw);
+ return -EINVAL;
+ }
+
+ memcpy(hdsp->firmware_cache, fw->data, sizeof(hdsp->firmware_cache));
+
+ release_firmware(fw);
+
+ hdsp->state |= HDSP_FirmwareCached;
+
+ if ((err = snd_hdsp_load_firmware_from_cache(hdsp)) < 0)
+ return err;
+
+ if (!(hdsp->state & HDSP_InitializationComplete)) {
+ if ((err = snd_hdsp_enable_io(hdsp)) < 0)
+ return err;
+
+ if ((err = snd_hdsp_create_hwdep(hdsp->card, hdsp)) < 0) {
+ snd_printk(KERN_ERR "Hammerfall-DSP: error creating hwdep device\n");
+ return err;
+ }
+ snd_hdsp_initialize_channels(hdsp);
+ snd_hdsp_initialize_midi_flush(hdsp);
+ if ((err = snd_hdsp_create_alsa_devices(hdsp->card, hdsp)) < 0) {
+ snd_printk(KERN_ERR "Hammerfall-DSP: error creating alsa devices\n");
+ return err;
+ }
+ }
+ return 0;
+}
+#endif
+
+static int __devinit snd_hdsp_create(struct snd_card *card,
+ struct hdsp *hdsp)
{
struct pci_dev *pci = hdsp->pci;
int err;
hdsp->irq = -1;
hdsp->state = 0;
- hdsp->midi[0].rmidi = 0;
- hdsp->midi[1].rmidi = 0;
- hdsp->midi[0].input = 0;
- hdsp->midi[1].input = 0;
- hdsp->midi[0].output = 0;
- hdsp->midi[1].output = 0;
+ hdsp->midi[0].rmidi = NULL;
+ hdsp->midi[1].rmidi = NULL;
+ hdsp->midi[0].input = NULL;
+ hdsp->midi[1].input = NULL;
+ hdsp->midi[0].output = NULL;
+ hdsp->midi[1].output = NULL;
+ hdsp->midi[0].pending = 0;
+ hdsp->midi[1].pending = 0;
spin_lock_init(&hdsp->midi[0].lock);
spin_lock_init(&hdsp->midi[1].lock);
- hdsp->iobase = 0;
- hdsp->res_port = 0;
+ hdsp->iobase = NULL;
hdsp->control_register = 0;
hdsp->control2_register = 0;
hdsp->io_type = Undefined;
tasklet_init(&hdsp->midi_tasklet, hdsp_midi_tasklet, (unsigned long)hdsp);
pci_read_config_word(hdsp->pci, PCI_CLASS_REVISION, &hdsp->firmware_rev);
+ hdsp->firmware_rev &= 0xff;
/* From Martin Bjoernsen :
"It is important that the card's latency timer register in
strcpy(card->driver, "H-DSP");
strcpy(card->mixername, "Xilinx FPGA");
- switch (hdsp->firmware_rev & 0xff) {
- case 0xa:
- case 0xb:
- case 0x32:
+ if (hdsp->firmware_rev < 0xa)
+ return -ENODEV;
+ else if (hdsp->firmware_rev < 0x64)
hdsp->card_name = "RME Hammerfall DSP";
- break;
-
- case 0x64:
- case 0x65:
- case 0x68:
+ else if (hdsp->firmware_rev < 0x96) {
hdsp->card_name = "RME HDSP 9652";
is_9652 = 1;
- break;
- case 0x96:
- case 0x97:
+ } else {
hdsp->card_name = "RME HDSP 9632";
hdsp->max_channels = 16;
- is_9632 = 1;
- break;
- default:
- return -ENODEV;
+ is_9632 = 1;
}
- if ((err = pci_enable_device(pci)) < 0) {
+ if ((err = pci_enable_device(pci)) < 0)
return err;
- }
pci_set_master(hdsp->pci);
+ if ((err = pci_request_regions(pci, "hdsp")) < 0)
+ return err;
hdsp->port = pci_resource_start(pci, 0);
-
- if ((hdsp->res_port = request_mem_region(hdsp->port, HDSP_IO_EXTENT, "hdsp")) == NULL) {
- snd_printk("unable to grab memory region 0x%lx-0x%lx\n", hdsp->port, hdsp->port + HDSP_IO_EXTENT - 1);
- return -EBUSY;
- }
-
- if ((hdsp->iobase = (unsigned long) ioremap_nocache(hdsp->port, HDSP_IO_EXTENT)) == 0) {
- snd_printk("unable to remap region 0x%lx-0x%lx\n", hdsp->port, hdsp->port + HDSP_IO_EXTENT - 1);
+ if ((hdsp->iobase = ioremap_nocache(hdsp->port, HDSP_IO_EXTENT)) == NULL) {
+ snd_printk(KERN_ERR "Hammerfall-DSP: unable to remap region 0x%lx-0x%lx\n", hdsp->port, hdsp->port + HDSP_IO_EXTENT - 1);
return -EBUSY;
}
if (request_irq(pci->irq, snd_hdsp_interrupt, SA_INTERRUPT|SA_SHIRQ, "hdsp", (void *)hdsp)) {
- snd_printk("unable to use IRQ %d\n", pci->irq);
+ snd_printk(KERN_ERR "Hammerfall-DSP: unable to use IRQ %d\n", pci->irq);
return -EBUSY;
}
hdsp->irq = pci->irq;
- hdsp->precise_ptr = precise_ptr;
+ hdsp->precise_ptr = 1;
+ hdsp->use_midi_tasklet = 1;
- if ((err = snd_hdsp_initialize_memory(hdsp)) < 0) {
+ if ((err = snd_hdsp_initialize_memory(hdsp)) < 0)
return err;
- }
- if (!is_9652 && !is_9632 && hdsp_check_for_iobox (hdsp)) {
- /* no iobox connected, we defer initialization */
- snd_printk("card initialization pending : waiting for firmware\n");
- if ((err = snd_hdsp_create_hwdep(card, hdsp)) < 0) {
- return err;
+ if (!is_9652 && !is_9632) {
+ /* we wait 2 seconds to let freshly inserted cardbus cards do their hardware init */
+ ssleep(2);
+
+ if ((hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DllError) != 0) {
+#ifdef HDSP_FW_LOADER
+ if ((err = hdsp_request_fw_loader(hdsp)) < 0)
+ /* we don't fail as this can happen
+ if userspace is not ready for
+ firmware upload
+ */
+ snd_printk(KERN_ERR "Hammerfall-DSP: couldn't get firmware from userspace. try using hdsploader\n");
+ else
+ /* init is complete, we return */
+ return 0;
+#endif
+ /* no iobox connected, we defer initialization */
+ snd_printk(KERN_INFO "Hammerfall-DSP: card initialization pending : waiting for firmware\n");
+ if ((err = snd_hdsp_create_hwdep(card, hdsp)) < 0)
+ return err;
+ return 0;
+ } else {
+ snd_printk(KERN_INFO "Hammerfall-DSP: Firmware already present, initializing card.\n");
+ if (hdsp_read(hdsp, HDSP_status2Register) & HDSP_version1)
+ hdsp->io_type = Multiface;
+ else
+ hdsp->io_type = Digiface;
}
- return 0;
}
- if ((err = snd_hdsp_enable_io(hdsp)) != 0) {
+ if ((err = snd_hdsp_enable_io(hdsp)) != 0)
return err;
- }
- if ((hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DllError) != 0) {
- snd_printk("card initialization pending : waiting for firmware\n");
- if ((err = snd_hdsp_create_hwdep(card, hdsp)) < 0) {
- return err;
- }
- return 0;
- }
-
- snd_printk("Firmware already loaded, initializing card.\n");
-
- if (hdsp_read(hdsp, HDSP_status2Register) & HDSP_version1) {
- hdsp->io_type = Multiface;
- } else {
- hdsp->io_type = Digiface;
- }
-
- if (is_9652) {
+ if (is_9652)
hdsp->io_type = H9652;
- }
- if (is_9632) {
+ if (is_9632)
hdsp->io_type = H9632;
- }
- if ((err = snd_hdsp_create_hwdep(card, hdsp)) < 0) {
+ if ((err = snd_hdsp_create_hwdep(card, hdsp)) < 0)
return err;
- }
snd_hdsp_initialize_channels(hdsp);
snd_hdsp_initialize_midi_flush(hdsp);
hdsp->state |= HDSP_FirmwareLoaded;
- if ((err = snd_hdsp_create_alsa_devices(card, hdsp)) < 0) {
+ if ((err = snd_hdsp_create_alsa_devices(card, hdsp)) < 0)
return err;
- }
return 0;
}
-static int snd_hdsp_free(hdsp_t *hdsp)
+static int snd_hdsp_free(struct hdsp *hdsp)
{
- if (hdsp->res_port) {
+ if (hdsp->port) {
/* stop the audio, and cancel all interrupts */
+ tasklet_kill(&hdsp->midi_tasklet);
hdsp->control_register &= ~(HDSP_Start|HDSP_AudioInterruptEnable|HDSP_Midi0InterruptEnable|HDSP_Midi1InterruptEnable);
hdsp_write (hdsp, HDSP_controlRegister, hdsp->control_register);
}
snd_hdsp_free_buffers(hdsp);
if (hdsp->iobase)
- iounmap((void *) hdsp->iobase);
+ iounmap(hdsp->iobase);
- if (hdsp->res_port) {
- release_resource(hdsp->res_port);
- kfree_nocheck(hdsp->res_port);
- }
+ if (hdsp->port)
+ pci_release_regions(hdsp->pci);
+ pci_disable_device(hdsp->pci);
return 0;
}
-static void snd_hdsp_card_free(snd_card_t *card)
+static void snd_hdsp_card_free(struct snd_card *card)
{
- hdsp_t *hdsp = (hdsp_t *) card->private_data;
+ struct hdsp *hdsp = (struct hdsp *) card->private_data;
if (hdsp)
snd_hdsp_free(hdsp);
const struct pci_device_id *pci_id)
{
static int dev;
- hdsp_t *hdsp;
- snd_card_t *card;
+ struct hdsp *hdsp;
+ struct snd_card *card;
int err;
if (dev >= SNDRV_CARDS)
return -ENOENT;
}
- if (!(card = snd_card_new(index[dev], id[dev], THIS_MODULE, sizeof(hdsp_t))))
+ if (!(card = snd_card_new(index[dev], id[dev], THIS_MODULE, sizeof(struct hdsp))))
return -ENOMEM;
- hdsp = (hdsp_t *) card->private_data;
+ hdsp = (struct hdsp *) card->private_data;
card->private_free = snd_hdsp_card_free;
hdsp->dev = dev;
hdsp->pci = pci;
snd_card_set_dev(card, &pci->dev);
- if ((err = snd_hdsp_create(card, hdsp, precise_ptr[dev])) < 0) {
+ if ((err = snd_hdsp_create(card, hdsp)) < 0) {
snd_card_free(card);
return err;
}
static int __init alsa_card_hdsp_init(void)
{
- return pci_module_init(&driver);
+ return pci_register_driver(&driver);
}
static void __exit alsa_card_hdsp_exit(void)