cregit-Linux how code gets into the kernel

Release 4.8 sound/isa/sscape.c

Directory: sound/isa
/*
 *   Low-level ALSA driver for the ENSONIQ SoundScape
 *   Copyright (c) by Chris Rankin
 *
 *   This driver was written in part using information obtained from
 *   the OSS/Free SoundScape driver, written by Hannu Savolainen.
 *
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program; if not, write to the Free Software
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 */

#include <linux/init.h>
#include <linux/err.h>
#include <linux/io.h>
#include <linux/isa.h>
#include <linux/delay.h>
#include <linux/firmware.h>
#include <linux/pnp.h>
#include <linux/spinlock.h>
#include <linux/module.h>
#include <asm/dma.h>
#include <sound/core.h>
#include <sound/wss.h>
#include <sound/mpu401.h>
#include <sound/initval.h>


MODULE_AUTHOR("Chris Rankin");
MODULE_DESCRIPTION("ENSONIQ SoundScape driver");
MODULE_LICENSE("GPL");
MODULE_FIRMWARE("sndscape.co0");
MODULE_FIRMWARE("sndscape.co1");
MODULE_FIRMWARE("sndscape.co2");
MODULE_FIRMWARE("sndscape.co3");
MODULE_FIRMWARE("sndscape.co4");
MODULE_FIRMWARE("scope.cod");


static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;

static char* id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;

static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;

static long wss_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;

static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ;

static int mpu_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ;

static int dma[SNDRV_CARDS] = SNDRV_DEFAULT_DMA;

static int dma2[SNDRV_CARDS] = SNDRV_DEFAULT_DMA;

static bool joystick[SNDRV_CARDS];

module_param_array(index, int, NULL, 0444);
MODULE_PARM_DESC(index, "Index number for SoundScape soundcard");

module_param_array(id, charp, NULL, 0444);
MODULE_PARM_DESC(id, "Description for SoundScape card");

module_param_array(port, long, NULL, 0444);
MODULE_PARM_DESC(port, "Port # for SoundScape driver.");

module_param_array(wss_port, long, NULL, 0444);
MODULE_PARM_DESC(wss_port, "WSS Port # for SoundScape driver.");

module_param_array(irq, int, NULL, 0444);
MODULE_PARM_DESC(irq, "IRQ # for SoundScape driver.");

module_param_array(mpu_irq, int, NULL, 0444);
MODULE_PARM_DESC(mpu_irq, "MPU401 IRQ # for SoundScape driver.");

module_param_array(dma, int, NULL, 0444);
MODULE_PARM_DESC(dma, "DMA # for SoundScape driver.");

module_param_array(dma2, int, NULL, 0444);
MODULE_PARM_DESC(dma2, "DMA2 # for SoundScape driver.");

module_param_array(joystick, bool, NULL, 0444);
MODULE_PARM_DESC(joystick, "Enable gameport.");

#ifdef CONFIG_PNP

static int isa_registered;

static int pnp_registered;


static struct pnp_card_device_id sscape_pnpids[] = {
	{ .id = "ENS3081", .devs = { { "ENS0000" } } }, /* Soundscape PnP */
	{ .id = "ENS4081", .devs = { { "ENS1011" } } },	/* VIVO90 */
	{ .id = "" }	/* end */
};

MODULE_DEVICE_TABLE(pnp_card, sscape_pnpids);
#endif



#define HOST_CTRL_IO(i)  ((i) + 2)

#define HOST_DATA_IO(i)  ((i) + 3)

#define ODIE_ADDR_IO(i)  ((i) + 4)

#define ODIE_DATA_IO(i)  ((i) + 5)

#define CODEC_IO(i)      ((i) + 8)


#define IC_ODIE  1

#define IC_OPUS  2


#define RX_READY 0x01

#define TX_READY 0x02


#define CMD_ACK			0x80

#define CMD_SET_MIDI_VOL	0x84

#define CMD_GET_MIDI_VOL	0x85

#define CMD_XXX_MIDI_VOL	0x86

#define CMD_SET_EXTMIDI		0x8a

#define CMD_GET_EXTMIDI		0x8b

#define CMD_SET_MT32		0x8c

#define CMD_GET_MT32		0x8d


enum GA_REG {
	
GA_INTSTAT_REG = 0,
	
GA_INTENA_REG,
	
GA_DMAA_REG,
	
GA_DMAB_REG,
	
GA_INTCFG_REG,
	
GA_DMACFG_REG,
	
GA_CDCFG_REG,
	
GA_SMCFGA_REG,
	
GA_SMCFGB_REG,
	
GA_HMCTL_REG
};


#define DMA_8BIT  0x80



enum card_type {
	
MEDIA_FX,	/* Sequoia S-1000 */
	
SSCAPE,		/* Sequoia S-2000 */
	
SSCAPE_PNP,
	
SSCAPE_VIVO,
};


struct soundscape {
	
spinlock_t lock;
	
unsigned io_base;
	
int ic_type;
	
enum card_type type;
	
struct resource *io_res;
	
struct resource *wss_res;
	
struct snd_wss *chip;

	
unsigned char midi_vol;
};


#define INVALID_IRQ  ((unsigned)-1)



static inline struct soundscape *get_card_soundscape(struct snd_card *c) { return (struct soundscape *) (c->private_data); }

Contributors

PersonTokensPropCommitsCommitProp
jaroslav kyselajaroslav kysela2492.31%150.00%
takashi iwaitakashi iwai27.69%150.00%
Total26100.00%2100.00%

/* * Allocates some kernel memory that we can use for DMA. * I think this means that the memory has to map to * contiguous pages of physical memory. */
static struct snd_dma_buffer *get_dmabuf(struct snd_dma_buffer *buf, unsigned long size) { if (buf) { if (snd_dma_alloc_pages_fallback(SNDRV_DMA_TYPE_DEV, snd_dma_isa_data(), size, buf) < 0) { snd_printk(KERN_ERR "sscape: Failed to allocate " "%lu bytes for DMA\n", size); return NULL; } } return buf; }

Contributors

PersonTokensPropCommitsCommitProp
jaroslav kyselajaroslav kysela5496.43%375.00%
krzysztof heltkrzysztof helt23.57%125.00%
Total56100.00%4100.00%

/* * Release the DMA-able kernel memory ... */
static void free_dmabuf(struct snd_dma_buffer *buf) { if (buf && buf->area) snd_dma_free_pages(buf); }

Contributors

PersonTokensPropCommitsCommitProp
jaroslav kyselajaroslav kysela24100.00%2100.00%
Total24100.00%2100.00%

/* * This function writes to the SoundScape's control registers, * but doesn't do any locking. It's up to the caller to do that. * This is why this function is "unsafe" ... */
static inline void sscape_write_unsafe(unsigned io_base, enum GA_REG reg, unsigned char val) { outb(reg, ODIE_ADDR_IO(io_base)); outb(val, ODIE_DATA_IO(io_base)); }

Contributors

PersonTokensPropCommitsCommitProp
jaroslav kyselajaroslav kysela38100.00%1100.00%
Total38100.00%1100.00%

/* * Write to the SoundScape's control registers, and do the * necessary locking ... */
static void sscape_write(struct soundscape *s, enum GA_REG reg, unsigned char val) { unsigned long flags; spin_lock_irqsave(&s->lock, flags); sscape_write_unsafe(s->io_base, reg, val); spin_unlock_irqrestore(&s->lock, flags); }

Contributors

PersonTokensPropCommitsCommitProp
jaroslav kyselajaroslav kysela54100.00%1100.00%
Total54100.00%1100.00%

/* * Read from the SoundScape's control registers, but leave any * locking to the caller. This is why the function is "unsafe" ... */
static inline unsigned char sscape_read_unsafe(unsigned io_base, enum GA_REG reg) { outb(reg, ODIE_ADDR_IO(io_base)); return inb(ODIE_DATA_IO(io_base)); }

Contributors

PersonTokensPropCommitsCommitProp
jaroslav kyselajaroslav kysela34100.00%1100.00%
Total34100.00%1100.00%

/* * Puts the SoundScape into "host" mode, as compared to "MIDI" mode */
static inline void set_host_mode_unsafe(unsigned io_base) { outb(0x0, HOST_CTRL_IO(io_base)); }

Contributors

PersonTokensPropCommitsCommitProp
jaroslav kyselajaroslav kysela20100.00%1100.00%
Total20100.00%1100.00%

/* * Puts the SoundScape into "MIDI" mode, as compared to "host" mode */
static inline void set_midi_mode_unsafe(unsigned io_base) { outb(0x3, HOST_CTRL_IO(io_base)); }

Contributors

PersonTokensPropCommitsCommitProp
jaroslav kyselajaroslav kysela20100.00%1100.00%
Total20100.00%1100.00%

/* * Read the SoundScape's host-mode control register, but leave * any locking issues to the caller ... */
static inline int host_read_unsafe(unsigned io_base) { int data = -1; if ((inb(HOST_CTRL_IO(io_base)) & RX_READY) != 0) data = inb(HOST_DATA_IO(io_base)); return data; }

Contributors

PersonTokensPropCommitsCommitProp
jaroslav kyselajaroslav kysela45100.00%1100.00%
Total45100.00%1100.00%

/* * Read the SoundScape's host-mode control register, performing * a limited amount of busy-waiting if the register isn't ready. * Also leaves all locking-issues to the caller ... */
static int host_read_ctrl_unsafe(unsigned io_base, unsigned timeout) { int data; while (((data = host_read_unsafe(io_base)) < 0) && (timeout != 0)) { udelay(100); --timeout; } /* while */ return data; }

Contributors

PersonTokensPropCommitsCommitProp
jaroslav kyselajaroslav kysela50100.00%1100.00%
Total50100.00%1100.00%

/* * Write to the SoundScape's host-mode control registers, but * leave any locking issues to the caller ... */
static inline int host_write_unsafe(unsigned io_base, unsigned char data) { if ((inb(HOST_CTRL_IO(io_base)) & TX_READY) != 0) { outb(data, HOST_DATA_IO(io_base)); return 1; } return 0; }

Contributors

PersonTokensPropCommitsCommitProp
jaroslav kyselajaroslav kysela48100.00%1100.00%
Total48100.00%1100.00%

/* * Write to the SoundScape's host-mode control registers, performing * a limited amount of busy-waiting if the register isn't ready. * Also leaves all locking-issues to the caller ... */
static int host_write_ctrl_unsafe(unsigned io_base, unsigned char data, unsigned timeout) { int err; while (!(err = host_write_unsafe(io_base, data)) && (timeout != 0)) { udelay(100); --timeout; } /* while */ return err; }

Contributors

PersonTokensPropCommitsCommitProp
jaroslav kyselajaroslav kysela53100.00%1100.00%
Total53100.00%1100.00%

/* * Check that the MIDI subsystem is operational. If it isn't, * then we will hang the computer if we try to use it ... * * NOTE: This check is based upon observation, not documentation. */
static inline int verify_mpu401(const struct snd_mpu401 *mpu) { return ((inb(MPU401C(mpu)) & 0xc0) == 0x80); }

Contributors

PersonTokensPropCommitsCommitProp
jaroslav kyselajaroslav kysela2790.00%133.33%
takashi iwaitakashi iwai26.67%133.33%
krzysztof heltkrzysztof helt13.33%133.33%
Total30100.00%3100.00%

/* * This is apparently the standard way to initailise an MPU-401 */
static inline void initialise_mpu401(const struct snd_mpu401 *mpu) { outb(0, MPU401D(mpu)); }

Contributors

PersonTokensPropCommitsCommitProp
jaroslav kyselajaroslav kysela2086.96%133.33%
takashi iwaitakashi iwai28.70%133.33%
krzysztof heltkrzysztof helt14.35%133.33%
Total23100.00%3100.00%

/* * Tell the SoundScape to activate the AD1845 chip (I think). * The AD1845 detection fails if we *don't* do this, so I * think that this is a good idea ... */
static void activate_ad1845_unsafe(unsigned io_base) { unsigned char val = sscape_read_unsafe(io_base, GA_HMCTL_REG); sscape_write_unsafe(io_base, GA_HMCTL_REG, (val & 0xcf) | 0x10); sscape_write_unsafe(io_base, GA_CDCFG_REG, 0x80); }

Contributors

PersonTokensPropCommitsCommitProp
jaroslav kyselajaroslav kysela3375.00%150.00%
krzysztof heltkrzysztof helt1125.00%150.00%
Total44100.00%2100.00%

/* * Do the necessary ALSA-level cleanup to deallocate our driver ... */
static void soundscape_free(struct snd_card *c) { struct soundscape *sscape = get_card_soundscape(c); release_and_free_resource(sscape->io_res); release_and_free_resource(sscape->wss_res); free_dma(sscape->chip->dma1); }

Contributors

PersonTokensPropCommitsCommitProp
jaroslav kyselajaroslav kysela3477.27%125.00%
krzysztof heltkrzysztof helt715.91%125.00%
takashi iwaitakashi iwai36.82%250.00%
Total44100.00%4100.00%

/* * Tell the SoundScape to begin a DMA tranfer using the given channel. * All locking issues are left to the caller. */
static void sscape_start_dma_unsafe(unsigned io_base, enum GA_REG reg) { sscape_write_unsafe(io_base, reg, sscape_read_unsafe(io_base, reg) | 0x01); sscape_write_unsafe(io_base, reg, sscape_read_unsafe(io_base, reg) & 0xfe); }

Contributors

PersonTokensPropCommitsCommitProp
jaroslav kyselajaroslav kysela45100.00%1100.00%
Total45100.00%1100.00%

/* * Wait for a DMA transfer to complete. This is a "limited busy-wait", * and all locking issues are left to the caller. */
static int sscape_wait_dma_unsafe(unsigned io_base, enum GA_REG reg, unsigned timeout) { while (!(sscape_read_unsafe(io_base, reg) & 0x01) && (timeout != 0)) { udelay(100); --timeout; } /* while */ return sscape_read_unsafe(io_base, reg) & 0x01; }

Contributors

PersonTokensPropCommitsCommitProp
jaroslav kyselajaroslav kysela57100.00%1100.00%
Total57100.00%1100.00%

/* * Wait for the On-Board Processor to return its start-up * acknowledgement sequence. This wait is too long for * us to perform "busy-waiting", and so we must sleep. * This in turn means that we must not be holding any * spinlocks when we call this function. */
static int obp_startup_ack(struct soundscape *s, unsigned timeout) { unsigned long end_time = jiffies + msecs_to_jiffies(timeout); do { unsigned long flags; int x; spin_lock_irqsave(&s->lock, flags); x = host_read_unsafe(s->io_base); spin_unlock_irqrestore(&s->lock, flags); if (x == 0xfe || x == 0xff) return 1; msleep(10); } while (time_before(jiffies, end_time)); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
jaroslav kyselajaroslav kysela6467.37%133.33%
krzysztof heltkrzysztof helt3132.63%266.67%
Total95100.00%3100.00%

/* * Wait for the host to return its start-up acknowledgement * sequence. This wait is too long for us to perform * "busy-waiting", and so we must sleep. This in turn means * that we must not be holding any spinlocks when we call * this function. */
static int host_startup_ack(struct soundscape *s, unsigned timeout) { unsigned long end_time = jiffies + msecs_to_jiffies(timeout); do { unsigned long flags; int x; spin_lock_irqsave(&s->lock, flags); x = host_read_unsafe(s->io_base); spin_unlock_irqrestore(&s->lock, flags); if (x == 0xfe) return 1; msleep(10); } while (time_before(jiffies, end_time)); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
jaroslav kyselajaroslav kysela6470.33%133.33%
krzysztof heltkrzysztof helt2729.67%266.67%
Total91100.00%3100.00%

/* * Upload a byte-stream into the SoundScape using DMA channel A. */
static int upload_dma_data(struct soundscape *s, const unsigned char *data, size_t size) { unsigned long flags; struct snd_dma_buffer dma; int ret; unsigned char val; if (!get_dmabuf(&dma, PAGE_ALIGN(32 * 1024))) return -ENOMEM; spin_lock_irqsave(&s->lock, flags); /* * Reset the board ... */ val = sscape_read_unsafe(s->io_base, GA_HMCTL_REG); sscape_write_unsafe(s->io_base, GA_HMCTL_REG, val & 0x3f); /* * Enable the DMA channels and configure them ... */ val = (s->chip->dma1 << 4) | DMA_8BIT; sscape_write_unsafe(s->io_base, GA_DMAA_REG, val); sscape_write_unsafe(s->io_base, GA_DMAB_REG, 0x20); /* * Take the board out of reset ... */ val = sscape_read_unsafe(s->io_base, GA_HMCTL_REG); sscape_write_unsafe(s->io_base, GA_HMCTL_REG, val | 0x80); /* * Upload the firmware to the SoundScape * board through the DMA channel ... */ while (size != 0) { unsigned long len; len = min(size, dma.bytes); memcpy(dma.area, data, len); data += len; size -= len; snd_dma_program(s->chip->dma1, dma.addr, len, DMA_MODE_WRITE); sscape_start_dma_unsafe(s->io_base, GA_DMAA_REG); if (!sscape_wait_dma_unsafe(s->io_base, GA_DMAA_REG, 5000)) { /* * Don't forget to release this spinlock we're holding */ spin_unlock_irqrestore(&s->lock, flags); snd_printk(KERN_ERR "sscape: DMA upload has timed out\n"); ret = -EAGAIN; goto _release_dma; } } /* while */ set_host_mode_unsafe(s->io_base); outb(0x0, s->io_base); /* * Boot the board ... (I think) */ val = sscape_read_unsafe(s->io_base, GA_HMCTL_REG); sscape_write_unsafe(s->io_base, GA_HMCTL_REG, val | 0x40); spin_unlock_irqrestore(&s->lock, flags); /* * If all has gone well, then the board should acknowledge * the new upload and tell us that it has rebooted OK. We * give it 5 seconds (max) ... */ ret = 0; if (!obp_startup_ack(s, 5000)) { snd_printk(KERN_ERR "sscape: No response " "from on-board processor after upload\n"); ret = -EAGAIN; } else if (!host_startup_ack(s, 5000)) { snd_printk(KERN_ERR "sscape: SoundScape failed to initialise\n"); ret = -EAGAIN; } _release_dma: /* * NOTE!!! We are NOT holding any spinlocks at this point !!! */ sscape_write(s, GA_DMAA_REG, (s->ic_type == IC_OPUS ? 0x40 : 0x70)); free_dmabuf(&dma); return ret; }

Contributors

PersonTokensPropCommitsCommitProp
jaroslav kyselajaroslav kysela33684.42%342.86%
krzysztof heltkrzysztof helt6215.58%457.14%
Total398100.00%7100.00%

/* * Upload the bootblock(?) into the SoundScape. The only * purpose of this block of code seems to be to tell * us which version of the microcode we should be using. */
static int sscape_upload_bootblock(struct snd_card *card) { struct soundscape *sscape = get_card_soundscape(card); unsigned long flags; const struct firmware *init_fw = NULL; int data = 0; int ret; ret = request_firmware(&init_fw, "scope.cod", card->dev); if (ret < 0) { snd_printk(KERN_ERR "sscape: Error loading scope.cod"); return ret; } ret = upload_dma_data(sscape, init_fw->data, init_fw->size); release_firmware(init_fw); spin_lock_irqsave(&sscape->lock, flags); if (ret == 0) data = host_read_ctrl_unsafe(sscape->io_base, 100); if (data & 0x10) sscape_write_unsafe(sscape->io_base, GA_SMCFGA_REG, 0x2f); spin_unlock_irqrestore(&sscape->lock, flags); data &= 0xf; if (ret == 0 && data > 7) { snd_printk(KERN_ERR "sscape: timeout reading firmware version\n"); ret = -EAGAIN; } return (ret == 0) ? data : ret; }

Contributors

PersonTokensPropCommitsCommitProp
jaroslav kyselajaroslav kysela9752.72%250.00%
krzysztof heltkrzysztof helt8747.28%250.00%
Total184100.00%4100.00%

/* * Upload the microcode into the SoundScape. */
static int sscape_upload_microcode(struct snd_card *card, int version) { struct soundscape *sscape = get_card_soundscape(card); const struct firmware *init_fw = NULL; char name[14]; int err; snprintf(name, sizeof(name), "sndscape.co%d", version); err = request_firmware(&init_fw, name, card->dev); if (err < 0) { snd_printk(KERN_ERR "sscape: Error loading sndscape.co%d", version); return err; } err = upload_dma_data(sscape, init_fw->data, init_fw->size); if (err == 0) snd_printk(KERN_INFO "sscape: MIDI firmware loaded %zu KBs\n", init_fw->size >> 10); release_firmware(init_fw); return err; }

Contributors

PersonTokensPropCommitsCommitProp
krzysztof heltkrzysztof helt6751.94%250.00%
jaroslav kyselajaroslav kysela6147.29%125.00%
william breathitt graywilliam breathitt gray10.78%125.00%
Total129100.00%4100.00%

/* * Mixer control for the SoundScape's MIDI device. */
static int sscape_midi_info(struct snd_kcontrol *ctl, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 1; uinfo->value.integer.min = 0; uinfo->value.integer.max = 127; return 0; }

Contributors

PersonTokensPropCommitsCommitProp
jaroslav kyselajaroslav kysela4792.16%150.00%
takashi iwaitakashi iwai47.84%150.00%
Total51100.00%2100.00%


static int sscape_midi_get(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *uctl) { struct snd_wss *chip = snd_kcontrol_chip(kctl); struct snd_card *card = chip->card; register struct soundscape *s = get_card_soundscape(card); unsigned long flags; spin_lock_irqsave(&s->lock, flags); uctl->value.integer.value[0] = s->midi_vol; spin_unlock_irqrestore(&s->lock, flags); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
jaroslav kyselajaroslav kysela7989.77%125.00%
takashi iwaitakashi iwai77.95%125.00%
krzysztof heltkrzysztof helt22.27%250.00%
Total88100.00%4100.00%


static int sscape_midi_put(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *uctl) { struct snd_wss *chip = snd_kcontrol_chip(kctl); struct snd_card *card = chip->card; struct soundscape *s = get_card_soundscape(card); unsigned long flags; int change; unsigned char new_val; spin_lock_irqsave(&s->lock, flags); new_val = uctl->value.integer.value[0] & 127; /* * We need to put the board into HOST mode before we * can send any volume-changing HOST commands ... */ set_host_mode_unsafe(s->io_base); /* * To successfully change the MIDI volume setting, you seem to * have to write a volume command, write the new volume value, * and then perform another volume-related command. Perhaps the * first command is an "open" and the second command is a "close"? */ if (s->midi_vol == new_val) { change = 0; goto __skip_change; } change = host_write_ctrl_unsafe(s->io_base, CMD_SET_MIDI_VOL, 100) && host_write_ctrl_unsafe(s->io_base, new_val, 100) && host_write_ctrl_unsafe(s->io_base, CMD_XXX_MIDI_VOL, 100) && host_write_ctrl_unsafe(s->io_base, new_val, 100); s->midi_vol = new_val; __skip_change: /* * Take the board out of HOST mode and back into MIDI mode ... */ set_midi_mode_unsafe(s->io_base); spin_unlock_irqrestore(&s->lock, flags); return change; }

Contributors

PersonTokensPropCommitsCommitProp
jaroslav kyselajaroslav kysela13674.73%120.00%
krzysztof heltkrzysztof helt3921.43%360.00%
takashi iwaitakashi iwai73.85%120.00%
Total182100.00%5100.00%

static struct snd_kcontrol_new midi_mixer_ctl = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "MIDI", .info = sscape_midi_info, .get = sscape_midi_get, .put = sscape_midi_put }; /* * The SoundScape can use two IRQs from a possible set of four. * These IRQs are encoded as bit patterns so that they can be * written to the control registers. */
static unsigned get_irq_config(int sscape_type, int irq) { static const int valid_irq[] = { 9, 5, 7, 10 }; static const int old_irq[] = { 9, 7, 5, 15 }; unsigned cfg; if (sscape_type == MEDIA_FX) { for (cfg = 0; cfg < ARRAY_SIZE(old_irq); ++cfg) if (irq == old_irq[cfg]) return cfg; } else { for (cfg = 0; cfg < ARRAY_SIZE(valid_irq); ++cfg) if (irq == valid_irq[cfg]) return cfg; } return INVALID_IRQ; }

Contributors

PersonTokensPropCommitsCommitProp
jaroslav kyselajaroslav kysela6051.28%150.00%
krzysztof heltkrzysztof helt5748.72%150.00%
Total117100.00%2100.00%

/* * Perform certain arcane port-checks to see whether there * is a SoundScape board lurking behind the given ports. */
static int detect_sscape(struct soundscape *s, long wss_io) { unsigned long flags; unsigned d; int retval = 0; spin_lock_irqsave(&s->lock, flags); /* * The following code is lifted from the original OSS driver, * and as I don't have a datasheet I cannot really comment * on what it is doing... */ if ((inb(HOST_CTRL_IO(s->io_base)) & 0x78) != 0) goto _done; d = inb(ODIE_ADDR_IO(s->io_base)) & 0xf0; if ((d & 0x80) != 0) goto _done; if (d == 0) s->ic_type = IC_ODIE; else if ((d & 0x60) != 0) s->ic_type = IC_OPUS; else goto _done; outb(0xfa, ODIE_ADDR_IO(s->io_base)); if ((inb(ODIE_ADDR_IO(s->io_base)) & 0x9f) != 0x0a) goto _done; outb(0xfe, ODIE_ADDR_IO(s->io_base)); if ((inb(ODIE_ADDR_IO(s->io_base)) & 0x9f) != 0x0e) goto _done; outb(0xfe, ODIE_ADDR_IO(s->io_base)); d = inb(ODIE_DATA_IO(s->io_base)); if (s->type != SSCAPE_VIVO && (d & 0x9f) != 0x0e) goto _done; if (s->ic_type == IC_OPUS) activate_ad1845_unsafe(s->io_base); if (s->type == SSCAPE_VIVO) wss_io += 4; d = sscape_read_unsafe(s->io_base, GA_HMCTL_REG); sscape_write_unsafe(s->io_base, GA_HMCTL_REG, d | 0xc0); /* wait for WSS codec */ for (d = 0; d < 500; d++) { if ((inb(wss_io) & 0x80) == 0) break; spin_unlock_irqrestore(&s->lock, flags); msleep(1); spin_lock_irqsave(&s