summaryrefslogtreecommitdiffstats
path: root/sound/isa/opti9xx/opti92x-ad1848.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/isa/opti9xx/opti92x-ad1848.c')
-rw-r--r--sound/isa/opti9xx/opti92x-ad1848.c720
1 files changed, 312 insertions, 408 deletions
diff --git a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c
index b94339f8306..1ea3944ef7a 100644
--- a/sound/isa/opti9xx/opti92x-ad1848.c
+++ b/sound/isa/opti9xx/opti92x-ad1848.c
@@ -24,13 +24,15 @@
#include <sound/driver.h>
-#include <asm/io.h>
-#include <asm/dma.h>
-#include <linux/delay.h>
#include <linux/init.h>
+#include <linux/err.h>
+#include <linux/platform_device.h>
+#include <linux/delay.h>
#include <linux/slab.h>
#include <linux/pnp.h>
#include <linux/moduleparam.h>
+#include <asm/io.h>
+#include <asm/dma.h>
#include <sound/core.h>
#ifdef CS4231
#include <sound/cs4231.h>
@@ -120,8 +122,6 @@ MODULE_PARM_DESC(dma2, "2nd dma # for opti9xx driver.");
#define OPTi9XX_MC_REG(n) n
-typedef struct _snd_opti9xx opti9xx_t;
-
#ifdef OPTi93X
#define OPTi93X_INDEX 0x00
@@ -193,16 +193,14 @@ typedef struct _snd_opti9xx opti9xx_t;
#define OPTi93X_IRQ_CAPTURE 0x08
-typedef struct _snd_opti93x opti93x_t;
-
-struct _snd_opti93x {
+struct snd_opti93x {
unsigned long port;
struct resource *res_port;
int irq;
int dma1;
int dma2;
- opti9xx_t *chip;
+ struct snd_opti9xx *chip;
unsigned short hardware;
unsigned char image[32];
@@ -212,10 +210,10 @@ struct _snd_opti93x {
spinlock_t lock;
- snd_card_t *card;
- snd_pcm_t *pcm;
- snd_pcm_substream_t *playback_substream;
- snd_pcm_substream_t *capture_substream;
+ struct snd_card *card;
+ struct snd_pcm *pcm;
+ struct snd_pcm_substream *playback_substream;
+ struct snd_pcm_substream *capture_substream;
unsigned int p_dma_size;
unsigned int c_dma_size;
};
@@ -227,7 +225,7 @@ struct _snd_opti93x {
#endif /* OPTi93X */
-struct _snd_opti9xx {
+struct snd_opti9xx {
unsigned short hardware;
unsigned char password;
char name[7];
@@ -260,8 +258,8 @@ struct _snd_opti9xx {
#endif /* CONFIG_PNP */
};
-static int snd_opti9xx_first_hit = 1;
-static snd_card_t *snd_opti9xx_legacy = SNDRV_DEFAULT_PTR1;
+static int snd_opti9xx_pnp_is_probed;
+static struct platform_device *snd_opti9xx_platform_device;
#ifdef CONFIG_PNP
@@ -296,7 +294,7 @@ static char * snd_opti9xx_names[] = {
};
-static long snd_legacy_find_free_ioport(long *port_table, long size)
+static long __init snd_legacy_find_free_ioport(long *port_table, long size)
{
while (*port_table != -1) {
if (request_region(*port_table, size, "ALSA test")) {
@@ -308,7 +306,7 @@ static long snd_legacy_find_free_ioport(long *port_table, long size)
return -1;
}
-static int __devinit snd_opti9xx_init(opti9xx_t *chip, unsigned short hardware)
+static int __init snd_opti9xx_init(struct snd_opti9xx *chip, unsigned short hardware)
{
static int opti9xx_mc_size[] = {7, 7, 10, 10, 2, 2, 2};
@@ -363,7 +361,7 @@ static int __devinit snd_opti9xx_init(opti9xx_t *chip, unsigned short hardware)
return 0;
}
-static unsigned char snd_opti9xx_read(opti9xx_t *chip,
+static unsigned char snd_opti9xx_read(struct snd_opti9xx *chip,
unsigned char reg)
{
unsigned long flags;
@@ -406,7 +404,7 @@ static unsigned char snd_opti9xx_read(opti9xx_t *chip,
return retval;
}
-static void snd_opti9xx_write(opti9xx_t *chip, unsigned char reg,
+static void snd_opti9xx_write(struct snd_opti9xx *chip, unsigned char reg,
unsigned char value)
{
unsigned long flags;
@@ -453,7 +451,7 @@ static void snd_opti9xx_write(opti9xx_t *chip, unsigned char reg,
(snd_opti9xx_read(chip, reg) & ~(mask)) | ((value) & (mask)))
-static int __devinit snd_opti9xx_configure(opti9xx_t *chip)
+static int __init snd_opti9xx_configure(struct snd_opti9xx *chip)
{
unsigned char wss_base_bits;
unsigned char irq_bits;
@@ -684,7 +682,7 @@ static unsigned char snd_opti93x_default_image[32] =
};
-static int snd_opti93x_busy_wait(opti93x_t *chip)
+static int snd_opti93x_busy_wait(struct snd_opti93x *chip)
{
int timeout;
@@ -696,14 +694,14 @@ static int snd_opti93x_busy_wait(opti93x_t *chip)
return -EBUSY;
}
-static unsigned char snd_opti93x_in(opti93x_t *chip, unsigned char reg)
+static unsigned char snd_opti93x_in(struct snd_opti93x *chip, unsigned char reg)
{
snd_opti93x_busy_wait(chip);
outb(chip->mce_bit | (reg & 0x1f), OPTi93X_PORT(chip, INDEX));
return inb(OPTi93X_PORT(chip, DATA));
}
-static void snd_opti93x_out(opti93x_t *chip, unsigned char reg,
+static void snd_opti93x_out(struct snd_opti93x *chip, unsigned char reg,
unsigned char value)
{
snd_opti93x_busy_wait(chip);
@@ -711,13 +709,13 @@ static void snd_opti93x_out(opti93x_t *chip, unsigned char reg,
outb(value, OPTi93X_PORT(chip, DATA));
}
-static void snd_opti93x_out_image(opti93x_t *chip, unsigned char reg,
+static void snd_opti93x_out_image(struct snd_opti93x *chip, unsigned char reg,
unsigned char value)
{
snd_opti93x_out(chip, reg, chip->image[reg] = value);
}
-static void snd_opti93x_out_mask(opti93x_t *chip, unsigned char reg,
+static void snd_opti93x_out_mask(struct snd_opti93x *chip, unsigned char reg,
unsigned char mask, unsigned char value)
{
snd_opti93x_out_image(chip, reg,
@@ -725,7 +723,7 @@ static void snd_opti93x_out_mask(opti93x_t *chip, unsigned char reg,
}
-static void snd_opti93x_mce_up(opti93x_t *chip)
+static void snd_opti93x_mce_up(struct snd_opti93x *chip)
{
snd_opti93x_busy_wait(chip);
@@ -734,7 +732,7 @@ static void snd_opti93x_mce_up(opti93x_t *chip)
outb(chip->mce_bit, OPTi93X_PORT(chip, INDEX));
}
-static void snd_opti93x_mce_down(opti93x_t *chip)
+static void snd_opti93x_mce_down(struct snd_opti93x *chip)
{
snd_opti93x_busy_wait(chip);
@@ -746,7 +744,7 @@ static void snd_opti93x_mce_down(opti93x_t *chip)
#define snd_opti93x_mute_reg(chip, reg, mute) \
snd_opti93x_out(chip, reg, mute ? 0x80 : chip->image[reg]);
-static void snd_opti93x_mute(opti93x_t *chip, int mute)
+static void snd_opti93x_mute(struct snd_opti93x *chip, int mute)
{
mute = mute ? 1 : 0;
if (chip->mute == mute)
@@ -798,7 +796,7 @@ static unsigned int rates[] = { 5512, 6615, 8000, 9600, 11025, 16000,
44100, 48000 };
#define RATES ARRAY_SIZE(rates)
-static snd_pcm_hw_constraint_list_t hw_constraints_rates = {
+static struct snd_pcm_hw_constraint_list hw_constraints_rates = {
.count = RATES,
.list = rates,
.mask = 0,
@@ -820,7 +818,7 @@ static unsigned char snd_opti93x_get_freq(unsigned int rate)
return bits[RATES-1];
}
-static unsigned char snd_opti93x_get_format(opti93x_t *chip,
+static unsigned char snd_opti93x_get_format(struct snd_opti93x *chip,
unsigned int format, int channels)
{
unsigned char retval = OPTi93X_LINEAR_8;
@@ -845,7 +843,7 @@ static unsigned char snd_opti93x_get_format(opti93x_t *chip,
}
-static void snd_opti93x_playback_format(opti93x_t *chip, unsigned char fmt)
+static void snd_opti93x_playback_format(struct snd_opti93x *chip, unsigned char fmt)
{
unsigned char mask;
@@ -859,7 +857,7 @@ static void snd_opti93x_playback_format(opti93x_t *chip, unsigned char fmt)
snd_opti93x_mute(chip, 0);
}
-static void snd_opti93x_capture_format(opti93x_t *chip, unsigned char fmt)
+static void snd_opti93x_capture_format(struct snd_opti93x *chip, unsigned char fmt)
{
snd_opti93x_mute(chip, 1);
@@ -875,7 +873,7 @@ static void snd_opti93x_capture_format(opti93x_t *chip, unsigned char fmt)
}
-static int snd_opti93x_open(opti93x_t *chip, unsigned int mode)
+static int snd_opti93x_open(struct snd_opti93x *chip, unsigned int mode)
{
unsigned long flags;
@@ -899,7 +897,7 @@ static int snd_opti93x_open(opti93x_t *chip, unsigned int mode)
return 0;
}
-static void snd_opti93x_close(opti93x_t *chip, unsigned int mode)
+static void snd_opti93x_close(struct snd_opti93x *chip, unsigned int mode)
{
unsigned long flags;
@@ -926,10 +924,10 @@ static void snd_opti93x_close(opti93x_t *chip, unsigned int mode)
spin_unlock_irqrestore(&chip->lock, flags);
}
-static int snd_opti93x_trigger(snd_pcm_substream_t *substream,
+static int snd_opti93x_trigger(struct snd_pcm_substream *substream,
unsigned char what, int cmd)
{
- opti93x_t *chip = snd_pcm_substream_chip(substream);
+ struct snd_opti93x *chip = snd_pcm_substream_chip(substream);
switch (cmd) {
case SNDRV_PCM_TRIGGER_START:
@@ -937,7 +935,7 @@ static int snd_opti93x_trigger(snd_pcm_substream_t *substream,
{
unsigned int what = 0;
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 == chip->playback_substream) {
@@ -964,36 +962,36 @@ static int snd_opti93x_trigger(snd_pcm_substream_t *substream,
return 0;
}
-static int snd_opti93x_playback_trigger(snd_pcm_substream_t *substream, int cmd)
+static int snd_opti93x_playback_trigger(struct snd_pcm_substream *substream, int cmd)
{
return snd_opti93x_trigger(substream,
OPTi93X_PLAYBACK_ENABLE, cmd);
}
-static int snd_opti93x_capture_trigger(snd_pcm_substream_t * substream, int cmd)
+static int snd_opti93x_capture_trigger(struct snd_pcm_substream *substream, int cmd)
{
return snd_opti93x_trigger(substream,
OPTi93X_CAPTURE_ENABLE, cmd);
}
-static int snd_opti93x_hw_params(snd_pcm_substream_t * substream,
- snd_pcm_hw_params_t * hw_params)
+static int snd_opti93x_hw_params(struct snd_pcm_substream *substream,
+ struct snd_pcm_hw_params *hw_params)
{
return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
}
-static int snd_opti93x_hw_free(snd_pcm_substream_t * substream)
+static int snd_opti93x_hw_free(struct snd_pcm_substream *substream)
{
snd_pcm_lib_free_pages(substream);
return 0;
}
-static int snd_opti93x_playback_prepare(snd_pcm_substream_t * substream)
+static int snd_opti93x_playback_prepare(struct snd_pcm_substream *substream)
{
- opti93x_t *chip = snd_pcm_substream_chip(substream);
- snd_pcm_runtime_t *runtime = substream->runtime;
+ struct snd_opti93x *chip = snd_pcm_substream_chip(substream);
+ struct snd_pcm_runtime *runtime = substream->runtime;
unsigned long flags;
unsigned char format;
unsigned int count = snd_pcm_lib_period_bytes(substream);
@@ -1023,10 +1021,10 @@ static int snd_opti93x_playback_prepare(snd_pcm_substream_t * substream)
return 0;
}
-static int snd_opti93x_capture_prepare(snd_pcm_substream_t *substream)
+static int snd_opti93x_capture_prepare(struct snd_pcm_substream *substream)
{
- opti93x_t *chip = snd_pcm_substream_chip(substream);
- snd_pcm_runtime_t *runtime = substream->runtime;
+ struct snd_opti93x *chip = snd_pcm_substream_chip(substream);
+ struct snd_pcm_runtime *runtime = substream->runtime;
unsigned long flags;
unsigned char format;
unsigned int count = snd_pcm_lib_period_bytes(substream);
@@ -1055,9 +1053,9 @@ static int snd_opti93x_capture_prepare(snd_pcm_substream_t *substream)
return 0;
}
-static snd_pcm_uframes_t snd_opti93x_playback_pointer(snd_pcm_substream_t *substream)
+static snd_pcm_uframes_t snd_opti93x_playback_pointer(struct snd_pcm_substream *substream)
{
- opti93x_t *chip = snd_pcm_substream_chip(substream);
+ struct snd_opti93x *chip = snd_pcm_substream_chip(substream);
size_t ptr;
if (!(chip->image[OPTi93X_IFACE_CONF] & OPTi93X_PLAYBACK_ENABLE))
@@ -1067,9 +1065,9 @@ static snd_pcm_uframes_t snd_opti93x_playback_pointer(snd_pcm_substream_t *subst
return bytes_to_frames(substream->runtime, ptr);
}
-static snd_pcm_uframes_t snd_opti93x_capture_pointer(snd_pcm_substream_t *substream)
+static snd_pcm_uframes_t snd_opti93x_capture_pointer(struct snd_pcm_substream *substream)
{
- opti93x_t *chip = snd_pcm_substream_chip(substream);
+ struct snd_opti93x *chip = snd_pcm_substream_chip(substream);
size_t ptr;
if (!(chip->image[OPTi93X_IFACE_CONF] & OPTi93X_CAPTURE_ENABLE))
@@ -1080,7 +1078,7 @@ static snd_pcm_uframes_t snd_opti93x_capture_pointer(snd_pcm_substream_t *substr
}
-static void snd_opti93x_overrange(opti93x_t *chip)
+static void snd_opti93x_overrange(struct snd_opti93x *chip)
{
unsigned long flags;
@@ -1094,7 +1092,7 @@ static void snd_opti93x_overrange(opti93x_t *chip)
static irqreturn_t snd_opti93x_interrupt(int irq, void *dev_id, struct pt_regs *regs)
{
- opti93x_t *codec = dev_id;
+ struct snd_opti93x *codec = dev_id;
unsigned char status;
status = snd_opti9xx_read(codec->chip, OPTi9XX_MC_REG(11));
@@ -1109,7 +1107,7 @@ static irqreturn_t snd_opti93x_interrupt(int irq, void *dev_id, struct pt_regs *
}
-static snd_pcm_hardware_t snd_opti93x_playback = {
+static struct snd_pcm_hardware snd_opti93x_playback = {
.info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_SYNC_START),
.formats = (SNDRV_PCM_FMTBIT_MU_LAW | SNDRV_PCM_FMTBIT_A_LAW | SNDRV_PCM_FMTBIT_IMA_ADPCM |
@@ -1127,7 +1125,7 @@ static snd_pcm_hardware_t snd_opti93x_playback = {
.fifo_size = 0,
};
-static snd_pcm_hardware_t snd_opti93x_capture = {
+static struct snd_pcm_hardware snd_opti93x_capture = {
.info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_SYNC_START),
.formats = (SNDRV_PCM_FMTBIT_MU_LAW | SNDRV_PCM_FMTBIT_A_LAW | SNDRV_PCM_FMTBIT_IMA_ADPCM |
@@ -1145,11 +1143,11 @@ static snd_pcm_hardware_t snd_opti93x_capture = {
.fifo_size = 0,
};
-static int snd_opti93x_playback_open(snd_pcm_substream_t *substream)
+static int snd_opti93x_playback_open(struct snd_pcm_substream *substream)
{
int error;
- opti93x_t *chip = snd_pcm_substream_chip(substream);
- snd_pcm_runtime_t *runtime = substream->runtime;
+ struct snd_opti93x *chip = snd_pcm_substream_chip(substream);
+ struct snd_pcm_runtime *runtime = substream->runtime;
if ((error = snd_opti93x_open(chip, OPTi93X_MODE_PLAY)) < 0)
return error;
@@ -1161,11 +1159,11 @@ static int snd_opti93x_playback_open(snd_pcm_substream_t *substream)
return error;
}
-static int snd_opti93x_capture_open(snd_pcm_substream_t *substream)
+static int snd_opti93x_capture_open(struct snd_pcm_substream *substream)
{
int error;
- opti93x_t *chip = snd_pcm_substream_chip(substream);
- snd_pcm_runtime_t *runtime = substream->runtime;
+ struct snd_opti93x *chip = snd_pcm_substream_chip(substream);
+ struct snd_pcm_runtime *runtime = substream->runtime;
if ((error = snd_opti93x_open(chip, OPTi93X_MODE_CAPTURE)) < 0)
return error;
@@ -1177,18 +1175,18 @@ static int snd_opti93x_capture_open(snd_pcm_substream_t *substream)
return error;
}
-static int snd_opti93x_playback_close(snd_pcm_substream_t *substream)
+static int snd_opti93x_playback_close(struct snd_pcm_substream *substream)
{
- opti93x_t *chip = snd_pcm_substream_chip(substream);
+ struct snd_opti93x *chip = snd_pcm_substream_chip(substream);
chip->playback_substream = NULL;
snd_opti93x_close(chip, OPTi93X_MODE_PLAY);
return 0;
}
-static int snd_opti93x_capture_close(snd_pcm_substream_t *substream)
+static int snd_opti93x_capture_close(struct snd_pcm_substream *substream)
{
- opti93x_t *chip = snd_pcm_substream_chip(substream);
+ struct snd_opti93x *chip = snd_pcm_substream_chip(substream);
chip->capture_substream = NULL;
snd_opti93x_close(chip, OPTi93X_MODE_CAPTURE);
@@ -1196,7 +1194,7 @@ static int snd_opti93x_capture_close(snd_pcm_substream_t *substream)
}
-static void snd_opti93x_init(opti93x_t *chip)
+static void snd_opti93x_init(struct snd_opti93x *chip)
{
unsigned long flags;
int i;
@@ -1211,7 +1209,7 @@ static void snd_opti93x_init(opti93x_t *chip)
spin_unlock_irqrestore(&chip->lock, flags);
}
-static int snd_opti93x_probe(opti93x_t *chip)
+static int snd_opti93x_probe(struct snd_opti93x *chip)
{
unsigned long flags;
unsigned char val;
@@ -1223,7 +1221,7 @@ static int snd_opti93x_probe(opti93x_t *chip)
return (val == 0x0a) ? 0 : -ENODEV;
}
-static int snd_opti93x_free(opti93x_t *chip)
+static int snd_opti93x_free(struct snd_opti93x *chip)
{
release_and_free_resource(chip->res_port);
if (chip->dma1 >= 0) {
@@ -1241,13 +1239,13 @@ static int snd_opti93x_free(opti93x_t *chip)
return 0;
}
-static int snd_opti93x_dev_free(snd_device_t *device)
+static int snd_opti93x_dev_free(struct snd_device *device)
{
- opti93x_t *chip = device->device_data;
+ struct snd_opti93x *chip = device->device_data;
return snd_opti93x_free(chip);
}
-static const char *snd_opti93x_chip_id(opti93x_t *codec)
+static const char *snd_opti93x_chip_id(struct snd_opti93x *codec)
{
switch (codec->hardware) {
case OPTi9XX_HW_82C930: return "82C930";
@@ -1257,15 +1255,15 @@ static const char *snd_opti93x_chip_id(opti93x_t *codec)
}
}
-static int snd_opti93x_create(snd_card_t *card, opti9xx_t *chip,
+static int snd_opti93x_create(struct snd_card *card, struct snd_opti9xx *chip,
int dma1, int dma2,
- opti93x_t **rcodec)
+ struct snd_opti93x **rcodec)
{
- static snd_device_ops_t ops = {
+ static struct snd_device_ops ops = {
.dev_free = snd_opti93x_dev_free,
};
int error;
- opti93x_t *codec;
+ struct snd_opti93x *codec;
*rcodec = NULL;
codec = kzalloc(sizeof(*codec), GFP_KERNEL);
@@ -1324,7 +1322,7 @@ static int snd_opti93x_create(snd_card_t *card, opti9xx_t *chip,
return 0;
}
-static snd_pcm_ops_t snd_opti93x_playback_ops = {
+static struct snd_pcm_ops snd_opti93x_playback_ops = {
.open = snd_opti93x_playback_open,
.close = snd_opti93x_playback_close,
.ioctl = snd_pcm_lib_ioctl,
@@ -1335,7 +1333,7 @@ static snd_pcm_ops_t snd_opti93x_playback_ops = {
.pointer = snd_opti93x_playback_pointer,
};
-static snd_pcm_ops_t snd_opti93x_capture_ops = {
+static struct snd_pcm_ops snd_opti93x_capture_ops = {
.open = snd_opti93x_capture_open,
.close = snd_opti93x_capture_close,
.ioctl = snd_pcm_lib_ioctl,
@@ -1346,17 +1344,10 @@ static snd_pcm_ops_t snd_opti93x_capture_ops = {
.pointer = snd_opti93x_capture_pointer,
};
-static void snd_opti93x_pcm_free(snd_pcm_t *pcm)
-{
- opti93x_t *codec = pcm->private_data;
- codec->pcm = NULL;
- snd_pcm_lib_preallocate_free_for_all(pcm);
-}
-
-static int snd_opti93x_pcm(opti93x_t *codec, int device, snd_pcm_t **rpcm)
+static int snd_opti93x_pcm(struct snd_opti93x *codec, int device, struct snd_pcm **rpcm)
{
int error;
- snd_pcm_t *pcm;
+ struct snd_pcm *pcm;
if ((error = snd_pcm_new(codec->card, "OPTi 82C93X", device, 1, 1, &pcm)))
return error;
@@ -1365,7 +1356,6 @@ static int snd_opti93x_pcm(opti93x_t *codec, int device, snd_pcm_t **rpcm)
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_opti93x_capture_ops);
pcm->private_data = codec;
- pcm->private_free = snd_opti93x_pcm_free;
pcm->info_flags = SNDRV_PCM_INFO_JOINT_DUPLEX;
strcpy(pcm->name, snd_opti93x_chip_id(codec));
@@ -1384,7 +1374,7 @@ static int snd_opti93x_pcm(opti93x_t *codec, int device, snd_pcm_t **rpcm)
* MIXER part
*/
-static int snd_opti93x_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_opti93x_info_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
{
static char *texts[4] = {
"Line1", "Aux", "Mic", "Mix"
@@ -1399,9 +1389,9 @@ static int snd_opti93x_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *
return 0;
}
-static int snd_opti93x_get_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_opti93x_get_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
- opti93x_t *chip = snd_kcontrol_chip(kcontrol);
+ struct snd_opti93x *chip = snd_kcontrol_chip(kcontrol);
unsigned long flags;
spin_lock_irqsave(&chip->lock, flags);
@@ -1411,9 +1401,9 @@ static int snd_opti93x_get_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *
return 0;
}
-static int snd_opti93x_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_opti93x_put_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
- opti93x_t *chip = snd_kcontrol_chip(kcontrol);
+ struct snd_opti93x *chip = snd_kcontrol_chip(kcontrol);
unsigned long flags;
unsigned short left, right;
int change;
@@ -1442,7 +1432,7 @@ static int snd_opti93x_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *
.get = snd_opti93x_get_single, .put = snd_opti93x_put_single, \
.private_value = reg | (shift << 8) | (mask << 16) | (invert << 24) }
-static int snd_opti93x_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_opti93x_info_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
{
int mask = (kcontrol->private_value >> 16) & 0xff;
@@ -1453,9 +1443,9 @@ static int snd_opti93x_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t
return 0;
}
-static int snd_opti93x_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_opti93x_get_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
- opti93x_t *chip = snd_kcontrol_chip(kcontrol);
+ struct snd_opti93x *chip = snd_kcontrol_chip(kcontrol);
unsigned long flags;
int reg = kcontrol->private_value & 0xff;
int shift = (kcontrol->private_value >> 8) & 0xff;
@@ -1470,9 +1460,9 @@ static int snd_opti93x_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_
return 0;
}
-static int snd_opti93x_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_opti93x_put_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
- opti93x_t *chip = snd_kcontrol_chip(kcontrol);
+ struct snd_opti93x *chip = snd_kcontrol_chip(kcontrol);
unsigned long flags;
int reg = kcontrol->private_value & 0xff;
int shift = (kcontrol->private_value >> 8) & 0xff;
@@ -1507,7 +1497,7 @@ static int snd_opti93x_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_
do { xctl.private_value &= ~0x0000ffff; \
xctl.private_value |= left_reg | (right_reg << 8); } while (0)
-static int snd_opti93x_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_opti93x_info_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
{
int mask = (kcontrol->private_value >> 24) & 0xff;
@@ -1518,9 +1508,9 @@ static int snd_opti93x_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t
return 0;
}
-static int snd_opti93x_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_opti93x_get_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
- opti93x_t *chip = snd_kcontrol_chip(kcontrol);
+ struct snd_opti93x *chip = snd_kcontrol_chip(kcontrol);
unsigned long flags;
int left_reg = kcontrol->private_value & 0xff;
int right_reg = (kcontrol->private_value >> 8) & 0xff;
@@ -1540,9 +1530,9 @@ static int snd_opti93x_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_
return 0;
}
-static int snd_opti93x_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_opti93x_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
- opti93x_t *chip = snd_kcontrol_chip(kcontrol);
+ struct snd_opti93x *chip = snd_kcontrol_chip(kcontrol);
unsigned long flags;
int left_reg = kcontrol->private_value & 0xff;
int right_reg = (kcontrol->private_value >> 8) & 0xff;
@@ -1571,7 +1561,7 @@ static int snd_opti93x_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_
return change;
}
-static snd_kcontrol_new_t snd_opti93x_controls[] = {
+static struct snd_kcontrol_new snd_opti93x_controls[] = {
OPTi93X_DOUBLE("Master Playback Switch", 0, OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 7, 7, 1, 1),
OPTi93X_DOUBLE("Master Playback Volume", 0, OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 1, 1, 31, 1),
OPTi93X_DOUBLE("PCM Playback Switch", 0, OPTi93X_DAC_LEFT, OPTi93X_DAC_RIGHT, 7, 7, 1, 1),
@@ -1597,10 +1587,10 @@ OPTi93X_DOUBLE("Capture Volume", 0, OPTi93X_MIXOUT_LEFT, OPTi93X_MIXOUT_RIGHT, 0
}
};
-static int snd_opti93x_mixer(opti93x_t *chip)
+static int snd_opti93x_mixer(struct snd_opti93x *chip)
{
- snd_card_t *card;
- snd_kcontrol_new_t knew;
+ struct snd_card *card;
+ struct snd_kcontrol_new knew;
int err;
unsigned int idx;
@@ -1632,7 +1622,7 @@ static int snd_opti93x_mixer(opti93x_t *chip)
#endif /* OPTi93X */
-static int __devinit snd_card_opti9xx_detect(snd_card_t *card, opti9xx_t *chip)
+static int __init snd_card_opti9xx_detect(struct snd_card *card, struct snd_opti9xx *chip)
{
int i, err;
@@ -1686,8 +1676,8 @@ static int __devinit snd_card_opti9xx_detect(snd_card_t *card, opti9xx_t *chip)
}
#ifdef CONFIG_PNP
-static int __devinit snd_card_opti9xx_pnp(opti9xx_t *chip, struct pnp_card_link *card,
- const struct pnp_card_device_id *pid)
+static int __init snd_card_opti9xx_pnp(struct snd_opti9xx *chip, struct pnp_card_link *card,
+ const struct pnp_card_device_id *pid)
{
struct pnp_dev *pdev;
struct pnp_resource_table *cfg = kmalloc(sizeof(*cfg), GFP_KERNEL);
@@ -1778,195 +1768,35 @@ static int __devinit snd_card_opti9xx_pnp(opti9xx_t *chip, struct pnp_card_link
}
#endif /* CONFIG_PNP */
-#if 0
-static int __devinit snd_card_opti9xx_resources(struct snd_card_opti9xx *chip,
- snd_card_t *card)
-{
- int error, i, pnp = 0;
-
-#ifdef CONFIG_PNP
- pnp = chip->dev != NULL;
-#endif /* CONFIG_PNP */
-
-#ifndef OPTi93X
- if (chip->chip->hardware == OPTi9XX_HW_82C928)
- mpu_port = -1;
-#endif /* OPTi93X */
- error = 0;
- if (!pnp && (mpu_port == SNDRV_DEFAULT_PORT1)) {
- for (i = 0; possible_mpu_ports[i] != -1; i++)
- if (!snd_register_ioport(card, possible_mpu_ports[i], 2,
- DRIVER_NAME" - MPU-401", NULL)) {
- mpu_port = possible_mpu_ports[i];
- break;
- }
- if (mpu_port == SNDRV_DEFAULT_PORT1)
- error = -EBUSY;
- }
- else
- error = (mpu_port == -1) ? -ENODEV :
- snd_register_ioport(card, mpu_port, 2,
- DRIVER_NAME" - MPU-401", NULL);
- if (error)
- chip->chip->mpu_port = -1;
- else if (pnp && (irq == mpu_irq))
- chip->chip->mpu_irq = mpu_irq;
- else if (!snd_register_interrupt(card,
- DRIVER_NAME" - MPU-401",
- mpu_irq, SNDRV_IRQ_TYPE_ISA,
- snd_card_opti9xx_mpu_interrupt, chip,
- pnp ? no_alternatives : possible_mpu_irqs,
- &chip->mpuirqptr)) {
- chip->chip->mpu_port = mpu_port;
- chip->chip->mpu_irq = chip->mpuirqptr->irq;
- }
- else
- chip->chip->mpu_port = -1;
-
- if (!pnp && (port == SNDRV_DEFAULT_PORT1)) {
- for (i = 0; possible_ports[i] != -1; i++)
- if (!snd_register_ioport(card, possible_ports[i], 8,
- DRIVER_NAME" - WSS", NULL)) {
- port = possible_ports[i];
- break;
- }
- if (port == SNDRV_DEFAULT_PORT1)
- return -EBUSY;
- }
- else if ((error = snd_register_ioport(card, port, 8,
- DRIVER_NAME" - WSS", NULL)) < 0)
- return error;
- chip->chip->wss_base = port;
- if ((error = snd_register_interrupt(card, DRIVER_NAME" - WSS",
- irq, SNDRV_IRQ_TYPE_ISA,
- snd_card_opti9xx_interrupt, chip,
- pnp ? no_alternatives : possible_irqs,
- &chip->irqptr)) < 0)
- return error;
- chip->chip->irq = chip->irqptr->irq;
- if ((error = snd_register_dma_channel(card,
-#if defined(CS4231) || defined(OPTi93X)
- DRIVER_NAME" - WSS playback",
-#else
- DRIVER_NAME" - WSS",
-#endif /* CS4231 || OPTi93X */
- dma1, SNDRV_DMA_TYPE_ISA, dma1_size,
- pnp ? no_alternatives : possible_dma1s,
- &chip->dma1ptr)) < 0)
- return error;
- chip->chip->dma1 = chip->dma1ptr->dma;
-#if defined(CS4231) || defined(OPTi93X)
- if ((error = snd_register_dma_channel(card, DRIVER_NAME" - WSS capture",
- dma2, SNDRV_DMA_TYPE_ISA, dma2_size,
- pnp ? no_alternatives :
- possible_dma2s[chip->dma1ptr->dma],
- &chip->dma2ptr)) < 0)
- return error;
- chip->chip->dma2 = chip->dma2ptr->dma;
-#endif /* CS4231 || OPTi93X */
-
- if (snd_register_ioport(card,
- pnp ? fm_port : fm_port = 0x388, 4,
- DRIVER_NAME" - OPL", NULL) < 0)
- fm_port = -1;
- chip->chip->fm_port = fm_port;
-
- return 0;
-}
-#endif
-
-static void snd_card_opti9xx_free(snd_card_t *card)
+static void snd_card_opti9xx_free(struct snd_card *card)
{
- opti9xx_t *chip = (opti9xx_t *)card->private_data;
+ struct snd_opti9xx *chip = card->private_data;
if (chip)
release_and_free_resource(chip->res_mc_base);
}
-static int snd_card_opti9xx_probe(struct pnp_card_link *pcard,
- const struct pnp_card_device_id *pid)
+static int __init snd_opti9xx_probe(struct snd_card *card)
{
static long possible_ports[] = {0x530, 0xe80, 0xf40, 0x604, -1};
- static long possible_mpu_ports[] = {0x300, 0x310, 0x320, 0x330, -1};
-#ifdef OPTi93X
- static int possible_irqs[] = {5, 9, 10, 11, 7, -1};
-#else
- static int possible_irqs[] = {9, 10, 11, 7, -1};
-#endif /* OPTi93X */
- static int possible_mpu_irqs[] = {5, 9, 10, 7, -1};
- static int possible_dma1s[] = {3, 1, 0, -1};
-#if defined(CS4231) || defined(OPTi93X)
- static int possible_dma2s[][2] = {{1,-1}, {0,-1}, {-1,-1}, {0,-1}};
-#endif /* CS4231 || OPTi93X */
int error;
- opti9xx_t *chip;
+ struct snd_opti9xx *chip = card->private_data;
#if defined(OPTi93X)
- opti93x_t *codec;
+ struct snd_opti93x *codec;
#elif defined(CS4231)
- cs4231_t *codec;
- snd_timer_t *timer;
+ struct snd_cs4231 *codec;
+ struct snd_timer *timer;
#else
- ad1848_t *codec;
+ struct snd_ad1848 *codec;
#endif
- snd_card_t *card;
- snd_pcm_t *pcm;
- snd_rawmidi_t *rmidi;
- snd_hwdep_t *synth;
-#ifdef CONFIG_PNP
- int hw;
-#endif /* CONFIG_PNP */
-
- if (pcard && !snd_opti9xx_first_hit)
- return -EBUSY;
- if (!(card = snd_card_new(index, id, THIS_MODULE,
- sizeof(opti9xx_t))))
- return -ENOMEM;
- card->private_free = snd_card_opti9xx_free;
- chip = (opti9xx_t *)card->private_data;
-
-#ifdef CONFIG_PNP
- if (isapnp && pcard && (hw = snd_card_opti9xx_pnp(chip, pcard, pid)) > 0) {
- switch (hw) {
- case 0x0924:
- hw = OPTi9XX_HW_82C924;
- break;
- case 0x0925:
- hw = OPTi9XX_HW_82C925;
- break;
- case 0x0931:
- hw = OPTi9XX_HW_82C931;
- break;
- default:
- snd_card_free(card);
- return -ENODEV;
- }
-
- if ((error = snd_opti9xx_init(chip, hw))) {
- snd_card_free(card);
- return error;
- }
- if (hw <= OPTi9XX_HW_82C930)
- chip->mc_base -= 0x80;
- snd_card_set_dev(card, &pcard->card->dev);
- } else {
-#endif /* CONFIG_PNP */
- if ((error = snd_card_opti9xx_detect(card, chip)) < 0) {
- snd_card_free(card);
- return error;
- }
- if ((error = snd_card_set_generic_dev(card)) < 0) {
- snd_card_free(card);
- return error;
- }
-#ifdef CONFIG_PNP
- }
-#endif /* CONFIG_PNP */
+ struct snd_pcm *pcm;
+ struct snd_rawmidi *rmidi;
+ struct snd_hwdep *synth;
if (! chip->res_mc_base &&
- (chip->res_mc_base = request_region(chip->mc_base, chip->mc_base_size, "OPTi9xx MC")) == NULL) {
- snd_card_free(card);
+ (chip->res_mc_base = request_region(chip->mc_base, chip->mc_base_size,
+ "OPTi9xx MC")) == NULL)
return -ENOMEM;
- }
chip->wss_base = port;
chip->fm_port = fm_port;
@@ -1980,110 +1810,42 @@ static int snd_card_opti9xx_probe(struct pnp_card_link *pcard,
if (chip->wss_base == SNDRV_AUTO_PORT) {
if ((chip->wss_base = snd_legacy_find_free_ioport(possible_ports, 4)) < 0) {
- snd_card_free(card);
snd_printk("unable to find a free WSS port\n");
return -EBUSY;
}
}
-#ifdef CONFIG_PNP
- if (!isapnp) {
-#endif
- if (chip->mpu_port == SNDRV_AUTO_PORT) {
- if ((chip->mpu_port = snd_legacy_find_free_ioport(possible_mpu_ports, 2)) < 0) {
- snd_card_free(card);
- snd_printk("unable to find a free MPU401 port\n");
- return -EBUSY;
- }
- }
- if (chip->irq == SNDRV_AUTO_IRQ) {
- if ((chip->irq = snd_legacy_find_free_irq(possible_irqs)) < 0) {
- snd_card_free(card);
- snd_printk("unable to find a free IRQ\n");
- return -EBUSY;
- }
- }
- if (chip->mpu_irq == SNDRV_AUTO_IRQ) {
- if ((chip->mpu_irq = snd_legacy_find_free_irq(possible_mpu_irqs)) < 0) {
- snd_card_free(card);
- snd_printk("unable to find a free MPU401 IRQ\n");
- return -EBUSY;
- }
- }
- if (chip->dma1 == SNDRV_AUTO_DMA) {
- if ((chip->dma1 = snd_legacy_find_free_dma(possible_dma1s)) < 0) {
- snd_card_free(card);
- snd_printk("unable to find a free DMA1\n");
- return -EBUSY;
- }
- }
-#if defined(CS4231) || defined(OPTi93X)
- if (chip->dma2 == SNDRV_AUTO_DMA) {
- if ((chip->dma2 = snd_legacy_find_free_dma(possible_dma2s[chip->dma1 % 4])) < 0) {
- snd_card_free(card);
- snd_printk("unable to find a free DMA2\n");
- return -EBUSY;
- }
- }
-#endif
-
-#ifdef CONFIG_PNP
- }
-#endif
-
- if ((error = snd_opti9xx_configure(chip))) {
- snd_card_free(card);
+ if ((error = snd_opti9xx_configure(chip)))
return error;
- }
#if defined(OPTi93X)
- if ((error = snd_opti93x_create(card, chip, chip->dma1, chip->dma2, &codec))) {
- snd_card_free(card);
+ if ((error = snd_opti93x_create(card, chip, chip->dma1, chip->dma2, &codec)))
return error;
- }
- if ((error = snd_opti93x_pcm(codec, 0, &pcm)) < 0) {
- snd_card_free(card);
+ if ((error = snd_opti93x_pcm(codec, 0, &pcm)) < 0)
return error;
- }
- if ((error = snd_opti93x_mixer(codec)) < 0) {
- snd_card_free(card);
+ if ((error = snd_opti93x_mixer(codec)) < 0)
return error;
- }
#elif defined(CS4231)
if ((error = snd_cs4231_create(card, chip->wss_base + 4, -1,
chip->irq, chip->dma1, chip->dma2,
CS4231_HW_DETECT,
0,
- &codec)) < 0) {
- snd_card_free(card);
+ &codec)) < 0)
return error;
- }
- if ((error = snd_cs4231_pcm(codec, 0, &pcm)) < 0) {
- snd_card_free(card);
+ if ((error = snd_cs4231_pcm(codec, 0, &pcm)) < 0)
return error;
- }
- if ((error = snd_cs4231_mixer(codec)) < 0) {
- snd_card_free(card);
+ if ((error = snd_cs4231_mixer(codec)) < 0)
return error;
- }
- if ((error = snd_cs4231_timer(codec, 0, &timer)) < 0) {
- snd_card_free(card);
+ if ((error = snd_cs4231_timer(codec, 0, &timer)) < 0)
return error;
- }
#else
if ((error = snd_ad1848_create(card, chip->wss_base + 4,
chip->irq, chip->dma1,
- AD1848_HW_DETECT, &codec)) < 0) {
- snd_card_free(card);
+ AD1848_HW_DETECT, &codec)) < 0)
return error;
- }
- if ((error = snd_ad1848_pcm(codec, 0, &pcm)) < 0) {
- snd_card_free(card);
+ if ((error = snd_ad1848_pcm(codec, 0, &pcm)) < 0)
return error;
- }
- if ((error = snd_ad1848_mixer(codec)) < 0) {
- snd_card_free(card);
+ if ((error = snd_ad1848_mixer(codec)) < 0)
return error;
- }
#endif
strcpy(card->driver, chip->name);
sprintf(card->shortname, "OPTi %s", card->driver);
@@ -2103,15 +1865,16 @@ static int snd_card_opti9xx_probe(struct pnp_card_link *pcard,
if ((error = snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401,
chip->mpu_port, 0, chip->mpu_irq, SA_INTERRUPT,
&rmidi)))
- snd_printk("no MPU-401 device at 0x%lx?\n", chip->mpu_port);
+ snd_printk(KERN_WARNING "no MPU-401 device at 0x%lx?\n",
+ chip->mpu_port);
if (chip->fm_port > 0 && chip->fm_port != SNDRV_AUTO_PORT) {
- opl3_t *opl3 = NULL;
+ struct snd_opl3 *opl3 = NULL;
#ifndef OPTi93X
if (chip->hardware == OPTi9XX_HW_82C928 ||
chip->hardware == OPTi9XX_HW_82C929 ||
chip->hardware == OPTi9XX_HW_82C924) {
- opl4_t *opl4;
+ struct snd_opl4 *opl4;
/* assume we have an OPL4 */
snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(2),
0x20, 0x20);
@@ -2129,89 +1892,230 @@ static int snd_card_opti9xx_probe(struct pnp_card_link *pcard,
chip->fm_port,
chip->fm_port + 2,
OPL3_HW_AUTO, 0, &opl3) < 0) {
- snd_printk("no OPL device at 0x%lx-0x%lx\n",
+ snd_printk(KERN_WARNING "no OPL device at 0x%lx-0x%lx\n",
chip->fm_port, chip->fm_port + 4 - 1);
}
if (opl3) {
- if ((error = snd_opl3_timer_new(opl3,
#ifdef CS4231
- 1, 2)) < 0) {
+ const int t1dev = 1;
#else
- 0, 1)) < 0) {
-#endif /* CS4231 */
- snd_card_free(card);
+ const int t1dev = 0;
+#endif
+ if ((error = snd_opl3_timer_new(opl3, t1dev, t1dev+1)) < 0)
return error;
- }
- if ((error = snd_opl3_hwdep_new(opl3, 0, 1, &synth)) < 0) {
- snd_card_free(card);
+ if ((error = snd_opl3_hwdep_new(opl3, 0, 1, &synth)) < 0)
return error;
- }
}
}
- if ((error = snd_card_register(card))) {
+ return snd_card_register(card);
+}
+
+static struct snd_card *snd_opti9xx_card_new(void)
+{
+ struct snd_card *card;
+
+ card = snd_card_new(index, id, THIS_MODULE, sizeof(struct snd_opti9xx));
+ if (! card)
+ return NULL;
+ card->private_free = snd_card_opti9xx_free;
+ return card;
+}
+
+static int __init snd_opti9xx_nonpnp_probe(struct platform_device *devptr)
+{
+ struct snd_card *card;
+ int error;
+ static long possible_mpu_ports[] = {0x300, 0x310, 0x320, 0x330, -1};
+#ifdef OPTi93X
+ static int possible_irqs[] = {5, 9, 10, 11, 7, -1};
+#else
+ static int possible_irqs[] = {9, 10, 11, 7, -1};
+#endif /* OPTi93X */
+ static int possible_mpu_irqs[] = {5, 9, 10, 7, -1};
+ static int possible_dma1s[] = {3, 1, 0, -1};
+#if defined(CS4231) || defined(OPTi93X)
+ static int possible_dma2s[][2] = {{1,-1}, {0,-1}, {-1,-1}, {0,-1}};
+#endif /* CS4231 || OPTi93X */
+
+ if (snd_opti9xx_pnp_is_probed)
+ return -EBUSY;
+
+ if (mpu_port == SNDRV_AUTO_PORT) {
+ if ((mpu_port = snd_legacy_find_free_ioport(possible_mpu_ports, 2)) < 0) {
+ snd_printk(KERN_ERR "unable to find a free MPU401 port\n");
+ return -EBUSY;
+ }
+ }
+ if (irq == SNDRV_AUTO_IRQ) {
+ if ((irq = snd_legacy_find_free_irq(possible_irqs)) < 0) {
+ snd_printk(KERN_ERR "unable to find a free IRQ\n");
+ return -EBUSY;
+ }
+ }
+ if (mpu_irq == SNDRV_AUTO_IRQ) {
+ if ((mpu_irq = snd_legacy_find_free_irq(possible_mpu_irqs)) < 0) {
+ snd_printk(KERN_ERR "unable to find a free MPU401 IRQ\n");
+ return -EBUSY;
+ }
+ }
+ if (dma1 == SNDRV_AUTO_DMA) {
+ if ((dma1 = snd_legacy_find_free_dma(possible_dma1s)) < 0) {
+ snd_printk(KERN_ERR "unable to find a free DMA1\n");
+ return -EBUSY;
+ }
+ }
+#if defined(CS4231) || defined(OPTi93X)
+ if (dma2 == SNDRV_AUTO_DMA) {
+ if ((dma2 = snd_legacy_find_free_dma(possible_dma2s[dma1 % 4])) < 0) {
+ snd_printk("unable to find a free DMA2\n");
+ return -EBUSY;
+ }
+ }
+#endif
+
+ card = snd_opti9xx_card_new();
+ if (! card)
+ return -ENOMEM;
+
+ if ((error = snd_card_opti9xx_detect(card, card->private_data)) < 0) {
snd_card_free(card);
return error;
}
- snd_opti9xx_first_hit = 0;
- if (pcard)
- pnp_set_card_drvdata(pcard, card);
- else
- snd_opti9xx_legacy = card;
+ snd_card_set_dev(card, &devptr->dev);
+ if ((error = snd_opti9xx_probe(card)) < 0) {
+ snd_card_free(card);
+ return error;
+ }
+ platform_set_drvdata(devptr, card);
+ return 0;
+}
+
+static int __devexit snd_opti9xx_nonpnp_remove(struct platform_device *devptr)
+{
+ snd_card_free(platform_get_drvdata(devptr));
+ platform_set_drvdata(devptr, NULL);
return 0;
}
+static struct platform_driver snd_opti9xx_driver = {
+ .probe = snd_opti9xx_nonpnp_probe,
+ .remove = __devexit_p(snd_opti9xx_nonpnp_remove),
+ /* FIXME: suspend/resume */
+ .driver = {
+ .name = DRIVER_NAME
+ },
+};
+
#ifdef CONFIG_PNP
-static void __devexit snd_opti9xx_pnp_remove(struct pnp_card_link * pcard)
+static int __init snd_opti9xx_pnp_probe(struct pnp_card_link *pcard,
+ const struct pnp_card_device_id *pid)
{
- snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard);
+ struct snd_card *card;
+ int error, hw;
+ struct snd_opti9xx *chip;
- snd_card_disconnect(card);
- snd_card_free_in_thread(card);
- snd_opti9xx_first_hit = 0;
+ if (snd_opti9xx_pnp_is_probed)
+ return -EBUSY;
+ if (! isapnp)
+ return -ENODEV;
+ card = snd_opti9xx_card_new();
+ if (! card)
+ return -ENOMEM;
+ chip = card->private_data;
+
+ hw = snd_card_opti9xx_pnp(chip, pcard, pid);
+ switch (hw) {
+ case 0x0924:
+ hw = OPTi9XX_HW_82C924;
+ break;
+ case 0x0925:
+ hw = OPTi9XX_HW_82C925;
+ break;
+ case 0x0931:
+ hw = OPTi9XX_HW_82C931;
+ break;
+ default:
+ snd_card_free(card);
+ return -ENODEV;
+ }
+
+ if ((error = snd_opti9xx_init(chip, hw))) {
+ snd_card_free(card);
+ return error;
+ }
+ if (hw <= OPTi9XX_HW_82C930)
+ chip->mc_base -= 0x80;
+ snd_card_set_dev(card, &pcard->card->dev);
+ if ((error = snd_opti9xx_probe(card)) < 0) {
+ snd_card_free(card);
+ return error;
+ }
+ pnp_set_card_drvdata(pcard, card);
+ snd_opti9xx_pnp_is_probed = 1;
+ return 0;
+}
+
+static void __devexit snd_opti9xx_pnp_remove(struct pnp_card_link * pcard)
+{
+ snd_card_free(pnp_get_card_drvdata(pcard));
+ pnp_set_card_drvdata(pcard, NULL);
+ snd_opti9xx_pnp_is_probed = 0;
}
static struct pnp_card_driver opti9xx_pnpc_driver = {
.flags = PNP_DRIVER_RES_DISABLE,
.name = "opti9xx",
.id_table = snd_opti9xx_pnpids,
- .probe = snd_card_opti9xx_probe,
+ .probe = snd_opti9xx_pnp_probe,
.remove = __devexit_p(snd_opti9xx_pnp_remove),
};
#endif
-static int __init alsa_card_opti9xx_init(void)
-{
- int cards, error;
-
#ifdef CONFIG_PNP
- cards = pnp_register_card_driver(&opti9xx_pnpc_driver);
+#define is_isapnp_selected() isapnp
#else
- cards = 0;
-#endif
- if (cards == 0 && (error = snd_card_opti9xx_probe(NULL, NULL)) < 0) {
-#ifdef CONFIG_PNP
- pnp_unregister_card_driver(&opti9xx_pnpc_driver);
+#define is_isapnp_selected() 0
#endif
-#ifdef MODULE
#ifdef OPTi93X
- printk(KERN_ERR "no OPTi 82C93x soundcard found\n");
+#define CHIP_NAME "82C93x"
#else
- printk(KERN_ERR "no OPTi 82C92x soundcard found\n");
-#endif /* OPTi93X */
+#define CHIP_NAME "82C92x"
#endif
- return error;
+
+static int __init alsa_card_opti9xx_init(void)
+{
+ int error;
+ struct platform_device *device;
+
+ pnp_register_card_driver(&opti9xx_pnpc_driver);
+ if (snd_opti9xx_pnp_is_probed)
+ return 0;
+ if (! is_isapnp_selected()) {
+ error = platform_driver_register(&snd_opti9xx_driver);
+ if (error < 0)
+ return error;
+ device = platform_device_register_simple(DRIVER_NAME, -1, NULL, 0);
+ if (!IS_ERR(device)) {
+ snd_opti9xx_platform_device = device;
+ return 0;
+ }
+ platform_driver_unregister(&snd_opti9xx_driver);
}
- return 0;
+ pnp_unregister_card_driver(&opti9xx_pnpc_driver);
+#ifdef MODULE
+ printk(KERN_ERR "no OPTi " CHIP_NAME " soundcard found\n");
+#endif
+ return -ENODEV;
}
static void __exit alsa_card_opti9xx_exit(void)
{
-#ifdef CONFIG_PNP
+ if (!snd_opti9xx_pnp_is_probed) {
+ platform_device_unregister(snd_opti9xx_platform_device);
+ platform_driver_unregister(&snd_opti9xx_driver);
+ }
pnp_unregister_card_driver(&opti9xx_pnpc_driver);
-#endif
- if (snd_opti9xx_legacy)
- snd_card_free(snd_opti9xx_legacy);
}
module_init(alsa_card_opti9xx_init)