static int uda134x_soc_suspend(struct snd_soc_codec *codec, pm_message_t state) { uda134x_set_bias_level(codec, SND_SOC_BIAS_STANDBY); uda134x_set_bias_level(codec, SND_SOC_BIAS_OFF); return 0; }
static int uda134x_soc_resume(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); struct snd_soc_codec *codec = socdev->card->codec; uda134x_set_bias_level(codec, SND_SOC_BIAS_PREPARE); uda134x_set_bias_level(codec, SND_SOC_BIAS_ON); return 0; }
/* power down chip */ static int uda134x_soc_remove(struct snd_soc_codec *codec) { struct uda134x_priv *uda134x = snd_soc_codec_get_drvdata(codec); uda134x_set_bias_level(codec, SND_SOC_BIAS_STANDBY); uda134x_set_bias_level(codec, SND_SOC_BIAS_OFF); kfree(uda134x); return 0; }
static int uda134x_soc_suspend(struct platform_device *pdev, pm_message_t state) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); struct snd_soc_codec *codec = socdev->card->codec; uda134x_set_bias_level(codec, SND_SOC_BIAS_STANDBY); uda134x_set_bias_level(codec, SND_SOC_BIAS_OFF); return 0; }
/* power down chip */ static int uda134x_soc_remove(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); struct snd_soc_codec *codec = socdev->card->codec; uda134x_set_bias_level(codec, SND_SOC_BIAS_STANDBY); uda134x_set_bias_level(codec, SND_SOC_BIAS_OFF); snd_soc_free_pcms(socdev); snd_soc_dapm_free(socdev); kfree(snd_soc_codec_get_drvdata(codec)); kfree(codec->reg_cache); kfree(codec); return 0; }
static int uda134x_soc_resume(struct snd_soc_codec *codec) { uda134x_set_bias_level(codec, SND_SOC_BIAS_PREPARE); uda134x_set_bias_level(codec, SND_SOC_BIAS_ON); return 0; }
static int uda134x_soc_probe(struct snd_soc_codec *codec) { struct uda134x_priv *uda134x; struct uda134x_platform_data *pd = codec->card->dev->platform_data; const struct snd_soc_dapm_widget *widgets; unsigned num_widgets; int ret; printk(KERN_INFO "UDA134X SoC Audio Codec\n"); if (!pd) { printk(KERN_ERR "UDA134X SoC codec: " "missing L3 bitbang function\n"); return -ENODEV; } switch (pd->model) { case UDA134X_UDA1340: case UDA134X_UDA1341: case UDA134X_UDA1344: case UDA134X_UDA1345: break; default: printk(KERN_ERR "UDA134X SoC codec: " "unsupported model %d\n", pd->model); return -EINVAL; } uda134x = kzalloc(sizeof(struct uda134x_priv), GFP_KERNEL); if (uda134x == NULL) return -ENOMEM; snd_soc_codec_set_drvdata(codec, uda134x); codec->control_data = pd; if (pd->power) pd->power(1); uda134x_reset(codec); if (pd->is_powered_on_standby) uda134x_set_bias_level(codec, SND_SOC_BIAS_ON); else uda134x_set_bias_level(codec, SND_SOC_BIAS_STANDBY); if (pd->model == UDA134X_UDA1341) { widgets = uda1341_dapm_widgets; num_widgets = ARRAY_SIZE(uda1341_dapm_widgets); } else { widgets = uda1340_dapm_widgets; num_widgets = ARRAY_SIZE(uda1340_dapm_widgets); } ret = snd_soc_dapm_new_controls(&codec->dapm, widgets, num_widgets); if (ret) { printk(KERN_ERR "%s failed to register dapm controls: %d", __func__, ret); kfree(uda134x); return ret; } switch (pd->model) { case UDA134X_UDA1340: case UDA134X_UDA1344: ret = snd_soc_add_codec_controls(codec, uda1340_snd_controls, ARRAY_SIZE(uda1340_snd_controls)); break; case UDA134X_UDA1341: ret = snd_soc_add_codec_controls(codec, uda1341_snd_controls, ARRAY_SIZE(uda1341_snd_controls)); break; case UDA134X_UDA1345: ret = snd_soc_add_codec_controls(codec, uda1345_snd_controls, ARRAY_SIZE(uda1345_snd_controls)); break; default: printk(KERN_ERR "%s unknown codec type: %d", __func__, pd->model); kfree(uda134x); return -EINVAL; } if (ret < 0) { printk(KERN_ERR "UDA134X: failed to register controls\n"); kfree(uda134x); return ret; } return 0; }
static int uda134x_soc_probe(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); struct snd_soc_codec *codec; struct uda134x_priv *uda134x; void *codec_setup_data = socdev->codec_data; int ret = -ENOMEM; struct uda134x_platform_data *pd; printk(KERN_INFO "UDA134X SoC Audio Codec\n"); if (!codec_setup_data) { printk(KERN_ERR "UDA134X SoC codec: " "missing L3 bitbang function\n"); return -ENODEV; } pd = codec_setup_data; switch (pd->model) { case UDA134X_UDA1340: case UDA134X_UDA1341: case UDA134X_UDA1344: case UDA134X_UDA1345: break; default: printk(KERN_ERR "UDA134X SoC codec: " "unsupported model %d\n", pd->model); return -EINVAL; } socdev->card->codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); if (socdev->card->codec == NULL) return ret; codec = socdev->card->codec; uda134x = kzalloc(sizeof(struct uda134x_priv), GFP_KERNEL); if (uda134x == NULL) goto priv_err; snd_soc_codec_set_drvdata(codec, uda134x); codec->reg_cache = kmemdup(uda134x_reg, sizeof(uda134x_reg), GFP_KERNEL); if (codec->reg_cache == NULL) goto reg_err; mutex_init(&codec->mutex); codec->reg_cache_size = sizeof(uda134x_reg); codec->reg_cache_step = 1; codec->name = "UDA134X"; codec->owner = THIS_MODULE; codec->dai = &uda134x_dai; codec->num_dai = 1; codec->read = uda134x_read_reg_cache; codec->write = uda134x_write; INIT_LIST_HEAD(&codec->dapm_widgets); INIT_LIST_HEAD(&codec->dapm_paths); codec->control_data = codec_setup_data; if (pd->power) pd->power(1); uda134x_reset(codec); if (pd->is_powered_on_standby) { codec->set_bias_level = NULL; uda134x_set_bias_level(codec, SND_SOC_BIAS_ON); } else { codec->set_bias_level = uda134x_set_bias_level; uda134x_set_bias_level(codec, SND_SOC_BIAS_STANDBY); } /* register pcms */ ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); if (ret < 0) { printk(KERN_ERR "UDA134X: failed to register pcms\n"); goto pcm_err; } switch (pd->model) { case UDA134X_UDA1340: case UDA134X_UDA1344: ret = snd_soc_add_controls(codec, uda1340_snd_controls, ARRAY_SIZE(uda1340_snd_controls)); break; case UDA134X_UDA1341: ret = snd_soc_add_controls(codec, uda1341_snd_controls, ARRAY_SIZE(uda1341_snd_controls)); break; case UDA134X_UDA1345: ret = snd_soc_add_controls(codec, uda1345_snd_controls, ARRAY_SIZE(uda1345_snd_controls)); break; default: printk(KERN_ERR "%s unknown codec type: %d", __func__, pd->model); return -EINVAL; } if (ret < 0) { printk(KERN_ERR "UDA134X: failed to register controls\n"); goto pcm_err; } return 0; pcm_err: kfree(codec->reg_cache); reg_err: kfree(snd_soc_codec_get_drvdata(codec)); priv_err: kfree(codec); return ret; }