static int twl6040_probe(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); struct snd_soc_codec *codec; int ret = 0; BUG_ON(!twl6040_codec); codec = twl6040_codec; socdev->card->codec = codec; /* register pcms */ ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); if (ret < 0) { dev_err(&pdev->dev, "failed to create pcms\n"); return ret; } snd_soc_add_controls(codec, twl6040_snd_controls, ARRAY_SIZE(twl6040_snd_controls)); twl6040_add_widgets(codec); if (ret < 0) { dev_err(&pdev->dev, "failed to register card\n"); goto card_err; } return ret; card_err: snd_soc_free_pcms(socdev); snd_soc_dapm_free(socdev); return ret; }
static int aml_m1_codec_remove(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); // struct snd_soc_codec *codec = socdev->card->codec; snd_soc_free_pcms(socdev); snd_soc_dapm_free(socdev); return 0; }
static int cs4344_soc_remove(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); snd_soc_free_pcms(socdev); snd_soc_dapm_free(socdev); return 0; }
/* * initialise the es8328 driver * register the mixer and dsp interfaces with the kernel */ static int es8328_init(struct snd_soc_device *socdev) { struct snd_soc_codec *codec = socdev->card->codec; int reg, ret = 0; codec->name = "es8328"; codec->owner = THIS_MODULE; codec->read = es8328_read_reg_cache; codec->write = es8328_write; codec->set_bias_level = es8328_set_bias_level; codec->dai = &es8328_dai; codec->num_dai = 1; codec->reg_cache = (void*)es8328_reg; codec->reg_cache_size = ARRAY_SIZE(es8328_reg); #ifdef CONFIG_HHBF_FAST_REBOOT if (_bfin_swrst & FAST_REBOOT_FLAG) init_reboot = 1; // XXX: read register values from codec? #endif //es8328_reset(codec); /* register pcms */ ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); if (ret < 0) { printk(KERN_ERR "es8328: failed to create pcms\n"); goto pcm_err; } es8328_codec_init(codec); es8328_add_controls(codec); es8328_add_widgets(codec); // ret = snd_soc_register_card(socdev); ret = snd_soc_init_card(socdev); if (ret < 0) { printk(KERN_ERR "es8328: failed to register card\n"); goto card_err; } #ifdef CONFIG_HHTECH_MINIPMP init_reboot = 0; #endif//CONFIG_HHTECH_MINIPMP return ret; card_err: snd_soc_free_pcms(socdev); snd_soc_dapm_free(socdev); pcm_err: #ifndef CONFIG_HHTECH_MINIPMP kfree(codec->reg_cache); #endif//CONFIG_HHTECH_MINIPMP return ret; }
static int jzcodec_soc_dev_setup(struct snd_soc_device *socdev, struct snd_soc_codec *codec) { int ret; u16 reg_val; socdev->card->codec = codec; mutex_init(&codec->mutex); /* register pcms */ ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); if (ret < 0) { printk(KERN_ERR "jzcodec: failed to create pcms\n"); return ret; } /* power on device */ jzcodec_dapm_event(codec, SNDRV_CTL_POWER_D3hot); /* clear suspend bit of jz4740 internal codec */ reg_val = jzcodec_read_reg_cache(codec, ICODEC_1_LOW); reg_val = reg_val & ~(0x2); jzcodec_write(codec, ICODEC_1_LOW, reg_val); /* set vol bits */ reg_val = jzcodec_read_reg_cache(codec, ICODEC_2_LOW); reg_val = reg_val | 0x3; jzcodec_write(codec, ICODEC_2_LOW, reg_val); /* set line in capture gain bits */ reg_val = jzcodec_read_reg_cache(codec, ICODEC_2_HIGH); reg_val = reg_val | 0x1f; jzcodec_write(codec, ICODEC_2_HIGH, reg_val); /* set mic boost gain bits */ reg_val = jzcodec_read_reg_cache(codec, ICODEC_2_LOW); reg_val = reg_val | (0x3 << 4); jzcodec_write(codec, ICODEC_2_LOW, reg_val); mdelay(5); reg_val = 0x3300; jzcodec_write(codec, ICODEC_1_LOW, reg_val); reg_val = 0x0003; jzcodec_write(codec, ICODEC_1_HIGH, reg_val); jzcodec_add_controls(codec); jzcodec_add_widgets(codec); ret = snd_soc_init_card(socdev); if (ret < 0) { printk(KERN_ERR "jzcodec: failed to register card\n"); goto card_err; } return ret; card_err: snd_soc_free_pcms(socdev); snd_soc_dapm_free(socdev); return ret; }
static int wm8728_init(struct snd_soc_device *socdev, enum snd_soc_control_type control) { struct snd_soc_codec *codec = socdev->card->codec; int ret = 0; codec->name = "WM8728"; codec->owner = THIS_MODULE; codec->set_bias_level = wm8728_set_bias_level; codec->dai = &wm8728_dai; codec->num_dai = 1; codec->bias_level = SND_SOC_BIAS_OFF; codec->reg_cache_size = ARRAY_SIZE(wm8728_reg_defaults); codec->reg_cache = kmemdup(wm8728_reg_defaults, sizeof(wm8728_reg_defaults), GFP_KERNEL); if (codec->reg_cache == NULL) return -ENOMEM; ret = snd_soc_codec_set_cache_io(codec, 7, 9, control); if (ret < 0) { printk(KERN_ERR "wm8728: failed to configure cache I/O: %d\n", ret); goto err; } ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); if (ret < 0) { printk(KERN_ERR "wm8728: failed to create pcms\n"); goto err; } wm8728_set_bias_level(codec, SND_SOC_BIAS_STANDBY); snd_soc_add_controls(codec, wm8728_snd_controls, ARRAY_SIZE(wm8728_snd_controls)); wm8728_add_widgets(codec); ret = snd_soc_init_card(socdev); if (ret < 0) { printk(KERN_ERR "wm8728: failed to register card\n"); goto card_err; } return ret; card_err: snd_soc_free_pcms(socdev); snd_soc_dapm_free(socdev); err: kfree(codec->reg_cache); return ret; }
/* power down chip */ static int ak4647_remove(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); struct snd_soc_codec *codec = socdev->card->codec; snd_soc_free_pcms(socdev); snd_soc_dapm_free(socdev); i2c_del_driver(&ak4647_i2c_driver); kfree(codec); return 0; }
static int twl6040_remove(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); struct snd_soc_codec *codec = socdev->card->codec; twl6040_set_bias_level(codec, SND_SOC_BIAS_OFF); snd_soc_free_pcms(socdev); snd_soc_dapm_free(socdev); kfree(codec); return 0; }
/* power down chip */ static int wm8903_remove(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); struct snd_soc_codec *codec = socdev->card->codec; if (codec->control_data) wm8903_set_bias_level(codec, SND_SOC_BIAS_OFF); snd_soc_free_pcms(socdev); snd_soc_dapm_free(socdev); return 0; }
/* power down chip */ static int jzcodec_remove(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); struct snd_soc_codec *codec = socdev->card->codec; if (codec->control_data) jzcodec_dapm_event(codec, SNDRV_CTL_POWER_D3cold); snd_soc_free_pcms(socdev); snd_soc_dapm_free(socdev); return 0; }
static int ak5702_remove(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); struct snd_soc_codec *codec = socdev->card->codec; if (codec->control_data) ak5702_set_bias_level(codec, SND_SOC_BIAS_OFF); snd_soc_free_pcms(socdev); snd_soc_dapm_free(socdev); #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) i2c_del_driver(&ak5702_i2c_driver); #endif return 0; }
static int ad1980_soc_remove(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); struct snd_soc_codec *codec = socdev->codec; if (codec == NULL) return 0; snd_soc_dapm_free(socdev); snd_soc_free_pcms(socdev); snd_soc_free_ac97_codec(codec); kfree(codec->reg_cache); kfree(codec); return 0; }
/* * initialise the AK4671 driver * register the mixer and dsp interfaces with the kernel */ static int ak4671_init(struct snd_soc_device *socdev) { struct snd_soc_codec *codec = socdev->codec; int ret = 0; memcpy(ak4671_reg_default, ak4671_reg, sizeof(ak4671_reg)); // copy ak4671 default register codec->dev = socdev->dev; codec->name = "AK4671"; codec->owner = THIS_MODULE; codec->read = ak4671_read_reg_cache; codec->write = ak4671_write; codec->set_bias_level = ak4671_set_bias_level; codec->dai = &ak4671_dai; codec->num_dai = 1; codec->reg_cache_size = ARRAY_SIZE(ak4671_reg); codec->reg_cache = kmemdup(ak4671_reg, sizeof(ak4671_reg), GFP_KERNEL); if (codec->reg_cache == NULL) return -ENOMEM; /* register pcms */ ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); if (ret < 0) { printk(KERN_ERR "ak4671: failed to create pcms\n"); goto pcm_err; } /* power on device */ ak4671_set_bias_level(codec, SND_SOC_BIAS_STANDBY); ak4671_add_controls(codec); ret = snd_soc_init_card(socdev); if (ret < 0) { printk(KERN_ERR "ak4671: failed to register card\n"); goto card_err; } return ret; card_err: snd_soc_free_pcms(socdev); snd_soc_dapm_free(socdev); pcm_err: kfree(codec->reg_cache); return ret; }
static int ak4535_init(struct snd_soc_device *socdev) { struct snd_soc_codec *codec = socdev->card->codec; int ret = 0; codec->name = "AK4535"; codec->owner = THIS_MODULE; codec->read = ak4535_read_reg_cache; codec->write = ak4535_write; codec->set_bias_level = ak4535_set_bias_level; codec->dai = &ak4535_dai; codec->num_dai = 1; codec->reg_cache_size = ARRAY_SIZE(ak4535_reg); codec->reg_cache = kmemdup(ak4535_reg, sizeof(ak4535_reg), GFP_KERNEL); if (codec->reg_cache == NULL) return -ENOMEM; ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); if (ret < 0) { printk(KERN_ERR "ak4535: failed to create pcms\n"); goto pcm_err; } ak4535_set_bias_level(codec, SND_SOC_BIAS_STANDBY); snd_soc_add_controls(codec, ak4535_snd_controls, ARRAY_SIZE(ak4535_snd_controls)); ak4535_add_widgets(codec); ret = snd_soc_init_card(socdev); if (ret < 0) { printk(KERN_ERR "ak4535: failed to register card\n"); goto card_err; } return ret; card_err: snd_soc_free_pcms(socdev); snd_soc_dapm_free(socdev); pcm_err: kfree(codec->reg_cache); return ret; }
/* 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; }
/* power down chip */ static int tlv320_remove(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); struct snd_soc_codec *codec = socdev->codec; if (tlv320_workq) destroy_workqueue(tlv320_workq); snd_soc_free_pcms(socdev); snd_soc_dapm_free(socdev); #if defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE) i2c_del_driver(&tlv320_i2c_driver); #endif kfree(codec->private_data); kfree(codec); return 0; }
static int ak4647_probe(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); struct snd_soc_codec *codec = ak4647_codec; int ret = 0; socdev->card->codec = ak4647_codec; ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); if (ret < 0) { dev_err(&ak4647_i2c_client->dev, "failed to create pcms\n"); return ret; } /* setup init value for audio path controls here */ /* enable DAC to headphone */ ak4647_write_reg(AK4647_MODE4, 0x9); /* capture source to be LIN2 and RIN2 */ ak4647_write_reg(AK4647_PM3, 0x6); /* MPWR pin up */ ak4647_write_reg(AK4647_SIG1, 0x5); /* MCKI = 12M, default audio interface format as "left-justified" */ ak4647_write_reg(AK4647_MODE1, 0x62); /* ALC disabled */ ak4647_write_reg(AK4647_ALC1, 0x0); ak4647_state.left_capture_vol = 0x91; ak4647_state.right_capture_vol = 0x91; snd_soc_add_controls(codec, ak4647_snd_controls, ARRAY_SIZE(ak4647_snd_controls)); ak4647_add_widgets(codec); ret = snd_soc_init_card(socdev); if (ret < 0) { pr_err("ak4647: failed to register card\n"); snd_soc_free_pcms(socdev); snd_soc_dapm_free(socdev); return ret; } return 0; }
/** * cs42888_probe - ASoC probe function * @pdev: platform device * * This function is called when ASoC has all the pieces it needs to * instantiate a sound driver. */ static int cs42888_probe(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); struct snd_soc_codec *codec = cs42888_codec; int ret; /* Connect the codec to the socdev. snd_soc_new_pcms() needs this. */ socdev->card->codec = codec; /* Register PCMs */ ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); if (ret < 0) { dev_err(codec->dev, "failed to create pcms\n"); return ret; } /* Add the non-DAPM controls */ ret = snd_soc_add_controls(codec, cs42888_snd_controls, ARRAY_SIZE(cs42888_snd_controls)); if (ret < 0) { dev_err(codec->dev, "failed to add controls\n"); goto error_free_pcms; } /* Add DAPM controls */ ca42888_add_widgets(codec); /* And finally, register the socdev */ ret = snd_soc_init_card(socdev); if (ret < 0) { dev_err(codec->dev, "failed to register card\n"); goto error_free_pcms; } return 0; error_free_pcms: snd_soc_free_pcms(socdev); snd_soc_dapm_free(socdev); return ret; }
static int ad1836_probe(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); struct snd_soc_codec *codec; int ret = 0; if (ad1836_codec == NULL) { dev_err(&pdev->dev, "Codec device not registered\n"); return -ENODEV; } socdev->card->codec = ad1836_codec; codec = ad1836_codec; /* register pcms */ ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); if (ret < 0) { dev_err(codec->dev, "failed to create pcms: %d\n", ret); goto pcm_err; } snd_soc_add_controls(codec, ad1836_snd_controls, ARRAY_SIZE(ad1836_snd_controls)); snd_soc_dapm_new_controls(codec, ad1836_dapm_widgets, ARRAY_SIZE(ad1836_dapm_widgets)); snd_soc_dapm_add_routes(codec, audio_paths, ARRAY_SIZE(audio_paths)); snd_soc_dapm_new_widgets(codec); ret = snd_soc_init_card(socdev); if (ret < 0) { dev_err(codec->dev, "failed to register card: %d\n", ret); goto card_err; } return ret; card_err: snd_soc_free_pcms(socdev); snd_soc_dapm_free(socdev); pcm_err: return ret; }
static int wm8728_remove(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); struct snd_soc_codec *codec = socdev->card->codec; if (codec->control_data) wm8728_set_bias_level(codec, SND_SOC_BIAS_OFF); snd_soc_free_pcms(socdev); snd_soc_dapm_free(socdev); #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) i2c_unregister_device(codec->control_data); i2c_del_driver(&wm8728_i2c_driver); #endif #if defined(CONFIG_SPI_MASTER) spi_unregister_driver(&wm8728_spi_driver); #endif kfree(codec); return 0; }
/* power down chip */ static int es8328_remove(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); struct snd_soc_codec *codec = socdev->card->codec; if (codec->control_data) es8328_set_bias_level(codec, SND_SOC_BIAS_OFF); run_delayed_work(&codec->delayed_work); snd_soc_free_pcms(socdev); snd_soc_dapm_free(socdev); #if defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE) i2c_del_driver(&es8328_i2c_driver); #endif #ifndef CONFIG_HHTECH_MINIPMP kfree(codec->private_data); #endif//CONFIG_HHTECH_MINIPMP kfree(codec); return 0; }
static int ak4671_probe(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); struct snd_soc_codec *codec; int ret = 0; if (ak4671_codec == NULL) { dev_err(&pdev->dev, "Codec device not registered\n"); return -ENODEV; } socdev->codec = ak4671_codec; codec = ak4671_codec; /* register pcms */ ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); if (ret < 0) { dev_err(codec->dev, "failed to create pcms: %d\n", ret); goto pcm_err; } ak4671_add_controls(codec); ak4671_add_widgets(codec); ret = snd_soc_init_card(socdev); if (ret < 0) { dev_err(codec->dev, "failed to register card: %d\n", ret); goto card_err; } ak4671_set_bias_level(codec, SND_SOC_BIAS_STANDBY); return ret; card_err: snd_soc_free_pcms(socdev); snd_soc_dapm_free(socdev); pcm_err: return ret; }
/* * initialise the TLV320 driver * register the mixer and dsp interfaces with the kernel */ static int tlv320_init(struct snd_soc_device *socdev) { struct snd_soc_codec *codec = socdev->codec; int ret = 0; codec->name = "TLV320"; codec->owner = THIS_MODULE; codec->read = tlv320_read_reg_cache; codec->write = tlv320_write; codec->dai = tlv320_dai; codec->num_dai = ARRAY_SIZE(tlv320_dai); codec->reg_cache_size = ARRAY_SIZE(tlv320_reg_addr); codec->reg_cache = kzalloc(sizeof(u8) * ARRAY_SIZE(tlv320_reg_addr), GFP_KERNEL); if (codec->reg_cache == NULL) return -ENOMEM; memcpy(codec->reg_cache, tlv320_reg_addr, sizeof(u8) * ARRAY_SIZE(tlv320_reg_addr)); codec->reg_cache_size = sizeof(u8) * ARRAY_SIZE(tlv320_reg_addr); /* register pcms */ ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); if (ret < 0) { kfree(codec->reg_cache); return ret; } queue_delayed_work(tlv320_workq, &codec->delayed_work, msecs_to_jiffies(caps_charge)); ret = snd_soc_register_card(socdev); if (ret < 0) { snd_soc_free_pcms(socdev); snd_soc_dapm_free(socdev); } return ret; }
static int cs4344_soc_probe(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); struct snd_soc_codec *codec = cs4344_codec; int ret = 0; int i = 0; printk ("****** started cs4344 ******\n"); BUG_ON(cs4344_codec == NULL); socdev->card->codec = cs4344_codec; /* register pcms */ ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); if (ret < 0) { printk(KERN_ERR "cs4344: failed to create pcms\n"); goto pcm_err; } for (i = 0; i < ARRAY_SIZE(cs4344_snd_controls); i++) { struct snd_kcontrol *kctrl = snd_soc_cnew(&cs4344_snd_controls[i], codec, NULL); ret = snd_ctl_add(codec->card, kctrl); if (ret < 0) { printk (KERN_ERR "cs4344: failed to add control\n"); goto card_err; } } return ret; card_err: snd_soc_free_pcms(socdev); snd_soc_dapm_free(socdev); pcm_err: return ret; }
static int cx20442_codec_probe(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); struct snd_soc_codec *codec; int ret; if (!cx20442_codec) { dev_err(&pdev->dev, "cx20442 not yet discovered\n"); return -ENODEV; } codec = cx20442_codec; socdev->card->codec = codec; ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); if (ret < 0) { dev_err(&pdev->dev, "failed to create pcms\n"); goto pcm_err; } cx20442_add_widgets(codec); ret = snd_soc_init_card(socdev); if (ret < 0) { dev_err(&pdev->dev, "failed to register card\n"); goto card_err; } return ret; card_err: snd_soc_free_pcms(socdev); snd_soc_dapm_free(socdev); pcm_err: return ret; }
static int soc_codec_dev_iphone_probe(struct platform_device *pdev) { int ret; struct snd_soc_codec *codec; struct snd_soc_device *socdev = platform_get_drvdata(pdev); pr_debug("ENTER soc_codec_dev_iphone_probe\n"); socdev->card->codec = &priv.codec; codec = &priv.codec; ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); if (ret < 0) { pr_debug(KERN_ERR "iphone-wm8758-audio: failed to create pcms\n"); goto pcm_err; } snd_soc_add_controls(codec, wm8978_snd_controls, ARRAY_SIZE(wm8978_snd_controls)); wm8978_add_widgets(codec); /*ret = snd_soc_init_card(socdev); if (ret < 0) { printk(KERN_ERR "iphone-wm8758-audio: failed to register card\n"); goto card_err; }*/ return ret; card_err: snd_soc_free_pcms(socdev); snd_soc_dapm_free(socdev); return ret; pcm_err: return ret; }
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: 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; codec->private_data = 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; #ifdef POWER_OFF_ON_STANDBY codec->set_bias_level = uda134x_set_bias_level; #endif 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); 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; default: printk(KERN_ERR "%s unkown codec type: %d", __func__, pd->model); return -EINVAL; } if (ret < 0) { printk(KERN_ERR "UDA134X: failed to register controls\n"); goto pcm_err; } ret = snd_soc_init_card(socdev); if (ret < 0) { printk(KERN_ERR "UDA134X: failed to register card\n"); goto card_err; } return 0; card_err: snd_soc_free_pcms(socdev); snd_soc_dapm_free(socdev); pcm_err: kfree(codec->reg_cache); reg_err: kfree(codec->private_data); priv_err: kfree(codec); return ret; }
static int wm8350_probe(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); struct snd_soc_codec *codec; struct wm8350 *wm8350; struct wm8350_data *priv; int ret; struct wm8350_output *out1; struct wm8350_output *out2; BUG_ON(!wm8350_codec); socdev->codec = wm8350_codec; codec = socdev->codec; wm8350 = codec->control_data; priv = codec->private_data; /* Enable the codec */ wm8350_set_bits(wm8350, WM8350_POWER_MGMT_5, WM8350_CODEC_ENA); /* Enable robust clocking mode in ADC */ wm8350_codec_write(codec, WM8350_SECURITY, 0xa7); wm8350_codec_write(codec, 0xde, 0x13); wm8350_codec_write(codec, WM8350_SECURITY, 0); /* read OUT1 & OUT2 volumes */ out1 = &priv->out1; out2 = &priv->out2; out1->left_vol = (wm8350_reg_read(wm8350, WM8350_LOUT1_VOLUME) & WM8350_OUT1L_VOL_MASK) >> WM8350_OUT1L_VOL_SHIFT; out1->right_vol = (wm8350_reg_read(wm8350, WM8350_ROUT1_VOLUME) & WM8350_OUT1R_VOL_MASK) >> WM8350_OUT1R_VOL_SHIFT; out2->left_vol = (wm8350_reg_read(wm8350, WM8350_LOUT2_VOLUME) & WM8350_OUT2L_VOL_MASK) >> WM8350_OUT1L_VOL_SHIFT; out2->right_vol = (wm8350_reg_read(wm8350, WM8350_ROUT2_VOLUME) & WM8350_OUT2R_VOL_MASK) >> WM8350_OUT1R_VOL_SHIFT; wm8350_reg_write(wm8350, WM8350_LOUT1_VOLUME, 0); wm8350_reg_write(wm8350, WM8350_ROUT1_VOLUME, 0); wm8350_reg_write(wm8350, WM8350_LOUT2_VOLUME, 0); wm8350_reg_write(wm8350, WM8350_ROUT2_VOLUME, 0); /* Latch VU bits & mute */ wm8350_set_bits(wm8350, WM8350_LOUT1_VOLUME, WM8350_OUT1_VU | WM8350_OUT1L_MUTE); wm8350_set_bits(wm8350, WM8350_LOUT2_VOLUME, WM8350_OUT2_VU | WM8350_OUT2L_MUTE); wm8350_set_bits(wm8350, WM8350_ROUT1_VOLUME, WM8350_OUT1_VU | WM8350_OUT1R_MUTE); wm8350_set_bits(wm8350, WM8350_ROUT2_VOLUME, WM8350_OUT2_VU | WM8350_OUT2R_MUTE); wm8350_mask_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_L); wm8350_mask_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_R); wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_L, wm8350_hp_jack_handler, priv); wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_R, wm8350_hp_jack_handler, priv); ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); if (ret < 0) { dev_err(&pdev->dev, "failed to create pcms\n"); return ret; } snd_soc_add_controls(codec, wm8350_snd_controls, ARRAY_SIZE(wm8350_snd_controls)); wm8350_add_widgets(codec); wm8350_set_bias_level(codec, SND_SOC_BIAS_STANDBY); ret = snd_soc_init_card(socdev); if (ret < 0) { dev_err(&pdev->dev, "failed to register card\n"); goto card_err; } return 0; card_err: snd_soc_free_pcms(socdev); snd_soc_dapm_free(socdev); return ret; }
/* * initialise the JZCODEC driver * register the mixer and dsp interfaces with the kernel */ static int jzcodec_init(struct snd_soc_device *socdev) { struct snd_soc_codec *codec = socdev->codec; int reg, ret = 0; u16 reg_val; for (reg = 0; reg < JZCODEC_CACHEREGNUM / 2; reg++) { switch (reg) { case 0: jzcodec_reg[reg] = REG_ICDC_CDCCR1; jzcodec_reg_LH[ICODEC_1_LOW] = jzcodec_reg[reg] & 0xffff; jzcodec_reg_LH[ICODEC_1_HIGH] = (jzcodec_reg[reg] & 0xffff0000) >> 16; break; case 1: jzcodec_reg[reg] = REG_ICDC_CDCCR2; jzcodec_reg_LH[ICODEC_2_LOW] = jzcodec_reg[reg] & 0xffff; jzcodec_reg_LH[ICODEC_2_HIGH] = (jzcodec_reg[reg] & 0xffff0000) >> 16; break; } } codec->name = "JZCODEC"; codec->owner = THIS_MODULE; codec->read = jzcodec_read_reg_cache; codec->write = jzcodec_write; codec->dapm_event = jzcodec_dapm_event; codec->dai = &jzcodec_dai; codec->num_dai = 1; codec->reg_cache_size = sizeof(jzcodec_reg_LH); codec->reg_cache = kmemdup(jzcodec_reg_LH, sizeof(jzcodec_reg_LH), GFP_KERNEL); if (codec->reg_cache == NULL) return -ENOMEM; jzcodec_reset(codec); /* register pcms */ ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); if (ret < 0) { printk(KERN_ERR "jzcodec: failed to create pcms\n"); goto pcm_err; } /* power on device */ jzcodec_dapm_event(codec, SNDRV_CTL_POWER_D3hot); /* clear suspend bit of jz4740 internal codec */ reg_val = jzcodec_read_reg_cache(codec, ICODEC_1_LOW); reg_val = reg_val & ~(0x2); jzcodec_write(codec, ICODEC_1_LOW, reg_val); /* set vol bits */ reg_val = jzcodec_read_reg_cache(codec, ICODEC_2_LOW); reg_val = reg_val | 0x3; jzcodec_write(codec, ICODEC_2_LOW, reg_val); /* set line in capture gain bits */ reg_val = jzcodec_read_reg_cache(codec, ICODEC_2_HIGH); reg_val = reg_val | 0x1f; jzcodec_write(codec, ICODEC_2_HIGH, reg_val); /* set mic boost gain bits */ reg_val = jzcodec_read_reg_cache(codec, ICODEC_2_LOW); reg_val = reg_val | (0x3 << 4); jzcodec_write(codec, ICODEC_2_LOW, reg_val); mdelay(5); reg_val = 0x3300; jzcodec_write(codec, ICODEC_1_LOW, reg_val); reg_val = 0x0003; jzcodec_write(codec, ICODEC_1_HIGH, reg_val); jzcodec_add_controls(codec); jzcodec_add_widgets(codec); ret = snd_soc_register_card(socdev); if (ret < 0) { printk(KERN_ERR "jzcodec: failed to register card\n"); goto card_err; } return ret; card_err: snd_soc_free_pcms(socdev); snd_soc_dapm_free(socdev); pcm_err: kfree(codec->reg_cache); return ret; }
static int ak5702_probe(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); struct snd_soc_codec *codec = ak5702_codec; int ret = 0; u8 reg = 0; socdev->card->codec = ak5702_codec; /* register pcms */ ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); if (ret < 0) { printk(KERN_ERR "ak5702: failed to create pcms\n"); goto pcm_err; } /* power on device */ reg = ak5702_read_reg_cache(codec, AK5702_PM1); reg |= AK5702_PM1_PMVCM; ak5702_write(codec, AK5702_PM1, reg); /* initialize ADC */ reg = AK5702_SIG1_L_LIN1 | AK5702_SIG1_R_RIN2; ak5702_write(codec, AK5702_SIG1, reg); reg = AK5702_SIG2_L_LIN3 | AK5702_SIG2_R_RIN4; ak5702_write(codec, AK5702_SIG2, reg); reg = ak5702_read_reg_cache(codec, AK5702_PM1); reg = reg | AK5702_PM1_PMADAL | AK5702_PM1_PMADAR; ak5702_write(codec, AK5702_PM1, reg); reg = ak5702_read_reg_cache(codec, AK5702_PM2); reg = reg | AK5702_PM2_PMADBL | AK5702_PM2_PMADBR; ak5702_write(codec, AK5702_PM2, reg); /* initialize volume */ ak5702_write(codec, AK5702_MICG1, AK5702_MICG1_INIT); ak5702_write(codec, AK5702_MICG2, AK5702_MICG2_INIT); ak5702_write(codec, AK5702_VOL1, AK5702_VOL1_IVOLAC); ak5702_write(codec, AK5702_VOL2, AK5702_VOL2_IVOLBC); ak5702_write(codec, AK5702_LVOL1, AK5702_LVOL1_INIT); ak5702_write(codec, AK5702_RVOL1, AK5702_RVOL1_INIT); ak5702_write(codec, AK5702_LVOL2, AK5702_LVOL2_INIT); ak5702_write(codec, AK5702_RVOL2, AK5702_RVOL2_INIT); snd_soc_add_controls(codec, ak5702_snd_controls, ARRAY_SIZE(ak5702_snd_controls)); ak5702_add_widgets(codec); ret = snd_soc_init_card(socdev); if (ret < 0) { printk(KERN_ERR "ak5702: failed to register card\n"); goto card_err; } return ret; card_err: snd_soc_free_pcms(socdev); snd_soc_dapm_free(socdev); pcm_err: kfree(codec->reg_cache); return ret; }