[ALSA] Add even more 'const' to everything related to TLV
[linux-2.6.git] / sound / drivers / vx / vx_mixer.c
index 8ec2c60..f63152a 100644 (file)
@@ -23,6 +23,7 @@
 #include <sound/driver.h>
 #include <sound/core.h>
 #include <sound/control.h>
+#include <sound/tlv.h>
 #include <sound/vx_core.h>
 #include "vx_cmd.h"
 
@@ -427,10 +428,10 @@ static int vx_output_level_get(struct snd_kcontrol *kcontrol, struct snd_ctl_ele
 {
        struct vx_core *chip = snd_kcontrol_chip(kcontrol);
        int codec = kcontrol->id.index;
-       down(&chip->mixer_mutex);
+       mutex_lock(&chip->mixer_mutex);
        ucontrol->value.integer.value[0] = chip->output_level[codec][0];
        ucontrol->value.integer.value[1] = chip->output_level[codec][1];
-       up(&chip->mixer_mutex);
+       mutex_unlock(&chip->mixer_mutex);
        return 0;
 }
 
@@ -438,7 +439,7 @@ static int vx_output_level_put(struct snd_kcontrol *kcontrol, struct snd_ctl_ele
 {
        struct vx_core *chip = snd_kcontrol_chip(kcontrol);
        int codec = kcontrol->id.index;
-       down(&chip->mixer_mutex);
+       mutex_lock(&chip->mixer_mutex);
        if (ucontrol->value.integer.value[0] != chip->output_level[codec][0] ||
            ucontrol->value.integer.value[1] != chip->output_level[codec][1]) {
                vx_set_analog_output_level(chip, codec,
@@ -446,19 +447,22 @@ static int vx_output_level_put(struct snd_kcontrol *kcontrol, struct snd_ctl_ele
                                           ucontrol->value.integer.value[1]);
                chip->output_level[codec][0] = ucontrol->value.integer.value[0];
                chip->output_level[codec][1] = ucontrol->value.integer.value[1];
-               up(&chip->mixer_mutex);
+               mutex_unlock(&chip->mixer_mutex);
                return 1;
        }
-       up(&chip->mixer_mutex);
+       mutex_unlock(&chip->mixer_mutex);
        return 0;
 }
 
 static struct snd_kcontrol_new vx_control_output_level = {
        .iface =        SNDRV_CTL_ELEM_IFACE_MIXER,
+       .access =       (SNDRV_CTL_ELEM_ACCESS_READWRITE |
+                        SNDRV_CTL_ELEM_ACCESS_TLV_READ),
        .name =         "Master Playback Volume",
        .info =         vx_output_level_info,
        .get =          vx_output_level_get,
        .put =          vx_output_level_put,
+       /* tlv will be filled later */
 };
 
 /*
@@ -502,14 +506,14 @@ static int vx_audio_src_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_v
 static int vx_audio_src_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
        struct vx_core *chip = snd_kcontrol_chip(kcontrol);
-       down(&chip->mixer_mutex);
+       mutex_lock(&chip->mixer_mutex);
        if (chip->audio_source_target != ucontrol->value.enumerated.item[0]) {
                chip->audio_source_target = ucontrol->value.enumerated.item[0];
                vx_sync_audio_source(chip);
-               up(&chip->mixer_mutex);
+               mutex_unlock(&chip->mixer_mutex);
                return 1;
        }
-       up(&chip->mixer_mutex);
+       mutex_unlock(&chip->mixer_mutex);
        return 0;
 }
 
@@ -550,14 +554,14 @@ static int vx_clock_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_
 static int vx_clock_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
        struct vx_core *chip = snd_kcontrol_chip(kcontrol);
-       down(&chip->mixer_mutex);
+       mutex_lock(&chip->mixer_mutex);
        if (chip->clock_mode != ucontrol->value.enumerated.item[0]) {
                chip->clock_mode = ucontrol->value.enumerated.item[0];
                vx_set_clock(chip, chip->freq);
-               up(&chip->mixer_mutex);
+               mutex_unlock(&chip->mixer_mutex);
                return 1;
        }
-       up(&chip->mixer_mutex);
+       mutex_unlock(&chip->mixer_mutex);
        return 0;
 }
 
@@ -587,10 +591,10 @@ static int vx_audio_gain_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_
        int audio = kcontrol->private_value & 0xff;
        int capture = (kcontrol->private_value >> 8) & 1;
 
-       down(&chip->mixer_mutex);
+       mutex_lock(&chip->mixer_mutex);
        ucontrol->value.integer.value[0] = chip->audio_gain[capture][audio];
        ucontrol->value.integer.value[1] = chip->audio_gain[capture][audio+1];
-       up(&chip->mixer_mutex);
+       mutex_unlock(&chip->mixer_mutex);
        return 0;
 }
 
@@ -600,15 +604,15 @@ static int vx_audio_gain_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_
        int audio = kcontrol->private_value & 0xff;
        int capture = (kcontrol->private_value >> 8) & 1;
 
-       down(&chip->mixer_mutex);
+       mutex_lock(&chip->mixer_mutex);
        if (ucontrol->value.integer.value[0] != chip->audio_gain[capture][audio] ||
            ucontrol->value.integer.value[1] != chip->audio_gain[capture][audio+1]) {
                vx_set_audio_gain(chip, audio, capture, ucontrol->value.integer.value[0]);
                vx_set_audio_gain(chip, audio+1, capture, ucontrol->value.integer.value[1]);
-               up(&chip->mixer_mutex);
+               mutex_unlock(&chip->mixer_mutex);
                return 1;
        }
-       up(&chip->mixer_mutex);
+       mutex_unlock(&chip->mixer_mutex);
        return 0;
 }
 
@@ -617,10 +621,10 @@ static int vx_audio_monitor_get(struct snd_kcontrol *kcontrol, struct snd_ctl_el
        struct vx_core *chip = snd_kcontrol_chip(kcontrol);
        int audio = kcontrol->private_value & 0xff;
 
-       down(&chip->mixer_mutex);
+       mutex_lock(&chip->mixer_mutex);
        ucontrol->value.integer.value[0] = chip->audio_monitor[audio];
        ucontrol->value.integer.value[1] = chip->audio_monitor[audio+1];
-       up(&chip->mixer_mutex);
+       mutex_unlock(&chip->mixer_mutex);
        return 0;
 }
 
@@ -629,17 +633,17 @@ static int vx_audio_monitor_put(struct snd_kcontrol *kcontrol, struct snd_ctl_el
        struct vx_core *chip = snd_kcontrol_chip(kcontrol);
        int audio = kcontrol->private_value & 0xff;
 
-       down(&chip->mixer_mutex);
+       mutex_lock(&chip->mixer_mutex);
        if (ucontrol->value.integer.value[0] != chip->audio_monitor[audio] ||
            ucontrol->value.integer.value[1] != chip->audio_monitor[audio+1]) {
                vx_set_monitor_level(chip, audio, ucontrol->value.integer.value[0],
                                     chip->audio_monitor_active[audio]);
                vx_set_monitor_level(chip, audio+1, ucontrol->value.integer.value[1],
                                     chip->audio_monitor_active[audio+1]);
-               up(&chip->mixer_mutex);
+               mutex_unlock(&chip->mixer_mutex);
                return 1;
        }
-       up(&chip->mixer_mutex);
+       mutex_unlock(&chip->mixer_mutex);
        return 0;
 }
 
@@ -657,10 +661,10 @@ static int vx_audio_sw_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_va
        struct vx_core *chip = snd_kcontrol_chip(kcontrol);
        int audio = kcontrol->private_value & 0xff;
 
-       down(&chip->mixer_mutex);
+       mutex_lock(&chip->mixer_mutex);
        ucontrol->value.integer.value[0] = chip->audio_active[audio];
        ucontrol->value.integer.value[1] = chip->audio_active[audio+1];
-       up(&chip->mixer_mutex);
+       mutex_unlock(&chip->mixer_mutex);
        return 0;
 }
 
@@ -669,15 +673,15 @@ static int vx_audio_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_va
        struct vx_core *chip = snd_kcontrol_chip(kcontrol);
        int audio = kcontrol->private_value & 0xff;
 
-       down(&chip->mixer_mutex);
+       mutex_lock(&chip->mixer_mutex);
        if (ucontrol->value.integer.value[0] != chip->audio_active[audio] ||
            ucontrol->value.integer.value[1] != chip->audio_active[audio+1]) {
                vx_set_audio_switch(chip, audio, ucontrol->value.integer.value[0]);
                vx_set_audio_switch(chip, audio+1, ucontrol->value.integer.value[1]);
-               up(&chip->mixer_mutex);
+               mutex_unlock(&chip->mixer_mutex);
                return 1;
        }
-       up(&chip->mixer_mutex);
+       mutex_unlock(&chip->mixer_mutex);
        return 0;
 }
 
@@ -686,10 +690,10 @@ static int vx_monitor_sw_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_
        struct vx_core *chip = snd_kcontrol_chip(kcontrol);
        int audio = kcontrol->private_value & 0xff;
 
-       down(&chip->mixer_mutex);
+       mutex_lock(&chip->mixer_mutex);
        ucontrol->value.integer.value[0] = chip->audio_monitor_active[audio];
        ucontrol->value.integer.value[1] = chip->audio_monitor_active[audio+1];
-       up(&chip->mixer_mutex);
+       mutex_unlock(&chip->mixer_mutex);
        return 0;
 }
 
@@ -698,26 +702,31 @@ static int vx_monitor_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_
        struct vx_core *chip = snd_kcontrol_chip(kcontrol);
        int audio = kcontrol->private_value & 0xff;
 
-       down(&chip->mixer_mutex);
+       mutex_lock(&chip->mixer_mutex);
        if (ucontrol->value.integer.value[0] != chip->audio_monitor_active[audio] ||
            ucontrol->value.integer.value[1] != chip->audio_monitor_active[audio+1]) {
                vx_set_monitor_level(chip, audio, chip->audio_monitor[audio],
                                     ucontrol->value.integer.value[0]);
                vx_set_monitor_level(chip, audio+1, chip->audio_monitor[audio+1],
                                     ucontrol->value.integer.value[1]);
-               up(&chip->mixer_mutex);
+               mutex_unlock(&chip->mixer_mutex);
                return 1;
        }
-       up(&chip->mixer_mutex);
+       mutex_unlock(&chip->mixer_mutex);
        return 0;
 }
 
+static const DECLARE_TLV_DB_SCALE(db_scale_audio_gain, -10975, 25, 0);
+
 static struct snd_kcontrol_new vx_control_audio_gain = {
        .iface =        SNDRV_CTL_ELEM_IFACE_MIXER,
+       .access =       (SNDRV_CTL_ELEM_ACCESS_READWRITE |
+                        SNDRV_CTL_ELEM_ACCESS_TLV_READ),
        /* name will be filled later */
        .info =         vx_audio_gain_info,
        .get =          vx_audio_gain_get,
-       .put =          vx_audio_gain_put
+       .put =          vx_audio_gain_put,
+       .tlv = { .p = db_scale_audio_gain },
 };
 static struct snd_kcontrol_new vx_control_output_switch = {
        .iface =        SNDRV_CTL_ELEM_IFACE_MIXER,
@@ -729,9 +738,12 @@ static struct snd_kcontrol_new vx_control_output_switch = {
 static struct snd_kcontrol_new vx_control_monitor_gain = {
        .iface =        SNDRV_CTL_ELEM_IFACE_MIXER,
        .name =         "Monitoring Volume",
+       .access =       (SNDRV_CTL_ELEM_ACCESS_READWRITE |
+                        SNDRV_CTL_ELEM_ACCESS_TLV_READ),
        .info =         vx_audio_gain_info,     /* shared */
        .get =          vx_audio_monitor_get,
-       .put =          vx_audio_monitor_put
+       .put =          vx_audio_monitor_put,
+       .tlv = { .p = db_scale_audio_gain },
 };
 static struct snd_kcontrol_new vx_control_monitor_switch = {
        .iface =        SNDRV_CTL_ELEM_IFACE_MIXER,
@@ -756,12 +768,12 @@ static int vx_iec958_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_valu
 {
        struct vx_core *chip = snd_kcontrol_chip(kcontrol);
 
-       down(&chip->mixer_mutex);
+       mutex_lock(&chip->mixer_mutex);
        ucontrol->value.iec958.status[0] = (chip->uer_bits >> 0) & 0xff;
        ucontrol->value.iec958.status[1] = (chip->uer_bits >> 8) & 0xff;
        ucontrol->value.iec958.status[2] = (chip->uer_bits >> 16) & 0xff;
        ucontrol->value.iec958.status[3] = (chip->uer_bits >> 24) & 0xff;
-       up(&chip->mixer_mutex);
+       mutex_unlock(&chip->mixer_mutex);
         return 0;
 }
 
@@ -783,14 +795,14 @@ static int vx_iec958_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_valu
              (ucontrol->value.iec958.status[1] << 8) |
              (ucontrol->value.iec958.status[2] << 16) |
              (ucontrol->value.iec958.status[3] << 24);
-       down(&chip->mixer_mutex);
+       mutex_lock(&chip->mixer_mutex);
        if (chip->uer_bits != val) {
                chip->uer_bits = val;
                vx_set_iec958_status(chip, val);
-               up(&chip->mixer_mutex);
+               mutex_unlock(&chip->mixer_mutex);
                return 1;
        }
-       up(&chip->mixer_mutex);
+       mutex_unlock(&chip->mixer_mutex);
        return 0;
 }
 
@@ -918,6 +930,7 @@ int snd_vx_mixer_new(struct vx_core *chip)
        for (i = 0; i < chip->hw->num_outs; i++) {
                temp = vx_control_output_level;
                temp.index = i;
+               temp.tlv.p = chip->hw->output_level_db_scale;
                if ((err = snd_ctl_add(card, snd_ctl_new1(&temp, chip))) < 0)
                        return err;
        }