#include <linux/time.h>
#include <linux/init.h>
#include <sound/core.h>
#include <sound/emu10k1.h>
#include <linux/delay.h>
#include <sound/tlv.h>
#include "p17v.h"
#define AC97_ID_STAC9758 …
static const DECLARE_TLV_DB_SCALE(snd_audigy_db_scale2, -10350, 50, 1);
static int add_ctls(struct snd_emu10k1 *emu, const struct snd_kcontrol_new *tpl,
const char * const *ctls, unsigned nctls)
{ … }
static int snd_emu10k1_spdif_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
{ … }
static int snd_emu10k1_spdif_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static int snd_emu10k1_spdif_get_mask(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
#define PAIR_PS(base, one, two, sfx) …
#define LR_PS(base, sfx) …
#define ADAT_PS(pfx, sfx) …
#define PAIR_REGS(base, one, two) …
#define LR_REGS(base) …
#define ADAT_REGS(base) …
#define DSP_TEXTS …
#define PAIR_TEXTS(base, one, two) …
#define LR_TEXTS(base) …
#define ADAT_TEXTS(pfx) …
#define EMU32_SRC_REGS …
#define EMU1010_COMMON_TEXTS …
static const char * const emu1010_src_texts[] = …;
static const unsigned short emu1010_src_regs[] = …;
static_assert(…);
#define EMU1010b_COMMON_TEXTS …
static const char * const emu1010b_src_texts[] = …;
static const unsigned short emu1010b_src_regs[] = …;
static_assert(…);
#define EMU1616_COMMON_TEXTS …
static const char * const emu1616_src_texts[] = …;
static const unsigned short emu1616_src_regs[] = …;
static_assert(…);
#define EMU0404_COMMON_TEXTS …
static const char * const emu0404_src_texts[] = …;
static const unsigned short emu0404_src_regs[] = …;
static_assert(…);
#define LR_CTLS(base) …
#define ADAT_CTLS(pfx) …
static const char * const emu1010_output_texts[] = …;
static_assert(…);
static const unsigned short emu1010_output_dst[] = …;
static_assert(…);
static const unsigned short emu1010_output_dflt[] = …;
static_assert(…);
static const char * const snd_emu1010b_output_texts[] = …;
static_assert(…);
static const unsigned short emu1010b_output_dst[] = …;
static_assert(…);
static const unsigned short emu1010b_output_dflt[] = …;
static const char * const snd_emu1616_output_texts[] = …;
static_assert(…);
static const unsigned short emu1616_output_dst[] = …;
static_assert(…);
static const unsigned short emu1616_output_dflt[] = …;
static_assert(…);
static const char * const snd_emu0404_output_texts[] = …;
static_assert(…);
static const unsigned short emu0404_output_dst[] = …;
static_assert(…);
static const unsigned short emu0404_output_dflt[] = …;
static_assert(…);
static const char * const emu1010_input_texts[] = …;
static_assert(…);
static const unsigned short emu1010_input_dst[] = …;
static_assert(…);
static const unsigned short emu1010_input_dflt[] = …;
static_assert(…);
static const unsigned short emu0404_input_dflt[] = …;
struct snd_emu1010_routing_info { … };
static const struct snd_emu1010_routing_info emu1010_routing_info[] = …;
static unsigned emu1010_idx(struct snd_emu10k1 *emu)
{ … }
static void snd_emu1010_output_source_apply(struct snd_emu10k1 *emu,
int channel, int src)
{ … }
static void snd_emu1010_input_source_apply(struct snd_emu10k1 *emu,
int channel, int src)
{ … }
static void snd_emu1010_apply_sources(struct snd_emu10k1 *emu)
{ … }
static u8 emu1010_map_source(const struct snd_emu1010_routing_info *emu_ri,
unsigned val)
{ … }
static int snd_emu1010_input_output_source_info(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_info *uinfo)
{ … }
static int snd_emu1010_output_source_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static int snd_emu1010_output_source_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static const struct snd_kcontrol_new emu1010_output_source_ctl = …;
static int snd_emu1010_input_source_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static int snd_emu1010_input_source_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static const struct snd_kcontrol_new emu1010_input_source_ctl = …;
static int add_emu1010_source_mixers(struct snd_emu10k1 *emu)
{ … }
static const char * const snd_emu1010_adc_pads[] = …;
static const unsigned short snd_emu1010_adc_pad_regs[] = …;
#define snd_emu1010_adc_pads_info …
static int snd_emu1010_adc_pads_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{ … }
static int snd_emu1010_adc_pads_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{ … }
static const struct snd_kcontrol_new emu1010_adc_pads_ctl = …;
static const char * const snd_emu1010_dac_pads[] = …;
static const unsigned short snd_emu1010_dac_regs[] = …;
#define snd_emu1010_dac_pads_info …
static int snd_emu1010_dac_pads_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{ … }
static int snd_emu1010_dac_pads_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{ … }
static const struct snd_kcontrol_new emu1010_dac_pads_ctl = …;
struct snd_emu1010_pads_info { … };
static const struct snd_emu1010_pads_info emu1010_pads_info[] = …;
static const char * const emu1010_clock_texts[] = …;
static const u8 emu1010_clock_vals[] = …;
static const char * const emu0404_clock_texts[] = …;
static const u8 emu0404_clock_vals[] = …;
struct snd_emu1010_clock_info { … };
static const struct snd_emu1010_clock_info emu1010_clock_info[] = …;
static int snd_emu1010_clock_source_info(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_info *uinfo)
{ … }
static int snd_emu1010_clock_source_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static int snd_emu1010_clock_source_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static const struct snd_kcontrol_new snd_emu1010_clock_source = …;
static int snd_emu1010_clock_fallback_info(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_info *uinfo)
{ … }
static int snd_emu1010_clock_fallback_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static int snd_emu1010_clock_fallback_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static const struct snd_kcontrol_new snd_emu1010_clock_fallback = …;
static int snd_emu1010_optical_out_info(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_info *uinfo)
{ … }
static int snd_emu1010_optical_out_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static int snd_emu1010_optical_out_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static const struct snd_kcontrol_new snd_emu1010_optical_out = …;
static int snd_emu1010_optical_in_info(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_info *uinfo)
{ … }
static int snd_emu1010_optical_in_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static int snd_emu1010_optical_in_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static const struct snd_kcontrol_new snd_emu1010_optical_in = …;
static int snd_audigy_i2c_capture_source_info(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_info *uinfo)
{ … }
static int snd_audigy_i2c_capture_source_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static int snd_audigy_i2c_capture_source_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static const struct snd_kcontrol_new snd_audigy_i2c_capture_source = …;
static int snd_audigy_i2c_volume_info(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_info *uinfo)
{ … }
static int snd_audigy_i2c_volume_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static int snd_audigy_i2c_volume_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static const struct snd_kcontrol_new i2c_volume_ctl = …;
static const char * const snd_audigy_i2c_volume_ctls[] = …;
#if 0
static int snd_audigy_spdif_output_rate_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
{
static const char * const texts[] = {"44100", "48000", "96000"};
return snd_ctl_enum_info(uinfo, 1, 3, texts);
}
static int snd_audigy_spdif_output_rate_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
unsigned int tmp;
tmp = snd_emu10k1_ptr_read(emu, A_SPDIF_SAMPLERATE, 0);
switch (tmp & A_SPDIF_RATE_MASK) {
case A_SPDIF_44100:
ucontrol->value.enumerated.item[0] = 0;
break;
case A_SPDIF_48000:
ucontrol->value.enumerated.item[0] = 1;
break;
case A_SPDIF_96000:
ucontrol->value.enumerated.item[0] = 2;
break;
default:
ucontrol->value.enumerated.item[0] = 1;
}
return 0;
}
static int snd_audigy_spdif_output_rate_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
int change;
unsigned int reg, val, tmp;
switch(ucontrol->value.enumerated.item[0]) {
case 0:
val = A_SPDIF_44100;
break;
case 1:
val = A_SPDIF_48000;
break;
case 2:
val = A_SPDIF_96000;
break;
default:
val = A_SPDIF_48000;
break;
}
spin_lock_irq(&emu->reg_lock);
reg = snd_emu10k1_ptr_read(emu, A_SPDIF_SAMPLERATE, 0);
tmp = reg & ~A_SPDIF_RATE_MASK;
tmp |= val;
change = (tmp != reg);
if (change)
snd_emu10k1_ptr_write(emu, A_SPDIF_SAMPLERATE, 0, tmp);
spin_unlock_irq(&emu->reg_lock);
return change;
}
static const struct snd_kcontrol_new snd_audigy_spdif_output_rate =
{
.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "Audigy SPDIF Output Sample Rate",
.count = 1,
.info = snd_audigy_spdif_output_rate_info,
.get = snd_audigy_spdif_output_rate_get,
.put = snd_audigy_spdif_output_rate_put
};
#endif
static int snd_emu10k1_spdif_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static const struct snd_kcontrol_new snd_emu10k1_spdif_mask_control = …;
static const struct snd_kcontrol_new snd_emu10k1_spdif_control = …;
static void update_emu10k1_fxrt(struct snd_emu10k1 *emu, int voice, unsigned char *route)
{ … }
static void update_emu10k1_send_volume(struct snd_emu10k1 *emu, int voice, unsigned char *volume)
{ … }
static int snd_emu10k1_send_routing_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
{ … }
static int snd_emu10k1_send_routing_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static int snd_emu10k1_send_routing_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static const struct snd_kcontrol_new snd_emu10k1_send_routing_control = …;
static int snd_emu10k1_send_volume_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
{ … }
static int snd_emu10k1_send_volume_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static int snd_emu10k1_send_volume_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static const struct snd_kcontrol_new snd_emu10k1_send_volume_control = …;
static int snd_emu10k1_attn_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
{ … }
static int snd_emu10k1_attn_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static int snd_emu10k1_attn_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static const struct snd_kcontrol_new snd_emu10k1_attn_control = …;
static int snd_emu10k1_efx_send_routing_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
{ … }
static int snd_emu10k1_efx_send_routing_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static int snd_emu10k1_efx_send_routing_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static const struct snd_kcontrol_new snd_emu10k1_efx_send_routing_control = …;
static int snd_emu10k1_efx_send_volume_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
{ … }
static int snd_emu10k1_efx_send_volume_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static int snd_emu10k1_efx_send_volume_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static const struct snd_kcontrol_new snd_emu10k1_efx_send_volume_control = …;
static int snd_emu10k1_efx_attn_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
{ … }
static int snd_emu10k1_efx_attn_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static int snd_emu10k1_efx_attn_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static const struct snd_kcontrol_new snd_emu10k1_efx_attn_control = …;
#define snd_emu10k1_shared_spdif_info …
static int snd_emu10k1_shared_spdif_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static int snd_emu10k1_shared_spdif_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static const struct snd_kcontrol_new snd_emu10k1_shared_spdif = …;
static const struct snd_kcontrol_new snd_audigy_shared_spdif = …;
#define snd_audigy_capture_boost_info …
static int snd_audigy_capture_boost_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static int snd_audigy_capture_boost_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static const struct snd_kcontrol_new snd_audigy_capture_boost = …;
static void snd_emu10k1_mixer_free_ac97(struct snd_ac97 *ac97)
{ … }
static int remove_ctl(struct snd_card *card, const char *name)
{ … }
static int rename_ctl(struct snd_card *card, const char *src, const char *dst)
{ … }
int snd_emu10k1_mixer(struct snd_emu10k1 *emu,
int pcm_device, int multi_device)
{ … }