]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[ALSA] oxygen: generalize handling of DAC volume limits
authorClemens Ladisch <clemens@ladisch.de>
Wed, 16 Apr 2008 07:13:36 +0000 (09:13 +0200)
committerTakashi Iwai <tiwai@suse.de>
Thu, 24 Apr 2008 10:00:36 +0000 (12:00 +0200)
Add fields for the DAC volume limits to the module structure so that
model drivers do not need to install their own control info handlers.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/oxygen/hifier.c
sound/pci/oxygen/oxygen.c
sound/pci/oxygen/oxygen.h
sound/pci/oxygen/oxygen_lib.c
sound/pci/oxygen/oxygen_mixer.c
sound/pci/oxygen/virtuoso.c

index b67888f6745b377a2b398ec11a6bf7cf48f501d2..bf39c72a130c686c0466043ebb3e57d0eef9dddc 100644 (file)
@@ -153,6 +153,8 @@ static const struct oxygen_model model_hifier = {
                       PLAYBACK_1_TO_SPDIF |
                       CAPTURE_0_FROM_I2S_1,
        .dac_channels = 2,
+       .dac_volume_min = 0,
+       .dac_volume_max = 255,
        .function_flags = OXYGEN_FUNCTION_SPI,
        .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
        .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
index b3b7771b54c02c354abe7b0e65da8a2de323d06b..718169792c3b4fe982dc375f2bd2fe106656875c 100644 (file)
@@ -278,6 +278,8 @@ static const struct oxygen_model model_generic = {
                       CAPTURE_1_FROM_SPDIF |
                       CAPTURE_2_FROM_AC97_1,
        .dac_channels = 8,
+       .dac_volume_min = 0,
+       .dac_volume_max = 255,
        .function_flags = OXYGEN_FUNCTION_SPI |
                          OXYGEN_FUNCTION_ENABLE_SPI_4_5,
        .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
@@ -303,6 +305,8 @@ static const struct oxygen_model model_meridian = {
                       CAPTURE_1_FROM_SPDIF |
                       CAPTURE_2_FROM_AC97_1,
        .dac_channels = 8,
+       .dac_volume_min = 0,
+       .dac_volume_max = 255,
        .misc_flags = OXYGEN_MISC_MIDI,
        .function_flags = OXYGEN_FUNCTION_SPI |
                          OXYGEN_FUNCTION_ENABLE_SPI_4_5,
index 7efbf54bc4ec1c1f0bef1e3e2698ed10b5373462..36f2f81fefc52693825edba31f1c038a0e043cde 100644 (file)
@@ -103,6 +103,8 @@ struct oxygen_model {
        size_t model_data_size;
        unsigned int pcm_dev_cfg;
        u8 dac_channels;
+       u8 dac_volume_min;
+       u8 dac_volume_max;
        u8 misc_flags;
        u8 function_flags;
        u16 dac_i2s_format;
index 39e4b7a5174007ec447b515a53aaa0eaaa027b16..b7aa9fcb6b811fd3f3beedbb488445c63d882bef 100644 (file)
@@ -221,7 +221,7 @@ static void oxygen_init(struct oxygen *chip)
 
        chip->dac_routing = 1;
        for (i = 0; i < 8; ++i)
-               chip->dac_volume[i] = 0xff;
+               chip->dac_volume[i] = chip->model->dac_volume_max;
        chip->spdif_playback_enable = 1;
        chip->spdif_bits = OXYGEN_SPDIF_C | OXYGEN_SPDIF_ORIGINAL |
                (IEC958_AES1_CON_PCM_CODER << OXYGEN_SPDIF_CATEGORY_SHIFT);
index 2cb914498a19ff7c601df48a9ea5b79218b4b67f..056581ecd915df06b0610e90083e29687a8d98d2 100644 (file)
@@ -32,8 +32,8 @@ static int dac_volume_info(struct snd_kcontrol *ctl,
 
        info->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
        info->count = chip->model->dac_channels;
-       info->value.integer.min = 0;
-       info->value.integer.max = 0xff;
+       info->value.integer.min = chip->model->dac_volume_min;
+       info->value.integer.max = chip->model->dac_volume_max;
        return 0;
 }
 
index 6f5c2531abd0b8e548cc9443d55fc4a97c458570..37f53a8c5888770ad817b9175444f4a3ca72b59e 100644 (file)
@@ -219,10 +219,7 @@ static void xonar_d2x_init(struct oxygen *chip)
 static void xonar_dx_init(struct oxygen *chip)
 {
        struct xonar_data *data = chip->model_data;
-       unsigned int i;
 
-       for (i = 0; i < 8; ++i)
-               chip->dac_volume[i] = 127;
        data->anti_pop_delay = 800;
        data->output_enable_bit = GPIO_DX_OUTPUT_ENABLE;
        data->ext_power_reg = OXYGEN_GPI_DATA;
@@ -414,26 +411,6 @@ static void xonar_gpio_changed(struct oxygen *chip)
        }
 }
 
-static int pcm1796_volume_info(struct snd_kcontrol *ctl,
-                              struct snd_ctl_elem_info *info)
-{
-       info->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
-       info->count = 8;
-       info->value.integer.min = 0x0f;
-       info->value.integer.max = 0xff;
-       return 0;
-}
-
-static int cs4362a_volume_info(struct snd_kcontrol *ctl,
-                              struct snd_ctl_elem_info *info)
-{
-       info->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
-       info->count = 8;
-       info->value.integer.min = 0;
-       info->value.integer.max = 127;
-       return 0;
-}
-
 static int alt_switch_get(struct snd_kcontrol *ctl,
                          struct snd_ctl_elem_value *value)
 {
@@ -526,7 +503,6 @@ static int xonar_d2_control_filter(struct snd_kcontrol_new *template)
 {
        if (!strcmp(template->name, "Master Playback Volume")) {
                template->access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ;
-               template->info = pcm1796_volume_info;
                template->tlv.p = pcm1796_db_scale;
        } else if (!strncmp(template->name, "CD Capture ", 11)) {
                /* CD in is actually connected to the video in pin */
@@ -539,7 +515,6 @@ static int xonar_dx_control_filter(struct snd_kcontrol_new *template)
 {
        if (!strcmp(template->name, "Master Playback Volume")) {
                template->access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ;
-               template->info = cs4362a_volume_info;
                template->tlv.p = cs4362a_db_scale;
        } else if (!strncmp(template->name, "CD Capture ", 11)) {
                return 1; /* no CD input */
@@ -577,6 +552,8 @@ static const struct oxygen_model xonar_models[] = {
                               CAPTURE_0_FROM_I2S_2 |
                               CAPTURE_1_FROM_SPDIF,
                .dac_channels = 8,
+               .dac_volume_min = 0x0f,
+               .dac_volume_max = 0xff,
                .misc_flags = OXYGEN_MISC_MIDI,
                .function_flags = OXYGEN_FUNCTION_SPI |
                                  OXYGEN_FUNCTION_ENABLE_SPI_4_5,
@@ -603,6 +580,8 @@ static const struct oxygen_model xonar_models[] = {
                               CAPTURE_0_FROM_I2S_2 |
                               CAPTURE_1_FROM_SPDIF,
                .dac_channels = 8,
+               .dac_volume_min = 0x0f,
+               .dac_volume_max = 0xff,
                .misc_flags = OXYGEN_MISC_MIDI,
                .function_flags = OXYGEN_FUNCTION_SPI |
                                  OXYGEN_FUNCTION_ENABLE_SPI_4_5,
@@ -629,6 +608,8 @@ static const struct oxygen_model xonar_models[] = {
                               PLAYBACK_1_TO_SPDIF |
                               CAPTURE_0_FROM_I2S_2,
                .dac_channels = 8,
+               .dac_volume_min = 0,
+               .dac_volume_max = 127,
                .function_flags = OXYGEN_FUNCTION_2WIRE,
                .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
                .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST,