Ejemplo n.º 1
0
static int playpaq_wm8510_init(struct snd_soc_codec *codec)
{
	int i;

	/*
	 * Add DAPM widgets
	 */
	for (i = 0; i < ARRAY_SIZE(playpaq_dapm_widgets); i++)
		snd_soc_dapm_new_control(codec, &playpaq_dapm_widgets[i]);



	/*
	 * Setup audio path interconnects
	 */
	for (i = 0; intercon[i][0] != NULL; i++) {
		snd_soc_dapm_connect_input(codec,
					   intercon[i][0],
					   intercon[i][1], intercon[i][2]);
	}


	/* always connected pins */
	snd_soc_dapm_enable_pin(codec, "Int Mic");
	snd_soc_dapm_enable_pin(codec, "Ext Spk");
	snd_soc_dapm_sync(codec);



	/* Make CSB show PLL rate */
	snd_soc_dai_set_clkdiv(codec->dai, WM8510_OPCLKDIV,
				       WM8510_OPCLKDIV_1 | 4);

	return 0;
}
Ejemplo n.º 2
0
Archivo: spitz.c Proyecto: 274914765/C
/*
 * Logic for a wm8750 as connected on a Sharp SL-Cxx00 Device
 */
static int spitz_wm8750_init(struct snd_soc_codec *codec)
{
    int i, err;

    /* NC codec pins */
    snd_soc_dapm_set_endpoint(codec, "RINPUT1", 0);
    snd_soc_dapm_set_endpoint(codec, "LINPUT2", 0);
    snd_soc_dapm_set_endpoint(codec, "RINPUT2", 0);
    snd_soc_dapm_set_endpoint(codec, "LINPUT3", 0);
    snd_soc_dapm_set_endpoint(codec, "RINPUT3", 0);
    snd_soc_dapm_set_endpoint(codec, "OUT3", 0);
    snd_soc_dapm_set_endpoint(codec, "MONO", 0);

    /* Add spitz specific controls */
    for (i = 0; i < ARRAY_SIZE(wm8750_spitz_controls); i++) {
        err = snd_ctl_add(codec->card,
            snd_soc_cnew(&wm8750_spitz_controls[i], codec, NULL));
        if (err < 0)
            return err;
    }

    /* Add spitz specific widgets */
    for (i = 0; i < ARRAY_SIZE(wm8750_dapm_widgets); i++)
        snd_soc_dapm_new_control(codec, &wm8750_dapm_widgets[i]);

    /* Set up spitz specific audio path audio_map */
    for (i = 0; audio_map[i][0] != NULL; i++)
        snd_soc_dapm_connect_input(codec, audio_map[i][0],
            audio_map[i][1], audio_map[i][2]);

    snd_soc_dapm_sync_endpoints(codec);
    return 0;
}
Ejemplo n.º 3
0
/*
 * Pavo for a jzcodec as connected on jz4740 Device
 */
static int pavo_jzcodec_init(struct snd_soc_codec *codec)
{
	int i, err;
	
	snd_soc_dapm_nc_pin(codec, "LLINEIN");
	snd_soc_dapm_nc_pin(codec, "RLINEIN");

	/* Add pavo specific controls */
	for (i = 0; i < ARRAY_SIZE(jzcodec_pavo_controls); i++) {
		err = snd_ctl_add(codec->card,
			snd_soc_cnew(&jzcodec_pavo_controls[i],codec, NULL));
		if (err < 0)
			return err;
	}

	/* Add pavo specific widgets */
	for(i = 0; i < ARRAY_SIZE(jzcodec_dapm_widgets); i++) {
		snd_soc_dapm_new_control(codec, &jzcodec_dapm_widgets[i]);
	}
	
//	snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map));

	snd_soc_dapm_sync(codec);

	return 0;
}
Ejemplo n.º 4
0
/*
 * This is an example machine initialisation for a wm8580 connected to a
 * smdk2450. It is missing logic to detect hp/mic insertions and logic
 * to re-route the audio in such an event.
 */
static int smdk_wm8580_init(struct snd_soc_codec *codec)
{
	int i, err;

	/* set endpoints to default mode */
	set_scenario_endpoints(codec, SMDK_AUDIO_OFF);

	/* Add smdk2450 specific widgets */
	for (i = 0; i < ARRAY_SIZE(wm8580_dapm_widgets); i++)
		snd_soc_dapm_new_control(codec, &wm8580_dapm_widgets[i]);

	/* add smdk2450 specific controls */
	for (i = 0; i < ARRAY_SIZE(wm8580_smdk_controls); i++) {
		err = snd_ctl_add(codec->card,
				snd_soc_cnew(&wm8580_smdk_controls[i],
				codec, NULL));
		if (err < 0)
			return err;
	}

	/* set up smdk2450 specific audio path audio_mapnects */
	for (i = 0; audio_map[i][0] != NULL; i++) {
		snd_soc_dapm_connect_input(codec, audio_map[i][0],
			audio_map[i][1], audio_map[i][2]);
	}

	/* always connected */
	snd_soc_dapm_set_endpoint(codec, "Mic1 Jack", 1);
	snd_soc_dapm_set_endpoint(codec, "Headphone Jack", 1);
	snd_soc_dapm_set_endpoint(codec, "Line In Jack", 1);

	snd_soc_dapm_sync_endpoints(codec);
	return 0;
}
Ejemplo n.º 5
0
/*
 * Logic for a wm8994 as connected on a rockchip board.
 */
static int rockchip_wm8994_init(struct snd_soc_codec *codec)
{
	int i;
	  
    DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
    
    /* Add specific widgets */
    for(i = 0; i < ARRAY_SIZE(rockchip_dapm_widgets); i++) {
    	  snd_soc_dapm_new_control(codec, &rockchip_dapm_widgets[i]);
    }
    
    /* Set up specific audio path audio_mapnects */
    for(i = 0; audio_map[i][0] != NULL; i++) {
    	snd_soc_dapm_connect_input(codec, audio_map[i][0],
    		audio_map[i][1], audio_map[i][2]);
    }
    
    /* not connected */
    snd_soc_dapm_set_endpoint(codec, "RLINEIN", 0);
    snd_soc_dapm_set_endpoint(codec, "LLINEIN", 0);
    
    /* always connected */
    snd_soc_dapm_set_endpoint(codec, "Int Mic", 1);
    snd_soc_dapm_set_endpoint(codec, "Ext Spk", 1);
    
    snd_soc_dapm_sync_endpoints(codec);
    
    return 0;
}
Ejemplo n.º 6
0
/* Logic for a aic3x as connected on a davinci-evm */
static int evm_aic3x_init(struct snd_soc_codec *codec)
{
	int i;

	/* Add davinci-evm specific widgets */
	for (i = 0; i < ARRAY_SIZE(aic3x_dapm_widgets); i++)
		snd_soc_dapm_new_control(codec, &aic3x_dapm_widgets[i]);

	/* Set up davinci-evm specific audio path audio_map */
	for (i = 0; audio_map[i][0] != NULL; i++)
		snd_soc_dapm_connect_input(codec, audio_map[i][0],
					   audio_map[i][1], audio_map[i][2]);

	/* not connected */
	snd_soc_dapm_set_endpoint(codec, "MONO_LOUT", 0);
	snd_soc_dapm_set_endpoint(codec, "HPLCOM", 0);
	snd_soc_dapm_set_endpoint(codec, "HPRCOM", 0);

	/* always connected */
	snd_soc_dapm_set_endpoint(codec, "Headphone Jack", 1);
	snd_soc_dapm_set_endpoint(codec, "Line Out", 1);
	snd_soc_dapm_set_endpoint(codec, "Mic Jack", 1);
	snd_soc_dapm_set_endpoint(codec, "Line In", 1);

	snd_soc_dapm_sync_endpoints(codec);

	return 0;
}
Ejemplo n.º 7
0
/*
 * Pavo for a jzcodec as connected on jz4740 Device
 */
static int pavo_jzcodec_init(struct snd_soc_codec *codec)
{
	int i, err;

	snd_soc_dapm_set_endpoint(codec, "LLINEIN", 0);
	snd_soc_dapm_set_endpoint(codec, "RLINEIN", 0);

	/* Add pavo specific controls */
	for (i = 0; i < ARRAY_SIZE(jzcodec_pavo_controls); i++) {
		err = snd_ctl_add(codec->card,
			snd_soc_cnew(&jzcodec_pavo_controls[i],codec, NULL));
		if (err < 0)
			return err;
	}

	/* Add pavo specific widgets */
	for(i = 0; i < ARRAY_SIZE(jzcodec_dapm_widgets); i++) {
		snd_soc_dapm_new_control(codec, &jzcodec_dapm_widgets[i]);
	}

	/* Set up pavo specific audio path audio_map */
	for(i = 0; audio_map[i][0] != NULL; i++) {
		snd_soc_dapm_connect_input(codec, audio_map[i][0],
			audio_map[i][1], audio_map[i][2]);
	}

	snd_soc_dapm_sync_endpoints(codec);
	return 0;
}
Ejemplo n.º 8
0
/*
 * Logic for a wm8731 as connected on a Endrelia ETI-B1 board.
 */
static int mainstone_wm8731_init(struct snd_soc_codec *codec)
{
	int i;


	/* Add specific widgets */
	for(i = 0; i < ARRAY_SIZE(dapm_widgets); i++) {
		snd_soc_dapm_new_control(codec, &dapm_widgets[i]);
	}

	/* Set up specific audio path interconnects */
	for(i = 0; intercon[i][0] != NULL; i++) {
		snd_soc_dapm_connect_input(codec, intercon[i][0], intercon[i][1], intercon[i][2]);
	}

	/* not connected */
	snd_soc_dapm_set_endpoint(codec, "RLINEIN", 0);
	snd_soc_dapm_set_endpoint(codec, "LLINEIN", 0);

	/* always connected */
	snd_soc_dapm_set_endpoint(codec, "Int Mic", 1);
	snd_soc_dapm_set_endpoint(codec, "Ext Spk", 1);

	snd_soc_dapm_sync_endpoints(codec);

	return 0;
}
Ejemplo n.º 9
0
static int h5000_ak4535_init (struct snd_soc_codec *codec)
{
	int i, err;
	/* NC codec pins */
	snd_soc_dapm_set_endpoint (codec, "MOUT1", 0);
	snd_soc_dapm_set_endpoint (codec, "LOUT", 0);
	snd_soc_dapm_set_endpoint (codec, "ROUT", 0);
	snd_soc_dapm_set_endpoint (codec, "MOUT2", 0);	/* FIXME: These pins are marked as INPUTS */
	snd_soc_dapm_set_endpoint (codec, "MIN", 0);	/* FIXME: and OUTPUTS in ak4535.c . We need to do this in order */
	snd_soc_dapm_set_endpoint (codec, "AIN", 0);	/* FIXME: to get DAPM working properly, because the pins are connected */
	snd_soc_dapm_set_endpoint (codec, "MICOUT", 0);	/* FIXME: OUTPUT -> INPUT. */

	/* Add h5000 specific controls */
	for (i = 0; i < ARRAY_SIZE (ak4535_h5000_controls); i++) {
		err = snd_ctl_add (codec->card,
			snd_soc_cnew (&ak4535_h5000_controls[i], codec, NULL));
		if (err < 0)
			return err;
	};
		
	/* Add h5000 specific widgets */
	for (i = 0; i < ARRAY_SIZE (ak4535_dapm_widgets); i++) {
		snd_soc_dapm_new_control (codec, &ak4535_dapm_widgets [i]);
	};

	/* Set up h5000 specific audio path audio_map */
	for (i = 0; audio_map [i][0] != NULL; i++) {
		snd_soc_dapm_connect_input (codec, audio_map [i][0], 
			audio_map [i][1], audio_map [i][2]);
	};

	snd_soc_dapm_sync_endpoints (codec);
	return 0;
};
Ejemplo n.º 10
0
static int playpaq_wm8510_init(struct snd_soc_pcm_runtime *rtd)
{
	struct snd_soc_codec *codec = rtd->codec;
	struct snd_soc_dapm_context *dapm = &codec->dapm;
	int i;

	/*
	 * Add DAPM widgets
	 */
	for (i = 0; i < ARRAY_SIZE(playpaq_dapm_widgets); i++)
		snd_soc_dapm_new_control(dapm, &playpaq_dapm_widgets[i]);



	/*
	 * Setup audio path interconnects
	 */
	snd_soc_dapm_add_routes(dapm, intercon, ARRAY_SIZE(intercon));



	/* always connected pins */
	snd_soc_dapm_enable_pin(dapm, "Int Mic");
	snd_soc_dapm_enable_pin(dapm, "Ext Spk");
	snd_soc_dapm_sync(dapm);



	/* Make CSB show PLL rate */
	snd_soc_dai_set_clkdiv(rtd->codec_dai, WM8510_OPCLKDIV,
				       WM8510_OPCLKDIV_1 | 4);

	return 0;
}
Ejemplo n.º 11
0
static int jzcodec_add_widgets(struct snd_soc_codec *codec)
{
	int i,cnt;
	
	cnt = ARRAY_SIZE(jzcodec_dapm_widgets);
	for(i = 0; i < ARRAY_SIZE(jzcodec_dapm_widgets); i++) {
		snd_soc_dapm_new_control(codec, &jzcodec_dapm_widgets[i]);
	}

	/* set up audio path interconnects */
	snd_soc_dapm_add_routes(codec, intercon_routes, ARRAY_SIZE(intercon_routes));
	snd_soc_dapm_new_widgets(codec);
	return 0;
}
Ejemplo n.º 12
0
static int imx_3stack_mach_probe(struct snd_soc_machine
				 *machine)
{
	struct snd_soc_codec *codec;
	struct snd_soc_pcm_link *pcm_link;
	int i, ret;

	pcm_link = list_first_entry(&machine->active_list,
				    struct snd_soc_pcm_link, active_list);
	codec = pcm_link->codec;

	codec->ops->io_probe(codec, machine);

	snd_soc_dapm_set_endpoint(machine, "RIN2", 0);

	/* Add imx_3stack specific widgets */
	for (i = 0; i < ARRAY_SIZE(imx_3stack_dapm_widgets); i++) {
		snd_soc_dapm_new_control(machine, codec,
					 &imx_3stack_dapm_widgets[i]);
	}

	for (i = 0; i < ARRAY_SIZE(ak4647_machine_controls); i++) {
		ret = snd_ctl_add(machine->card,
				  snd_soc_cnew(&ak4647_machine_controls[i],
					       codec, NULL));
		if (ret < 0)
			return ret;
	}

	/* set up imx_3stack specific audio path audio_mapnects */
	for (i = 0; audio_map[i][0] != NULL; i++) {
		snd_soc_dapm_connect_input(machine,
					   audio_map[i][0],
					   audio_map[i][1], audio_map[i][2]);
	}

	snd_soc_dapm_set_policy(machine, SND_SOC_DAPM_POLICY_STREAM);

	/* register card with ALSA upper layers */
	ret = snd_soc_register_card(machine);
	if (ret < 0) {
		pr_err("%s: failed to register sound card\n", __func__);
		return ret;
	}

	return 0;
}
Ejemplo n.º 13
0
static int jzcodec_add_widgets(struct snd_soc_codec *codec)
{
	int i,cnt;
	
	cnt = ARRAY_SIZE(jzcodec_dapm_widgets);
	for(i = 0; i < ARRAY_SIZE(jzcodec_dapm_widgets); i++) {
		snd_soc_dapm_new_control(codec, &jzcodec_dapm_widgets[i]);
	}

	/* set up audio path interconnects */
	for(i = 0; intercon[i][0] != NULL; i++) {
		snd_soc_dapm_connect_input(codec, intercon[i][0],
			intercon[i][1], intercon[i][2]);
	}

	snd_soc_dapm_new_widgets(codec);
	return 0;
}
Ejemplo n.º 14
0
/*
 * This is an example machine initialisation for a wm8990 connected to a
 * smdk6410. It is missing logic to detect hp/mic insertions and logic
 * to re-route the audio in such an event.
 */
static int smdk6410_wm8990_init(struct snd_soc_codec *codec)
{
	int i, err;

	/* Add smdk6410 specific widgets */
	for (i = 0; i < ARRAY_SIZE(wm8990_dapm_widgets); i++)
		snd_soc_dapm_new_control(codec, &wm8990_dapm_widgets[i]);

	/* add smdk6410 specific controls */
	for (i = 0; i < ARRAY_SIZE(wm8990_smdk6410_controls); i++) {
		err = snd_ctl_add(codec->card,
				snd_soc_cnew(&wm8990_smdk6410_controls[i],
				codec, NULL));
		if (err < 0)
			return err;
	}

	/* set up smdk6410 specific audio paths */
	for (i = 0; audio_map[i][0] != NULL; i++) {
		snd_soc_dapm_connect_input(codec, audio_map[i][0],
			audio_map[i][1], audio_map[i][2]);
	}

	/* not connected */
	snd_soc_dapm_set_endpoint(codec, "RIN1", 0);
	snd_soc_dapm_set_endpoint(codec, "LIN3", 0);
	snd_soc_dapm_set_endpoint(codec, "LIN4", 0);
	snd_soc_dapm_set_endpoint(codec, "RIN3", 0);
	snd_soc_dapm_set_endpoint(codec, "RIN4", 0);
	snd_soc_dapm_set_endpoint(codec, "OUT3", 0);
	snd_soc_dapm_set_endpoint(codec, "OUT4", 0);
	snd_soc_dapm_set_endpoint(codec, "SPKP", 0);
	snd_soc_dapm_set_endpoint(codec, "SPKN", 0);
	snd_soc_dapm_set_endpoint(codec, "ROP", 0);
	snd_soc_dapm_set_endpoint(codec, "RON", 0);
	snd_soc_dapm_set_endpoint(codec, "LOP", 0);
	snd_soc_dapm_set_endpoint(codec, "LON", 0);

	/* set endpoints to default mode & sync with DAPM */
	set_scenario_endpoints(codec, SMDK6410_STEREO_TO_HEADPHONES);
		
	return 0;
}
Ejemplo n.º 15
0
static int es8328_add_widgets(struct snd_soc_codec *codec)
{
	int i;

	for(i = 0; i < ARRAY_SIZE(es8328_dapm_widgets); i++) {
		snd_soc_dapm_new_control(codec, &es8328_dapm_widgets[i]);
	}
#if 1
	/* set up audio path audio_mapnects */
	for(i = 0; audio_map[i][0] != NULL; i++) {
		snd_soc_dapm_connect_input(codec, audio_map[i][0],
			audio_map[i][1], audio_map[i][2]);
	}
#endif

//	snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map));
	snd_soc_dapm_new_widgets(codec);
	return 0;
}
Ejemplo n.º 16
0
static int wm8350_add_widgets(struct snd_soc_codec *codec, 
	struct snd_soc_machine *machine)
{
	int i;

	for(i = 0; i < ARRAY_SIZE(wm8350_dapm_widgets); i++) {
		snd_soc_dapm_new_control(machine, codec, 
			&wm8350_dapm_widgets[i]);
	}

	/* set up audio path audio_mapnects */
	for(i = 0; audio_map[i][0] != NULL; i++) {
		snd_soc_dapm_connect_input(machine, audio_map[i][0],
			audio_map[i][1], audio_map[i][2]);
	}

	snd_soc_dapm_new_widgets(machine);
	return 0;
}
Ejemplo n.º 17
0
static int smdk6410_wm8580_init(struct snd_soc_codec *codec)
{
	int i;

	/* Add smdk6410 specific widgets */
	for (i = 0; i < ARRAY_SIZE(wm8580_dapm_widgets); i++)
		snd_soc_dapm_new_control(codec, &wm8580_dapm_widgets[i]);

	/* set up smdk6410 specific audio paths */
	for (i = 0; audio_map[i][0] != NULL; i++) {
		snd_soc_dapm_connect_input(codec, audio_map[i][0],
			audio_map[i][1], audio_map[i][2]);
	}

	/* No jack detect - mark all jacks as enabled */
	for (i = 0; i < ARRAY_SIZE(wm8580_dapm_widgets); i++)
		snd_soc_dapm_set_endpoint(codec,
					  wm8580_dapm_widgets[i].name, 1);

	snd_soc_dapm_sync_endpoints(codec);

	return 0;
}
Ejemplo n.º 18
0
/*
 * This is an example machine initialisation for a wm8987 connected to a
 * imapx200. It is missing logic to detect hp/mic insertions and logic
 * to re-route the audio in such an event.
 */
static int imapx200_wm8987_init(struct snd_soc_codec *codec)
{
	int i, err;

	/* set endpoints to default mode */
//	set_scenario_endpoints(codec, IMAPX200_AUDIO_OFF);

	/* Add imapx200 specific widgets */
	for (i = 0; i < ARRAY_SIZE(wm8987_dapm_widgets); i++)
		snd_soc_dapm_new_control(codec, &wm8987_dapm_widgets[i]);

	/* add imapx200 specific controls */
	for (i = 0; i < ARRAY_SIZE(wm8987_imapx200_controls); i++) {
		err = snd_ctl_add(codec->card,
				snd_soc_cnew(&wm8987_imapx200_controls[i],
				codec, NULL));
		if (err < 0)
			return err;
	}

	/* set up imapx200 specific audio path audio_mapnects */
#if 1
	for (i = 0; audio_map[i][0] != NULL; i++) {
		snd_soc_dapm_connect_input(codec, audio_map[i][0],
			audio_map[i][1], audio_map[i][2]);
	}
#endif

//	snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map));
	/* always connected */
	snd_soc_dapm_enable_pin(codec, "Mic Bias");
	snd_soc_dapm_enable_pin(codec, "Headphone Jack");
	snd_soc_dapm_enable_pin(codec, "Line In Jack");
	snd_soc_dapm_sync(codec);
	return 0;
}
static int armadillo440_wm8978_dai_init(struct snd_soc_codec *codec)
{
	int i;
	int ret;

	armadillo440_wm8978_codec_init(codec);

	/* set up NC codec pins */
	snd_soc_dapm_set_endpoint(codec, "RIP", 0);
	snd_soc_dapm_set_endpoint(codec, "RIN", 0);
	snd_soc_dapm_set_endpoint(codec, "AUXL", 0);
	snd_soc_dapm_set_endpoint(codec, "AUXR", 0);
	snd_soc_dapm_set_endpoint(codec, "OUT3", 0);
	snd_soc_dapm_set_endpoint(codec, "OUT4", 0);

	/* Add armadillo500fx specific widgets */
	for (i = 0; i < ARRAY_SIZE(armadillo440_dapm_widgets); i++) {
		ret = snd_soc_dapm_new_control(codec,
					       &armadillo440_dapm_widgets[i]);
		if (ret < 0) {
			error("widgets %d ret: %d\n", i, ret);
		}
	}

	/* set up armadillo440 audio specific path audio_map */
	for (i = 0; audio_map[i][0] != NULL; i++) {
		ret = snd_soc_dapm_connect_input(codec, audio_map[i][0],
			audio_map[i][1], audio_map[i][2]);
		if (ret < 0)
			return ret;
	}

	snd_soc_dapm_sync_endpoints(codec);

	return 0;
}
Ejemplo n.º 20
0
static int mach_probe(struct snd_soc_machine *machine)
{
	struct snd_soc_codec *codec;
	struct snd_soc_dai *codec_dai;
	struct snd_soc_pcm_link *pcm_link;
	struct platform_device *pdev = machine->pdev;
	struct mxc_sgtl5000_platform_data *plat = pdev->dev.platform_data;
	struct sgtl5000_platform_data *codec_data;
	struct imx_3stack_priv *priv;
	struct regulator *reg;

	int i, ret;

	pcm_link = list_first_entry(&machine->active_list,
				    struct snd_soc_pcm_link, active_list);
	sgtl5000_3stack_pcm_link = pcm_link;

	codec = pcm_link->codec;

	codec_dai = pcm_link->codec_dai;
	codec_dai->ops->set_sysclk(codec_dai, 0, plat->sysclk, 0);

	priv = kzalloc(sizeof(struct imx_3stack_priv), GFP_KERNEL);
	if (!priv)
		return -ENOMEM;
	codec_data = kzalloc(sizeof(struct sgtl5000_platform_data), GFP_KERNEL);
	if (!codec_data) {
		ret = -ENOMEM;
		goto err_codec_data;
	}

	ret = -EINVAL;
	if (plat->init && plat->init())
		goto err_plat_init;
	if (plat->vddio_reg) {
		reg = regulator_get(&pdev->dev, plat->vddio_reg);
		if (IS_ERR(reg))
			goto err_reg_vddio;
		priv->reg_vddio = reg;
	}
	if (plat->vdda_reg) {
		reg = regulator_get(&pdev->dev, plat->vdda_reg);
		if (IS_ERR(reg))
			goto err_reg_vdda;
		priv->reg_vdda = reg;
	}
	if (plat->vddd_reg) {
		reg = regulator_get(&pdev->dev, plat->vddd_reg);
		if (IS_ERR(reg))
			goto err_reg_vddd;
		priv->reg_vddd = reg;
	}
	machine->platform_data = priv;

	if (priv->reg_vdda) {
		ret = regulator_set_voltage(priv->reg_vdda, plat->vdda);
		regulator_enable(priv->reg_vdda);
	}
	if (priv->reg_vddio) {
		regulator_set_voltage(priv->reg_vddio, plat->vddio);
		regulator_enable(priv->reg_vddio);
	}
	if (priv->reg_vddd) {
		regulator_set_voltage(priv->reg_vddd, plat->vddd);
		regulator_enable(priv->reg_vddd);
	}

	/* The SGTL5000 has an internal reset that is deasserted 8 SYS_MCLK
	   cycles after all power rails have been brought up. After this time
	   communication can start */
	msleep(1);

	codec_data->vddio = plat->vddio / 1000; /* uV to mV */
	codec_data->vdda = plat->vdda / 1000;
	codec_data->vddd = plat->vddd / 1000;
	codec->platform_data = codec_data;

	ret = codec->ops->io_probe(codec, machine);
	if (ret < 0)
		goto err_card_reg;

	gpio_activate_audio_ports();
	imx_3stack_init_dam(plat->src_port, plat->ext_port);

	/* Add imx_3stack specific widgets */
	for (i = 0; i < ARRAY_SIZE(imx_3stack_dapm_widgets); i++) {
		snd_soc_dapm_new_control(machine, codec,
					 &imx_3stack_dapm_widgets[i]);
	}

	/* set up imx_3stack specific audio path audio map */
	for (i = 0; audio_map[i][0] != NULL; i++) {
		snd_soc_dapm_connect_input(machine, audio_map[i][0],
					   audio_map[i][1], audio_map[i][2]);
	}

	/* connect and enable all imx_3stack SGTL5000 jacks (for now) */
	snd_soc_dapm_set_endpoint(machine, "Line In Jack", 1);
	snd_soc_dapm_set_endpoint(machine, "Mic Jack", 1);
	snd_soc_dapm_set_endpoint(machine, "Line Out Jack", 1);
	snd_soc_dapm_set_endpoint(machine, "Headphone Jack", 1);
	sgtl5000_jack_func = 1;
	sgtl5000_spk_func = 1;

	snd_soc_dapm_set_policy(machine, SND_SOC_DAPM_POLICY_STREAM);
	snd_soc_dapm_sync_endpoints(machine);

	for (i = 0; i < ARRAY_SIZE(sgtl5000_machine_controls); i++) {
		ret = snd_ctl_add(machine->card,
				  snd_soc_cnew(&sgtl5000_machine_controls[i],
					       codec, NULL));
		if (ret < 0)
			goto err_card_reg;
	}

	/* register card with ALSA upper layers */
	ret = snd_soc_register_card(machine);
	if (ret < 0) {
		pr_err("%s: failed to register sound card\n",
		       __func__);
		goto err_card_reg;
	}

	if (plat->hp_status())
		ret = request_irq(plat->hp_irq,
				  imx_headphone_detect_handler,
				  IRQT_FALLING, pdev->name, machine);
	else
		ret = request_irq(plat->hp_irq,
				  imx_headphone_detect_handler,
				  IRQT_RISING, pdev->name, machine);
	if (ret < 0) {
		pr_err("%s: request irq failed\n", __func__);
		goto err_card_reg;
	}

	return 0;

err_card_reg:
	if (priv->reg_vddd)
		regulator_put(priv->reg_vddd, &pdev->dev);
err_reg_vddd:
	if (priv->reg_vdda)
		regulator_put(priv->reg_vdda, &pdev->dev);
err_reg_vdda:
	if (priv->reg_vddio)
		regulator_put(priv->reg_vddio, &pdev->dev);
err_reg_vddio:
	if (plat->finit)
		plat->finit();
err_plat_init:
	kfree(codec_data);
	codec->platform_data = NULL;
err_codec_data:
	kfree(priv);
	machine->platform_data = NULL;
	return ret;
}
Ejemplo n.º 21
0
static int imx_3stack_mach_probe(struct snd_soc_machine
				 *machine)
{
	struct snd_soc_codec *codec;
	struct snd_soc_pcm_link *pcm_link;
	int i, ret;

	pcm_link = list_first_entry(&machine->active_list,
				    struct snd_soc_pcm_link, active_list);

	wm8903_3stack_pcm_link = pcm_link;

	codec = pcm_link->codec;

	gpio_activate_audio_ports();
	codec->ops->io_probe(codec, machine);

	/* set unused imx_3stack WM8903 codec pins */
	snd_soc_dapm_set_endpoint(machine, "IN2R", 0);
	snd_soc_dapm_set_endpoint(machine, "IN1R", 0);

	/* Add imx_3stack specific widgets */
	for (i = 0; i < ARRAY_SIZE(imx_3stack_dapm_widgets); i++) {
		snd_soc_dapm_new_control(machine, codec,
					 &imx_3stack_dapm_widgets[i]);
	}

	for (i = 0; i < ARRAY_SIZE(imx_3stack_machine_controls); i++) {
		ret = snd_ctl_add(machine->card,
				  snd_soc_cnew(&imx_3stack_machine_controls[i],
					       codec, NULL));
		if (ret < 0)
			return ret;
	}

	/* set up imx_3stack specific audio path audio map */
	for (i = 0; audio_map[i][0] != NULL; i++) {
		snd_soc_dapm_connect_input(machine, audio_map[i][0],
					   audio_map[i][1], audio_map[i][2]);
	}

	imx_3stack_ext_control();

	snd_soc_dapm_set_policy(machine, SND_SOC_DAPM_POLICY_STREAM);
	snd_soc_dapm_sync_endpoints(machine);

	wm8903_hp_initialize_hp_detect(codec);
	wm8903_hp_status(codec);

	gpio_config(WM8903_IRQ_GPIO_PORT, WM8903_IRQ_GPIO_NUM,
		    false, GPIO_INT_RISE_EDGE);
	gpio_request_irq(WM8903_IRQ_GPIO_PORT, WM8903_IRQ_GPIO_NUM,
			 GPIO_LOW_PRIO,
			 imx_headphone_detect_handler, 0,
			 "headphone", pcm_link);

	/* register card with ALSA upper layers */
	ret = snd_soc_register_card(machine);
	if (ret < 0) {
		pr_err("%s: failed to register sound card\n", __func__);
		return ret;
	}

	return 0;
}