Ejemplo n.º 1
0
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;
}
Ejemplo n.º 2
0
static int sndhdmi_soc_probe(struct platform_device *pdev)
{
	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
	struct snd_soc_codec *codec;
	int ret = -ENOMEM;
	
	(socdev->card->codec) = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL);
	if (socdev->card->codec == NULL)
		return ret;

	codec = socdev->card->codec;

	mutex_init(&codec->mutex);

	codec->name = "SNDHDMI";
	codec->owner = THIS_MODULE;
	codec->dai = &sndhdmi_dai;
	codec->num_dai = 1;
	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 pcm_err;
	}

	return 0;


pcm_err:
	kfree(codec);
	return ret;
}
Ejemplo n.º 3
0
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;
}
static int aml_m1_codec_probe(struct platform_device *pdev)
{
	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
	struct snd_soc_codec *codec;
	int ret = 0;

	if (!aml_m1_codec) {
		dev_err(&pdev->dev, "AML_M1_CODEC not yet discovered\n");
		return -ENODEV;
	}
	codec = aml_m1_codec;			
	socdev->card->codec = codec;	
	
	/* register pcms */
	ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
	if (ret < 0) {
		kfree(codec);
		dev_err(codec->dev, "aml m1 codec: failed to create pcms: %d\n", ret);
		goto pcm_err;
	}
	
    snd_soc_add_controls(codec, amlm1_snd_controls,
				ARRAY_SIZE(amlm1_snd_controls));
	amlm1_add_widgets(codec);
pcm_err:

	return 0;
}
Ejemplo n.º 5
0
static int wm8903_probe(struct platform_device *pdev)
{
	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
	int ret = 0;

	if (!wm8903_codec) {
		dev_err(&pdev->dev, "I2C device not yet probed\n");
		goto err;
	}

	socdev->card->codec = wm8903_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");
		goto err;
	}

	snd_soc_add_controls(socdev->card->codec, wm8903_snd_controls,
				ARRAY_SIZE(wm8903_snd_controls));
	wm8903_add_widgets(socdev->card->codec);

	return ret;

err:
	return ret;
}
Ejemplo n.º 6
0
static int sndspdif_soc_probe(struct platform_device *pdev)
{
	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
	struct snd_soc_codec *codec;
	int ret = -ENOMEM;
	
	(socdev->card->codec) = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL);
	if (socdev->card->codec == NULL)
		return ret;

	codec = socdev->card->codec;

	mutex_init(&codec->mutex);

	codec->name = "SNDSPDIF";
	codec->owner = THIS_MODULE;
	codec->dai = &sndspdif_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, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
	if (ret < 0) {
//		printk(KERN_ERR "ANX7150: failed to register pcms\n");
		goto pcm_err;
	}

	return 0;

pcm_err:
	kfree(codec);
	return ret;
}
Ejemplo n.º 7
0
static int wm8961_probe(struct platform_device *pdev)
{
	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
	struct snd_soc_codec *codec;
	int ret = 0;

	if (wm8961_codec == NULL) {
		dev_err(&pdev->dev, "Codec device not registered\n");
		return -ENODEV;
	}

	socdev->card->codec = wm8961_codec;
	codec = wm8961_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, wm8961_snd_controls,
				ARRAY_SIZE(wm8961_snd_controls));
	snd_soc_dapm_new_controls(codec, wm8961_dapm_widgets,
				  ARRAY_SIZE(wm8961_dapm_widgets));
	snd_soc_dapm_add_routes(codec, audio_paths, ARRAY_SIZE(audio_paths));

	return ret;

pcm_err:
	return ret;
}
Ejemplo n.º 8
0
/*
 * 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;
}
Ejemplo n.º 9
0
static int wm9090_probe(struct platform_device *pdev)
{
	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
	struct snd_soc_codec *codec;
	int ret = 0;

	if (wm9090_codec == NULL) {
		dev_err(&pdev->dev, "Codec device not registered\n");
		return -ENODEV;
	}

	socdev->card->codec = wm9090_codec;
	codec = wm9090_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;
	}

	wm9090_add_controls(codec);

	return 0;

pcm_err:
	return ret;
}
static int spdif_dit_codec_probe(struct platform_device *pdev)
{
	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
	struct snd_soc_codec *codec;
	int ret;

	if (spdif_dit_codec == NULL) {
		dev_err(&pdev->dev, "Codec device not registered\n");
		return -ENODEV;
	}

	socdev->card->codec = spdif_dit_codec;
	codec = spdif_dit_codec;

	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 err_create_pcms;
	}

	return 0;

err_create_pcms:
	return ret;
}
Ejemplo n.º 11
0
static int ak4642_probe(struct platform_device *pdev)
{
	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
	int ret;

	if (!ak4642_codec) {
		dev_err(&pdev->dev, "Codec device not registered\n");
		return -ENODEV;
	}

	socdev->card->codec = ak4642_codec;

	/* register pcms */
	ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
	if (ret < 0) {
		printk(KERN_ERR "ak4642: failed to create pcms\n");
		goto pcm_err;
	}

	dev_info(&pdev->dev, "AK4642 Audio Codec %s", AK4642_VERSION);
	return ret;

pcm_err:
	return ret;

}
Ejemplo n.º 12
0
static int s5m8751_probe(struct platform_device *pdev)
{
	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
	struct snd_soc_codec *codec;
	int ret = 0;

	if (s5m8751_codec == NULL) {
		dev_err(&pdev->dev, "Codec device isn't registered\n");
		return -ENOMEM;
	}

	socdev->card->codec = s5m8751_codec;
	codec = s5m8751_codec;

	/* register pcm */
	ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
	if (ret < 0) {
		dev_err(codec->dev, "Failed to create pcm: %d\n", ret);
		goto pcm_err;
	}

	snd_soc_add_controls(codec, s5m8751_snd_controls,
			ARRAY_SIZE(s5m8751_snd_controls));
	s5m8751_add_widgets(codec);

	return ret;

pcm_err:
	return ret;
}
Ejemplo n.º 13
0
static int cs4334_probe(struct platform_device *pdev)
{
	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
	struct snd_soc_codec *codec;
	int ret = 0;
    printk("***Entered %s:%s\n", __FILE__,__func__);
	if (cs4334_codec == NULL) {
		dev_err(&pdev->dev, "Codec device not registered\n");
		return -ENODEV;
	}
	
	codec = cs4334_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 register new PCMs\n");
		goto pcm_err;
	}

	//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);
pcm_err:
	return ret;
}
Ejemplo n.º 14
0
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;

	/* 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");
		goto pcm_err;
	}

	cx20442_add_widgets(codec);

pcm_err:
	return ret;
}
Ejemplo n.º 15
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->card->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;
	}

	snd_soc_add_controls(codec, ak4671_snd_controls,
			     ARRAY_SIZE(ak4671_snd_controls));
	ak4671_add_widgets(codec);

	ak4671_set_bias_level(codec, SND_SOC_BIAS_STANDBY);

	return ret;

pcm_err:
	return ret;
}
Ejemplo n.º 16
0
static int ac97_soc_probe(struct platform_device *pdev)
{
	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
	struct snd_soc_card *card = socdev->card;
	struct snd_soc_codec *codec;
	struct snd_ac97_bus *ac97_bus;
	struct snd_ac97_template ac97_template;
	int i;
	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);

	/* register pcms */
	ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
	if (ret < 0)
		goto err;

	/* add codec as bus device for standard ac97 */
	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;

	for (i = 0; i < card->num_links; i++) {
		if (card->dai_link[i].codec_dai->ac97_control) {
			snd_ac97_dev_add_pdata(codec->ac97,
				card->dai_link[i].cpu_dai->ac97_pdata);
		}
	}

	return 0;

bus_err:
	snd_soc_free_pcms(socdev);

err:
	kfree(socdev->card->codec);
	socdev->card->codec = NULL;
	return ret;
}
Ejemplo n.º 17
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;
}
Ejemplo n.º 18
0
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;
}
Ejemplo n.º 19
0
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);

	return ret;

pcm_err:
	kfree(codec->reg_cache);
	return ret;
}
Ejemplo n.º 20
0
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;
}
Ejemplo n.º 21
0
static int qsd_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);

	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;
	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 "qsd_soc: failed to create pcms\n");
		goto __nopcm;
	}

	card = socdev->codec->card;

	ret = qsd_new_mixer(card);
	if (ret < 0) {
		printk(KERN_ERR "qsd_soc:ALSA MSM Mixer Fail");
		goto __nodev;
	}

	ret = snd_soc_register_card(socdev);
	if (ret < 0) {
		printk(KERN_ERR "qsd_soc: failed to register card\n");
		goto __nodev;
	}

	qsd_glb_ctl.playback_device = CAD_HW_DEVICE_ID_DEFAULT_RX;
	qsd_glb_ctl.capture_device = CAD_HW_DEVICE_ID_DEFAULT_TX;
	qsd_glb_ctl.volume = 50;

	return 0;

__nodev:
	snd_soc_free_pcms(socdev);
__nopcm:
	kfree(codec);
	return ret;
}
Ejemplo n.º 22
0
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;
}
Ejemplo n.º 23
0
/**
 * cs4270_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 cs4270_probe(struct platform_device *pdev)
{
	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
	struct snd_soc_codec *codec = cs4270_codec;
	struct cs4270_private *cs4270 = codec->private_data;
	int i, 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, cs4270_snd_controls,
				ARRAY_SIZE(cs4270_snd_controls));
	if (ret < 0) {
		dev_err(codec->dev, "failed to add controls\n");
		goto error_free_pcms;
	}

	/* get the power supply regulators */
	for (i = 0; i < ARRAY_SIZE(supply_names); i++)
		cs4270->supplies[i].supply = supply_names[i];

	ret = regulator_bulk_get(codec->dev, ARRAY_SIZE(cs4270->supplies),
				 cs4270->supplies);
	if (ret < 0)
		goto error_free_pcms;

	ret = regulator_bulk_enable(ARRAY_SIZE(cs4270->supplies),
				    cs4270->supplies);
	if (ret < 0)
		goto error_free_regulators;

	return 0;

error_free_regulators:
	regulator_bulk_free(ARRAY_SIZE(cs4270->supplies),
			    cs4270->supplies);

error_free_pcms:
	snd_soc_free_pcms(socdev);

	return ret;
}
Ejemplo n.º 24
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;
}
Ejemplo n.º 25
0
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;
}
Ejemplo n.º 26
0
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;
}
Ejemplo n.º 27
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;
}
Ejemplo n.º 28
0
static int wm8993_probe(struct platform_device *pdev)
{
	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
	struct snd_soc_codec *codec;
	struct wm8993_priv *wm8993;
	int ret = 0;

	if (!wm8993_codec) {
		dev_err(&pdev->dev, "I2C device not yet probed\n");
		goto err;
	}

	socdev->card->codec = wm8993_codec;
	codec = wm8993_codec;
	wm8993 = codec->private_data;

	ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
	if (ret < 0) {
		dev_err(codec->dev, "failed to create pcms\n");
		goto err;
	}

	snd_soc_add_controls(codec, wm8993_snd_controls,
			     ARRAY_SIZE(wm8993_snd_controls));
	if (wm8993->pdata.num_retune_configs != 0) {
		dev_dbg(codec->dev, "Using ReTune Mobile\n");
	} else {
		dev_dbg(codec->dev, "No ReTune Mobile, using normal EQ\n");
		snd_soc_add_controls(codec, wm8993_eq_controls,
				     ARRAY_SIZE(wm8993_eq_controls));
	}

	snd_soc_dapm_new_controls(codec, wm8993_dapm_widgets,
				  ARRAY_SIZE(wm8993_dapm_widgets));
	wm_hubs_add_analogue_controls(codec);

	snd_soc_dapm_add_routes(codec, routes, ARRAY_SIZE(routes));
	wm_hubs_add_analogue_routes(codec, wm8993->pdata.lineout1_diff,
				    wm8993->pdata.lineout2_diff);

	return ret;

err:
	return ret;
}
Ejemplo n.º 29
0
static int timpani_soc_probe(struct platform_device *pdev)
{
	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
	struct snd_soc_codec *codec;
	int ret = 0;

	if (!timpani_codec) {
		dev_err(&pdev->dev, "core driver not yet probed\n");
		return -ENODEV;
	}

	socdev->card->codec = timpani_codec;
	codec = timpani_codec;

	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;
}
Ejemplo n.º 30
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;
}