static int wm9090_resume(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); struct snd_soc_codec *codec = socdev->card->codec; wm9090_set_bias_level(codec, SND_SOC_BIAS_STANDBY); return 0; }
static int wm9090_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; wm9090_set_bias_level(codec, SND_SOC_BIAS_OFF); return 0; }
static int wm9090_probe(struct snd_soc_codec *codec) { int ret; ret = snd_soc_codec_set_cache_io(codec, 8, 16, SND_SOC_I2C); if (ret != 0) { dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); return ret; } ret = snd_soc_read(codec, WM9090_SOFTWARE_RESET); if (ret < 0) return ret; if (ret != wm9090_reg_defaults[WM9090_SOFTWARE_RESET]) { dev_err(codec->dev, "Device is not a WM9090, ID=%x\n", ret); return -EINVAL; } ret = snd_soc_write(codec, WM9090_SOFTWARE_RESET, 0); if (ret < 0) return ret; /* Configure some defaults; they will be written out when we * bring the bias up. */ snd_soc_update_bits(codec, WM9090_IN1_LINE_INPUT_A_VOLUME, WM9090_IN1_VU | WM9090_IN1A_ZC, WM9090_IN1_VU | WM9090_IN1A_ZC); snd_soc_update_bits(codec, WM9090_IN1_LINE_INPUT_B_VOLUME, WM9090_IN1_VU | WM9090_IN1B_ZC, WM9090_IN1_VU | WM9090_IN1B_ZC); snd_soc_update_bits(codec, WM9090_IN2_LINE_INPUT_A_VOLUME, WM9090_IN2_VU | WM9090_IN2A_ZC, WM9090_IN2_VU | WM9090_IN2A_ZC); snd_soc_update_bits(codec, WM9090_IN2_LINE_INPUT_B_VOLUME, WM9090_IN2_VU | WM9090_IN2B_ZC, WM9090_IN2_VU | WM9090_IN2B_ZC); snd_soc_update_bits(codec, WM9090_SPEAKER_VOLUME_LEFT, WM9090_SPKOUT_VU | WM9090_SPKOUTL_ZC, WM9090_SPKOUT_VU | WM9090_SPKOUTL_ZC); snd_soc_update_bits(codec, WM9090_LEFT_OUTPUT_VOLUME, WM9090_HPOUT1_VU | WM9090_HPOUT1L_ZC, WM9090_HPOUT1_VU | WM9090_HPOUT1L_ZC); snd_soc_update_bits(codec, WM9090_RIGHT_OUTPUT_VOLUME, WM9090_HPOUT1_VU | WM9090_HPOUT1R_ZC, WM9090_HPOUT1_VU | WM9090_HPOUT1R_ZC); snd_soc_update_bits(codec, WM9090_CLOCKING_1, WM9090_TOCLK_ENA, WM9090_TOCLK_ENA); wm9090_set_bias_level(codec, SND_SOC_BIAS_STANDBY); wm9090_add_controls(codec); return 0; }
static int wm9090_i2c_remove(struct i2c_client *i2c) { struct wm9090_priv *wm9090 = i2c_get_clientdata(i2c); struct snd_soc_codec *codec = &wm9090->codec; snd_soc_unregister_codec(codec); wm9090_set_bias_level(codec, SND_SOC_BIAS_OFF); kfree(wm9090); wm9090_codec = NULL; return 0; }
static int wm9090_probe(struct snd_soc_codec *codec) { struct wm9090_priv *wm9090 = dev_get_drvdata(codec->dev); int ret; codec->control_data = wm9090->regmap; ret = snd_soc_codec_set_cache_io(codec, 8, 16, SND_SOC_REGMAP); if (ret != 0) { dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); return ret; } /* Configure some defaults; they will be written out when we * bring the bias up. */ snd_soc_update_bits(codec, WM9090_IN1_LINE_INPUT_A_VOLUME, WM9090_IN1_VU | WM9090_IN1A_ZC, WM9090_IN1_VU | WM9090_IN1A_ZC); snd_soc_update_bits(codec, WM9090_IN1_LINE_INPUT_B_VOLUME, WM9090_IN1_VU | WM9090_IN1B_ZC, WM9090_IN1_VU | WM9090_IN1B_ZC); snd_soc_update_bits(codec, WM9090_IN2_LINE_INPUT_A_VOLUME, WM9090_IN2_VU | WM9090_IN2A_ZC, WM9090_IN2_VU | WM9090_IN2A_ZC); snd_soc_update_bits(codec, WM9090_IN2_LINE_INPUT_B_VOLUME, WM9090_IN2_VU | WM9090_IN2B_ZC, WM9090_IN2_VU | WM9090_IN2B_ZC); snd_soc_update_bits(codec, WM9090_SPEAKER_VOLUME_LEFT, WM9090_SPKOUT_VU | WM9090_SPKOUTL_ZC, WM9090_SPKOUT_VU | WM9090_SPKOUTL_ZC); snd_soc_update_bits(codec, WM9090_LEFT_OUTPUT_VOLUME, WM9090_HPOUT1_VU | WM9090_HPOUT1L_ZC, WM9090_HPOUT1_VU | WM9090_HPOUT1L_ZC); snd_soc_update_bits(codec, WM9090_RIGHT_OUTPUT_VOLUME, WM9090_HPOUT1_VU | WM9090_HPOUT1R_ZC, WM9090_HPOUT1_VU | WM9090_HPOUT1R_ZC); snd_soc_update_bits(codec, WM9090_CLOCKING_1, WM9090_TOCLK_ENA, WM9090_TOCLK_ENA); wm9090_set_bias_level(codec, SND_SOC_BIAS_STANDBY); wm9090_add_controls(codec); return 0; }
static int wm9090_probe(struct snd_soc_codec *codec) { /* Configure some defaults; they will be written out when we * bring the bias up. */ snd_soc_update_bits(codec, WM9090_IN1_LINE_INPUT_A_VOLUME, WM9090_IN1_VU | WM9090_IN1A_ZC, WM9090_IN1_VU | WM9090_IN1A_ZC); snd_soc_update_bits(codec, WM9090_IN1_LINE_INPUT_B_VOLUME, WM9090_IN1_VU | WM9090_IN1B_ZC, WM9090_IN1_VU | WM9090_IN1B_ZC); snd_soc_update_bits(codec, WM9090_IN2_LINE_INPUT_A_VOLUME, WM9090_IN2_VU | WM9090_IN2A_ZC, WM9090_IN2_VU | WM9090_IN2A_ZC); snd_soc_update_bits(codec, WM9090_IN2_LINE_INPUT_B_VOLUME, WM9090_IN2_VU | WM9090_IN2B_ZC, WM9090_IN2_VU | WM9090_IN2B_ZC); snd_soc_update_bits(codec, WM9090_SPEAKER_VOLUME_LEFT, WM9090_SPKOUT_VU | WM9090_SPKOUTL_ZC, WM9090_SPKOUT_VU | WM9090_SPKOUTL_ZC); snd_soc_update_bits(codec, WM9090_LEFT_OUTPUT_VOLUME, WM9090_HPOUT1_VU | WM9090_HPOUT1L_ZC, WM9090_HPOUT1_VU | WM9090_HPOUT1L_ZC); snd_soc_update_bits(codec, WM9090_RIGHT_OUTPUT_VOLUME, WM9090_HPOUT1_VU | WM9090_HPOUT1R_ZC, WM9090_HPOUT1_VU | WM9090_HPOUT1R_ZC); snd_soc_update_bits(codec, WM9090_CLOCKING_1, WM9090_TOCLK_ENA, WM9090_TOCLK_ENA); wm9090_set_bias_level(codec, SND_SOC_BIAS_STANDBY); wm9090_add_controls(codec); return 0; }
static int wm9090_remove(struct snd_soc_codec *codec) { wm9090_set_bias_level(codec, SND_SOC_BIAS_OFF); return 0; }
static int wm9090_resume(struct snd_soc_codec *codec) { wm9090_set_bias_level(codec, SND_SOC_BIAS_STANDBY); return 0; }
static int wm9090_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct wm9090_priv *wm9090; struct snd_soc_codec *codec; int ret; wm9090 = kzalloc(sizeof(*wm9090), GFP_KERNEL); if (wm9090 == NULL) { dev_err(&i2c->dev, "Can not allocate memory\n"); return -ENOMEM; } codec = &wm9090->codec; if (i2c->dev.platform_data) memcpy(&wm9090->pdata, i2c->dev.platform_data, sizeof(wm9090->pdata)); wm9090_codec = codec; i2c_set_clientdata(i2c, wm9090); mutex_init(&codec->mutex); INIT_LIST_HEAD(&codec->dapm_widgets); INIT_LIST_HEAD(&codec->dapm_paths); codec->control_data = i2c; snd_soc_codec_set_drvdata(codec, wm9090); codec->dev = &i2c->dev; codec->name = "WM9090"; codec->owner = THIS_MODULE; codec->bias_level = SND_SOC_BIAS_OFF; codec->set_bias_level = wm9090_set_bias_level, codec->reg_cache_size = WM9090_MAX_REGISTER + 1; codec->reg_cache = &wm9090->reg_cache; codec->volatile_register = wm9090_volatile; ret = snd_soc_codec_set_cache_io(codec, 8, 16, SND_SOC_I2C); if (ret != 0) { dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); goto err; } memcpy(&wm9090->reg_cache, wm9090_reg_defaults, sizeof(wm9090->reg_cache)); ret = snd_soc_read(codec, WM9090_SOFTWARE_RESET); if (ret < 0) goto err; if (ret != wm9090_reg_defaults[WM9090_SOFTWARE_RESET]) { dev_err(&i2c->dev, "Device is not a WM9090, ID=%x\n", ret); ret = -EINVAL; goto err; } ret = snd_soc_write(codec, WM9090_SOFTWARE_RESET, 0); if (ret < 0) goto err; /* Configure some defaults; they will be written out when we * bring the bias up. */ wm9090->reg_cache[WM9090_IN1_LINE_INPUT_A_VOLUME] |= WM9090_IN1_VU | WM9090_IN1A_ZC; wm9090->reg_cache[WM9090_IN1_LINE_INPUT_B_VOLUME] |= WM9090_IN1_VU | WM9090_IN1B_ZC; wm9090->reg_cache[WM9090_IN2_LINE_INPUT_A_VOLUME] |= WM9090_IN2_VU | WM9090_IN2A_ZC; wm9090->reg_cache[WM9090_IN2_LINE_INPUT_B_VOLUME] |= WM9090_IN2_VU | WM9090_IN2B_ZC; wm9090->reg_cache[WM9090_SPEAKER_VOLUME_LEFT] |= WM9090_SPKOUT_VU | WM9090_SPKOUTL_ZC; wm9090->reg_cache[WM9090_LEFT_OUTPUT_VOLUME] |= WM9090_HPOUT1_VU | WM9090_HPOUT1L_ZC; wm9090->reg_cache[WM9090_RIGHT_OUTPUT_VOLUME] |= WM9090_HPOUT1_VU | WM9090_HPOUT1R_ZC; wm9090->reg_cache[WM9090_CLOCKING_1] |= WM9090_TOCLK_ENA; wm9090_set_bias_level(codec, SND_SOC_BIAS_STANDBY); ret = snd_soc_register_codec(codec); if (ret != 0) { dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret); goto err_bias; } return 0; err_bias: wm9090_set_bias_level(codec, SND_SOC_BIAS_OFF); err: kfree(wm9090); i2c_set_clientdata(i2c, NULL); wm9090_codec = NULL; return ret; }
static int wm9090_suspend(struct snd_soc_codec *codec, pm_message_t state) { wm9090_set_bias_level(codec, SND_SOC_BIAS_OFF); return 0; }