Esempio n. 1
0
static int ak4671_probe(struct platform_device *pdev)
{
	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
	struct ak4671_setup_data *setup;
	struct snd_soc_codec *codec;
	struct ak4671_priv *ak4671;
	int ret = 0;

	printk(KERN_INFO "AK4671 Audio Codec %s", AK4671_VERSION);

	/* Board Specific function */
	audio_init();
	if (amp_init() < 0)
		printk("amp init failed.\n");
	audio_power(1);
	ak4671_power = 1;
	amp_set_path(AK4671_AMP_PATH_SPK);
	mic_set_path(AK4671_MIC_PATH_MAIN);

	ret = device_create_file(&pdev->dev, &dev_attr_ak4671_control);

	setup = socdev->codec_data;
	codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL);
	if (codec == NULL)
		return -ENOMEM;

	ak4671 = kzalloc(sizeof(struct ak4671_priv), GFP_KERNEL);
	if (ak4671 == NULL) {
		kfree(codec);
		return -ENOMEM;
	}

	codec->private_data = ak4671;
	socdev->codec = codec;
	mutex_init(&codec->mutex);
	INIT_LIST_HEAD(&codec->dapm_widgets);
	INIT_LIST_HEAD(&codec->dapm_paths);

	ak4671_socdev = socdev;

#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
	if (setup->i2c_address) {
		normal_i2c[0] = setup->i2c_address;
		codec->hw_write = (hw_write_t)i2c_master_send;
		codec->hw_read = (hw_read_t)i2c_master_recv;
		ret = i2c_add_driver(&ak4671_i2c_driver);
		if (ret != 0)
			printk(KERN_ERR "can't add i2c driver");
	}
#else
	/* Add other interfaces here */
#endif

	if (ret != 0) {
		kfree(codec->private_data);
		kfree(codec);
	}
	return ret;
}
Esempio n. 2
0
static int set_registers(struct snd_soc_codec *codec, int mode)
{
	int ret = 0;
	P("Set Audio PATH : 0x%02x\n", mode);

	/* for Recording path change */
	if ( (ak4671_idle_mode == IDLE_POWER_DOWN_MODE_OFF) && (ak4671_power == 1) ) {
		ret = path_change(codec, mode, ak4671_path);

		if (ret > 0) {
			P("Path Changed (0x%02x->0x%02x)", ak4671_path, mode);

			ak4671_idle_mode = IDLE_POWER_DOWN_MODE_OFF; // IDLE Mode reset (off)
			ak4671_path = mode;

			return 0;
		}
	}

	path_disable(codec, ak4671_path);

	/* voice call rec MODE off */
	if (ak4671_voice_call_rec_mode != 0)
		ak4671_voice_call_rec_mode = 0; 

	amp_path_control(mode);

	if (ak4671_power == 0) {
		audio_power(1); /* Board Specific function */
		ak4671_power = 1;
	}

	path_enable(codec, mode);

	ak4671_idle_mode = IDLE_POWER_DOWN_MODE_OFF; // IDLE Mode reset (off)
	ak4671_path = mode;

	return 0;
}
Esempio n. 3
0
static int ak4671_suspend(struct platform_device *pdev, pm_message_t state)
{
	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
	struct snd_soc_codec *codec = socdev->codec;
	P("");

	ak4671_set_bias_level(codec, SND_SOC_BIAS_OFF);

	if ( (ak4671_path & 0xf0) != MM_AUDIO_VOICECALL && (ak4671_path & 0xf0) != MM_AUDIO_VOICEMEMO ) 
	{
		path_disable(codec, ak4671_path);

		/* AUDIO_EN & MAX8906_AMP_EN Disable */
		amp_enable(0); /* Board Specific function */
		audio_power(0); /* Board Specific function */
		mic_enable(0); /* MICBIAS Disable (SPH-M900 Only) */
		ak4671_power = 0;
		ak4671_idle_mode = IDLE_POWER_DOWN_MODE_ON;
	}

	return 0;
}
Esempio n. 4
0
static void s3c_audio_off(void)
{
	pr_info("%s: Turn off audio power, amp\n", __func__);
	amp_enable(0);
	audio_power(0);
}