Merge branch 'topic/ca0106' into to-push
This commit is contained in:
Коммит
86b3aa390b
|
@ -353,7 +353,7 @@ void snd_verbose_printd(const char *file, int line, const char *format, ...)
|
|||
* snd_printk - printk wrapper
|
||||
* @fmt: format string
|
||||
*
|
||||
* Works like print() but prints the file and the line of the caller
|
||||
* Works like printk() but prints the file and the line of the caller
|
||||
* when configured with CONFIG_SND_VERBOSE_PRINTK.
|
||||
*/
|
||||
#define snd_printk(fmt, args...) \
|
||||
|
@ -380,18 +380,40 @@ void snd_verbose_printd(const char *file, int line, const char *format, ...)
|
|||
printk(fmt ,##args)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* snd_BUG - give a BUG warning message and stack trace
|
||||
*
|
||||
* Calls WARN() if CONFIG_SND_DEBUG is set.
|
||||
* Ignored when CONFIG_SND_DEBUG is not set.
|
||||
*/
|
||||
#define snd_BUG() WARN(1, "BUG?\n")
|
||||
|
||||
/**
|
||||
* snd_BUG_ON - debugging check macro
|
||||
* @cond: condition to evaluate
|
||||
*
|
||||
* When CONFIG_SND_DEBUG is set, this macro evaluates the given condition,
|
||||
* and call WARN() and returns the value if it's non-zero.
|
||||
*
|
||||
* When CONFIG_SND_DEBUG is not set, this just returns zero, and the given
|
||||
* condition is ignored.
|
||||
*
|
||||
* NOTE: the argument won't be evaluated at all when CONFIG_SND_DEBUG=n.
|
||||
* Thus, don't put any statement that influences on the code behavior,
|
||||
* such as pre/post increment, to the argument of this macro.
|
||||
* If you want to evaluate and give a warning, use standard WARN_ON().
|
||||
*/
|
||||
#define snd_BUG_ON(cond) WARN((cond), "BUG? (%s)\n", __stringify(cond))
|
||||
|
||||
#else /* !CONFIG_SND_DEBUG */
|
||||
|
||||
#define snd_printd(fmt, args...) do { } while (0)
|
||||
#define snd_BUG() do { } while (0)
|
||||
static inline int __snd_bug_on(void)
|
||||
static inline int __snd_bug_on(int cond)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#define snd_BUG_ON(cond) __snd_bug_on() /* always false */
|
||||
#define snd_BUG_ON(cond) __snd_bug_on(0 && (cond)) /* always false */
|
||||
|
||||
#endif /* CONFIG_SND_DEBUG */
|
||||
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
/* include/version.h */
|
||||
#define CONFIG_SND_VERSION "1.0.18rc3"
|
||||
#define CONFIG_SND_VERSION "1.0.18a"
|
||||
#define CONFIG_SND_DATE ""
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <linux/init.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/string.h>
|
||||
#include <sound/ac97_codec.h>
|
||||
|
||||
/*
|
||||
* Let drivers decide whether they want to support given codec from their
|
||||
|
|
|
@ -98,7 +98,7 @@ int snd_device_free(struct snd_card *card, void *device_data)
|
|||
kfree(dev);
|
||||
return 0;
|
||||
}
|
||||
snd_printd("device free %p (from %p), not found\n", device_data,
|
||||
snd_printd("device free %p (from %pF), not found\n", device_data,
|
||||
__builtin_return_address(0));
|
||||
return -ENXIO;
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ int snd_device_disconnect(struct snd_card *card, void *device_data)
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
snd_printd("device disconnect %p (from %p), not found\n", device_data,
|
||||
snd_printd("device disconnect %p (from %pF), not found\n", device_data,
|
||||
__builtin_return_address(0));
|
||||
return -ENXIO;
|
||||
}
|
||||
|
|
|
@ -163,7 +163,7 @@ config SND_ML403_AC97CR
|
|||
|
||||
config SND_AC97_POWER_SAVE
|
||||
bool "AC97 Power-Saving Mode"
|
||||
depends on SND_AC97_CODEC && EXPERIMENTAL
|
||||
depends on SND_AC97_CODEC
|
||||
default n
|
||||
help
|
||||
Say Y here to enable the aggressive power-saving support of
|
||||
|
|
|
@ -96,7 +96,7 @@ static int __devinit snd_card_pcsp_probe(int devnum, struct device *dev)
|
|||
return -EINVAL;
|
||||
|
||||
hrtimer_init(&pcsp_chip.timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
|
||||
pcsp_chip.timer.cb_mode = HRTIMER_CB_SOFTIRQ;
|
||||
pcsp_chip.timer.cb_mode = HRTIMER_CB_IRQSAFE_UNLOCKED;
|
||||
pcsp_chip.timer.function = pcsp_do_timer;
|
||||
|
||||
card = snd_card_new(index, id, THIS_MODULE, 0);
|
||||
|
@ -188,10 +188,8 @@ static int __devexit pcsp_remove(struct platform_device *dev)
|
|||
|
||||
static void pcsp_stop_beep(struct snd_pcsp *chip)
|
||||
{
|
||||
spin_lock_irq(&chip->substream_lock);
|
||||
if (!chip->playback_substream)
|
||||
pcspkr_stop_sound();
|
||||
spin_unlock_irq(&chip->substream_lock);
|
||||
pcsp_sync_stop(chip);
|
||||
pcspkr_stop_sound();
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
|
|
|
@ -62,6 +62,8 @@ struct snd_pcsp {
|
|||
unsigned short port, irq, dma;
|
||||
spinlock_t substream_lock;
|
||||
struct snd_pcm_substream *playback_substream;
|
||||
unsigned int fmt_size;
|
||||
unsigned int is_signed;
|
||||
size_t playback_ptr;
|
||||
size_t period_ptr;
|
||||
atomic_t timer_active;
|
||||
|
@ -77,6 +79,7 @@ struct snd_pcsp {
|
|||
extern struct snd_pcsp pcsp_chip;
|
||||
|
||||
extern enum hrtimer_restart pcsp_do_timer(struct hrtimer *handle);
|
||||
extern void pcsp_sync_stop(struct snd_pcsp *chip);
|
||||
|
||||
extern int snd_pcsp_new_pcm(struct snd_pcsp *chip);
|
||||
extern int snd_pcsp_new_mixer(struct snd_pcsp *chip);
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include <linux/module.h>
|
||||
#include <linux/moduleparam.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <sound/pcm.h>
|
||||
#include <asm/io.h>
|
||||
#include "pcsp.h"
|
||||
|
@ -19,61 +20,57 @@ MODULE_PARM_DESC(nforce_wa, "Apply NForce chipset workaround "
|
|||
|
||||
#define DMIX_WANTS_S16 1
|
||||
|
||||
enum hrtimer_restart pcsp_do_timer(struct hrtimer *handle)
|
||||
/*
|
||||
* Call snd_pcm_period_elapsed in a tasklet
|
||||
* This avoids spinlock messes and long-running irq contexts
|
||||
*/
|
||||
static void pcsp_call_pcm_elapsed(unsigned long priv)
|
||||
{
|
||||
if (atomic_read(&pcsp_chip.timer_active)) {
|
||||
struct snd_pcm_substream *substream;
|
||||
substream = pcsp_chip.playback_substream;
|
||||
if (substream)
|
||||
snd_pcm_period_elapsed(substream);
|
||||
}
|
||||
}
|
||||
|
||||
static DECLARE_TASKLET(pcsp_pcm_tasklet, pcsp_call_pcm_elapsed, 0);
|
||||
|
||||
/* write the port and returns the next expire time in ns;
|
||||
* called at the trigger-start and in hrtimer callback
|
||||
*/
|
||||
static unsigned long pcsp_timer_update(struct hrtimer *handle)
|
||||
{
|
||||
unsigned char timer_cnt, val;
|
||||
int fmt_size, periods_elapsed;
|
||||
u64 ns;
|
||||
size_t period_bytes, buffer_bytes;
|
||||
struct snd_pcm_substream *substream;
|
||||
struct snd_pcm_runtime *runtime;
|
||||
struct snd_pcsp *chip = container_of(handle, struct snd_pcsp, timer);
|
||||
unsigned long flags;
|
||||
|
||||
if (chip->thalf) {
|
||||
outb(chip->val61, 0x61);
|
||||
chip->thalf = 0;
|
||||
if (!atomic_read(&chip->timer_active))
|
||||
return HRTIMER_NORESTART;
|
||||
hrtimer_forward(&chip->timer, hrtimer_get_expires(&chip->timer),
|
||||
ktime_set(0, chip->ns_rem));
|
||||
return HRTIMER_RESTART;
|
||||
return 0;
|
||||
return chip->ns_rem;
|
||||
}
|
||||
|
||||
spin_lock_irq(&chip->substream_lock);
|
||||
/* Takashi Iwai says regarding this extra lock:
|
||||
|
||||
If the irq handler handles some data on the DMA buffer, it should
|
||||
do snd_pcm_stream_lock().
|
||||
That protects basically against all races among PCM callbacks, yes.
|
||||
However, there are two remaining issues:
|
||||
1. The substream pointer you try to lock isn't protected _before_
|
||||
this lock yet.
|
||||
2. snd_pcm_period_elapsed() itself acquires the lock.
|
||||
The requirement of another lock is because of 1. When you get
|
||||
chip->playback_substream, it's not protected.
|
||||
Keeping this lock while snd_pcm_period_elapsed() assures the substream
|
||||
is still protected (at least, not released). And the other status is
|
||||
handled properly inside snd_pcm_stream_lock() in
|
||||
snd_pcm_period_elapsed().
|
||||
|
||||
*/
|
||||
if (!chip->playback_substream)
|
||||
goto exit_nr_unlock1;
|
||||
substream = chip->playback_substream;
|
||||
snd_pcm_stream_lock(substream);
|
||||
if (!atomic_read(&chip->timer_active))
|
||||
goto exit_nr_unlock2;
|
||||
return 0;
|
||||
substream = chip->playback_substream;
|
||||
if (!substream)
|
||||
return 0;
|
||||
|
||||
runtime = substream->runtime;
|
||||
fmt_size = snd_pcm_format_physical_width(runtime->format) >> 3;
|
||||
/* assume it is mono! */
|
||||
val = runtime->dma_area[chip->playback_ptr + fmt_size - 1];
|
||||
if (snd_pcm_format_signed(runtime->format))
|
||||
val = runtime->dma_area[chip->playback_ptr + chip->fmt_size - 1];
|
||||
if (chip->is_signed)
|
||||
val ^= 0x80;
|
||||
timer_cnt = val * CUR_DIV() / 256;
|
||||
|
||||
if (timer_cnt && chip->enable) {
|
||||
spin_lock(&i8253_lock);
|
||||
spin_lock_irqsave(&i8253_lock, flags);
|
||||
if (!nforce_wa) {
|
||||
outb_p(chip->val61, 0x61);
|
||||
outb_p(timer_cnt, 0x42);
|
||||
|
@ -82,12 +79,39 @@ enum hrtimer_restart pcsp_do_timer(struct hrtimer *handle)
|
|||
outb(chip->val61 ^ 2, 0x61);
|
||||
chip->thalf = 1;
|
||||
}
|
||||
spin_unlock(&i8253_lock);
|
||||
spin_unlock_irqrestore(&i8253_lock, flags);
|
||||
}
|
||||
|
||||
chip->ns_rem = PCSP_PERIOD_NS();
|
||||
ns = (chip->thalf ? PCSP_CALC_NS(timer_cnt) : chip->ns_rem);
|
||||
chip->ns_rem -= ns;
|
||||
return ns;
|
||||
}
|
||||
|
||||
enum hrtimer_restart pcsp_do_timer(struct hrtimer *handle)
|
||||
{
|
||||
struct snd_pcsp *chip = container_of(handle, struct snd_pcsp, timer);
|
||||
struct snd_pcm_substream *substream;
|
||||
int periods_elapsed, pointer_update;
|
||||
size_t period_bytes, buffer_bytes;
|
||||
unsigned long ns;
|
||||
unsigned long flags;
|
||||
|
||||
pointer_update = !chip->thalf;
|
||||
ns = pcsp_timer_update(handle);
|
||||
if (!ns)
|
||||
return HRTIMER_NORESTART;
|
||||
|
||||
/* update the playback position */
|
||||
substream = chip->playback_substream;
|
||||
if (!substream)
|
||||
return HRTIMER_NORESTART;
|
||||
|
||||
period_bytes = snd_pcm_lib_period_bytes(substream);
|
||||
buffer_bytes = snd_pcm_lib_buffer_bytes(substream);
|
||||
chip->playback_ptr += PCSP_INDEX_INC() * fmt_size;
|
||||
|
||||
spin_lock_irqsave(&chip->substream_lock, flags);
|
||||
chip->playback_ptr += PCSP_INDEX_INC() * chip->fmt_size;
|
||||
periods_elapsed = chip->playback_ptr - chip->period_ptr;
|
||||
if (periods_elapsed < 0) {
|
||||
#if PCSP_DEBUG
|
||||
|
@ -102,41 +126,30 @@ enum hrtimer_restart pcsp_do_timer(struct hrtimer *handle)
|
|||
* or ALSA will BUG on us. */
|
||||
chip->playback_ptr %= buffer_bytes;
|
||||
|
||||
snd_pcm_stream_unlock(substream);
|
||||
|
||||
if (periods_elapsed) {
|
||||
snd_pcm_period_elapsed(substream);
|
||||
chip->period_ptr += periods_elapsed * period_bytes;
|
||||
chip->period_ptr %= buffer_bytes;
|
||||
}
|
||||
spin_unlock_irqrestore(&chip->substream_lock, flags);
|
||||
|
||||
spin_unlock_irq(&chip->substream_lock);
|
||||
if (periods_elapsed)
|
||||
tasklet_schedule(&pcsp_pcm_tasklet);
|
||||
|
||||
if (!atomic_read(&chip->timer_active))
|
||||
return HRTIMER_NORESTART;
|
||||
hrtimer_forward(handle, hrtimer_get_expires(handle), ns_to_ktime(ns));
|
||||
|
||||
chip->ns_rem = PCSP_PERIOD_NS();
|
||||
ns = (chip->thalf ? PCSP_CALC_NS(timer_cnt) : chip->ns_rem);
|
||||
chip->ns_rem -= ns;
|
||||
hrtimer_forward(&chip->timer, hrtimer_get_expires(&chip->timer),
|
||||
ktime_set(0, ns));
|
||||
return HRTIMER_RESTART;
|
||||
|
||||
exit_nr_unlock2:
|
||||
snd_pcm_stream_unlock(substream);
|
||||
exit_nr_unlock1:
|
||||
spin_unlock_irq(&chip->substream_lock);
|
||||
return HRTIMER_NORESTART;
|
||||
}
|
||||
|
||||
static void pcsp_start_playing(struct snd_pcsp *chip)
|
||||
static int pcsp_start_playing(struct snd_pcsp *chip)
|
||||
{
|
||||
unsigned long ns;
|
||||
|
||||
#if PCSP_DEBUG
|
||||
printk(KERN_INFO "PCSP: start_playing called\n");
|
||||
#endif
|
||||
if (atomic_read(&chip->timer_active)) {
|
||||
printk(KERN_ERR "PCSP: Timer already active\n");
|
||||
return;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
spin_lock(&i8253_lock);
|
||||
|
@ -146,7 +159,12 @@ static void pcsp_start_playing(struct snd_pcsp *chip)
|
|||
atomic_set(&chip->timer_active, 1);
|
||||
chip->thalf = 0;
|
||||
|
||||
hrtimer_start(&pcsp_chip.timer, ktime_set(0, 0), HRTIMER_MODE_REL);
|
||||
ns = pcsp_timer_update(&pcsp_chip.timer);
|
||||
if (!ns)
|
||||
return -EIO;
|
||||
|
||||
hrtimer_start(&pcsp_chip.timer, ktime_set(0, ns), HRTIMER_MODE_REL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void pcsp_stop_playing(struct snd_pcsp *chip)
|
||||
|
@ -165,26 +183,35 @@ static void pcsp_stop_playing(struct snd_pcsp *chip)
|
|||
spin_unlock(&i8253_lock);
|
||||
}
|
||||
|
||||
/*
|
||||
* Force to stop and sync the stream
|
||||
*/
|
||||
void pcsp_sync_stop(struct snd_pcsp *chip)
|
||||
{
|
||||
local_irq_disable();
|
||||
pcsp_stop_playing(chip);
|
||||
local_irq_enable();
|
||||
hrtimer_cancel(&chip->timer);
|
||||
tasklet_kill(&pcsp_pcm_tasklet);
|
||||
}
|
||||
|
||||
static int snd_pcsp_playback_close(struct snd_pcm_substream *substream)
|
||||
{
|
||||
struct snd_pcsp *chip = snd_pcm_substream_chip(substream);
|
||||
#if PCSP_DEBUG
|
||||
printk(KERN_INFO "PCSP: close called\n");
|
||||
#endif
|
||||
if (atomic_read(&chip->timer_active)) {
|
||||
printk(KERN_ERR "PCSP: timer still active\n");
|
||||
pcsp_stop_playing(chip);
|
||||
}
|
||||
spin_lock_irq(&chip->substream_lock);
|
||||
pcsp_sync_stop(chip);
|
||||
chip->playback_substream = NULL;
|
||||
spin_unlock_irq(&chip->substream_lock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int snd_pcsp_playback_hw_params(struct snd_pcm_substream *substream,
|
||||
struct snd_pcm_hw_params *hw_params)
|
||||
{
|
||||
struct snd_pcsp *chip = snd_pcm_substream_chip(substream);
|
||||
int err;
|
||||
pcsp_sync_stop(chip);
|
||||
err = snd_pcm_lib_malloc_pages(substream,
|
||||
params_buffer_bytes(hw_params));
|
||||
if (err < 0)
|
||||
|
@ -194,9 +221,11 @@ static int snd_pcsp_playback_hw_params(struct snd_pcm_substream *substream,
|
|||
|
||||
static int snd_pcsp_playback_hw_free(struct snd_pcm_substream *substream)
|
||||
{
|
||||
struct snd_pcsp *chip = snd_pcm_substream_chip(substream);
|
||||
#if PCSP_DEBUG
|
||||
printk(KERN_INFO "PCSP: hw_free called\n");
|
||||
#endif
|
||||
pcsp_sync_stop(chip);
|
||||
return snd_pcm_lib_free_pages(substream);
|
||||
}
|
||||
|
||||
|
@ -212,8 +241,12 @@ static int snd_pcsp_playback_prepare(struct snd_pcm_substream *substream)
|
|||
snd_pcm_lib_period_bytes(substream),
|
||||
substream->runtime->periods);
|
||||
#endif
|
||||
pcsp_sync_stop(chip);
|
||||
chip->playback_ptr = 0;
|
||||
chip->period_ptr = 0;
|
||||
chip->fmt_size =
|
||||
snd_pcm_format_physical_width(substream->runtime->format) >> 3;
|
||||
chip->is_signed = snd_pcm_format_signed(substream->runtime->format);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -226,8 +259,7 @@ static int snd_pcsp_trigger(struct snd_pcm_substream *substream, int cmd)
|
|||
switch (cmd) {
|
||||
case SNDRV_PCM_TRIGGER_START:
|
||||
case SNDRV_PCM_TRIGGER_RESUME:
|
||||
pcsp_start_playing(chip);
|
||||
break;
|
||||
return pcsp_start_playing(chip);
|
||||
case SNDRV_PCM_TRIGGER_STOP:
|
||||
case SNDRV_PCM_TRIGGER_SUSPEND:
|
||||
pcsp_stop_playing(chip);
|
||||
|
@ -242,7 +274,11 @@ static snd_pcm_uframes_t snd_pcsp_playback_pointer(struct snd_pcm_substream
|
|||
*substream)
|
||||
{
|
||||
struct snd_pcsp *chip = snd_pcm_substream_chip(substream);
|
||||
return bytes_to_frames(substream->runtime, chip->playback_ptr);
|
||||
unsigned int pos;
|
||||
spin_lock(&chip->substream_lock);
|
||||
pos = chip->playback_ptr;
|
||||
spin_unlock(&chip->substream_lock);
|
||||
return bytes_to_frames(substream->runtime, pos);
|
||||
}
|
||||
|
||||
static struct snd_pcm_hardware snd_pcsp_playback = {
|
||||
|
@ -279,9 +315,7 @@ static int snd_pcsp_playback_open(struct snd_pcm_substream *substream)
|
|||
return -EBUSY;
|
||||
}
|
||||
runtime->hw = snd_pcsp_playback;
|
||||
spin_lock_irq(&chip->substream_lock);
|
||||
chip->playback_substream = substream;
|
||||
spin_unlock_irq(&chip->substream_lock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -140,8 +140,10 @@ static int __devinit snd_sb8_probe(struct device *pdev, unsigned int dev)
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (i >= ARRAY_SIZE(possible_ports))
|
||||
if (i >= ARRAY_SIZE(possible_ports)) {
|
||||
err = -EINVAL;
|
||||
goto _err;
|
||||
}
|
||||
}
|
||||
acard->chip = chip;
|
||||
|
||||
|
|
|
@ -175,7 +175,7 @@ static const struct ac97_codec_id snd_ac97_codec_ids[] = {
|
|||
{ 0x574d4C04, 0xffffffff, "WM9704M,WM9704Q", patch_wolfson04, NULL},
|
||||
{ 0x574d4C05, 0xffffffff, "WM9705,WM9710", patch_wolfson05, NULL},
|
||||
{ 0x574d4C09, 0xffffffff, "WM9709", NULL, NULL},
|
||||
{ 0x574d4C12, 0xffffffff, "WM9711,WM9712", patch_wolfson11, NULL},
|
||||
{ 0x574d4C12, 0xffffffff, "WM9711,WM9712,WM9715", patch_wolfson11, NULL},
|
||||
{ 0x574d4c13, 0xffffffff, "WM9713,WM9714", patch_wolfson13, NULL, AC97_DEFAULT_POWER_OFF},
|
||||
{ 0x594d4800, 0xffffffff, "YMF743", patch_yamaha_ymf743, NULL },
|
||||
{ 0x594d4802, 0xffffffff, "YMF752", NULL, NULL },
|
||||
|
|
|
@ -2832,6 +2832,8 @@ static int patch_alc655(struct snd_ac97 * ac97)
|
|||
val &= ~(1 << 1); /* Pin 47 is EAPD (for internal speaker) */
|
||||
else
|
||||
val |= (1 << 1); /* Pin 47 is spdif input pin */
|
||||
/* this seems missing on some hardwares */
|
||||
ac97->ext_id |= AC97_EI_SPDIF;
|
||||
}
|
||||
val &= ~(1 << 12); /* vref enable */
|
||||
snd_ac97_write_cache(ac97, 0x7a, val);
|
||||
|
|
|
@ -664,10 +664,14 @@ struct snd_ca0106_pcm {
|
|||
struct snd_ca0106_details {
|
||||
u32 serial;
|
||||
char * name;
|
||||
int ac97;
|
||||
int gpio_type;
|
||||
int i2c_adc;
|
||||
int spi_dac;
|
||||
int ac97; /* ac97 = 0 -> Select MIC, Line in, TAD in, AUX in.
|
||||
ac97 = 1 -> Default to AC97 in. */
|
||||
int gpio_type; /* gpio_type = 1 -> shared mic-in/line-in
|
||||
gpio_type = 2 -> shared side-out/line-in. */
|
||||
int i2c_adc; /* with i2c_adc=1, the driver adds some capture volume
|
||||
controls, phone, mic, line-in and aux. */
|
||||
int spi_dac; /* spi_dac=1 adds the mute switch for each analog
|
||||
output, front, rear, etc. */
|
||||
};
|
||||
|
||||
// definition of the chip-specific record
|
||||
|
@ -686,11 +690,12 @@ struct snd_ca0106 {
|
|||
spinlock_t emu_lock;
|
||||
|
||||
struct snd_ac97 *ac97;
|
||||
struct snd_pcm *pcm;
|
||||
struct snd_pcm *pcm[4];
|
||||
|
||||
struct snd_ca0106_channel playback_channels[4];
|
||||
struct snd_ca0106_channel capture_channels[4];
|
||||
u32 spdif_bits[4]; /* s/pdif out setup */
|
||||
u32 spdif_bits[4]; /* s/pdif out default setup */
|
||||
u32 spdif_str_bits[4]; /* s/pdif out per-stream setup */
|
||||
int spdif_enable;
|
||||
int capture_source;
|
||||
int i2c_capture_source;
|
||||
|
@ -703,6 +708,11 @@ struct snd_ca0106 {
|
|||
struct snd_ca_midi midi2;
|
||||
|
||||
u16 spi_dac_reg[16];
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
#define NUM_SAVED_VOLUMES 9
|
||||
unsigned int saved_vol[NUM_SAVED_VOLUMES];
|
||||
#endif
|
||||
};
|
||||
|
||||
int snd_ca0106_mixer(struct snd_ca0106 *emu);
|
||||
|
@ -721,3 +731,11 @@ int snd_ca0106_i2c_write(struct snd_ca0106 *emu, u32 reg, u32 value);
|
|||
|
||||
int snd_ca0106_spi_write(struct snd_ca0106 * emu,
|
||||
unsigned int data);
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
void snd_ca0106_mixer_suspend(struct snd_ca0106 *chip);
|
||||
void snd_ca0106_mixer_resume(struct snd_ca0106 *chip);
|
||||
#else
|
||||
#define snd_ca0106_mixer_suspend(chip) do { } while (0)
|
||||
#define snd_ca0106_mixer_resume(chip) do { } while (0)
|
||||
#endif
|
||||
|
|
|
@ -254,7 +254,7 @@ static struct snd_ca0106_details ca0106_chip_details[] = {
|
|||
.name = "MSI K8N Diamond MB",
|
||||
.gpio_type = 2,
|
||||
.i2c_adc = 1,
|
||||
.spi_dac = 2 } ,
|
||||
.spi_dac = 1 } ,
|
||||
/* Shuttle XPC SD31P which has an onboard Creative Labs
|
||||
* Sound Blaster Live! 24-bit EAX
|
||||
* high-definition 7.1 audio processor".
|
||||
|
@ -305,9 +305,15 @@ static struct snd_pcm_hardware snd_ca0106_capture_hw = {
|
|||
SNDRV_PCM_INFO_BLOCK_TRANSFER |
|
||||
SNDRV_PCM_INFO_MMAP_VALID),
|
||||
.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE,
|
||||
#if 0 /* FIXME: looks like 44.1kHz capture causes noisy output on 48kHz */
|
||||
.rates = (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |
|
||||
SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000),
|
||||
.rate_min = 44100,
|
||||
#else
|
||||
.rates = (SNDRV_PCM_RATE_48000 |
|
||||
SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000),
|
||||
.rate_min = 48000,
|
||||
#endif /* FIXME */
|
||||
.rate_max = 192000,
|
||||
.channels_min = 2,
|
||||
.channels_max = 2,
|
||||
|
@ -479,6 +485,15 @@ static const int spi_dacd_bit[] = {
|
|||
[PCM_UNKNOWN_CHANNEL] = SPI_DACD1_BIT,
|
||||
};
|
||||
|
||||
static void restore_spdif_bits(struct snd_ca0106 *chip, int idx)
|
||||
{
|
||||
if (chip->spdif_str_bits[idx] != chip->spdif_bits[idx]) {
|
||||
chip->spdif_str_bits[idx] = chip->spdif_bits[idx];
|
||||
snd_ca0106_ptr_write(chip, SPCS0 + idx, 0,
|
||||
chip->spdif_str_bits[idx]);
|
||||
}
|
||||
}
|
||||
|
||||
/* open_playback callback */
|
||||
static int snd_ca0106_pcm_open_playback_channel(struct snd_pcm_substream *substream,
|
||||
int channel_id)
|
||||
|
@ -524,6 +539,9 @@ static int snd_ca0106_pcm_open_playback_channel(struct snd_pcm_substream *substr
|
|||
if (err < 0)
|
||||
return err;
|
||||
}
|
||||
|
||||
restore_spdif_bits(chip, channel_id);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -535,6 +553,8 @@ static int snd_ca0106_pcm_close_playback(struct snd_pcm_substream *substream)
|
|||
struct snd_ca0106_pcm *epcm = runtime->private_data;
|
||||
chip->playback_channels[epcm->channel_id].use = 0;
|
||||
|
||||
restore_spdif_bits(chip, epcm->channel_id);
|
||||
|
||||
if (chip->details->spi_dac && epcm->channel_id != PCM_FRONT_CHANNEL) {
|
||||
const int reg = spi_dacd_reg[epcm->channel_id];
|
||||
|
||||
|
@ -847,15 +867,18 @@ static int snd_ca0106_pcm_trigger_playback(struct snd_pcm_substream *substream,
|
|||
struct snd_pcm_substream *s;
|
||||
u32 basic = 0;
|
||||
u32 extended = 0;
|
||||
int running=0;
|
||||
u32 bits;
|
||||
int running = 0;
|
||||
|
||||
switch (cmd) {
|
||||
case SNDRV_PCM_TRIGGER_START:
|
||||
running=1;
|
||||
case SNDRV_PCM_TRIGGER_RESUME:
|
||||
running = 1;
|
||||
break;
|
||||
case SNDRV_PCM_TRIGGER_STOP:
|
||||
case SNDRV_PCM_TRIGGER_SUSPEND:
|
||||
default:
|
||||
running=0;
|
||||
running = 0;
|
||||
break;
|
||||
}
|
||||
snd_pcm_group_for_each_entry(s, substream) {
|
||||
|
@ -865,22 +888,32 @@ static int snd_ca0106_pcm_trigger_playback(struct snd_pcm_substream *substream,
|
|||
runtime = s->runtime;
|
||||
epcm = runtime->private_data;
|
||||
channel = epcm->channel_id;
|
||||
//snd_printk("channel=%d\n",channel);
|
||||
/* snd_printk("channel=%d\n",channel); */
|
||||
epcm->running = running;
|
||||
basic |= (0x1<<channel);
|
||||
extended |= (0x10<<channel);
|
||||
basic |= (0x1 << channel);
|
||||
extended |= (0x10 << channel);
|
||||
snd_pcm_trigger_done(s, substream);
|
||||
}
|
||||
//snd_printk("basic=0x%x, extended=0x%x\n",basic, extended);
|
||||
/* snd_printk("basic=0x%x, extended=0x%x\n",basic, extended); */
|
||||
|
||||
switch (cmd) {
|
||||
case SNDRV_PCM_TRIGGER_START:
|
||||
snd_ca0106_ptr_write(emu, EXTENDED_INT_MASK, 0, snd_ca0106_ptr_read(emu, EXTENDED_INT_MASK, 0) | (extended));
|
||||
snd_ca0106_ptr_write(emu, BASIC_INTERRUPT, 0, snd_ca0106_ptr_read(emu, BASIC_INTERRUPT, 0)|(basic));
|
||||
case SNDRV_PCM_TRIGGER_RESUME:
|
||||
bits = snd_ca0106_ptr_read(emu, EXTENDED_INT_MASK, 0);
|
||||
bits |= extended;
|
||||
snd_ca0106_ptr_write(emu, EXTENDED_INT_MASK, 0, bits);
|
||||
bits = snd_ca0106_ptr_read(emu, BASIC_INTERRUPT, 0);
|
||||
bits |= basic;
|
||||
snd_ca0106_ptr_write(emu, BASIC_INTERRUPT, 0, bits);
|
||||
break;
|
||||
case SNDRV_PCM_TRIGGER_STOP:
|
||||
snd_ca0106_ptr_write(emu, BASIC_INTERRUPT, 0, snd_ca0106_ptr_read(emu, BASIC_INTERRUPT, 0) & ~(basic));
|
||||
snd_ca0106_ptr_write(emu, EXTENDED_INT_MASK, 0, snd_ca0106_ptr_read(emu, EXTENDED_INT_MASK, 0) & ~(extended));
|
||||
case SNDRV_PCM_TRIGGER_SUSPEND:
|
||||
bits = snd_ca0106_ptr_read(emu, BASIC_INTERRUPT, 0);
|
||||
bits &= ~basic;
|
||||
snd_ca0106_ptr_write(emu, BASIC_INTERRUPT, 0, bits);
|
||||
bits = snd_ca0106_ptr_read(emu, EXTENDED_INT_MASK, 0);
|
||||
bits &= ~extended;
|
||||
snd_ca0106_ptr_write(emu, EXTENDED_INT_MASK, 0, bits);
|
||||
break;
|
||||
default:
|
||||
result = -EINVAL;
|
||||
|
@ -1103,21 +1136,13 @@ static int snd_ca0106_ac97(struct snd_ca0106 *chip)
|
|||
return snd_ac97_mixer(pbus, &ac97, &chip->ac97);
|
||||
}
|
||||
|
||||
static void ca0106_stop_chip(struct snd_ca0106 *chip);
|
||||
|
||||
static int snd_ca0106_free(struct snd_ca0106 *chip)
|
||||
{
|
||||
if (chip->res_port != NULL) { /* avoid access to already used hardware */
|
||||
// disable interrupts
|
||||
snd_ca0106_ptr_write(chip, BASIC_INTERRUPT, 0, 0);
|
||||
outl(0, chip->port + INTE);
|
||||
snd_ca0106_ptr_write(chip, EXTENDED_INT_MASK, 0, 0);
|
||||
udelay(1000);
|
||||
// disable audio
|
||||
//outl(HCFG_LOCKSOUNDCACHE, chip->port + HCFG);
|
||||
outl(0, chip->port + HCFG);
|
||||
/* FIXME: We need to stop and DMA transfers here.
|
||||
* But as I am not sure how yet, we cannot from the dma pages.
|
||||
* So we can fix: snd-malloc: Memory leak? pages not freed = 8
|
||||
*/
|
||||
if (chip->res_port != NULL) {
|
||||
/* avoid access to already used hardware */
|
||||
ca0106_stop_chip(chip);
|
||||
}
|
||||
if (chip->irq >= 0)
|
||||
free_irq(chip->irq, chip);
|
||||
|
@ -1203,15 +1228,14 @@ static irqreturn_t snd_ca0106_interrupt(int irq, void *dev_id)
|
|||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
static int __devinit snd_ca0106_pcm(struct snd_ca0106 *emu, int device, struct snd_pcm **rpcm)
|
||||
static int __devinit snd_ca0106_pcm(struct snd_ca0106 *emu, int device)
|
||||
{
|
||||
struct snd_pcm *pcm;
|
||||
struct snd_pcm_substream *substream;
|
||||
int err;
|
||||
|
||||
if (rpcm)
|
||||
*rpcm = NULL;
|
||||
if ((err = snd_pcm_new(emu->card, "ca0106", device, 1, 1, &pcm)) < 0)
|
||||
err = snd_pcm_new(emu->card, "ca0106", device, 1, 1, &pcm);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
pcm->private_data = emu;
|
||||
|
@ -1238,7 +1262,6 @@ static int __devinit snd_ca0106_pcm(struct snd_ca0106 *emu, int device, struct s
|
|||
pcm->info_flags = 0;
|
||||
pcm->dev_subclass = SNDRV_PCM_SUBCLASS_GENERIC_MIX;
|
||||
strcpy(pcm->name, "CA0106");
|
||||
emu->pcm = pcm;
|
||||
|
||||
for(substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream;
|
||||
substream;
|
||||
|
@ -1260,8 +1283,7 @@ static int __devinit snd_ca0106_pcm(struct snd_ca0106 *emu, int device, struct s
|
|||
return err;
|
||||
}
|
||||
|
||||
if (rpcm)
|
||||
*rpcm = pcm;
|
||||
emu->pcm[device] = pcm;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1301,89 +1323,10 @@ static unsigned int i2c_adc_init[][2] = {
|
|||
{ 0x15, ADC_MUX_LINEIN }, /* ADC Mixer control */
|
||||
};
|
||||
|
||||
static int __devinit snd_ca0106_create(int dev, struct snd_card *card,
|
||||
struct pci_dev *pci,
|
||||
struct snd_ca0106 **rchip)
|
||||
static void ca0106_init_chip(struct snd_ca0106 *chip, int resume)
|
||||
{
|
||||
struct snd_ca0106 *chip;
|
||||
struct snd_ca0106_details *c;
|
||||
int err;
|
||||
int ch;
|
||||
static struct snd_device_ops ops = {
|
||||
.dev_free = snd_ca0106_dev_free,
|
||||
};
|
||||
|
||||
*rchip = NULL;
|
||||
|
||||
if ((err = pci_enable_device(pci)) < 0)
|
||||
return err;
|
||||
if (pci_set_dma_mask(pci, DMA_32BIT_MASK) < 0 ||
|
||||
pci_set_consistent_dma_mask(pci, DMA_32BIT_MASK) < 0) {
|
||||
printk(KERN_ERR "error to set 32bit mask DMA\n");
|
||||
pci_disable_device(pci);
|
||||
return -ENXIO;
|
||||
}
|
||||
|
||||
chip = kzalloc(sizeof(*chip), GFP_KERNEL);
|
||||
if (chip == NULL) {
|
||||
pci_disable_device(pci);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
chip->card = card;
|
||||
chip->pci = pci;
|
||||
chip->irq = -1;
|
||||
|
||||
spin_lock_init(&chip->emu_lock);
|
||||
|
||||
chip->port = pci_resource_start(pci, 0);
|
||||
if ((chip->res_port = request_region(chip->port, 0x20,
|
||||
"snd_ca0106")) == NULL) {
|
||||
snd_ca0106_free(chip);
|
||||
printk(KERN_ERR "cannot allocate the port\n");
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
if (request_irq(pci->irq, snd_ca0106_interrupt,
|
||||
IRQF_SHARED, "snd_ca0106", chip)) {
|
||||
snd_ca0106_free(chip);
|
||||
printk(KERN_ERR "cannot grab irq\n");
|
||||
return -EBUSY;
|
||||
}
|
||||
chip->irq = pci->irq;
|
||||
|
||||
/* This stores the periods table. */
|
||||
if(snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), 1024, &chip->buffer) < 0) {
|
||||
snd_ca0106_free(chip);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
pci_set_master(pci);
|
||||
/* read serial */
|
||||
pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &chip->serial);
|
||||
pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &chip->model);
|
||||
#if 1
|
||||
printk(KERN_INFO "snd-ca0106: Model %04x Rev %08x Serial %08x\n", chip->model,
|
||||
pci->revision, chip->serial);
|
||||
#endif
|
||||
strcpy(card->driver, "CA0106");
|
||||
strcpy(card->shortname, "CA0106");
|
||||
|
||||
for (c = ca0106_chip_details; c->serial; c++) {
|
||||
if (subsystem[dev]) {
|
||||
if (c->serial == subsystem[dev])
|
||||
break;
|
||||
} else if (c->serial == chip->serial)
|
||||
break;
|
||||
}
|
||||
chip->details = c;
|
||||
if (subsystem[dev]) {
|
||||
printk(KERN_INFO "snd-ca0106: Sound card name=%s, subsystem=0x%x. Forced to subsystem=0x%x\n",
|
||||
c->name, chip->serial, subsystem[dev]);
|
||||
}
|
||||
|
||||
sprintf(card->longname, "%s at 0x%lx irq %i",
|
||||
c->name, chip->port, chip->irq);
|
||||
unsigned int def_bits;
|
||||
|
||||
outl(0, chip->port + INTE);
|
||||
|
||||
|
@ -1401,31 +1344,22 @@ static int __devinit snd_ca0106_create(int dev, struct snd_card *card,
|
|||
* AN = 0 (Audio data)
|
||||
* P = 0 (Consumer)
|
||||
*/
|
||||
snd_ca0106_ptr_write(chip, SPCS0, 0,
|
||||
chip->spdif_bits[0] =
|
||||
SPCS_CLKACCY_1000PPM | SPCS_SAMPLERATE_48 |
|
||||
SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC |
|
||||
SPCS_GENERATIONSTATUS | 0x00001200 |
|
||||
0x00000000 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT);
|
||||
def_bits =
|
||||
SPCS_CLKACCY_1000PPM | SPCS_SAMPLERATE_48 |
|
||||
SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC |
|
||||
SPCS_GENERATIONSTATUS | 0x00001200 |
|
||||
0x00000000 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT;
|
||||
if (!resume) {
|
||||
chip->spdif_str_bits[0] = chip->spdif_bits[0] = def_bits;
|
||||
chip->spdif_str_bits[1] = chip->spdif_bits[1] = def_bits;
|
||||
chip->spdif_str_bits[2] = chip->spdif_bits[2] = def_bits;
|
||||
chip->spdif_str_bits[3] = chip->spdif_bits[3] = def_bits;
|
||||
}
|
||||
/* Only SPCS1 has been tested */
|
||||
snd_ca0106_ptr_write(chip, SPCS1, 0,
|
||||
chip->spdif_bits[1] =
|
||||
SPCS_CLKACCY_1000PPM | SPCS_SAMPLERATE_48 |
|
||||
SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC |
|
||||
SPCS_GENERATIONSTATUS | 0x00001200 |
|
||||
0x00000000 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT);
|
||||
snd_ca0106_ptr_write(chip, SPCS2, 0,
|
||||
chip->spdif_bits[2] =
|
||||
SPCS_CLKACCY_1000PPM | SPCS_SAMPLERATE_48 |
|
||||
SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC |
|
||||
SPCS_GENERATIONSTATUS | 0x00001200 |
|
||||
0x00000000 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT);
|
||||
snd_ca0106_ptr_write(chip, SPCS3, 0,
|
||||
chip->spdif_bits[3] =
|
||||
SPCS_CLKACCY_1000PPM | SPCS_SAMPLERATE_48 |
|
||||
SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC |
|
||||
SPCS_GENERATIONSTATUS | 0x00001200 |
|
||||
0x00000000 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT);
|
||||
snd_ca0106_ptr_write(chip, SPCS1, 0, chip->spdif_str_bits[1]);
|
||||
snd_ca0106_ptr_write(chip, SPCS0, 0, chip->spdif_str_bits[0]);
|
||||
snd_ca0106_ptr_write(chip, SPCS2, 0, chip->spdif_str_bits[2]);
|
||||
snd_ca0106_ptr_write(chip, SPCS3, 0, chip->spdif_str_bits[3]);
|
||||
|
||||
snd_ca0106_ptr_write(chip, PLAYBACK_MUTE, 0, 0x00fc0000);
|
||||
snd_ca0106_ptr_write(chip, CAPTURE_MUTE, 0, 0x00fc0000);
|
||||
|
@ -1433,92 +1367,124 @@ static int __devinit snd_ca0106_create(int dev, struct snd_card *card,
|
|||
/* Write 0x8000 to AC97_REC_GAIN to mute it. */
|
||||
outb(AC97_REC_GAIN, chip->port + AC97ADDRESS);
|
||||
outw(0x8000, chip->port + AC97DATA);
|
||||
#if 0
|
||||
#if 0 /* FIXME: what are these? */
|
||||
snd_ca0106_ptr_write(chip, SPCS0, 0, 0x2108006);
|
||||
snd_ca0106_ptr_write(chip, 0x42, 0, 0x2108006);
|
||||
snd_ca0106_ptr_write(chip, 0x43, 0, 0x2108006);
|
||||
snd_ca0106_ptr_write(chip, 0x44, 0, 0x2108006);
|
||||
#endif
|
||||
|
||||
//snd_ca0106_ptr_write(chip, SPDIF_SELECT2, 0, 0xf0f003f); /* OSS drivers set this. */
|
||||
/* OSS drivers set this. */
|
||||
/* snd_ca0106_ptr_write(chip, SPDIF_SELECT2, 0, 0xf0f003f); */
|
||||
|
||||
/* Analog or Digital output */
|
||||
snd_ca0106_ptr_write(chip, SPDIF_SELECT1, 0, 0xf);
|
||||
snd_ca0106_ptr_write(chip, SPDIF_SELECT2, 0, 0x000f0000); /* 0x0b000000 for digital, 0x000b0000 for analog, from win2000 drivers. Use 0x000f0000 for surround71 */
|
||||
chip->spdif_enable = 0; /* Set digital SPDIF output off */
|
||||
//snd_ca0106_ptr_write(chip, 0x45, 0, 0); /* Analogue out */
|
||||
//snd_ca0106_ptr_write(chip, 0x45, 0, 0xf00); /* Digital out */
|
||||
/* 0x0b000000 for digital, 0x000b0000 for analog, from win2000 drivers.
|
||||
* Use 0x000f0000 for surround71
|
||||
*/
|
||||
snd_ca0106_ptr_write(chip, SPDIF_SELECT2, 0, 0x000f0000);
|
||||
|
||||
chip->spdif_enable = 0; /* Set digital SPDIF output off */
|
||||
/*snd_ca0106_ptr_write(chip, 0x45, 0, 0);*/ /* Analogue out */
|
||||
/*snd_ca0106_ptr_write(chip, 0x45, 0, 0xf00);*/ /* Digital out */
|
||||
|
||||
/* goes to 0x40c80000 when doing SPDIF IN/OUT */
|
||||
snd_ca0106_ptr_write(chip, CAPTURE_CONTROL, 0, 0x40c81000);
|
||||
/* (Mute) CAPTURE feedback into PLAYBACK volume.
|
||||
* Only lower 16 bits matter.
|
||||
*/
|
||||
snd_ca0106_ptr_write(chip, CAPTURE_CONTROL, 1, 0xffffffff);
|
||||
/* SPDIF IN Volume */
|
||||
snd_ca0106_ptr_write(chip, CAPTURE_CONTROL, 2, 0x30300000);
|
||||
/* SPDIF IN Volume, 0x70 = (vol & 0x3f) | 0x40 */
|
||||
snd_ca0106_ptr_write(chip, CAPTURE_CONTROL, 3, 0x00700000);
|
||||
|
||||
snd_ca0106_ptr_write(chip, CAPTURE_CONTROL, 0, 0x40c81000); /* goes to 0x40c80000 when doing SPDIF IN/OUT */
|
||||
snd_ca0106_ptr_write(chip, CAPTURE_CONTROL, 1, 0xffffffff); /* (Mute) CAPTURE feedback into PLAYBACK volume. Only lower 16 bits matter. */
|
||||
snd_ca0106_ptr_write(chip, CAPTURE_CONTROL, 2, 0x30300000); /* SPDIF IN Volume */
|
||||
snd_ca0106_ptr_write(chip, CAPTURE_CONTROL, 3, 0x00700000); /* SPDIF IN Volume, 0x70 = (vol & 0x3f) | 0x40 */
|
||||
snd_ca0106_ptr_write(chip, PLAYBACK_ROUTING1, 0, 0x32765410);
|
||||
snd_ca0106_ptr_write(chip, PLAYBACK_ROUTING2, 0, 0x76767676);
|
||||
snd_ca0106_ptr_write(chip, CAPTURE_ROUTING1, 0, 0x32765410);
|
||||
snd_ca0106_ptr_write(chip, CAPTURE_ROUTING2, 0, 0x76767676);
|
||||
for(ch = 0; ch < 4; ch++) {
|
||||
snd_ca0106_ptr_write(chip, CAPTURE_VOLUME1, ch, 0x30303030); /* Only high 16 bits matter */
|
||||
|
||||
for (ch = 0; ch < 4; ch++) {
|
||||
/* Only high 16 bits matter */
|
||||
snd_ca0106_ptr_write(chip, CAPTURE_VOLUME1, ch, 0x30303030);
|
||||
snd_ca0106_ptr_write(chip, CAPTURE_VOLUME2, ch, 0x30303030);
|
||||
//snd_ca0106_ptr_write(chip, PLAYBACK_VOLUME1, ch, 0x40404040); /* Mute */
|
||||
//snd_ca0106_ptr_write(chip, PLAYBACK_VOLUME2, ch, 0x40404040); /* Mute */
|
||||
snd_ca0106_ptr_write(chip, PLAYBACK_VOLUME1, ch, 0xffffffff); /* Mute */
|
||||
snd_ca0106_ptr_write(chip, PLAYBACK_VOLUME2, ch, 0xffffffff); /* Mute */
|
||||
#if 0 /* Mute */
|
||||
snd_ca0106_ptr_write(chip, PLAYBACK_VOLUME1, ch, 0x40404040);
|
||||
snd_ca0106_ptr_write(chip, PLAYBACK_VOLUME2, ch, 0x40404040);
|
||||
snd_ca0106_ptr_write(chip, PLAYBACK_VOLUME1, ch, 0xffffffff);
|
||||
snd_ca0106_ptr_write(chip, PLAYBACK_VOLUME2, ch, 0xffffffff);
|
||||
#endif
|
||||
}
|
||||
if (chip->details->i2c_adc == 1) {
|
||||
/* Select MIC, Line in, TAD in, AUX in */
|
||||
snd_ca0106_ptr_write(chip, CAPTURE_SOURCE, 0x0, 0x333300e4);
|
||||
/* Default to CAPTURE_SOURCE to i2s in */
|
||||
chip->capture_source = 3;
|
||||
if (!resume)
|
||||
chip->capture_source = 3;
|
||||
} else if (chip->details->ac97 == 1) {
|
||||
/* Default to AC97 in */
|
||||
snd_ca0106_ptr_write(chip, CAPTURE_SOURCE, 0x0, 0x444400e4);
|
||||
/* Default to CAPTURE_SOURCE to AC97 in */
|
||||
chip->capture_source = 4;
|
||||
if (!resume)
|
||||
chip->capture_source = 4;
|
||||
} else {
|
||||
/* Select MIC, Line in, TAD in, AUX in */
|
||||
snd_ca0106_ptr_write(chip, CAPTURE_SOURCE, 0x0, 0x333300e4);
|
||||
/* Default to Set CAPTURE_SOURCE to i2s in */
|
||||
chip->capture_source = 3;
|
||||
if (!resume)
|
||||
chip->capture_source = 3;
|
||||
}
|
||||
|
||||
if (chip->details->gpio_type == 2) { /* The SB0438 use GPIO differently. */
|
||||
/* FIXME: Still need to find out what the other GPIO bits do. E.g. For digital spdif out. */
|
||||
if (chip->details->gpio_type == 2) {
|
||||
/* The SB0438 use GPIO differently. */
|
||||
/* FIXME: Still need to find out what the other GPIO bits do.
|
||||
* E.g. For digital spdif out.
|
||||
*/
|
||||
outl(0x0, chip->port+GPIO);
|
||||
//outl(0x00f0e000, chip->port+GPIO); /* Analog */
|
||||
/* outl(0x00f0e000, chip->port+GPIO); */ /* Analog */
|
||||
outl(0x005f5301, chip->port+GPIO); /* Analog */
|
||||
} else if (chip->details->gpio_type == 1) { /* The SB0410 and SB0413 use GPIO differently. */
|
||||
/* FIXME: Still need to find out what the other GPIO bits do. E.g. For digital spdif out. */
|
||||
} else if (chip->details->gpio_type == 1) {
|
||||
/* The SB0410 and SB0413 use GPIO differently. */
|
||||
/* FIXME: Still need to find out what the other GPIO bits do.
|
||||
* E.g. For digital spdif out.
|
||||
*/
|
||||
outl(0x0, chip->port+GPIO);
|
||||
//outl(0x00f0e000, chip->port+GPIO); /* Analog */
|
||||
/* outl(0x00f0e000, chip->port+GPIO); */ /* Analog */
|
||||
outl(0x005f5301, chip->port+GPIO); /* Analog */
|
||||
} else {
|
||||
outl(0x0, chip->port+GPIO);
|
||||
outl(0x005f03a3, chip->port+GPIO); /* Analog */
|
||||
//outl(0x005f02a2, chip->port+GPIO); /* SPDIF */
|
||||
/* outl(0x005f02a2, chip->port+GPIO); */ /* SPDIF */
|
||||
}
|
||||
snd_ca0106_intr_enable(chip, 0x105); /* Win2000 uses 0x1e0 */
|
||||
|
||||
//outl(HCFG_LOCKSOUNDCACHE|HCFG_AUDIOENABLE, chip->port+HCFG);
|
||||
//outl(0x00001409, chip->port+HCFG); /* 0x1000 causes AC3 to fails. Maybe it effects 24 bit output. */
|
||||
//outl(0x00000009, chip->port+HCFG);
|
||||
outl(HCFG_AC97 | HCFG_AUDIOENABLE, chip->port+HCFG); /* AC97 2.0, Enable outputs. */
|
||||
/* outl(HCFG_LOCKSOUNDCACHE|HCFG_AUDIOENABLE, chip->port+HCFG); */
|
||||
/* 0x1000 causes AC3 to fails. Maybe it effects 24 bit output. */
|
||||
/* outl(0x00001409, chip->port+HCFG); */
|
||||
/* outl(0x00000009, chip->port+HCFG); */
|
||||
/* AC97 2.0, Enable outputs. */
|
||||
outl(HCFG_AC97 | HCFG_AUDIOENABLE, chip->port+HCFG);
|
||||
|
||||
if (chip->details->i2c_adc == 1) { /* The SB0410 and SB0413 use I2C to control ADC. */
|
||||
if (chip->details->i2c_adc == 1) {
|
||||
/* The SB0410 and SB0413 use I2C to control ADC. */
|
||||
int size, n;
|
||||
|
||||
size = ARRAY_SIZE(i2c_adc_init);
|
||||
//snd_printk("I2C:array size=0x%x\n", size);
|
||||
for (n=0; n < size; n++) {
|
||||
snd_ca0106_i2c_write(chip, i2c_adc_init[n][0], i2c_adc_init[n][1]);
|
||||
/* snd_printk("I2C:array size=0x%x\n", size); */
|
||||
for (n = 0; n < size; n++)
|
||||
snd_ca0106_i2c_write(chip, i2c_adc_init[n][0],
|
||||
i2c_adc_init[n][1]);
|
||||
for (n = 0; n < 4; n++) {
|
||||
chip->i2c_capture_volume[n][0] = 0xcf;
|
||||
chip->i2c_capture_volume[n][1] = 0xcf;
|
||||
}
|
||||
for (n=0; n < 4; n++) {
|
||||
chip->i2c_capture_volume[n][0]= 0xcf;
|
||||
chip->i2c_capture_volume[n][1]= 0xcf;
|
||||
}
|
||||
chip->i2c_capture_source=2; /* Line in */
|
||||
//snd_ca0106_i2c_write(chip, ADC_MUX, ADC_MUX_LINEIN); /* Enable Line-in capture. MIC in currently untested. */
|
||||
chip->i2c_capture_source = 2; /* Line in */
|
||||
/* Enable Line-in capture. MIC in currently untested. */
|
||||
/* snd_ca0106_i2c_write(chip, ADC_MUX, ADC_MUX_LINEIN); */
|
||||
}
|
||||
if (chip->details->spi_dac == 1) { /* The SB0570 use SPI to control DAC. */
|
||||
|
||||
if (chip->details->spi_dac == 1) {
|
||||
/* The SB0570 use SPI to control DAC. */
|
||||
int size, n;
|
||||
|
||||
size = ARRAY_SIZE(spi_dac_init);
|
||||
|
@ -1530,9 +1496,112 @@ static int __devinit snd_ca0106_create(int dev, struct snd_card *card,
|
|||
chip->spi_dac_reg[reg] = spi_dac_init[n];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL,
|
||||
chip, &ops)) < 0) {
|
||||
static void ca0106_stop_chip(struct snd_ca0106 *chip)
|
||||
{
|
||||
/* disable interrupts */
|
||||
snd_ca0106_ptr_write(chip, BASIC_INTERRUPT, 0, 0);
|
||||
outl(0, chip->port + INTE);
|
||||
snd_ca0106_ptr_write(chip, EXTENDED_INT_MASK, 0, 0);
|
||||
udelay(1000);
|
||||
/* disable audio */
|
||||
/* outl(HCFG_LOCKSOUNDCACHE, chip->port + HCFG); */
|
||||
outl(0, chip->port + HCFG);
|
||||
/* FIXME: We need to stop and DMA transfers here.
|
||||
* But as I am not sure how yet, we cannot from the dma pages.
|
||||
* So we can fix: snd-malloc: Memory leak? pages not freed = 8
|
||||
*/
|
||||
}
|
||||
|
||||
static int __devinit snd_ca0106_create(int dev, struct snd_card *card,
|
||||
struct pci_dev *pci,
|
||||
struct snd_ca0106 **rchip)
|
||||
{
|
||||
struct snd_ca0106 *chip;
|
||||
struct snd_ca0106_details *c;
|
||||
int err;
|
||||
static struct snd_device_ops ops = {
|
||||
.dev_free = snd_ca0106_dev_free,
|
||||
};
|
||||
|
||||
*rchip = NULL;
|
||||
|
||||
err = pci_enable_device(pci);
|
||||
if (err < 0)
|
||||
return err;
|
||||
if (pci_set_dma_mask(pci, DMA_32BIT_MASK) < 0 ||
|
||||
pci_set_consistent_dma_mask(pci, DMA_32BIT_MASK) < 0) {
|
||||
printk(KERN_ERR "error to set 32bit mask DMA\n");
|
||||
pci_disable_device(pci);
|
||||
return -ENXIO;
|
||||
}
|
||||
|
||||
chip = kzalloc(sizeof(*chip), GFP_KERNEL);
|
||||
if (chip == NULL) {
|
||||
pci_disable_device(pci);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
chip->card = card;
|
||||
chip->pci = pci;
|
||||
chip->irq = -1;
|
||||
|
||||
spin_lock_init(&chip->emu_lock);
|
||||
|
||||
chip->port = pci_resource_start(pci, 0);
|
||||
chip->res_port = request_region(chip->port, 0x20, "snd_ca0106");
|
||||
if (!chip->res_port) {
|
||||
snd_ca0106_free(chip);
|
||||
printk(KERN_ERR "cannot allocate the port\n");
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
if (request_irq(pci->irq, snd_ca0106_interrupt,
|
||||
IRQF_SHARED, "snd_ca0106", chip)) {
|
||||
snd_ca0106_free(chip);
|
||||
printk(KERN_ERR "cannot grab irq\n");
|
||||
return -EBUSY;
|
||||
}
|
||||
chip->irq = pci->irq;
|
||||
|
||||
/* This stores the periods table. */
|
||||
if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
|
||||
1024, &chip->buffer) < 0) {
|
||||
snd_ca0106_free(chip);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
pci_set_master(pci);
|
||||
/* read serial */
|
||||
pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &chip->serial);
|
||||
pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &chip->model);
|
||||
printk(KERN_INFO "snd-ca0106: Model %04x Rev %08x Serial %08x\n",
|
||||
chip->model, pci->revision, chip->serial);
|
||||
strcpy(card->driver, "CA0106");
|
||||
strcpy(card->shortname, "CA0106");
|
||||
|
||||
for (c = ca0106_chip_details; c->serial; c++) {
|
||||
if (subsystem[dev]) {
|
||||
if (c->serial == subsystem[dev])
|
||||
break;
|
||||
} else if (c->serial == chip->serial)
|
||||
break;
|
||||
}
|
||||
chip->details = c;
|
||||
if (subsystem[dev]) {
|
||||
printk(KERN_INFO "snd-ca0106: Sound card name=%s, "
|
||||
"subsystem=0x%x. Forced to subsystem=0x%x\n",
|
||||
c->name, chip->serial, subsystem[dev]);
|
||||
}
|
||||
|
||||
sprintf(card->longname, "%s at 0x%lx irq %i",
|
||||
c->name, chip->port, chip->irq);
|
||||
|
||||
ca0106_init_chip(chip, 0);
|
||||
|
||||
err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
|
||||
if (err < 0) {
|
||||
snd_ca0106_free(chip);
|
||||
return err;
|
||||
}
|
||||
|
@ -1629,7 +1698,7 @@ static int __devinit snd_ca0106_probe(struct pci_dev *pci,
|
|||
static int dev;
|
||||
struct snd_card *card;
|
||||
struct snd_ca0106 *chip;
|
||||
int err;
|
||||
int i, err;
|
||||
|
||||
if (dev >= SNDRV_CARDS)
|
||||
return -ENODEV;
|
||||
|
@ -1642,44 +1711,31 @@ static int __devinit snd_ca0106_probe(struct pci_dev *pci,
|
|||
if (card == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
if ((err = snd_ca0106_create(dev, card, pci, &chip)) < 0) {
|
||||
snd_card_free(card);
|
||||
return err;
|
||||
err = snd_ca0106_create(dev, card, pci, &chip);
|
||||
if (err < 0)
|
||||
goto error;
|
||||
card->private_data = chip;
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
err = snd_ca0106_pcm(chip, i);
|
||||
if (err < 0)
|
||||
goto error;
|
||||
}
|
||||
|
||||
if ((err = snd_ca0106_pcm(chip, 0, NULL)) < 0) {
|
||||
snd_card_free(card);
|
||||
return err;
|
||||
}
|
||||
if ((err = snd_ca0106_pcm(chip, 1, NULL)) < 0) {
|
||||
snd_card_free(card);
|
||||
return err;
|
||||
}
|
||||
if ((err = snd_ca0106_pcm(chip, 2, NULL)) < 0) {
|
||||
snd_card_free(card);
|
||||
return err;
|
||||
}
|
||||
if ((err = snd_ca0106_pcm(chip, 3, NULL)) < 0) {
|
||||
snd_card_free(card);
|
||||
return err;
|
||||
}
|
||||
if (chip->details->ac97 == 1) { /* The SB0410 and SB0413 do not have an AC97 chip. */
|
||||
if ((err = snd_ca0106_ac97(chip)) < 0) {
|
||||
snd_card_free(card);
|
||||
return err;
|
||||
}
|
||||
}
|
||||
if ((err = snd_ca0106_mixer(chip)) < 0) {
|
||||
snd_card_free(card);
|
||||
return err;
|
||||
if (chip->details->ac97 == 1) {
|
||||
/* The SB0410 and SB0413 do not have an AC97 chip. */
|
||||
err = snd_ca0106_ac97(chip);
|
||||
if (err < 0)
|
||||
goto error;
|
||||
}
|
||||
err = snd_ca0106_mixer(chip);
|
||||
if (err < 0)
|
||||
goto error;
|
||||
|
||||
snd_printdd("ca0106: probe for MIDI channel A ...");
|
||||
if ((err = snd_ca0106_midi(chip,CA0106_MIDI_CHAN_A)) < 0) {
|
||||
snd_card_free(card);
|
||||
snd_printdd(" failed, err=0x%x\n",err);
|
||||
return err;
|
||||
}
|
||||
err = snd_ca0106_midi(chip, CA0106_MIDI_CHAN_A);
|
||||
if (err < 0)
|
||||
goto error;
|
||||
snd_printdd(" done.\n");
|
||||
|
||||
#ifdef CONFIG_PROC_FS
|
||||
|
@ -1688,14 +1744,17 @@ static int __devinit snd_ca0106_probe(struct pci_dev *pci,
|
|||
|
||||
snd_card_set_dev(card, &pci->dev);
|
||||
|
||||
if ((err = snd_card_register(card)) < 0) {
|
||||
snd_card_free(card);
|
||||
return err;
|
||||
}
|
||||
err = snd_card_register(card);
|
||||
if (err < 0)
|
||||
goto error;
|
||||
|
||||
pci_set_drvdata(pci, card);
|
||||
dev++;
|
||||
return 0;
|
||||
|
||||
error:
|
||||
snd_card_free(card);
|
||||
return err;
|
||||
}
|
||||
|
||||
static void __devexit snd_ca0106_remove(struct pci_dev *pci)
|
||||
|
@ -1704,6 +1763,59 @@ static void __devexit snd_ca0106_remove(struct pci_dev *pci)
|
|||
pci_set_drvdata(pci, NULL);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
static int snd_ca0106_suspend(struct pci_dev *pci, pm_message_t state)
|
||||
{
|
||||
struct snd_card *card = pci_get_drvdata(pci);
|
||||
struct snd_ca0106 *chip = card->private_data;
|
||||
int i;
|
||||
|
||||
snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
|
||||
for (i = 0; i < 4; i++)
|
||||
snd_pcm_suspend_all(chip->pcm[i]);
|
||||
if (chip->details->ac97)
|
||||
snd_ac97_suspend(chip->ac97);
|
||||
snd_ca0106_mixer_suspend(chip);
|
||||
|
||||
ca0106_stop_chip(chip);
|
||||
|
||||
pci_disable_device(pci);
|
||||
pci_save_state(pci);
|
||||
pci_set_power_state(pci, pci_choose_state(pci, state));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int snd_ca0106_resume(struct pci_dev *pci)
|
||||
{
|
||||
struct snd_card *card = pci_get_drvdata(pci);
|
||||
struct snd_ca0106 *chip = card->private_data;
|
||||
int i;
|
||||
|
||||
pci_set_power_state(pci, PCI_D0);
|
||||
pci_restore_state(pci);
|
||||
|
||||
if (pci_enable_device(pci) < 0) {
|
||||
snd_card_disconnect(card);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
pci_set_master(pci);
|
||||
|
||||
ca0106_init_chip(chip, 1);
|
||||
|
||||
if (chip->details->ac97)
|
||||
snd_ac97_resume(chip->ac97);
|
||||
snd_ca0106_mixer_resume(chip);
|
||||
if (chip->details->spi_dac) {
|
||||
for (i = 0; i < ARRAY_SIZE(chip->spi_dac_reg); i++)
|
||||
snd_ca0106_spi_write(chip, chip->spi_dac_reg[i]);
|
||||
}
|
||||
|
||||
snd_power_change_state(card, SNDRV_CTL_POWER_D0);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
// PCI IDs
|
||||
static struct pci_device_id snd_ca0106_ids[] = {
|
||||
{ 0x1102, 0x0007, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* Audigy LS or Live 24bit */
|
||||
|
@ -1717,6 +1829,10 @@ static struct pci_driver driver = {
|
|||
.id_table = snd_ca0106_ids,
|
||||
.probe = snd_ca0106_probe,
|
||||
.remove = __devexit_p(snd_ca0106_remove),
|
||||
#ifdef CONFIG_PM
|
||||
.suspend = snd_ca0106_suspend,
|
||||
.resume = snd_ca0106_resume,
|
||||
#endif
|
||||
};
|
||||
|
||||
// initialization of the module
|
||||
|
|
|
@ -75,6 +75,84 @@
|
|||
|
||||
#include "ca0106.h"
|
||||
|
||||
static void ca0106_spdif_enable(struct snd_ca0106 *emu)
|
||||
{
|
||||
unsigned int val;
|
||||
|
||||
if (emu->spdif_enable) {
|
||||
/* Digital */
|
||||
snd_ca0106_ptr_write(emu, SPDIF_SELECT1, 0, 0xf);
|
||||
snd_ca0106_ptr_write(emu, SPDIF_SELECT2, 0, 0x0b000000);
|
||||
val = snd_ca0106_ptr_read(emu, CAPTURE_CONTROL, 0) & ~0x1000;
|
||||
snd_ca0106_ptr_write(emu, CAPTURE_CONTROL, 0, val);
|
||||
val = inl(emu->port + GPIO) & ~0x101;
|
||||
outl(val, emu->port + GPIO);
|
||||
|
||||
} else {
|
||||
/* Analog */
|
||||
snd_ca0106_ptr_write(emu, SPDIF_SELECT1, 0, 0xf);
|
||||
snd_ca0106_ptr_write(emu, SPDIF_SELECT2, 0, 0x000f0000);
|
||||
val = snd_ca0106_ptr_read(emu, CAPTURE_CONTROL, 0) | 0x1000;
|
||||
snd_ca0106_ptr_write(emu, CAPTURE_CONTROL, 0, val);
|
||||
val = inl(emu->port + GPIO) | 0x101;
|
||||
outl(val, emu->port + GPIO);
|
||||
}
|
||||
}
|
||||
|
||||
static void ca0106_set_capture_source(struct snd_ca0106 *emu)
|
||||
{
|
||||
unsigned int val = emu->capture_source;
|
||||
unsigned int source, mask;
|
||||
source = (val << 28) | (val << 24) | (val << 20) | (val << 16);
|
||||
mask = snd_ca0106_ptr_read(emu, CAPTURE_SOURCE, 0) & 0xffff;
|
||||
snd_ca0106_ptr_write(emu, CAPTURE_SOURCE, 0, source | mask);
|
||||
}
|
||||
|
||||
static void ca0106_set_i2c_capture_source(struct snd_ca0106 *emu,
|
||||
unsigned int val, int force)
|
||||
{
|
||||
unsigned int ngain, ogain;
|
||||
u32 source;
|
||||
|
||||
snd_ca0106_i2c_write(emu, ADC_MUX, 0); /* Mute input */
|
||||
ngain = emu->i2c_capture_volume[val][0]; /* Left */
|
||||
ogain = emu->i2c_capture_volume[emu->i2c_capture_source][0]; /* Left */
|
||||
if (force || ngain != ogain)
|
||||
snd_ca0106_i2c_write(emu, ADC_ATTEN_ADCL, ngain & 0xff);
|
||||
ngain = emu->i2c_capture_volume[val][1]; /* Right */
|
||||
ogain = emu->i2c_capture_volume[emu->i2c_capture_source][1]; /* Right */
|
||||
if (force || ngain != ogain)
|
||||
snd_ca0106_i2c_write(emu, ADC_ATTEN_ADCR, ngain & 0xff);
|
||||
source = 1 << val;
|
||||
snd_ca0106_i2c_write(emu, ADC_MUX, source); /* Set source */
|
||||
emu->i2c_capture_source = val;
|
||||
}
|
||||
|
||||
static void ca0106_set_capture_mic_line_in(struct snd_ca0106 *emu)
|
||||
{
|
||||
u32 tmp;
|
||||
|
||||
if (emu->capture_mic_line_in) {
|
||||
/* snd_ca0106_i2c_write(emu, ADC_MUX, 0); */ /* Mute input */
|
||||
tmp = inl(emu->port+GPIO) & ~0x400;
|
||||
tmp = tmp | 0x400;
|
||||
outl(tmp, emu->port+GPIO);
|
||||
/* snd_ca0106_i2c_write(emu, ADC_MUX, ADC_MUX_MIC); */
|
||||
} else {
|
||||
/* snd_ca0106_i2c_write(emu, ADC_MUX, 0); */ /* Mute input */
|
||||
tmp = inl(emu->port+GPIO) & ~0x400;
|
||||
outl(tmp, emu->port+GPIO);
|
||||
/* snd_ca0106_i2c_write(emu, ADC_MUX, ADC_MUX_LINEIN); */
|
||||
}
|
||||
}
|
||||
|
||||
static void ca0106_set_spdif_bits(struct snd_ca0106 *emu, int idx)
|
||||
{
|
||||
snd_ca0106_ptr_write(emu, SPCS0 + idx, 0, emu->spdif_str_bits[idx]);
|
||||
}
|
||||
|
||||
/*
|
||||
*/
|
||||
static const DECLARE_TLV_DB_SCALE(snd_ca0106_db_scale1, -5175, 25, 1);
|
||||
static const DECLARE_TLV_DB_SCALE(snd_ca0106_db_scale2, -10350, 50, 1);
|
||||
|
||||
|
@ -95,30 +173,12 @@ static int snd_ca0106_shared_spdif_put(struct snd_kcontrol *kcontrol,
|
|||
struct snd_ca0106 *emu = snd_kcontrol_chip(kcontrol);
|
||||
unsigned int val;
|
||||
int change = 0;
|
||||
u32 mask;
|
||||
|
||||
val = !!ucontrol->value.integer.value[0];
|
||||
change = (emu->spdif_enable != val);
|
||||
if (change) {
|
||||
emu->spdif_enable = val;
|
||||
if (val) {
|
||||
/* Digital */
|
||||
snd_ca0106_ptr_write(emu, SPDIF_SELECT1, 0, 0xf);
|
||||
snd_ca0106_ptr_write(emu, SPDIF_SELECT2, 0, 0x0b000000);
|
||||
snd_ca0106_ptr_write(emu, CAPTURE_CONTROL, 0,
|
||||
snd_ca0106_ptr_read(emu, CAPTURE_CONTROL, 0) & ~0x1000);
|
||||
mask = inl(emu->port + GPIO) & ~0x101;
|
||||
outl(mask, emu->port + GPIO);
|
||||
|
||||
} else {
|
||||
/* Analog */
|
||||
snd_ca0106_ptr_write(emu, SPDIF_SELECT1, 0, 0xf);
|
||||
snd_ca0106_ptr_write(emu, SPDIF_SELECT2, 0, 0x000f0000);
|
||||
snd_ca0106_ptr_write(emu, CAPTURE_CONTROL, 0,
|
||||
snd_ca0106_ptr_read(emu, CAPTURE_CONTROL, 0) | 0x1000);
|
||||
mask = inl(emu->port + GPIO) | 0x101;
|
||||
outl(mask, emu->port + GPIO);
|
||||
}
|
||||
ca0106_spdif_enable(emu);
|
||||
}
|
||||
return change;
|
||||
}
|
||||
|
@ -154,8 +214,6 @@ static int snd_ca0106_capture_source_put(struct snd_kcontrol *kcontrol,
|
|||
struct snd_ca0106 *emu = snd_kcontrol_chip(kcontrol);
|
||||
unsigned int val;
|
||||
int change = 0;
|
||||
u32 mask;
|
||||
u32 source;
|
||||
|
||||
val = ucontrol->value.enumerated.item[0] ;
|
||||
if (val >= 6)
|
||||
|
@ -163,9 +221,7 @@ static int snd_ca0106_capture_source_put(struct snd_kcontrol *kcontrol,
|
|||
change = (emu->capture_source != val);
|
||||
if (change) {
|
||||
emu->capture_source = val;
|
||||
source = (val << 28) | (val << 24) | (val << 20) | (val << 16);
|
||||
mask = snd_ca0106_ptr_read(emu, CAPTURE_SOURCE, 0) & 0xffff;
|
||||
snd_ca0106_ptr_write(emu, CAPTURE_SOURCE, 0, source | mask);
|
||||
ca0106_set_capture_source(emu);
|
||||
}
|
||||
return change;
|
||||
}
|
||||
|
@ -200,9 +256,7 @@ static int snd_ca0106_i2c_capture_source_put(struct snd_kcontrol *kcontrol,
|
|||
{
|
||||
struct snd_ca0106 *emu = snd_kcontrol_chip(kcontrol);
|
||||
unsigned int source_id;
|
||||
unsigned int ngain, ogain;
|
||||
int change = 0;
|
||||
u32 source;
|
||||
/* If the capture source has changed,
|
||||
* update the capture volume from the cached value
|
||||
* for the particular source.
|
||||
|
@ -212,18 +266,7 @@ static int snd_ca0106_i2c_capture_source_put(struct snd_kcontrol *kcontrol,
|
|||
return -EINVAL;
|
||||
change = (emu->i2c_capture_source != source_id);
|
||||
if (change) {
|
||||
snd_ca0106_i2c_write(emu, ADC_MUX, 0); /* Mute input */
|
||||
ngain = emu->i2c_capture_volume[source_id][0]; /* Left */
|
||||
ogain = emu->i2c_capture_volume[emu->i2c_capture_source][0]; /* Left */
|
||||
if (ngain != ogain)
|
||||
snd_ca0106_i2c_write(emu, ADC_ATTEN_ADCL, ((ngain) & 0xff));
|
||||
ngain = emu->i2c_capture_volume[source_id][1]; /* Left */
|
||||
ogain = emu->i2c_capture_volume[emu->i2c_capture_source][1]; /* Left */
|
||||
if (ngain != ogain)
|
||||
snd_ca0106_i2c_write(emu, ADC_ATTEN_ADCR, ((ngain) & 0xff));
|
||||
source = 1 << source_id;
|
||||
snd_ca0106_i2c_write(emu, ADC_MUX, source); /* Set source */
|
||||
emu->i2c_capture_source = source_id;
|
||||
ca0106_set_i2c_capture_source(emu, source_id, 0);
|
||||
}
|
||||
return change;
|
||||
}
|
||||
|
@ -271,7 +314,6 @@ static int snd_ca0106_capture_mic_line_in_put(struct snd_kcontrol *kcontrol,
|
|||
struct snd_ca0106 *emu = snd_kcontrol_chip(kcontrol);
|
||||
unsigned int val;
|
||||
int change = 0;
|
||||
u32 tmp;
|
||||
|
||||
val = ucontrol->value.enumerated.item[0] ;
|
||||
if (val > 1)
|
||||
|
@ -279,18 +321,7 @@ static int snd_ca0106_capture_mic_line_in_put(struct snd_kcontrol *kcontrol,
|
|||
change = (emu->capture_mic_line_in != val);
|
||||
if (change) {
|
||||
emu->capture_mic_line_in = val;
|
||||
if (val) {
|
||||
//snd_ca0106_i2c_write(emu, ADC_MUX, 0); /* Mute input */
|
||||
tmp = inl(emu->port+GPIO) & ~0x400;
|
||||
tmp = tmp | 0x400;
|
||||
outl(tmp, emu->port+GPIO);
|
||||
//snd_ca0106_i2c_write(emu, ADC_MUX, ADC_MUX_MIC);
|
||||
} else {
|
||||
//snd_ca0106_i2c_write(emu, ADC_MUX, 0); /* Mute input */
|
||||
tmp = inl(emu->port+GPIO) & ~0x400;
|
||||
outl(tmp, emu->port+GPIO);
|
||||
//snd_ca0106_i2c_write(emu, ADC_MUX, ADC_MUX_LINEIN);
|
||||
}
|
||||
ca0106_set_capture_mic_line_in(emu);
|
||||
}
|
||||
return change;
|
||||
}
|
||||
|
@ -322,16 +353,33 @@ static int snd_ca0106_spdif_info(struct snd_kcontrol *kcontrol,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int snd_ca0106_spdif_get(struct snd_kcontrol *kcontrol,
|
||||
static void decode_spdif_bits(unsigned char *status, unsigned int bits)
|
||||
{
|
||||
status[0] = (bits >> 0) & 0xff;
|
||||
status[1] = (bits >> 8) & 0xff;
|
||||
status[2] = (bits >> 16) & 0xff;
|
||||
status[3] = (bits >> 24) & 0xff;
|
||||
}
|
||||
|
||||
static int snd_ca0106_spdif_get_default(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct snd_ca0106 *emu = snd_kcontrol_chip(kcontrol);
|
||||
unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
|
||||
|
||||
ucontrol->value.iec958.status[0] = (emu->spdif_bits[idx] >> 0) & 0xff;
|
||||
ucontrol->value.iec958.status[1] = (emu->spdif_bits[idx] >> 8) & 0xff;
|
||||
ucontrol->value.iec958.status[2] = (emu->spdif_bits[idx] >> 16) & 0xff;
|
||||
ucontrol->value.iec958.status[3] = (emu->spdif_bits[idx] >> 24) & 0xff;
|
||||
decode_spdif_bits(ucontrol->value.iec958.status,
|
||||
emu->spdif_bits[idx]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int snd_ca0106_spdif_get_stream(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct snd_ca0106 *emu = snd_kcontrol_chip(kcontrol);
|
||||
unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
|
||||
|
||||
decode_spdif_bits(ucontrol->value.iec958.status,
|
||||
emu->spdif_str_bits[idx]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -345,24 +393,48 @@ static int snd_ca0106_spdif_get_mask(struct snd_kcontrol *kcontrol,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int snd_ca0106_spdif_put(struct snd_kcontrol *kcontrol,
|
||||
static unsigned int encode_spdif_bits(unsigned char *status)
|
||||
{
|
||||
return ((unsigned int)status[0] << 0) |
|
||||
((unsigned int)status[1] << 8) |
|
||||
((unsigned int)status[2] << 16) |
|
||||
((unsigned int)status[3] << 24);
|
||||
}
|
||||
|
||||
static int snd_ca0106_spdif_put_default(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct snd_ca0106 *emu = snd_kcontrol_chip(kcontrol);
|
||||
unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
|
||||
int change;
|
||||
unsigned int val;
|
||||
|
||||
val = (ucontrol->value.iec958.status[0] << 0) |
|
||||
(ucontrol->value.iec958.status[1] << 8) |
|
||||
(ucontrol->value.iec958.status[2] << 16) |
|
||||
(ucontrol->value.iec958.status[3] << 24);
|
||||
change = val != emu->spdif_bits[idx];
|
||||
if (change) {
|
||||
snd_ca0106_ptr_write(emu, SPCS0 + idx, 0, val);
|
||||
val = encode_spdif_bits(ucontrol->value.iec958.status);
|
||||
if (val != emu->spdif_bits[idx]) {
|
||||
emu->spdif_bits[idx] = val;
|
||||
/* FIXME: this isn't safe, but needed to keep the compatibility
|
||||
* with older alsa-lib config
|
||||
*/
|
||||
emu->spdif_str_bits[idx] = val;
|
||||
ca0106_set_spdif_bits(emu, idx);
|
||||
return 1;
|
||||
}
|
||||
return change;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int snd_ca0106_spdif_put_stream(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct snd_ca0106 *emu = snd_kcontrol_chip(kcontrol);
|
||||
unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
|
||||
unsigned int val;
|
||||
|
||||
val = encode_spdif_bits(ucontrol->value.iec958.status);
|
||||
if (val != emu->spdif_str_bits[idx]) {
|
||||
emu->spdif_str_bits[idx] = val;
|
||||
ca0106_set_spdif_bits(emu, idx);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int snd_ca0106_volume_info(struct snd_kcontrol *kcontrol,
|
||||
|
@ -573,8 +645,16 @@ static struct snd_kcontrol_new snd_ca0106_volume_ctls[] __devinitdata = {
|
|||
.name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT),
|
||||
.count = 4,
|
||||
.info = snd_ca0106_spdif_info,
|
||||
.get = snd_ca0106_spdif_get,
|
||||
.put = snd_ca0106_spdif_put
|
||||
.get = snd_ca0106_spdif_get_default,
|
||||
.put = snd_ca0106_spdif_put_default
|
||||
},
|
||||
{
|
||||
.iface = SNDRV_CTL_ELEM_IFACE_PCM,
|
||||
.name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,PCM_STREAM),
|
||||
.count = 4,
|
||||
.info = snd_ca0106_spdif_info,
|
||||
.get = snd_ca0106_spdif_get_stream,
|
||||
.put = snd_ca0106_spdif_put_stream
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -773,3 +853,50 @@ int __devinit snd_ca0106_mixer(struct snd_ca0106 *emu)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
struct ca0106_vol_tbl {
|
||||
unsigned int channel_id;
|
||||
unsigned int reg;
|
||||
};
|
||||
|
||||
static struct ca0106_vol_tbl saved_volumes[NUM_SAVED_VOLUMES] = {
|
||||
{ CONTROL_FRONT_CHANNEL, PLAYBACK_VOLUME2 },
|
||||
{ CONTROL_REAR_CHANNEL, PLAYBACK_VOLUME2 },
|
||||
{ CONTROL_CENTER_LFE_CHANNEL, PLAYBACK_VOLUME2 },
|
||||
{ CONTROL_UNKNOWN_CHANNEL, PLAYBACK_VOLUME2 },
|
||||
{ CONTROL_FRONT_CHANNEL, PLAYBACK_VOLUME1 },
|
||||
{ CONTROL_REAR_CHANNEL, PLAYBACK_VOLUME1 },
|
||||
{ CONTROL_CENTER_LFE_CHANNEL, PLAYBACK_VOLUME1 },
|
||||
{ CONTROL_UNKNOWN_CHANNEL, PLAYBACK_VOLUME1 },
|
||||
{ 1, CAPTURE_CONTROL },
|
||||
};
|
||||
|
||||
void snd_ca0106_mixer_suspend(struct snd_ca0106 *chip)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* save volumes */
|
||||
for (i = 0; i < NUM_SAVED_VOLUMES; i++)
|
||||
chip->saved_vol[i] =
|
||||
snd_ca0106_ptr_read(chip, saved_volumes[i].reg,
|
||||
saved_volumes[i].channel_id);
|
||||
}
|
||||
|
||||
void snd_ca0106_mixer_resume(struct snd_ca0106 *chip)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < NUM_SAVED_VOLUMES; i++)
|
||||
snd_ca0106_ptr_write(chip, saved_volumes[i].reg,
|
||||
saved_volumes[i].channel_id,
|
||||
chip->saved_vol[i]);
|
||||
|
||||
ca0106_spdif_enable(chip);
|
||||
ca0106_set_capture_source(chip);
|
||||
ca0106_set_i2c_capture_source(chip, chip->i2c_capture_source, 1);
|
||||
for (i = 0; i < 4; i++)
|
||||
ca0106_set_spdif_bits(chip, i);
|
||||
if (chip->details->i2c_adc)
|
||||
ca0106_set_capture_mic_line_in(chip);
|
||||
}
|
||||
#endif /* CONFIG_PM */
|
||||
|
|
|
@ -3640,7 +3640,10 @@ int snd_cs46xx_resume(struct pci_dev *pci)
|
|||
{
|
||||
struct snd_card *card = pci_get_drvdata(pci);
|
||||
struct snd_cs46xx *chip = card->private_data;
|
||||
int i, amp_saved;
|
||||
int amp_saved;
|
||||
#ifdef CONFIG_SND_CS46XX_NEW_DSP
|
||||
int i;
|
||||
#endif
|
||||
|
||||
pci_set_power_state(pci, PCI_D0);
|
||||
pci_restore_state(pci);
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -382,23 +382,25 @@ static irqreturn_t snd_vt1724_interrupt(int irq, void *dev_id)
|
|||
unsigned char status_mask =
|
||||
VT1724_IRQ_MPU_RX | VT1724_IRQ_MPU_TX | VT1724_IRQ_MTPCM;
|
||||
int handled = 0;
|
||||
#ifdef CONFIG_SND_DEBUG
|
||||
int timeout = 0;
|
||||
#endif
|
||||
|
||||
while (1) {
|
||||
status = inb(ICEREG1724(ice, IRQSTAT));
|
||||
status &= status_mask;
|
||||
if (status == 0)
|
||||
break;
|
||||
#ifdef CONFIG_SND_DEBUG
|
||||
if (++timeout > 10) {
|
||||
printk(KERN_ERR
|
||||
"ice1724: Too long irq loop, status = 0x%x\n",
|
||||
status);
|
||||
status = inb(ICEREG1724(ice, IRQSTAT));
|
||||
printk(KERN_ERR "ice1724: Too long irq loop, "
|
||||
"status = 0x%x\n", status);
|
||||
if (status & VT1724_IRQ_MPU_TX) {
|
||||
printk(KERN_ERR "ice1724: Disabling MPU_TX\n");
|
||||
outb(inb(ICEREG1724(ice, IRQMASK)) |
|
||||
VT1724_IRQ_MPU_TX,
|
||||
ICEREG1724(ice, IRQMASK));
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
handled = 1;
|
||||
if (status & VT1724_IRQ_MPU_TX) {
|
||||
spin_lock(&ice->reg_lock);
|
||||
|
@ -2351,7 +2353,6 @@ static int __devinit snd_vt1724_create(struct snd_card *card,
|
|||
{
|
||||
struct snd_ice1712 *ice;
|
||||
int err;
|
||||
unsigned char mask;
|
||||
static struct snd_device_ops ops = {
|
||||
.dev_free = snd_vt1724_dev_free,
|
||||
};
|
||||
|
@ -2412,9 +2413,9 @@ static int __devinit snd_vt1724_create(struct snd_card *card,
|
|||
return -EIO;
|
||||
}
|
||||
|
||||
/* unmask used interrupts */
|
||||
mask = VT1724_IRQ_MPU_RX | VT1724_IRQ_MPU_TX;
|
||||
outb(mask, ICEREG1724(ice, IRQMASK));
|
||||
/* MPU_RX and TX irq masks are cleared later dynamically */
|
||||
outb(VT1724_IRQ_MPU_RX | VT1724_IRQ_MPU_TX , ICEREG1724(ice, IRQMASK));
|
||||
|
||||
/* don't handle FIFO overrun/underruns (just yet),
|
||||
* since they cause machine lockups
|
||||
*/
|
||||
|
|
|
@ -1010,7 +1010,7 @@ static int __devinit snd_mixart_create(struct mixart_mgr *mgr, struct snd_card *
|
|||
.dev_free = snd_mixart_chip_dev_free,
|
||||
};
|
||||
|
||||
mgr->chip[idx] = chip = kzalloc(sizeof(*chip), GFP_KERNEL);
|
||||
chip = kzalloc(sizeof(*chip), GFP_KERNEL);
|
||||
if (! chip) {
|
||||
snd_printk(KERN_ERR "cannot allocate chip\n");
|
||||
return -ENOMEM;
|
||||
|
@ -1025,6 +1025,7 @@ static int __devinit snd_mixart_create(struct mixart_mgr *mgr, struct snd_card *
|
|||
return err;
|
||||
}
|
||||
|
||||
mgr->chip[idx] = chip;
|
||||
snd_card_set_dev(card, &mgr->pci->dev);
|
||||
|
||||
return 0;
|
||||
|
@ -1377,6 +1378,7 @@ static int __devinit snd_mixart_probe(struct pci_dev *pci,
|
|||
sprintf(card->longname, "%s [PCM #%d]", mgr->longname, i);
|
||||
|
||||
if ((err = snd_mixart_create(mgr, card, i)) < 0) {
|
||||
snd_card_free(card);
|
||||
snd_mixart_free(mgr);
|
||||
return err;
|
||||
}
|
||||
|
|
|
@ -1024,7 +1024,7 @@ static int __devinit pcxhr_create(struct pcxhr_mgr *mgr, struct snd_card *card,
|
|||
.dev_free = pcxhr_chip_dev_free,
|
||||
};
|
||||
|
||||
mgr->chip[idx] = chip = kzalloc(sizeof(*chip), GFP_KERNEL);
|
||||
chip = kzalloc(sizeof(*chip), GFP_KERNEL);
|
||||
if (! chip) {
|
||||
snd_printk(KERN_ERR "cannot allocate chip\n");
|
||||
return -ENOMEM;
|
||||
|
@ -1050,6 +1050,7 @@ static int __devinit pcxhr_create(struct pcxhr_mgr *mgr, struct snd_card *card,
|
|||
return err;
|
||||
}
|
||||
|
||||
mgr->chip[idx] = chip;
|
||||
snd_card_set_dev(card, &mgr->pci->dev);
|
||||
|
||||
return 0;
|
||||
|
@ -1310,6 +1311,7 @@ static int __devinit pcxhr_probe(struct pci_dev *pci, const struct pci_device_id
|
|||
sprintf(card->longname, "%s [PCM #%d]", mgr->longname, i);
|
||||
|
||||
if ((err = pcxhr_create(mgr, card, i)) < 0) {
|
||||
snd_card_free(card);
|
||||
pcxhr_free(mgr);
|
||||
return err;
|
||||
}
|
||||
|
|
|
@ -172,7 +172,7 @@ MODULE_PARM_DESC(opl3_port, "OPL3 port # for Riptide driver.");
|
|||
|
||||
#define MAX_WRITE_RETRY 10 /* cmd interface limits */
|
||||
#define MAX_ERROR_COUNT 10
|
||||
#define CMDIF_TIMEOUT 500000
|
||||
#define CMDIF_TIMEOUT 50000
|
||||
#define RESET_TRIES 5
|
||||
|
||||
#define READ_PORT_ULONG(p) inl((unsigned long)&(p))
|
||||
|
|
|
@ -1033,7 +1033,7 @@ static int __init snd_pmac_detect(struct snd_pmac *chip)
|
|||
}
|
||||
if (of_device_is_compatible(sound, "tumbler")) {
|
||||
chip->model = PMAC_TUMBLER;
|
||||
chip->can_capture = 0; /* no capture */
|
||||
chip->can_capture = machine_is_compatible("PowerMac4,2");
|
||||
chip->can_duplex = 0;
|
||||
// chip->can_byte_swap = 0; /* FIXME: check this */
|
||||
chip->num_freqs = ARRAY_SIZE(tumbler_freqs);
|
||||
|
|
|
@ -875,7 +875,8 @@ static struct snd_kcontrol_new snapper_mixers[] __initdata = {
|
|||
.put = tumbler_put_master_switch
|
||||
},
|
||||
DEFINE_SNAPPER_MIX("PCM Playback Volume", 0, VOL_IDX_PCM),
|
||||
DEFINE_SNAPPER_MIX("PCM Playback Volume", 1, VOL_IDX_PCM2),
|
||||
/* Alternative PCM is assigned to Mic analog loopback on iBook G4 */
|
||||
DEFINE_SNAPPER_MIX("Mic Playback Volume", 0, VOL_IDX_PCM2),
|
||||
DEFINE_SNAPPER_MIX("Monitor Mix Volume", 0, VOL_IDX_ADC),
|
||||
DEFINE_SNAPPER_MONO("Tone Control - Bass", bass),
|
||||
DEFINE_SNAPPER_MONO("Tone Control - Treble", treble),
|
||||
|
|
|
@ -247,69 +247,56 @@ static struct caiaq_controller a8dj_controller[] = {
|
|||
{ "Software lock", 40 }
|
||||
};
|
||||
|
||||
int __devinit snd_usb_caiaq_control_init(struct snd_usb_caiaqdev *dev)
|
||||
static int __devinit add_controls(struct caiaq_controller *c, int num,
|
||||
struct snd_usb_caiaqdev *dev)
|
||||
{
|
||||
int i;
|
||||
int i, ret;
|
||||
struct snd_kcontrol *kc;
|
||||
|
||||
switch (dev->chip.usb_id) {
|
||||
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1):
|
||||
for (i = 0; i < ARRAY_SIZE(ak1_controller); i++) {
|
||||
struct caiaq_controller *c = ak1_controller + i;
|
||||
kcontrol_template.name = c->name;
|
||||
kcontrol_template.private_value = c->index;
|
||||
kc = snd_ctl_new1(&kcontrol_template, dev);
|
||||
snd_ctl_add(dev->chip.card, kc);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2):
|
||||
for (i = 0; i < ARRAY_SIZE(rk2_controller); i++) {
|
||||
struct caiaq_controller *c = rk2_controller + i;
|
||||
kcontrol_template.name = c->name;
|
||||
kcontrol_template.private_value = c->index;
|
||||
kc = snd_ctl_new1(&kcontrol_template, dev);
|
||||
snd_ctl_add(dev->chip.card, kc);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3):
|
||||
for (i = 0; i < ARRAY_SIZE(rk3_controller); i++) {
|
||||
struct caiaq_controller *c = rk3_controller + i;
|
||||
kcontrol_template.name = c->name;
|
||||
kcontrol_template.private_value = c->index;
|
||||
kc = snd_ctl_new1(&kcontrol_template, dev);
|
||||
snd_ctl_add(dev->chip.card, kc);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER):
|
||||
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER2):
|
||||
for (i = 0; i < ARRAY_SIZE(kore_controller); i++) {
|
||||
struct caiaq_controller *c = kore_controller + i;
|
||||
kcontrol_template.name = c->name;
|
||||
kcontrol_template.private_value = c->index;
|
||||
kc = snd_ctl_new1(&kcontrol_template, dev);
|
||||
snd_ctl_add(dev->chip.card, kc);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ):
|
||||
for (i = 0; i < ARRAY_SIZE(a8dj_controller); i++) {
|
||||
struct caiaq_controller *c = a8dj_controller + i;
|
||||
kcontrol_template.name = c->name;
|
||||
kcontrol_template.private_value = c->index;
|
||||
kc = snd_ctl_new1(&kcontrol_template, dev);
|
||||
snd_ctl_add(dev->chip.card, kc);
|
||||
}
|
||||
|
||||
break;
|
||||
for (i = 0; i < num; i++, c++) {
|
||||
kcontrol_template.name = c->name;
|
||||
kcontrol_template.private_value = c->index;
|
||||
kc = snd_ctl_new1(&kcontrol_template, dev);
|
||||
ret = snd_ctl_add(dev->chip.card, kc);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __devinit snd_usb_caiaq_control_init(struct snd_usb_caiaqdev *dev)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
switch (dev->chip.usb_id) {
|
||||
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1):
|
||||
ret = add_controls(ak1_controller,
|
||||
ARRAY_SIZE(ak1_controller), dev);
|
||||
break;
|
||||
|
||||
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2):
|
||||
ret = add_controls(rk2_controller,
|
||||
ARRAY_SIZE(rk2_controller), dev);
|
||||
break;
|
||||
|
||||
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3):
|
||||
ret = add_controls(rk3_controller,
|
||||
ARRAY_SIZE(rk3_controller), dev);
|
||||
break;
|
||||
|
||||
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER):
|
||||
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER2):
|
||||
ret = add_controls(kore_controller,
|
||||
ARRAY_SIZE(kore_controller), dev);
|
||||
break;
|
||||
|
||||
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ):
|
||||
ret = add_controls(a8dj_controller,
|
||||
ARRAY_SIZE(a8dj_controller), dev);
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
#endif
|
||||
|
||||
MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>");
|
||||
MODULE_DESCRIPTION("caiaq USB audio, version 1.3.8");
|
||||
MODULE_DESCRIPTION("caiaq USB audio, version 1.3.9");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_SUPPORTED_DEVICE("{{Native Instruments, RigKontrol2},"
|
||||
"{Native Instruments, RigKontrol3},"
|
||||
|
|
|
@ -276,7 +276,8 @@ static void subs_set_complete(struct urb **urbs, void (*complete)(struct urb *))
|
|||
}
|
||||
}
|
||||
|
||||
int usb_stream_prepare_playback(struct usb_stream_kernel *sk, struct urb *inurb)
|
||||
static int usb_stream_prepare_playback(struct usb_stream_kernel *sk,
|
||||
struct urb *inurb)
|
||||
{
|
||||
struct usb_stream *s = sk->s;
|
||||
struct urb *io;
|
||||
|
|
Загрузка…
Ссылка в новой задаче