2019-05-27 09:55:05 +03:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2005-04-17 02:20:36 +04:00
|
|
|
/*
|
|
|
|
* Driver for C-Media CMI8338 and 8738 PCI soundcards.
|
|
|
|
* Copyright (c) 2000 by Takashi Iwai <tiwai@suse.de>
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Does not work. Warning may block system in capture mode */
|
|
|
|
/* #define USE_VAR48KRATE */
|
|
|
|
|
2015-01-28 18:49:33 +03:00
|
|
|
#include <linux/io.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/gameport.h>
|
2011-07-15 21:13:37 +04:00
|
|
|
#include <linux/module.h>
|
2006-01-16 18:34:20 +03:00
|
|
|
#include <linux/mutex.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
#include <sound/core.h>
|
|
|
|
#include <sound/info.h>
|
|
|
|
#include <sound/control.h>
|
|
|
|
#include <sound/pcm.h>
|
|
|
|
#include <sound/rawmidi.h>
|
|
|
|
#include <sound/mpu401.h>
|
|
|
|
#include <sound/opl3.h>
|
|
|
|
#include <sound/sb.h>
|
|
|
|
#include <sound/asoundef.h>
|
|
|
|
#include <sound/initval.h>
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>");
|
|
|
|
MODULE_DESCRIPTION("C-Media CMI8x38 PCI");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
|
2016-11-13 01:26:41 +03:00
|
|
|
#if IS_REACHABLE(CONFIG_GAMEPORT)
|
2005-04-17 02:20:36 +04:00
|
|
|
#define SUPPORT_JOYSTICK 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
|
|
|
|
static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
|
2011-12-15 07:19:36 +04:00
|
|
|
static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable switches */
|
ALSA: cmipci: Allow disabling MPU port via module option
Patrick May reported that his sound card with CMI8378 chip causes a
crash / reboot when accessing the MIDI port that isn't actually
present on the board. Moreover, despite of the documentation,
passing mpu_port=0 doesn't disable the MIDI port on this board.
It implies that the chip is a newer revision and the MPU401 port is
integrated and mapped on the PCI register. For this chip model, the
driver enables the MPU port unconditionally, so far.
Although fixing the unexpected reboot would be the best solution, it's
not so trivial to identify the cause. So, as a plan B, this patch
extends the existing mpu_port option usage to allow disabling the port
by specifying the value 0, just like we applied for fm_port option in
commit 2f24d159d5ac ("[ALSA] cmipci - Allow to disable integrated FM
port"). As default, the MPU port is still enabled, but user can pass
mpu_port=0 to disable it.
Reported-and-tested-by: Patrick May <dusthillresident@gmail.com>
Link: https://lore.kernel.org/r/20191217081448.1144-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-12-17 11:14:48 +03:00
|
|
|
static long mpu_port[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = 1};
|
2007-02-15 20:56:43 +03:00
|
|
|
static long fm_port[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)]=1};
|
2011-12-15 07:19:36 +04:00
|
|
|
static bool soft_ac3[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)]=1};
|
2005-04-17 02:20:36 +04:00
|
|
|
#ifdef SUPPORT_JOYSTICK
|
|
|
|
static int joystick_port[SNDRV_CARDS];
|
|
|
|
#endif
|
|
|
|
|
|
|
|
module_param_array(index, int, NULL, 0444);
|
|
|
|
MODULE_PARM_DESC(index, "Index value for C-Media PCI soundcard.");
|
|
|
|
module_param_array(id, charp, NULL, 0444);
|
|
|
|
MODULE_PARM_DESC(id, "ID string for C-Media PCI soundcard.");
|
|
|
|
module_param_array(enable, bool, NULL, 0444);
|
|
|
|
MODULE_PARM_DESC(enable, "Enable C-Media PCI soundcard.");
|
2017-04-04 18:54:30 +03:00
|
|
|
module_param_hw_array(mpu_port, long, ioport, NULL, 0444);
|
2005-04-17 02:20:36 +04:00
|
|
|
MODULE_PARM_DESC(mpu_port, "MPU-401 port.");
|
2017-04-04 18:54:30 +03:00
|
|
|
module_param_hw_array(fm_port, long, ioport, NULL, 0444);
|
2005-04-17 02:20:36 +04:00
|
|
|
MODULE_PARM_DESC(fm_port, "FM port.");
|
|
|
|
module_param_array(soft_ac3, bool, NULL, 0444);
|
2011-03-31 05:57:33 +04:00
|
|
|
MODULE_PARM_DESC(soft_ac3, "Software-conversion of raw SPDIF packets (model 033 only).");
|
2005-04-17 02:20:36 +04:00
|
|
|
#ifdef SUPPORT_JOYSTICK
|
2017-04-04 18:54:30 +03:00
|
|
|
module_param_hw_array(joystick_port, int, ioport, NULL, 0444);
|
2005-04-17 02:20:36 +04:00
|
|
|
MODULE_PARM_DESC(joystick_port, "Joystick port address.");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* CM8x38 registers definition
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define CM_REG_FUNCTRL0 0x00
|
|
|
|
#define CM_RST_CH1 0x00080000
|
|
|
|
#define CM_RST_CH0 0x00040000
|
|
|
|
#define CM_CHEN1 0x00020000 /* ch1: enable */
|
|
|
|
#define CM_CHEN0 0x00010000 /* ch0: enable */
|
|
|
|
#define CM_PAUSE1 0x00000008 /* ch1: pause */
|
|
|
|
#define CM_PAUSE0 0x00000004 /* ch0: pause */
|
|
|
|
#define CM_CHADC1 0x00000002 /* ch1, 0:playback, 1:record */
|
|
|
|
#define CM_CHADC0 0x00000001 /* ch0, 0:playback, 1:record */
|
|
|
|
|
|
|
|
#define CM_REG_FUNCTRL1 0x04
|
2007-09-17 11:35:46 +04:00
|
|
|
#define CM_DSFC_MASK 0x0000E000 /* channel 1 (DAC?) sampling frequency */
|
|
|
|
#define CM_DSFC_SHIFT 13
|
|
|
|
#define CM_ASFC_MASK 0x00001C00 /* channel 0 (ADC?) sampling frequency */
|
|
|
|
#define CM_ASFC_SHIFT 10
|
2005-04-17 02:20:36 +04:00
|
|
|
#define CM_SPDF_1 0x00000200 /* SPDIF IN/OUT at channel B */
|
|
|
|
#define CM_SPDF_0 0x00000100 /* SPDIF OUT only channel A */
|
2007-09-17 11:35:46 +04:00
|
|
|
#define CM_SPDFLOOP 0x00000080 /* ext. SPDIIF/IN -> OUT loopback */
|
2005-04-17 02:20:36 +04:00
|
|
|
#define CM_SPDO2DAC 0x00000040 /* SPDIF/OUT can be heard from internal DAC */
|
|
|
|
#define CM_INTRM 0x00000020 /* master control block (MCB) interrupt enabled */
|
|
|
|
#define CM_BREQ 0x00000010 /* bus master enabled */
|
|
|
|
#define CM_VOICE_EN 0x00000008 /* legacy voice (SB16,FM) */
|
2007-09-17 11:35:46 +04:00
|
|
|
#define CM_UART_EN 0x00000004 /* legacy UART */
|
|
|
|
#define CM_JYSTK_EN 0x00000002 /* legacy joystick */
|
|
|
|
#define CM_ZVPORT 0x00000001 /* ZVPORT */
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
#define CM_REG_CHFORMAT 0x08
|
|
|
|
|
|
|
|
#define CM_CHB3D5C 0x80000000 /* 5,6 channels */
|
2007-09-17 11:35:46 +04:00
|
|
|
#define CM_FMOFFSET2 0x40000000 /* initial FM PCM offset 2 when Fmute=1 */
|
2005-04-17 02:20:36 +04:00
|
|
|
#define CM_CHB3D 0x20000000 /* 4 channels */
|
|
|
|
|
|
|
|
#define CM_CHIP_MASK1 0x1f000000
|
|
|
|
#define CM_CHIP_037 0x01000000
|
2007-09-17 11:35:46 +04:00
|
|
|
#define CM_SETLAT48 0x00800000 /* set latency timer 48h */
|
|
|
|
#define CM_EDGEIRQ 0x00400000 /* emulated edge trigger legacy IRQ */
|
|
|
|
#define CM_SPD24SEL39 0x00200000 /* 24-bit spdif: model 039 */
|
2005-04-17 02:20:36 +04:00
|
|
|
#define CM_AC3EN1 0x00100000 /* enable AC3: model 037 */
|
2007-09-17 11:35:46 +04:00
|
|
|
#define CM_SPDIF_SELECT1 0x00080000 /* for model <= 037 ? */
|
2005-04-17 02:20:36 +04:00
|
|
|
#define CM_SPD24SEL 0x00020000 /* 24bit spdif: model 037 */
|
|
|
|
/* #define CM_SPDIF_INVERSE 0x00010000 */ /* ??? */
|
|
|
|
|
|
|
|
#define CM_ADCBITLEN_MASK 0x0000C000
|
|
|
|
#define CM_ADCBITLEN_16 0x00000000
|
|
|
|
#define CM_ADCBITLEN_15 0x00004000
|
|
|
|
#define CM_ADCBITLEN_14 0x00008000
|
|
|
|
#define CM_ADCBITLEN_13 0x0000C000
|
|
|
|
|
2007-09-17 11:35:46 +04:00
|
|
|
#define CM_ADCDACLEN_MASK 0x00003000 /* model 037 */
|
2005-04-17 02:20:36 +04:00
|
|
|
#define CM_ADCDACLEN_060 0x00000000
|
|
|
|
#define CM_ADCDACLEN_066 0x00001000
|
|
|
|
#define CM_ADCDACLEN_130 0x00002000
|
|
|
|
#define CM_ADCDACLEN_280 0x00003000
|
|
|
|
|
2007-09-17 11:35:46 +04:00
|
|
|
#define CM_ADCDLEN_MASK 0x00003000 /* model 039 */
|
|
|
|
#define CM_ADCDLEN_ORIGINAL 0x00000000
|
|
|
|
#define CM_ADCDLEN_EXTRA 0x00001000
|
|
|
|
#define CM_ADCDLEN_24K 0x00002000
|
|
|
|
#define CM_ADCDLEN_WEIGHT 0x00003000
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
#define CM_CH1_SRATE_176K 0x00000800
|
2007-09-03 11:54:55 +04:00
|
|
|
#define CM_CH1_SRATE_96K 0x00000800 /* model 055? */
|
2005-04-17 02:20:36 +04:00
|
|
|
#define CM_CH1_SRATE_88K 0x00000400
|
|
|
|
#define CM_CH0_SRATE_176K 0x00000200
|
2007-09-03 11:54:55 +04:00
|
|
|
#define CM_CH0_SRATE_96K 0x00000200 /* model 055? */
|
2005-04-17 02:20:36 +04:00
|
|
|
#define CM_CH0_SRATE_88K 0x00000100
|
2007-10-31 19:36:20 +03:00
|
|
|
#define CM_CH0_SRATE_128K 0x00000300
|
|
|
|
#define CM_CH0_SRATE_MASK 0x00000300
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
#define CM_SPDIF_INVERSE2 0x00000080 /* model 055? */
|
2007-09-17 11:35:46 +04:00
|
|
|
#define CM_DBLSPDS 0x00000040 /* double SPDIF sample rate 88.2/96 */
|
|
|
|
#define CM_POLVALID 0x00000020 /* inverse SPDIF/IN valid bit */
|
|
|
|
#define CM_SPDLOCKED 0x00000010
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2007-09-17 11:35:46 +04:00
|
|
|
#define CM_CH1FMT_MASK 0x0000000C /* bit 3: 16 bits, bit 2: stereo */
|
2005-04-17 02:20:36 +04:00
|
|
|
#define CM_CH1FMT_SHIFT 2
|
2007-09-17 11:35:46 +04:00
|
|
|
#define CM_CH0FMT_MASK 0x00000003 /* bit 1: 16 bits, bit 0: stereo */
|
2005-04-17 02:20:36 +04:00
|
|
|
#define CM_CH0FMT_SHIFT 0
|
|
|
|
|
|
|
|
#define CM_REG_INT_HLDCLR 0x0C
|
|
|
|
#define CM_CHIP_MASK2 0xff000000
|
2007-09-17 11:35:46 +04:00
|
|
|
#define CM_CHIP_8768 0x20000000
|
|
|
|
#define CM_CHIP_055 0x08000000
|
2005-04-17 02:20:36 +04:00
|
|
|
#define CM_CHIP_039 0x04000000
|
|
|
|
#define CM_CHIP_039_6CH 0x01000000
|
2007-09-17 11:35:46 +04:00
|
|
|
#define CM_UNKNOWN_INT_EN 0x00080000 /* ? */
|
2005-04-17 02:20:36 +04:00
|
|
|
#define CM_TDMA_INT_EN 0x00040000
|
|
|
|
#define CM_CH1_INT_EN 0x00020000
|
|
|
|
#define CM_CH0_INT_EN 0x00010000
|
|
|
|
|
|
|
|
#define CM_REG_INT_STATUS 0x10
|
|
|
|
#define CM_INTR 0x80000000
|
|
|
|
#define CM_VCO 0x08000000 /* Voice Control? CMI8738 */
|
|
|
|
#define CM_MCBINT 0x04000000 /* Master Control Block abort cond.? */
|
|
|
|
#define CM_UARTINT 0x00010000
|
|
|
|
#define CM_LTDMAINT 0x00008000
|
|
|
|
#define CM_HTDMAINT 0x00004000
|
|
|
|
#define CM_XDO46 0x00000080 /* Modell 033? Direct programming EEPROM (read data register) */
|
|
|
|
#define CM_LHBTOG 0x00000040 /* High/Low status from DMA ctrl register */
|
|
|
|
#define CM_LEG_HDMA 0x00000020 /* Legacy is in High DMA channel */
|
|
|
|
#define CM_LEG_STEREO 0x00000010 /* Legacy is in Stereo mode */
|
|
|
|
#define CM_CH1BUSY 0x00000008
|
|
|
|
#define CM_CH0BUSY 0x00000004
|
|
|
|
#define CM_CHINT1 0x00000002
|
|
|
|
#define CM_CHINT0 0x00000001
|
|
|
|
|
|
|
|
#define CM_REG_LEGACY_CTRL 0x14
|
2007-09-17 11:35:46 +04:00
|
|
|
#define CM_NXCHG 0x80000000 /* don't map base reg dword->sample */
|
2005-04-17 02:20:36 +04:00
|
|
|
#define CM_VMPU_MASK 0x60000000 /* MPU401 i/o port address */
|
|
|
|
#define CM_VMPU_330 0x00000000
|
|
|
|
#define CM_VMPU_320 0x20000000
|
|
|
|
#define CM_VMPU_310 0x40000000
|
|
|
|
#define CM_VMPU_300 0x60000000
|
2007-09-17 11:35:46 +04:00
|
|
|
#define CM_ENWR8237 0x10000000 /* enable bus master to write 8237 base reg */
|
2005-04-17 02:20:36 +04:00
|
|
|
#define CM_VSBSEL_MASK 0x0C000000 /* SB16 base address */
|
|
|
|
#define CM_VSBSEL_220 0x00000000
|
|
|
|
#define CM_VSBSEL_240 0x04000000
|
|
|
|
#define CM_VSBSEL_260 0x08000000
|
|
|
|
#define CM_VSBSEL_280 0x0C000000
|
|
|
|
#define CM_FMSEL_MASK 0x03000000 /* FM OPL3 base address */
|
|
|
|
#define CM_FMSEL_388 0x00000000
|
|
|
|
#define CM_FMSEL_3C8 0x01000000
|
|
|
|
#define CM_FMSEL_3E0 0x02000000
|
|
|
|
#define CM_FMSEL_3E8 0x03000000
|
2007-09-17 11:35:46 +04:00
|
|
|
#define CM_ENSPDOUT 0x00800000 /* enable XSPDIF/OUT to I/O interface */
|
|
|
|
#define CM_SPDCOPYRHT 0x00400000 /* spdif in/out copyright bit */
|
2005-04-17 02:20:36 +04:00
|
|
|
#define CM_DAC2SPDO 0x00200000 /* enable wave+fm_midi -> SPDIF/OUT */
|
2007-09-17 11:35:46 +04:00
|
|
|
#define CM_INVIDWEN 0x00100000 /* internal vendor ID write enable, model 039? */
|
|
|
|
#define CM_SETRETRY 0x00100000 /* 0: legacy i/o wait (default), 1: legacy i/o bus retry */
|
|
|
|
#define CM_C_EEACCESS 0x00080000 /* direct programming eeprom regs */
|
|
|
|
#define CM_C_EECS 0x00040000
|
|
|
|
#define CM_C_EEDI46 0x00020000
|
|
|
|
#define CM_C_EECK46 0x00010000
|
2005-04-17 02:20:36 +04:00
|
|
|
#define CM_CHB3D6C 0x00008000 /* 5.1 channels support */
|
2007-09-17 11:35:46 +04:00
|
|
|
#define CM_CENTR2LIN 0x00004000 /* line-in as center out */
|
|
|
|
#define CM_BASE2LIN 0x00002000 /* line-in as bass out */
|
|
|
|
#define CM_EXBASEN 0x00001000 /* external bass input enable */
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
#define CM_REG_MISC_CTRL 0x18
|
2007-09-17 11:35:46 +04:00
|
|
|
#define CM_PWD 0x80000000 /* power down */
|
2005-04-17 02:20:36 +04:00
|
|
|
#define CM_RESET 0x40000000
|
2007-09-17 11:35:46 +04:00
|
|
|
#define CM_SFIL_MASK 0x30000000 /* filter control at front end DAC, model 037? */
|
|
|
|
#define CM_VMGAIN 0x10000000 /* analog master amp +6dB, model 039? */
|
|
|
|
#define CM_TXVX 0x08000000 /* model 037? */
|
|
|
|
#define CM_N4SPK3D 0x04000000 /* copy front to rear */
|
2005-04-17 02:20:36 +04:00
|
|
|
#define CM_SPDO5V 0x02000000 /* 5V spdif output (1 = 0.5v (coax)) */
|
|
|
|
#define CM_SPDIF48K 0x01000000 /* write */
|
|
|
|
#define CM_SPATUS48K 0x01000000 /* read */
|
2007-09-17 11:35:46 +04:00
|
|
|
#define CM_ENDBDAC 0x00800000 /* enable double dac */
|
2005-04-17 02:20:36 +04:00
|
|
|
#define CM_XCHGDAC 0x00400000 /* 0: front=ch0, 1: front=ch1 */
|
|
|
|
#define CM_SPD32SEL 0x00200000 /* 0: 16bit SPDIF, 1: 32bit */
|
2007-09-17 11:35:46 +04:00
|
|
|
#define CM_SPDFLOOPI 0x00100000 /* int. SPDIF-OUT -> int. IN */
|
|
|
|
#define CM_FM_EN 0x00080000 /* enable legacy FM */
|
2005-04-17 02:20:36 +04:00
|
|
|
#define CM_AC3EN2 0x00040000 /* enable AC3: model 039 */
|
2007-09-17 11:35:46 +04:00
|
|
|
#define CM_ENWRASID 0x00010000 /* choose writable internal SUBID (audio) */
|
|
|
|
#define CM_VIDWPDSB 0x00010000 /* model 037? */
|
2005-04-17 02:20:36 +04:00
|
|
|
#define CM_SPDF_AC97 0x00008000 /* 0: SPDIF/OUT 44.1K, 1: 48K */
|
2007-09-17 11:35:46 +04:00
|
|
|
#define CM_MASK_EN 0x00004000 /* activate channel mask on legacy DMA */
|
|
|
|
#define CM_ENWRMSID 0x00002000 /* choose writable internal SUBID (modem) */
|
|
|
|
#define CM_VIDWPPRT 0x00002000 /* model 037? */
|
|
|
|
#define CM_SFILENB 0x00001000 /* filter stepping at front end DAC, model 037? */
|
|
|
|
#define CM_MMODE_MASK 0x00000E00 /* model DAA interface mode */
|
2005-04-17 02:20:36 +04:00
|
|
|
#define CM_SPDIF_SELECT2 0x00000100 /* for model > 039 ? */
|
|
|
|
#define CM_ENCENTER 0x00000080
|
2007-10-30 10:59:14 +03:00
|
|
|
#define CM_FLINKON 0x00000040 /* force modem link detection on, model 037 */
|
2007-09-17 11:35:46 +04:00
|
|
|
#define CM_MUTECH1 0x00000040 /* mute PCI ch1 to DAC */
|
2007-10-30 10:59:14 +03:00
|
|
|
#define CM_FLINKOFF 0x00000020 /* force modem link detection off, model 037 */
|
2007-09-17 11:35:46 +04:00
|
|
|
#define CM_MIDSMP 0x00000010 /* 1/2 interpolation at front end DAC */
|
|
|
|
#define CM_UPDDMA_MASK 0x0000000C /* TDMA position update notification */
|
|
|
|
#define CM_UPDDMA_2048 0x00000000
|
|
|
|
#define CM_UPDDMA_1024 0x00000004
|
|
|
|
#define CM_UPDDMA_512 0x00000008
|
|
|
|
#define CM_UPDDMA_256 0x0000000C
|
|
|
|
#define CM_TWAIT_MASK 0x00000003 /* model 037 */
|
|
|
|
#define CM_TWAIT1 0x00000002 /* FM i/o cycle, 0: 48, 1: 64 PCICLKs */
|
|
|
|
#define CM_TWAIT0 0x00000001 /* i/o cycle, 0: 4, 1: 6 PCICLKs */
|
|
|
|
|
|
|
|
#define CM_REG_TDMA_POSITION 0x1C
|
|
|
|
#define CM_TDMA_CNT_MASK 0xFFFF0000 /* current byte/word count */
|
|
|
|
#define CM_TDMA_ADR_MASK 0x0000FFFF /* current address */
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/* byte */
|
|
|
|
#define CM_REG_MIXER0 0x20
|
2007-09-17 11:35:46 +04:00
|
|
|
#define CM_REG_SBVR 0x20 /* write: sb16 version */
|
|
|
|
#define CM_REG_DEV 0x20 /* read: hardware device version */
|
|
|
|
|
|
|
|
#define CM_REG_MIXER21 0x21
|
|
|
|
#define CM_UNKNOWN_21_MASK 0x78 /* ? */
|
|
|
|
#define CM_X_ADPCM 0x04 /* SB16 ADPCM enable */
|
|
|
|
#define CM_PROINV 0x02 /* SBPro left/right channel switching */
|
|
|
|
#define CM_X_SB16 0x01 /* SB16 compatible */
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
#define CM_REG_SB16_DATA 0x22
|
|
|
|
#define CM_REG_SB16_ADDR 0x23
|
|
|
|
|
|
|
|
#define CM_REFFREQ_XIN (315*1000*1000)/22 /* 14.31818 Mhz reference clock frequency pin XIN */
|
|
|
|
#define CM_ADCMULT_XIN 512 /* Guessed (487 best for 44.1kHz, not for 88/176kHz) */
|
|
|
|
#define CM_TOLERANCE_RATE 0.001 /* Tolerance sample rate pitch (1000ppm) */
|
|
|
|
#define CM_MAXIMUM_RATE 80000000 /* Note more than 80MHz */
|
|
|
|
|
|
|
|
#define CM_REG_MIXER1 0x24
|
|
|
|
#define CM_FMMUTE 0x80 /* mute FM */
|
|
|
|
#define CM_FMMUTE_SHIFT 7
|
|
|
|
#define CM_WSMUTE 0x40 /* mute PCM */
|
|
|
|
#define CM_WSMUTE_SHIFT 6
|
2007-09-17 11:35:46 +04:00
|
|
|
#define CM_REAR2LIN 0x20 /* lin-in -> rear line out */
|
|
|
|
#define CM_REAR2LIN_SHIFT 5
|
2005-04-17 02:20:36 +04:00
|
|
|
#define CM_REAR2FRONT 0x10 /* exchange rear/front */
|
|
|
|
#define CM_REAR2FRONT_SHIFT 4
|
|
|
|
#define CM_WAVEINL 0x08 /* digital wave rec. left chan */
|
|
|
|
#define CM_WAVEINL_SHIFT 3
|
|
|
|
#define CM_WAVEINR 0x04 /* digical wave rec. right */
|
|
|
|
#define CM_WAVEINR_SHIFT 2
|
|
|
|
#define CM_X3DEN 0x02 /* 3D surround enable */
|
|
|
|
#define CM_X3DEN_SHIFT 1
|
|
|
|
#define CM_CDPLAY 0x01 /* enable SPDIF/IN PCM -> DAC */
|
|
|
|
#define CM_CDPLAY_SHIFT 0
|
|
|
|
|
|
|
|
#define CM_REG_MIXER2 0x25
|
|
|
|
#define CM_RAUXREN 0x80 /* AUX right capture */
|
|
|
|
#define CM_RAUXREN_SHIFT 7
|
|
|
|
#define CM_RAUXLEN 0x40 /* AUX left capture */
|
|
|
|
#define CM_RAUXLEN_SHIFT 6
|
|
|
|
#define CM_VAUXRM 0x20 /* AUX right mute */
|
|
|
|
#define CM_VAUXRM_SHIFT 5
|
|
|
|
#define CM_VAUXLM 0x10 /* AUX left mute */
|
|
|
|
#define CM_VAUXLM_SHIFT 4
|
|
|
|
#define CM_VADMIC_MASK 0x0e /* mic gain level (0-3) << 1 */
|
|
|
|
#define CM_VADMIC_SHIFT 1
|
|
|
|
#define CM_MICGAINZ 0x01 /* mic boost */
|
|
|
|
#define CM_MICGAINZ_SHIFT 0
|
|
|
|
|
|
|
|
#define CM_REG_AUX_VOL 0x26
|
|
|
|
#define CM_VAUXL_MASK 0xf0
|
|
|
|
#define CM_VAUXR_MASK 0x0f
|
|
|
|
|
|
|
|
#define CM_REG_MISC 0x27
|
2007-09-17 11:35:46 +04:00
|
|
|
#define CM_UNKNOWN_27_MASK 0xd8 /* ? */
|
2005-04-17 02:20:36 +04:00
|
|
|
#define CM_XGPO1 0x20
|
|
|
|
// #define CM_XGPBIO 0x04
|
|
|
|
#define CM_MIC_CENTER_LFE 0x04 /* mic as center/lfe out? (model 039 or later?) */
|
|
|
|
#define CM_SPDIF_INVERSE 0x04 /* spdif input phase inverse (model 037) */
|
|
|
|
#define CM_SPDVALID 0x02 /* spdif input valid check */
|
2007-09-17 11:35:46 +04:00
|
|
|
#define CM_DMAUTO 0x01 /* SB16 DMA auto detect */
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
#define CM_REG_AC97 0x28 /* hmmm.. do we have ac97 link? */
|
|
|
|
/*
|
|
|
|
* For CMI-8338 (0x28 - 0x2b) .. is this valid for CMI-8738
|
|
|
|
* or identical with AC97 codec?
|
|
|
|
*/
|
|
|
|
#define CM_REG_EXTERN_CODEC CM_REG_AC97
|
|
|
|
|
|
|
|
/*
|
|
|
|
* MPU401 pci port index address 0x40 - 0x4f (CMI-8738 spec ver. 0.6)
|
|
|
|
*/
|
|
|
|
#define CM_REG_MPU_PCI 0x40
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FM pci port index address 0x50 - 0x5f (CMI-8738 spec ver. 0.6)
|
|
|
|
*/
|
|
|
|
#define CM_REG_FM_PCI 0x50
|
|
|
|
|
|
|
|
/*
|
2005-06-30 15:45:20 +04:00
|
|
|
* access from SB-mixer port
|
2005-04-17 02:20:36 +04:00
|
|
|
*/
|
|
|
|
#define CM_REG_EXTENT_IND 0xf0
|
|
|
|
#define CM_VPHONE_MASK 0xe0 /* Phone volume control (0-3) << 5 */
|
|
|
|
#define CM_VPHONE_SHIFT 5
|
|
|
|
#define CM_VPHOM 0x10 /* Phone mute control */
|
|
|
|
#define CM_VSPKM 0x08 /* Speaker mute control, default high */
|
|
|
|
#define CM_RLOOPREN 0x04 /* Rec. R-channel enable */
|
|
|
|
#define CM_RLOOPLEN 0x02 /* Rec. L-channel enable */
|
2005-06-30 15:45:20 +04:00
|
|
|
#define CM_VADMIC3 0x01 /* Mic record boost */
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* CMI-8338 spec ver 0.5 (this is not valid for CMI-8738):
|
|
|
|
* the 8 registers 0xf8 - 0xff are used for programming m/n counter by the PLL
|
|
|
|
* unit (readonly?).
|
|
|
|
*/
|
|
|
|
#define CM_REG_PLL 0xf8
|
|
|
|
|
|
|
|
/*
|
|
|
|
* extended registers
|
|
|
|
*/
|
2007-09-17 11:35:46 +04:00
|
|
|
#define CM_REG_CH0_FRAME1 0x80 /* write: base address */
|
|
|
|
#define CM_REG_CH0_FRAME2 0x84 /* read: current address */
|
2005-04-17 02:20:36 +04:00
|
|
|
#define CM_REG_CH1_FRAME1 0x88 /* 0-15: count of samples at bus master; buffer size */
|
|
|
|
#define CM_REG_CH1_FRAME2 0x8C /* 16-31: count of samples at codec; fragment size */
|
2007-09-17 11:35:46 +04:00
|
|
|
|
2005-11-17 18:14:49 +03:00
|
|
|
#define CM_REG_EXT_MISC 0x90
|
2007-09-17 11:35:46 +04:00
|
|
|
#define CM_ADC48K44K 0x10000000 /* ADC parameters group, 0: 44k, 1: 48k */
|
|
|
|
#define CM_CHB3D8C 0x00200000 /* 7.1 channels support */
|
|
|
|
#define CM_SPD32FMT 0x00100000 /* SPDIF/IN 32k sample rate */
|
|
|
|
#define CM_ADC2SPDIF 0x00080000 /* ADC output to SPDIF/OUT */
|
|
|
|
#define CM_SHAREADC 0x00040000 /* DAC in ADC as Center/LFE */
|
|
|
|
#define CM_REALTCMP 0x00020000 /* monitor the CMPL/CMPR of ADC */
|
|
|
|
#define CM_INVLRCK 0x00010000 /* invert ZVPORT's LRCK */
|
|
|
|
#define CM_UNKNOWN_90_MASK 0x0000FFFF /* ? */
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* size of i/o region
|
|
|
|
*/
|
|
|
|
#define CM_EXTENT_CODEC 0x100
|
|
|
|
#define CM_EXTENT_MIDI 0x2
|
|
|
|
#define CM_EXTENT_SYNTH 0x4
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* channels for playback / capture
|
|
|
|
*/
|
|
|
|
#define CM_CH_PLAY 0
|
|
|
|
#define CM_CH_CAPT 1
|
|
|
|
|
|
|
|
/*
|
|
|
|
* flags to check device open/close
|
|
|
|
*/
|
|
|
|
#define CM_OPEN_NONE 0
|
|
|
|
#define CM_OPEN_CH_MASK 0x01
|
|
|
|
#define CM_OPEN_DAC 0x10
|
|
|
|
#define CM_OPEN_ADC 0x20
|
|
|
|
#define CM_OPEN_SPDIF 0x40
|
|
|
|
#define CM_OPEN_MCHAN 0x80
|
|
|
|
#define CM_OPEN_PLAYBACK (CM_CH_PLAY | CM_OPEN_DAC)
|
|
|
|
#define CM_OPEN_PLAYBACK2 (CM_CH_CAPT | CM_OPEN_DAC)
|
|
|
|
#define CM_OPEN_PLAYBACK_MULTI (CM_CH_PLAY | CM_OPEN_DAC | CM_OPEN_MCHAN)
|
|
|
|
#define CM_OPEN_CAPTURE (CM_CH_CAPT | CM_OPEN_ADC)
|
|
|
|
#define CM_OPEN_SPDIF_PLAYBACK (CM_CH_PLAY | CM_OPEN_DAC | CM_OPEN_SPDIF)
|
|
|
|
#define CM_OPEN_SPDIF_CAPTURE (CM_CH_CAPT | CM_OPEN_ADC | CM_OPEN_SPDIF)
|
|
|
|
|
|
|
|
|
|
|
|
#if CM_CH_PLAY == 1
|
|
|
|
#define CM_PLAYBACK_SRATE_176K CM_CH1_SRATE_176K
|
|
|
|
#define CM_PLAYBACK_SPDF CM_SPDF_1
|
|
|
|
#define CM_CAPTURE_SPDF CM_SPDF_0
|
|
|
|
#else
|
|
|
|
#define CM_PLAYBACK_SRATE_176K CM_CH0_SRATE_176K
|
|
|
|
#define CM_PLAYBACK_SPDF CM_SPDF_0
|
|
|
|
#define CM_CAPTURE_SPDF CM_SPDF_1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* driver data
|
|
|
|
*/
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
struct cmipci_pcm {
|
|
|
|
struct snd_pcm_substream *substream;
|
2007-09-17 11:40:57 +04:00
|
|
|
u8 running; /* dac/adc running? */
|
|
|
|
u8 fmt; /* format bits */
|
|
|
|
u8 is_dac;
|
2007-09-17 11:41:36 +04:00
|
|
|
u8 needs_silencing;
|
2005-04-17 02:20:36 +04:00
|
|
|
unsigned int dma_size; /* in frames */
|
2007-09-17 11:40:57 +04:00
|
|
|
unsigned int shift;
|
|
|
|
unsigned int ch; /* channel (0/1) */
|
2005-04-17 02:20:36 +04:00
|
|
|
unsigned int offset; /* physical address of the buffer */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* mixer elements toggled/resumed during ac3 playback */
|
|
|
|
struct cmipci_mixer_auto_switches {
|
|
|
|
const char *name; /* switch to toggle */
|
|
|
|
int toggle_on; /* value to change when ac3 mode */
|
|
|
|
};
|
|
|
|
static const struct cmipci_mixer_auto_switches cm_saved_mixer[] = {
|
|
|
|
{"PCM Playback Switch", 0},
|
|
|
|
{"IEC958 Output Switch", 1},
|
|
|
|
{"IEC958 Mix Analog", 0},
|
|
|
|
// {"IEC958 Out To DAC", 1}, // no longer used
|
|
|
|
{"IEC958 Loop", 0},
|
|
|
|
};
|
|
|
|
#define CM_SAVED_MIXERS ARRAY_SIZE(cm_saved_mixer)
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
struct cmipci {
|
|
|
|
struct snd_card *card;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
struct pci_dev *pci;
|
|
|
|
unsigned int device; /* device ID */
|
|
|
|
int irq;
|
|
|
|
|
|
|
|
unsigned long iobase;
|
|
|
|
unsigned int ctrl; /* FUNCTRL0 current value */
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
struct snd_pcm *pcm; /* DAC/ADC PCM */
|
|
|
|
struct snd_pcm *pcm2; /* 2nd DAC */
|
|
|
|
struct snd_pcm *pcm_spdif; /* SPDIF */
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
int chip_version;
|
|
|
|
int max_channels;
|
|
|
|
unsigned int can_ac3_sw: 1;
|
|
|
|
unsigned int can_ac3_hw: 1;
|
|
|
|
unsigned int can_multi_ch: 1;
|
2007-10-31 19:36:20 +03:00
|
|
|
unsigned int can_96k: 1; /* samplerate above 48k */
|
2005-04-17 02:20:36 +04:00
|
|
|
unsigned int do_soft_ac3: 1;
|
|
|
|
|
|
|
|
unsigned int spdif_playback_avail: 1; /* spdif ready? */
|
|
|
|
unsigned int spdif_playback_enabled: 1; /* spdif switch enabled? */
|
|
|
|
int spdif_counter; /* for software AC3 */
|
|
|
|
|
|
|
|
unsigned int dig_status;
|
|
|
|
unsigned int dig_pcm_status;
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
struct snd_pcm_hardware *hw_info[3]; /* for playbacks */
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
int opened[2]; /* open mode */
|
2006-01-16 18:34:20 +03:00
|
|
|
struct mutex open_mutex;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
unsigned int mixer_insensitive: 1;
|
2005-11-17 17:03:13 +03:00
|
|
|
struct snd_kcontrol *mixer_res_ctl[CM_SAVED_MIXERS];
|
2005-04-17 02:20:36 +04:00
|
|
|
int mixer_res_status[CM_SAVED_MIXERS];
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
struct cmipci_pcm channel[2]; /* ch0 - DAC, ch1 - ADC or 2nd DAC */
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/* external MIDI */
|
2005-11-17 17:03:13 +03:00
|
|
|
struct snd_rawmidi *rmidi;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
#ifdef SUPPORT_JOYSTICK
|
|
|
|
struct gameport *gameport;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
spinlock_t reg_lock;
|
2005-11-17 18:14:49 +03:00
|
|
|
|
2012-08-14 20:12:04 +04:00
|
|
|
#ifdef CONFIG_PM_SLEEP
|
2005-11-17 18:14:49 +03:00
|
|
|
unsigned int saved_regs[0x20];
|
|
|
|
unsigned char saved_mixers[0x20];
|
|
|
|
#endif
|
2005-04-17 02:20:36 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* read/write operations for dword register */
|
2005-11-17 17:03:13 +03:00
|
|
|
static inline void snd_cmipci_write(struct cmipci *cm, unsigned int cmd, unsigned int data)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
outl(data, cm->iobase + cmd);
|
|
|
|
}
|
2005-07-27 22:46:09 +04:00
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static inline unsigned int snd_cmipci_read(struct cmipci *cm, unsigned int cmd)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
return inl(cm->iobase + cmd);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* read/write operations for word register */
|
2005-11-17 17:03:13 +03:00
|
|
|
static inline void snd_cmipci_write_w(struct cmipci *cm, unsigned int cmd, unsigned short data)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
outw(data, cm->iobase + cmd);
|
|
|
|
}
|
2005-07-27 22:46:09 +04:00
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static inline unsigned short snd_cmipci_read_w(struct cmipci *cm, unsigned int cmd)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
return inw(cm->iobase + cmd);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* read/write operations for byte register */
|
2005-11-17 17:03:13 +03:00
|
|
|
static inline void snd_cmipci_write_b(struct cmipci *cm, unsigned int cmd, unsigned char data)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
outb(data, cm->iobase + cmd);
|
|
|
|
}
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static inline unsigned char snd_cmipci_read_b(struct cmipci *cm, unsigned int cmd)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
return inb(cm->iobase + cmd);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* bit operations for dword register */
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_set_bit(struct cmipci *cm, unsigned int cmd, unsigned int flag)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
[ALSA] Replace pci_module_init() with pci_register_driver()
Documentation,ALS4000 driver,ATIIXP driver,ATIIXP-modem driver
AZT3328 driver,BT87x driver,CMIPCI driver,CS4281 driver
ENS1370/1+ driver,ES1938 driver,ES1968 driver,FM801 driver
Intel8x0 driver,Intel8x0-modem driver,Maestro3 driver,RME32 driver
RME96 driver,SonicVibes driver,VIA82xx driver,VIA82xx-modem driver
ALI5451 driver,au88x0 driver,CA0106 driver,CS46xx driver
EMU10K1/EMU10K2 driver,HDA Intel driver,ICE1712 driver,ICE1724 driver
KORG1212 driver,MIXART driver,NM256 driver,RME HDSP driver
RME9652 driver,Trident driver,Digigram VX222 driver,YMFPCI driver
Replace the obsolete pci_module_init() with pci_register_driver().
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2005-04-11 18:58:24 +04:00
|
|
|
unsigned int val, oval;
|
|
|
|
val = oval = inl(cm->iobase + cmd);
|
2005-04-17 02:20:36 +04:00
|
|
|
val |= flag;
|
[ALSA] Replace pci_module_init() with pci_register_driver()
Documentation,ALS4000 driver,ATIIXP driver,ATIIXP-modem driver
AZT3328 driver,BT87x driver,CMIPCI driver,CS4281 driver
ENS1370/1+ driver,ES1938 driver,ES1968 driver,FM801 driver
Intel8x0 driver,Intel8x0-modem driver,Maestro3 driver,RME32 driver
RME96 driver,SonicVibes driver,VIA82xx driver,VIA82xx-modem driver
ALI5451 driver,au88x0 driver,CA0106 driver,CS46xx driver
EMU10K1/EMU10K2 driver,HDA Intel driver,ICE1712 driver,ICE1724 driver
KORG1212 driver,MIXART driver,NM256 driver,RME HDSP driver
RME9652 driver,Trident driver,Digigram VX222 driver,YMFPCI driver
Replace the obsolete pci_module_init() with pci_register_driver().
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2005-04-11 18:58:24 +04:00
|
|
|
if (val == oval)
|
|
|
|
return 0;
|
2005-04-17 02:20:36 +04:00
|
|
|
outl(val, cm->iobase + cmd);
|
[ALSA] Replace pci_module_init() with pci_register_driver()
Documentation,ALS4000 driver,ATIIXP driver,ATIIXP-modem driver
AZT3328 driver,BT87x driver,CMIPCI driver,CS4281 driver
ENS1370/1+ driver,ES1938 driver,ES1968 driver,FM801 driver
Intel8x0 driver,Intel8x0-modem driver,Maestro3 driver,RME32 driver
RME96 driver,SonicVibes driver,VIA82xx driver,VIA82xx-modem driver
ALI5451 driver,au88x0 driver,CA0106 driver,CS46xx driver
EMU10K1/EMU10K2 driver,HDA Intel driver,ICE1712 driver,ICE1724 driver
KORG1212 driver,MIXART driver,NM256 driver,RME HDSP driver
RME9652 driver,Trident driver,Digigram VX222 driver,YMFPCI driver
Replace the obsolete pci_module_init() with pci_register_driver().
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2005-04-11 18:58:24 +04:00
|
|
|
return 1;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_clear_bit(struct cmipci *cm, unsigned int cmd, unsigned int flag)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
[ALSA] Replace pci_module_init() with pci_register_driver()
Documentation,ALS4000 driver,ATIIXP driver,ATIIXP-modem driver
AZT3328 driver,BT87x driver,CMIPCI driver,CS4281 driver
ENS1370/1+ driver,ES1938 driver,ES1968 driver,FM801 driver
Intel8x0 driver,Intel8x0-modem driver,Maestro3 driver,RME32 driver
RME96 driver,SonicVibes driver,VIA82xx driver,VIA82xx-modem driver
ALI5451 driver,au88x0 driver,CA0106 driver,CS46xx driver
EMU10K1/EMU10K2 driver,HDA Intel driver,ICE1712 driver,ICE1724 driver
KORG1212 driver,MIXART driver,NM256 driver,RME HDSP driver
RME9652 driver,Trident driver,Digigram VX222 driver,YMFPCI driver
Replace the obsolete pci_module_init() with pci_register_driver().
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2005-04-11 18:58:24 +04:00
|
|
|
unsigned int val, oval;
|
|
|
|
val = oval = inl(cm->iobase + cmd);
|
2005-04-17 02:20:36 +04:00
|
|
|
val &= ~flag;
|
[ALSA] Replace pci_module_init() with pci_register_driver()
Documentation,ALS4000 driver,ATIIXP driver,ATIIXP-modem driver
AZT3328 driver,BT87x driver,CMIPCI driver,CS4281 driver
ENS1370/1+ driver,ES1938 driver,ES1968 driver,FM801 driver
Intel8x0 driver,Intel8x0-modem driver,Maestro3 driver,RME32 driver
RME96 driver,SonicVibes driver,VIA82xx driver,VIA82xx-modem driver
ALI5451 driver,au88x0 driver,CA0106 driver,CS46xx driver
EMU10K1/EMU10K2 driver,HDA Intel driver,ICE1712 driver,ICE1724 driver
KORG1212 driver,MIXART driver,NM256 driver,RME HDSP driver
RME9652 driver,Trident driver,Digigram VX222 driver,YMFPCI driver
Replace the obsolete pci_module_init() with pci_register_driver().
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2005-04-11 18:58:24 +04:00
|
|
|
if (val == oval)
|
|
|
|
return 0;
|
2005-04-17 02:20:36 +04:00
|
|
|
outl(val, cm->iobase + cmd);
|
[ALSA] Replace pci_module_init() with pci_register_driver()
Documentation,ALS4000 driver,ATIIXP driver,ATIIXP-modem driver
AZT3328 driver,BT87x driver,CMIPCI driver,CS4281 driver
ENS1370/1+ driver,ES1938 driver,ES1968 driver,FM801 driver
Intel8x0 driver,Intel8x0-modem driver,Maestro3 driver,RME32 driver
RME96 driver,SonicVibes driver,VIA82xx driver,VIA82xx-modem driver
ALI5451 driver,au88x0 driver,CA0106 driver,CS46xx driver
EMU10K1/EMU10K2 driver,HDA Intel driver,ICE1712 driver,ICE1724 driver
KORG1212 driver,MIXART driver,NM256 driver,RME HDSP driver
RME9652 driver,Trident driver,Digigram VX222 driver,YMFPCI driver
Replace the obsolete pci_module_init() with pci_register_driver().
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2005-04-11 18:58:24 +04:00
|
|
|
return 1;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* bit operations for byte register */
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_set_bit_b(struct cmipci *cm, unsigned int cmd, unsigned char flag)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
[ALSA] Replace pci_module_init() with pci_register_driver()
Documentation,ALS4000 driver,ATIIXP driver,ATIIXP-modem driver
AZT3328 driver,BT87x driver,CMIPCI driver,CS4281 driver
ENS1370/1+ driver,ES1938 driver,ES1968 driver,FM801 driver
Intel8x0 driver,Intel8x0-modem driver,Maestro3 driver,RME32 driver
RME96 driver,SonicVibes driver,VIA82xx driver,VIA82xx-modem driver
ALI5451 driver,au88x0 driver,CA0106 driver,CS46xx driver
EMU10K1/EMU10K2 driver,HDA Intel driver,ICE1712 driver,ICE1724 driver
KORG1212 driver,MIXART driver,NM256 driver,RME HDSP driver
RME9652 driver,Trident driver,Digigram VX222 driver,YMFPCI driver
Replace the obsolete pci_module_init() with pci_register_driver().
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2005-04-11 18:58:24 +04:00
|
|
|
unsigned char val, oval;
|
|
|
|
val = oval = inb(cm->iobase + cmd);
|
2005-04-17 02:20:36 +04:00
|
|
|
val |= flag;
|
[ALSA] Replace pci_module_init() with pci_register_driver()
Documentation,ALS4000 driver,ATIIXP driver,ATIIXP-modem driver
AZT3328 driver,BT87x driver,CMIPCI driver,CS4281 driver
ENS1370/1+ driver,ES1938 driver,ES1968 driver,FM801 driver
Intel8x0 driver,Intel8x0-modem driver,Maestro3 driver,RME32 driver
RME96 driver,SonicVibes driver,VIA82xx driver,VIA82xx-modem driver
ALI5451 driver,au88x0 driver,CA0106 driver,CS46xx driver
EMU10K1/EMU10K2 driver,HDA Intel driver,ICE1712 driver,ICE1724 driver
KORG1212 driver,MIXART driver,NM256 driver,RME HDSP driver
RME9652 driver,Trident driver,Digigram VX222 driver,YMFPCI driver
Replace the obsolete pci_module_init() with pci_register_driver().
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2005-04-11 18:58:24 +04:00
|
|
|
if (val == oval)
|
|
|
|
return 0;
|
2005-04-17 02:20:36 +04:00
|
|
|
outb(val, cm->iobase + cmd);
|
[ALSA] Replace pci_module_init() with pci_register_driver()
Documentation,ALS4000 driver,ATIIXP driver,ATIIXP-modem driver
AZT3328 driver,BT87x driver,CMIPCI driver,CS4281 driver
ENS1370/1+ driver,ES1938 driver,ES1968 driver,FM801 driver
Intel8x0 driver,Intel8x0-modem driver,Maestro3 driver,RME32 driver
RME96 driver,SonicVibes driver,VIA82xx driver,VIA82xx-modem driver
ALI5451 driver,au88x0 driver,CA0106 driver,CS46xx driver
EMU10K1/EMU10K2 driver,HDA Intel driver,ICE1712 driver,ICE1724 driver
KORG1212 driver,MIXART driver,NM256 driver,RME HDSP driver
RME9652 driver,Trident driver,Digigram VX222 driver,YMFPCI driver
Replace the obsolete pci_module_init() with pci_register_driver().
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2005-04-11 18:58:24 +04:00
|
|
|
return 1;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_clear_bit_b(struct cmipci *cm, unsigned int cmd, unsigned char flag)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
[ALSA] Replace pci_module_init() with pci_register_driver()
Documentation,ALS4000 driver,ATIIXP driver,ATIIXP-modem driver
AZT3328 driver,BT87x driver,CMIPCI driver,CS4281 driver
ENS1370/1+ driver,ES1938 driver,ES1968 driver,FM801 driver
Intel8x0 driver,Intel8x0-modem driver,Maestro3 driver,RME32 driver
RME96 driver,SonicVibes driver,VIA82xx driver,VIA82xx-modem driver
ALI5451 driver,au88x0 driver,CA0106 driver,CS46xx driver
EMU10K1/EMU10K2 driver,HDA Intel driver,ICE1712 driver,ICE1724 driver
KORG1212 driver,MIXART driver,NM256 driver,RME HDSP driver
RME9652 driver,Trident driver,Digigram VX222 driver,YMFPCI driver
Replace the obsolete pci_module_init() with pci_register_driver().
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2005-04-11 18:58:24 +04:00
|
|
|
unsigned char val, oval;
|
|
|
|
val = oval = inb(cm->iobase + cmd);
|
2005-04-17 02:20:36 +04:00
|
|
|
val &= ~flag;
|
[ALSA] Replace pci_module_init() with pci_register_driver()
Documentation,ALS4000 driver,ATIIXP driver,ATIIXP-modem driver
AZT3328 driver,BT87x driver,CMIPCI driver,CS4281 driver
ENS1370/1+ driver,ES1938 driver,ES1968 driver,FM801 driver
Intel8x0 driver,Intel8x0-modem driver,Maestro3 driver,RME32 driver
RME96 driver,SonicVibes driver,VIA82xx driver,VIA82xx-modem driver
ALI5451 driver,au88x0 driver,CA0106 driver,CS46xx driver
EMU10K1/EMU10K2 driver,HDA Intel driver,ICE1712 driver,ICE1724 driver
KORG1212 driver,MIXART driver,NM256 driver,RME HDSP driver
RME9652 driver,Trident driver,Digigram VX222 driver,YMFPCI driver
Replace the obsolete pci_module_init() with pci_register_driver().
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2005-04-11 18:58:24 +04:00
|
|
|
if (val == oval)
|
|
|
|
return 0;
|
2005-04-17 02:20:36 +04:00
|
|
|
outb(val, cm->iobase + cmd);
|
[ALSA] Replace pci_module_init() with pci_register_driver()
Documentation,ALS4000 driver,ATIIXP driver,ATIIXP-modem driver
AZT3328 driver,BT87x driver,CMIPCI driver,CS4281 driver
ENS1370/1+ driver,ES1938 driver,ES1968 driver,FM801 driver
Intel8x0 driver,Intel8x0-modem driver,Maestro3 driver,RME32 driver
RME96 driver,SonicVibes driver,VIA82xx driver,VIA82xx-modem driver
ALI5451 driver,au88x0 driver,CA0106 driver,CS46xx driver
EMU10K1/EMU10K2 driver,HDA Intel driver,ICE1712 driver,ICE1724 driver
KORG1212 driver,MIXART driver,NM256 driver,RME HDSP driver
RME9652 driver,Trident driver,Digigram VX222 driver,YMFPCI driver
Replace the obsolete pci_module_init() with pci_register_driver().
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2005-04-11 18:58:24 +04:00
|
|
|
return 1;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* PCM interface
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* calculate frequency
|
|
|
|
*/
|
|
|
|
|
2020-01-05 17:47:51 +03:00
|
|
|
static const unsigned int rates[] = { 5512, 11025, 22050, 44100, 8000, 16000, 32000, 48000 };
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
static unsigned int snd_cmipci_rate_freq(unsigned int rate)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
2007-09-17 11:40:24 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
for (i = 0; i < ARRAY_SIZE(rates); i++) {
|
|
|
|
if (rates[i] == rate)
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
snd_BUG();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef USE_VAR48KRATE
|
|
|
|
/*
|
|
|
|
* Determine PLL values for frequency setup, maybe the CMI8338 (CMI8738???)
|
|
|
|
* does it this way .. maybe not. Never get any information from C-Media about
|
|
|
|
* that <werner@suse.de>.
|
|
|
|
*/
|
|
|
|
static int snd_cmipci_pll_rmn(unsigned int rate, unsigned int adcmult, int *r, int *m, int *n)
|
|
|
|
{
|
|
|
|
unsigned int delta, tolerance;
|
|
|
|
int xm, xn, xr;
|
|
|
|
|
|
|
|
for (*r = 0; rate < CM_MAXIMUM_RATE/adcmult; *r += (1<<5))
|
|
|
|
rate <<= 1;
|
|
|
|
*n = -1;
|
|
|
|
if (*r > 0xff)
|
|
|
|
goto out;
|
|
|
|
tolerance = rate*CM_TOLERANCE_RATE;
|
|
|
|
|
|
|
|
for (xn = (1+2); xn < (0x1f+2); xn++) {
|
|
|
|
for (xm = (1+2); xm < (0xff+2); xm++) {
|
|
|
|
xr = ((CM_REFFREQ_XIN/adcmult) * xm) / xn;
|
|
|
|
|
|
|
|
if (xr < rate)
|
|
|
|
delta = rate - xr;
|
|
|
|
else
|
|
|
|
delta = xr - rate;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we found one, remember this,
|
|
|
|
* and try to find a closer one
|
|
|
|
*/
|
|
|
|
if (delta < tolerance) {
|
|
|
|
tolerance = delta;
|
|
|
|
*m = xm - 2;
|
|
|
|
*n = xn - 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
out:
|
|
|
|
return (*n > -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2011-03-31 05:57:33 +04:00
|
|
|
* Program pll register bits, I assume that the 8 registers 0xf8 up to 0xff
|
|
|
|
* are mapped onto the 8 ADC/DAC sampling frequency which can be chosen
|
2005-04-17 02:20:36 +04:00
|
|
|
* at the register CM_REG_FUNCTRL1 (0x04).
|
|
|
|
* Problem: other ways are also possible (any information about that?)
|
|
|
|
*/
|
2005-11-17 17:03:13 +03:00
|
|
|
static void snd_cmipci_set_pll(struct cmipci *cm, unsigned int rate, unsigned int slot)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
unsigned int reg = CM_REG_PLL + slot;
|
|
|
|
/*
|
|
|
|
* Guess that this programs at reg. 0x04 the pos 15:13/12:10
|
2011-03-31 05:57:33 +04:00
|
|
|
* for DSFC/ASFC (000 up to 111).
|
2005-04-17 02:20:36 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* FIXME: Init (Do we've to set an other register first before programming?) */
|
|
|
|
|
|
|
|
/* FIXME: Is this correct? Or shouldn't the m/n/r values be used for that? */
|
|
|
|
snd_cmipci_write_b(cm, reg, rate>>8);
|
|
|
|
snd_cmipci_write_b(cm, reg, rate&0xff);
|
|
|
|
|
|
|
|
/* FIXME: Setup (Do we've to set an other register first to enable this?) */
|
|
|
|
}
|
|
|
|
#endif /* USE_VAR48KRATE */
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_playback2_hw_params(struct snd_pcm_substream *substream,
|
|
|
|
struct snd_pcm_hw_params *hw_params)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2005-11-17 17:03:13 +03:00
|
|
|
struct cmipci *cm = snd_pcm_substream_chip(substream);
|
2005-04-17 02:20:36 +04:00
|
|
|
if (params_channels(hw_params) > 2) {
|
2006-01-16 18:34:20 +03:00
|
|
|
mutex_lock(&cm->open_mutex);
|
2005-04-17 02:20:36 +04:00
|
|
|
if (cm->opened[CM_CH_PLAY]) {
|
2006-01-16 18:34:20 +03:00
|
|
|
mutex_unlock(&cm->open_mutex);
|
2005-04-17 02:20:36 +04:00
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
/* reserve the channel A */
|
|
|
|
cm->opened[CM_CH_PLAY] = CM_OPEN_PLAYBACK_MULTI;
|
2006-01-16 18:34:20 +03:00
|
|
|
mutex_unlock(&cm->open_mutex);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
2019-12-09 12:49:02 +03:00
|
|
|
return 0;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static void snd_cmipci_ch_reset(struct cmipci *cm, int ch)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
int reset = CM_RST_CH0 << (cm->channel[ch].ch);
|
|
|
|
snd_cmipci_write(cm, CM_REG_FUNCTRL0, cm->ctrl | reset);
|
|
|
|
snd_cmipci_write(cm, CM_REG_FUNCTRL0, cm->ctrl & ~reset);
|
|
|
|
udelay(10);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
*/
|
|
|
|
|
2017-06-07 15:18:47 +03:00
|
|
|
static const unsigned int hw_channels[] = {1, 2, 4, 6, 8};
|
|
|
|
static const struct snd_pcm_hw_constraint_list hw_constraints_channels_4 = {
|
2005-04-17 02:20:36 +04:00
|
|
|
.count = 3,
|
|
|
|
.list = hw_channels,
|
|
|
|
.mask = 0,
|
|
|
|
};
|
2017-06-07 15:18:47 +03:00
|
|
|
static const struct snd_pcm_hw_constraint_list hw_constraints_channels_6 = {
|
2007-09-17 11:39:10 +04:00
|
|
|
.count = 4,
|
2005-04-17 02:20:36 +04:00
|
|
|
.list = hw_channels,
|
|
|
|
.mask = 0,
|
|
|
|
};
|
2017-06-07 15:18:47 +03:00
|
|
|
static const struct snd_pcm_hw_constraint_list hw_constraints_channels_8 = {
|
2007-09-17 11:39:10 +04:00
|
|
|
.count = 5,
|
2005-04-17 02:20:36 +04:00
|
|
|
.list = hw_channels,
|
|
|
|
.mask = 0,
|
|
|
|
};
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static int set_dac_channels(struct cmipci *cm, struct cmipci_pcm *rec, int channels)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
if (channels > 2) {
|
2007-09-17 11:39:51 +04:00
|
|
|
if (!cm->can_multi_ch || !rec->ch)
|
2005-04-17 02:20:36 +04:00
|
|
|
return -EINVAL;
|
|
|
|
if (rec->fmt != 0x03) /* stereo 16bit only */
|
|
|
|
return -EINVAL;
|
2007-09-17 11:39:51 +04:00
|
|
|
}
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2007-09-17 11:39:51 +04:00
|
|
|
if (cm->can_multi_ch) {
|
2005-04-17 02:20:36 +04:00
|
|
|
spin_lock_irq(&cm->reg_lock);
|
2007-09-17 11:39:51 +04:00
|
|
|
if (channels > 2) {
|
|
|
|
snd_cmipci_set_bit(cm, CM_REG_LEGACY_CTRL, CM_NXCHG);
|
|
|
|
snd_cmipci_set_bit(cm, CM_REG_MISC_CTRL, CM_XCHGDAC);
|
2005-04-17 02:20:36 +04:00
|
|
|
} else {
|
2007-09-17 11:39:51 +04:00
|
|
|
snd_cmipci_clear_bit(cm, CM_REG_LEGACY_CTRL, CM_NXCHG);
|
|
|
|
snd_cmipci_clear_bit(cm, CM_REG_MISC_CTRL, CM_XCHGDAC);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
2007-09-17 11:39:51 +04:00
|
|
|
if (channels == 8)
|
|
|
|
snd_cmipci_set_bit(cm, CM_REG_EXT_MISC, CM_CHB3D8C);
|
|
|
|
else
|
|
|
|
snd_cmipci_clear_bit(cm, CM_REG_EXT_MISC, CM_CHB3D8C);
|
|
|
|
if (channels == 6) {
|
|
|
|
snd_cmipci_set_bit(cm, CM_REG_CHFORMAT, CM_CHB3D5C);
|
2005-04-17 02:20:36 +04:00
|
|
|
snd_cmipci_set_bit(cm, CM_REG_LEGACY_CTRL, CM_CHB3D6C);
|
|
|
|
} else {
|
|
|
|
snd_cmipci_clear_bit(cm, CM_REG_CHFORMAT, CM_CHB3D5C);
|
|
|
|
snd_cmipci_clear_bit(cm, CM_REG_LEGACY_CTRL, CM_CHB3D6C);
|
|
|
|
}
|
2007-09-17 11:39:51 +04:00
|
|
|
if (channels == 4)
|
|
|
|
snd_cmipci_set_bit(cm, CM_REG_CHFORMAT, CM_CHB3D);
|
|
|
|
else
|
|
|
|
snd_cmipci_clear_bit(cm, CM_REG_CHFORMAT, CM_CHB3D);
|
|
|
|
spin_unlock_irq(&cm->reg_lock);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* prepare playback/capture channel
|
|
|
|
* channel to be used must have been set in rec->ch.
|
|
|
|
*/
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_pcm_prepare(struct cmipci *cm, struct cmipci_pcm *rec,
|
|
|
|
struct snd_pcm_substream *substream)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2007-10-31 19:36:20 +03:00
|
|
|
unsigned int reg, freq, freq_ext, val;
|
2007-09-17 11:40:57 +04:00
|
|
|
unsigned int period_size;
|
2005-11-17 17:03:13 +03:00
|
|
|
struct snd_pcm_runtime *runtime = substream->runtime;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
rec->fmt = 0;
|
|
|
|
rec->shift = 0;
|
|
|
|
if (snd_pcm_format_width(runtime->format) >= 16) {
|
|
|
|
rec->fmt |= 0x02;
|
|
|
|
if (snd_pcm_format_width(runtime->format) > 16)
|
|
|
|
rec->shift++; /* 24/32bit */
|
|
|
|
}
|
|
|
|
if (runtime->channels > 1)
|
|
|
|
rec->fmt |= 0x01;
|
|
|
|
if (rec->is_dac && set_dac_channels(cm, rec, runtime->channels) < 0) {
|
2014-02-25 15:39:30 +04:00
|
|
|
dev_dbg(cm->card->dev, "cannot set dac channels\n");
|
2005-04-17 02:20:36 +04:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
rec->offset = runtime->dma_addr;
|
|
|
|
/* buffer and period sizes in frame */
|
|
|
|
rec->dma_size = runtime->buffer_size << rec->shift;
|
2007-09-17 11:40:57 +04:00
|
|
|
period_size = runtime->period_size << rec->shift;
|
2005-04-17 02:20:36 +04:00
|
|
|
if (runtime->channels > 2) {
|
|
|
|
/* multi-channels */
|
|
|
|
rec->dma_size = (rec->dma_size * runtime->channels) / 2;
|
2007-09-17 11:40:57 +04:00
|
|
|
period_size = (period_size * runtime->channels) / 2;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
spin_lock_irq(&cm->reg_lock);
|
|
|
|
|
|
|
|
/* set buffer address */
|
|
|
|
reg = rec->ch ? CM_REG_CH1_FRAME1 : CM_REG_CH0_FRAME1;
|
|
|
|
snd_cmipci_write(cm, reg, rec->offset);
|
|
|
|
/* program sample counts */
|
|
|
|
reg = rec->ch ? CM_REG_CH1_FRAME2 : CM_REG_CH0_FRAME2;
|
|
|
|
snd_cmipci_write_w(cm, reg, rec->dma_size - 1);
|
2007-09-17 11:40:57 +04:00
|
|
|
snd_cmipci_write_w(cm, reg + 2, period_size - 1);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/* set adc/dac flag */
|
|
|
|
val = rec->ch ? CM_CHADC1 : CM_CHADC0;
|
|
|
|
if (rec->is_dac)
|
|
|
|
cm->ctrl &= ~val;
|
|
|
|
else
|
|
|
|
cm->ctrl |= val;
|
|
|
|
snd_cmipci_write(cm, CM_REG_FUNCTRL0, cm->ctrl);
|
2014-02-25 15:39:30 +04:00
|
|
|
/* dev_dbg(cm->card->dev, "functrl0 = %08x\n", cm->ctrl); */
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/* set sample rate */
|
2007-10-31 19:36:20 +03:00
|
|
|
freq = 0;
|
|
|
|
freq_ext = 0;
|
|
|
|
if (runtime->rate > 48000)
|
|
|
|
switch (runtime->rate) {
|
|
|
|
case 88200: freq_ext = CM_CH0_SRATE_88K; break;
|
|
|
|
case 96000: freq_ext = CM_CH0_SRATE_96K; break;
|
|
|
|
case 128000: freq_ext = CM_CH0_SRATE_128K; break;
|
|
|
|
default: snd_BUG(); break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
freq = snd_cmipci_rate_freq(runtime->rate);
|
2005-04-17 02:20:36 +04:00
|
|
|
val = snd_cmipci_read(cm, CM_REG_FUNCTRL1);
|
|
|
|
if (rec->ch) {
|
|
|
|
val &= ~CM_DSFC_MASK;
|
|
|
|
val |= (freq << CM_DSFC_SHIFT) & CM_DSFC_MASK;
|
2007-09-17 11:35:46 +04:00
|
|
|
} else {
|
|
|
|
val &= ~CM_ASFC_MASK;
|
|
|
|
val |= (freq << CM_ASFC_SHIFT) & CM_ASFC_MASK;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
snd_cmipci_write(cm, CM_REG_FUNCTRL1, val);
|
2014-02-25 15:39:30 +04:00
|
|
|
dev_dbg(cm->card->dev, "functrl1 = %08x\n", val);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/* set format */
|
|
|
|
val = snd_cmipci_read(cm, CM_REG_CHFORMAT);
|
|
|
|
if (rec->ch) {
|
|
|
|
val &= ~CM_CH1FMT_MASK;
|
|
|
|
val |= rec->fmt << CM_CH1FMT_SHIFT;
|
|
|
|
} else {
|
|
|
|
val &= ~CM_CH0FMT_MASK;
|
|
|
|
val |= rec->fmt << CM_CH0FMT_SHIFT;
|
|
|
|
}
|
2007-10-31 19:36:20 +03:00
|
|
|
if (cm->can_96k) {
|
|
|
|
val &= ~(CM_CH0_SRATE_MASK << (rec->ch * 2));
|
|
|
|
val |= freq_ext << (rec->ch * 2);
|
2007-09-03 11:54:55 +04:00
|
|
|
}
|
2005-04-17 02:20:36 +04:00
|
|
|
snd_cmipci_write(cm, CM_REG_CHFORMAT, val);
|
2014-02-25 15:39:30 +04:00
|
|
|
dev_dbg(cm->card->dev, "chformat = %08x\n", val);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2007-11-07 17:49:57 +03:00
|
|
|
if (!rec->is_dac && cm->chip_version) {
|
|
|
|
if (runtime->rate > 44100)
|
|
|
|
snd_cmipci_set_bit(cm, CM_REG_EXT_MISC, CM_ADC48K44K);
|
|
|
|
else
|
|
|
|
snd_cmipci_clear_bit(cm, CM_REG_EXT_MISC, CM_ADC48K44K);
|
|
|
|
}
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
rec->running = 0;
|
|
|
|
spin_unlock_irq(&cm->reg_lock);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* PCM trigger/stop
|
|
|
|
*/
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_pcm_trigger(struct cmipci *cm, struct cmipci_pcm *rec,
|
2007-09-17 11:40:57 +04:00
|
|
|
int cmd)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
unsigned int inthld, chen, reset, pause;
|
|
|
|
int result = 0;
|
|
|
|
|
|
|
|
inthld = CM_CH0_INT_EN << rec->ch;
|
|
|
|
chen = CM_CHEN0 << rec->ch;
|
|
|
|
reset = CM_RST_CH0 << rec->ch;
|
|
|
|
pause = CM_PAUSE0 << rec->ch;
|
|
|
|
|
|
|
|
spin_lock(&cm->reg_lock);
|
|
|
|
switch (cmd) {
|
|
|
|
case SNDRV_PCM_TRIGGER_START:
|
|
|
|
rec->running = 1;
|
|
|
|
/* set interrupt */
|
|
|
|
snd_cmipci_set_bit(cm, CM_REG_INT_HLDCLR, inthld);
|
|
|
|
cm->ctrl |= chen;
|
|
|
|
/* enable channel */
|
|
|
|
snd_cmipci_write(cm, CM_REG_FUNCTRL0, cm->ctrl);
|
2014-02-25 15:39:30 +04:00
|
|
|
dev_dbg(cm->card->dev, "functrl0 = %08x\n", cm->ctrl);
|
2005-04-17 02:20:36 +04:00
|
|
|
break;
|
|
|
|
case SNDRV_PCM_TRIGGER_STOP:
|
|
|
|
rec->running = 0;
|
|
|
|
/* disable interrupt */
|
|
|
|
snd_cmipci_clear_bit(cm, CM_REG_INT_HLDCLR, inthld);
|
|
|
|
/* reset */
|
|
|
|
cm->ctrl &= ~chen;
|
|
|
|
snd_cmipci_write(cm, CM_REG_FUNCTRL0, cm->ctrl | reset);
|
|
|
|
snd_cmipci_write(cm, CM_REG_FUNCTRL0, cm->ctrl & ~reset);
|
2007-09-17 11:41:36 +04:00
|
|
|
rec->needs_silencing = rec->is_dac;
|
2005-04-17 02:20:36 +04:00
|
|
|
break;
|
|
|
|
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
|
2005-11-17 18:14:49 +03:00
|
|
|
case SNDRV_PCM_TRIGGER_SUSPEND:
|
2005-04-17 02:20:36 +04:00
|
|
|
cm->ctrl |= pause;
|
|
|
|
snd_cmipci_write(cm, CM_REG_FUNCTRL0, cm->ctrl);
|
|
|
|
break;
|
|
|
|
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
|
2005-11-17 18:14:49 +03:00
|
|
|
case SNDRV_PCM_TRIGGER_RESUME:
|
2005-04-17 02:20:36 +04:00
|
|
|
cm->ctrl &= ~pause;
|
|
|
|
snd_cmipci_write(cm, CM_REG_FUNCTRL0, cm->ctrl);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
result = -EINVAL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
spin_unlock(&cm->reg_lock);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* return the current pointer
|
|
|
|
*/
|
2005-11-17 17:03:13 +03:00
|
|
|
static snd_pcm_uframes_t snd_cmipci_pcm_pointer(struct cmipci *cm, struct cmipci_pcm *rec,
|
|
|
|
struct snd_pcm_substream *substream)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
size_t ptr;
|
2010-03-24 09:10:54 +03:00
|
|
|
unsigned int reg, rem, tries;
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
if (!rec->running)
|
|
|
|
return 0;
|
|
|
|
#if 1 // this seems better..
|
|
|
|
reg = rec->ch ? CM_REG_CH1_FRAME2 : CM_REG_CH0_FRAME2;
|
2010-03-24 09:10:54 +03:00
|
|
|
for (tries = 0; tries < 3; tries++) {
|
|
|
|
rem = snd_cmipci_read_w(cm, reg);
|
|
|
|
if (rem < rec->dma_size)
|
|
|
|
goto ok;
|
|
|
|
}
|
2014-02-25 15:39:30 +04:00
|
|
|
dev_err(cm->card->dev, "invalid PCM pointer: %#x\n", rem);
|
2010-03-24 09:10:54 +03:00
|
|
|
return SNDRV_PCM_POS_XRUN;
|
|
|
|
ok:
|
|
|
|
ptr = (rec->dma_size - (rem + 1)) >> rec->shift;
|
2005-04-17 02:20:36 +04:00
|
|
|
#else
|
|
|
|
reg = rec->ch ? CM_REG_CH1_FRAME1 : CM_REG_CH0_FRAME1;
|
|
|
|
ptr = snd_cmipci_read(cm, reg) - rec->offset;
|
|
|
|
ptr = bytes_to_frames(substream->runtime, ptr);
|
|
|
|
#endif
|
|
|
|
if (substream->runtime->channels > 2)
|
|
|
|
ptr = (ptr * 2) / substream->runtime->channels;
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* playback
|
|
|
|
*/
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_playback_trigger(struct snd_pcm_substream *substream,
|
2005-04-17 02:20:36 +04:00
|
|
|
int cmd)
|
|
|
|
{
|
2005-11-17 17:03:13 +03:00
|
|
|
struct cmipci *cm = snd_pcm_substream_chip(substream);
|
2007-09-17 11:40:57 +04:00
|
|
|
return snd_cmipci_pcm_trigger(cm, &cm->channel[CM_CH_PLAY], cmd);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static snd_pcm_uframes_t snd_cmipci_playback_pointer(struct snd_pcm_substream *substream)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2005-11-17 17:03:13 +03:00
|
|
|
struct cmipci *cm = snd_pcm_substream_chip(substream);
|
2005-04-17 02:20:36 +04:00
|
|
|
return snd_cmipci_pcm_pointer(cm, &cm->channel[CM_CH_PLAY], substream);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* capture
|
|
|
|
*/
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_capture_trigger(struct snd_pcm_substream *substream,
|
2005-04-17 02:20:36 +04:00
|
|
|
int cmd)
|
|
|
|
{
|
2005-11-17 17:03:13 +03:00
|
|
|
struct cmipci *cm = snd_pcm_substream_chip(substream);
|
2007-09-17 11:40:57 +04:00
|
|
|
return snd_cmipci_pcm_trigger(cm, &cm->channel[CM_CH_CAPT], cmd);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static snd_pcm_uframes_t snd_cmipci_capture_pointer(struct snd_pcm_substream *substream)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2005-11-17 17:03:13 +03:00
|
|
|
struct cmipci *cm = snd_pcm_substream_chip(substream);
|
2005-04-17 02:20:36 +04:00
|
|
|
return snd_cmipci_pcm_pointer(cm, &cm->channel[CM_CH_CAPT], substream);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* hw preparation for spdif
|
|
|
|
*/
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_spdif_default_info(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_info *uinfo)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958;
|
|
|
|
uinfo->count = 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_spdif_default_get(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2005-11-17 17:03:13 +03:00
|
|
|
struct cmipci *chip = snd_kcontrol_chip(kcontrol);
|
2005-04-17 02:20:36 +04:00
|
|
|
int i;
|
|
|
|
|
|
|
|
spin_lock_irq(&chip->reg_lock);
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
ucontrol->value.iec958.status[i] = (chip->dig_status >> (i * 8)) & 0xff;
|
|
|
|
spin_unlock_irq(&chip->reg_lock);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_spdif_default_put(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2005-11-17 17:03:13 +03:00
|
|
|
struct cmipci *chip = snd_kcontrol_chip(kcontrol);
|
2005-04-17 02:20:36 +04:00
|
|
|
int i, change;
|
|
|
|
unsigned int val;
|
|
|
|
|
|
|
|
val = 0;
|
|
|
|
spin_lock_irq(&chip->reg_lock);
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
val |= (unsigned int)ucontrol->value.iec958.status[i] << (i * 8);
|
|
|
|
change = val != chip->dig_status;
|
|
|
|
chip->dig_status = val;
|
|
|
|
spin_unlock_irq(&chip->reg_lock);
|
|
|
|
return change;
|
|
|
|
}
|
|
|
|
|
2017-02-19 21:48:09 +03:00
|
|
|
static const struct snd_kcontrol_new snd_cmipci_spdif_default =
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
.iface = SNDRV_CTL_ELEM_IFACE_PCM,
|
|
|
|
.name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT),
|
|
|
|
.info = snd_cmipci_spdif_default_info,
|
|
|
|
.get = snd_cmipci_spdif_default_get,
|
|
|
|
.put = snd_cmipci_spdif_default_put
|
|
|
|
};
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_spdif_mask_info(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_info *uinfo)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958;
|
|
|
|
uinfo->count = 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_spdif_mask_get(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
ucontrol->value.iec958.status[0] = 0xff;
|
|
|
|
ucontrol->value.iec958.status[1] = 0xff;
|
|
|
|
ucontrol->value.iec958.status[2] = 0xff;
|
|
|
|
ucontrol->value.iec958.status[3] = 0xff;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-02-19 21:48:09 +03:00
|
|
|
static const struct snd_kcontrol_new snd_cmipci_spdif_mask =
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
.access = SNDRV_CTL_ELEM_ACCESS_READ,
|
[ALSA] sound - fix .iface field of mixer control elements
Documentation,CS46xx driver,EMU10K1/EMU10K2 driver,AD1848 driver
SB16/AWE driver,CMIPCI driver,ENS1370/1+ driver,RME32 driver
RME96 driver,ICE1712 driver,ICE1724 driver,KORG1212 driver
RME HDSP driver,RME9652 driver
This patch changes .iface to SNDRV_CTL_ELEM_IFACE_MIXER whre _PCM or
_HWDEP was used in controls that are not associated with a specific PCM
(sub)stream or hwdep device, and changes some controls that got
inconsitent .iface values due to copy+paste errors. Furthermore, it
makes sure that all control that do use _PCM or _HWDEP use the correct
number in the .device field.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
2005-07-29 17:32:58 +04:00
|
|
|
.iface = SNDRV_CTL_ELEM_IFACE_PCM,
|
2005-04-17 02:20:36 +04:00
|
|
|
.name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,CON_MASK),
|
|
|
|
.info = snd_cmipci_spdif_mask_info,
|
|
|
|
.get = snd_cmipci_spdif_mask_get,
|
|
|
|
};
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_spdif_stream_info(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_info *uinfo)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958;
|
|
|
|
uinfo->count = 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_spdif_stream_get(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2005-11-17 17:03:13 +03:00
|
|
|
struct cmipci *chip = snd_kcontrol_chip(kcontrol);
|
2005-04-17 02:20:36 +04:00
|
|
|
int i;
|
|
|
|
|
|
|
|
spin_lock_irq(&chip->reg_lock);
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
ucontrol->value.iec958.status[i] = (chip->dig_pcm_status >> (i * 8)) & 0xff;
|
|
|
|
spin_unlock_irq(&chip->reg_lock);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_spdif_stream_put(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2005-11-17 17:03:13 +03:00
|
|
|
struct cmipci *chip = snd_kcontrol_chip(kcontrol);
|
2005-04-17 02:20:36 +04:00
|
|
|
int i, change;
|
|
|
|
unsigned int val;
|
|
|
|
|
|
|
|
val = 0;
|
|
|
|
spin_lock_irq(&chip->reg_lock);
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
val |= (unsigned int)ucontrol->value.iec958.status[i] << (i * 8);
|
|
|
|
change = val != chip->dig_pcm_status;
|
|
|
|
chip->dig_pcm_status = val;
|
|
|
|
spin_unlock_irq(&chip->reg_lock);
|
|
|
|
return change;
|
|
|
|
}
|
|
|
|
|
2017-02-19 21:48:09 +03:00
|
|
|
static const struct snd_kcontrol_new snd_cmipci_spdif_stream =
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
.access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_INACTIVE,
|
|
|
|
.iface = SNDRV_CTL_ELEM_IFACE_PCM,
|
|
|
|
.name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,PCM_STREAM),
|
|
|
|
.info = snd_cmipci_spdif_stream_info,
|
|
|
|
.get = snd_cmipci_spdif_stream_get,
|
|
|
|
.put = snd_cmipci_spdif_stream_put
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* save mixer setting and mute for AC3 playback */
|
2005-11-17 17:03:13 +03:00
|
|
|
static int save_mixer_state(struct cmipci *cm)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
if (! cm->mixer_insensitive) {
|
2005-11-17 17:03:13 +03:00
|
|
|
struct snd_ctl_elem_value *val;
|
2005-04-17 02:20:36 +04:00
|
|
|
unsigned int i;
|
|
|
|
|
2018-04-09 23:09:27 +03:00
|
|
|
val = kmalloc(sizeof(*val), GFP_KERNEL);
|
2005-04-17 02:20:36 +04:00
|
|
|
if (!val)
|
|
|
|
return -ENOMEM;
|
|
|
|
for (i = 0; i < CM_SAVED_MIXERS; i++) {
|
2005-11-17 17:03:13 +03:00
|
|
|
struct snd_kcontrol *ctl = cm->mixer_res_ctl[i];
|
2005-04-17 02:20:36 +04:00
|
|
|
if (ctl) {
|
|
|
|
int event;
|
|
|
|
memset(val, 0, sizeof(*val));
|
|
|
|
ctl->get(ctl, val);
|
|
|
|
cm->mixer_res_status[i] = val->value.integer.value[0];
|
|
|
|
val->value.integer.value[0] = cm_saved_mixer[i].toggle_on;
|
|
|
|
event = SNDRV_CTL_EVENT_MASK_INFO;
|
|
|
|
if (cm->mixer_res_status[i] != val->value.integer.value[0]) {
|
|
|
|
ctl->put(ctl, val); /* toggle */
|
|
|
|
event |= SNDRV_CTL_EVENT_MASK_VALUE;
|
|
|
|
}
|
|
|
|
ctl->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_INACTIVE;
|
|
|
|
snd_ctl_notify(cm->card, event, &ctl->id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
kfree(val);
|
|
|
|
cm->mixer_insensitive = 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* restore the previously saved mixer status */
|
2005-11-17 17:03:13 +03:00
|
|
|
static void restore_mixer_state(struct cmipci *cm)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
if (cm->mixer_insensitive) {
|
2005-11-17 17:03:13 +03:00
|
|
|
struct snd_ctl_elem_value *val;
|
2005-04-17 02:20:36 +04:00
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
val = kmalloc(sizeof(*val), GFP_KERNEL);
|
|
|
|
if (!val)
|
|
|
|
return;
|
|
|
|
cm->mixer_insensitive = 0; /* at first clear this;
|
|
|
|
otherwise the changes will be ignored */
|
|
|
|
for (i = 0; i < CM_SAVED_MIXERS; i++) {
|
2005-11-17 17:03:13 +03:00
|
|
|
struct snd_kcontrol *ctl = cm->mixer_res_ctl[i];
|
2005-04-17 02:20:36 +04:00
|
|
|
if (ctl) {
|
|
|
|
int event;
|
|
|
|
|
|
|
|
memset(val, 0, sizeof(*val));
|
|
|
|
ctl->vd[0].access &= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE;
|
|
|
|
ctl->get(ctl, val);
|
|
|
|
event = SNDRV_CTL_EVENT_MASK_INFO;
|
|
|
|
if (val->value.integer.value[0] != cm->mixer_res_status[i]) {
|
|
|
|
val->value.integer.value[0] = cm->mixer_res_status[i];
|
|
|
|
ctl->put(ctl, val);
|
|
|
|
event |= SNDRV_CTL_EVENT_MASK_VALUE;
|
|
|
|
}
|
|
|
|
snd_ctl_notify(cm->card, event, &ctl->id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
kfree(val);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* spinlock held! */
|
2005-11-17 17:03:13 +03:00
|
|
|
static void setup_ac3(struct cmipci *cm, struct snd_pcm_substream *subs, int do_ac3, int rate)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
if (do_ac3) {
|
|
|
|
/* AC3EN for 037 */
|
|
|
|
snd_cmipci_set_bit(cm, CM_REG_CHFORMAT, CM_AC3EN1);
|
|
|
|
/* AC3EN for 039 */
|
|
|
|
snd_cmipci_set_bit(cm, CM_REG_MISC_CTRL, CM_AC3EN2);
|
|
|
|
|
|
|
|
if (cm->can_ac3_hw) {
|
|
|
|
/* SPD24SEL for 037, 0x02 */
|
|
|
|
/* SPD24SEL for 039, 0x20, but cannot be set */
|
|
|
|
snd_cmipci_set_bit(cm, CM_REG_CHFORMAT, CM_SPD24SEL);
|
|
|
|
snd_cmipci_clear_bit(cm, CM_REG_MISC_CTRL, CM_SPD32SEL);
|
|
|
|
} else { /* can_ac3_sw */
|
|
|
|
/* SPD32SEL for 037 & 039, 0x20 */
|
|
|
|
snd_cmipci_set_bit(cm, CM_REG_MISC_CTRL, CM_SPD32SEL);
|
|
|
|
/* set 176K sample rate to fix 033 HW bug */
|
|
|
|
if (cm->chip_version == 33) {
|
|
|
|
if (rate >= 48000) {
|
|
|
|
snd_cmipci_set_bit(cm, CM_REG_CHFORMAT, CM_PLAYBACK_SRATE_176K);
|
|
|
|
} else {
|
|
|
|
snd_cmipci_clear_bit(cm, CM_REG_CHFORMAT, CM_PLAYBACK_SRATE_176K);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
snd_cmipci_clear_bit(cm, CM_REG_CHFORMAT, CM_AC3EN1);
|
|
|
|
snd_cmipci_clear_bit(cm, CM_REG_MISC_CTRL, CM_AC3EN2);
|
|
|
|
|
|
|
|
if (cm->can_ac3_hw) {
|
|
|
|
/* chip model >= 37 */
|
|
|
|
if (snd_pcm_format_width(subs->runtime->format) > 16) {
|
|
|
|
snd_cmipci_set_bit(cm, CM_REG_MISC_CTRL, CM_SPD32SEL);
|
|
|
|
snd_cmipci_set_bit(cm, CM_REG_CHFORMAT, CM_SPD24SEL);
|
|
|
|
} else {
|
|
|
|
snd_cmipci_clear_bit(cm, CM_REG_MISC_CTRL, CM_SPD32SEL);
|
|
|
|
snd_cmipci_clear_bit(cm, CM_REG_CHFORMAT, CM_SPD24SEL);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
snd_cmipci_clear_bit(cm, CM_REG_MISC_CTRL, CM_SPD32SEL);
|
|
|
|
snd_cmipci_clear_bit(cm, CM_REG_CHFORMAT, CM_SPD24SEL);
|
|
|
|
snd_cmipci_clear_bit(cm, CM_REG_CHFORMAT, CM_PLAYBACK_SRATE_176K);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static int setup_spdif_playback(struct cmipci *cm, struct snd_pcm_substream *subs, int up, int do_ac3)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
int rate, err;
|
|
|
|
|
|
|
|
rate = subs->runtime->rate;
|
|
|
|
|
2021-06-08 17:04:56 +03:00
|
|
|
if (up && do_ac3) {
|
|
|
|
err = save_mixer_state(cm);
|
|
|
|
if (err < 0)
|
2005-04-17 02:20:36 +04:00
|
|
|
return err;
|
2021-06-08 17:04:56 +03:00
|
|
|
}
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
spin_lock_irq(&cm->reg_lock);
|
|
|
|
cm->spdif_playback_avail = up;
|
|
|
|
if (up) {
|
|
|
|
/* they are controlled via "IEC958 Output Switch" */
|
|
|
|
/* snd_cmipci_set_bit(cm, CM_REG_LEGACY_CTRL, CM_ENSPDOUT); */
|
|
|
|
/* snd_cmipci_set_bit(cm, CM_REG_FUNCTRL1, CM_SPDO2DAC); */
|
|
|
|
if (cm->spdif_playback_enabled)
|
|
|
|
snd_cmipci_set_bit(cm, CM_REG_FUNCTRL1, CM_PLAYBACK_SPDF);
|
|
|
|
setup_ac3(cm, subs, do_ac3, rate);
|
|
|
|
|
2007-09-03 11:54:55 +04:00
|
|
|
if (rate == 48000 || rate == 96000)
|
2005-04-17 02:20:36 +04:00
|
|
|
snd_cmipci_set_bit(cm, CM_REG_MISC_CTRL, CM_SPDIF48K | CM_SPDF_AC97);
|
|
|
|
else
|
|
|
|
snd_cmipci_clear_bit(cm, CM_REG_MISC_CTRL, CM_SPDIF48K | CM_SPDF_AC97);
|
2007-09-03 11:54:55 +04:00
|
|
|
if (rate > 48000)
|
|
|
|
snd_cmipci_set_bit(cm, CM_REG_CHFORMAT, CM_DBLSPDS);
|
|
|
|
else
|
|
|
|
snd_cmipci_clear_bit(cm, CM_REG_CHFORMAT, CM_DBLSPDS);
|
2005-04-17 02:20:36 +04:00
|
|
|
} else {
|
|
|
|
/* they are controlled via "IEC958 Output Switch" */
|
|
|
|
/* snd_cmipci_clear_bit(cm, CM_REG_LEGACY_CTRL, CM_ENSPDOUT); */
|
|
|
|
/* snd_cmipci_clear_bit(cm, CM_REG_FUNCTRL1, CM_SPDO2DAC); */
|
2007-09-03 11:54:55 +04:00
|
|
|
snd_cmipci_clear_bit(cm, CM_REG_CHFORMAT, CM_DBLSPDS);
|
2005-04-17 02:20:36 +04:00
|
|
|
snd_cmipci_clear_bit(cm, CM_REG_FUNCTRL1, CM_PLAYBACK_SPDF);
|
|
|
|
setup_ac3(cm, subs, 0, 0);
|
|
|
|
}
|
|
|
|
spin_unlock_irq(&cm->reg_lock);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* preparation
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* playback - enable spdif only on the certain condition */
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_playback_prepare(struct snd_pcm_substream *substream)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2005-11-17 17:03:13 +03:00
|
|
|
struct cmipci *cm = snd_pcm_substream_chip(substream);
|
2005-04-17 02:20:36 +04:00
|
|
|
int rate = substream->runtime->rate;
|
|
|
|
int err, do_spdif, do_ac3 = 0;
|
|
|
|
|
2007-10-31 19:36:20 +03:00
|
|
|
do_spdif = (rate >= 44100 && rate <= 96000 &&
|
2005-04-17 02:20:36 +04:00
|
|
|
substream->runtime->format == SNDRV_PCM_FORMAT_S16_LE &&
|
|
|
|
substream->runtime->channels == 2);
|
|
|
|
if (do_spdif && cm->can_ac3_hw)
|
|
|
|
do_ac3 = cm->dig_pcm_status & IEC958_AES0_NONAUDIO;
|
2021-06-08 17:04:56 +03:00
|
|
|
err = setup_spdif_playback(cm, substream, do_spdif, do_ac3);
|
|
|
|
if (err < 0)
|
2005-04-17 02:20:36 +04:00
|
|
|
return err;
|
|
|
|
return snd_cmipci_pcm_prepare(cm, &cm->channel[CM_CH_PLAY], substream);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* playback (via device #2) - enable spdif always */
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_playback_spdif_prepare(struct snd_pcm_substream *substream)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2005-11-17 17:03:13 +03:00
|
|
|
struct cmipci *cm = snd_pcm_substream_chip(substream);
|
2005-04-17 02:20:36 +04:00
|
|
|
int err, do_ac3;
|
|
|
|
|
|
|
|
if (cm->can_ac3_hw)
|
|
|
|
do_ac3 = cm->dig_pcm_status & IEC958_AES0_NONAUDIO;
|
|
|
|
else
|
|
|
|
do_ac3 = 1; /* doesn't matter */
|
2021-06-08 17:04:56 +03:00
|
|
|
err = setup_spdif_playback(cm, substream, 1, do_ac3);
|
|
|
|
if (err < 0)
|
2005-04-17 02:20:36 +04:00
|
|
|
return err;
|
|
|
|
return snd_cmipci_pcm_prepare(cm, &cm->channel[CM_CH_PLAY], substream);
|
|
|
|
}
|
|
|
|
|
2007-09-17 11:41:36 +04:00
|
|
|
/*
|
|
|
|
* Apparently, the samples last played on channel A stay in some buffer, even
|
|
|
|
* after the channel is reset, and get added to the data for the rear DACs when
|
|
|
|
* playing a multichannel stream on channel B. This is likely to generate
|
|
|
|
* wraparounds and thus distortions.
|
|
|
|
* To avoid this, we play at least one zero sample after the actual stream has
|
|
|
|
* stopped.
|
|
|
|
*/
|
|
|
|
static void snd_cmipci_silence_hack(struct cmipci *cm, struct cmipci_pcm *rec)
|
|
|
|
{
|
|
|
|
struct snd_pcm_runtime *runtime = rec->substream->runtime;
|
|
|
|
unsigned int reg, val;
|
|
|
|
|
|
|
|
if (rec->needs_silencing && runtime && runtime->dma_area) {
|
|
|
|
/* set up a small silence buffer */
|
|
|
|
memset(runtime->dma_area, 0, PAGE_SIZE);
|
|
|
|
reg = rec->ch ? CM_REG_CH1_FRAME2 : CM_REG_CH0_FRAME2;
|
|
|
|
val = ((PAGE_SIZE / 4) - 1) | (((PAGE_SIZE / 4) / 2 - 1) << 16);
|
|
|
|
snd_cmipci_write(cm, reg, val);
|
|
|
|
|
|
|
|
/* configure for 16 bits, 2 channels, 8 kHz */
|
|
|
|
if (runtime->channels > 2)
|
|
|
|
set_dac_channels(cm, rec, 2);
|
|
|
|
spin_lock_irq(&cm->reg_lock);
|
|
|
|
val = snd_cmipci_read(cm, CM_REG_FUNCTRL1);
|
|
|
|
val &= ~(CM_ASFC_MASK << (rec->ch * 3));
|
|
|
|
val |= (4 << CM_ASFC_SHIFT) << (rec->ch * 3);
|
|
|
|
snd_cmipci_write(cm, CM_REG_FUNCTRL1, val);
|
|
|
|
val = snd_cmipci_read(cm, CM_REG_CHFORMAT);
|
|
|
|
val &= ~(CM_CH0FMT_MASK << (rec->ch * 2));
|
|
|
|
val |= (3 << CM_CH0FMT_SHIFT) << (rec->ch * 2);
|
2007-10-31 19:36:20 +03:00
|
|
|
if (cm->can_96k)
|
|
|
|
val &= ~(CM_CH0_SRATE_MASK << (rec->ch * 2));
|
2007-09-17 11:41:36 +04:00
|
|
|
snd_cmipci_write(cm, CM_REG_CHFORMAT, val);
|
|
|
|
|
|
|
|
/* start stream (we don't need interrupts) */
|
|
|
|
cm->ctrl |= CM_CHEN0 << rec->ch;
|
|
|
|
snd_cmipci_write(cm, CM_REG_FUNCTRL0, cm->ctrl);
|
|
|
|
spin_unlock_irq(&cm->reg_lock);
|
|
|
|
|
|
|
|
msleep(1);
|
|
|
|
|
|
|
|
/* stop and reset stream */
|
|
|
|
spin_lock_irq(&cm->reg_lock);
|
|
|
|
cm->ctrl &= ~(CM_CHEN0 << rec->ch);
|
|
|
|
val = CM_RST_CH0 << rec->ch;
|
|
|
|
snd_cmipci_write(cm, CM_REG_FUNCTRL0, cm->ctrl | val);
|
|
|
|
snd_cmipci_write(cm, CM_REG_FUNCTRL0, cm->ctrl & ~val);
|
|
|
|
spin_unlock_irq(&cm->reg_lock);
|
|
|
|
|
|
|
|
rec->needs_silencing = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_playback_hw_free(struct snd_pcm_substream *substream)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2005-11-17 17:03:13 +03:00
|
|
|
struct cmipci *cm = snd_pcm_substream_chip(substream);
|
2005-04-17 02:20:36 +04:00
|
|
|
setup_spdif_playback(cm, substream, 0, 0);
|
|
|
|
restore_mixer_state(cm);
|
2007-09-17 11:41:36 +04:00
|
|
|
snd_cmipci_silence_hack(cm, &cm->channel[0]);
|
2019-12-09 12:49:02 +03:00
|
|
|
return 0;
|
2007-09-17 11:41:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static int snd_cmipci_playback2_hw_free(struct snd_pcm_substream *substream)
|
|
|
|
{
|
|
|
|
struct cmipci *cm = snd_pcm_substream_chip(substream);
|
|
|
|
snd_cmipci_silence_hack(cm, &cm->channel[1]);
|
2019-12-09 12:49:02 +03:00
|
|
|
return 0;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* capture */
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_capture_prepare(struct snd_pcm_substream *substream)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2005-11-17 17:03:13 +03:00
|
|
|
struct cmipci *cm = snd_pcm_substream_chip(substream);
|
2005-04-17 02:20:36 +04:00
|
|
|
return snd_cmipci_pcm_prepare(cm, &cm->channel[CM_CH_CAPT], substream);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* capture with spdif (via device #2) */
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_capture_spdif_prepare(struct snd_pcm_substream *substream)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2005-11-17 17:03:13 +03:00
|
|
|
struct cmipci *cm = snd_pcm_substream_chip(substream);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
spin_lock_irq(&cm->reg_lock);
|
|
|
|
snd_cmipci_set_bit(cm, CM_REG_FUNCTRL1, CM_CAPTURE_SPDF);
|
2007-10-31 19:36:20 +03:00
|
|
|
if (cm->can_96k) {
|
|
|
|
if (substream->runtime->rate > 48000)
|
|
|
|
snd_cmipci_set_bit(cm, CM_REG_CHFORMAT, CM_DBLSPDS);
|
|
|
|
else
|
|
|
|
snd_cmipci_clear_bit(cm, CM_REG_CHFORMAT, CM_DBLSPDS);
|
|
|
|
}
|
2007-11-07 17:50:52 +03:00
|
|
|
if (snd_pcm_format_width(substream->runtime->format) > 16)
|
|
|
|
snd_cmipci_set_bit(cm, CM_REG_MISC_CTRL, CM_SPD32SEL);
|
|
|
|
else
|
|
|
|
snd_cmipci_clear_bit(cm, CM_REG_MISC_CTRL, CM_SPD32SEL);
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
spin_unlock_irq(&cm->reg_lock);
|
|
|
|
|
|
|
|
return snd_cmipci_pcm_prepare(cm, &cm->channel[CM_CH_CAPT], substream);
|
|
|
|
}
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_capture_spdif_hw_free(struct snd_pcm_substream *subs)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2005-11-17 17:03:13 +03:00
|
|
|
struct cmipci *cm = snd_pcm_substream_chip(subs);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
spin_lock_irq(&cm->reg_lock);
|
|
|
|
snd_cmipci_clear_bit(cm, CM_REG_FUNCTRL1, CM_CAPTURE_SPDF);
|
2007-11-07 17:50:52 +03:00
|
|
|
snd_cmipci_clear_bit(cm, CM_REG_MISC_CTRL, CM_SPD32SEL);
|
2005-04-17 02:20:36 +04:00
|
|
|
spin_unlock_irq(&cm->reg_lock);
|
|
|
|
|
2019-12-09 12:49:02 +03:00
|
|
|
return 0;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* interrupt handler
|
|
|
|
*/
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 17:55:46 +04:00
|
|
|
static irqreturn_t snd_cmipci_interrupt(int irq, void *dev_id)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2005-11-17 17:03:13 +03:00
|
|
|
struct cmipci *cm = dev_id;
|
2005-04-17 02:20:36 +04:00
|
|
|
unsigned int status, mask = 0;
|
|
|
|
|
|
|
|
/* fastpath out, to ease interrupt sharing */
|
|
|
|
status = snd_cmipci_read(cm, CM_REG_INT_STATUS);
|
|
|
|
if (!(status & CM_INTR))
|
|
|
|
return IRQ_NONE;
|
|
|
|
|
|
|
|
/* acknowledge interrupt */
|
|
|
|
spin_lock(&cm->reg_lock);
|
|
|
|
if (status & CM_CHINT0)
|
|
|
|
mask |= CM_CH0_INT_EN;
|
|
|
|
if (status & CM_CHINT1)
|
|
|
|
mask |= CM_CH1_INT_EN;
|
|
|
|
snd_cmipci_clear_bit(cm, CM_REG_INT_HLDCLR, mask);
|
|
|
|
snd_cmipci_set_bit(cm, CM_REG_INT_HLDCLR, mask);
|
|
|
|
spin_unlock(&cm->reg_lock);
|
|
|
|
|
|
|
|
if (cm->rmidi && (status & CM_UARTINT))
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 17:55:46 +04:00
|
|
|
snd_mpu401_uart_interrupt(irq, cm->rmidi->private_data);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
if (cm->pcm) {
|
|
|
|
if ((status & CM_CHINT0) && cm->channel[0].running)
|
|
|
|
snd_pcm_period_elapsed(cm->channel[0].substream);
|
|
|
|
if ((status & CM_CHINT1) && cm->channel[1].running)
|
|
|
|
snd_pcm_period_elapsed(cm->channel[1].substream);
|
|
|
|
}
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* h/w infos
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* playback on channel A */
|
2017-08-12 18:31:28 +03:00
|
|
|
static const struct snd_pcm_hardware snd_cmipci_playback =
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
.info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
|
|
|
|
SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_PAUSE |
|
2005-11-17 18:14:49 +03:00
|
|
|
SNDRV_PCM_INFO_RESUME | SNDRV_PCM_INFO_MMAP_VALID),
|
2005-04-17 02:20:36 +04:00
|
|
|
.formats = SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE,
|
|
|
|
.rates = SNDRV_PCM_RATE_5512 | SNDRV_PCM_RATE_8000_48000,
|
|
|
|
.rate_min = 5512,
|
|
|
|
.rate_max = 48000,
|
|
|
|
.channels_min = 1,
|
|
|
|
.channels_max = 2,
|
|
|
|
.buffer_bytes_max = (128*1024),
|
|
|
|
.period_bytes_min = 64,
|
|
|
|
.period_bytes_max = (128*1024),
|
|
|
|
.periods_min = 2,
|
|
|
|
.periods_max = 1024,
|
|
|
|
.fifo_size = 0,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* capture on channel B */
|
2017-08-12 18:31:28 +03:00
|
|
|
static const struct snd_pcm_hardware snd_cmipci_capture =
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
.info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
|
|
|
|
SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_PAUSE |
|
2005-11-17 18:14:49 +03:00
|
|
|
SNDRV_PCM_INFO_RESUME | SNDRV_PCM_INFO_MMAP_VALID),
|
2005-04-17 02:20:36 +04:00
|
|
|
.formats = SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE,
|
|
|
|
.rates = SNDRV_PCM_RATE_5512 | SNDRV_PCM_RATE_8000_48000,
|
|
|
|
.rate_min = 5512,
|
|
|
|
.rate_max = 48000,
|
|
|
|
.channels_min = 1,
|
|
|
|
.channels_max = 2,
|
|
|
|
.buffer_bytes_max = (128*1024),
|
|
|
|
.period_bytes_min = 64,
|
|
|
|
.period_bytes_max = (128*1024),
|
|
|
|
.periods_min = 2,
|
|
|
|
.periods_max = 1024,
|
|
|
|
.fifo_size = 0,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* playback on channel B - stereo 16bit only? */
|
2017-08-12 18:31:28 +03:00
|
|
|
static const struct snd_pcm_hardware snd_cmipci_playback2 =
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
.info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
|
|
|
|
SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_PAUSE |
|
2005-11-17 18:14:49 +03:00
|
|
|
SNDRV_PCM_INFO_RESUME | SNDRV_PCM_INFO_MMAP_VALID),
|
2005-04-17 02:20:36 +04:00
|
|
|
.formats = SNDRV_PCM_FMTBIT_S16_LE,
|
|
|
|
.rates = SNDRV_PCM_RATE_5512 | SNDRV_PCM_RATE_8000_48000,
|
|
|
|
.rate_min = 5512,
|
|
|
|
.rate_max = 48000,
|
|
|
|
.channels_min = 2,
|
|
|
|
.channels_max = 2,
|
|
|
|
.buffer_bytes_max = (128*1024),
|
|
|
|
.period_bytes_min = 64,
|
|
|
|
.period_bytes_max = (128*1024),
|
|
|
|
.periods_min = 2,
|
|
|
|
.periods_max = 1024,
|
|
|
|
.fifo_size = 0,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* spdif playback on channel A */
|
2017-08-12 18:31:28 +03:00
|
|
|
static const struct snd_pcm_hardware snd_cmipci_playback_spdif =
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
.info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
|
|
|
|
SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_PAUSE |
|
2005-11-17 18:14:49 +03:00
|
|
|
SNDRV_PCM_INFO_RESUME | SNDRV_PCM_INFO_MMAP_VALID),
|
2005-04-17 02:20:36 +04:00
|
|
|
.formats = SNDRV_PCM_FMTBIT_S16_LE,
|
|
|
|
.rates = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000,
|
|
|
|
.rate_min = 44100,
|
|
|
|
.rate_max = 48000,
|
|
|
|
.channels_min = 2,
|
|
|
|
.channels_max = 2,
|
|
|
|
.buffer_bytes_max = (128*1024),
|
|
|
|
.period_bytes_min = 64,
|
|
|
|
.period_bytes_max = (128*1024),
|
|
|
|
.periods_min = 2,
|
|
|
|
.periods_max = 1024,
|
|
|
|
.fifo_size = 0,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* spdif playback on channel A (32bit, IEC958 subframes) */
|
2017-08-12 18:31:28 +03:00
|
|
|
static const struct snd_pcm_hardware snd_cmipci_playback_iec958_subframe =
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
.info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
|
|
|
|
SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_PAUSE |
|
2005-11-17 18:14:49 +03:00
|
|
|
SNDRV_PCM_INFO_RESUME | SNDRV_PCM_INFO_MMAP_VALID),
|
2005-04-17 02:20:36 +04:00
|
|
|
.formats = SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE,
|
|
|
|
.rates = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000,
|
|
|
|
.rate_min = 44100,
|
|
|
|
.rate_max = 48000,
|
|
|
|
.channels_min = 2,
|
|
|
|
.channels_max = 2,
|
|
|
|
.buffer_bytes_max = (128*1024),
|
|
|
|
.period_bytes_min = 64,
|
|
|
|
.period_bytes_max = (128*1024),
|
|
|
|
.periods_min = 2,
|
|
|
|
.periods_max = 1024,
|
|
|
|
.fifo_size = 0,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* spdif capture on channel B */
|
2017-08-12 18:31:28 +03:00
|
|
|
static const struct snd_pcm_hardware snd_cmipci_capture_spdif =
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
.info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
|
|
|
|
SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_PAUSE |
|
2005-11-17 18:14:49 +03:00
|
|
|
SNDRV_PCM_INFO_RESUME | SNDRV_PCM_INFO_MMAP_VALID),
|
2007-11-07 17:50:52 +03:00
|
|
|
.formats = SNDRV_PCM_FMTBIT_S16_LE |
|
|
|
|
SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE,
|
2005-04-17 02:20:36 +04:00
|
|
|
.rates = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000,
|
|
|
|
.rate_min = 44100,
|
|
|
|
.rate_max = 48000,
|
|
|
|
.channels_min = 2,
|
|
|
|
.channels_max = 2,
|
|
|
|
.buffer_bytes_max = (128*1024),
|
|
|
|
.period_bytes_min = 64,
|
|
|
|
.period_bytes_max = (128*1024),
|
|
|
|
.periods_min = 2,
|
|
|
|
.periods_max = 1024,
|
|
|
|
.fifo_size = 0,
|
|
|
|
};
|
|
|
|
|
2017-06-07 15:18:47 +03:00
|
|
|
static const unsigned int rate_constraints[] = { 5512, 8000, 11025, 16000, 22050,
|
2007-10-31 19:36:20 +03:00
|
|
|
32000, 44100, 48000, 88200, 96000, 128000 };
|
2017-06-07 15:18:47 +03:00
|
|
|
static const struct snd_pcm_hw_constraint_list hw_constraints_rates = {
|
2007-10-31 19:36:20 +03:00
|
|
|
.count = ARRAY_SIZE(rate_constraints),
|
|
|
|
.list = rate_constraints,
|
|
|
|
.mask = 0,
|
|
|
|
};
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/*
|
|
|
|
* check device open/close
|
|
|
|
*/
|
2005-11-17 17:03:13 +03:00
|
|
|
static int open_device_check(struct cmipci *cm, int mode, struct snd_pcm_substream *subs)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
int ch = mode & CM_OPEN_CH_MASK;
|
|
|
|
|
|
|
|
/* FIXME: a file should wait until the device becomes free
|
|
|
|
* when it's opened on blocking mode. however, since the current
|
|
|
|
* pcm framework doesn't pass file pointer before actually opened,
|
|
|
|
* we can't know whether blocking mode or not in open callback..
|
|
|
|
*/
|
2006-01-16 18:34:20 +03:00
|
|
|
mutex_lock(&cm->open_mutex);
|
2005-04-17 02:20:36 +04:00
|
|
|
if (cm->opened[ch]) {
|
2006-01-16 18:34:20 +03:00
|
|
|
mutex_unlock(&cm->open_mutex);
|
2005-04-17 02:20:36 +04:00
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
cm->opened[ch] = mode;
|
|
|
|
cm->channel[ch].substream = subs;
|
|
|
|
if (! (mode & CM_OPEN_DAC)) {
|
|
|
|
/* disable dual DAC mode */
|
|
|
|
cm->channel[ch].is_dac = 0;
|
|
|
|
spin_lock_irq(&cm->reg_lock);
|
|
|
|
snd_cmipci_clear_bit(cm, CM_REG_MISC_CTRL, CM_ENDBDAC);
|
|
|
|
spin_unlock_irq(&cm->reg_lock);
|
|
|
|
}
|
2006-01-16 18:34:20 +03:00
|
|
|
mutex_unlock(&cm->open_mutex);
|
2005-04-17 02:20:36 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static void close_device_check(struct cmipci *cm, int mode)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
int ch = mode & CM_OPEN_CH_MASK;
|
|
|
|
|
2006-01-16 18:34:20 +03:00
|
|
|
mutex_lock(&cm->open_mutex);
|
2005-04-17 02:20:36 +04:00
|
|
|
if (cm->opened[ch] == mode) {
|
|
|
|
if (cm->channel[ch].substream) {
|
|
|
|
snd_cmipci_ch_reset(cm, ch);
|
|
|
|
cm->channel[ch].running = 0;
|
|
|
|
cm->channel[ch].substream = NULL;
|
|
|
|
}
|
|
|
|
cm->opened[ch] = 0;
|
|
|
|
if (! cm->channel[ch].is_dac) {
|
|
|
|
/* enable dual DAC mode again */
|
|
|
|
cm->channel[ch].is_dac = 1;
|
|
|
|
spin_lock_irq(&cm->reg_lock);
|
|
|
|
snd_cmipci_set_bit(cm, CM_REG_MISC_CTRL, CM_ENDBDAC);
|
|
|
|
spin_unlock_irq(&cm->reg_lock);
|
|
|
|
}
|
|
|
|
}
|
2006-01-16 18:34:20 +03:00
|
|
|
mutex_unlock(&cm->open_mutex);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
*/
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_playback_open(struct snd_pcm_substream *substream)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2005-11-17 17:03:13 +03:00
|
|
|
struct cmipci *cm = snd_pcm_substream_chip(substream);
|
|
|
|
struct snd_pcm_runtime *runtime = substream->runtime;
|
2005-04-17 02:20:36 +04:00
|
|
|
int err;
|
|
|
|
|
2021-06-08 17:04:56 +03:00
|
|
|
err = open_device_check(cm, CM_OPEN_PLAYBACK, substream);
|
|
|
|
if (err < 0)
|
2005-04-17 02:20:36 +04:00
|
|
|
return err;
|
|
|
|
runtime->hw = snd_cmipci_playback;
|
2007-09-03 11:54:55 +04:00
|
|
|
if (cm->chip_version == 68) {
|
|
|
|
runtime->hw.rates |= SNDRV_PCM_RATE_88200 |
|
|
|
|
SNDRV_PCM_RATE_96000;
|
|
|
|
runtime->hw.rate_max = 96000;
|
2007-10-31 19:36:20 +03:00
|
|
|
} else if (cm->chip_version == 55) {
|
|
|
|
err = snd_pcm_hw_constraint_list(runtime, 0,
|
|
|
|
SNDRV_PCM_HW_PARAM_RATE, &hw_constraints_rates);
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
runtime->hw.rates |= SNDRV_PCM_RATE_KNOT;
|
|
|
|
runtime->hw.rate_max = 128000;
|
2007-09-03 11:54:55 +04:00
|
|
|
}
|
2005-04-17 02:20:36 +04:00
|
|
|
snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 0, 0x10000);
|
|
|
|
cm->dig_pcm_status = cm->dig_status;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_capture_open(struct snd_pcm_substream *substream)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2005-11-17 17:03:13 +03:00
|
|
|
struct cmipci *cm = snd_pcm_substream_chip(substream);
|
|
|
|
struct snd_pcm_runtime *runtime = substream->runtime;
|
2005-04-17 02:20:36 +04:00
|
|
|
int err;
|
|
|
|
|
2021-06-08 17:04:56 +03:00
|
|
|
err = open_device_check(cm, CM_OPEN_CAPTURE, substream);
|
|
|
|
if (err < 0)
|
2005-04-17 02:20:36 +04:00
|
|
|
return err;
|
|
|
|
runtime->hw = snd_cmipci_capture;
|
|
|
|
if (cm->chip_version == 68) { // 8768 only supports 44k/48k recording
|
|
|
|
runtime->hw.rate_min = 41000;
|
|
|
|
runtime->hw.rates = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000;
|
2007-10-31 19:36:20 +03:00
|
|
|
} else if (cm->chip_version == 55) {
|
|
|
|
err = snd_pcm_hw_constraint_list(runtime, 0,
|
|
|
|
SNDRV_PCM_HW_PARAM_RATE, &hw_constraints_rates);
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
runtime->hw.rates |= SNDRV_PCM_RATE_KNOT;
|
|
|
|
runtime->hw.rate_max = 128000;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 0, 0x10000);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_playback2_open(struct snd_pcm_substream *substream)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2005-11-17 17:03:13 +03:00
|
|
|
struct cmipci *cm = snd_pcm_substream_chip(substream);
|
|
|
|
struct snd_pcm_runtime *runtime = substream->runtime;
|
2005-04-17 02:20:36 +04:00
|
|
|
int err;
|
|
|
|
|
2021-06-08 17:04:56 +03:00
|
|
|
/* use channel B */
|
|
|
|
err = open_device_check(cm, CM_OPEN_PLAYBACK2, substream);
|
|
|
|
if (err < 0)
|
2005-04-17 02:20:36 +04:00
|
|
|
return err;
|
|
|
|
runtime->hw = snd_cmipci_playback2;
|
2006-01-16 18:34:20 +03:00
|
|
|
mutex_lock(&cm->open_mutex);
|
2005-04-17 02:20:36 +04:00
|
|
|
if (! cm->opened[CM_CH_PLAY]) {
|
|
|
|
if (cm->can_multi_ch) {
|
|
|
|
runtime->hw.channels_max = cm->max_channels;
|
|
|
|
if (cm->max_channels == 4)
|
|
|
|
snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, &hw_constraints_channels_4);
|
|
|
|
else if (cm->max_channels == 6)
|
|
|
|
snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, &hw_constraints_channels_6);
|
|
|
|
else if (cm->max_channels == 8)
|
|
|
|
snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, &hw_constraints_channels_8);
|
|
|
|
}
|
|
|
|
}
|
2006-01-16 18:34:20 +03:00
|
|
|
mutex_unlock(&cm->open_mutex);
|
2007-09-17 11:37:47 +04:00
|
|
|
if (cm->chip_version == 68) {
|
|
|
|
runtime->hw.rates |= SNDRV_PCM_RATE_88200 |
|
|
|
|
SNDRV_PCM_RATE_96000;
|
|
|
|
runtime->hw.rate_max = 96000;
|
2007-10-31 19:36:20 +03:00
|
|
|
} else if (cm->chip_version == 55) {
|
|
|
|
err = snd_pcm_hw_constraint_list(runtime, 0,
|
|
|
|
SNDRV_PCM_HW_PARAM_RATE, &hw_constraints_rates);
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
runtime->hw.rates |= SNDRV_PCM_RATE_KNOT;
|
|
|
|
runtime->hw.rate_max = 128000;
|
2007-09-17 11:37:47 +04:00
|
|
|
}
|
|
|
|
snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 0, 0x10000);
|
2005-04-17 02:20:36 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_playback_spdif_open(struct snd_pcm_substream *substream)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2005-11-17 17:03:13 +03:00
|
|
|
struct cmipci *cm = snd_pcm_substream_chip(substream);
|
|
|
|
struct snd_pcm_runtime *runtime = substream->runtime;
|
2005-04-17 02:20:36 +04:00
|
|
|
int err;
|
|
|
|
|
2021-06-08 17:04:56 +03:00
|
|
|
/* use channel A */
|
|
|
|
err = open_device_check(cm, CM_OPEN_SPDIF_PLAYBACK, substream);
|
|
|
|
if (err < 0)
|
2005-04-17 02:20:36 +04:00
|
|
|
return err;
|
|
|
|
if (cm->can_ac3_hw) {
|
|
|
|
runtime->hw = snd_cmipci_playback_spdif;
|
2007-09-07 12:44:13 +04:00
|
|
|
if (cm->chip_version >= 37) {
|
2005-04-17 02:20:36 +04:00
|
|
|
runtime->hw.formats |= SNDRV_PCM_FMTBIT_S32_LE;
|
2007-09-07 12:44:13 +04:00
|
|
|
snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24);
|
|
|
|
}
|
2007-10-31 19:36:20 +03:00
|
|
|
if (cm->can_96k) {
|
2007-09-03 11:54:55 +04:00
|
|
|
runtime->hw.rates |= SNDRV_PCM_RATE_88200 |
|
|
|
|
SNDRV_PCM_RATE_96000;
|
|
|
|
runtime->hw.rate_max = 96000;
|
|
|
|
}
|
2005-04-17 02:20:36 +04:00
|
|
|
} else {
|
|
|
|
runtime->hw = snd_cmipci_playback_iec958_subframe;
|
|
|
|
}
|
|
|
|
snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 0, 0x40000);
|
|
|
|
cm->dig_pcm_status = cm->dig_status;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_capture_spdif_open(struct snd_pcm_substream *substream)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2005-11-17 17:03:13 +03:00
|
|
|
struct cmipci *cm = snd_pcm_substream_chip(substream);
|
|
|
|
struct snd_pcm_runtime *runtime = substream->runtime;
|
2005-04-17 02:20:36 +04:00
|
|
|
int err;
|
|
|
|
|
2021-06-08 17:04:56 +03:00
|
|
|
/* use channel B */
|
|
|
|
err = open_device_check(cm, CM_OPEN_SPDIF_CAPTURE, substream);
|
|
|
|
if (err < 0)
|
2005-04-17 02:20:36 +04:00
|
|
|
return err;
|
|
|
|
runtime->hw = snd_cmipci_capture_spdif;
|
2007-10-31 19:36:20 +03:00
|
|
|
if (cm->can_96k && !(cm->chip_version == 68)) {
|
|
|
|
runtime->hw.rates |= SNDRV_PCM_RATE_88200 |
|
|
|
|
SNDRV_PCM_RATE_96000;
|
|
|
|
runtime->hw.rate_max = 96000;
|
|
|
|
}
|
2005-04-17 02:20:36 +04:00
|
|
|
snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 0, 0x40000);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
*/
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_playback_close(struct snd_pcm_substream *substream)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2005-11-17 17:03:13 +03:00
|
|
|
struct cmipci *cm = snd_pcm_substream_chip(substream);
|
2005-04-17 02:20:36 +04:00
|
|
|
close_device_check(cm, CM_OPEN_PLAYBACK);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_capture_close(struct snd_pcm_substream *substream)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2005-11-17 17:03:13 +03:00
|
|
|
struct cmipci *cm = snd_pcm_substream_chip(substream);
|
2005-04-17 02:20:36 +04:00
|
|
|
close_device_check(cm, CM_OPEN_CAPTURE);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_playback2_close(struct snd_pcm_substream *substream)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2005-11-17 17:03:13 +03:00
|
|
|
struct cmipci *cm = snd_pcm_substream_chip(substream);
|
2005-04-17 02:20:36 +04:00
|
|
|
close_device_check(cm, CM_OPEN_PLAYBACK2);
|
|
|
|
close_device_check(cm, CM_OPEN_PLAYBACK_MULTI);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_playback_spdif_close(struct snd_pcm_substream *substream)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2005-11-17 17:03:13 +03:00
|
|
|
struct cmipci *cm = snd_pcm_substream_chip(substream);
|
2005-04-17 02:20:36 +04:00
|
|
|
close_device_check(cm, CM_OPEN_SPDIF_PLAYBACK);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_capture_spdif_close(struct snd_pcm_substream *substream)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2005-11-17 17:03:13 +03:00
|
|
|
struct cmipci *cm = snd_pcm_substream_chip(substream);
|
2005-04-17 02:20:36 +04:00
|
|
|
close_device_check(cm, CM_OPEN_SPDIF_CAPTURE);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
*/
|
|
|
|
|
2016-09-02 01:13:10 +03:00
|
|
|
static const struct snd_pcm_ops snd_cmipci_playback_ops = {
|
2005-04-17 02:20:36 +04:00
|
|
|
.open = snd_cmipci_playback_open,
|
|
|
|
.close = snd_cmipci_playback_close,
|
|
|
|
.hw_free = snd_cmipci_playback_hw_free,
|
|
|
|
.prepare = snd_cmipci_playback_prepare,
|
|
|
|
.trigger = snd_cmipci_playback_trigger,
|
|
|
|
.pointer = snd_cmipci_playback_pointer,
|
|
|
|
};
|
|
|
|
|
2016-09-02 01:13:10 +03:00
|
|
|
static const struct snd_pcm_ops snd_cmipci_capture_ops = {
|
2005-04-17 02:20:36 +04:00
|
|
|
.open = snd_cmipci_capture_open,
|
|
|
|
.close = snd_cmipci_capture_close,
|
|
|
|
.prepare = snd_cmipci_capture_prepare,
|
|
|
|
.trigger = snd_cmipci_capture_trigger,
|
|
|
|
.pointer = snd_cmipci_capture_pointer,
|
|
|
|
};
|
|
|
|
|
2016-09-02 01:13:10 +03:00
|
|
|
static const struct snd_pcm_ops snd_cmipci_playback2_ops = {
|
2005-04-17 02:20:36 +04:00
|
|
|
.open = snd_cmipci_playback2_open,
|
|
|
|
.close = snd_cmipci_playback2_close,
|
|
|
|
.hw_params = snd_cmipci_playback2_hw_params,
|
2007-09-17 11:41:36 +04:00
|
|
|
.hw_free = snd_cmipci_playback2_hw_free,
|
2005-04-17 02:20:36 +04:00
|
|
|
.prepare = snd_cmipci_capture_prepare, /* channel B */
|
|
|
|
.trigger = snd_cmipci_capture_trigger, /* channel B */
|
|
|
|
.pointer = snd_cmipci_capture_pointer, /* channel B */
|
|
|
|
};
|
|
|
|
|
2016-09-02 01:13:10 +03:00
|
|
|
static const struct snd_pcm_ops snd_cmipci_playback_spdif_ops = {
|
2005-04-17 02:20:36 +04:00
|
|
|
.open = snd_cmipci_playback_spdif_open,
|
|
|
|
.close = snd_cmipci_playback_spdif_close,
|
|
|
|
.hw_free = snd_cmipci_playback_hw_free,
|
|
|
|
.prepare = snd_cmipci_playback_spdif_prepare, /* set up rate */
|
|
|
|
.trigger = snd_cmipci_playback_trigger,
|
|
|
|
.pointer = snd_cmipci_playback_pointer,
|
|
|
|
};
|
|
|
|
|
2016-09-02 01:13:10 +03:00
|
|
|
static const struct snd_pcm_ops snd_cmipci_capture_spdif_ops = {
|
2005-04-17 02:20:36 +04:00
|
|
|
.open = snd_cmipci_capture_spdif_open,
|
|
|
|
.close = snd_cmipci_capture_spdif_close,
|
|
|
|
.hw_free = snd_cmipci_capture_spdif_hw_free,
|
|
|
|
.prepare = snd_cmipci_capture_spdif_prepare,
|
|
|
|
.trigger = snd_cmipci_capture_trigger,
|
|
|
|
.pointer = snd_cmipci_capture_pointer,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
*/
|
|
|
|
|
2012-12-06 21:35:10 +04:00
|
|
|
static int snd_cmipci_pcm_new(struct cmipci *cm, int device)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2005-11-17 17:03:13 +03:00
|
|
|
struct snd_pcm *pcm;
|
2005-04-17 02:20:36 +04:00
|
|
|
int err;
|
|
|
|
|
|
|
|
err = snd_pcm_new(cm->card, cm->card->driver, device, 1, 1, &pcm);
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_cmipci_playback_ops);
|
|
|
|
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_cmipci_capture_ops);
|
|
|
|
|
|
|
|
pcm->private_data = cm;
|
|
|
|
pcm->info_flags = 0;
|
|
|
|
strcpy(pcm->name, "C-Media PCI DAC/ADC");
|
|
|
|
cm->pcm = pcm;
|
|
|
|
|
2019-12-09 12:49:02 +03:00
|
|
|
snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV,
|
|
|
|
&cm->pci->dev, 64*1024, 128*1024);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-12-06 21:35:10 +04:00
|
|
|
static int snd_cmipci_pcm2_new(struct cmipci *cm, int device)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2005-11-17 17:03:13 +03:00
|
|
|
struct snd_pcm *pcm;
|
2005-04-17 02:20:36 +04:00
|
|
|
int err;
|
|
|
|
|
|
|
|
err = snd_pcm_new(cm->card, cm->card->driver, device, 1, 0, &pcm);
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_cmipci_playback2_ops);
|
|
|
|
|
|
|
|
pcm->private_data = cm;
|
|
|
|
pcm->info_flags = 0;
|
|
|
|
strcpy(pcm->name, "C-Media PCI 2nd DAC");
|
|
|
|
cm->pcm2 = pcm;
|
|
|
|
|
2019-12-09 12:49:02 +03:00
|
|
|
snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV,
|
|
|
|
&cm->pci->dev, 64*1024, 128*1024);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-12-06 21:35:10 +04:00
|
|
|
static int snd_cmipci_pcm_spdif_new(struct cmipci *cm, int device)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2005-11-17 17:03:13 +03:00
|
|
|
struct snd_pcm *pcm;
|
2005-04-17 02:20:36 +04:00
|
|
|
int err;
|
|
|
|
|
|
|
|
err = snd_pcm_new(cm->card, cm->card->driver, device, 1, 1, &pcm);
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_cmipci_playback_spdif_ops);
|
|
|
|
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_cmipci_capture_spdif_ops);
|
|
|
|
|
|
|
|
pcm->private_data = cm;
|
|
|
|
pcm->info_flags = 0;
|
|
|
|
strcpy(pcm->name, "C-Media PCI IEC958");
|
|
|
|
cm->pcm_spdif = pcm;
|
|
|
|
|
2019-12-09 12:49:02 +03:00
|
|
|
snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV,
|
|
|
|
&cm->pci->dev, 64*1024, 128*1024);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2012-08-03 20:02:38 +04:00
|
|
|
err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK,
|
|
|
|
snd_pcm_alt_chmaps, cm->max_channels, 0,
|
|
|
|
NULL);
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* mixer interface:
|
|
|
|
* - CM8338/8738 has a compatible mixer interface with SB16, but
|
|
|
|
* lack of some elements like tone control, i/o gain and AGC.
|
|
|
|
* - Access to native registers:
|
|
|
|
* - A 3D switch
|
|
|
|
* - Output mute switches
|
|
|
|
*/
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static void snd_cmipci_mixer_write(struct cmipci *s, unsigned char idx, unsigned char data)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
outb(idx, s->iobase + CM_REG_SB16_ADDR);
|
|
|
|
outb(data, s->iobase + CM_REG_SB16_DATA);
|
|
|
|
}
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static unsigned char snd_cmipci_mixer_read(struct cmipci *s, unsigned char idx)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
unsigned char v;
|
|
|
|
|
|
|
|
outb(idx, s->iobase + CM_REG_SB16_ADDR);
|
|
|
|
v = inb(s->iobase + CM_REG_SB16_DATA);
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* general mixer element
|
|
|
|
*/
|
2005-11-17 17:03:13 +03:00
|
|
|
struct cmipci_sb_reg {
|
2005-04-17 02:20:36 +04:00
|
|
|
unsigned int left_reg, right_reg;
|
|
|
|
unsigned int left_shift, right_shift;
|
|
|
|
unsigned int mask;
|
|
|
|
unsigned int invert: 1;
|
|
|
|
unsigned int stereo: 1;
|
2005-11-17 17:03:13 +03:00
|
|
|
};
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
#define COMPOSE_SB_REG(lreg,rreg,lshift,rshift,mask,invert,stereo) \
|
|
|
|
((lreg) | ((rreg) << 8) | (lshift << 16) | (rshift << 19) | (mask << 24) | (invert << 22) | (stereo << 23))
|
|
|
|
|
|
|
|
#define CMIPCI_DOUBLE(xname, left_reg, right_reg, left_shift, right_shift, mask, invert, stereo) \
|
|
|
|
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
|
|
|
|
.info = snd_cmipci_info_volume, \
|
|
|
|
.get = snd_cmipci_get_volume, .put = snd_cmipci_put_volume, \
|
|
|
|
.private_value = COMPOSE_SB_REG(left_reg, right_reg, left_shift, right_shift, mask, invert, stereo), \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define CMIPCI_SB_VOL_STEREO(xname,reg,shift,mask) CMIPCI_DOUBLE(xname, reg, reg+1, shift, shift, mask, 0, 1)
|
|
|
|
#define CMIPCI_SB_VOL_MONO(xname,reg,shift,mask) CMIPCI_DOUBLE(xname, reg, reg, shift, shift, mask, 0, 0)
|
|
|
|
#define CMIPCI_SB_SW_STEREO(xname,lshift,rshift) CMIPCI_DOUBLE(xname, SB_DSP4_OUTPUT_SW, SB_DSP4_OUTPUT_SW, lshift, rshift, 1, 0, 1)
|
|
|
|
#define CMIPCI_SB_SW_MONO(xname,shift) CMIPCI_DOUBLE(xname, SB_DSP4_OUTPUT_SW, SB_DSP4_OUTPUT_SW, shift, shift, 1, 0, 0)
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static void cmipci_sb_reg_decode(struct cmipci_sb_reg *r, unsigned long val)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
r->left_reg = val & 0xff;
|
|
|
|
r->right_reg = (val >> 8) & 0xff;
|
|
|
|
r->left_shift = (val >> 16) & 0x07;
|
|
|
|
r->right_shift = (val >> 19) & 0x07;
|
|
|
|
r->invert = (val >> 22) & 1;
|
|
|
|
r->stereo = (val >> 23) & 1;
|
|
|
|
r->mask = (val >> 24) & 0xff;
|
|
|
|
}
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_info_volume(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_info *uinfo)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2005-11-17 17:03:13 +03:00
|
|
|
struct cmipci_sb_reg reg;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
cmipci_sb_reg_decode(®, kcontrol->private_value);
|
|
|
|
uinfo->type = reg.mask == 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER;
|
|
|
|
uinfo->count = reg.stereo + 1;
|
|
|
|
uinfo->value.integer.min = 0;
|
|
|
|
uinfo->value.integer.max = reg.mask;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_get_volume(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2005-11-17 17:03:13 +03:00
|
|
|
struct cmipci *cm = snd_kcontrol_chip(kcontrol);
|
|
|
|
struct cmipci_sb_reg reg;
|
2005-04-17 02:20:36 +04:00
|
|
|
int val;
|
|
|
|
|
|
|
|
cmipci_sb_reg_decode(®, kcontrol->private_value);
|
|
|
|
spin_lock_irq(&cm->reg_lock);
|
|
|
|
val = (snd_cmipci_mixer_read(cm, reg.left_reg) >> reg.left_shift) & reg.mask;
|
|
|
|
if (reg.invert)
|
|
|
|
val = reg.mask - val;
|
|
|
|
ucontrol->value.integer.value[0] = val;
|
|
|
|
if (reg.stereo) {
|
|
|
|
val = (snd_cmipci_mixer_read(cm, reg.right_reg) >> reg.right_shift) & reg.mask;
|
|
|
|
if (reg.invert)
|
|
|
|
val = reg.mask - val;
|
2015-02-25 16:33:57 +03:00
|
|
|
ucontrol->value.integer.value[1] = val;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
spin_unlock_irq(&cm->reg_lock);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_put_volume(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2005-11-17 17:03:13 +03:00
|
|
|
struct cmipci *cm = snd_kcontrol_chip(kcontrol);
|
|
|
|
struct cmipci_sb_reg reg;
|
2005-04-17 02:20:36 +04:00
|
|
|
int change;
|
|
|
|
int left, right, oleft, oright;
|
|
|
|
|
|
|
|
cmipci_sb_reg_decode(®, kcontrol->private_value);
|
|
|
|
left = ucontrol->value.integer.value[0] & reg.mask;
|
|
|
|
if (reg.invert)
|
|
|
|
left = reg.mask - left;
|
|
|
|
left <<= reg.left_shift;
|
|
|
|
if (reg.stereo) {
|
|
|
|
right = ucontrol->value.integer.value[1] & reg.mask;
|
|
|
|
if (reg.invert)
|
|
|
|
right = reg.mask - right;
|
|
|
|
right <<= reg.right_shift;
|
|
|
|
} else
|
|
|
|
right = 0;
|
|
|
|
spin_lock_irq(&cm->reg_lock);
|
|
|
|
oleft = snd_cmipci_mixer_read(cm, reg.left_reg);
|
|
|
|
left |= oleft & ~(reg.mask << reg.left_shift);
|
|
|
|
change = left != oleft;
|
|
|
|
if (reg.stereo) {
|
|
|
|
if (reg.left_reg != reg.right_reg) {
|
|
|
|
snd_cmipci_mixer_write(cm, reg.left_reg, left);
|
|
|
|
oright = snd_cmipci_mixer_read(cm, reg.right_reg);
|
|
|
|
} else
|
|
|
|
oright = left;
|
|
|
|
right |= oright & ~(reg.mask << reg.right_shift);
|
|
|
|
change |= right != oright;
|
|
|
|
snd_cmipci_mixer_write(cm, reg.right_reg, right);
|
|
|
|
} else
|
|
|
|
snd_cmipci_mixer_write(cm, reg.left_reg, left);
|
|
|
|
spin_unlock_irq(&cm->reg_lock);
|
|
|
|
return change;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* input route (left,right) -> (left,right)
|
|
|
|
*/
|
|
|
|
#define CMIPCI_SB_INPUT_SW(xname, left_shift, right_shift) \
|
|
|
|
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
|
|
|
|
.info = snd_cmipci_info_input_sw, \
|
|
|
|
.get = snd_cmipci_get_input_sw, .put = snd_cmipci_put_input_sw, \
|
|
|
|
.private_value = COMPOSE_SB_REG(SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT, left_shift, right_shift, 1, 0, 1), \
|
|
|
|
}
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_info_input_sw(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_info *uinfo)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
|
|
|
|
uinfo->count = 4;
|
|
|
|
uinfo->value.integer.min = 0;
|
|
|
|
uinfo->value.integer.max = 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_get_input_sw(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2005-11-17 17:03:13 +03:00
|
|
|
struct cmipci *cm = snd_kcontrol_chip(kcontrol);
|
|
|
|
struct cmipci_sb_reg reg;
|
2005-04-17 02:20:36 +04:00
|
|
|
int val1, val2;
|
|
|
|
|
|
|
|
cmipci_sb_reg_decode(®, kcontrol->private_value);
|
|
|
|
spin_lock_irq(&cm->reg_lock);
|
|
|
|
val1 = snd_cmipci_mixer_read(cm, reg.left_reg);
|
|
|
|
val2 = snd_cmipci_mixer_read(cm, reg.right_reg);
|
|
|
|
spin_unlock_irq(&cm->reg_lock);
|
|
|
|
ucontrol->value.integer.value[0] = (val1 >> reg.left_shift) & 1;
|
|
|
|
ucontrol->value.integer.value[1] = (val2 >> reg.left_shift) & 1;
|
|
|
|
ucontrol->value.integer.value[2] = (val1 >> reg.right_shift) & 1;
|
|
|
|
ucontrol->value.integer.value[3] = (val2 >> reg.right_shift) & 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_put_input_sw(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2005-11-17 17:03:13 +03:00
|
|
|
struct cmipci *cm = snd_kcontrol_chip(kcontrol);
|
|
|
|
struct cmipci_sb_reg reg;
|
2005-04-17 02:20:36 +04:00
|
|
|
int change;
|
|
|
|
int val1, val2, oval1, oval2;
|
|
|
|
|
|
|
|
cmipci_sb_reg_decode(®, kcontrol->private_value);
|
|
|
|
spin_lock_irq(&cm->reg_lock);
|
|
|
|
oval1 = snd_cmipci_mixer_read(cm, reg.left_reg);
|
|
|
|
oval2 = snd_cmipci_mixer_read(cm, reg.right_reg);
|
|
|
|
val1 = oval1 & ~((1 << reg.left_shift) | (1 << reg.right_shift));
|
|
|
|
val2 = oval2 & ~((1 << reg.left_shift) | (1 << reg.right_shift));
|
|
|
|
val1 |= (ucontrol->value.integer.value[0] & 1) << reg.left_shift;
|
|
|
|
val2 |= (ucontrol->value.integer.value[1] & 1) << reg.left_shift;
|
|
|
|
val1 |= (ucontrol->value.integer.value[2] & 1) << reg.right_shift;
|
|
|
|
val2 |= (ucontrol->value.integer.value[3] & 1) << reg.right_shift;
|
|
|
|
change = val1 != oval1 || val2 != oval2;
|
|
|
|
snd_cmipci_mixer_write(cm, reg.left_reg, val1);
|
|
|
|
snd_cmipci_mixer_write(cm, reg.right_reg, val2);
|
|
|
|
spin_unlock_irq(&cm->reg_lock);
|
|
|
|
return change;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* native mixer switches/volumes
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define CMIPCI_MIXER_SW_STEREO(xname, reg, lshift, rshift, invert) \
|
|
|
|
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
|
|
|
|
.info = snd_cmipci_info_native_mixer, \
|
|
|
|
.get = snd_cmipci_get_native_mixer, .put = snd_cmipci_put_native_mixer, \
|
|
|
|
.private_value = COMPOSE_SB_REG(reg, reg, lshift, rshift, 1, invert, 1), \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define CMIPCI_MIXER_SW_MONO(xname, reg, shift, invert) \
|
|
|
|
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
|
|
|
|
.info = snd_cmipci_info_native_mixer, \
|
|
|
|
.get = snd_cmipci_get_native_mixer, .put = snd_cmipci_put_native_mixer, \
|
|
|
|
.private_value = COMPOSE_SB_REG(reg, reg, shift, shift, 1, invert, 0), \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define CMIPCI_MIXER_VOL_STEREO(xname, reg, lshift, rshift, mask) \
|
|
|
|
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
|
|
|
|
.info = snd_cmipci_info_native_mixer, \
|
|
|
|
.get = snd_cmipci_get_native_mixer, .put = snd_cmipci_put_native_mixer, \
|
|
|
|
.private_value = COMPOSE_SB_REG(reg, reg, lshift, rshift, mask, 0, 1), \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define CMIPCI_MIXER_VOL_MONO(xname, reg, shift, mask) \
|
|
|
|
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
|
|
|
|
.info = snd_cmipci_info_native_mixer, \
|
|
|
|
.get = snd_cmipci_get_native_mixer, .put = snd_cmipci_put_native_mixer, \
|
|
|
|
.private_value = COMPOSE_SB_REG(reg, reg, shift, shift, mask, 0, 0), \
|
|
|
|
}
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_info_native_mixer(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_info *uinfo)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2005-11-17 17:03:13 +03:00
|
|
|
struct cmipci_sb_reg reg;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
cmipci_sb_reg_decode(®, kcontrol->private_value);
|
|
|
|
uinfo->type = reg.mask == 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER;
|
|
|
|
uinfo->count = reg.stereo + 1;
|
|
|
|
uinfo->value.integer.min = 0;
|
|
|
|
uinfo->value.integer.max = reg.mask;
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_get_native_mixer(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2005-11-17 17:03:13 +03:00
|
|
|
struct cmipci *cm = snd_kcontrol_chip(kcontrol);
|
|
|
|
struct cmipci_sb_reg reg;
|
2005-04-17 02:20:36 +04:00
|
|
|
unsigned char oreg, val;
|
|
|
|
|
|
|
|
cmipci_sb_reg_decode(®, kcontrol->private_value);
|
|
|
|
spin_lock_irq(&cm->reg_lock);
|
|
|
|
oreg = inb(cm->iobase + reg.left_reg);
|
|
|
|
val = (oreg >> reg.left_shift) & reg.mask;
|
|
|
|
if (reg.invert)
|
|
|
|
val = reg.mask - val;
|
|
|
|
ucontrol->value.integer.value[0] = val;
|
|
|
|
if (reg.stereo) {
|
|
|
|
val = (oreg >> reg.right_shift) & reg.mask;
|
|
|
|
if (reg.invert)
|
|
|
|
val = reg.mask - val;
|
|
|
|
ucontrol->value.integer.value[1] = val;
|
|
|
|
}
|
|
|
|
spin_unlock_irq(&cm->reg_lock);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_put_native_mixer(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2005-11-17 17:03:13 +03:00
|
|
|
struct cmipci *cm = snd_kcontrol_chip(kcontrol);
|
|
|
|
struct cmipci_sb_reg reg;
|
2005-04-17 02:20:36 +04:00
|
|
|
unsigned char oreg, nreg, val;
|
|
|
|
|
|
|
|
cmipci_sb_reg_decode(®, kcontrol->private_value);
|
|
|
|
spin_lock_irq(&cm->reg_lock);
|
|
|
|
oreg = inb(cm->iobase + reg.left_reg);
|
|
|
|
val = ucontrol->value.integer.value[0] & reg.mask;
|
|
|
|
if (reg.invert)
|
|
|
|
val = reg.mask - val;
|
|
|
|
nreg = oreg & ~(reg.mask << reg.left_shift);
|
|
|
|
nreg |= (val << reg.left_shift);
|
|
|
|
if (reg.stereo) {
|
|
|
|
val = ucontrol->value.integer.value[1] & reg.mask;
|
|
|
|
if (reg.invert)
|
|
|
|
val = reg.mask - val;
|
|
|
|
nreg &= ~(reg.mask << reg.right_shift);
|
|
|
|
nreg |= (val << reg.right_shift);
|
|
|
|
}
|
|
|
|
outb(nreg, cm->iobase + reg.left_reg);
|
|
|
|
spin_unlock_irq(&cm->reg_lock);
|
|
|
|
return (nreg != oreg);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* special case - check mixer sensitivity
|
|
|
|
*/
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_get_native_mixer_sensitive(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2005-11-17 17:03:13 +03:00
|
|
|
//struct cmipci *cm = snd_kcontrol_chip(kcontrol);
|
2005-04-17 02:20:36 +04:00
|
|
|
return snd_cmipci_get_native_mixer(kcontrol, ucontrol);
|
|
|
|
}
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_put_native_mixer_sensitive(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2005-11-17 17:03:13 +03:00
|
|
|
struct cmipci *cm = snd_kcontrol_chip(kcontrol);
|
2005-04-17 02:20:36 +04:00
|
|
|
if (cm->mixer_insensitive) {
|
|
|
|
/* ignored */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return snd_cmipci_put_native_mixer(kcontrol, ucontrol);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-01-03 11:16:53 +03:00
|
|
|
static const struct snd_kcontrol_new snd_cmipci_mixers[] = {
|
2005-04-17 02:20:36 +04:00
|
|
|
CMIPCI_SB_VOL_STEREO("Master Playback Volume", SB_DSP4_MASTER_DEV, 3, 31),
|
|
|
|
CMIPCI_MIXER_SW_MONO("3D Control - Switch", CM_REG_MIXER1, CM_X3DEN_SHIFT, 0),
|
|
|
|
CMIPCI_SB_VOL_STEREO("PCM Playback Volume", SB_DSP4_PCM_DEV, 3, 31),
|
|
|
|
//CMIPCI_MIXER_SW_MONO("PCM Playback Switch", CM_REG_MIXER1, CM_WSMUTE_SHIFT, 1),
|
|
|
|
{ /* switch with sensitivity */
|
|
|
|
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
|
|
|
|
.name = "PCM Playback Switch",
|
|
|
|
.info = snd_cmipci_info_native_mixer,
|
|
|
|
.get = snd_cmipci_get_native_mixer_sensitive,
|
|
|
|
.put = snd_cmipci_put_native_mixer_sensitive,
|
|
|
|
.private_value = COMPOSE_SB_REG(CM_REG_MIXER1, CM_REG_MIXER1, CM_WSMUTE_SHIFT, CM_WSMUTE_SHIFT, 1, 1, 0),
|
|
|
|
},
|
|
|
|
CMIPCI_MIXER_SW_STEREO("PCM Capture Switch", CM_REG_MIXER1, CM_WAVEINL_SHIFT, CM_WAVEINR_SHIFT, 0),
|
|
|
|
CMIPCI_SB_VOL_STEREO("Synth Playback Volume", SB_DSP4_SYNTH_DEV, 3, 31),
|
|
|
|
CMIPCI_MIXER_SW_MONO("Synth Playback Switch", CM_REG_MIXER1, CM_FMMUTE_SHIFT, 1),
|
|
|
|
CMIPCI_SB_INPUT_SW("Synth Capture Route", 6, 5),
|
|
|
|
CMIPCI_SB_VOL_STEREO("CD Playback Volume", SB_DSP4_CD_DEV, 3, 31),
|
|
|
|
CMIPCI_SB_SW_STEREO("CD Playback Switch", 2, 1),
|
|
|
|
CMIPCI_SB_INPUT_SW("CD Capture Route", 2, 1),
|
|
|
|
CMIPCI_SB_VOL_STEREO("Line Playback Volume", SB_DSP4_LINE_DEV, 3, 31),
|
|
|
|
CMIPCI_SB_SW_STEREO("Line Playback Switch", 4, 3),
|
|
|
|
CMIPCI_SB_INPUT_SW("Line Capture Route", 4, 3),
|
|
|
|
CMIPCI_SB_VOL_MONO("Mic Playback Volume", SB_DSP4_MIC_DEV, 3, 31),
|
|
|
|
CMIPCI_SB_SW_MONO("Mic Playback Switch", 0),
|
|
|
|
CMIPCI_DOUBLE("Mic Capture Switch", SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT, 0, 0, 1, 0, 0),
|
2009-11-03 17:47:25 +03:00
|
|
|
CMIPCI_SB_VOL_MONO("Beep Playback Volume", SB_DSP4_SPEAKER_DEV, 6, 3),
|
2005-04-17 02:20:36 +04:00
|
|
|
CMIPCI_MIXER_VOL_STEREO("Aux Playback Volume", CM_REG_AUX_VOL, 4, 0, 15),
|
|
|
|
CMIPCI_MIXER_SW_STEREO("Aux Playback Switch", CM_REG_MIXER2, CM_VAUXLM_SHIFT, CM_VAUXRM_SHIFT, 0),
|
|
|
|
CMIPCI_MIXER_SW_STEREO("Aux Capture Switch", CM_REG_MIXER2, CM_RAUXLEN_SHIFT, CM_RAUXREN_SHIFT, 0),
|
2005-06-30 15:45:20 +04:00
|
|
|
CMIPCI_MIXER_SW_MONO("Mic Boost Playback Switch", CM_REG_MIXER2, CM_MICGAINZ_SHIFT, 1),
|
2005-04-17 02:20:36 +04:00
|
|
|
CMIPCI_MIXER_VOL_MONO("Mic Capture Volume", CM_REG_MIXER2, CM_VADMIC_SHIFT, 7),
|
2005-06-30 15:45:20 +04:00
|
|
|
CMIPCI_SB_VOL_MONO("Phone Playback Volume", CM_REG_EXTENT_IND, 5, 7),
|
|
|
|
CMIPCI_DOUBLE("Phone Playback Switch", CM_REG_EXTENT_IND, CM_REG_EXTENT_IND, 4, 4, 1, 0, 0),
|
2009-11-03 17:47:25 +03:00
|
|
|
CMIPCI_DOUBLE("Beep Playback Switch", CM_REG_EXTENT_IND, CM_REG_EXTENT_IND, 3, 3, 1, 0, 0),
|
2005-06-30 15:45:20 +04:00
|
|
|
CMIPCI_DOUBLE("Mic Boost Capture Switch", CM_REG_EXTENT_IND, CM_REG_EXTENT_IND, 0, 0, 1, 0, 0),
|
2005-04-17 02:20:36 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* other switches
|
|
|
|
*/
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
struct cmipci_switch_args {
|
2005-04-17 02:20:36 +04:00
|
|
|
int reg; /* register index */
|
|
|
|
unsigned int mask; /* mask bits */
|
|
|
|
unsigned int mask_on; /* mask bits to turn on */
|
|
|
|
unsigned int is_byte: 1; /* byte access? */
|
2005-11-17 17:03:13 +03:00
|
|
|
unsigned int ac3_sensitive: 1; /* access forbidden during
|
|
|
|
* non-audio operation?
|
|
|
|
*/
|
|
|
|
};
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2007-07-23 17:42:26 +04:00
|
|
|
#define snd_cmipci_uswitch_info snd_ctl_boolean_mono_info
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static int _snd_cmipci_uswitch_get(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol,
|
|
|
|
struct cmipci_switch_args *args)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
unsigned int val;
|
2005-11-17 17:03:13 +03:00
|
|
|
struct cmipci *cm = snd_kcontrol_chip(kcontrol);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
spin_lock_irq(&cm->reg_lock);
|
|
|
|
if (args->ac3_sensitive && cm->mixer_insensitive) {
|
|
|
|
ucontrol->value.integer.value[0] = 0;
|
|
|
|
spin_unlock_irq(&cm->reg_lock);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (args->is_byte)
|
|
|
|
val = inb(cm->iobase + args->reg);
|
|
|
|
else
|
|
|
|
val = snd_cmipci_read(cm, args->reg);
|
|
|
|
ucontrol->value.integer.value[0] = ((val & args->mask) == args->mask_on) ? 1 : 0;
|
|
|
|
spin_unlock_irq(&cm->reg_lock);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_uswitch_get(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2005-11-17 17:03:13 +03:00
|
|
|
struct cmipci_switch_args *args;
|
|
|
|
args = (struct cmipci_switch_args *)kcontrol->private_value;
|
2008-08-08 19:12:14 +04:00
|
|
|
if (snd_BUG_ON(!args))
|
|
|
|
return -EINVAL;
|
2005-04-17 02:20:36 +04:00
|
|
|
return _snd_cmipci_uswitch_get(kcontrol, ucontrol, args);
|
|
|
|
}
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static int _snd_cmipci_uswitch_put(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol,
|
|
|
|
struct cmipci_switch_args *args)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
unsigned int val;
|
|
|
|
int change;
|
2005-11-17 17:03:13 +03:00
|
|
|
struct cmipci *cm = snd_kcontrol_chip(kcontrol);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
spin_lock_irq(&cm->reg_lock);
|
|
|
|
if (args->ac3_sensitive && cm->mixer_insensitive) {
|
|
|
|
/* ignored */
|
|
|
|
spin_unlock_irq(&cm->reg_lock);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (args->is_byte)
|
|
|
|
val = inb(cm->iobase + args->reg);
|
|
|
|
else
|
|
|
|
val = snd_cmipci_read(cm, args->reg);
|
2006-12-20 21:20:07 +03:00
|
|
|
change = (val & args->mask) != (ucontrol->value.integer.value[0] ?
|
|
|
|
args->mask_on : (args->mask & ~args->mask_on));
|
2005-04-17 02:20:36 +04:00
|
|
|
if (change) {
|
|
|
|
val &= ~args->mask;
|
|
|
|
if (ucontrol->value.integer.value[0])
|
|
|
|
val |= args->mask_on;
|
|
|
|
else
|
|
|
|
val |= (args->mask & ~args->mask_on);
|
|
|
|
if (args->is_byte)
|
|
|
|
outb((unsigned char)val, cm->iobase + args->reg);
|
|
|
|
else
|
|
|
|
snd_cmipci_write(cm, args->reg, val);
|
|
|
|
}
|
|
|
|
spin_unlock_irq(&cm->reg_lock);
|
|
|
|
return change;
|
|
|
|
}
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_uswitch_put(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2005-11-17 17:03:13 +03:00
|
|
|
struct cmipci_switch_args *args;
|
|
|
|
args = (struct cmipci_switch_args *)kcontrol->private_value;
|
2008-08-08 19:12:14 +04:00
|
|
|
if (snd_BUG_ON(!args))
|
|
|
|
return -EINVAL;
|
2005-04-17 02:20:36 +04:00
|
|
|
return _snd_cmipci_uswitch_put(kcontrol, ucontrol, args);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define DEFINE_SWITCH_ARG(sname, xreg, xmask, xmask_on, xis_byte, xac3) \
|
2005-11-17 17:03:13 +03:00
|
|
|
static struct cmipci_switch_args cmipci_switch_arg_##sname = { \
|
2005-04-17 02:20:36 +04:00
|
|
|
.reg = xreg, \
|
|
|
|
.mask = xmask, \
|
|
|
|
.mask_on = xmask_on, \
|
|
|
|
.is_byte = xis_byte, \
|
|
|
|
.ac3_sensitive = xac3, \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define DEFINE_BIT_SWITCH_ARG(sname, xreg, xmask, xis_byte, xac3) \
|
|
|
|
DEFINE_SWITCH_ARG(sname, xreg, xmask, xmask, xis_byte, xac3)
|
|
|
|
|
|
|
|
#if 0 /* these will be controlled in pcm device */
|
|
|
|
DEFINE_BIT_SWITCH_ARG(spdif_in, CM_REG_FUNCTRL1, CM_SPDF_1, 0, 0);
|
|
|
|
DEFINE_BIT_SWITCH_ARG(spdif_out, CM_REG_FUNCTRL1, CM_SPDF_0, 0, 0);
|
|
|
|
#endif
|
|
|
|
DEFINE_BIT_SWITCH_ARG(spdif_in_sel1, CM_REG_CHFORMAT, CM_SPDIF_SELECT1, 0, 0);
|
|
|
|
DEFINE_BIT_SWITCH_ARG(spdif_in_sel2, CM_REG_MISC_CTRL, CM_SPDIF_SELECT2, 0, 0);
|
|
|
|
DEFINE_BIT_SWITCH_ARG(spdif_enable, CM_REG_LEGACY_CTRL, CM_ENSPDOUT, 0, 0);
|
|
|
|
DEFINE_BIT_SWITCH_ARG(spdo2dac, CM_REG_FUNCTRL1, CM_SPDO2DAC, 0, 1);
|
|
|
|
DEFINE_BIT_SWITCH_ARG(spdi_valid, CM_REG_MISC, CM_SPDVALID, 1, 0);
|
|
|
|
DEFINE_BIT_SWITCH_ARG(spdif_copyright, CM_REG_LEGACY_CTRL, CM_SPDCOPYRHT, 0, 0);
|
|
|
|
DEFINE_BIT_SWITCH_ARG(spdif_dac_out, CM_REG_LEGACY_CTRL, CM_DAC2SPDO, 0, 1);
|
|
|
|
DEFINE_SWITCH_ARG(spdo_5v, CM_REG_MISC_CTRL, CM_SPDO5V, 0, 0, 0); /* inverse: 0 = 5V */
|
|
|
|
// DEFINE_BIT_SWITCH_ARG(spdo_48k, CM_REG_MISC_CTRL, CM_SPDF_AC97|CM_SPDIF48K, 0, 1);
|
|
|
|
DEFINE_BIT_SWITCH_ARG(spdif_loop, CM_REG_FUNCTRL1, CM_SPDFLOOP, 0, 1);
|
|
|
|
DEFINE_BIT_SWITCH_ARG(spdi_monitor, CM_REG_MIXER1, CM_CDPLAY, 1, 0);
|
|
|
|
/* DEFINE_BIT_SWITCH_ARG(spdi_phase, CM_REG_CHFORMAT, CM_SPDIF_INVERSE, 0, 0); */
|
|
|
|
DEFINE_BIT_SWITCH_ARG(spdi_phase, CM_REG_MISC, CM_SPDIF_INVERSE, 1, 0);
|
|
|
|
DEFINE_BIT_SWITCH_ARG(spdi_phase2, CM_REG_CHFORMAT, CM_SPDIF_INVERSE2, 0, 0);
|
|
|
|
#if CM_CH_PLAY == 1
|
|
|
|
DEFINE_SWITCH_ARG(exchange_dac, CM_REG_MISC_CTRL, CM_XCHGDAC, 0, 0, 0); /* reversed */
|
|
|
|
#else
|
|
|
|
DEFINE_SWITCH_ARG(exchange_dac, CM_REG_MISC_CTRL, CM_XCHGDAC, CM_XCHGDAC, 0, 0);
|
|
|
|
#endif
|
|
|
|
DEFINE_BIT_SWITCH_ARG(fourch, CM_REG_MISC_CTRL, CM_N4SPK3D, 0, 0);
|
2007-09-17 11:35:46 +04:00
|
|
|
// DEFINE_BIT_SWITCH_ARG(line_rear, CM_REG_MIXER1, CM_REAR2LIN, 1, 0);
|
|
|
|
// DEFINE_BIT_SWITCH_ARG(line_bass, CM_REG_LEGACY_CTRL, CM_CENTR2LIN|CM_BASE2LIN, 0, 0);
|
2005-04-17 02:20:36 +04:00
|
|
|
// DEFINE_BIT_SWITCH_ARG(joystick, CM_REG_FUNCTRL1, CM_JYSTK_EN, 0, 0); /* now module option */
|
|
|
|
DEFINE_SWITCH_ARG(modem, CM_REG_MISC_CTRL, CM_FLINKON|CM_FLINKOFF, CM_FLINKON, 0, 0);
|
|
|
|
|
|
|
|
#define DEFINE_SWITCH(sname, stype, sarg) \
|
|
|
|
{ .name = sname, \
|
|
|
|
.iface = stype, \
|
|
|
|
.info = snd_cmipci_uswitch_info, \
|
|
|
|
.get = snd_cmipci_uswitch_get, \
|
|
|
|
.put = snd_cmipci_uswitch_put, \
|
|
|
|
.private_value = (unsigned long)&cmipci_switch_arg_##sarg,\
|
|
|
|
}
|
|
|
|
|
|
|
|
#define DEFINE_CARD_SWITCH(sname, sarg) DEFINE_SWITCH(sname, SNDRV_CTL_ELEM_IFACE_CARD, sarg)
|
|
|
|
#define DEFINE_MIXER_SWITCH(sname, sarg) DEFINE_SWITCH(sname, SNDRV_CTL_ELEM_IFACE_MIXER, sarg)
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* callbacks for spdif output switch
|
|
|
|
* needs toggle two registers..
|
|
|
|
*/
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_spdout_enable_get(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
int changed;
|
|
|
|
changed = _snd_cmipci_uswitch_get(kcontrol, ucontrol, &cmipci_switch_arg_spdif_enable);
|
|
|
|
changed |= _snd_cmipci_uswitch_get(kcontrol, ucontrol, &cmipci_switch_arg_spdo2dac);
|
|
|
|
return changed;
|
|
|
|
}
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_spdout_enable_put(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2005-11-17 17:03:13 +03:00
|
|
|
struct cmipci *chip = snd_kcontrol_chip(kcontrol);
|
2005-04-17 02:20:36 +04:00
|
|
|
int changed;
|
|
|
|
changed = _snd_cmipci_uswitch_put(kcontrol, ucontrol, &cmipci_switch_arg_spdif_enable);
|
|
|
|
changed |= _snd_cmipci_uswitch_put(kcontrol, ucontrol, &cmipci_switch_arg_spdo2dac);
|
|
|
|
if (changed) {
|
|
|
|
if (ucontrol->value.integer.value[0]) {
|
|
|
|
if (chip->spdif_playback_avail)
|
|
|
|
snd_cmipci_set_bit(chip, CM_REG_FUNCTRL1, CM_PLAYBACK_SPDF);
|
|
|
|
} else {
|
|
|
|
if (chip->spdif_playback_avail)
|
|
|
|
snd_cmipci_clear_bit(chip, CM_REG_FUNCTRL1, CM_PLAYBACK_SPDF);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
chip->spdif_playback_enabled = ucontrol->value.integer.value[0];
|
|
|
|
return changed;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_line_in_mode_info(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_info *uinfo)
|
[ALSA] Replace pci_module_init() with pci_register_driver()
Documentation,ALS4000 driver,ATIIXP driver,ATIIXP-modem driver
AZT3328 driver,BT87x driver,CMIPCI driver,CS4281 driver
ENS1370/1+ driver,ES1938 driver,ES1968 driver,FM801 driver
Intel8x0 driver,Intel8x0-modem driver,Maestro3 driver,RME32 driver
RME96 driver,SonicVibes driver,VIA82xx driver,VIA82xx-modem driver
ALI5451 driver,au88x0 driver,CA0106 driver,CS46xx driver
EMU10K1/EMU10K2 driver,HDA Intel driver,ICE1712 driver,ICE1724 driver
KORG1212 driver,MIXART driver,NM256 driver,RME HDSP driver
RME9652 driver,Trident driver,Digigram VX222 driver,YMFPCI driver
Replace the obsolete pci_module_init() with pci_register_driver().
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2005-04-11 18:58:24 +04:00
|
|
|
{
|
2005-11-17 17:03:13 +03:00
|
|
|
struct cmipci *cm = snd_kcontrol_chip(kcontrol);
|
2011-01-10 18:28:19 +03:00
|
|
|
static const char *const texts[3] = {
|
|
|
|
"Line-In", "Rear Output", "Bass Output"
|
|
|
|
};
|
|
|
|
|
|
|
|
return snd_ctl_enum_info(uinfo, 1,
|
|
|
|
cm->chip_version >= 39 ? 3 : 2, texts);
|
[ALSA] Replace pci_module_init() with pci_register_driver()
Documentation,ALS4000 driver,ATIIXP driver,ATIIXP-modem driver
AZT3328 driver,BT87x driver,CMIPCI driver,CS4281 driver
ENS1370/1+ driver,ES1938 driver,ES1968 driver,FM801 driver
Intel8x0 driver,Intel8x0-modem driver,Maestro3 driver,RME32 driver
RME96 driver,SonicVibes driver,VIA82xx driver,VIA82xx-modem driver
ALI5451 driver,au88x0 driver,CA0106 driver,CS46xx driver
EMU10K1/EMU10K2 driver,HDA Intel driver,ICE1712 driver,ICE1724 driver
KORG1212 driver,MIXART driver,NM256 driver,RME HDSP driver
RME9652 driver,Trident driver,Digigram VX222 driver,YMFPCI driver
Replace the obsolete pci_module_init() with pci_register_driver().
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2005-04-11 18:58:24 +04:00
|
|
|
}
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static inline unsigned int get_line_in_mode(struct cmipci *cm)
|
[ALSA] Replace pci_module_init() with pci_register_driver()
Documentation,ALS4000 driver,ATIIXP driver,ATIIXP-modem driver
AZT3328 driver,BT87x driver,CMIPCI driver,CS4281 driver
ENS1370/1+ driver,ES1938 driver,ES1968 driver,FM801 driver
Intel8x0 driver,Intel8x0-modem driver,Maestro3 driver,RME32 driver
RME96 driver,SonicVibes driver,VIA82xx driver,VIA82xx-modem driver
ALI5451 driver,au88x0 driver,CA0106 driver,CS46xx driver
EMU10K1/EMU10K2 driver,HDA Intel driver,ICE1712 driver,ICE1724 driver
KORG1212 driver,MIXART driver,NM256 driver,RME HDSP driver
RME9652 driver,Trident driver,Digigram VX222 driver,YMFPCI driver
Replace the obsolete pci_module_init() with pci_register_driver().
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2005-04-11 18:58:24 +04:00
|
|
|
{
|
|
|
|
unsigned int val;
|
|
|
|
if (cm->chip_version >= 39) {
|
|
|
|
val = snd_cmipci_read(cm, CM_REG_LEGACY_CTRL);
|
2007-09-17 11:35:46 +04:00
|
|
|
if (val & (CM_CENTR2LIN | CM_BASE2LIN))
|
[ALSA] Replace pci_module_init() with pci_register_driver()
Documentation,ALS4000 driver,ATIIXP driver,ATIIXP-modem driver
AZT3328 driver,BT87x driver,CMIPCI driver,CS4281 driver
ENS1370/1+ driver,ES1938 driver,ES1968 driver,FM801 driver
Intel8x0 driver,Intel8x0-modem driver,Maestro3 driver,RME32 driver
RME96 driver,SonicVibes driver,VIA82xx driver,VIA82xx-modem driver
ALI5451 driver,au88x0 driver,CA0106 driver,CS46xx driver
EMU10K1/EMU10K2 driver,HDA Intel driver,ICE1712 driver,ICE1724 driver
KORG1212 driver,MIXART driver,NM256 driver,RME HDSP driver
RME9652 driver,Trident driver,Digigram VX222 driver,YMFPCI driver
Replace the obsolete pci_module_init() with pci_register_driver().
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2005-04-11 18:58:24 +04:00
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
val = snd_cmipci_read_b(cm, CM_REG_MIXER1);
|
2007-09-17 11:35:46 +04:00
|
|
|
if (val & CM_REAR2LIN)
|
[ALSA] Replace pci_module_init() with pci_register_driver()
Documentation,ALS4000 driver,ATIIXP driver,ATIIXP-modem driver
AZT3328 driver,BT87x driver,CMIPCI driver,CS4281 driver
ENS1370/1+ driver,ES1938 driver,ES1968 driver,FM801 driver
Intel8x0 driver,Intel8x0-modem driver,Maestro3 driver,RME32 driver
RME96 driver,SonicVibes driver,VIA82xx driver,VIA82xx-modem driver
ALI5451 driver,au88x0 driver,CA0106 driver,CS46xx driver
EMU10K1/EMU10K2 driver,HDA Intel driver,ICE1712 driver,ICE1724 driver
KORG1212 driver,MIXART driver,NM256 driver,RME HDSP driver
RME9652 driver,Trident driver,Digigram VX222 driver,YMFPCI driver
Replace the obsolete pci_module_init() with pci_register_driver().
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2005-04-11 18:58:24 +04:00
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_line_in_mode_get(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
[ALSA] Replace pci_module_init() with pci_register_driver()
Documentation,ALS4000 driver,ATIIXP driver,ATIIXP-modem driver
AZT3328 driver,BT87x driver,CMIPCI driver,CS4281 driver
ENS1370/1+ driver,ES1938 driver,ES1968 driver,FM801 driver
Intel8x0 driver,Intel8x0-modem driver,Maestro3 driver,RME32 driver
RME96 driver,SonicVibes driver,VIA82xx driver,VIA82xx-modem driver
ALI5451 driver,au88x0 driver,CA0106 driver,CS46xx driver
EMU10K1/EMU10K2 driver,HDA Intel driver,ICE1712 driver,ICE1724 driver
KORG1212 driver,MIXART driver,NM256 driver,RME HDSP driver
RME9652 driver,Trident driver,Digigram VX222 driver,YMFPCI driver
Replace the obsolete pci_module_init() with pci_register_driver().
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2005-04-11 18:58:24 +04:00
|
|
|
{
|
2005-11-17 17:03:13 +03:00
|
|
|
struct cmipci *cm = snd_kcontrol_chip(kcontrol);
|
[ALSA] Replace pci_module_init() with pci_register_driver()
Documentation,ALS4000 driver,ATIIXP driver,ATIIXP-modem driver
AZT3328 driver,BT87x driver,CMIPCI driver,CS4281 driver
ENS1370/1+ driver,ES1938 driver,ES1968 driver,FM801 driver
Intel8x0 driver,Intel8x0-modem driver,Maestro3 driver,RME32 driver
RME96 driver,SonicVibes driver,VIA82xx driver,VIA82xx-modem driver
ALI5451 driver,au88x0 driver,CA0106 driver,CS46xx driver
EMU10K1/EMU10K2 driver,HDA Intel driver,ICE1712 driver,ICE1724 driver
KORG1212 driver,MIXART driver,NM256 driver,RME HDSP driver
RME9652 driver,Trident driver,Digigram VX222 driver,YMFPCI driver
Replace the obsolete pci_module_init() with pci_register_driver().
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2005-04-11 18:58:24 +04:00
|
|
|
|
|
|
|
spin_lock_irq(&cm->reg_lock);
|
|
|
|
ucontrol->value.enumerated.item[0] = get_line_in_mode(cm);
|
|
|
|
spin_unlock_irq(&cm->reg_lock);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_line_in_mode_put(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
[ALSA] Replace pci_module_init() with pci_register_driver()
Documentation,ALS4000 driver,ATIIXP driver,ATIIXP-modem driver
AZT3328 driver,BT87x driver,CMIPCI driver,CS4281 driver
ENS1370/1+ driver,ES1938 driver,ES1968 driver,FM801 driver
Intel8x0 driver,Intel8x0-modem driver,Maestro3 driver,RME32 driver
RME96 driver,SonicVibes driver,VIA82xx driver,VIA82xx-modem driver
ALI5451 driver,au88x0 driver,CA0106 driver,CS46xx driver
EMU10K1/EMU10K2 driver,HDA Intel driver,ICE1712 driver,ICE1724 driver
KORG1212 driver,MIXART driver,NM256 driver,RME HDSP driver
RME9652 driver,Trident driver,Digigram VX222 driver,YMFPCI driver
Replace the obsolete pci_module_init() with pci_register_driver().
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2005-04-11 18:58:24 +04:00
|
|
|
{
|
2005-11-17 17:03:13 +03:00
|
|
|
struct cmipci *cm = snd_kcontrol_chip(kcontrol);
|
[ALSA] Replace pci_module_init() with pci_register_driver()
Documentation,ALS4000 driver,ATIIXP driver,ATIIXP-modem driver
AZT3328 driver,BT87x driver,CMIPCI driver,CS4281 driver
ENS1370/1+ driver,ES1938 driver,ES1968 driver,FM801 driver
Intel8x0 driver,Intel8x0-modem driver,Maestro3 driver,RME32 driver
RME96 driver,SonicVibes driver,VIA82xx driver,VIA82xx-modem driver
ALI5451 driver,au88x0 driver,CA0106 driver,CS46xx driver
EMU10K1/EMU10K2 driver,HDA Intel driver,ICE1712 driver,ICE1724 driver
KORG1212 driver,MIXART driver,NM256 driver,RME HDSP driver
RME9652 driver,Trident driver,Digigram VX222 driver,YMFPCI driver
Replace the obsolete pci_module_init() with pci_register_driver().
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2005-04-11 18:58:24 +04:00
|
|
|
int change;
|
|
|
|
|
|
|
|
spin_lock_irq(&cm->reg_lock);
|
|
|
|
if (ucontrol->value.enumerated.item[0] == 2)
|
2007-09-17 11:35:46 +04:00
|
|
|
change = snd_cmipci_set_bit(cm, CM_REG_LEGACY_CTRL, CM_CENTR2LIN | CM_BASE2LIN);
|
[ALSA] Replace pci_module_init() with pci_register_driver()
Documentation,ALS4000 driver,ATIIXP driver,ATIIXP-modem driver
AZT3328 driver,BT87x driver,CMIPCI driver,CS4281 driver
ENS1370/1+ driver,ES1938 driver,ES1968 driver,FM801 driver
Intel8x0 driver,Intel8x0-modem driver,Maestro3 driver,RME32 driver
RME96 driver,SonicVibes driver,VIA82xx driver,VIA82xx-modem driver
ALI5451 driver,au88x0 driver,CA0106 driver,CS46xx driver
EMU10K1/EMU10K2 driver,HDA Intel driver,ICE1712 driver,ICE1724 driver
KORG1212 driver,MIXART driver,NM256 driver,RME HDSP driver
RME9652 driver,Trident driver,Digigram VX222 driver,YMFPCI driver
Replace the obsolete pci_module_init() with pci_register_driver().
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2005-04-11 18:58:24 +04:00
|
|
|
else
|
2007-09-17 11:35:46 +04:00
|
|
|
change = snd_cmipci_clear_bit(cm, CM_REG_LEGACY_CTRL, CM_CENTR2LIN | CM_BASE2LIN);
|
[ALSA] Replace pci_module_init() with pci_register_driver()
Documentation,ALS4000 driver,ATIIXP driver,ATIIXP-modem driver
AZT3328 driver,BT87x driver,CMIPCI driver,CS4281 driver
ENS1370/1+ driver,ES1938 driver,ES1968 driver,FM801 driver
Intel8x0 driver,Intel8x0-modem driver,Maestro3 driver,RME32 driver
RME96 driver,SonicVibes driver,VIA82xx driver,VIA82xx-modem driver
ALI5451 driver,au88x0 driver,CA0106 driver,CS46xx driver
EMU10K1/EMU10K2 driver,HDA Intel driver,ICE1712 driver,ICE1724 driver
KORG1212 driver,MIXART driver,NM256 driver,RME HDSP driver
RME9652 driver,Trident driver,Digigram VX222 driver,YMFPCI driver
Replace the obsolete pci_module_init() with pci_register_driver().
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2005-04-11 18:58:24 +04:00
|
|
|
if (ucontrol->value.enumerated.item[0] == 1)
|
2007-09-17 11:35:46 +04:00
|
|
|
change |= snd_cmipci_set_bit_b(cm, CM_REG_MIXER1, CM_REAR2LIN);
|
[ALSA] Replace pci_module_init() with pci_register_driver()
Documentation,ALS4000 driver,ATIIXP driver,ATIIXP-modem driver
AZT3328 driver,BT87x driver,CMIPCI driver,CS4281 driver
ENS1370/1+ driver,ES1938 driver,ES1968 driver,FM801 driver
Intel8x0 driver,Intel8x0-modem driver,Maestro3 driver,RME32 driver
RME96 driver,SonicVibes driver,VIA82xx driver,VIA82xx-modem driver
ALI5451 driver,au88x0 driver,CA0106 driver,CS46xx driver
EMU10K1/EMU10K2 driver,HDA Intel driver,ICE1712 driver,ICE1724 driver
KORG1212 driver,MIXART driver,NM256 driver,RME HDSP driver
RME9652 driver,Trident driver,Digigram VX222 driver,YMFPCI driver
Replace the obsolete pci_module_init() with pci_register_driver().
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2005-04-11 18:58:24 +04:00
|
|
|
else
|
2007-09-17 11:35:46 +04:00
|
|
|
change |= snd_cmipci_clear_bit_b(cm, CM_REG_MIXER1, CM_REAR2LIN);
|
[ALSA] Replace pci_module_init() with pci_register_driver()
Documentation,ALS4000 driver,ATIIXP driver,ATIIXP-modem driver
AZT3328 driver,BT87x driver,CMIPCI driver,CS4281 driver
ENS1370/1+ driver,ES1938 driver,ES1968 driver,FM801 driver
Intel8x0 driver,Intel8x0-modem driver,Maestro3 driver,RME32 driver
RME96 driver,SonicVibes driver,VIA82xx driver,VIA82xx-modem driver
ALI5451 driver,au88x0 driver,CA0106 driver,CS46xx driver
EMU10K1/EMU10K2 driver,HDA Intel driver,ICE1712 driver,ICE1724 driver
KORG1212 driver,MIXART driver,NM256 driver,RME HDSP driver
RME9652 driver,Trident driver,Digigram VX222 driver,YMFPCI driver
Replace the obsolete pci_module_init() with pci_register_driver().
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2005-04-11 18:58:24 +04:00
|
|
|
spin_unlock_irq(&cm->reg_lock);
|
|
|
|
return change;
|
|
|
|
}
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_mic_in_mode_info(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_info *uinfo)
|
[ALSA] Replace pci_module_init() with pci_register_driver()
Documentation,ALS4000 driver,ATIIXP driver,ATIIXP-modem driver
AZT3328 driver,BT87x driver,CMIPCI driver,CS4281 driver
ENS1370/1+ driver,ES1938 driver,ES1968 driver,FM801 driver
Intel8x0 driver,Intel8x0-modem driver,Maestro3 driver,RME32 driver
RME96 driver,SonicVibes driver,VIA82xx driver,VIA82xx-modem driver
ALI5451 driver,au88x0 driver,CA0106 driver,CS46xx driver
EMU10K1/EMU10K2 driver,HDA Intel driver,ICE1712 driver,ICE1724 driver
KORG1212 driver,MIXART driver,NM256 driver,RME HDSP driver
RME9652 driver,Trident driver,Digigram VX222 driver,YMFPCI driver
Replace the obsolete pci_module_init() with pci_register_driver().
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2005-04-11 18:58:24 +04:00
|
|
|
{
|
2011-01-10 18:28:19 +03:00
|
|
|
static const char *const texts[2] = { "Mic-In", "Center/LFE Output" };
|
|
|
|
|
|
|
|
return snd_ctl_enum_info(uinfo, 1, 2, texts);
|
[ALSA] Replace pci_module_init() with pci_register_driver()
Documentation,ALS4000 driver,ATIIXP driver,ATIIXP-modem driver
AZT3328 driver,BT87x driver,CMIPCI driver,CS4281 driver
ENS1370/1+ driver,ES1938 driver,ES1968 driver,FM801 driver
Intel8x0 driver,Intel8x0-modem driver,Maestro3 driver,RME32 driver
RME96 driver,SonicVibes driver,VIA82xx driver,VIA82xx-modem driver
ALI5451 driver,au88x0 driver,CA0106 driver,CS46xx driver
EMU10K1/EMU10K2 driver,HDA Intel driver,ICE1712 driver,ICE1724 driver
KORG1212 driver,MIXART driver,NM256 driver,RME HDSP driver
RME9652 driver,Trident driver,Digigram VX222 driver,YMFPCI driver
Replace the obsolete pci_module_init() with pci_register_driver().
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2005-04-11 18:58:24 +04:00
|
|
|
}
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_mic_in_mode_get(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
[ALSA] Replace pci_module_init() with pci_register_driver()
Documentation,ALS4000 driver,ATIIXP driver,ATIIXP-modem driver
AZT3328 driver,BT87x driver,CMIPCI driver,CS4281 driver
ENS1370/1+ driver,ES1938 driver,ES1968 driver,FM801 driver
Intel8x0 driver,Intel8x0-modem driver,Maestro3 driver,RME32 driver
RME96 driver,SonicVibes driver,VIA82xx driver,VIA82xx-modem driver
ALI5451 driver,au88x0 driver,CA0106 driver,CS46xx driver
EMU10K1/EMU10K2 driver,HDA Intel driver,ICE1712 driver,ICE1724 driver
KORG1212 driver,MIXART driver,NM256 driver,RME HDSP driver
RME9652 driver,Trident driver,Digigram VX222 driver,YMFPCI driver
Replace the obsolete pci_module_init() with pci_register_driver().
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2005-04-11 18:58:24 +04:00
|
|
|
{
|
2005-11-17 17:03:13 +03:00
|
|
|
struct cmipci *cm = snd_kcontrol_chip(kcontrol);
|
[ALSA] Replace pci_module_init() with pci_register_driver()
Documentation,ALS4000 driver,ATIIXP driver,ATIIXP-modem driver
AZT3328 driver,BT87x driver,CMIPCI driver,CS4281 driver
ENS1370/1+ driver,ES1938 driver,ES1968 driver,FM801 driver
Intel8x0 driver,Intel8x0-modem driver,Maestro3 driver,RME32 driver
RME96 driver,SonicVibes driver,VIA82xx driver,VIA82xx-modem driver
ALI5451 driver,au88x0 driver,CA0106 driver,CS46xx driver
EMU10K1/EMU10K2 driver,HDA Intel driver,ICE1712 driver,ICE1724 driver
KORG1212 driver,MIXART driver,NM256 driver,RME HDSP driver
RME9652 driver,Trident driver,Digigram VX222 driver,YMFPCI driver
Replace the obsolete pci_module_init() with pci_register_driver().
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2005-04-11 18:58:24 +04:00
|
|
|
/* same bit as spdi_phase */
|
|
|
|
spin_lock_irq(&cm->reg_lock);
|
|
|
|
ucontrol->value.enumerated.item[0] =
|
|
|
|
(snd_cmipci_read_b(cm, CM_REG_MISC) & CM_SPDIF_INVERSE) ? 1 : 0;
|
|
|
|
spin_unlock_irq(&cm->reg_lock);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static int snd_cmipci_mic_in_mode_put(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
[ALSA] Replace pci_module_init() with pci_register_driver()
Documentation,ALS4000 driver,ATIIXP driver,ATIIXP-modem driver
AZT3328 driver,BT87x driver,CMIPCI driver,CS4281 driver
ENS1370/1+ driver,ES1938 driver,ES1968 driver,FM801 driver
Intel8x0 driver,Intel8x0-modem driver,Maestro3 driver,RME32 driver
RME96 driver,SonicVibes driver,VIA82xx driver,VIA82xx-modem driver
ALI5451 driver,au88x0 driver,CA0106 driver,CS46xx driver
EMU10K1/EMU10K2 driver,HDA Intel driver,ICE1712 driver,ICE1724 driver
KORG1212 driver,MIXART driver,NM256 driver,RME HDSP driver
RME9652 driver,Trident driver,Digigram VX222 driver,YMFPCI driver
Replace the obsolete pci_module_init() with pci_register_driver().
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2005-04-11 18:58:24 +04:00
|
|
|
{
|
2005-11-17 17:03:13 +03:00
|
|
|
struct cmipci *cm = snd_kcontrol_chip(kcontrol);
|
[ALSA] Replace pci_module_init() with pci_register_driver()
Documentation,ALS4000 driver,ATIIXP driver,ATIIXP-modem driver
AZT3328 driver,BT87x driver,CMIPCI driver,CS4281 driver
ENS1370/1+ driver,ES1938 driver,ES1968 driver,FM801 driver
Intel8x0 driver,Intel8x0-modem driver,Maestro3 driver,RME32 driver
RME96 driver,SonicVibes driver,VIA82xx driver,VIA82xx-modem driver
ALI5451 driver,au88x0 driver,CA0106 driver,CS46xx driver
EMU10K1/EMU10K2 driver,HDA Intel driver,ICE1712 driver,ICE1724 driver
KORG1212 driver,MIXART driver,NM256 driver,RME HDSP driver
RME9652 driver,Trident driver,Digigram VX222 driver,YMFPCI driver
Replace the obsolete pci_module_init() with pci_register_driver().
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2005-04-11 18:58:24 +04:00
|
|
|
int change;
|
|
|
|
|
|
|
|
spin_lock_irq(&cm->reg_lock);
|
|
|
|
if (ucontrol->value.enumerated.item[0])
|
|
|
|
change = snd_cmipci_set_bit_b(cm, CM_REG_MISC, CM_SPDIF_INVERSE);
|
|
|
|
else
|
|
|
|
change = snd_cmipci_clear_bit_b(cm, CM_REG_MISC, CM_SPDIF_INVERSE);
|
|
|
|
spin_unlock_irq(&cm->reg_lock);
|
|
|
|
return change;
|
|
|
|
}
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/* both for CM8338/8738 */
|
2020-01-03 11:16:53 +03:00
|
|
|
static const struct snd_kcontrol_new snd_cmipci_mixer_switches[] = {
|
2005-04-17 02:20:36 +04:00
|
|
|
DEFINE_MIXER_SWITCH("Four Channel Mode", fourch),
|
[ALSA] Replace pci_module_init() with pci_register_driver()
Documentation,ALS4000 driver,ATIIXP driver,ATIIXP-modem driver
AZT3328 driver,BT87x driver,CMIPCI driver,CS4281 driver
ENS1370/1+ driver,ES1938 driver,ES1968 driver,FM801 driver
Intel8x0 driver,Intel8x0-modem driver,Maestro3 driver,RME32 driver
RME96 driver,SonicVibes driver,VIA82xx driver,VIA82xx-modem driver
ALI5451 driver,au88x0 driver,CA0106 driver,CS46xx driver
EMU10K1/EMU10K2 driver,HDA Intel driver,ICE1712 driver,ICE1724 driver
KORG1212 driver,MIXART driver,NM256 driver,RME HDSP driver
RME9652 driver,Trident driver,Digigram VX222 driver,YMFPCI driver
Replace the obsolete pci_module_init() with pci_register_driver().
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2005-04-11 18:58:24 +04:00
|
|
|
{
|
|
|
|
.name = "Line-In Mode",
|
|
|
|
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
|
|
|
|
.info = snd_cmipci_line_in_mode_info,
|
|
|
|
.get = snd_cmipci_line_in_mode_get,
|
|
|
|
.put = snd_cmipci_line_in_mode_put,
|
|
|
|
},
|
2005-04-17 02:20:36 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/* for non-multichannel chips */
|
2020-01-03 11:16:53 +03:00
|
|
|
static const struct snd_kcontrol_new snd_cmipci_nomulti_switch =
|
2005-04-17 02:20:36 +04:00
|
|
|
DEFINE_MIXER_SWITCH("Exchange DAC", exchange_dac);
|
|
|
|
|
|
|
|
/* only for CM8738 */
|
2020-01-03 11:16:53 +03:00
|
|
|
static const struct snd_kcontrol_new snd_cmipci_8738_mixer_switches[] = {
|
2005-04-17 02:20:36 +04:00
|
|
|
#if 0 /* controlled in pcm device */
|
|
|
|
DEFINE_MIXER_SWITCH("IEC958 In Record", spdif_in),
|
|
|
|
DEFINE_MIXER_SWITCH("IEC958 Out", spdif_out),
|
|
|
|
DEFINE_MIXER_SWITCH("IEC958 Out To DAC", spdo2dac),
|
|
|
|
#endif
|
|
|
|
// DEFINE_MIXER_SWITCH("IEC958 Output Switch", spdif_enable),
|
|
|
|
{ .name = "IEC958 Output Switch",
|
|
|
|
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
|
|
|
|
.info = snd_cmipci_uswitch_info,
|
|
|
|
.get = snd_cmipci_spdout_enable_get,
|
|
|
|
.put = snd_cmipci_spdout_enable_put,
|
|
|
|
},
|
|
|
|
DEFINE_MIXER_SWITCH("IEC958 In Valid", spdi_valid),
|
|
|
|
DEFINE_MIXER_SWITCH("IEC958 Copyright", spdif_copyright),
|
|
|
|
DEFINE_MIXER_SWITCH("IEC958 5V", spdo_5v),
|
|
|
|
// DEFINE_MIXER_SWITCH("IEC958 In/Out 48KHz", spdo_48k),
|
|
|
|
DEFINE_MIXER_SWITCH("IEC958 Loop", spdif_loop),
|
|
|
|
DEFINE_MIXER_SWITCH("IEC958 In Monitor", spdi_monitor),
|
|
|
|
};
|
|
|
|
|
|
|
|
/* only for model 033/037 */
|
2020-01-03 11:16:53 +03:00
|
|
|
static const struct snd_kcontrol_new snd_cmipci_old_mixer_switches[] = {
|
2005-04-17 02:20:36 +04:00
|
|
|
DEFINE_MIXER_SWITCH("IEC958 Mix Analog", spdif_dac_out),
|
|
|
|
DEFINE_MIXER_SWITCH("IEC958 In Phase Inverse", spdi_phase),
|
|
|
|
DEFINE_MIXER_SWITCH("IEC958 In Select", spdif_in_sel1),
|
|
|
|
};
|
|
|
|
|
|
|
|
/* only for model 039 or later */
|
2020-01-03 11:16:53 +03:00
|
|
|
static const struct snd_kcontrol_new snd_cmipci_extra_mixer_switches[] = {
|
2005-04-17 02:20:36 +04:00
|
|
|
DEFINE_MIXER_SWITCH("IEC958 In Select", spdif_in_sel2),
|
|
|
|
DEFINE_MIXER_SWITCH("IEC958 In Phase Inverse", spdi_phase2),
|
[ALSA] Replace pci_module_init() with pci_register_driver()
Documentation,ALS4000 driver,ATIIXP driver,ATIIXP-modem driver
AZT3328 driver,BT87x driver,CMIPCI driver,CS4281 driver
ENS1370/1+ driver,ES1938 driver,ES1968 driver,FM801 driver
Intel8x0 driver,Intel8x0-modem driver,Maestro3 driver,RME32 driver
RME96 driver,SonicVibes driver,VIA82xx driver,VIA82xx-modem driver
ALI5451 driver,au88x0 driver,CA0106 driver,CS46xx driver
EMU10K1/EMU10K2 driver,HDA Intel driver,ICE1712 driver,ICE1724 driver
KORG1212 driver,MIXART driver,NM256 driver,RME HDSP driver
RME9652 driver,Trident driver,Digigram VX222 driver,YMFPCI driver
Replace the obsolete pci_module_init() with pci_register_driver().
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2005-04-11 18:58:24 +04:00
|
|
|
{
|
|
|
|
.name = "Mic-In Mode",
|
|
|
|
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
|
|
|
|
.info = snd_cmipci_mic_in_mode_info,
|
|
|
|
.get = snd_cmipci_mic_in_mode_get,
|
|
|
|
.put = snd_cmipci_mic_in_mode_put,
|
|
|
|
}
|
2005-04-17 02:20:36 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/* card control switches */
|
2020-01-03 11:16:53 +03:00
|
|
|
static const struct snd_kcontrol_new snd_cmipci_modem_switch =
|
2007-12-10 14:28:52 +03:00
|
|
|
DEFINE_CARD_SWITCH("Modem", modem);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
|
2012-12-06 21:35:10 +04:00
|
|
|
static int snd_cmipci_mixer_new(struct cmipci *cm, int pcm_spdif_device)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2005-11-17 17:03:13 +03:00
|
|
|
struct snd_card *card;
|
2020-01-03 11:16:53 +03:00
|
|
|
const struct snd_kcontrol_new *sw;
|
2005-11-17 17:03:13 +03:00
|
|
|
struct snd_kcontrol *kctl;
|
2005-04-17 02:20:36 +04:00
|
|
|
unsigned int idx;
|
|
|
|
int err;
|
|
|
|
|
2008-08-08 19:12:14 +04:00
|
|
|
if (snd_BUG_ON(!cm || !cm->card))
|
|
|
|
return -EINVAL;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
card = cm->card;
|
|
|
|
|
|
|
|
strcpy(card->mixername, "CMedia PCI");
|
|
|
|
|
|
|
|
spin_lock_irq(&cm->reg_lock);
|
|
|
|
snd_cmipci_mixer_write(cm, 0x00, 0x00); /* mixer reset */
|
|
|
|
spin_unlock_irq(&cm->reg_lock);
|
|
|
|
|
|
|
|
for (idx = 0; idx < ARRAY_SIZE(snd_cmipci_mixers); idx++) {
|
|
|
|
if (cm->chip_version == 68) { // 8768 has no PCM volume
|
|
|
|
if (!strcmp(snd_cmipci_mixers[idx].name,
|
|
|
|
"PCM Playback Volume"))
|
|
|
|
continue;
|
|
|
|
}
|
2021-06-08 17:04:56 +03:00
|
|
|
err = snd_ctl_add(card, snd_ctl_new1(&snd_cmipci_mixers[idx], cm));
|
|
|
|
if (err < 0)
|
2005-04-17 02:20:36 +04:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* mixer switches */
|
|
|
|
sw = snd_cmipci_mixer_switches;
|
|
|
|
for (idx = 0; idx < ARRAY_SIZE(snd_cmipci_mixer_switches); idx++, sw++) {
|
|
|
|
err = snd_ctl_add(cm->card, snd_ctl_new1(sw, cm));
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
if (! cm->can_multi_ch) {
|
|
|
|
err = snd_ctl_add(cm->card, snd_ctl_new1(&snd_cmipci_nomulti_switch, cm));
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
if (cm->device == PCI_DEVICE_ID_CMEDIA_CM8738 ||
|
|
|
|
cm->device == PCI_DEVICE_ID_CMEDIA_CM8738B) {
|
|
|
|
sw = snd_cmipci_8738_mixer_switches;
|
|
|
|
for (idx = 0; idx < ARRAY_SIZE(snd_cmipci_8738_mixer_switches); idx++, sw++) {
|
|
|
|
err = snd_ctl_add(cm->card, snd_ctl_new1(sw, cm));
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
if (cm->can_ac3_hw) {
|
2021-06-08 17:04:56 +03:00
|
|
|
kctl = snd_ctl_new1(&snd_cmipci_spdif_default, cm);
|
|
|
|
err = snd_ctl_add(card, kctl);
|
|
|
|
if (err < 0)
|
2005-04-17 02:20:36 +04:00
|
|
|
return err;
|
|
|
|
kctl->id.device = pcm_spdif_device;
|
2021-06-08 17:04:56 +03:00
|
|
|
kctl = snd_ctl_new1(&snd_cmipci_spdif_mask, cm);
|
|
|
|
err = snd_ctl_add(card, kctl);
|
|
|
|
if (err < 0)
|
2005-04-17 02:20:36 +04:00
|
|
|
return err;
|
|
|
|
kctl->id.device = pcm_spdif_device;
|
2021-06-08 17:04:56 +03:00
|
|
|
kctl = snd_ctl_new1(&snd_cmipci_spdif_stream, cm);
|
|
|
|
err = snd_ctl_add(card, kctl);
|
|
|
|
if (err < 0)
|
2005-04-17 02:20:36 +04:00
|
|
|
return err;
|
|
|
|
kctl->id.device = pcm_spdif_device;
|
|
|
|
}
|
|
|
|
if (cm->chip_version <= 37) {
|
|
|
|
sw = snd_cmipci_old_mixer_switches;
|
|
|
|
for (idx = 0; idx < ARRAY_SIZE(snd_cmipci_old_mixer_switches); idx++, sw++) {
|
|
|
|
err = snd_ctl_add(cm->card, snd_ctl_new1(sw, cm));
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (cm->chip_version >= 39) {
|
|
|
|
sw = snd_cmipci_extra_mixer_switches;
|
|
|
|
for (idx = 0; idx < ARRAY_SIZE(snd_cmipci_extra_mixer_switches); idx++, sw++) {
|
|
|
|
err = snd_ctl_add(cm->card, snd_ctl_new1(sw, cm));
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* card switches */
|
2007-12-11 10:55:16 +03:00
|
|
|
/*
|
|
|
|
* newer chips don't have the register bits to force modem link
|
|
|
|
* detection; the bit that was FLINKON now mutes CH1
|
|
|
|
*/
|
2007-12-10 14:28:52 +03:00
|
|
|
if (cm->chip_version < 39) {
|
|
|
|
err = snd_ctl_add(cm->card,
|
|
|
|
snd_ctl_new1(&snd_cmipci_modem_switch, cm));
|
2005-04-17 02:20:36 +04:00
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (idx = 0; idx < CM_SAVED_MIXERS; idx++) {
|
2008-02-28 13:52:17 +03:00
|
|
|
struct snd_ctl_elem_id elem_id;
|
2005-11-17 17:03:13 +03:00
|
|
|
struct snd_kcontrol *ctl;
|
2008-02-28 13:52:17 +03:00
|
|
|
memset(&elem_id, 0, sizeof(elem_id));
|
|
|
|
elem_id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
|
|
|
|
strcpy(elem_id.name, cm_saved_mixer[idx].name);
|
|
|
|
ctl = snd_ctl_find_id(cm->card, &elem_id);
|
|
|
|
if (ctl)
|
2005-04-17 02:20:36 +04:00
|
|
|
cm->mixer_res_ctl[idx] = ctl;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* proc interface
|
|
|
|
*/
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static void snd_cmipci_proc_read(struct snd_info_entry *entry,
|
|
|
|
struct snd_info_buffer *buffer)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2005-11-17 17:03:13 +03:00
|
|
|
struct cmipci *cm = entry->private_data;
|
2007-09-17 11:36:16 +04:00
|
|
|
int i, v;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2007-09-17 11:36:16 +04:00
|
|
|
snd_iprintf(buffer, "%s\n", cm->card->longname);
|
|
|
|
for (i = 0; i < 0x94; i++) {
|
|
|
|
if (i == 0x28)
|
|
|
|
i = 0x90;
|
|
|
|
v = inb(cm->iobase + i);
|
2005-04-17 02:20:36 +04:00
|
|
|
if (i % 4 == 0)
|
2007-09-17 11:36:16 +04:00
|
|
|
snd_iprintf(buffer, "\n%02x:", i);
|
|
|
|
snd_iprintf(buffer, " %02x", v);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
2007-09-17 11:36:16 +04:00
|
|
|
snd_iprintf(buffer, "\n");
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
2012-12-06 21:35:10 +04:00
|
|
|
static void snd_cmipci_proc_init(struct cmipci *cm)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2019-02-04 18:01:39 +03:00
|
|
|
snd_card_ro_proc_new(cm->card, "cmipci", cm, snd_cmipci_proc_read);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
2014-08-08 17:56:03 +04:00
|
|
|
static const struct pci_device_id snd_cmipci_ids[] = {
|
2009-06-25 09:13:35 +04:00
|
|
|
{PCI_VDEVICE(CMEDIA, PCI_DEVICE_ID_CMEDIA_CM8338A), 0},
|
|
|
|
{PCI_VDEVICE(CMEDIA, PCI_DEVICE_ID_CMEDIA_CM8338B), 0},
|
|
|
|
{PCI_VDEVICE(CMEDIA, PCI_DEVICE_ID_CMEDIA_CM8738), 0},
|
|
|
|
{PCI_VDEVICE(CMEDIA, PCI_DEVICE_ID_CMEDIA_CM8738B), 0},
|
|
|
|
{PCI_VDEVICE(AL, PCI_DEVICE_ID_CMEDIA_CM8738), 0},
|
2005-04-17 02:20:36 +04:00
|
|
|
{0,},
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* check chip version and capabilities
|
|
|
|
* driver name is modified according to the chip model
|
|
|
|
*/
|
2012-12-06 21:35:10 +04:00
|
|
|
static void query_chip(struct cmipci *cm)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
unsigned int detect;
|
|
|
|
|
|
|
|
/* check reg 0Ch, bit 24-31 */
|
|
|
|
detect = snd_cmipci_read(cm, CM_REG_INT_HLDCLR) & CM_CHIP_MASK2;
|
|
|
|
if (! detect) {
|
|
|
|
/* check reg 08h, bit 24-28 */
|
|
|
|
detect = snd_cmipci_read(cm, CM_REG_CHFORMAT) & CM_CHIP_MASK1;
|
2007-08-27 11:20:31 +04:00
|
|
|
switch (detect) {
|
|
|
|
case 0:
|
2005-04-17 02:20:36 +04:00
|
|
|
cm->chip_version = 33;
|
|
|
|
if (cm->do_soft_ac3)
|
|
|
|
cm->can_ac3_sw = 1;
|
|
|
|
else
|
|
|
|
cm->can_ac3_hw = 1;
|
2007-08-27 11:20:31 +04:00
|
|
|
break;
|
2007-09-17 11:34:59 +04:00
|
|
|
case CM_CHIP_037:
|
2005-04-17 02:20:36 +04:00
|
|
|
cm->chip_version = 37;
|
|
|
|
cm->can_ac3_hw = 1;
|
2007-08-27 11:20:31 +04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
cm->chip_version = 39;
|
|
|
|
cm->can_ac3_hw = 1;
|
|
|
|
break;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
2007-08-27 11:20:31 +04:00
|
|
|
cm->max_channels = 2;
|
2005-04-17 02:20:36 +04:00
|
|
|
} else {
|
2007-08-27 11:20:31 +04:00
|
|
|
if (detect & CM_CHIP_039) {
|
2005-04-17 02:20:36 +04:00
|
|
|
cm->chip_version = 39;
|
|
|
|
if (detect & CM_CHIP_039_6CH) /* 4 or 6 channels */
|
|
|
|
cm->max_channels = 6;
|
|
|
|
else
|
|
|
|
cm->max_channels = 4;
|
2007-08-27 11:20:31 +04:00
|
|
|
} else if (detect & CM_CHIP_8768) {
|
|
|
|
cm->chip_version = 68;
|
|
|
|
cm->max_channels = 8;
|
2007-10-31 19:36:20 +03:00
|
|
|
cm->can_96k = 1;
|
2005-04-17 02:20:36 +04:00
|
|
|
} else {
|
2007-08-27 11:20:31 +04:00
|
|
|
cm->chip_version = 55;
|
|
|
|
cm->max_channels = 6;
|
2007-10-31 19:36:20 +03:00
|
|
|
cm->can_96k = 1;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
2007-08-27 11:20:31 +04:00
|
|
|
cm->can_ac3_hw = 1;
|
|
|
|
cm->can_multi_ch = 1;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef SUPPORT_JOYSTICK
|
2012-12-06 21:35:10 +04:00
|
|
|
static int snd_cmipci_create_gameport(struct cmipci *cm, int dev)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2020-01-05 17:47:51 +03:00
|
|
|
static const int ports[] = { 0x201, 0x200, 0 }; /* FIXME: majority is 0x201? */
|
2005-04-17 02:20:36 +04:00
|
|
|
struct gameport *gp;
|
|
|
|
struct resource *r = NULL;
|
|
|
|
int i, io_port = 0;
|
|
|
|
|
|
|
|
if (joystick_port[dev] == 0)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
if (joystick_port[dev] == 1) { /* auto-detect */
|
|
|
|
for (i = 0; ports[i]; i++) {
|
|
|
|
io_port = ports[i];
|
2021-07-15 10:58:35 +03:00
|
|
|
r = devm_request_region(&cm->pci->dev, io_port, 1,
|
|
|
|
"CMIPCI gameport");
|
2005-04-17 02:20:36 +04:00
|
|
|
if (r)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
io_port = joystick_port[dev];
|
2021-07-15 10:58:35 +03:00
|
|
|
r = devm_request_region(&cm->pci->dev, io_port, 1,
|
|
|
|
"CMIPCI gameport");
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!r) {
|
2014-02-25 15:39:30 +04:00
|
|
|
dev_warn(cm->card->dev, "cannot reserve joystick ports\n");
|
2005-04-17 02:20:36 +04:00
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
|
|
|
|
cm->gameport = gp = gameport_allocate_port();
|
|
|
|
if (!gp) {
|
2014-02-25 15:39:30 +04:00
|
|
|
dev_err(cm->card->dev, "cannot allocate memory for gameport\n");
|
2005-04-17 02:20:36 +04:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
gameport_set_name(gp, "C-Media Gameport");
|
|
|
|
gameport_set_phys(gp, "pci%s/gameport0", pci_name(cm->pci));
|
|
|
|
gameport_set_dev_parent(gp, &cm->pci->dev);
|
|
|
|
gp->io = io_port;
|
|
|
|
|
|
|
|
snd_cmipci_set_bit(cm, CM_REG_FUNCTRL1, CM_JYSTK_EN);
|
|
|
|
|
|
|
|
gameport_register_port(cm->gameport);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 17:03:13 +03:00
|
|
|
static void snd_cmipci_free_gameport(struct cmipci *cm)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
if (cm->gameport) {
|
|
|
|
gameport_unregister_port(cm->gameport);
|
|
|
|
cm->gameport = NULL;
|
|
|
|
|
|
|
|
snd_cmipci_clear_bit(cm, CM_REG_FUNCTRL1, CM_JYSTK_EN);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
2005-11-17 17:03:13 +03:00
|
|
|
static inline int snd_cmipci_create_gameport(struct cmipci *cm, int dev) { return -ENOSYS; }
|
|
|
|
static inline void snd_cmipci_free_gameport(struct cmipci *cm) { }
|
2005-04-17 02:20:36 +04:00
|
|
|
#endif
|
|
|
|
|
2021-07-15 10:58:35 +03:00
|
|
|
static void snd_cmipci_free(struct snd_card *card)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2021-07-15 10:58:35 +03:00
|
|
|
struct cmipci *cm = card->private_data;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2021-07-15 10:58:35 +03:00
|
|
|
snd_cmipci_clear_bit(cm, CM_REG_MISC_CTRL, CM_FM_EN);
|
|
|
|
snd_cmipci_clear_bit(cm, CM_REG_LEGACY_CTRL, CM_ENSPDOUT);
|
|
|
|
snd_cmipci_write(cm, CM_REG_INT_HLDCLR, 0); /* disable ints */
|
|
|
|
snd_cmipci_ch_reset(cm, CM_CH_PLAY);
|
|
|
|
snd_cmipci_ch_reset(cm, CM_CH_CAPT);
|
|
|
|
snd_cmipci_write(cm, CM_REG_FUNCTRL0, 0); /* disable channels */
|
|
|
|
snd_cmipci_write(cm, CM_REG_FUNCTRL1, 0);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2021-07-15 10:58:35 +03:00
|
|
|
/* reset mixer */
|
|
|
|
snd_cmipci_mixer_write(cm, 0, 0);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
snd_cmipci_free_gameport(cm);
|
|
|
|
}
|
|
|
|
|
2012-12-06 21:35:10 +04:00
|
|
|
static int snd_cmipci_create_fm(struct cmipci *cm, long fm_port)
|
2005-09-14 10:33:46 +04:00
|
|
|
{
|
|
|
|
long iosynth;
|
|
|
|
unsigned int val;
|
2005-11-17 17:03:13 +03:00
|
|
|
struct snd_opl3 *opl3;
|
2005-09-14 10:33:46 +04:00
|
|
|
int err;
|
|
|
|
|
2007-02-15 20:56:43 +03:00
|
|
|
if (!fm_port)
|
|
|
|
goto disable_fm;
|
|
|
|
|
2007-09-03 11:55:49 +04:00
|
|
|
if (cm->chip_version >= 39) {
|
2007-08-22 11:45:03 +04:00
|
|
|
/* first try FM regs in PCI port range */
|
|
|
|
iosynth = cm->iobase + CM_REG_FM_PCI;
|
|
|
|
err = snd_opl3_create(cm->card, iosynth, iosynth + 2,
|
|
|
|
OPL3_HW_OPL3, 1, &opl3);
|
|
|
|
} else {
|
|
|
|
err = -EIO;
|
|
|
|
}
|
2005-09-14 10:33:46 +04:00
|
|
|
if (err < 0) {
|
|
|
|
/* then try legacy ports */
|
|
|
|
val = snd_cmipci_read(cm, CM_REG_LEGACY_CTRL) & ~CM_FMSEL_MASK;
|
|
|
|
iosynth = fm_port;
|
|
|
|
switch (iosynth) {
|
|
|
|
case 0x3E8: val |= CM_FMSEL_3E8; break;
|
|
|
|
case 0x3E0: val |= CM_FMSEL_3E0; break;
|
|
|
|
case 0x3C8: val |= CM_FMSEL_3C8; break;
|
|
|
|
case 0x388: val |= CM_FMSEL_388; break;
|
|
|
|
default:
|
2007-02-15 20:56:43 +03:00
|
|
|
goto disable_fm;
|
2005-09-14 10:33:46 +04:00
|
|
|
}
|
|
|
|
snd_cmipci_write(cm, CM_REG_LEGACY_CTRL, val);
|
|
|
|
/* enable FM */
|
|
|
|
snd_cmipci_set_bit(cm, CM_REG_MISC_CTRL, CM_FM_EN);
|
|
|
|
|
|
|
|
if (snd_opl3_create(cm->card, iosynth, iosynth + 2,
|
|
|
|
OPL3_HW_OPL3, 0, &opl3) < 0) {
|
2014-02-25 15:39:30 +04:00
|
|
|
dev_err(cm->card->dev,
|
|
|
|
"no OPL device at %#lx, skipping...\n",
|
|
|
|
iosynth);
|
2007-02-15 20:56:43 +03:00
|
|
|
goto disable_fm;
|
2005-09-14 10:33:46 +04:00
|
|
|
}
|
|
|
|
}
|
2021-06-08 17:04:56 +03:00
|
|
|
err = snd_opl3_hwdep_new(opl3, 0, 1, NULL);
|
|
|
|
if (err < 0) {
|
2014-02-25 15:39:30 +04:00
|
|
|
dev_err(cm->card->dev, "cannot create OPL3 hwdep\n");
|
2005-09-14 10:33:46 +04:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
return 0;
|
2007-02-15 20:56:43 +03:00
|
|
|
|
|
|
|
disable_fm:
|
|
|
|
snd_cmipci_clear_bit(cm, CM_REG_LEGACY_CTRL, CM_FMSEL_MASK);
|
|
|
|
snd_cmipci_clear_bit(cm, CM_REG_MISC_CTRL, CM_FM_EN);
|
|
|
|
return 0;
|
2005-09-14 10:33:46 +04:00
|
|
|
}
|
|
|
|
|
2012-12-06 21:35:10 +04:00
|
|
|
static int snd_cmipci_create(struct snd_card *card, struct pci_dev *pci,
|
2021-07-15 10:58:35 +03:00
|
|
|
int dev)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2021-07-15 10:58:35 +03:00
|
|
|
struct cmipci *cm = card->private_data;
|
2005-04-17 02:20:36 +04:00
|
|
|
int err;
|
2007-08-27 11:22:31 +04:00
|
|
|
unsigned int val;
|
2009-04-27 15:12:37 +04:00
|
|
|
long iomidi = 0;
|
2007-08-24 11:18:04 +04:00
|
|
|
int integrated_midi = 0;
|
2007-09-03 11:56:45 +04:00
|
|
|
char modelstr[16];
|
2005-04-17 02:20:36 +04:00
|
|
|
int pcm_index, pcm_spdif_index;
|
2014-08-08 17:56:03 +04:00
|
|
|
static const struct pci_device_id intel_82437vx[] = {
|
2005-04-17 02:20:36 +04:00
|
|
|
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82437VX) },
|
|
|
|
{ },
|
|
|
|
};
|
|
|
|
|
2021-07-15 10:58:35 +03:00
|
|
|
err = pcim_enable_device(pci);
|
2021-06-08 17:04:56 +03:00
|
|
|
if (err < 0)
|
2005-04-17 02:20:36 +04:00
|
|
|
return err;
|
|
|
|
|
|
|
|
spin_lock_init(&cm->reg_lock);
|
2006-01-16 18:34:20 +03:00
|
|
|
mutex_init(&cm->open_mutex);
|
2005-04-17 02:20:36 +04:00
|
|
|
cm->device = pci->device;
|
|
|
|
cm->card = card;
|
|
|
|
cm->pci = pci;
|
|
|
|
cm->irq = -1;
|
|
|
|
cm->channel[0].ch = 0;
|
|
|
|
cm->channel[1].ch = 1;
|
|
|
|
cm->channel[0].is_dac = cm->channel[1].is_dac = 1; /* dual DAC mode */
|
|
|
|
|
2021-06-08 17:04:56 +03:00
|
|
|
err = pci_request_regions(pci, card->driver);
|
2021-07-15 10:58:35 +03:00
|
|
|
if (err < 0)
|
2005-04-17 02:20:36 +04:00
|
|
|
return err;
|
|
|
|
cm->iobase = pci_resource_start(pci, 0);
|
|
|
|
|
2021-07-15 10:58:35 +03:00
|
|
|
if (devm_request_irq(&pci->dev, pci->irq, snd_cmipci_interrupt,
|
|
|
|
IRQF_SHARED, KBUILD_MODNAME, cm)) {
|
2014-02-25 15:39:30 +04:00
|
|
|
dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
|
2005-04-17 02:20:36 +04:00
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
cm->irq = pci->irq;
|
2019-12-10 09:34:09 +03:00
|
|
|
card->sync_irq = cm->irq;
|
2021-07-15 10:58:35 +03:00
|
|
|
card->private_free = snd_cmipci_free;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
pci_set_master(cm->pci);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* check chip version, max channels and capabilities
|
|
|
|
*/
|
|
|
|
|
|
|
|
cm->chip_version = 0;
|
|
|
|
cm->max_channels = 2;
|
|
|
|
cm->do_soft_ac3 = soft_ac3[dev];
|
|
|
|
|
|
|
|
if (pci->device != PCI_DEVICE_ID_CMEDIA_CM8338A &&
|
|
|
|
pci->device != PCI_DEVICE_ID_CMEDIA_CM8338B)
|
|
|
|
query_chip(cm);
|
|
|
|
/* added -MCx suffix for chip supporting multi-channels */
|
|
|
|
if (cm->can_multi_ch)
|
|
|
|
sprintf(cm->card->driver + strlen(cm->card->driver),
|
|
|
|
"-MC%d", cm->max_channels);
|
|
|
|
else if (cm->can_ac3_sw)
|
|
|
|
strcpy(cm->card->driver + strlen(cm->card->driver), "-SWIEC");
|
|
|
|
|
|
|
|
cm->dig_status = SNDRV_PCM_DEFAULT_CON_SPDIF;
|
|
|
|
cm->dig_pcm_status = SNDRV_PCM_DEFAULT_CON_SPDIF;
|
|
|
|
|
|
|
|
#if CM_CH_PLAY == 1
|
|
|
|
cm->ctrl = CM_CHADC0; /* default FUNCNTRL0 */
|
|
|
|
#else
|
|
|
|
cm->ctrl = CM_CHADC1; /* default FUNCNTRL0 */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* initialize codec registers */
|
2007-09-17 11:36:49 +04:00
|
|
|
snd_cmipci_set_bit(cm, CM_REG_MISC_CTRL, CM_RESET);
|
|
|
|
snd_cmipci_clear_bit(cm, CM_REG_MISC_CTRL, CM_RESET);
|
2005-04-17 02:20:36 +04:00
|
|
|
snd_cmipci_write(cm, CM_REG_INT_HLDCLR, 0); /* disable ints */
|
|
|
|
snd_cmipci_ch_reset(cm, CM_CH_PLAY);
|
|
|
|
snd_cmipci_ch_reset(cm, CM_CH_CAPT);
|
|
|
|
snd_cmipci_write(cm, CM_REG_FUNCTRL0, 0); /* disable channels */
|
|
|
|
snd_cmipci_write(cm, CM_REG_FUNCTRL1, 0);
|
|
|
|
|
|
|
|
snd_cmipci_write(cm, CM_REG_CHFORMAT, 0);
|
|
|
|
snd_cmipci_set_bit(cm, CM_REG_MISC_CTRL, CM_ENDBDAC|CM_N4SPK3D);
|
|
|
|
#if CM_CH_PLAY == 1
|
|
|
|
snd_cmipci_set_bit(cm, CM_REG_MISC_CTRL, CM_XCHGDAC);
|
|
|
|
#else
|
|
|
|
snd_cmipci_clear_bit(cm, CM_REG_MISC_CTRL, CM_XCHGDAC);
|
|
|
|
#endif
|
2007-09-17 11:37:19 +04:00
|
|
|
if (cm->chip_version) {
|
|
|
|
snd_cmipci_write_b(cm, CM_REG_EXT_MISC, 0x20); /* magic */
|
|
|
|
snd_cmipci_write_b(cm, CM_REG_EXT_MISC + 1, 0x09); /* more magic */
|
|
|
|
}
|
2005-04-17 02:20:36 +04:00
|
|
|
/* Set Bus Master Request */
|
|
|
|
snd_cmipci_set_bit(cm, CM_REG_FUNCTRL1, CM_BREQ);
|
|
|
|
|
|
|
|
/* Assume TX and compatible chip set (Autodetection required for VX chip sets) */
|
|
|
|
switch (pci->device) {
|
|
|
|
case PCI_DEVICE_ID_CMEDIA_CM8738:
|
|
|
|
case PCI_DEVICE_ID_CMEDIA_CM8738B:
|
|
|
|
if (!pci_dev_present(intel_82437vx))
|
|
|
|
snd_cmipci_set_bit(cm, CM_REG_MISC_CTRL, CM_TXVX);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2007-08-27 11:22:31 +04:00
|
|
|
if (cm->chip_version < 68) {
|
|
|
|
val = pci->device < 0x110 ? 8338 : 8738;
|
|
|
|
} else {
|
|
|
|
switch (snd_cmipci_read_b(cm, CM_REG_INT_HLDCLR + 3) & 0x03) {
|
|
|
|
case 0:
|
|
|
|
val = 8769;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
val = 8762;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
switch ((pci->subsystem_vendor << 16) |
|
|
|
|
pci->subsystem_device) {
|
|
|
|
case 0x13f69761:
|
|
|
|
case 0x584d3741:
|
|
|
|
case 0x584d3751:
|
|
|
|
case 0x584d3761:
|
|
|
|
case 0x584d3771:
|
|
|
|
case 0x72848384:
|
|
|
|
val = 8770;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
val = 8768;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-09-03 11:56:45 +04:00
|
|
|
sprintf(card->shortname, "C-Media CMI%d", val);
|
|
|
|
if (cm->chip_version < 68)
|
|
|
|
sprintf(modelstr, " (model %d)", cm->chip_version);
|
|
|
|
else
|
|
|
|
modelstr[0] = '\0';
|
|
|
|
sprintf(card->longname, "%s%s at %#lx, irq %i",
|
|
|
|
card->shortname, modelstr, cm->iobase, cm->irq);
|
2007-08-21 10:58:35 +04:00
|
|
|
|
2007-09-03 11:55:49 +04:00
|
|
|
if (cm->chip_version >= 39) {
|
2007-08-24 11:18:04 +04:00
|
|
|
val = snd_cmipci_read_b(cm, CM_REG_MPU_PCI + 1);
|
|
|
|
if (val != 0x00 && val != 0xff) {
|
ALSA: cmipci: Allow disabling MPU port via module option
Patrick May reported that his sound card with CMI8378 chip causes a
crash / reboot when accessing the MIDI port that isn't actually
present on the board. Moreover, despite of the documentation,
passing mpu_port=0 doesn't disable the MIDI port on this board.
It implies that the chip is a newer revision and the MPU401 port is
integrated and mapped on the PCI register. For this chip model, the
driver enables the MPU port unconditionally, so far.
Although fixing the unexpected reboot would be the best solution, it's
not so trivial to identify the cause. So, as a plan B, this patch
extends the existing mpu_port option usage to allow disabling the port
by specifying the value 0, just like we applied for fm_port option in
commit 2f24d159d5ac ("[ALSA] cmipci - Allow to disable integrated FM
port"). As default, the MPU port is still enabled, but user can pass
mpu_port=0 to disable it.
Reported-and-tested-by: Patrick May <dusthillresident@gmail.com>
Link: https://lore.kernel.org/r/20191217081448.1144-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-12-17 11:14:48 +03:00
|
|
|
if (mpu_port[dev])
|
|
|
|
iomidi = cm->iobase + CM_REG_MPU_PCI;
|
2007-08-24 11:18:04 +04:00
|
|
|
integrated_midi = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!integrated_midi) {
|
2007-09-03 11:55:49 +04:00
|
|
|
val = 0;
|
2005-09-14 10:33:46 +04:00
|
|
|
iomidi = mpu_port[dev];
|
|
|
|
switch (iomidi) {
|
|
|
|
case 0x320: val = CM_VMPU_320; break;
|
|
|
|
case 0x310: val = CM_VMPU_310; break;
|
|
|
|
case 0x300: val = CM_VMPU_300; break;
|
|
|
|
case 0x330: val = CM_VMPU_330; break;
|
|
|
|
default:
|
|
|
|
iomidi = 0; break;
|
|
|
|
}
|
|
|
|
if (iomidi > 0) {
|
|
|
|
snd_cmipci_write(cm, CM_REG_LEGACY_CTRL, val);
|
|
|
|
/* enable UART */
|
|
|
|
snd_cmipci_set_bit(cm, CM_REG_FUNCTRL1, CM_UART_EN);
|
2007-09-03 11:56:23 +04:00
|
|
|
if (inb(iomidi + 1) == 0xff) {
|
2014-02-25 15:39:30 +04:00
|
|
|
dev_err(cm->card->dev,
|
|
|
|
"cannot enable MPU-401 port at %#lx\n",
|
|
|
|
iomidi);
|
2007-09-03 11:56:23 +04:00
|
|
|
snd_cmipci_clear_bit(cm, CM_REG_FUNCTRL1,
|
|
|
|
CM_UART_EN);
|
|
|
|
iomidi = 0;
|
|
|
|
}
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
}
|
2005-09-14 10:33:46 +04:00
|
|
|
|
2007-08-22 11:45:03 +04:00
|
|
|
if (cm->chip_version < 68) {
|
|
|
|
err = snd_cmipci_create_fm(cm, fm_port[dev]);
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
}
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/* reset mixer */
|
|
|
|
snd_cmipci_mixer_write(cm, 0, 0);
|
|
|
|
|
|
|
|
snd_cmipci_proc_init(cm);
|
|
|
|
|
|
|
|
/* create pcm devices */
|
|
|
|
pcm_index = pcm_spdif_index = 0;
|
2021-06-08 17:04:56 +03:00
|
|
|
err = snd_cmipci_pcm_new(cm, pcm_index);
|
|
|
|
if (err < 0)
|
2005-04-17 02:20:36 +04:00
|
|
|
return err;
|
|
|
|
pcm_index++;
|
2021-06-08 17:04:56 +03:00
|
|
|
err = snd_cmipci_pcm2_new(cm, pcm_index);
|
|
|
|
if (err < 0)
|
2007-08-27 11:21:02 +04:00
|
|
|
return err;
|
|
|
|
pcm_index++;
|
2005-04-17 02:20:36 +04:00
|
|
|
if (cm->can_ac3_hw || cm->can_ac3_sw) {
|
|
|
|
pcm_spdif_index = pcm_index;
|
2021-06-08 17:04:56 +03:00
|
|
|
err = snd_cmipci_pcm_spdif_new(cm, pcm_index);
|
|
|
|
if (err < 0)
|
2005-04-17 02:20:36 +04:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* create mixer interface & switches */
|
2021-06-08 17:04:56 +03:00
|
|
|
err = snd_cmipci_mixer_new(cm, pcm_spdif_index);
|
|
|
|
if (err < 0)
|
2005-04-17 02:20:36 +04:00
|
|
|
return err;
|
|
|
|
|
|
|
|
if (iomidi > 0) {
|
2021-06-08 17:04:56 +03:00
|
|
|
err = snd_mpu401_uart_new(card, 0, MPU401_HW_CMIPCI,
|
|
|
|
iomidi,
|
|
|
|
(integrated_midi ?
|
|
|
|
MPU401_INFO_INTEGRATED : 0) |
|
|
|
|
MPU401_INFO_IRQ_HOOK,
|
|
|
|
-1, &cm->rmidi);
|
|
|
|
if (err < 0)
|
2014-02-25 15:39:30 +04:00
|
|
|
dev_err(cm->card->dev,
|
|
|
|
"no UART401 device at 0x%lx\n", iomidi);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef USE_VAR48KRATE
|
|
|
|
for (val = 0; val < ARRAY_SIZE(rates); val++)
|
|
|
|
snd_cmipci_set_pll(cm, rates[val], val);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* (Re-)Enable external switch spdo_48k
|
|
|
|
*/
|
|
|
|
snd_cmipci_set_bit(cm, CM_REG_MISC_CTRL, CM_SPDIF48K|CM_SPDF_AC97);
|
|
|
|
#endif /* USE_VAR48KRATE */
|
|
|
|
|
|
|
|
if (snd_cmipci_create_gameport(cm, dev) < 0)
|
|
|
|
snd_cmipci_clear_bit(cm, CM_REG_FUNCTRL1, CM_JYSTK_EN);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
*/
|
|
|
|
|
|
|
|
MODULE_DEVICE_TABLE(pci, snd_cmipci_ids);
|
|
|
|
|
2012-12-06 21:35:10 +04:00
|
|
|
static int snd_cmipci_probe(struct pci_dev *pci,
|
|
|
|
const struct pci_device_id *pci_id)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
static int dev;
|
2005-11-17 17:03:13 +03:00
|
|
|
struct snd_card *card;
|
|
|
|
struct cmipci *cm;
|
2005-04-17 02:20:36 +04:00
|
|
|
int err;
|
|
|
|
|
|
|
|
if (dev >= SNDRV_CARDS)
|
|
|
|
return -ENODEV;
|
|
|
|
if (! enable[dev]) {
|
|
|
|
dev++;
|
|
|
|
return -ENOENT;
|
|
|
|
}
|
|
|
|
|
2021-07-15 10:58:35 +03:00
|
|
|
err = snd_devm_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
|
|
|
|
sizeof(*cm), &card);
|
2008-12-28 18:44:30 +03:00
|
|
|
if (err < 0)
|
|
|
|
return err;
|
2021-07-15 10:58:35 +03:00
|
|
|
cm = card->private_data;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
switch (pci->device) {
|
|
|
|
case PCI_DEVICE_ID_CMEDIA_CM8738:
|
|
|
|
case PCI_DEVICE_ID_CMEDIA_CM8738B:
|
|
|
|
strcpy(card->driver, "CMI8738");
|
|
|
|
break;
|
|
|
|
case PCI_DEVICE_ID_CMEDIA_CM8338A:
|
|
|
|
case PCI_DEVICE_ID_CMEDIA_CM8338B:
|
|
|
|
strcpy(card->driver, "CMI8338");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
strcpy(card->driver, "CMIPCI");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-07-15 10:58:35 +03:00
|
|
|
err = snd_cmipci_create(card, pci, dev);
|
2017-08-22 20:58:30 +03:00
|
|
|
if (err < 0)
|
2022-04-12 13:26:29 +03:00
|
|
|
goto error;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2017-08-22 20:58:30 +03:00
|
|
|
err = snd_card_register(card);
|
|
|
|
if (err < 0)
|
2022-04-12 13:26:29 +03:00
|
|
|
goto error;
|
2017-08-22 20:58:30 +03:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
pci_set_drvdata(pci, card);
|
|
|
|
dev++;
|
|
|
|
return 0;
|
2022-04-12 13:26:29 +03:00
|
|
|
|
|
|
|
error:
|
|
|
|
snd_card_free(card);
|
|
|
|
return err;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
2012-08-14 20:12:04 +04:00
|
|
|
#ifdef CONFIG_PM_SLEEP
|
2005-11-17 18:14:49 +03:00
|
|
|
/*
|
|
|
|
* power management
|
|
|
|
*/
|
2020-01-05 17:47:51 +03:00
|
|
|
static const unsigned char saved_regs[] = {
|
2005-11-17 18:14:49 +03:00
|
|
|
CM_REG_FUNCTRL1, CM_REG_CHFORMAT, CM_REG_LEGACY_CTRL, CM_REG_MISC_CTRL,
|
2022-03-13 22:56:17 +03:00
|
|
|
CM_REG_MIXER0, CM_REG_MIXER1, CM_REG_MIXER2, CM_REG_AUX_VOL, CM_REG_PLL,
|
2005-11-17 18:14:49 +03:00
|
|
|
CM_REG_CH0_FRAME1, CM_REG_CH0_FRAME2,
|
|
|
|
CM_REG_CH1_FRAME1, CM_REG_CH1_FRAME2, CM_REG_EXT_MISC,
|
|
|
|
CM_REG_INT_STATUS, CM_REG_INT_HLDCLR, CM_REG_FUNCTRL0,
|
|
|
|
};
|
|
|
|
|
2020-01-05 17:47:51 +03:00
|
|
|
static const unsigned char saved_mixers[] = {
|
2005-11-17 18:14:49 +03:00
|
|
|
SB_DSP4_MASTER_DEV, SB_DSP4_MASTER_DEV + 1,
|
|
|
|
SB_DSP4_PCM_DEV, SB_DSP4_PCM_DEV + 1,
|
|
|
|
SB_DSP4_SYNTH_DEV, SB_DSP4_SYNTH_DEV + 1,
|
|
|
|
SB_DSP4_CD_DEV, SB_DSP4_CD_DEV + 1,
|
|
|
|
SB_DSP4_LINE_DEV, SB_DSP4_LINE_DEV + 1,
|
|
|
|
SB_DSP4_MIC_DEV, SB_DSP4_SPEAKER_DEV,
|
|
|
|
CM_REG_EXTENT_IND, SB_DSP4_OUTPUT_SW,
|
|
|
|
SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT,
|
|
|
|
};
|
|
|
|
|
2012-07-02 17:20:37 +04:00
|
|
|
static int snd_cmipci_suspend(struct device *dev)
|
2005-11-17 18:14:49 +03:00
|
|
|
{
|
2012-07-02 17:20:37 +04:00
|
|
|
struct snd_card *card = dev_get_drvdata(dev);
|
2005-11-17 18:14:49 +03:00
|
|
|
struct cmipci *cm = card->private_data;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
|
|
|
|
|
|
|
|
/* save registers */
|
|
|
|
for (i = 0; i < ARRAY_SIZE(saved_regs); i++)
|
|
|
|
cm->saved_regs[i] = snd_cmipci_read(cm, saved_regs[i]);
|
|
|
|
for (i = 0; i < ARRAY_SIZE(saved_mixers); i++)
|
|
|
|
cm->saved_mixers[i] = snd_cmipci_mixer_read(cm, saved_mixers[i]);
|
|
|
|
|
|
|
|
/* disable ints */
|
|
|
|
snd_cmipci_write(cm, CM_REG_INT_HLDCLR, 0);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-07-02 17:20:37 +04:00
|
|
|
static int snd_cmipci_resume(struct device *dev)
|
2005-11-17 18:14:49 +03:00
|
|
|
{
|
2012-07-02 17:20:37 +04:00
|
|
|
struct snd_card *card = dev_get_drvdata(dev);
|
2005-11-17 18:14:49 +03:00
|
|
|
struct cmipci *cm = card->private_data;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* reset / initialize to a sane state */
|
|
|
|
snd_cmipci_write(cm, CM_REG_INT_HLDCLR, 0);
|
|
|
|
snd_cmipci_ch_reset(cm, CM_CH_PLAY);
|
|
|
|
snd_cmipci_ch_reset(cm, CM_CH_CAPT);
|
|
|
|
snd_cmipci_mixer_write(cm, 0, 0);
|
|
|
|
|
|
|
|
/* restore registers */
|
|
|
|
for (i = 0; i < ARRAY_SIZE(saved_regs); i++)
|
|
|
|
snd_cmipci_write(cm, saved_regs[i], cm->saved_regs[i]);
|
|
|
|
for (i = 0; i < ARRAY_SIZE(saved_mixers); i++)
|
|
|
|
snd_cmipci_mixer_write(cm, saved_mixers[i], cm->saved_mixers[i]);
|
|
|
|
|
|
|
|
snd_power_change_state(card, SNDRV_CTL_POWER_D0);
|
|
|
|
return 0;
|
|
|
|
}
|
2012-07-02 17:20:37 +04:00
|
|
|
|
|
|
|
static SIMPLE_DEV_PM_OPS(snd_cmipci_pm, snd_cmipci_suspend, snd_cmipci_resume);
|
|
|
|
#define SND_CMIPCI_PM_OPS &snd_cmipci_pm
|
|
|
|
#else
|
|
|
|
#define SND_CMIPCI_PM_OPS NULL
|
2012-08-14 20:12:04 +04:00
|
|
|
#endif /* CONFIG_PM_SLEEP */
|
2005-11-17 18:14:49 +03:00
|
|
|
|
2012-04-24 14:25:00 +04:00
|
|
|
static struct pci_driver cmipci_driver = {
|
2011-06-10 18:20:20 +04:00
|
|
|
.name = KBUILD_MODNAME,
|
2005-04-17 02:20:36 +04:00
|
|
|
.id_table = snd_cmipci_ids,
|
|
|
|
.probe = snd_cmipci_probe,
|
2012-07-02 17:20:37 +04:00
|
|
|
.driver = {
|
|
|
|
.pm = SND_CMIPCI_PM_OPS,
|
|
|
|
},
|
2005-04-17 02:20:36 +04:00
|
|
|
};
|
|
|
|
|
2012-04-24 14:25:00 +04:00
|
|
|
module_pci_driver(cmipci_driver);
|