linux/sound/isa/gus/interwave.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 *  Driver for AMD InterWave soundcard
 *  Copyright (c) by Jaroslav Kysela <[email protected]>
 *
 *   1999/07/22		Erik Inge Bolso <[email protected]>
 *			* mixer group handlers
 */

#include <linux/init.h>
#include <linux/err.h>
#include <linux/isa.h>
#include <linux/delay.h>
#include <linux/pnp.h>
#include <linux/module.h>
#include <asm/dma.h>
#include <sound/core.h>
#include <sound/gus.h>
#include <sound/wss.h>
#ifdef SNDRV_STB
#include <sound/tea6330t.h>
#endif
#define SNDRV_LEGACY_FIND_FREE_IRQ
#define SNDRV_LEGACY_FIND_FREE_DMA
#include <sound/initval.h>

MODULE_AUTHOR();
MODULE_LICENSE();
#ifndef SNDRV_STB
MODULE_DESCRIPTION();
#else
MODULE_DESCRIPTION("AMD InterWave STB with TEA6330T");
#endif

static int index[SNDRV_CARDS] =;	/* Index 0-MAX */
static char *id[SNDRV_CARDS] =;	/* ID for this card */
static bool enable[SNDRV_CARDS] =; /* Enable this card */
#ifdef CONFIG_PNP
static bool isapnp[SNDRV_CARDS] =;
#endif
static long port[SNDRV_CARDS] =;	/* 0x210,0x220,0x230,0x240,0x250,0x260 */
#ifdef SNDRV_STB
static long port_tc[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;	/* 0x350,0x360,0x370,0x380 */
#endif
static int irq[SNDRV_CARDS] =;	/* 2,3,5,9,11,12,15 */
static int dma1[SNDRV_CARDS] =;	/* 0,1,3,5,6,7 */
static int dma2[SNDRV_CARDS] =;	/* 0,1,3,5,6,7 */
static int joystick_dac[SNDRV_CARDS] =;
				/* 0 to 31, (0.59V-4.52V or 0.389V-2.98V) */
static int midi[SNDRV_CARDS];
static int pcm_channels[SNDRV_CARDS] =;
static int effect[SNDRV_CARDS];

#ifdef SNDRV_STB
#define PFX
#define INTERWAVE_DRIVER
#define INTERWAVE_PNP_DRIVER
#else
#define PFX
#define INTERWAVE_DRIVER
#define INTERWAVE_PNP_DRIVER
#endif

module_param_array();
MODULE_PARM_DESC();
module_param_array();
MODULE_PARM_DESC();
module_param_array();
MODULE_PARM_DESC();
#ifdef CONFIG_PNP
module_param_array();
MODULE_PARM_DESC();
#endif
module_param_hw_array(port, long, ioport, NULL, 0444);
MODULE_PARM_DESC();
#ifdef SNDRV_STB
module_param_hw_array(port_tc, long, ioport, NULL, 0444);
MODULE_PARM_DESC(port_tc, "Tone control (TEA6330T - i2c bus) port # for InterWave driver.");
#endif
module_param_hw_array(irq, int, irq, NULL, 0444);
MODULE_PARM_DESC();
module_param_hw_array(dma1, int, dma, NULL, 0444);
MODULE_PARM_DESC();
module_param_hw_array(dma2, int, dma, NULL, 0444);
MODULE_PARM_DESC();
module_param_array();
MODULE_PARM_DESC();
module_param_array();
MODULE_PARM_DESC();
module_param_array();
MODULE_PARM_DESC();
module_param_array();
MODULE_PARM_DESC();

struct snd_interwave {};


#ifdef CONFIG_PNP
static int isa_registered;
static int pnp_registered;

static const struct pnp_card_device_id snd_interwave_pnpids[] =;

MODULE_DEVICE_TABLE(pnp_card, snd_interwave_pnpids);

#endif /* CONFIG_PNP */


#ifdef SNDRV_STB
static void snd_interwave_i2c_setlines(struct snd_i2c_bus *bus, int ctrl, int data)
{
	unsigned long port = bus->private_value;

#if 0
	printk(KERN_DEBUG "i2c_setlines - 0x%lx <- %i,%i\n", port, ctrl, data);
#endif
	outb((data << 1) | ctrl, port);
	udelay(10);
}

static int snd_interwave_i2c_getclockline(struct snd_i2c_bus *bus)
{
	unsigned long port = bus->private_value;
	unsigned char res;

	res = inb(port) & 1;
#if 0
	printk(KERN_DEBUG "i2c_getclockline - 0x%lx -> %i\n", port, res);
#endif
	return res;
}

static int snd_interwave_i2c_getdataline(struct snd_i2c_bus *bus, int ack)
{
	unsigned long port = bus->private_value;
	unsigned char res;

	if (ack)
		udelay(10);
	res = (inb(port) & 2) >> 1;
#if 0
	printk(KERN_DEBUG "i2c_getdataline - 0x%lx -> %i\n", port, res);
#endif
	return res;
}

static struct snd_i2c_bit_ops snd_interwave_i2c_bit_ops = {
	.setlines = snd_interwave_i2c_setlines,
	.getclock = snd_interwave_i2c_getclockline,
	.getdata  = snd_interwave_i2c_getdataline,
};

static int snd_interwave_detect_stb(struct snd_interwave *iwcard,
				    struct snd_gus_card *gus, int dev,
				    struct snd_i2c_bus **rbus)
{
	unsigned long port;
	struct snd_i2c_bus *bus;
	struct snd_card *card = iwcard->card;
	char name[32];
	int err;

	*rbus = NULL;
	port = port_tc[dev];
	if (port == SNDRV_AUTO_PORT) {
		port = 0x350;
		if (gus->gf1.port == 0x250) {
			port = 0x360;
		}
		while (port <= 0x380) {
			iwcard->i2c_res = devm_request_region(card->dev, port, 1,
							      "InterWave (I2C bus)");
			if (iwcard->i2c_res)
				break;
			port += 0x10;
		}
	} else {
		iwcard->i2c_res = devm_request_region(card->dev, port, 1,
						      "InterWave (I2C bus)");
	}
	if (iwcard->i2c_res == NULL) {
		snd_printk(KERN_ERR "interwave: can't grab i2c bus port\n");
		return -ENODEV;
	}

	sprintf(name, "InterWave-%i", card->number);
	err = snd_i2c_bus_create(card, name, NULL, &bus);
	if (err < 0)
		return err;
	bus->private_value = port;
	bus->hw_ops.bit = &snd_interwave_i2c_bit_ops;
	err = snd_tea6330t_detect(bus, 0);
	if (err < 0)
		return err;
	*rbus = bus;
	return 0;
}
#endif

static int snd_interwave_detect(struct snd_interwave *iwcard,
				struct snd_gus_card *gus,
				int dev
#ifdef SNDRV_STB
				, struct snd_i2c_bus **rbus
#endif
				          )
{}

static irqreturn_t snd_interwave_interrupt(int irq, void *dev_id)
{}

static void snd_interwave_reset(struct snd_gus_card *gus)
{}

static void snd_interwave_bank_sizes(struct snd_gus_card *gus, int *sizes)
{}

struct rom_hdr {};

static void snd_interwave_detect_memory(struct snd_gus_card *gus)
{}

static void snd_interwave_init(int dev, struct snd_gus_card *gus)
{}

static const struct snd_kcontrol_new snd_interwave_controls[] =;

static int snd_interwave_mixer(struct snd_wss *chip)
{}

#ifdef CONFIG_PNP

static int snd_interwave_pnp(int dev, struct snd_interwave *iwcard,
			     struct pnp_card_link *card,
			     const struct pnp_card_device_id *id)
{}
#endif /* CONFIG_PNP */

static int snd_interwave_card_new(struct device *pdev, int dev,
				  struct snd_card **cardp)
{}

static int snd_interwave_probe_gus(struct snd_card *card, int dev,
				   struct snd_gus_card **gusp)
{}

static int snd_interwave_probe(struct snd_card *card, int dev,
			       struct snd_gus_card *gus)
{}

static int snd_interwave_isa_match(struct device *pdev,
				   unsigned int dev)
{}

static int snd_interwave_isa_probe(struct device *pdev,
				   unsigned int dev)
{}

static struct isa_driver snd_interwave_driver =;

#ifdef CONFIG_PNP
static int snd_interwave_pnp_detect(struct pnp_card_link *pcard,
				    const struct pnp_card_device_id *pid)
{}

static struct pnp_card_driver interwave_pnpc_driver =;

#endif /* CONFIG_PNP */

static int __init alsa_card_interwave_init(void)
{}

static void __exit alsa_card_interwave_exit(void)
{}

module_init()
module_exit()