diff options
author | Takashi Iwai <tiwai@suse.de> | 2010-05-31 12:39:59 +0200 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2010-05-31 12:39:59 +0200 |
commit | c901cf870b42c16be3be4b300db77caab8e48a8d (patch) | |
tree | 5056b6ffc45f3a22c19cba726ba39d3c4d92f57c | |
parent | d04773ab58387642bfc4a65d2a4c1b17b62d44b0 (diff) | |
download | alsa-driver-build-unstable-c901cf870b42c16be3be4b300db77caab8e48a8d.tar.gz |
Fix build with 2.6.35-rc1
Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | drivers/pcsp/Makefile | 4 | ||||
-rw-r--r-- | drivers/pcsp/pcsp-2.6.34.h | 88 | ||||
-rw-r--r-- | drivers/pcsp/pcsp.h | 4 | ||||
-rw-r--r-- | drivers/pcsp/pcsp_input.c | 2 | ||||
-rw-r--r-- | drivers/pcsp/pcsp_input.patch | 38 | ||||
-rw-r--r-- | drivers/pcsp/pcsp_lib.c | 5 | ||||
-rw-r--r-- | drivers/pcsp/pcsp_lib.patch | 68 | ||||
-rw-r--r-- | pcmcia/pdaudiocf/pdaudiocf-2.6.34.c | 319 | ||||
-rw-r--r-- | pcmcia/pdaudiocf/pdaudiocf-2.6.34.h | 145 | ||||
-rw-r--r-- | pcmcia/pdaudiocf/pdaudiocf-old.h | 127 | ||||
-rw-r--r-- | pcmcia/pdaudiocf/pdaudiocf.c | 2 | ||||
-rw-r--r-- | pcmcia/pdaudiocf/pdaudiocf.h | 133 | ||||
-rw-r--r-- | pcmcia/vx/vxpocket-2.6.34.c | 389 | ||||
-rw-r--r-- | pcmcia/vx/vxpocket-2.6.34.h | 93 | ||||
-rw-r--r-- | pcmcia/vx/vxpocket-old.h | 74 | ||||
-rw-r--r-- | pcmcia/vx/vxpocket.c | 2 | ||||
-rw-r--r-- | pcmcia/vx/vxpocket.h | 80 |
18 files changed, 1362 insertions, 213 deletions
diff --git a/.gitignore b/.gitignore index bc27469dd..204b95266 100644 --- a/.gitignore +++ b/.gitignore @@ -51,6 +51,8 @@ acore/timer.c drivers/mpu401/mpu401.c drivers/mts64.c drivers/pcsp/pcsp.c +drivers/pcsp/pcsp_input.c +drivers/pcsp/pcsp_lib.c drivers/portman2x4.c drivers/opl3/opl3_lib.c isa/sb/sb16_csp.c diff --git a/drivers/pcsp/Makefile b/drivers/pcsp/Makefile index 8f181e7ef..458b3ca0c 100644 --- a/drivers/pcsp/Makefile +++ b/drivers/pcsp/Makefile @@ -5,10 +5,12 @@ endif include $(SND_TOPDIR)/toplevel.config include $(SND_TOPDIR)/Makefile.conf -clean-files := pcsp.c +clean-files := pcsp.c pcsp_input.c pcsp_lib.c include $(SND_TOPDIR)/alsa-kernel/drivers/pcsp/Makefile include $(SND_TOPDIR)/Rules.make pcsp.c: pcsp.patch $(SND_TOPDIR)/alsa-kernel/drivers/pcsp/pcsp.c +pcsp_input.c: pcsp_input.patch $(SND_TOPDIR)/alsa-kernel/drivers/pcsp/pcsp_input.c +pcsp_lib.c: pcsp_lib.patch $(SND_TOPDIR)/alsa-kernel/drivers/pcsp/pcsp_lib.c diff --git a/drivers/pcsp/pcsp-2.6.34.h b/drivers/pcsp/pcsp-2.6.34.h new file mode 100644 index 000000000..1e1230779 --- /dev/null +++ b/drivers/pcsp/pcsp-2.6.34.h @@ -0,0 +1,88 @@ +/* + * PC-Speaker driver for Linux + * + * Copyright (C) 1993-1997 Michael Beck + * Copyright (C) 1997-2001 David Woodhouse + * Copyright (C) 2001-2008 Stas Sergeev + */ + +#ifndef __PCSP_H__ +#define __PCSP_H__ + +#include <linux/hrtimer.h> +#include <linux/timex.h> +#if defined(CONFIG_MIPS) || defined(CONFIG_X86) +/* Use the global PIT lock ! */ +#include <asm/i8253.h> +#else +#include <asm/8253pit.h> +static DEFINE_SPINLOCK(i8253_lock); +#endif + +#define PCSP_SOUND_VERSION 0x400 /* read 4.00 */ +#define PCSP_DEBUG 0 + +/* default timer freq for PC-Speaker: 18643 Hz */ +#define DIV_18KHZ 64 +#define MAX_DIV DIV_18KHZ +#define CALC_DIV(d) (MAX_DIV >> (d)) +#define CUR_DIV() CALC_DIV(chip->treble) +#define PCSP_MAX_TREBLE 1 + +/* unfortunately, with hrtimers 37KHz does not work very well :( */ +#define PCSP_DEFAULT_TREBLE 0 +#define MIN_DIV (MAX_DIV >> PCSP_MAX_TREBLE) + +/* wild guess */ +#define PCSP_MIN_LPJ 1000000 +#define PCSP_DEFAULT_SDIV (DIV_18KHZ >> 1) +#define PCSP_DEFAULT_SRATE (PIT_TICK_RATE / PCSP_DEFAULT_SDIV) +#define PCSP_INDEX_INC() (1 << (PCSP_MAX_TREBLE - chip->treble)) +#define PCSP_CALC_RATE(i) (PIT_TICK_RATE / CALC_DIV(i)) +#define PCSP_RATE() PCSP_CALC_RATE(chip->treble) +#define PCSP_MIN_RATE__1 MAX_DIV/PIT_TICK_RATE +#define PCSP_MAX_RATE__1 MIN_DIV/PIT_TICK_RATE +#define PCSP_MAX_PERIOD_NS (1000000000ULL * PCSP_MIN_RATE__1) +#define PCSP_MIN_PERIOD_NS (1000000000ULL * PCSP_MAX_RATE__1) +#define PCSP_CALC_NS(div) ({ \ + u64 __val = 1000000000ULL * (div); \ + do_div(__val, PIT_TICK_RATE); \ + __val; \ +}) +#define PCSP_PERIOD_NS() PCSP_CALC_NS(CUR_DIV()) + +#define PCSP_MAX_PERIOD_SIZE (64*1024) +#define PCSP_MAX_PERIODS 512 +#define PCSP_BUFFER_SIZE (128*1024) + +struct snd_pcsp { + struct snd_card *card; + struct snd_pcm *pcm; + struct input_dev *input_dev; + struct hrtimer timer; + unsigned short port, irq, dma; + spinlock_t substream_lock; + struct snd_pcm_substream *playback_substream; + unsigned int fmt_size; + unsigned int is_signed; + size_t playback_ptr; + size_t period_ptr; + atomic_t timer_active; + int thalf; + u64 ns_rem; + unsigned char val61; + int enable; + int max_treble; + int treble; + int pcspkr; +}; + +extern struct snd_pcsp pcsp_chip; + +extern enum hrtimer_restart pcsp_do_timer(struct hrtimer *handle); +extern void pcsp_sync_stop(struct snd_pcsp *chip); + +extern int snd_pcsp_new_pcm(struct snd_pcsp *chip); +extern int snd_pcsp_new_mixer(struct snd_pcsp *chip, int nopcm); + +#endif diff --git a/drivers/pcsp/pcsp.h b/drivers/pcsp/pcsp.h index 0dfd31e52..04569a01c 100644 --- a/drivers/pcsp/pcsp.h +++ b/drivers/pcsp/pcsp.h @@ -1 +1,5 @@ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35) #include "../../alsa-kernel/drivers/pcsp/pcsp.h" +#else +#include "pcsp-2.6.34.h" +#endif diff --git a/drivers/pcsp/pcsp_input.c b/drivers/pcsp/pcsp_input.c deleted file mode 100644 index 84456b0b4..000000000 --- a/drivers/pcsp/pcsp_input.c +++ /dev/null @@ -1,2 +0,0 @@ -#include "adriver.h" -#include "../../alsa-kernel/drivers/pcsp/pcsp_input.c" diff --git a/drivers/pcsp/pcsp_input.patch b/drivers/pcsp/pcsp_input.patch new file mode 100644 index 000000000..323097ae5 --- /dev/null +++ b/drivers/pcsp/pcsp_input.patch @@ -0,0 +1,38 @@ +--- ../../alsa-kernel/drivers/pcsp/pcsp_input.c 2010-05-21 16:36:59.457637275 +0200 ++++ pcsp_input.c 2010-05-31 12:37:43.411686497 +0200 +@@ -1,3 +1,17 @@ ++#include "adriver.h" ++ ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35) ++#define pcsp_spin_lock raw_spin_lock ++#define pcsp_spin_unlock raw_spin_unlock ++#define pcsp_spin_lock_irqsave raw_spin_lock_irqsave ++#define pcsp_spin_unlock_irqrestore raw_spin_unlock_irqrestore ++#else ++#define pcsp_spin_lock spin_lock ++#define pcsp_spin_unlock spin_unlock ++#define pcsp_spin_lock_irqsave spin_lock_irqsave ++#define pcsp_spin_unlock_irqrestore spin_unlock_irqrestore ++#endif ++ + /* + * PC Speaker beeper driver for Linux + * +@@ -21,7 +35,7 @@ + { + unsigned long flags; + +- raw_spin_lock_irqsave(&i8253_lock, flags); ++ pcsp_spin_lock_irqsave(&i8253_lock, flags); + + if (count) { + /* set command for counter 2, 2 byte write */ +@@ -36,7 +50,7 @@ + outb(inb_p(0x61) & 0xFC, 0x61); + } + +- raw_spin_unlock_irqrestore(&i8253_lock, flags); ++ pcsp_spin_unlock_irqrestore(&i8253_lock, flags); + } + + void pcspkr_stop_sound(void) diff --git a/drivers/pcsp/pcsp_lib.c b/drivers/pcsp/pcsp_lib.c deleted file mode 100644 index f31895cf1..000000000 --- a/drivers/pcsp/pcsp_lib.c +++ /dev/null @@ -1,5 +0,0 @@ -#include "adriver.h" -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 28) -#define hrtimer_get_expires(t) (t)->expires -#endif -#include "../../alsa-kernel/drivers/pcsp/pcsp_lib.c" diff --git a/drivers/pcsp/pcsp_lib.patch b/drivers/pcsp/pcsp_lib.patch new file mode 100644 index 000000000..84fadcc89 --- /dev/null +++ b/drivers/pcsp/pcsp_lib.patch @@ -0,0 +1,68 @@ +--- ../../alsa-kernel/drivers/pcsp/pcsp_lib.c 2010-05-21 16:36:59.457637275 +0200 ++++ pcsp_lib.c 2010-05-31 12:35:16.677546512 +0200 +@@ -1,3 +1,20 @@ ++#include "adriver.h" ++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 28) ++#define hrtimer_get_expires(t) (t)->expires ++#endif ++ ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35) ++#define pcsp_spin_lock raw_spin_lock ++#define pcsp_spin_unlock raw_spin_unlock ++#define pcsp_spin_lock_irqsave raw_spin_lock_irqsave ++#define pcsp_spin_unlock_irqrestore raw_spin_unlock_irqrestore ++#else ++#define pcsp_spin_lock spin_lock ++#define pcsp_spin_unlock spin_unlock ++#define pcsp_spin_lock_irqsave spin_lock_irqsave ++#define pcsp_spin_unlock_irqrestore spin_unlock_irqrestore ++#endif ++ + /* + * PC-Speaker driver for Linux + * +@@ -66,7 +83,7 @@ + timer_cnt = val * CUR_DIV() / 256; + + if (timer_cnt && chip->enable) { +- raw_spin_lock_irqsave(&i8253_lock, flags); ++ pcsp_spin_lock_irqsave(&i8253_lock, flags); + if (!nforce_wa) { + outb_p(chip->val61, 0x61); + outb_p(timer_cnt, 0x42); +@@ -75,7 +92,7 @@ + outb(chip->val61 ^ 2, 0x61); + chip->thalf = 1; + } +- raw_spin_unlock_irqrestore(&i8253_lock, flags); ++ pcsp_spin_unlock_irqrestore(&i8253_lock, flags); + } + + chip->ns_rem = PCSP_PERIOD_NS(); +@@ -159,10 +176,10 @@ + return -EIO; + } + +- raw_spin_lock(&i8253_lock); ++ pcsp_spin_lock(&i8253_lock); + chip->val61 = inb(0x61) | 0x03; + outb_p(0x92, 0x43); /* binary, mode 1, LSB only, ch 2 */ +- raw_spin_unlock(&i8253_lock); ++ pcsp_spin_unlock(&i8253_lock); + atomic_set(&chip->timer_active, 1); + chip->thalf = 0; + +@@ -179,11 +196,11 @@ + return; + + atomic_set(&chip->timer_active, 0); +- raw_spin_lock(&i8253_lock); ++ pcsp_spin_lock(&i8253_lock); + /* restore the timer */ + outb_p(0xb6, 0x43); /* binary, mode 3, LSB/MSB, ch 2 */ + outb(chip->val61 & 0xFC, 0x61); +- raw_spin_unlock(&i8253_lock); ++ pcsp_spin_unlock(&i8253_lock); + } + + /* diff --git a/pcmcia/pdaudiocf/pdaudiocf-2.6.34.c b/pcmcia/pdaudiocf/pdaudiocf-2.6.34.c new file mode 100644 index 000000000..edaa72912 --- /dev/null +++ b/pcmcia/pdaudiocf/pdaudiocf-2.6.34.c @@ -0,0 +1,319 @@ +/* + * Driver for Sound Core PDAudioCF soundcard + * + * Copyright (c) 2003 by Jaroslav Kysela <perex@perex.cz> + * + * 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 <sound/core.h> +#include <linux/slab.h> +#include <linux/moduleparam.h> +#include <pcmcia/ciscode.h> +#include <pcmcia/cisreg.h> +#include "pdaudiocf.h" +#include <sound/initval.h> +#include <linux/init.h> + +/* + */ + +#define CARD_NAME "PDAudio-CF" + +MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>"); +MODULE_DESCRIPTION("Sound Core " CARD_NAME); +MODULE_LICENSE("GPL"); +MODULE_SUPPORTED_DEVICE("{{Sound Core," CARD_NAME "}}"); + +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 switches */ + +module_param_array(index, int, NULL, 0444); +MODULE_PARM_DESC(index, "Index value for " CARD_NAME " soundcard."); +module_param_array(id, charp, NULL, 0444); +MODULE_PARM_DESC(id, "ID string for " CARD_NAME " soundcard."); +module_param_array(enable, bool, NULL, 0444); +MODULE_PARM_DESC(enable, "Enable " CARD_NAME " soundcard."); + +/* + */ + +static struct snd_card *card_list[SNDRV_CARDS]; + +/* + * prototypes + */ +static int pdacf_config(struct pcmcia_device *link); +static void snd_pdacf_detach(struct pcmcia_device *p_dev); + +static void pdacf_release(struct pcmcia_device *link) +{ + pcmcia_disable_device(link); +} + +/* + * destructor + */ +static int snd_pdacf_free(struct snd_pdacf *pdacf) +{ + struct pcmcia_device *link = pdacf->p_dev; + + pdacf_release(link); + + card_list[pdacf->index] = NULL; + pdacf->card = NULL; + + kfree(pdacf); + return 0; +} + +static int snd_pdacf_dev_free(struct snd_device *device) +{ + struct snd_pdacf *chip = device->device_data; + return snd_pdacf_free(chip); +} + +/* + * snd_pdacf_attach - attach callback for cs + */ +static int snd_pdacf_probe(struct pcmcia_device *link) +{ + int i, err; + struct snd_pdacf *pdacf; + struct snd_card *card; + static struct snd_device_ops ops = { + .dev_free = snd_pdacf_dev_free, + }; + + snd_printdd(KERN_DEBUG "pdacf_attach called\n"); + /* find an empty slot from the card list */ + for (i = 0; i < SNDRV_CARDS; i++) { + if (! card_list[i]) + break; + } + if (i >= SNDRV_CARDS) { + snd_printk(KERN_ERR "pdacf: too many cards found\n"); + return -EINVAL; + } + if (! enable[i]) + return -ENODEV; /* disabled explicitly */ + + /* ok, create a card instance */ + err = snd_card_create(index[i], id[i], THIS_MODULE, 0, &card); + if (err < 0) { + snd_printk(KERN_ERR "pdacf: cannot create a card instance\n"); + return err; + } + + pdacf = snd_pdacf_create(card); + if (!pdacf) { + snd_card_free(card); + return -ENOMEM; + } + + err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, pdacf, &ops); + if (err < 0) { + kfree(pdacf); + snd_card_free(card); + return err; + } + + snd_card_set_dev(card, &link->dev); + + pdacf->index = i; + card_list[i] = card; + + pdacf->p_dev = link; + link->priv = pdacf; + + link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; + link->io.NumPorts1 = 16; + + link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_FORCED_PULSE; + /* FIXME: This driver should be updated to allow for dynamic IRQ sharing */ + /* link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING | IRQ_FORCED_PULSE; */ + + link->irq.Handler = pdacf_interrupt; + link->conf.Attributes = CONF_ENABLE_IRQ; + link->conf.IntType = INT_MEMORY_AND_IO; + link->conf.ConfigIndex = 1; + link->conf.Present = PRESENT_OPTION; + + return pdacf_config(link); +} + + +/** + * snd_pdacf_assign_resources - initialize the hardware and card instance. + * @port: i/o port for the card + * @irq: irq number for the card + * + * this function assigns the specified port and irq, boot the card, + * create pcm and control instances, and initialize the rest hardware. + * + * returns 0 if successful, or a negative error code. + */ +static int snd_pdacf_assign_resources(struct snd_pdacf *pdacf, int port, int irq) +{ + int err; + struct snd_card *card = pdacf->card; + + snd_printdd(KERN_DEBUG "pdacf assign resources: port = 0x%x, irq = %d\n", port, irq); + pdacf->port = port; + pdacf->irq = irq; + pdacf->chip_status |= PDAUDIOCF_STAT_IS_CONFIGURED; + + err = snd_pdacf_ak4117_create(pdacf); + if (err < 0) + return err; + + strcpy(card->driver, "PDAudio-CF"); + sprintf(card->shortname, "Core Sound %s", card->driver); + sprintf(card->longname, "%s at 0x%x, irq %i", + card->shortname, port, irq); + + err = snd_pdacf_pcm_new(pdacf); + if (err < 0) + return err; + + if ((err = snd_card_register(card)) < 0) + return err; + + return 0; +} + + +/* + * snd_pdacf_detach - detach callback for cs + */ +static void snd_pdacf_detach(struct pcmcia_device *link) +{ + struct snd_pdacf *chip = link->priv; + + snd_printdd(KERN_DEBUG "pdacf_detach called\n"); + + if (chip->chip_status & PDAUDIOCF_STAT_IS_CONFIGURED) + snd_pdacf_powerdown(chip); + chip->chip_status |= PDAUDIOCF_STAT_IS_STALE; /* to be sure */ + snd_card_disconnect(chip->card); + snd_card_free_when_closed(chip->card); +} + +/* + * configuration callback + */ + +static int pdacf_config(struct pcmcia_device *link) +{ + struct snd_pdacf *pdacf = link->priv; + int ret; + + snd_printdd(KERN_DEBUG "pdacf_config called\n"); + link->conf.ConfigIndex = 0x5; + + ret = pcmcia_request_io(link, &link->io); + if (ret) + goto failed; + + ret = pcmcia_request_irq(link, &link->irq); + if (ret) + goto failed; + + ret = pcmcia_request_configuration(link, &link->conf); + if (ret) + goto failed; + + if (snd_pdacf_assign_resources(pdacf, link->io.BasePort1, link->irq.AssignedIRQ) < 0) + goto failed; + + link->dev_node = &pdacf->node; + return 0; + +failed: + pcmcia_disable_device(link); + return -ENODEV; +} + +#ifdef CONFIG_PM + +static int pdacf_suspend(struct pcmcia_device *link) +{ + struct snd_pdacf *chip = link->priv; + + snd_printdd(KERN_DEBUG "SUSPEND\n"); + if (chip) { + snd_printdd(KERN_DEBUG "snd_pdacf_suspend calling\n"); + snd_pdacf_suspend(chip, PMSG_SUSPEND); + } + + return 0; +} + +static int pdacf_resume(struct pcmcia_device *link) +{ + struct snd_pdacf *chip = link->priv; + + snd_printdd(KERN_DEBUG "RESUME\n"); + if (pcmcia_dev_present(link)) { + if (chip) { + snd_printdd(KERN_DEBUG "calling snd_pdacf_resume\n"); + snd_pdacf_resume(chip); + } + } + snd_printdd(KERN_DEBUG "resume done!\n"); + + return 0; +} + +#endif + +/* + * Module entry points + */ +static struct pcmcia_device_id snd_pdacf_ids[] = { + /* this is too general PCMCIA_DEVICE_MANF_CARD(0x015d, 0x4c45), */ + PCMCIA_DEVICE_PROD_ID12("Core Sound","PDAudio-CF",0x396d19d2,0x71717b49), + PCMCIA_DEVICE_NULL +}; +MODULE_DEVICE_TABLE(pcmcia, snd_pdacf_ids); + +static struct pcmcia_driver pdacf_cs_driver = { + .owner = THIS_MODULE, + .drv = { + .name = "snd-pdaudiocf", + }, + .probe = snd_pdacf_probe, + .remove = snd_pdacf_detach, + .id_table = snd_pdacf_ids, +#ifdef CONFIG_PM + .suspend = pdacf_suspend, + .resume = pdacf_resume, +#endif + +}; + +static int __init init_pdacf(void) +{ + return pcmcia_register_driver(&pdacf_cs_driver); +} + +static void __exit exit_pdacf(void) +{ + pcmcia_unregister_driver(&pdacf_cs_driver); +} + +module_init(init_pdacf); +module_exit(exit_pdacf); diff --git a/pcmcia/pdaudiocf/pdaudiocf-2.6.34.h b/pcmcia/pdaudiocf/pdaudiocf-2.6.34.h new file mode 100644 index 000000000..b06018381 --- /dev/null +++ b/pcmcia/pdaudiocf/pdaudiocf-2.6.34.h @@ -0,0 +1,145 @@ +/* + * Driver for Sound Cors PDAudioCF soundcard + * + * Copyright (c) 2003 by Jaroslav Kysela <perex@perex.cz> + * + * 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 + */ + +#ifndef __PDAUDIOCF_H +#define __PDAUDIOCF_H + +#include <sound/pcm.h> +#include <asm/io.h> +#include <linux/interrupt.h> +#include <pcmcia/cs_types.h> +#include <pcmcia/cs.h> +#include <pcmcia/cistpl.h> +#include <pcmcia/ds.h> + +#include <sound/ak4117.h> + +/* PDAUDIOCF registers */ +#define PDAUDIOCF_REG_MD 0x00 /* music data, R/O */ +#define PDAUDIOCF_REG_WDP 0x02 /* write data pointer / 2, R/O */ +#define PDAUDIOCF_REG_RDP 0x04 /* read data pointer / 2, R/O */ +#define PDAUDIOCF_REG_TCR 0x06 /* test control register W/O */ +#define PDAUDIOCF_REG_SCR 0x08 /* status and control, R/W (see bit description) */ +#define PDAUDIOCF_REG_ISR 0x0a /* interrupt status, R/O */ +#define PDAUDIOCF_REG_IER 0x0c /* interrupt enable, R/W */ +#define PDAUDIOCF_REG_AK_IFR 0x0e /* AK interface register, R/W */ + +/* PDAUDIOCF_REG_TCR */ +#define PDAUDIOCF_ELIMAKMBIT (1<<0) /* simulate AKM music data */ +#define PDAUDIOCF_TESTDATASEL (1<<1) /* test data selection, 0 = 0x55, 1 = pseudo-random */ + +/* PDAUDIOCF_REG_SCR */ +#define PDAUDIOCF_AK_SBP (1<<0) /* serial port busy flag */ +#define PDAUDIOCF_RST (1<<2) /* FPGA, AKM + SRAM buffer reset */ +#define PDAUDIOCF_PDN (1<<3) /* power down bit */ +#define PDAUDIOCF_CLKDIV0 (1<<4) /* choose 24.576Mhz clock divided by 1,2,3 or 4 */ +#define PDAUDIOCF_CLKDIV1 (1<<5) +#define PDAUDIOCF_RECORD (1<<6) /* start capturing to SRAM */ +#define PDAUDIOCF_AK_SDD (1<<7) /* music data detected */ +#define PDAUDIOCF_RED_LED_OFF (1<<8) /* red LED off override */ +#define PDAUDIOCF_BLUE_LED_OFF (1<<9) /* blue LED off override */ +#define PDAUDIOCF_DATAFMT0 (1<<10) /* data format bits: 00 = 16-bit, 01 = 18-bit */ +#define PDAUDIOCF_DATAFMT1 (1<<11) /* 10 = 20-bit, 11 = 24-bit, all right justified */ +#define PDAUDIOCF_FPGAREV(x) ((x>>12)&0x0f) /* FPGA revision */ + +/* PDAUDIOCF_REG_ISR */ +#define PDAUDIOCF_IRQLVL (1<<0) /* Buffer level IRQ */ +#define PDAUDIOCF_IRQOVR (1<<1) /* Overrun IRQ */ +#define PDAUDIOCF_IRQAKM (1<<2) /* AKM IRQ */ + +/* PDAUDIOCF_REG_IER */ +#define PDAUDIOCF_IRQLVLEN0 (1<<0) /* fill threshold levels; 00 = none, 01 = 1/8th of buffer */ +#define PDAUDIOCF_IRQLVLEN1 (1<<1) /* 10 = 1/4th of buffer, 11 = 1/2th of buffer */ +#define PDAUDIOCF_IRQOVREN (1<<2) /* enable overrun IRQ */ +#define PDAUDIOCF_IRQAKMEN (1<<3) /* enable AKM IRQ */ +#define PDAUDIOCF_BLUEDUTY0 (1<<8) /* blue LED duty cycle; 00 = 100%, 01 = 50% */ +#define PDAUDIOCF_BLUEDUTY1 (1<<9) /* 02 = 25%, 11 = 12% */ +#define PDAUDIOCF_REDDUTY0 (1<<10) /* red LED duty cycle; 00 = 100%, 01 = 50% */ +#define PDAUDIOCF_REDDUTY1 (1<<11) /* 02 = 25%, 11 = 12% */ +#define PDAUDIOCF_BLUESDD (1<<12) /* blue LED against SDD bit */ +#define PDAUDIOCF_BLUEMODULATE (1<<13) /* save power when 100% duty cycle selected */ +#define PDAUDIOCF_REDMODULATE (1<<14) /* save power when 100% duty cycle selected */ +#define PDAUDIOCF_HALFRATE (1<<15) /* slow both LED blinks by half (also spdif detect rate) */ + +/* chip status */ +#define PDAUDIOCF_STAT_IS_STALE (1<<0) +#define PDAUDIOCF_STAT_IS_CONFIGURED (1<<1) +#define PDAUDIOCF_STAT_IS_SUSPENDED (1<<2) + +struct snd_pdacf { + struct snd_card *card; + int index; + + unsigned long port; + int irq; + + spinlock_t reg_lock; + unsigned short regmap[8]; + unsigned short suspend_reg_scr; + struct tasklet_struct tq; + + spinlock_t ak4117_lock; + struct ak4117 *ak4117; + + unsigned int chip_status; + + struct snd_pcm *pcm; + struct snd_pcm_substream *pcm_substream; + unsigned int pcm_running: 1; + unsigned int pcm_channels; + unsigned int pcm_swab; + unsigned int pcm_little; + unsigned int pcm_frame; + unsigned int pcm_sample; + unsigned int pcm_xor; + unsigned int pcm_size; + unsigned int pcm_period; + unsigned int pcm_tdone; + unsigned int pcm_hwptr; + void *pcm_area; + + /* pcmcia stuff */ + struct pcmcia_device *p_dev; + dev_node_t node; +}; + +static inline void pdacf_reg_write(struct snd_pdacf *chip, unsigned char reg, unsigned short val) +{ + outw(chip->regmap[reg>>1] = val, chip->port + reg); +} + +static inline unsigned short pdacf_reg_read(struct snd_pdacf *chip, unsigned char reg) +{ + return inw(chip->port + reg); +} + +struct snd_pdacf *snd_pdacf_create(struct snd_card *card); +int snd_pdacf_ak4117_create(struct snd_pdacf *pdacf); +void snd_pdacf_powerdown(struct snd_pdacf *chip); +#ifdef CONFIG_PM +int snd_pdacf_suspend(struct snd_pdacf *chip, pm_message_t state); +int snd_pdacf_resume(struct snd_pdacf *chip); +#endif +int snd_pdacf_pcm_new(struct snd_pdacf *chip); +irqreturn_t pdacf_interrupt(int irq, void *dev); +void pdacf_tasklet(unsigned long private_data); +void pdacf_reinit(struct snd_pdacf *chip, int resume); + +#endif /* __PDAUDIOCF_H */ diff --git a/pcmcia/pdaudiocf/pdaudiocf-old.h b/pcmcia/pdaudiocf/pdaudiocf-old.h new file mode 100644 index 000000000..139401693 --- /dev/null +++ b/pcmcia/pdaudiocf/pdaudiocf-old.h @@ -0,0 +1,127 @@ +/* old header */ + +#ifndef __PDAUDIOCF_H +#define __PDAUDIOCF_H + +#include <sound/pcm.h> +#include <asm/io.h> +#include <linux/interrupt.h> +#include <pcmcia/cs_types.h> +#include <pcmcia/cs.h> +#include <pcmcia/cistpl.h> +#include <pcmcia/ds.h> + +#include <sound/ak4117.h> + +/* PDAUDIOCF registers */ +#define PDAUDIOCF_REG_MD 0x00 /* music data, R/O */ +#define PDAUDIOCF_REG_WDP 0x02 /* write data pointer / 2, R/O */ +#define PDAUDIOCF_REG_RDP 0x04 /* read data pointer / 2, R/O */ +#define PDAUDIOCF_REG_TCR 0x06 /* test control register W/O */ +#define PDAUDIOCF_REG_SCR 0x08 /* status and control, R/W (see bit description) */ +#define PDAUDIOCF_REG_ISR 0x0a /* interrupt status, R/O */ +#define PDAUDIOCF_REG_IER 0x0c /* interrupt enable, R/W */ +#define PDAUDIOCF_REG_AK_IFR 0x0e /* AK interface register, R/W */ + +/* PDAUDIOCF_REG_TCR */ +#define PDAUDIOCF_ELIMAKMBIT (1<<0) /* simulate AKM music data */ +#define PDAUDIOCF_TESTDATASEL (1<<1) /* test data selection, 0 = 0x55, 1 = pseudo-random */ + +/* PDAUDIOCF_REG_SCR */ +#define PDAUDIOCF_AK_SBP (1<<0) /* serial port busy flag */ +#define PDAUDIOCF_RST (1<<2) /* FPGA, AKM + SRAM buffer reset */ +#define PDAUDIOCF_PDN (1<<3) /* power down bit */ +#define PDAUDIOCF_CLKDIV0 (1<<4) /* choose 24.576Mhz clock divided by 1,2,3 or 4 */ +#define PDAUDIOCF_CLKDIV1 (1<<5) +#define PDAUDIOCF_RECORD (1<<6) /* start capturing to SRAM */ +#define PDAUDIOCF_AK_SDD (1<<7) /* music data detected */ +#define PDAUDIOCF_RED_LED_OFF (1<<8) /* red LED off override */ +#define PDAUDIOCF_BLUE_LED_OFF (1<<9) /* blue LED off override */ +#define PDAUDIOCF_DATAFMT0 (1<<10) /* data format bits: 00 = 16-bit, 01 = 18-bit */ +#define PDAUDIOCF_DATAFMT1 (1<<11) /* 10 = 20-bit, 11 = 24-bit, all right justified */ +#define PDAUDIOCF_FPGAREV(x) ((x>>12)&0x0f) /* FPGA revision */ + +/* PDAUDIOCF_REG_ISR */ +#define PDAUDIOCF_IRQLVL (1<<0) /* Buffer level IRQ */ +#define PDAUDIOCF_IRQOVR (1<<1) /* Overrun IRQ */ +#define PDAUDIOCF_IRQAKM (1<<2) /* AKM IRQ */ + +/* PDAUDIOCF_REG_IER */ +#define PDAUDIOCF_IRQLVLEN0 (1<<0) /* fill threshold levels; 00 = none, 01 = 1/8th of buffer */ +#define PDAUDIOCF_IRQLVLEN1 (1<<1) /* 10 = 1/4th of buffer, 11 = 1/2th of buffer */ +#define PDAUDIOCF_IRQOVREN (1<<2) /* enable overrun IRQ */ +#define PDAUDIOCF_IRQAKMEN (1<<3) /* enable AKM IRQ */ +#define PDAUDIOCF_BLUEDUTY0 (1<<8) /* blue LED duty cycle; 00 = 100%, 01 = 50% */ +#define PDAUDIOCF_BLUEDUTY1 (1<<9) /* 02 = 25%, 11 = 12% */ +#define PDAUDIOCF_REDDUTY0 (1<<10) /* red LED duty cycle; 00 = 100%, 01 = 50% */ +#define PDAUDIOCF_REDDUTY1 (1<<11) /* 02 = 25%, 11 = 12% */ +#define PDAUDIOCF_BLUESDD (1<<12) /* blue LED against SDD bit */ +#define PDAUDIOCF_BLUEMODULATE (1<<13) /* save power when 100% duty cycle selected */ +#define PDAUDIOCF_REDMODULATE (1<<14) /* save power when 100% duty cycle selected */ +#define PDAUDIOCF_HALFRATE (1<<15) /* slow both LED blinks by half (also spdif detect rate) */ + +/* chip status */ +#define PDAUDIOCF_STAT_IS_STALE (1<<0) +#define PDAUDIOCF_STAT_IS_CONFIGURED (1<<1) +#define PDAUDIOCF_STAT_IS_SUSPENDED (1<<2) + +struct snd_pdacf { + struct snd_card *card; + int index; + + unsigned long port; + int irq; + + spinlock_t reg_lock; + unsigned short regmap[8]; + unsigned short suspend_reg_scr; + struct tasklet_struct tq; + + spinlock_t ak4117_lock; + struct ak4117 *ak4117; + + unsigned int chip_status; + + struct snd_pcm *pcm; + struct snd_pcm_substream *pcm_substream; + unsigned int pcm_running: 1; + unsigned int pcm_channels; + unsigned int pcm_swab; + unsigned int pcm_little; + unsigned int pcm_frame; + unsigned int pcm_sample; + unsigned int pcm_xor; + unsigned int pcm_size; + unsigned int pcm_period; + unsigned int pcm_tdone; + unsigned int pcm_hwptr; + void *pcm_area; + + /* pcmcia stuff */ + dev_link_t link; + dev_node_t node; +}; + +static inline void pdacf_reg_write(struct snd_pdacf *chip, unsigned char reg, unsigned short val) +{ + outw(chip->regmap[reg>>1] = val, chip->port + reg); +} + +static inline unsigned short pdacf_reg_read(struct snd_pdacf *chip, unsigned char reg) +{ + return inw(chip->port + reg); +} + +struct snd_pdacf *snd_pdacf_create(struct snd_card *card); +int snd_pdacf_ak4117_create(struct snd_pdacf *pdacf); +void snd_pdacf_powerdown(struct snd_pdacf *chip); +#ifdef CONFIG_PM +int snd_pdacf_suspend(struct snd_pdacf *chip, pm_message_t state); +int snd_pdacf_resume(struct snd_pdacf *chip); +#endif +int snd_pdacf_pcm_new(struct snd_pdacf *chip); +irqreturn_t pdacf_interrupt(int irq, void *dev, struct pt_regs *regs); +void pdacf_tasklet(unsigned long private_data); +void pdacf_reinit(struct snd_pdacf *chip, int resume); + +#endif /* __PDAUDIOCF_H */ diff --git a/pcmcia/pdaudiocf/pdaudiocf.c b/pcmcia/pdaudiocf/pdaudiocf.c index 1d6e11514..7f5e08d3a 100644 --- a/pcmcia/pdaudiocf/pdaudiocf.c +++ b/pcmcia/pdaudiocf/pdaudiocf.c @@ -4,6 +4,8 @@ #include "pdaudiocf_old.c" #elif LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) #include "pdaudiocf-2.6.16.c" +#elif LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,34) +#include "pdaudiocf-2.6.34.c" #else #include "adriver.h" #include "../../alsa-kernel/pcmcia/pdaudiocf/pdaudiocf.c" diff --git a/pcmcia/pdaudiocf/pdaudiocf.h b/pcmcia/pdaudiocf/pdaudiocf.h index 6f92e2f8c..94b2952e8 100644 --- a/pcmcia/pdaudiocf/pdaudiocf.h +++ b/pcmcia/pdaudiocf/pdaudiocf.h @@ -1,132 +1,7 @@ -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,16) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35) #include "../../alsa-kernel/pcmcia/pdaudiocf/pdaudiocf.h" +#elif LINUX_VERSION_CODE > KERNEL_VERSION(2,6,16) +#include "pdaudiocf-2.6.34.h" #else - -/* old header */ - -#ifndef __PDAUDIOCF_H -#define __PDAUDIOCF_H - -#include <sound/pcm.h> -#include <asm/io.h> -#include <linux/interrupt.h> -#include <pcmcia/cs_types.h> -#include <pcmcia/cs.h> -#include <pcmcia/cistpl.h> -#include <pcmcia/ds.h> - -#include <sound/ak4117.h> - -/* PDAUDIOCF registers */ -#define PDAUDIOCF_REG_MD 0x00 /* music data, R/O */ -#define PDAUDIOCF_REG_WDP 0x02 /* write data pointer / 2, R/O */ -#define PDAUDIOCF_REG_RDP 0x04 /* read data pointer / 2, R/O */ -#define PDAUDIOCF_REG_TCR 0x06 /* test control register W/O */ -#define PDAUDIOCF_REG_SCR 0x08 /* status and control, R/W (see bit description) */ -#define PDAUDIOCF_REG_ISR 0x0a /* interrupt status, R/O */ -#define PDAUDIOCF_REG_IER 0x0c /* interrupt enable, R/W */ -#define PDAUDIOCF_REG_AK_IFR 0x0e /* AK interface register, R/W */ - -/* PDAUDIOCF_REG_TCR */ -#define PDAUDIOCF_ELIMAKMBIT (1<<0) /* simulate AKM music data */ -#define PDAUDIOCF_TESTDATASEL (1<<1) /* test data selection, 0 = 0x55, 1 = pseudo-random */ - -/* PDAUDIOCF_REG_SCR */ -#define PDAUDIOCF_AK_SBP (1<<0) /* serial port busy flag */ -#define PDAUDIOCF_RST (1<<2) /* FPGA, AKM + SRAM buffer reset */ -#define PDAUDIOCF_PDN (1<<3) /* power down bit */ -#define PDAUDIOCF_CLKDIV0 (1<<4) /* choose 24.576Mhz clock divided by 1,2,3 or 4 */ -#define PDAUDIOCF_CLKDIV1 (1<<5) -#define PDAUDIOCF_RECORD (1<<6) /* start capturing to SRAM */ -#define PDAUDIOCF_AK_SDD (1<<7) /* music data detected */ -#define PDAUDIOCF_RED_LED_OFF (1<<8) /* red LED off override */ -#define PDAUDIOCF_BLUE_LED_OFF (1<<9) /* blue LED off override */ -#define PDAUDIOCF_DATAFMT0 (1<<10) /* data format bits: 00 = 16-bit, 01 = 18-bit */ -#define PDAUDIOCF_DATAFMT1 (1<<11) /* 10 = 20-bit, 11 = 24-bit, all right justified */ -#define PDAUDIOCF_FPGAREV(x) ((x>>12)&0x0f) /* FPGA revision */ - -/* PDAUDIOCF_REG_ISR */ -#define PDAUDIOCF_IRQLVL (1<<0) /* Buffer level IRQ */ -#define PDAUDIOCF_IRQOVR (1<<1) /* Overrun IRQ */ -#define PDAUDIOCF_IRQAKM (1<<2) /* AKM IRQ */ - -/* PDAUDIOCF_REG_IER */ -#define PDAUDIOCF_IRQLVLEN0 (1<<0) /* fill threshold levels; 00 = none, 01 = 1/8th of buffer */ -#define PDAUDIOCF_IRQLVLEN1 (1<<1) /* 10 = 1/4th of buffer, 11 = 1/2th of buffer */ -#define PDAUDIOCF_IRQOVREN (1<<2) /* enable overrun IRQ */ -#define PDAUDIOCF_IRQAKMEN (1<<3) /* enable AKM IRQ */ -#define PDAUDIOCF_BLUEDUTY0 (1<<8) /* blue LED duty cycle; 00 = 100%, 01 = 50% */ -#define PDAUDIOCF_BLUEDUTY1 (1<<9) /* 02 = 25%, 11 = 12% */ -#define PDAUDIOCF_REDDUTY0 (1<<10) /* red LED duty cycle; 00 = 100%, 01 = 50% */ -#define PDAUDIOCF_REDDUTY1 (1<<11) /* 02 = 25%, 11 = 12% */ -#define PDAUDIOCF_BLUESDD (1<<12) /* blue LED against SDD bit */ -#define PDAUDIOCF_BLUEMODULATE (1<<13) /* save power when 100% duty cycle selected */ -#define PDAUDIOCF_REDMODULATE (1<<14) /* save power when 100% duty cycle selected */ -#define PDAUDIOCF_HALFRATE (1<<15) /* slow both LED blinks by half (also spdif detect rate) */ - -/* chip status */ -#define PDAUDIOCF_STAT_IS_STALE (1<<0) -#define PDAUDIOCF_STAT_IS_CONFIGURED (1<<1) -#define PDAUDIOCF_STAT_IS_SUSPENDED (1<<2) - -struct snd_pdacf { - struct snd_card *card; - int index; - - unsigned long port; - int irq; - - spinlock_t reg_lock; - unsigned short regmap[8]; - unsigned short suspend_reg_scr; - struct tasklet_struct tq; - - spinlock_t ak4117_lock; - struct ak4117 *ak4117; - - unsigned int chip_status; - - struct snd_pcm *pcm; - struct snd_pcm_substream *pcm_substream; - unsigned int pcm_running: 1; - unsigned int pcm_channels; - unsigned int pcm_swab; - unsigned int pcm_little; - unsigned int pcm_frame; - unsigned int pcm_sample; - unsigned int pcm_xor; - unsigned int pcm_size; - unsigned int pcm_period; - unsigned int pcm_tdone; - unsigned int pcm_hwptr; - void *pcm_area; - - /* pcmcia stuff */ - dev_link_t link; - dev_node_t node; -}; - -static inline void pdacf_reg_write(struct snd_pdacf *chip, unsigned char reg, unsigned short val) -{ - outw(chip->regmap[reg>>1] = val, chip->port + reg); -} - -static inline unsigned short pdacf_reg_read(struct snd_pdacf *chip, unsigned char reg) -{ - return inw(chip->port + reg); -} - -struct snd_pdacf *snd_pdacf_create(struct snd_card *card); -int snd_pdacf_ak4117_create(struct snd_pdacf *pdacf); -void snd_pdacf_powerdown(struct snd_pdacf *chip); -#ifdef CONFIG_PM -int snd_pdacf_suspend(struct snd_pdacf *chip, pm_message_t state); -int snd_pdacf_resume(struct snd_pdacf *chip); -#endif -int snd_pdacf_pcm_new(struct snd_pdacf *chip); -irqreturn_t pdacf_interrupt(int irq, void *dev, struct pt_regs *regs); -void pdacf_tasklet(unsigned long private_data); -void pdacf_reinit(struct snd_pdacf *chip, int resume); - -#endif /* __PDAUDIOCF_H */ +#include "vxpocket-old.h" #endif diff --git a/pcmcia/vx/vxpocket-2.6.34.c b/pcmcia/vx/vxpocket-2.6.34.c new file mode 100644 index 000000000..7be3b3357 --- /dev/null +++ b/pcmcia/vx/vxpocket-2.6.34.c @@ -0,0 +1,389 @@ +/* + * Driver for Digigram VXpocket V2/440 soundcards + * + * Copyright (c) 2002 by Takashi Iwai <tiwai@suse.de> + * + * 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/moduleparam.h> +#include <sound/core.h> +#include "vxpocket.h" +#include <pcmcia/ciscode.h> +#include <pcmcia/cisreg.h> +#include <sound/initval.h> +#include <sound/tlv.h> + +/* + */ + +MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>"); +MODULE_DESCRIPTION("Digigram VXPocket"); +MODULE_LICENSE("GPL"); +MODULE_SUPPORTED_DEVICE("{{Digigram,VXPocket},{Digigram,VXPocket440}}"); + +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 switches */ +static int ibl[SNDRV_CARDS]; + +module_param_array(index, int, NULL, 0444); +MODULE_PARM_DESC(index, "Index value for VXPocket soundcard."); +module_param_array(id, charp, NULL, 0444); +MODULE_PARM_DESC(id, "ID string for VXPocket soundcard."); +module_param_array(enable, bool, NULL, 0444); +MODULE_PARM_DESC(enable, "Enable VXPocket soundcard."); +module_param_array(ibl, int, NULL, 0444); +MODULE_PARM_DESC(ibl, "Capture IBL size for VXPocket soundcard."); + + +/* + */ + +static unsigned int card_alloc; + + +/* + */ +static void vxpocket_release(struct pcmcia_device *link) +{ + pcmcia_disable_device(link); +} + +/* + * destructor, called from snd_card_free_when_closed() + */ +static int snd_vxpocket_dev_free(struct snd_device *device) +{ + struct vx_core *chip = device->device_data; + + snd_vx_free_firmware(chip); + kfree(chip); + return 0; +} + + +/* + * Hardware information + */ + +/* VX-pocket V2 + * + * 1 DSP, 1 sync UER + * 1 programmable clock (NIY) + * 1 stereo analog input (line/micro) + * 1 stereo analog output + * Only output levels can be modified + */ + +static const DECLARE_TLV_DB_SCALE(db_scale_old_vol, -11350, 50, 0); + +static struct snd_vx_hardware vxpocket_hw = { + .name = "VXPocket", + .type = VX_TYPE_VXPOCKET, + + /* hardware specs */ + .num_codecs = 1, + .num_ins = 1, + .num_outs = 1, + .output_level_max = VX_ANALOG_OUT_LEVEL_MAX, + .output_level_db_scale = db_scale_old_vol, +}; + +/* VX-pocket 440 + * + * 1 DSP, 1 sync UER, 1 sync World Clock (NIY) + * SMPTE (NIY) + * 2 stereo analog input (line/micro) + * 2 stereo analog output + * Only output levels can be modified + * UER, but only for the first two inputs and outputs. + */ + +static struct snd_vx_hardware vxp440_hw = { + .name = "VXPocket440", + .type = VX_TYPE_VXP440, + + /* hardware specs */ + .num_codecs = 2, + .num_ins = 2, + .num_outs = 2, + .output_level_max = VX_ANALOG_OUT_LEVEL_MAX, + .output_level_db_scale = db_scale_old_vol, +}; + + +/* + * create vxpocket instance + */ +static int snd_vxpocket_new(struct snd_card *card, int ibl, + struct pcmcia_device *link, + struct snd_vxpocket **chip_ret) +{ + struct vx_core *chip; + struct snd_vxpocket *vxp; + static struct snd_device_ops ops = { + .dev_free = snd_vxpocket_dev_free, + }; + int err; + + chip = snd_vx_create(card, &vxpocket_hw, &snd_vxpocket_ops, + sizeof(struct snd_vxpocket) - sizeof(struct vx_core)); + if (!chip) + return -ENOMEM; + + err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); + if (err < 0) { + kfree(chip); + return err; + } + chip->ibl.size = ibl; + + vxp = (struct snd_vxpocket *)chip; + + vxp->p_dev = link; + link->priv = chip; + + link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; + link->io.NumPorts1 = 16; + + link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; + + link->irq.Handler = &snd_vx_irq_handler; + + link->conf.Attributes = CONF_ENABLE_IRQ; + link->conf.IntType = INT_MEMORY_AND_IO; + link->conf.ConfigIndex = 1; + link->conf.Present = PRESENT_OPTION; + + *chip_ret = vxp; + return 0; +} + + +/** + * snd_vxpocket_assign_resources - initialize the hardware and card instance. + * @port: i/o port for the card + * @irq: irq number for the card + * + * this function assigns the specified port and irq, boot the card, + * create pcm and control instances, and initialize the rest hardware. + * + * returns 0 if successful, or a negative error code. + */ +static int snd_vxpocket_assign_resources(struct vx_core *chip, int port, int irq) +{ + int err; + struct snd_card *card = chip->card; + struct snd_vxpocket *vxp = (struct snd_vxpocket *)chip; + + snd_printdd(KERN_DEBUG "vxpocket assign resources: port = 0x%x, irq = %d\n", port, irq); + vxp->port = port; + + sprintf(card->shortname, "Digigram %s", card->driver); + sprintf(card->longname, "%s at 0x%x, irq %i", + card->shortname, port, irq); + + chip->irq = irq; + + if ((err = snd_vx_setup_firmware(chip)) < 0) + return err; + + return 0; +} + + +/* + * configuration callback + */ + +static int vxpocket_config(struct pcmcia_device *link) +{ + struct vx_core *chip = link->priv; + struct snd_vxpocket *vxp = (struct snd_vxpocket *)chip; + int ret; + + snd_printdd(KERN_DEBUG "vxpocket_config called\n"); + + /* redefine hardware record according to the VERSION1 string */ + if (!strcmp(link->prod_id[1], "VX-POCKET")) { + snd_printdd("VX-pocket is detected\n"); + } else { + snd_printdd("VX-pocket 440 is detected\n"); + /* overwrite the hardware information */ + chip->hw = &vxp440_hw; + chip->type = vxp440_hw.type; + strcpy(chip->card->driver, vxp440_hw.name); + } + + ret = pcmcia_request_io(link, &link->io); + if (ret) + goto failed; + + ret = pcmcia_request_irq(link, &link->irq); + if (ret) + goto failed; + + ret = pcmcia_request_configuration(link, &link->conf); + if (ret) + goto failed; + + chip->dev = &link->dev; + snd_card_set_dev(chip->card, chip->dev); + + if (snd_vxpocket_assign_resources(chip, link->io.BasePort1, link->irq.AssignedIRQ) < 0) + goto failed; + + link->dev_node = &vxp->node; + return 0; + +failed: + pcmcia_disable_device(link); + return -ENODEV; +} + +#ifdef CONFIG_PM + +static int vxp_suspend(struct pcmcia_device *link) +{ + struct vx_core *chip = link->priv; + + snd_printdd(KERN_DEBUG "SUSPEND\n"); + if (chip) { + snd_printdd(KERN_DEBUG "snd_vx_suspend calling\n"); + snd_vx_suspend(chip, PMSG_SUSPEND); + } + + return 0; +} + +static int vxp_resume(struct pcmcia_device *link) +{ + struct vx_core *chip = link->priv; + + snd_printdd(KERN_DEBUG "RESUME\n"); + if (pcmcia_dev_present(link)) { + //struct snd_vxpocket *vxp = (struct snd_vxpocket *)chip; + if (chip) { + snd_printdd(KERN_DEBUG "calling snd_vx_resume\n"); + snd_vx_resume(chip); + } + } + snd_printdd(KERN_DEBUG "resume done!\n"); + + return 0; +} + +#endif + + +/* + */ +static int vxpocket_probe(struct pcmcia_device *p_dev) +{ + struct snd_card *card; + struct snd_vxpocket *vxp; + int i, err; + + /* find an empty slot from the card list */ + for (i = 0; i < SNDRV_CARDS; i++) { + if (!(card_alloc & (1 << i))) + break; + } + if (i >= SNDRV_CARDS) { + snd_printk(KERN_ERR "vxpocket: too many cards found\n"); + return -EINVAL; + } + if (! enable[i]) + return -ENODEV; /* disabled explicitly */ + + /* ok, create a card instance */ + err = snd_card_create(index[i], id[i], THIS_MODULE, 0, &card); + if (err < 0) { + snd_printk(KERN_ERR "vxpocket: cannot create a card instance\n"); + return err; + } + + err = snd_vxpocket_new(card, ibl[i], p_dev, &vxp); + if (err < 0) { + snd_card_free(card); + return err; + } + card->private_data = vxp; + + vxp->index = i; + card_alloc |= 1 << i; + + vxp->p_dev = p_dev; + + return vxpocket_config(p_dev); +} + +static void vxpocket_detach(struct pcmcia_device *link) +{ + struct snd_vxpocket *vxp; + struct vx_core *chip; + + if (! link) + return; + + vxp = link->priv; + chip = (struct vx_core *)vxp; + card_alloc &= ~(1 << vxp->index); + + chip->chip_status |= VX_STAT_IS_STALE; /* to be sure */ + snd_card_disconnect(chip->card); + vxpocket_release(link); + snd_card_free_when_closed(chip->card); +} + +/* + * Module entry points + */ + +static struct pcmcia_device_id vxp_ids[] = { + PCMCIA_DEVICE_MANF_CARD(0x01f1, 0x0100), + PCMCIA_DEVICE_NULL +}; +MODULE_DEVICE_TABLE(pcmcia, vxp_ids); + +static struct pcmcia_driver vxp_cs_driver = { + .owner = THIS_MODULE, + .drv = { + .name = "snd-vxpocket", + }, + .probe = vxpocket_probe, + .remove = vxpocket_detach, + .id_table = vxp_ids, +#ifdef CONFIG_PM + .suspend = vxp_suspend, + .resume = vxp_resume, +#endif +}; + +static int __init init_vxpocket(void) +{ + return pcmcia_register_driver(&vxp_cs_driver); +} + +static void __exit exit_vxpocket(void) +{ + pcmcia_unregister_driver(&vxp_cs_driver); +} + +module_init(init_vxpocket); +module_exit(exit_vxpocket); diff --git a/pcmcia/vx/vxpocket-2.6.34.h b/pcmcia/vx/vxpocket-2.6.34.h new file mode 100644 index 000000000..27ea00229 --- /dev/null +++ b/pcmcia/vx/vxpocket-2.6.34.h @@ -0,0 +1,93 @@ +/* + * Driver for Digigram VXpocket soundcards + * + * Copyright (c) 2002 by Takashi Iwai <tiwai@suse.de> + * + * 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 + */ + +#ifndef __VXPOCKET_H +#define __VXPOCKET_H + +#include <sound/vx_core.h> + +#include <pcmcia/cs_types.h> +#include <pcmcia/cs.h> +#include <pcmcia/cistpl.h> +#include <pcmcia/ds.h> + +struct snd_vxpocket { + + struct vx_core core; + + unsigned long port; + + int mic_level; /* analog mic level (or boost) */ + + unsigned int regCDSP; /* current CDSP register */ + unsigned int regDIALOG; /* current DIALOG register */ + + int index; /* card index */ + + /* pcmcia stuff */ + struct pcmcia_device *p_dev; + dev_node_t node; +}; + +extern struct snd_vx_ops snd_vxpocket_ops; + +void vx_set_mic_boost(struct vx_core *chip, int boost); +void vx_set_mic_level(struct vx_core *chip, int level); + +int vxp_add_mic_controls(struct vx_core *chip); + +/* Constants used to access the CDSP register (0x08). */ +#define CDSP_MAGIC 0xA7 /* magic value (for read) */ +/* for write */ +#define VXP_CDSP_CLOCKIN_SEL_MASK 0x80 /* 0 (internal), 1 (AES/EBU) */ +#define VXP_CDSP_DATAIN_SEL_MASK 0x40 /* 0 (analog), 1 (UER) */ +#define VXP_CDSP_SMPTE_SEL_MASK 0x20 +#define VXP_CDSP_RESERVED_MASK 0x10 +#define VXP_CDSP_MIC_SEL_MASK 0x08 +#define VXP_CDSP_VALID_IRQ_MASK 0x04 +#define VXP_CDSP_CODEC_RESET_MASK 0x02 +#define VXP_CDSP_DSP_RESET_MASK 0x01 +/* VXPOCKET 240/440 */ +#define P24_CDSP_MICS_SEL_MASK 0x18 +#define P24_CDSP_MIC20_SEL_MASK 0x10 +#define P24_CDSP_MIC38_SEL_MASK 0x08 + +/* Constants used to access the MEMIRQ register (0x0C). */ +#define P44_MEMIRQ_MASTER_SLAVE_SEL_MASK 0x08 +#define P44_MEMIRQ_SYNCED_ALONE_SEL_MASK 0x04 +#define P44_MEMIRQ_WCLK_OUT_IN_SEL_MASK 0x02 /* Not used */ +#define P44_MEMIRQ_WCLK_UER_SEL_MASK 0x01 /* Not used */ + +/* Micro levels (0x0C) */ + +/* Constants used to access the DIALOG register (0x0D). */ +#define VXP_DLG_XILINX_REPROG_MASK 0x80 /* W */ +#define VXP_DLG_DATA_XICOR_MASK 0x80 /* R */ +#define VXP_DLG_RESERVED4_0_MASK 0x40 +#define VXP_DLG_RESERVED2_0_MASK 0x20 +#define VXP_DLG_RESERVED1_0_MASK 0x10 +#define VXP_DLG_DMAWRITE_SEL_MASK 0x08 /* W */ +#define VXP_DLG_DMAREAD_SEL_MASK 0x04 /* W */ +#define VXP_DLG_MEMIRQ_MASK 0x02 /* R */ +#define VXP_DLG_DMA16_SEL_MASK 0x02 /* W */ +#define VXP_DLG_ACK_MEMIRQ_MASK 0x01 /* R/W */ + + +#endif /* __VXPOCKET_H */ diff --git a/pcmcia/vx/vxpocket-old.h b/pcmcia/vx/vxpocket-old.h new file mode 100644 index 000000000..bd46067c6 --- /dev/null +++ b/pcmcia/vx/vxpocket-old.h @@ -0,0 +1,74 @@ +/* old header */ +#ifndef __VXPOCKET_H +#define __VXPOCKET_H + +#include <sound/vx_core.h> + +#include <pcmcia/cs_types.h> +#include <pcmcia/cs.h> +#include <pcmcia/cistpl.h> +#include <pcmcia/ds.h> + +struct snd_vxpocket { + + struct vx_core core; + + unsigned long port; + + int mic_level; /* analog mic level (or boost) */ + + unsigned int regCDSP; /* current CDSP register */ + unsigned int regDIALOG; /* current DIALOG register */ + + int index; /* card index */ + + /* pcmcia stuff */ + dev_link_t link; + dev_node_t node; +}; + +extern struct snd_vx_ops snd_vxpocket_ops; + +void vx_set_mic_boost(struct vx_core *chip, int boost); +void vx_set_mic_level(struct vx_core *chip, int level); + +int vxp_add_mic_controls(struct vx_core *chip); + +/* Constants used to access the CDSP register (0x08). */ +#define CDSP_MAGIC 0xA7 /* magic value (for read) */ +/* for write */ +#define VXP_CDSP_CLOCKIN_SEL_MASK 0x80 /* 0 (internal), 1 (AES/EBU) */ +#define VXP_CDSP_DATAIN_SEL_MASK 0x40 /* 0 (analog), 1 (UER) */ +#define VXP_CDSP_SMPTE_SEL_MASK 0x20 +#define VXP_CDSP_RESERVED_MASK 0x10 +#define VXP_CDSP_MIC_SEL_MASK 0x08 +#define VXP_CDSP_VALID_IRQ_MASK 0x04 +#define VXP_CDSP_CODEC_RESET_MASK 0x02 +#define VXP_CDSP_DSP_RESET_MASK 0x01 +/* VXPOCKET 240/440 */ +#define P24_CDSP_MICS_SEL_MASK 0x18 +#define P24_CDSP_MIC20_SEL_MASK 0x10 +#define P24_CDSP_MIC38_SEL_MASK 0x08 + +/* Constants used to access the MEMIRQ register (0x0C). */ +#define P44_MEMIRQ_MASTER_SLAVE_SEL_MASK 0x08 +#define P44_MEMIRQ_SYNCED_ALONE_SEL_MASK 0x04 +#define P44_MEMIRQ_WCLK_OUT_IN_SEL_MASK 0x02 /* Not used */ +#define P44_MEMIRQ_WCLK_UER_SEL_MASK 0x01 /* Not used */ + +/* Micro levels (0x0C) */ + +/* Constants used to access the DIALOG register (0x0D). */ +#define VXP_DLG_XILINX_REPROG_MASK 0x80 /* W */ +#define VXP_DLG_DATA_XICOR_MASK 0x80 /* R */ +#define VXP_DLG_RESERVED4_0_MASK 0x40 +#define VXP_DLG_RESERVED2_0_MASK 0x20 +#define VXP_DLG_RESERVED1_0_MASK 0x10 +#define VXP_DLG_DMAWRITE_SEL_MASK 0x08 /* W */ +#define VXP_DLG_DMAREAD_SEL_MASK 0x04 /* W */ +#define VXP_DLG_MEMIRQ_MASK 0x02 /* R */ +#define VXP_DLG_DMA16_SEL_MASK 0x02 /* W */ +#define VXP_DLG_ACK_MEMIRQ_MASK 0x01 /* R/W */ + + +#endif /* __VXPOCKET_H */ diff --git a/pcmcia/vx/vxpocket.c b/pcmcia/vx/vxpocket.c index b325c9c0c..76707985b 100644 --- a/pcmcia/vx/vxpocket.c +++ b/pcmcia/vx/vxpocket.c @@ -4,6 +4,8 @@ #include "vxpocket_old.c" #elif LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) #include "vxpocket-2.6.16.c" +#elif LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,34) +#include "vxpocket-2.6.34.c" #else #include "adriver.h" #include "../../alsa-kernel/pcmcia/vx/vxpocket.c" diff --git a/pcmcia/vx/vxpocket.h b/pcmcia/vx/vxpocket.h index f44c0002b..d5f79bd1e 100644 --- a/pcmcia/vx/vxpocket.h +++ b/pcmcia/vx/vxpocket.h @@ -1,79 +1,7 @@ -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,16) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35) #include "../../alsa-kernel/pcmcia/vx/vxpocket.h" +#elif LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 16) +#include "vxpocket-2.6.34.h" #else - -/* old header */ -#ifndef __VXPOCKET_H -#define __VXPOCKET_H - -#include <sound/vx_core.h> - -#include <pcmcia/cs_types.h> -#include <pcmcia/cs.h> -#include <pcmcia/cistpl.h> -#include <pcmcia/ds.h> - -struct snd_vxpocket { - - struct vx_core core; - - unsigned long port; - - int mic_level; /* analog mic level (or boost) */ - - unsigned int regCDSP; /* current CDSP register */ - unsigned int regDIALOG; /* current DIALOG register */ - - int index; /* card index */ - - /* pcmcia stuff */ - dev_link_t link; - dev_node_t node; -}; - -extern struct snd_vx_ops snd_vxpocket_ops; - -void vx_set_mic_boost(struct vx_core *chip, int boost); -void vx_set_mic_level(struct vx_core *chip, int level); - -int vxp_add_mic_controls(struct vx_core *chip); - -/* Constants used to access the CDSP register (0x08). */ -#define CDSP_MAGIC 0xA7 /* magic value (for read) */ -/* for write */ -#define VXP_CDSP_CLOCKIN_SEL_MASK 0x80 /* 0 (internal), 1 (AES/EBU) */ -#define VXP_CDSP_DATAIN_SEL_MASK 0x40 /* 0 (analog), 1 (UER) */ -#define VXP_CDSP_SMPTE_SEL_MASK 0x20 -#define VXP_CDSP_RESERVED_MASK 0x10 -#define VXP_CDSP_MIC_SEL_MASK 0x08 -#define VXP_CDSP_VALID_IRQ_MASK 0x04 -#define VXP_CDSP_CODEC_RESET_MASK 0x02 -#define VXP_CDSP_DSP_RESET_MASK 0x01 -/* VXPOCKET 240/440 */ -#define P24_CDSP_MICS_SEL_MASK 0x18 -#define P24_CDSP_MIC20_SEL_MASK 0x10 -#define P24_CDSP_MIC38_SEL_MASK 0x08 - -/* Constants used to access the MEMIRQ register (0x0C). */ -#define P44_MEMIRQ_MASTER_SLAVE_SEL_MASK 0x08 -#define P44_MEMIRQ_SYNCED_ALONE_SEL_MASK 0x04 -#define P44_MEMIRQ_WCLK_OUT_IN_SEL_MASK 0x02 /* Not used */ -#define P44_MEMIRQ_WCLK_UER_SEL_MASK 0x01 /* Not used */ - -/* Micro levels (0x0C) */ - -/* Constants used to access the DIALOG register (0x0D). */ -#define VXP_DLG_XILINX_REPROG_MASK 0x80 /* W */ -#define VXP_DLG_DATA_XICOR_MASK 0x80 /* R */ -#define VXP_DLG_RESERVED4_0_MASK 0x40 -#define VXP_DLG_RESERVED2_0_MASK 0x20 -#define VXP_DLG_RESERVED1_0_MASK 0x10 -#define VXP_DLG_DMAWRITE_SEL_MASK 0x08 /* W */ -#define VXP_DLG_DMAREAD_SEL_MASK 0x04 /* W */ -#define VXP_DLG_MEMIRQ_MASK 0x02 /* R */ -#define VXP_DLG_DMA16_SEL_MASK 0x02 /* W */ -#define VXP_DLG_ACK_MEMIRQ_MASK 0x01 /* R/W */ - - -#endif /* __VXPOCKET_H */ +#include "vxpocket-old.h" #endif |