/* * initialise the hwdac driver * register the mixer and dsp interfaces with the kernel */ static int wmt_hwdac_init(struct snd_soc_device *socdev) { struct snd_soc_codec *codec = socdev->card->codec; int ret = 0; DBG_DETAIL(); codec->name = "HWDAC"; codec->owner = THIS_MODULE; codec->dai = &hwdac_dai; codec->num_dai = 1; /* register pcms */ ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); if (ret < 0) { printk(KERN_ERR "hwdac: failed to create pcms\n"); goto pcm_err; } ret = snd_soc_init_card(socdev); if (ret < 0) { printk(KERN_ERR "hwdac: failed to register card\n"); goto card_err; } return ret; card_err: snd_soc_free_pcms(socdev); pcm_err: return ret; }
static int ak4104_probe(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); struct snd_soc_codec *codec = ak4104_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; } /* Register the socdev */ ret = snd_soc_init_card(socdev); if (ret < 0) { dev_err(codec->dev, "failed to register card\n"); snd_soc_free_pcms(socdev); return ret; } 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; }
static int ac97_soc_probe(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); struct snd_soc_codec *codec; struct snd_ac97_bus *ac97_bus; struct snd_ac97_template ac97_template; int ret = 0; printk(KERN_INFO "AC97 SoC Audio Codec %s\n", AC97_VERSION); socdev->card->codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); if (!socdev->card->codec) return -ENOMEM; codec = socdev->card->codec; mutex_init(&codec->mutex); codec->name = "AC97"; codec->owner = THIS_MODULE; codec->dai = &ac97_dai; codec->num_dai = 1; codec->write = ac97_write; codec->read = ac97_read; INIT_LIST_HEAD(&codec->dapm_widgets); INIT_LIST_HEAD(&codec->dapm_paths); ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); if (ret < 0) goto err; ret = snd_ac97_bus(codec->card, 0, &soc_ac97_ops, NULL, &ac97_bus); if (ret < 0) goto bus_err; memset(&ac97_template, 0, sizeof(struct snd_ac97_template)); ret = snd_ac97_mixer(ac97_bus, &ac97_template, &codec->ac97); if (ret < 0) goto bus_err; ret = snd_soc_init_card(socdev); if (ret < 0) goto bus_err; return 0; bus_err: snd_soc_free_pcms(socdev); err: kfree(socdev->card->codec); socdev->card->codec = NULL; return ret; }
static int codec_soc_probe(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); struct snd_soc_codec *codec; int ret = 0; socdev->card->codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); if (!socdev->card->codec) return -ENOMEM; codec = socdev->card->codec; mutex_init(&codec->mutex); codec->name = "tegra-generic-codec"; codec->owner = THIS_MODULE; codec->dai = &tegra_generic_codec_dai; codec->num_dai = 1; codec->write = NULL; codec->read = NULL; INIT_LIST_HEAD(&codec->dapm_widgets); INIT_LIST_HEAD(&codec->dapm_paths); /* Register PCMs. */ ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); if (ret < 0) { printk(KERN_ERR "codec: failed to create pcms\n"); goto pcm_err; } /* Register Card. */ ret = snd_soc_init_card(socdev); if (ret < 0) { printk(KERN_ERR "codec: failed to register card\n"); goto card_err; } /* Add volume control */ ret = snd_ctl_add(codec->card, snd_ctl_new1(&tegra_codec_ctrl_volume, codec)); if (ret < 0) { printk(KERN_ERR "codec: failed to add control\n"); goto card_err; } /* Add route control */ return snd_ctl_add(codec->card, snd_ctl_new1(&tegra_codec_ctrl_route, codec)); card_err: snd_soc_free_pcms(socdev); pcm_err: kfree(socdev->card->codec); return ret; }
/* * 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; }
int msm_pcm_probe(struct platform_device *devptr) { struct snd_card *card; struct snd_soc_codec *codec; int ret; struct snd_soc_device *socdev = platform_get_drvdata(devptr); printk(KERN_ERR "msm_soc: create pcms\n"); codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); if (codec == NULL) return -ENOMEM; codec->name = "MSM-CARD"; codec->owner = THIS_MODULE; //socdev->codec = codec; socdev->card->codec=codec; mutex_init(&codec->mutex); INIT_LIST_HEAD(&codec->dapm_widgets); INIT_LIST_HEAD(&codec->dapm_paths); /* register pcms */ ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); if (ret < 0) { printk(KERN_ERR "msm_soc: failed to create pcms\n"); goto __nopcm; } //card = socdev->codec->card; card = socdev->card; ret = snd_soc_init_card(socdev); if (ret < 0) { printk(KERN_ERR "msm_soc: failed to register card\n"); goto __nodev; } return 0; __nodev: snd_soc_free_pcms(socdev); __nopcm: kfree(codec); return ret; }
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 ad73311_soc_probe(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); struct snd_soc_codec *codec; int ret = 0; codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); if (codec == NULL) return -ENOMEM; mutex_init(&codec->mutex); codec->name = "AD73311"; codec->owner = THIS_MODULE; codec->dai = &ad73311_dai; codec->num_dai = 1; socdev->card->codec = codec; INIT_LIST_HEAD(&codec->dapm_widgets); INIT_LIST_HEAD(&codec->dapm_paths); ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); if (ret < 0) { printk(KERN_ERR "ad73311: failed to create pcms\n"); goto pcm_err; } ret = snd_soc_init_card(socdev); if (ret < 0) { printk(KERN_ERR "ad73311: failed to register card\n"); goto register_err; } return ret; register_err: snd_soc_free_pcms(socdev); pcm_err: kfree(socdev->card->codec); socdev->card->codec = NULL; return ret; }
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; }
static int nmi625_soc_probe(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); struct snd_soc_codec *codec; int ret = 0; printk(KERN_INFO "NMI625 SoC Audio Codec\n"); socdev->card->codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); if (!socdev->card->codec) return -ENOMEM; codec = socdev->card->codec; mutex_init(&codec->mutex); codec->name = "NMI625"; codec->owner = THIS_MODULE; codec->dai = &nmi625_dai; codec->num_dai = 1; INIT_LIST_HEAD(&codec->dapm_widgets); INIT_LIST_HEAD(&codec->dapm_paths); /* register pcms */ ret = snd_soc_new_pcms(socdev, 2, SNDRV_DEFAULT_STR1); if (ret < 0) goto err; ret = snd_soc_init_card(socdev); if (ret < 0) goto bus_err; return 0; bus_err: snd_soc_free_pcms(socdev); err: kfree(socdev->card->codec); socdev->card->codec = NULL; 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 spdif_probe(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); struct snd_soc_codec *codec; int ret = 0; //printk("SPDIF Virtual Audio Codec \n"); codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); if (codec == NULL) return -ENOMEM; socdev->codec = codec; mutex_init(&codec->mutex); INIT_LIST_HEAD(&codec->dapm_widgets); INIT_LIST_HEAD(&codec->dapm_paths); codec->name = "SPDIF"; codec->owner = THIS_MODULE; codec->dai = spdif_dai; codec->num_dai = ARRAY_SIZE(spdif_dai); ret = snd_soc_new_pcms(socdev, -1, NULL); if (ret < 0) { printk(KERN_ERR "spdif: failed to create pcms\n"); return -1; } //Modified as per 2.6.29 ret = snd_soc_init_card(socdev); if (ret < 0) { printk(KERN_ERR "spdif: failed to register card\n"); return -1; } 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: 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 pcm3008_soc_probe(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); struct snd_soc_codec *codec; struct pcm3008_setup_data *setup = socdev->codec_data; int ret = 0; printk(KERN_INFO "PCM3008 SoC Audio Codec %s\n", PCM3008_VERSION); socdev->card->codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); if (!socdev->card->codec) return -ENOMEM; codec = socdev->card->codec; mutex_init(&codec->mutex); codec->name = "PCM3008"; codec->owner = THIS_MODULE; codec->dai = &pcm3008_dai; codec->num_dai = 1; codec->write = NULL; codec->read = NULL; INIT_LIST_HEAD(&codec->dapm_widgets); INIT_LIST_HEAD(&codec->dapm_paths); /* Register PCMs. */ ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); if (ret < 0) { printk(KERN_ERR "pcm3008: failed to create pcms\n"); goto pcm_err; } /* Register Card. */ ret = snd_soc_init_card(socdev); if (ret < 0) { printk(KERN_ERR "pcm3008: failed to register card\n"); goto card_err; } /* DEM1 DEM0 DE-EMPHASIS_MODE * Low Low De-emphasis 44.1 kHz ON * Low High De-emphasis OFF * High Low De-emphasis 48 kHz ON * High High De-emphasis 32 kHz ON */ /* Configure DEM0 GPIO (turning OFF DAC De-emphasis). */ ret = gpio_request(setup->dem0_pin, "codec_dem0"); if (ret == 0) ret = gpio_direction_output(setup->dem0_pin, 1); if (ret != 0) goto gpio_err; /* Configure DEM1 GPIO (turning OFF DAC De-emphasis). */ ret = gpio_request(setup->dem1_pin, "codec_dem1"); if (ret == 0) ret = gpio_direction_output(setup->dem1_pin, 0); if (ret != 0) goto gpio_err; /* Configure PDAD GPIO. */ ret = gpio_request(setup->pdad_pin, "codec_pdad"); if (ret == 0) ret = gpio_direction_output(setup->pdad_pin, 1); if (ret != 0) goto gpio_err; /* Configure PDDA GPIO. */ ret = gpio_request(setup->pdda_pin, "codec_pdda"); if (ret == 0) ret = gpio_direction_output(setup->pdda_pin, 1); if (ret != 0) goto gpio_err; return ret; gpio_err: pcm3008_gpio_free(setup); card_err: snd_soc_free_pcms(socdev); pcm_err: kfree(socdev->card->codec); 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; }
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; }