ASoC: TWL4030: Add support for platform dependent configuration
authorPeter Ujfalusi <peter.ujfalusi@nokia.com>
Fri, 22 May 2009 07:13:15 +0000 (10:13 +0300)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Fri, 22 May 2009 09:23:22 +0000 (10:23 +0100)
twl4030_setup_data structure can be passed from platform drivers to
the codec via the snd_soc_device->codec_data pointer.

Currently the setup data has support for the Headset pop-removal
related configuration, which differs from board to board.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
sound/soc/codecs/twl4030.c
sound/soc/codecs/twl4030.h

index f554672f67c1cbf0bc67ad9438d7db87d62fb889..584507f71efbef91113562d1baed90621bcda2de 100644 (file)
@@ -1997,6 +1997,8 @@ static int twl4030_resume(struct platform_device *pdev)
 static int twl4030_init(struct snd_soc_device *socdev)
 {
        struct snd_soc_codec *codec = socdev->card->codec;
+       struct twl4030_setup_data *setup = socdev->codec_data;
+       struct twl4030_priv *twl4030 = codec->private_data;
        int ret = 0;
 
        printk(KERN_INFO "TWL4030 Audio Codec init \n");
@@ -2014,6 +2016,23 @@ static int twl4030_init(struct snd_soc_device *socdev)
        if (codec->reg_cache == NULL)
                return -ENOMEM;
 
+       /* Configuration for headset ramp delay from setup data */
+       if (setup) {
+               unsigned char hs_pop;
+
+               if (setup->sysclk)
+                       twl4030->sysclk = setup->sysclk;
+               else
+                       twl4030->sysclk = 26000;
+
+               hs_pop = twl4030_read_reg_cache(codec, TWL4030_REG_HS_POPN_SET);
+               hs_pop &= ~TWL4030_RAMP_DELAY;
+               hs_pop |= (setup->ramp_delay_value << 2);
+               twl4030_write_reg_cache(codec, TWL4030_REG_HS_POPN_SET, hs_pop);
+       } else {
+               twl4030->sysclk = 26000;
+       }
+
        /* register pcms */
        ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
        if (ret < 0) {
@@ -2063,9 +2082,6 @@ static int twl4030_probe(struct platform_device *pdev)
                kfree(codec);
                return -ENOMEM;
        }
-       /* Set default sysclk (used by the headsetl/rpga_event callback for
-        * pop-attenuation) */
-       twl4030->sysclk = 26000;
 
        codec->private_data = twl4030;
        socdev->card->codec = codec;
index 9668bdf430fb331689400449eb8ebbe66a48f570..48326e2bd9de15ae7640ca0934ca4a566c04bca0 100644 (file)
 extern struct snd_soc_dai twl4030_dai[2];
 extern struct snd_soc_codec_device soc_codec_dev_twl4030;
 
+struct twl4030_setup_data {
+       unsigned int ramp_delay_value;
+       unsigned int sysclk;
+};
+
 #endif /* End of __TWL4030_AUDIO_H__ */