Duy Truong | 790f06d | 2013-02-13 16:38:12 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2009, The Linux Foundation. All rights reserved. |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2 | * |
| 3 | * This software is licensed under the terms of the GNU General Public |
| 4 | * License version 2, as published by the Free Software Foundation, and |
| 5 | * may be copied, distributed, and modified under those terms. |
| 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 | |
| 14 | #include <linux/gpio.h> |
| 15 | #include <mach/pmic.h> |
| 16 | #include <mach/msm_qdsp6_audiov2.h> |
| 17 | |
| 18 | #define GPIO_HEADSET_AMP 157 |
| 19 | |
| 20 | void analog_init(void) |
| 21 | { |
| 22 | /* stereo pmic init */ |
| 23 | pmic_spkr_set_gain(LEFT_SPKR, SPKR_GAIN_PLUS12DB); |
| 24 | pmic_spkr_set_gain(RIGHT_SPKR, SPKR_GAIN_PLUS12DB); |
| 25 | pmic_mic_set_volt(MIC_VOLT_1_80V); |
| 26 | |
| 27 | gpio_direction_output(GPIO_HEADSET_AMP, 1); |
| 28 | gpio_set_value(GPIO_HEADSET_AMP, 0); |
| 29 | } |
| 30 | |
| 31 | void analog_headset_enable(int en) |
| 32 | { |
| 33 | /* enable audio amp */ |
| 34 | gpio_set_value(GPIO_HEADSET_AMP, !!en); |
| 35 | } |
| 36 | |
| 37 | void analog_speaker_enable(int en) |
| 38 | { |
| 39 | struct spkr_config_mode scm; |
| 40 | memset(&scm, 0, sizeof(scm)); |
| 41 | |
| 42 | if (en) { |
| 43 | scm.is_right_chan_en = 1; |
| 44 | scm.is_left_chan_en = 1; |
| 45 | scm.is_stereo_en = 1; |
| 46 | scm.is_hpf_en = 1; |
| 47 | pmic_spkr_en_mute(LEFT_SPKR, 0); |
| 48 | pmic_spkr_en_mute(RIGHT_SPKR, 0); |
| 49 | pmic_set_spkr_configuration(&scm); |
| 50 | pmic_spkr_en(LEFT_SPKR, 1); |
| 51 | pmic_spkr_en(RIGHT_SPKR, 1); |
| 52 | |
| 53 | /* unmute */ |
| 54 | pmic_spkr_en_mute(LEFT_SPKR, 1); |
| 55 | pmic_spkr_en_mute(RIGHT_SPKR, 1); |
| 56 | } else { |
| 57 | pmic_spkr_en_mute(LEFT_SPKR, 0); |
| 58 | pmic_spkr_en_mute(RIGHT_SPKR, 0); |
| 59 | |
| 60 | pmic_spkr_en(LEFT_SPKR, 0); |
| 61 | pmic_spkr_en(RIGHT_SPKR, 0); |
| 62 | |
| 63 | pmic_set_spkr_configuration(&scm); |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | void analog_mic_enable(int en) |
| 68 | { |
| 69 | pmic_mic_en(en); |
| 70 | } |
| 71 | |
| 72 | static struct q6audio_analog_ops ops = { |
| 73 | .init = analog_init, |
| 74 | .speaker_enable = analog_speaker_enable, |
| 75 | .headset_enable = analog_headset_enable, |
| 76 | .int_mic_enable = analog_mic_enable, |
| 77 | }; |
| 78 | |
| 79 | static int __init init(void) |
| 80 | { |
| 81 | q6audio_register_analog_ops(&ops); |
| 82 | return 0; |
| 83 | } |
| 84 | |
| 85 | device_initcall(init); |