]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - sound/pci/oxygen/hifier.c
ALSA: oxygen: add probe callback
[linux-2.6-omap-h63xx.git] / sound / pci / oxygen / hifier.c
index c5d2c86cacb224afa664539e1dc2070ccececdd4..173d6dddc937de3e947cf405b3d1cb9a3e164bd8 100644 (file)
@@ -17,6 +17,7 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  */
 
+#include <linux/delay.h>
 #include <linux/pci.h>
 #include <sound/control.h>
 #include <sound/core.h>
@@ -62,16 +63,28 @@ static void ak4396_write(struct oxygen *chip, u8 reg, u8 value)
                         AK4396_WRITE | (reg << 8) | value);
 }
 
-static void hifier_init(struct oxygen *chip)
+static void update_ak4396_volume(struct oxygen *chip)
+{
+       ak4396_write(chip, AK4396_LCH_ATT, chip->dac_volume[0]);
+       ak4396_write(chip, AK4396_RCH_ATT, chip->dac_volume[1]);
+}
+
+static void hifier_registers_init(struct oxygen *chip)
 {
        struct hifier_data *data = chip->model_data;
 
-       data->ak4396_ctl2 = AK4396_SMUTE | AK4396_DEM_OFF | AK4396_DFS_NORMAL;
        ak4396_write(chip, AK4396_CONTROL_1, AK4396_DIF_24_MSB | AK4396_RSTN);
        ak4396_write(chip, AK4396_CONTROL_2, data->ak4396_ctl2);
        ak4396_write(chip, AK4396_CONTROL_3, AK4396_PCM);
-       ak4396_write(chip, AK4396_LCH_ATT, 0);
-       ak4396_write(chip, AK4396_RCH_ATT, 0);
+       update_ak4396_volume(chip);
+}
+
+static void hifier_init(struct oxygen *chip)
+{
+       struct hifier_data *data = chip->model_data;
+
+       data->ak4396_ctl2 = AK4396_SMUTE | AK4396_DEM_OFF | AK4396_DFS_NORMAL;
+       hifier_registers_init(chip);
 
        snd_component_add(chip->card, "AK4396");
        snd_component_add(chip->card, "CS5340");
@@ -95,17 +108,14 @@ static void set_ak4396_params(struct oxygen *chip,
        else
                value |= AK4396_DFS_QUAD;
        data->ak4396_ctl2 = value;
+
+       msleep(1); /* wait for the new MCLK to become stable */
+
        ak4396_write(chip, AK4396_CONTROL_1, AK4396_DIF_24_MSB);
        ak4396_write(chip, AK4396_CONTROL_2, value);
        ak4396_write(chip, AK4396_CONTROL_1, AK4396_DIF_24_MSB | AK4396_RSTN);
 }
 
-static void update_ak4396_volume(struct oxygen *chip)
-{
-       ak4396_write(chip, AK4396_LCH_ATT, chip->dac_volume[0]);
-       ak4396_write(chip, AK4396_RCH_ATT, chip->dac_volume[1]);
-}
-
 static void update_ak4396_mute(struct oxygen *chip)
 {
        struct hifier_data *data = chip->model_data;
@@ -140,6 +150,7 @@ static const struct oxygen_model model_hifier = {
        .init = hifier_init,
        .control_filter = hifier_control_filter,
        .cleanup = hifier_cleanup,
+       .resume = hifier_registers_init,
        .set_dac_params = set_ak4396_params,
        .set_adc_params = set_cs5340_params,
        .update_dac_volume = update_ak4396_volume,
@@ -169,7 +180,7 @@ static int __devinit hifier_probe(struct pci_dev *pci,
                ++dev;
                return -ENOENT;
        }
-       err = oxygen_pci_probe(pci, index[dev], id[dev], &model_hifier);
+       err = oxygen_pci_probe(pci, index[dev], id[dev], &model_hifier, 0);
        if (err >= 0)
                ++dev;
        return err;
@@ -180,6 +191,10 @@ static struct pci_driver hifier_driver = {
        .id_table = hifier_ids,
        .probe = hifier_probe,
        .remove = __devexit_p(oxygen_pci_remove),
+#ifdef CONFIG_PM
+       .suspend = oxygen_pci_suspend,
+       .resume = oxygen_pci_resume,
+#endif
 };
 
 static int __init alsa_card_hifier_init(void)