]> err.no Git - linux-2.6/blobdiff - sound/pci/echoaudio/echoaudio.c
Merge branches 'release', 'misc' and 'misc-2.6.25' into release
[linux-2.6] / sound / pci / echoaudio / echoaudio.c
index 047e0b5bf15d3af1ac3b44a622c0a0a4a2cfce38..90ec090792ba12c4c22eecb4378744dd14549868 100644 (file)
@@ -34,6 +34,7 @@ module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable " ECHOCARD_NAME " soundcard.");
 
 static unsigned int channels_list[10] = {1, 2, 4, 6, 8, 10, 12, 14, 16, 999999};
+static const DECLARE_TLV_DB_SCALE(db_scale_output_gain, -12800, 100, 1);
 
 static int get_firmware(const struct firmware **fw_entry,
                        const struct firmware *frm, struct echoaudio *chip)
@@ -377,7 +378,7 @@ static int pcm_digital_in_open(struct snd_pcm_substream *substream)
 
        DE_ACT(("pcm_digital_in_open\n"));
        max_channels = num_digital_busses_in(chip) - substream->number;
-       down(&chip->mode_mutex);
+       mutex_lock(&chip->mode_mutex);
        if (chip->digital_mode == DIGITAL_MODE_ADAT)
                err = pcm_open(substream, max_channels);
        else    /* If the card has ADAT, subtract the 6 channels
@@ -404,7 +405,7 @@ static int pcm_digital_in_open(struct snd_pcm_substream *substream)
                chip->can_set_rate=0;
 
 din_exit:
-       up(&chip->mode_mutex);
+       mutex_unlock(&chip->mode_mutex);
        return err;
 }
 
@@ -419,7 +420,7 @@ static int pcm_digital_out_open(struct snd_pcm_substream *substream)
 
        DE_ACT(("pcm_digital_out_open\n"));
        max_channels = num_digital_busses_out(chip) - substream->number;
-       down(&chip->mode_mutex);
+       mutex_lock(&chip->mode_mutex);
        if (chip->digital_mode == DIGITAL_MODE_ADAT)
                err = pcm_open(substream, max_channels);
        else    /* If the card has ADAT, subtract the 6 channels
@@ -446,7 +447,7 @@ static int pcm_digital_out_open(struct snd_pcm_substream *substream)
        if (atomic_read(&chip->opencount) > 1 && chip->rate_set)
                chip->can_set_rate=0;
 dout_exit:
-       up(&chip->mode_mutex);
+       mutex_unlock(&chip->mode_mutex);
        return err;
 }
 
@@ -704,11 +705,9 @@ static int pcm_trigger(struct snd_pcm_substream *substream, int cmd)
        struct audiopipe *pipe = runtime->private_data;
        int i, err;
        u32 channelmask = 0;
-       struct list_head *pos;
        struct snd_pcm_substream *s;
 
-       snd_pcm_group_for_each(pos, substream) {
-               s = snd_pcm_group_substream_entry(pos);
+       snd_pcm_group_for_each_entry(s, substream) {
                for (i = 0; i < DSP_MAXPIPES; i++) {
                        if (s == chip->substream[i]) {
                                channelmask |= 1 << i;
@@ -1011,17 +1010,21 @@ static int snd_echo_output_gain_put(struct snd_kcontrol *kcontrol,
 static struct snd_kcontrol_new snd_echo_line_output_gain __devinitdata = {
        .name = "Line Playback Volume",
        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+       .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ,
        .info = snd_echo_output_gain_info,
        .get = snd_echo_output_gain_get,
        .put = snd_echo_output_gain_put,
+       .tlv = {.p = db_scale_output_gain},
 };
 #else
 static struct snd_kcontrol_new snd_echo_pcm_output_gain __devinitdata = {
        .name = "PCM Playback Volume",
        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+       .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ,
        .info = snd_echo_output_gain_info,
        .get = snd_echo_output_gain_get,
        .put = snd_echo_output_gain_put,
+       .tlv = {.p = db_scale_output_gain},
 };
 #endif
 
@@ -1080,12 +1083,16 @@ static int snd_echo_input_gain_put(struct snd_kcontrol *kcontrol,
        return changed;
 }
 
+static const DECLARE_TLV_DB_SCALE(db_scale_input_gain, -2500, 50, 0);
+
 static struct snd_kcontrol_new snd_echo_line_input_gain __devinitdata = {
        .name = "Line Capture Volume",
        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+       .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ,
        .info = snd_echo_input_gain_info,
        .get = snd_echo_input_gain_get,
        .put = snd_echo_input_gain_put,
+       .tlv = {.p = db_scale_input_gain},
 };
 
 #endif /* ECHOCARD_HAS_INPUT_GAIN */
@@ -1277,9 +1284,11 @@ static int snd_echo_mixer_put(struct snd_kcontrol *kcontrol,
 static struct snd_kcontrol_new snd_echo_monitor_mixer __devinitdata = {
        .name = "Monitor Mixer Volume",
        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+       .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ,
        .info = snd_echo_mixer_info,
        .get = snd_echo_mixer_get,
        .put = snd_echo_mixer_put,
+       .tlv = {.p = db_scale_output_gain},
 };
 
 #endif /* ECHOCARD_HAS_MONITOR */
@@ -1343,9 +1352,11 @@ static int snd_echo_vmixer_put(struct snd_kcontrol *kcontrol,
 static struct snd_kcontrol_new snd_echo_vmixer __devinitdata = {
        .name = "VMixer Volume",
        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+       .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ,
        .info = snd_echo_vmixer_info,
        .get = snd_echo_vmixer_get,
        .put = snd_echo_vmixer_put,
+       .tlv = {.p = db_scale_output_gain},
 };
 
 #endif /* ECHOCARD_HAS_VMIXER */
@@ -1409,7 +1420,7 @@ static int snd_echo_digital_mode_put(struct snd_kcontrol *kcontrol,
        if (dmode != chip->digital_mode) {
                /* mode_mutex is required to make this operation atomic wrt
                pcm_digital_*_open() and set_input_clock() functions. */
-               down(&chip->mode_mutex);
+               mutex_lock(&chip->mode_mutex);
 
                /* Do not allow the user to change the digital mode when a pcm
                device is open because it also changes the number of channels
@@ -1428,7 +1439,7 @@ static int snd_echo_digital_mode_put(struct snd_kcontrol *kcontrol,
                        if (changed >= 0)
                                changed = 1;    /* No errors */
                }
-               up(&chip->mode_mutex);
+               mutex_unlock(&chip->mode_mutex);
        }
        return changed;
 }
@@ -1555,12 +1566,12 @@ static int snd_echo_clock_source_put(struct snd_kcontrol *kcontrol,
                return -EINVAL;
        dclock = chip->clock_source_list[eclock];
        if (chip->input_clock != dclock) {
-               down(&chip->mode_mutex);
+               mutex_lock(&chip->mode_mutex);
                spin_lock_irq(&chip->lock);
                if ((changed = set_input_clock(chip, dclock)) == 0)
                        changed = 1;    /* no errors */
                spin_unlock_irq(&chip->lock);
-               up(&chip->mode_mutex);
+               mutex_unlock(&chip->mode_mutex);
        }
 
        if (changed < 0)
@@ -1584,15 +1595,7 @@ static struct snd_kcontrol_new snd_echo_clock_source_switch __devinitdata = {
 #ifdef ECHOCARD_HAS_PHANTOM_POWER
 
 /******************* Phantom power switch *******************/
-static int snd_echo_phantom_power_info(struct snd_kcontrol *kcontrol,
-                                      struct snd_ctl_elem_info *uinfo)
-{
-       uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
-       uinfo->count = 1;
-       uinfo->value.integer.min = 0;
-       uinfo->value.integer.max = 1;
-       return 0;
-}
+#define snd_echo_phantom_power_info    snd_ctl_boolean_mono_info
 
 static int snd_echo_phantom_power_get(struct snd_kcontrol *kcontrol,
                                      struct snd_ctl_elem_value *ucontrol)
@@ -1635,15 +1638,7 @@ static struct snd_kcontrol_new snd_echo_phantom_power_switch __devinitdata = {
 #ifdef ECHOCARD_HAS_DIGITAL_IN_AUTOMUTE
 
 /******************* Digital input automute switch *******************/
-static int snd_echo_automute_info(struct snd_kcontrol *kcontrol,
-                                 struct snd_ctl_elem_info *uinfo)
-{
-       uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
-       uinfo->count = 1;
-       uinfo->value.integer.min = 0;
-       uinfo->value.integer.max = 1;
-       return 0;
-}
+#define snd_echo_automute_info         snd_ctl_boolean_mono_info
 
 static int snd_echo_automute_get(struct snd_kcontrol *kcontrol,
                                 struct snd_ctl_elem_value *ucontrol)
@@ -1684,18 +1679,7 @@ static struct snd_kcontrol_new snd_echo_automute_switch __devinitdata = {
 
 
 /******************* VU-meters switch *******************/
-static int snd_echo_vumeters_switch_info(struct snd_kcontrol *kcontrol,
-                                        struct snd_ctl_elem_info *uinfo)
-{
-       struct echoaudio *chip;
-
-       chip = snd_kcontrol_chip(kcontrol);
-       uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
-       uinfo->count = 1;
-       uinfo->value.integer.min = 0;
-       uinfo->value.integer.max = 1;
-       return 0;
-}
+#define snd_echo_vumeters_switch_info          snd_ctl_boolean_mono_info
 
 static int snd_echo_vumeters_switch_put(struct snd_kcontrol *kcontrol,
                                        struct snd_ctl_elem_value *ucontrol)
@@ -1753,9 +1737,12 @@ static int snd_echo_vumeters_get(struct snd_kcontrol *kcontrol,
 static struct snd_kcontrol_new snd_echo_vumeters __devinitdata = {
        .name = "VU-meters",
        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-       .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE,
+       .access = SNDRV_CTL_ELEM_ACCESS_READ |
+                 SNDRV_CTL_ELEM_ACCESS_VOLATILE |
+                 SNDRV_CTL_ELEM_ACCESS_TLV_READ,
        .info = snd_echo_vumeters_info,
        .get = snd_echo_vumeters_get,
+       .tlv = {.p = db_scale_output_gain},
 };
 
 
@@ -1985,7 +1972,7 @@ static __devinit int snd_echo_create(struct snd_card *card,
                return err;
        }
        atomic_set(&chip->opencount, 0);
-       init_MUTEX(&chip->mode_mutex);
+       mutex_init(&chip->mode_mutex);
        chip->can_set_rate = 1;
        *rchip = chip;
        /* Init done ! */
@@ -2017,6 +2004,8 @@ static int __devinit snd_echo_probe(struct pci_dev *pci,
        if (card == NULL)
                return -ENOMEM;
 
+       snd_card_set_dev(card, &pci->dev);
+
        if ((err = snd_echo_create(card, pci, &chip)) < 0) {
                snd_card_free(card);
                return err;