ALSA: oxygen: allow to dump codec registers
authorClemens Ladisch <clemens@ladisch.de>
Thu, 2 Dec 2010 10:41:10 +0000 (11:41 +0100)
committerTakashi Iwai <tiwai@suse.de>
Mon, 6 Dec 2010 13:48:15 +0000 (14:48 +0100)
To help with debugging, add the registers of the model-specific
codecs to the controller and AC97 register dump in the proc file.

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

index ea8fffefad9f5c405aa243f7c7c422c467240036..a58e448fc1bfe2b376ce917fbaa03549efd30f59 100644 (file)
@@ -41,6 +41,7 @@
 #include <sound/ac97_codec.h>
 #include <sound/control.h>
 #include <sound/core.h>
+#include <sound/info.h>
 #include <sound/initval.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
@@ -518,6 +519,39 @@ static int generic_wm8785_mixer_init(struct oxygen *chip)
        return 0;
 }
 
+static void dump_ak4396_registers(struct oxygen *chip,
+                                 struct snd_info_buffer *buffer)
+{
+       struct generic_data *data = chip->model_data;
+       unsigned int dac, i;
+
+       for (dac = 0; dac < data->dacs; ++dac) {
+               snd_iprintf(buffer, "\nAK4396 %u:", dac + 1);
+               for (i = 0; i < 5; ++i)
+                       snd_iprintf(buffer, " %02x", data->ak4396_regs[dac][i]);
+       }
+       snd_iprintf(buffer, "\n");
+}
+
+static void dump_wm8785_registers(struct oxygen *chip,
+                                 struct snd_info_buffer *buffer)
+{
+       struct generic_data *data = chip->model_data;
+       unsigned int i;
+
+       snd_iprintf(buffer, "\nWM8785:");
+       for (i = 0; i < 3; ++i)
+               snd_iprintf(buffer, " %03x", data->wm8785_regs[i]);
+       snd_iprintf(buffer, "\n");
+}
+
+static void dump_oxygen_registers(struct oxygen *chip,
+                                 struct snd_info_buffer *buffer)
+{
+       dump_ak4396_registers(chip, buffer);
+       dump_wm8785_registers(chip, buffer);
+}
+
 static const DECLARE_TLV_DB_LINEAR(ak4396_db_scale, TLV_DB_GAIN_MUTE, 0);
 
 static const struct oxygen_model model_generic = {
@@ -533,6 +567,7 @@ static const struct oxygen_model model_generic = {
        .set_adc_params = set_wm8785_params,
        .update_dac_volume = update_ak4396_volume,
        .update_dac_mute = update_ak4396_mute,
+       .dump_registers = dump_oxygen_registers,
        .dac_tlv = ak4396_db_scale,
        .model_data_size = sizeof(struct generic_data),
        .device_config = PLAYBACK_0_TO_I2S |
@@ -561,6 +596,7 @@ static int __devinit get_oxygen_model(struct oxygen *chip,
                chip->model.mixer_init = generic_mixer_init;
                chip->model.resume = meridian_resume;
                chip->model.set_adc_params = set_ak5385_params;
+               chip->model.dump_registers = dump_ak4396_registers;
                chip->model.device_config = PLAYBACK_0_TO_I2S |
                                            PLAYBACK_1_TO_SPDIF |
                                            CAPTURE_0_FROM_I2S_2 |
@@ -579,6 +615,7 @@ static int __devinit get_oxygen_model(struct oxygen *chip,
                chip->model.suspend = claro_suspend;
                chip->model.resume = claro_resume;
                chip->model.set_adc_params = set_ak5385_params;
+               chip->model.dump_registers = dump_ak4396_registers;
                chip->model.device_config = PLAYBACK_0_TO_I2S |
                                            PLAYBACK_1_TO_SPDIF |
                                            CAPTURE_0_FROM_I2S_2 |
@@ -595,6 +632,7 @@ static int __devinit get_oxygen_model(struct oxygen *chip,
                chip->model.resume = stereo_resume;
                chip->model.mixer_init = generic_mixer_init;
                chip->model.set_adc_params = set_no_params;
+               chip->model.dump_registers = dump_ak4396_registers;
                chip->model.device_config = PLAYBACK_0_TO_I2S |
                                            PLAYBACK_1_TO_SPDIF;
                if (id->driver_data == MODEL_FANTASIA)
index cf9054ecb97b8566e66b3b9ba7d5f055c539aca0..b8fbc15b89a30ec8d1c11cdfcc158efca8ac707b 100644 (file)
@@ -66,6 +66,7 @@ struct snd_pcm_hardware;
 struct snd_pcm_hw_params;
 struct snd_kcontrol_new;
 struct snd_rawmidi;
+struct snd_info_buffer;
 struct oxygen;
 
 struct oxygen_model {
@@ -93,6 +94,8 @@ struct oxygen_model {
        void (*uart_input)(struct oxygen *chip);
        void (*ac97_switch)(struct oxygen *chip,
                            unsigned int reg, unsigned int mute);
+       void (*dump_registers)(struct oxygen *chip,
+                              struct snd_info_buffer *buffer);
        const unsigned int *dac_tlv;
        unsigned long private_data;
        size_t model_data_size;
index 2e65799622173731264a68eadcd73f81e5d15857..e581e7ab216cc6e2e310a11b9e59587dcec26432 100644 (file)
@@ -202,7 +202,7 @@ static void oxygen_proc_read(struct snd_info_entry *entry,
        struct oxygen *chip = entry->private_data;
        int i, j;
 
-       snd_iprintf(buffer, "CMI8788\n\n");
+       snd_iprintf(buffer, "CMI8788:\n");
        for (i = 0; i < OXYGEN_IO_SIZE; i += 0x10) {
                snd_iprintf(buffer, "%02x:", i);
                for (j = 0; j < 0x10; ++j)
@@ -212,7 +212,7 @@ static void oxygen_proc_read(struct snd_info_entry *entry,
        if (mutex_lock_interruptible(&chip->mutex) < 0)
                return;
        if (chip->has_ac97_0) {
-               snd_iprintf(buffer, "\nAC97\n");
+               snd_iprintf(buffer, "\nAC97:\n");
                for (i = 0; i < 0x80; i += 0x10) {
                        snd_iprintf(buffer, "%02x:", i);
                        for (j = 0; j < 0x10; j += 2)
@@ -222,7 +222,7 @@ static void oxygen_proc_read(struct snd_info_entry *entry,
                }
        }
        if (chip->has_ac97_1) {
-               snd_iprintf(buffer, "\nAC97 2\n");
+               snd_iprintf(buffer, "\nAC97 2:\n");
                for (i = 0; i < 0x80; i += 0x10) {
                        snd_iprintf(buffer, "%02x:", i);
                        for (j = 0; j < 0x10; j += 2)
@@ -232,13 +232,15 @@ static void oxygen_proc_read(struct snd_info_entry *entry,
                }
        }
        mutex_unlock(&chip->mutex);
+       if (chip->model.dump_registers)
+               chip->model.dump_registers(chip, buffer);
 }
 
 static void oxygen_proc_init(struct oxygen *chip)
 {
        struct snd_info_entry *entry;
 
-       if (!snd_card_proc_new(chip->card, "cmi8788", &entry))
+       if (!snd_card_proc_new(chip->card, "oxygen", &entry))
                snd_info_set_text_ops(entry, chip, oxygen_proc_read);
 }
 #else
index 501fe45bbdce80a0287e870d8ba463c8d699a802..092addb15e139986a5dfe55d9b9d85e5575b593f 100644 (file)
@@ -381,6 +381,30 @@ static int xonar_d1_mixer_init(struct oxygen *chip)
        return 0;
 }
 
+static void dump_cs4362a_registers(struct xonar_cs43xx *data,
+                                  struct snd_info_buffer *buffer)
+{
+       unsigned int i;
+
+       snd_iprintf(buffer, "\nCS4362A:");
+       for (i = 1; i <= 14; ++i)
+               snd_iprintf(buffer, " %02x", data->cs4362a_regs[i]);
+       snd_iprintf(buffer, "\n");
+}
+
+static void dump_d1_registers(struct oxygen *chip,
+                             struct snd_info_buffer *buffer)
+{
+       struct xonar_cs43xx *data = chip->model_data;
+       unsigned int i;
+
+       snd_iprintf(buffer, "\nCS4398: 7?");
+       for (i = 2; i <= 8; ++i)
+               snd_iprintf(buffer, " %02x", data->cs4398_regs[i]);
+       snd_iprintf(buffer, "\n");
+       dump_cs4362a_registers(data, buffer);
+}
+
 static const struct oxygen_model model_xonar_d1 = {
        .longname = "Asus Virtuoso 100",
        .chip = "AV200",
@@ -396,6 +420,7 @@ static const struct oxygen_model model_xonar_d1 = {
        .update_dac_mute = update_cs43xx_mute,
        .update_center_lfe_mix = update_cs43xx_center_lfe_mix,
        .ac97_switch = xonar_d1_line_mic_ac97_switch,
+       .dump_registers = dump_d1_registers,
        .dac_tlv = cs4362a_db_scale,
        .model_data_size = sizeof(struct xonar_cs43xx),
        .device_config = PLAYBACK_0_TO_I2S |
index 5193d73a916dbb5b2a9bae90b64df5a64b433bd1..dc69fddf2e6ecc7524c44700df1a22db0ff092ff 100644 (file)
 #include <sound/ac97_codec.h>
 #include <sound/control.h>
 #include <sound/core.h>
+#include <sound/info.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
 #include <sound/tlv.h>
@@ -192,7 +193,7 @@ struct xonar_pcm179x {
        bool hp_active;
        s8 hp_gain_offset;
        bool has_cs2000;
-       u8 cs2000_fun_cfg_1;
+       u8 cs2000_regs[0x1f];
 };
 
 struct xonar_hdav {
@@ -251,16 +252,14 @@ static void cs2000_write(struct oxygen *chip, u8 reg, u8 value)
        struct xonar_pcm179x *data = chip->model_data;
 
        oxygen_write_i2c(chip, I2C_DEVICE_CS2000, reg, value);
-       if (reg == CS2000_FUN_CFG_1)
-               data->cs2000_fun_cfg_1 = value;
+       data->cs2000_regs[reg] = value;
 }
 
 static void cs2000_write_cached(struct oxygen *chip, u8 reg, u8 value)
 {
        struct xonar_pcm179x *data = chip->model_data;
 
-       if (reg != CS2000_FUN_CFG_1 ||
-           value != data->cs2000_fun_cfg_1)
+       if (value != data->cs2000_regs[reg])
                cs2000_write(chip, reg, value);
 }
 
@@ -414,7 +413,8 @@ static void cs2000_registers_init(struct oxygen *chip)
        cs2000_write(chip, CS2000_RATIO_0 + 1, 0x10);
        cs2000_write(chip, CS2000_RATIO_0 + 2, 0x00);
        cs2000_write(chip, CS2000_RATIO_0 + 3, 0x00);
-       cs2000_write(chip, CS2000_FUN_CFG_1, data->cs2000_fun_cfg_1);
+       cs2000_write(chip, CS2000_FUN_CFG_1,
+                    data->cs2000_regs[CS2000_FUN_CFG_1]);
        cs2000_write(chip, CS2000_FUN_CFG_2, 0);
        cs2000_write(chip, CS2000_GLOBAL_CFG, CS2000_EN_DEV_CFG_2);
 }
@@ -425,7 +425,7 @@ static void xonar_st_init(struct oxygen *chip)
 
        data->generic.anti_pop_delay = 100;
        data->has_cs2000 = 1;
-       data->cs2000_fun_cfg_1 = CS2000_REF_CLK_DIV_1;
+       data->cs2000_regs[CS2000_FUN_CFG_1] = CS2000_REF_CLK_DIV_1;
 
        oxygen_write16(chip, OXYGEN_I2S_A_FORMAT,
                       OXYGEN_RATE_48000 | OXYGEN_I2S_FORMAT_I2S |
@@ -997,6 +997,45 @@ static int xonar_st_mixer_init(struct oxygen *chip)
        return 0;
 }
 
+static void dump_pcm1796_registers(struct oxygen *chip,
+                                  struct snd_info_buffer *buffer)
+{
+       struct xonar_pcm179x *data = chip->model_data;
+       unsigned int dac, i;
+
+       for (dac = 0; dac < data->dacs; ++dac) {
+               snd_iprintf(buffer, "\nPCM1796 %u:", dac + 1);
+               for (i = 0; i < 5; ++i)
+                       snd_iprintf(buffer, " %02x",
+                                   data->pcm1796_regs[dac][i]);
+       }
+       snd_iprintf(buffer, "\n");
+}
+
+static void dump_cs2000_registers(struct oxygen *chip,
+                                 struct snd_info_buffer *buffer)
+{
+       struct xonar_pcm179x *data = chip->model_data;
+       unsigned int i;
+
+       if (data->has_cs2000) {
+               snd_iprintf(buffer, "\nCS2000:\n00:   ");
+               for (i = 1; i < 0x10; ++i)
+                       snd_iprintf(buffer, " %02x", data->cs2000_regs[i]);
+               snd_iprintf(buffer, "\n10:");
+               for (i = 0x10; i < 0x1f; ++i)
+                       snd_iprintf(buffer, " %02x", data->cs2000_regs[i]);
+               snd_iprintf(buffer, "\n");
+       }
+}
+
+static void dump_st_registers(struct oxygen *chip,
+                             struct snd_info_buffer *buffer)
+{
+       dump_pcm1796_registers(chip, buffer);
+       dump_cs2000_registers(chip, buffer);
+}
+
 static const struct oxygen_model model_xonar_d2 = {
        .longname = "Asus Virtuoso 200",
        .chip = "AV200",
@@ -1011,6 +1050,7 @@ static const struct oxygen_model model_xonar_d2 = {
        .set_adc_params = xonar_set_cs53x1_params,
        .update_dac_volume = update_pcm1796_volume,
        .update_dac_mute = update_pcm1796_mute,
+       .dump_registers = dump_pcm1796_registers,
        .dac_tlv = pcm1796_db_scale,
        .model_data_size = sizeof(struct xonar_pcm179x),
        .device_config = PLAYBACK_0_TO_I2S |
@@ -1046,6 +1086,7 @@ static const struct oxygen_model model_xonar_hdav = {
        .update_dac_mute = update_pcm1796_mute,
        .uart_input = xonar_hdmi_uart_input,
        .ac97_switch = xonar_line_mic_ac97_switch,
+       .dump_registers = dump_pcm1796_registers,
        .dac_tlv = pcm1796_db_scale,
        .model_data_size = sizeof(struct xonar_hdav),
        .device_config = PLAYBACK_0_TO_I2S |
@@ -1075,6 +1116,7 @@ static const struct oxygen_model model_xonar_st = {
        .update_dac_volume = update_pcm1796_volume,
        .update_dac_mute = update_pcm1796_mute,
        .ac97_switch = xonar_line_mic_ac97_switch,
+       .dump_registers = dump_st_registers,
        .dac_tlv = pcm1796_db_scale,
        .model_data_size = sizeof(struct xonar_pcm179x),
        .device_config = PLAYBACK_0_TO_I2S |
index 200f7601276f8e5b5fa841a34ea5ad4a07c0fc44..2b5e69b6470859235c0061a941915c442ddaf623 100644 (file)
@@ -42,6 +42,7 @@
 #include <linux/delay.h>
 #include <sound/control.h>
 #include <sound/core.h>
+#include <sound/info.h>
 #include <sound/jack.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
@@ -1062,6 +1063,34 @@ static int xonar_ds_mixer_init(struct oxygen *chip)
        return 0;
 }
 
+static void dump_wm8776_registers(struct oxygen *chip,
+                                 struct snd_info_buffer *buffer)
+{
+       struct xonar_wm87x6 *data = chip->model_data;
+       unsigned int i;
+
+       snd_iprintf(buffer, "\nWM8776:\n00:");
+       for (i = 0; i < 0x10; ++i)
+               snd_iprintf(buffer, " %03x", data->wm8776_regs[i]);
+       snd_iprintf(buffer, "\n10:");
+       for (i = 0x10; i < 0x17; ++i)
+               snd_iprintf(buffer, " %03x", data->wm8776_regs[i]);
+       snd_iprintf(buffer, "\n");
+}
+
+static void dump_wm87x6_registers(struct oxygen *chip,
+                                 struct snd_info_buffer *buffer)
+{
+       struct xonar_wm87x6 *data = chip->model_data;
+       unsigned int i;
+
+       dump_wm8776_registers(chip, buffer);
+       snd_iprintf(buffer, "\nWM8766:\n00:");
+       for (i = 0; i < 0x10; ++i)
+               snd_iprintf(buffer, " %03x", data->wm8766_regs[i]);
+       snd_iprintf(buffer, "\n");
+}
+
 static const struct oxygen_model model_xonar_ds = {
        .shortname = "Xonar DS",
        .longname = "Asus Virtuoso 66",
@@ -1079,6 +1108,7 @@ static const struct oxygen_model model_xonar_ds = {
        .update_dac_mute = update_wm87x6_mute,
        .update_center_lfe_mix = update_wm8766_center_lfe_mix,
        .gpio_changed = xonar_ds_gpio_changed,
+       .dump_registers = dump_wm87x6_registers,
        .dac_tlv = wm87x6_dac_db_scale,
        .model_data_size = sizeof(struct xonar_wm87x6),
        .device_config = PLAYBACK_0_TO_I2S |