Duy Truong | 790f06d | 2013-02-13 16:38:12 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2010, The Linux Foundation. All rights reserved. |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | */ |
| 12 | |
| 13 | #include <linux/init.h> |
| 14 | #include <linux/wait.h> |
| 15 | #include <linux/gpio.h> |
| 16 | #include <mach/pmic.h> |
| 17 | #include <mach/msm_qdsp6_audio.h> |
| 18 | #include <asm/string.h> |
| 19 | #include <asm/mach-types.h> |
| 20 | #include <mach/debug_mm.h> |
| 21 | |
| 22 | #define GPIO_HEADSET_AMP 157 |
| 23 | #define GPIO_SPEAKER_AMP 39 |
| 24 | #define GPIO_HEADSET_SHDN_N 48 |
| 25 | |
| 26 | void analog_init(void) |
| 27 | { |
| 28 | /* stereo pmic init */ |
| 29 | pmic_spkr_set_gain(LEFT_SPKR, SPKR_GAIN_PLUS12DB); |
| 30 | pmic_spkr_set_gain(RIGHT_SPKR, SPKR_GAIN_PLUS12DB); |
| 31 | pmic_mic_set_volt(MIC_VOLT_1_80V); |
| 32 | gpio_direction_output(GPIO_HEADSET_AMP, 1); |
| 33 | gpio_set_value(GPIO_HEADSET_AMP, 0); |
| 34 | } |
| 35 | |
| 36 | void analog_headset_enable(int en) |
| 37 | { |
| 38 | pr_debug("[%s:%s] en = %d\n", __MM_FILE__, __func__, en); |
| 39 | /* enable audio amp */ |
| 40 | gpio_set_value(GPIO_HEADSET_AMP, !!en); |
| 41 | } |
| 42 | |
| 43 | void analog_speaker_enable(int en) |
| 44 | { |
| 45 | struct spkr_config_mode scm; |
| 46 | memset(&scm, 0, sizeof(scm)); |
| 47 | |
| 48 | pr_debug("[%s:%s] en = %d\n", __MM_FILE__, __func__, en); |
| 49 | if (en) { |
| 50 | scm.is_right_chan_en = 1; |
| 51 | scm.is_left_chan_en = 1; |
| 52 | scm.is_stereo_en = 1; |
| 53 | scm.is_hpf_en = 1; |
| 54 | pmic_spkr_en_mute(LEFT_SPKR, 0); |
| 55 | pmic_spkr_en_mute(RIGHT_SPKR, 0); |
| 56 | pmic_set_spkr_configuration(&scm); |
| 57 | pmic_spkr_en(LEFT_SPKR, 1); |
| 58 | pmic_spkr_en(RIGHT_SPKR, 1); |
| 59 | |
| 60 | /* unmute */ |
| 61 | pmic_spkr_en_mute(LEFT_SPKR, 1); |
| 62 | pmic_spkr_en_mute(RIGHT_SPKR, 1); |
| 63 | } else { |
| 64 | pmic_spkr_en_mute(LEFT_SPKR, 0); |
| 65 | pmic_spkr_en_mute(RIGHT_SPKR, 0); |
| 66 | |
| 67 | pmic_spkr_en(LEFT_SPKR, 0); |
| 68 | pmic_spkr_en(RIGHT_SPKR, 0); |
| 69 | |
| 70 | pmic_set_spkr_configuration(&scm); |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | void analog_mic_enable(int en) |
| 75 | { |
| 76 | pr_debug("[%s:%s] en = %d\n", __MM_FILE__, __func__, en); |
| 77 | pmic_mic_en(en); |
| 78 | } |
| 79 | |
| 80 | static struct q6audio_analog_ops ops = { |
| 81 | .init = analog_init, |
| 82 | .speaker_enable = analog_speaker_enable, |
| 83 | .headset_enable = analog_headset_enable, |
| 84 | .int_mic_enable = analog_mic_enable, |
| 85 | .ext_mic_enable = analog_mic_enable, |
| 86 | }; |
| 87 | |
| 88 | static int __init init(void) |
| 89 | { |
| 90 | q6audio_register_analog_ops(&ops); |
| 91 | return 0; |
| 92 | } |
| 93 | |
| 94 | device_initcall(init); |