Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 1 | /* |
| 2 | * wm_hubs.c -- WM8993/4 common code |
| 3 | * |
| 4 | * Copyright 2009 Wolfson Microelectronics plc |
| 5 | * |
| 6 | * Author: Mark Brown <broonie@opensource.wolfsonmicro.com> |
| 7 | * |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License version 2 as |
| 11 | * published by the Free Software Foundation. |
| 12 | */ |
| 13 | |
| 14 | #include <linux/module.h> |
| 15 | #include <linux/moduleparam.h> |
| 16 | #include <linux/init.h> |
| 17 | #include <linux/delay.h> |
| 18 | #include <linux/pm.h> |
| 19 | #include <linux/i2c.h> |
Mark Brown | 79ef0ab | 2011-08-01 13:02:17 +0900 | [diff] [blame] | 20 | #include <linux/mfd/wm8994/registers.h> |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 21 | #include <sound/core.h> |
| 22 | #include <sound/pcm.h> |
| 23 | #include <sound/pcm_params.h> |
| 24 | #include <sound/soc.h> |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 25 | #include <sound/initval.h> |
| 26 | #include <sound/tlv.h> |
| 27 | |
| 28 | #include "wm8993.h" |
| 29 | #include "wm_hubs.h" |
| 30 | |
| 31 | const DECLARE_TLV_DB_SCALE(wm_hubs_spkmix_tlv, -300, 300, 0); |
| 32 | EXPORT_SYMBOL_GPL(wm_hubs_spkmix_tlv); |
| 33 | |
| 34 | static const DECLARE_TLV_DB_SCALE(inpga_tlv, -1650, 150, 0); |
| 35 | static const DECLARE_TLV_DB_SCALE(inmix_sw_tlv, 0, 3000, 0); |
| 36 | static const DECLARE_TLV_DB_SCALE(inmix_tlv, -1500, 300, 1); |
| 37 | static const DECLARE_TLV_DB_SCALE(earpiece_tlv, -600, 600, 0); |
| 38 | static const DECLARE_TLV_DB_SCALE(outmix_tlv, -2100, 300, 0); |
| 39 | static const DECLARE_TLV_DB_SCALE(spkmixout_tlv, -1800, 600, 1); |
| 40 | static const DECLARE_TLV_DB_SCALE(outpga_tlv, -5700, 100, 0); |
| 41 | static const unsigned int spkboost_tlv[] = { |
Clemens Ladisch | 028aa63 | 2011-11-20 15:15:31 +0100 | [diff] [blame] | 42 | TLV_DB_RANGE_HEAD(2), |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 43 | 0, 6, TLV_DB_SCALE_ITEM(0, 150, 0), |
| 44 | 7, 7, TLV_DB_SCALE_ITEM(1200, 0, 0), |
| 45 | }; |
| 46 | static const DECLARE_TLV_DB_SCALE(line_tlv, -600, 600, 0); |
| 47 | |
| 48 | static const char *speaker_ref_text[] = { |
| 49 | "SPKVDD/2", |
| 50 | "VMID", |
| 51 | }; |
| 52 | |
| 53 | static const struct soc_enum speaker_ref = |
| 54 | SOC_ENUM_SINGLE(WM8993_SPEAKER_MIXER, 8, 2, speaker_ref_text); |
| 55 | |
| 56 | static const char *speaker_mode_text[] = { |
| 57 | "Class D", |
| 58 | "Class AB", |
| 59 | }; |
| 60 | |
| 61 | static const struct soc_enum speaker_mode = |
| 62 | SOC_ENUM_SINGLE(WM8993_SPKMIXR_ATTENUATION, 8, 2, speaker_mode_text); |
| 63 | |
Mark Brown | 4dcc93d | 2010-03-29 17:18:41 +0100 | [diff] [blame] | 64 | static void wait_for_dc_servo(struct snd_soc_codec *codec, unsigned int op) |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 65 | { |
Mark Brown | d96ca3c | 2011-07-12 15:25:03 +0900 | [diff] [blame] | 66 | struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 67 | unsigned int reg; |
| 68 | int count = 0; |
Mark Brown | 1479c3f | 2011-07-15 17:33:26 +0900 | [diff] [blame] | 69 | int timeout; |
Mark Brown | 4dcc93d | 2010-03-29 17:18:41 +0100 | [diff] [blame] | 70 | unsigned int val; |
| 71 | |
| 72 | val = op | WM8993_DCS_ENA_CHAN_0 | WM8993_DCS_ENA_CHAN_1; |
| 73 | |
| 74 | /* Trigger the command */ |
| 75 | snd_soc_write(codec, WM8993_DC_SERVO_0, val); |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 76 | |
| 77 | dev_dbg(codec->dev, "Waiting for DC servo...\n"); |
Mark Brown | 3ed7074 | 2010-01-20 17:39:45 +0000 | [diff] [blame] | 78 | |
Mark Brown | 1479c3f | 2011-07-15 17:33:26 +0900 | [diff] [blame] | 79 | if (hubs->dcs_done_irq) |
| 80 | timeout = 4; |
| 81 | else |
| 82 | timeout = 400; |
| 83 | |
| 84 | do { |
| 85 | count++; |
| 86 | |
| 87 | if (hubs->dcs_done_irq) |
| 88 | wait_for_completion_timeout(&hubs->dcs_done, |
| 89 | msecs_to_jiffies(250)); |
| 90 | else |
| 91 | msleep(1); |
Mark Brown | d96ca3c | 2011-07-12 15:25:03 +0900 | [diff] [blame] | 92 | |
Mark Brown | 4dcc93d | 2010-03-29 17:18:41 +0100 | [diff] [blame] | 93 | reg = snd_soc_read(codec, WM8993_DC_SERVO_0); |
Mark Brown | 1479c3f | 2011-07-15 17:33:26 +0900 | [diff] [blame] | 94 | dev_dbg(codec->dev, "DC servo: %x\n", reg); |
| 95 | } while (reg & op && count < timeout); |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 96 | |
Mark Brown | 4dcc93d | 2010-03-29 17:18:41 +0100 | [diff] [blame] | 97 | if (reg & op) |
Mark Brown | 5a9f91c | 2011-02-17 12:05:46 -0800 | [diff] [blame] | 98 | dev_err(codec->dev, "Timed out waiting for DC Servo %x\n", |
| 99 | op); |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 100 | } |
| 101 | |
Mark Brown | d96ca3c | 2011-07-12 15:25:03 +0900 | [diff] [blame] | 102 | irqreturn_t wm_hubs_dcs_done(int irq, void *data) |
| 103 | { |
| 104 | struct wm_hubs_data *hubs = data; |
| 105 | |
| 106 | complete(&hubs->dcs_done); |
| 107 | |
| 108 | return IRQ_HANDLED; |
| 109 | } |
| 110 | EXPORT_SYMBOL_GPL(wm_hubs_dcs_done); |
| 111 | |
Mark Brown | af31a22 | 2012-04-26 20:06:56 +0100 | [diff] [blame^] | 112 | static bool wm_hubs_dac_hp_direct(struct snd_soc_codec *codec) |
| 113 | { |
| 114 | int reg; |
| 115 | |
| 116 | /* If we're going via the mixer we'll need to do additional checks */ |
| 117 | reg = snd_soc_read(codec, WM8993_OUTPUT_MIXER1); |
| 118 | if (!(reg & WM8993_DACL_TO_HPOUT1L)) { |
| 119 | if (reg & ~WM8993_DACL_TO_MIXOUTL) { |
| 120 | dev_vdbg(codec->dev, "Analogue paths connected: %x\n", |
| 121 | reg & ~WM8993_DACL_TO_HPOUT1L); |
| 122 | return false; |
| 123 | } else { |
| 124 | dev_vdbg(codec->dev, "HPL connected to mixer\n"); |
| 125 | return false; |
| 126 | } |
| 127 | } else { |
| 128 | dev_vdbg(codec->dev, "HPL connected to DAC\n"); |
| 129 | } |
| 130 | |
| 131 | reg = snd_soc_read(codec, WM8993_OUTPUT_MIXER2); |
| 132 | if (!(reg & WM8993_DACR_TO_HPOUT1R)) { |
| 133 | if (reg & ~WM8993_DACR_TO_MIXOUTR) { |
| 134 | dev_vdbg(codec->dev, "Analogue paths connected: %x\n", |
| 135 | reg & ~WM8993_DACR_TO_HPOUT1R); |
| 136 | return false; |
| 137 | } else { |
| 138 | dev_vdbg(codec->dev, "HPR connected to mixer\n"); |
| 139 | return false; |
| 140 | } |
| 141 | } else { |
| 142 | dev_vdbg(codec->dev, "HPR connected to DAC\n"); |
| 143 | } |
| 144 | |
| 145 | return true; |
| 146 | } |
| 147 | |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 148 | /* |
Mark Brown | 3ed7074 | 2010-01-20 17:39:45 +0000 | [diff] [blame] | 149 | * Startup calibration of the DC servo |
| 150 | */ |
| 151 | static void calibrate_dc_servo(struct snd_soc_codec *codec) |
| 152 | { |
Mark Brown | b2c812e | 2010-04-14 15:35:19 +0900 | [diff] [blame] | 153 | struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); |
Mark Brown | 20a4e7f | 2011-01-21 12:47:33 +0000 | [diff] [blame] | 154 | s8 offset; |
Mark Brown | 79ef0ab | 2011-08-01 13:02:17 +0900 | [diff] [blame] | 155 | u16 reg, reg_l, reg_r, dcs_cfg, dcs_reg; |
| 156 | |
| 157 | switch (hubs->dcs_readback_mode) { |
| 158 | case 2: |
| 159 | dcs_reg = WM8994_DC_SERVO_4E; |
| 160 | break; |
| 161 | default: |
| 162 | dcs_reg = WM8993_DC_SERVO_3; |
| 163 | break; |
| 164 | } |
Mark Brown | 3ed7074 | 2010-01-20 17:39:45 +0000 | [diff] [blame] | 165 | |
Mark Brown | fec6dd8 | 2010-10-27 13:48:36 -0700 | [diff] [blame] | 166 | /* If we're using a digital only path and have a previously |
| 167 | * callibrated DC servo offset stored then use that. */ |
Mark Brown | af31a22 | 2012-04-26 20:06:56 +0100 | [diff] [blame^] | 168 | if (wm_hubs_dac_hp_direct(codec) && hubs->dac_hp_direct_dcs) { |
Mark Brown | fec6dd8 | 2010-10-27 13:48:36 -0700 | [diff] [blame] | 169 | dev_dbg(codec->dev, "Using cached DC servo offset %x\n", |
Mark Brown | af31a22 | 2012-04-26 20:06:56 +0100 | [diff] [blame^] | 170 | hubs->dac_hp_direct_dcs); |
| 171 | snd_soc_write(codec, dcs_reg, hubs->dac_hp_direct_dcs); |
Mark Brown | fec6dd8 | 2010-10-27 13:48:36 -0700 | [diff] [blame] | 172 | wait_for_dc_servo(codec, |
| 173 | WM8993_DCS_TRIG_DAC_WR_0 | |
| 174 | WM8993_DCS_TRIG_DAC_WR_1); |
| 175 | return; |
| 176 | } |
| 177 | |
Mark Brown | f9acf9f | 2011-06-07 23:23:52 +0100 | [diff] [blame] | 178 | if (hubs->series_startup) { |
Mark Brown | 11cef5f | 2010-11-26 17:23:44 +0000 | [diff] [blame] | 179 | /* Set for 32 series updates */ |
| 180 | snd_soc_update_bits(codec, WM8993_DC_SERVO_1, |
| 181 | WM8993_DCS_SERIES_NO_01_MASK, |
| 182 | 32 << WM8993_DCS_SERIES_NO_01_SHIFT); |
| 183 | wait_for_dc_servo(codec, |
| 184 | WM8993_DCS_TRIG_SERIES_0 | |
| 185 | WM8993_DCS_TRIG_SERIES_1); |
| 186 | } else { |
| 187 | wait_for_dc_servo(codec, |
| 188 | WM8993_DCS_TRIG_STARTUP_0 | |
| 189 | WM8993_DCS_TRIG_STARTUP_1); |
| 190 | } |
Mark Brown | 3ed7074 | 2010-01-20 17:39:45 +0000 | [diff] [blame] | 191 | |
Mark Brown | fec6dd8 | 2010-10-27 13:48:36 -0700 | [diff] [blame] | 192 | /* Different chips in the family support different readback |
| 193 | * methods. |
| 194 | */ |
| 195 | switch (hubs->dcs_readback_mode) { |
| 196 | case 0: |
| 197 | reg_l = snd_soc_read(codec, WM8993_DC_SERVO_READBACK_1) |
Joe Perches | ef995e3 | 2010-11-15 09:09:17 -0800 | [diff] [blame] | 198 | & WM8993_DCS_INTEG_CHAN_0_MASK; |
Mark Brown | fec6dd8 | 2010-10-27 13:48:36 -0700 | [diff] [blame] | 199 | reg_r = snd_soc_read(codec, WM8993_DC_SERVO_READBACK_2) |
| 200 | & WM8993_DCS_INTEG_CHAN_1_MASK; |
| 201 | break; |
Mark Brown | 79ef0ab | 2011-08-01 13:02:17 +0900 | [diff] [blame] | 202 | case 2: |
Mark Brown | fec6dd8 | 2010-10-27 13:48:36 -0700 | [diff] [blame] | 203 | case 1: |
Mark Brown | 79ef0ab | 2011-08-01 13:02:17 +0900 | [diff] [blame] | 204 | reg = snd_soc_read(codec, dcs_reg); |
Mark Brown | d5b040c | 2011-06-07 23:28:45 +0100 | [diff] [blame] | 205 | reg_r = (reg & WM8993_DCS_DAC_WR_VAL_1_MASK) |
Mark Brown | fec6dd8 | 2010-10-27 13:48:36 -0700 | [diff] [blame] | 206 | >> WM8993_DCS_DAC_WR_VAL_1_SHIFT; |
Mark Brown | d5b040c | 2011-06-07 23:28:45 +0100 | [diff] [blame] | 207 | reg_l = reg & WM8993_DCS_DAC_WR_VAL_0_MASK; |
Mark Brown | fec6dd8 | 2010-10-27 13:48:36 -0700 | [diff] [blame] | 208 | break; |
| 209 | default: |
Mark Brown | 9e3be1e | 2010-11-02 09:58:49 -0400 | [diff] [blame] | 210 | WARN(1, "Unknown DCS readback method\n"); |
Mark Brown | e778ba0 | 2012-02-29 15:39:56 +0000 | [diff] [blame] | 211 | return; |
Mark Brown | fec6dd8 | 2010-10-27 13:48:36 -0700 | [diff] [blame] | 212 | } |
| 213 | |
| 214 | dev_dbg(codec->dev, "DCS input: %x %x\n", reg_l, reg_r); |
| 215 | |
Mark Brown | 3ed7074 | 2010-01-20 17:39:45 +0000 | [diff] [blame] | 216 | /* Apply correction to DC servo result */ |
Mark Brown | 4537c4e | 2011-08-01 13:10:16 +0900 | [diff] [blame] | 217 | if (hubs->dcs_codes_l || hubs->dcs_codes_r) { |
| 218 | dev_dbg(codec->dev, |
| 219 | "Applying %d/%d code DC servo correction\n", |
| 220 | hubs->dcs_codes_l, hubs->dcs_codes_r); |
Mark Brown | 3ed7074 | 2010-01-20 17:39:45 +0000 | [diff] [blame] | 221 | |
Mark Brown | d5b040c | 2011-06-07 23:28:45 +0100 | [diff] [blame] | 222 | /* HPOUT1R */ |
| 223 | offset = reg_r; |
Mark Brown | 4537c4e | 2011-08-01 13:10:16 +0900 | [diff] [blame] | 224 | offset += hubs->dcs_codes_r; |
Mark Brown | 20a4e7f | 2011-01-21 12:47:33 +0000 | [diff] [blame] | 225 | dcs_cfg = (u8)offset << WM8993_DCS_DAC_WR_VAL_1_SHIFT; |
Mark Brown | 3ed7074 | 2010-01-20 17:39:45 +0000 | [diff] [blame] | 226 | |
Mark Brown | d5b040c | 2011-06-07 23:28:45 +0100 | [diff] [blame] | 227 | /* HPOUT1L */ |
| 228 | offset = reg_l; |
Mark Brown | 4537c4e | 2011-08-01 13:10:16 +0900 | [diff] [blame] | 229 | offset += hubs->dcs_codes_l; |
Mark Brown | 20a4e7f | 2011-01-21 12:47:33 +0000 | [diff] [blame] | 230 | dcs_cfg |= (u8)offset; |
Mark Brown | 3ed7074 | 2010-01-20 17:39:45 +0000 | [diff] [blame] | 231 | |
Mark Brown | 3254d28 | 2010-05-10 14:56:03 +0100 | [diff] [blame] | 232 | dev_dbg(codec->dev, "DCS result: %x\n", dcs_cfg); |
| 233 | |
Mark Brown | 3ed7074 | 2010-01-20 17:39:45 +0000 | [diff] [blame] | 234 | /* Do it */ |
Mark Brown | 79ef0ab | 2011-08-01 13:02:17 +0900 | [diff] [blame] | 235 | snd_soc_write(codec, dcs_reg, dcs_cfg); |
Mark Brown | 4dcc93d | 2010-03-29 17:18:41 +0100 | [diff] [blame] | 236 | wait_for_dc_servo(codec, |
| 237 | WM8993_DCS_TRIG_DAC_WR_0 | |
| 238 | WM8993_DCS_TRIG_DAC_WR_1); |
Mark Brown | fec6dd8 | 2010-10-27 13:48:36 -0700 | [diff] [blame] | 239 | } else { |
Mark Brown | d5b040c | 2011-06-07 23:28:45 +0100 | [diff] [blame] | 240 | dcs_cfg = reg_r << WM8993_DCS_DAC_WR_VAL_1_SHIFT; |
| 241 | dcs_cfg |= reg_l; |
Mark Brown | 3ed7074 | 2010-01-20 17:39:45 +0000 | [diff] [blame] | 242 | } |
Mark Brown | fec6dd8 | 2010-10-27 13:48:36 -0700 | [diff] [blame] | 243 | |
| 244 | /* Save the callibrated offset if we're in class W mode and |
| 245 | * therefore don't have any analogue signal mixed in. */ |
Mark Brown | af31a22 | 2012-04-26 20:06:56 +0100 | [diff] [blame^] | 246 | if (wm_hubs_dac_hp_direct(codec) && !hubs->no_cache_dac_hp_direct) |
| 247 | hubs->dac_hp_direct_dcs = dcs_cfg; |
Mark Brown | 3ed7074 | 2010-01-20 17:39:45 +0000 | [diff] [blame] | 248 | } |
| 249 | |
| 250 | /* |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 251 | * Update the DC servo calibration on gain changes |
| 252 | */ |
| 253 | static int wm8993_put_dc_servo(struct snd_kcontrol *kcontrol, |
Mark Brown | 3ed7074 | 2010-01-20 17:39:45 +0000 | [diff] [blame] | 254 | struct snd_ctl_elem_value *ucontrol) |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 255 | { |
| 256 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
Mark Brown | b2c812e | 2010-04-14 15:35:19 +0900 | [diff] [blame] | 257 | struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 258 | int ret; |
| 259 | |
Peter Ujfalusi | c4671a9 | 2011-10-06 09:59:12 +0300 | [diff] [blame] | 260 | ret = snd_soc_put_volsw(kcontrol, ucontrol); |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 261 | |
Mark Brown | fec6dd8 | 2010-10-27 13:48:36 -0700 | [diff] [blame] | 262 | /* Updating the analogue gains invalidates the DC servo cache */ |
Mark Brown | af31a22 | 2012-04-26 20:06:56 +0100 | [diff] [blame^] | 263 | hubs->dac_hp_direct_dcs = 0; |
Mark Brown | fec6dd8 | 2010-10-27 13:48:36 -0700 | [diff] [blame] | 264 | |
Mark Brown | ae9d860 | 2010-03-29 16:34:42 +0100 | [diff] [blame] | 265 | /* If we're applying an offset correction then updating the |
| 266 | * callibration would be likely to introduce further offsets. */ |
Mark Brown | 4537c4e | 2011-08-01 13:10:16 +0900 | [diff] [blame] | 267 | if (hubs->dcs_codes_l || hubs->dcs_codes_r || hubs->no_series_update) |
Mark Brown | ae9d860 | 2010-03-29 16:34:42 +0100 | [diff] [blame] | 268 | return ret; |
| 269 | |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 270 | /* Only need to do this if the outputs are active */ |
| 271 | if (snd_soc_read(codec, WM8993_POWER_MANAGEMENT_1) |
| 272 | & (WM8993_HPOUT1L_ENA | WM8993_HPOUT1R_ENA)) |
| 273 | snd_soc_update_bits(codec, |
| 274 | WM8993_DC_SERVO_0, |
| 275 | WM8993_DCS_TRIG_SINGLE_0 | |
| 276 | WM8993_DCS_TRIG_SINGLE_1, |
| 277 | WM8993_DCS_TRIG_SINGLE_0 | |
| 278 | WM8993_DCS_TRIG_SINGLE_1); |
| 279 | |
| 280 | return ret; |
| 281 | } |
| 282 | |
| 283 | static const struct snd_kcontrol_new analogue_snd_controls[] = { |
| 284 | SOC_SINGLE_TLV("IN1L Volume", WM8993_LEFT_LINE_INPUT_1_2_VOLUME, 0, 31, 0, |
| 285 | inpga_tlv), |
| 286 | SOC_SINGLE("IN1L Switch", WM8993_LEFT_LINE_INPUT_1_2_VOLUME, 7, 1, 1), |
Mark Brown | ea02c63 | 2011-05-27 21:56:16 +0800 | [diff] [blame] | 287 | SOC_SINGLE("IN1L ZC Switch", WM8993_LEFT_LINE_INPUT_1_2_VOLUME, 6, 1, 0), |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 288 | |
| 289 | SOC_SINGLE_TLV("IN1R Volume", WM8993_RIGHT_LINE_INPUT_1_2_VOLUME, 0, 31, 0, |
| 290 | inpga_tlv), |
| 291 | SOC_SINGLE("IN1R Switch", WM8993_RIGHT_LINE_INPUT_1_2_VOLUME, 7, 1, 1), |
Mark Brown | ea02c63 | 2011-05-27 21:56:16 +0800 | [diff] [blame] | 292 | SOC_SINGLE("IN1R ZC Switch", WM8993_RIGHT_LINE_INPUT_1_2_VOLUME, 6, 1, 0), |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 293 | |
| 294 | |
| 295 | SOC_SINGLE_TLV("IN2L Volume", WM8993_LEFT_LINE_INPUT_3_4_VOLUME, 0, 31, 0, |
| 296 | inpga_tlv), |
| 297 | SOC_SINGLE("IN2L Switch", WM8993_LEFT_LINE_INPUT_3_4_VOLUME, 7, 1, 1), |
Mark Brown | ea02c63 | 2011-05-27 21:56:16 +0800 | [diff] [blame] | 298 | SOC_SINGLE("IN2L ZC Switch", WM8993_LEFT_LINE_INPUT_3_4_VOLUME, 6, 1, 0), |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 299 | |
| 300 | SOC_SINGLE_TLV("IN2R Volume", WM8993_RIGHT_LINE_INPUT_3_4_VOLUME, 0, 31, 0, |
| 301 | inpga_tlv), |
| 302 | SOC_SINGLE("IN2R Switch", WM8993_RIGHT_LINE_INPUT_3_4_VOLUME, 7, 1, 1), |
Mark Brown | ea02c63 | 2011-05-27 21:56:16 +0800 | [diff] [blame] | 303 | SOC_SINGLE("IN2R ZC Switch", WM8993_RIGHT_LINE_INPUT_3_4_VOLUME, 6, 1, 0), |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 304 | |
| 305 | SOC_SINGLE_TLV("MIXINL IN2L Volume", WM8993_INPUT_MIXER3, 7, 1, 0, |
| 306 | inmix_sw_tlv), |
| 307 | SOC_SINGLE_TLV("MIXINL IN1L Volume", WM8993_INPUT_MIXER3, 4, 1, 0, |
| 308 | inmix_sw_tlv), |
| 309 | SOC_SINGLE_TLV("MIXINL Output Record Volume", WM8993_INPUT_MIXER3, 0, 7, 0, |
| 310 | inmix_tlv), |
| 311 | SOC_SINGLE_TLV("MIXINL IN1LP Volume", WM8993_INPUT_MIXER5, 6, 7, 0, inmix_tlv), |
| 312 | SOC_SINGLE_TLV("MIXINL Direct Voice Volume", WM8993_INPUT_MIXER5, 0, 6, 0, |
| 313 | inmix_tlv), |
| 314 | |
| 315 | SOC_SINGLE_TLV("MIXINR IN2R Volume", WM8993_INPUT_MIXER4, 7, 1, 0, |
| 316 | inmix_sw_tlv), |
| 317 | SOC_SINGLE_TLV("MIXINR IN1R Volume", WM8993_INPUT_MIXER4, 4, 1, 0, |
| 318 | inmix_sw_tlv), |
| 319 | SOC_SINGLE_TLV("MIXINR Output Record Volume", WM8993_INPUT_MIXER4, 0, 7, 0, |
| 320 | inmix_tlv), |
| 321 | SOC_SINGLE_TLV("MIXINR IN1RP Volume", WM8993_INPUT_MIXER6, 6, 7, 0, inmix_tlv), |
| 322 | SOC_SINGLE_TLV("MIXINR Direct Voice Volume", WM8993_INPUT_MIXER6, 0, 6, 0, |
| 323 | inmix_tlv), |
| 324 | |
| 325 | SOC_SINGLE_TLV("Left Output Mixer IN2RN Volume", WM8993_OUTPUT_MIXER5, 6, 7, 1, |
| 326 | outmix_tlv), |
| 327 | SOC_SINGLE_TLV("Left Output Mixer IN2LN Volume", WM8993_OUTPUT_MIXER3, 6, 7, 1, |
| 328 | outmix_tlv), |
| 329 | SOC_SINGLE_TLV("Left Output Mixer IN2LP Volume", WM8993_OUTPUT_MIXER3, 9, 7, 1, |
| 330 | outmix_tlv), |
| 331 | SOC_SINGLE_TLV("Left Output Mixer IN1L Volume", WM8993_OUTPUT_MIXER3, 0, 7, 1, |
| 332 | outmix_tlv), |
| 333 | SOC_SINGLE_TLV("Left Output Mixer IN1R Volume", WM8993_OUTPUT_MIXER3, 3, 7, 1, |
| 334 | outmix_tlv), |
| 335 | SOC_SINGLE_TLV("Left Output Mixer Right Input Volume", |
| 336 | WM8993_OUTPUT_MIXER5, 3, 7, 1, outmix_tlv), |
| 337 | SOC_SINGLE_TLV("Left Output Mixer Left Input Volume", |
| 338 | WM8993_OUTPUT_MIXER5, 0, 7, 1, outmix_tlv), |
| 339 | SOC_SINGLE_TLV("Left Output Mixer DAC Volume", WM8993_OUTPUT_MIXER5, 9, 7, 1, |
| 340 | outmix_tlv), |
| 341 | |
| 342 | SOC_SINGLE_TLV("Right Output Mixer IN2LN Volume", |
| 343 | WM8993_OUTPUT_MIXER6, 6, 7, 1, outmix_tlv), |
| 344 | SOC_SINGLE_TLV("Right Output Mixer IN2RN Volume", |
| 345 | WM8993_OUTPUT_MIXER4, 6, 7, 1, outmix_tlv), |
| 346 | SOC_SINGLE_TLV("Right Output Mixer IN1L Volume", |
| 347 | WM8993_OUTPUT_MIXER4, 3, 7, 1, outmix_tlv), |
| 348 | SOC_SINGLE_TLV("Right Output Mixer IN1R Volume", |
| 349 | WM8993_OUTPUT_MIXER4, 0, 7, 1, outmix_tlv), |
| 350 | SOC_SINGLE_TLV("Right Output Mixer IN2RP Volume", |
| 351 | WM8993_OUTPUT_MIXER4, 9, 7, 1, outmix_tlv), |
| 352 | SOC_SINGLE_TLV("Right Output Mixer Left Input Volume", |
| 353 | WM8993_OUTPUT_MIXER6, 3, 7, 1, outmix_tlv), |
| 354 | SOC_SINGLE_TLV("Right Output Mixer Right Input Volume", |
| 355 | WM8993_OUTPUT_MIXER6, 6, 7, 1, outmix_tlv), |
| 356 | SOC_SINGLE_TLV("Right Output Mixer DAC Volume", |
| 357 | WM8993_OUTPUT_MIXER6, 9, 7, 1, outmix_tlv), |
| 358 | |
| 359 | SOC_DOUBLE_R_TLV("Output Volume", WM8993_LEFT_OPGA_VOLUME, |
| 360 | WM8993_RIGHT_OPGA_VOLUME, 0, 63, 0, outpga_tlv), |
| 361 | SOC_DOUBLE_R("Output Switch", WM8993_LEFT_OPGA_VOLUME, |
| 362 | WM8993_RIGHT_OPGA_VOLUME, 6, 1, 0), |
| 363 | SOC_DOUBLE_R("Output ZC Switch", WM8993_LEFT_OPGA_VOLUME, |
| 364 | WM8993_RIGHT_OPGA_VOLUME, 7, 1, 0), |
| 365 | |
| 366 | SOC_SINGLE("Earpiece Switch", WM8993_HPOUT2_VOLUME, 5, 1, 1), |
| 367 | SOC_SINGLE_TLV("Earpiece Volume", WM8993_HPOUT2_VOLUME, 4, 1, 1, earpiece_tlv), |
| 368 | |
| 369 | SOC_SINGLE_TLV("SPKL Input Volume", WM8993_SPKMIXL_ATTENUATION, |
| 370 | 5, 1, 1, wm_hubs_spkmix_tlv), |
| 371 | SOC_SINGLE_TLV("SPKL IN1LP Volume", WM8993_SPKMIXL_ATTENUATION, |
| 372 | 4, 1, 1, wm_hubs_spkmix_tlv), |
| 373 | SOC_SINGLE_TLV("SPKL Output Volume", WM8993_SPKMIXL_ATTENUATION, |
| 374 | 3, 1, 1, wm_hubs_spkmix_tlv), |
| 375 | |
| 376 | SOC_SINGLE_TLV("SPKR Input Volume", WM8993_SPKMIXR_ATTENUATION, |
| 377 | 5, 1, 1, wm_hubs_spkmix_tlv), |
| 378 | SOC_SINGLE_TLV("SPKR IN1RP Volume", WM8993_SPKMIXR_ATTENUATION, |
| 379 | 4, 1, 1, wm_hubs_spkmix_tlv), |
| 380 | SOC_SINGLE_TLV("SPKR Output Volume", WM8993_SPKMIXR_ATTENUATION, |
| 381 | 3, 1, 1, wm_hubs_spkmix_tlv), |
| 382 | |
| 383 | SOC_DOUBLE_R_TLV("Speaker Mixer Volume", |
| 384 | WM8993_SPKMIXL_ATTENUATION, WM8993_SPKMIXR_ATTENUATION, |
| 385 | 0, 3, 1, spkmixout_tlv), |
| 386 | SOC_DOUBLE_R_TLV("Speaker Volume", |
| 387 | WM8993_SPEAKER_VOLUME_LEFT, WM8993_SPEAKER_VOLUME_RIGHT, |
| 388 | 0, 63, 0, outpga_tlv), |
| 389 | SOC_DOUBLE_R("Speaker Switch", |
| 390 | WM8993_SPEAKER_VOLUME_LEFT, WM8993_SPEAKER_VOLUME_RIGHT, |
| 391 | 6, 1, 0), |
| 392 | SOC_DOUBLE_R("Speaker ZC Switch", |
| 393 | WM8993_SPEAKER_VOLUME_LEFT, WM8993_SPEAKER_VOLUME_RIGHT, |
| 394 | 7, 1, 0), |
Uk Kim | ed8cc47 | 2010-12-05 17:26:07 +0900 | [diff] [blame] | 395 | SOC_DOUBLE_TLV("Speaker Boost Volume", WM8993_SPKOUT_BOOST, 3, 0, 7, 0, |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 396 | spkboost_tlv), |
| 397 | SOC_ENUM("Speaker Reference", speaker_ref), |
| 398 | SOC_ENUM("Speaker Mode", speaker_mode), |
| 399 | |
Peter Ujfalusi | 0f9887d | 2011-10-05 10:29:19 +0300 | [diff] [blame] | 400 | SOC_DOUBLE_R_EXT_TLV("Headphone Volume", |
| 401 | WM8993_LEFT_OUTPUT_VOLUME, WM8993_RIGHT_OUTPUT_VOLUME, |
Peter Ujfalusi | c4671a9 | 2011-10-06 09:59:12 +0300 | [diff] [blame] | 402 | 0, 63, 0, snd_soc_get_volsw, wm8993_put_dc_servo, |
Peter Ujfalusi | 0f9887d | 2011-10-05 10:29:19 +0300 | [diff] [blame] | 403 | outpga_tlv), |
| 404 | |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 405 | SOC_DOUBLE_R("Headphone Switch", WM8993_LEFT_OUTPUT_VOLUME, |
| 406 | WM8993_RIGHT_OUTPUT_VOLUME, 6, 1, 0), |
| 407 | SOC_DOUBLE_R("Headphone ZC Switch", WM8993_LEFT_OUTPUT_VOLUME, |
| 408 | WM8993_RIGHT_OUTPUT_VOLUME, 7, 1, 0), |
| 409 | |
| 410 | SOC_SINGLE("LINEOUT1N Switch", WM8993_LINE_OUTPUTS_VOLUME, 6, 1, 1), |
| 411 | SOC_SINGLE("LINEOUT1P Switch", WM8993_LINE_OUTPUTS_VOLUME, 5, 1, 1), |
| 412 | SOC_SINGLE_TLV("LINEOUT1 Volume", WM8993_LINE_OUTPUTS_VOLUME, 4, 1, 1, |
| 413 | line_tlv), |
| 414 | |
| 415 | SOC_SINGLE("LINEOUT2N Switch", WM8993_LINE_OUTPUTS_VOLUME, 2, 1, 1), |
| 416 | SOC_SINGLE("LINEOUT2P Switch", WM8993_LINE_OUTPUTS_VOLUME, 1, 1, 1), |
| 417 | SOC_SINGLE_TLV("LINEOUT2 Volume", WM8993_LINE_OUTPUTS_VOLUME, 0, 1, 1, |
| 418 | line_tlv), |
| 419 | }; |
| 420 | |
Mark Brown | 3ed7074 | 2010-01-20 17:39:45 +0000 | [diff] [blame] | 421 | static int hp_supply_event(struct snd_soc_dapm_widget *w, |
| 422 | struct snd_kcontrol *kcontrol, int event) |
| 423 | { |
| 424 | struct snd_soc_codec *codec = w->codec; |
Mark Brown | b2c812e | 2010-04-14 15:35:19 +0900 | [diff] [blame] | 425 | struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); |
Mark Brown | 3ed7074 | 2010-01-20 17:39:45 +0000 | [diff] [blame] | 426 | |
| 427 | switch (event) { |
| 428 | case SND_SOC_DAPM_PRE_PMU: |
| 429 | switch (hubs->hp_startup_mode) { |
| 430 | case 0: |
| 431 | break; |
| 432 | case 1: |
| 433 | /* Enable the headphone amp */ |
| 434 | snd_soc_update_bits(codec, WM8993_POWER_MANAGEMENT_1, |
| 435 | WM8993_HPOUT1L_ENA | |
| 436 | WM8993_HPOUT1R_ENA, |
| 437 | WM8993_HPOUT1L_ENA | |
| 438 | WM8993_HPOUT1R_ENA); |
| 439 | |
| 440 | /* Enable the second stage */ |
| 441 | snd_soc_update_bits(codec, WM8993_ANALOGUE_HP_0, |
| 442 | WM8993_HPOUT1L_DLY | |
| 443 | WM8993_HPOUT1R_DLY, |
| 444 | WM8993_HPOUT1L_DLY | |
| 445 | WM8993_HPOUT1R_DLY); |
| 446 | break; |
| 447 | default: |
| 448 | dev_err(codec->dev, "Unknown HP startup mode %d\n", |
| 449 | hubs->hp_startup_mode); |
| 450 | break; |
| 451 | } |
| 452 | |
| 453 | case SND_SOC_DAPM_PRE_PMD: |
| 454 | snd_soc_update_bits(codec, WM8993_CHARGE_PUMP_1, |
| 455 | WM8993_CP_ENA, 0); |
| 456 | break; |
| 457 | } |
| 458 | |
| 459 | return 0; |
| 460 | } |
| 461 | |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 462 | static int hp_event(struct snd_soc_dapm_widget *w, |
| 463 | struct snd_kcontrol *kcontrol, int event) |
| 464 | { |
| 465 | struct snd_soc_codec *codec = w->codec; |
| 466 | unsigned int reg = snd_soc_read(codec, WM8993_ANALOGUE_HP_0); |
| 467 | |
| 468 | switch (event) { |
| 469 | case SND_SOC_DAPM_POST_PMU: |
| 470 | snd_soc_update_bits(codec, WM8993_CHARGE_PUMP_1, |
| 471 | WM8993_CP_ENA, WM8993_CP_ENA); |
| 472 | |
| 473 | msleep(5); |
| 474 | |
| 475 | snd_soc_update_bits(codec, WM8993_POWER_MANAGEMENT_1, |
| 476 | WM8993_HPOUT1L_ENA | WM8993_HPOUT1R_ENA, |
| 477 | WM8993_HPOUT1L_ENA | WM8993_HPOUT1R_ENA); |
| 478 | |
| 479 | reg |= WM8993_HPOUT1L_DLY | WM8993_HPOUT1R_DLY; |
| 480 | snd_soc_write(codec, WM8993_ANALOGUE_HP_0, reg); |
| 481 | |
Mark Brown | 3ed7074 | 2010-01-20 17:39:45 +0000 | [diff] [blame] | 482 | snd_soc_update_bits(codec, WM8993_DC_SERVO_1, |
Mark Brown | f9925d4 | 2011-07-28 12:44:44 +0100 | [diff] [blame] | 483 | WM8993_DCS_TIMER_PERIOD_01_MASK, 0); |
Mark Brown | 3ed7074 | 2010-01-20 17:39:45 +0000 | [diff] [blame] | 484 | |
| 485 | calibrate_dc_servo(codec); |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 486 | |
| 487 | reg |= WM8993_HPOUT1R_OUTP | WM8993_HPOUT1R_RMV_SHORT | |
| 488 | WM8993_HPOUT1L_OUTP | WM8993_HPOUT1L_RMV_SHORT; |
| 489 | snd_soc_write(codec, WM8993_ANALOGUE_HP_0, reg); |
| 490 | break; |
| 491 | |
| 492 | case SND_SOC_DAPM_PRE_PMD: |
Mark Brown | 3ed7074 | 2010-01-20 17:39:45 +0000 | [diff] [blame] | 493 | snd_soc_update_bits(codec, WM8993_ANALOGUE_HP_0, |
Mark Brown | 6adb26b | 2010-05-10 16:13:11 +0100 | [diff] [blame] | 494 | WM8993_HPOUT1L_OUTP | |
| 495 | WM8993_HPOUT1R_OUTP | |
Mark Brown | 3ed7074 | 2010-01-20 17:39:45 +0000 | [diff] [blame] | 496 | WM8993_HPOUT1L_RMV_SHORT | |
| 497 | WM8993_HPOUT1R_RMV_SHORT, 0); |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 498 | |
Mark Brown | 3ed7074 | 2010-01-20 17:39:45 +0000 | [diff] [blame] | 499 | snd_soc_update_bits(codec, WM8993_ANALOGUE_HP_0, |
Mark Brown | 6adb26b | 2010-05-10 16:13:11 +0100 | [diff] [blame] | 500 | WM8993_HPOUT1L_DLY | |
| 501 | WM8993_HPOUT1R_DLY, 0); |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 502 | |
Mark Brown | 395e4b7 | 2010-05-10 21:06:14 +0100 | [diff] [blame] | 503 | snd_soc_write(codec, WM8993_DC_SERVO_0, 0); |
| 504 | |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 505 | snd_soc_update_bits(codec, WM8993_POWER_MANAGEMENT_1, |
| 506 | WM8993_HPOUT1L_ENA | WM8993_HPOUT1R_ENA, |
| 507 | 0); |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 508 | break; |
| 509 | } |
| 510 | |
| 511 | return 0; |
| 512 | } |
| 513 | |
| 514 | static int earpiece_event(struct snd_soc_dapm_widget *w, |
| 515 | struct snd_kcontrol *control, int event) |
| 516 | { |
| 517 | struct snd_soc_codec *codec = w->codec; |
| 518 | u16 reg = snd_soc_read(codec, WM8993_ANTIPOP1) & ~WM8993_HPOUT2_IN_ENA; |
| 519 | |
| 520 | switch (event) { |
| 521 | case SND_SOC_DAPM_PRE_PMU: |
| 522 | reg |= WM8993_HPOUT2_IN_ENA; |
| 523 | snd_soc_write(codec, WM8993_ANTIPOP1, reg); |
| 524 | udelay(50); |
| 525 | break; |
| 526 | |
| 527 | case SND_SOC_DAPM_POST_PMD: |
| 528 | snd_soc_write(codec, WM8993_ANTIPOP1, reg); |
| 529 | break; |
| 530 | |
| 531 | default: |
| 532 | BUG(); |
| 533 | break; |
| 534 | } |
| 535 | |
| 536 | return 0; |
| 537 | } |
| 538 | |
Mark Brown | 5f2f389 | 2012-02-08 18:51:42 +0000 | [diff] [blame] | 539 | static int lineout_event(struct snd_soc_dapm_widget *w, |
| 540 | struct snd_kcontrol *control, int event) |
| 541 | { |
| 542 | struct snd_soc_codec *codec = w->codec; |
| 543 | struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); |
| 544 | bool *flag; |
| 545 | |
| 546 | switch (w->shift) { |
| 547 | case WM8993_LINEOUT1N_ENA_SHIFT: |
| 548 | flag = &hubs->lineout1n_ena; |
| 549 | break; |
| 550 | case WM8993_LINEOUT1P_ENA_SHIFT: |
| 551 | flag = &hubs->lineout1p_ena; |
| 552 | break; |
| 553 | case WM8993_LINEOUT2N_ENA_SHIFT: |
| 554 | flag = &hubs->lineout2n_ena; |
| 555 | break; |
| 556 | case WM8993_LINEOUT2P_ENA_SHIFT: |
| 557 | flag = &hubs->lineout2p_ena; |
| 558 | break; |
| 559 | default: |
| 560 | WARN(1, "Unknown line output"); |
| 561 | return -EINVAL; |
| 562 | } |
| 563 | |
| 564 | *flag = SND_SOC_DAPM_EVENT_ON(event); |
| 565 | |
| 566 | return 0; |
| 567 | } |
| 568 | |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 569 | static const struct snd_kcontrol_new in1l_pga[] = { |
| 570 | SOC_DAPM_SINGLE("IN1LP Switch", WM8993_INPUT_MIXER2, 5, 1, 0), |
| 571 | SOC_DAPM_SINGLE("IN1LN Switch", WM8993_INPUT_MIXER2, 4, 1, 0), |
| 572 | }; |
| 573 | |
| 574 | static const struct snd_kcontrol_new in1r_pga[] = { |
| 575 | SOC_DAPM_SINGLE("IN1RP Switch", WM8993_INPUT_MIXER2, 1, 1, 0), |
| 576 | SOC_DAPM_SINGLE("IN1RN Switch", WM8993_INPUT_MIXER2, 0, 1, 0), |
| 577 | }; |
| 578 | |
| 579 | static const struct snd_kcontrol_new in2l_pga[] = { |
| 580 | SOC_DAPM_SINGLE("IN2LP Switch", WM8993_INPUT_MIXER2, 7, 1, 0), |
| 581 | SOC_DAPM_SINGLE("IN2LN Switch", WM8993_INPUT_MIXER2, 6, 1, 0), |
| 582 | }; |
| 583 | |
| 584 | static const struct snd_kcontrol_new in2r_pga[] = { |
| 585 | SOC_DAPM_SINGLE("IN2RP Switch", WM8993_INPUT_MIXER2, 3, 1, 0), |
| 586 | SOC_DAPM_SINGLE("IN2RN Switch", WM8993_INPUT_MIXER2, 2, 1, 0), |
| 587 | }; |
| 588 | |
| 589 | static const struct snd_kcontrol_new mixinl[] = { |
| 590 | SOC_DAPM_SINGLE("IN2L Switch", WM8993_INPUT_MIXER3, 8, 1, 0), |
| 591 | SOC_DAPM_SINGLE("IN1L Switch", WM8993_INPUT_MIXER3, 5, 1, 0), |
| 592 | }; |
| 593 | |
| 594 | static const struct snd_kcontrol_new mixinr[] = { |
| 595 | SOC_DAPM_SINGLE("IN2R Switch", WM8993_INPUT_MIXER4, 8, 1, 0), |
| 596 | SOC_DAPM_SINGLE("IN1R Switch", WM8993_INPUT_MIXER4, 5, 1, 0), |
| 597 | }; |
| 598 | |
| 599 | static const struct snd_kcontrol_new left_output_mixer[] = { |
| 600 | SOC_DAPM_SINGLE("Right Input Switch", WM8993_OUTPUT_MIXER1, 7, 1, 0), |
| 601 | SOC_DAPM_SINGLE("Left Input Switch", WM8993_OUTPUT_MIXER1, 6, 1, 0), |
| 602 | SOC_DAPM_SINGLE("IN2RN Switch", WM8993_OUTPUT_MIXER1, 5, 1, 0), |
| 603 | SOC_DAPM_SINGLE("IN2LN Switch", WM8993_OUTPUT_MIXER1, 4, 1, 0), |
| 604 | SOC_DAPM_SINGLE("IN2LP Switch", WM8993_OUTPUT_MIXER1, 1, 1, 0), |
| 605 | SOC_DAPM_SINGLE("IN1R Switch", WM8993_OUTPUT_MIXER1, 3, 1, 0), |
| 606 | SOC_DAPM_SINGLE("IN1L Switch", WM8993_OUTPUT_MIXER1, 2, 1, 0), |
| 607 | SOC_DAPM_SINGLE("DAC Switch", WM8993_OUTPUT_MIXER1, 0, 1, 0), |
| 608 | }; |
| 609 | |
| 610 | static const struct snd_kcontrol_new right_output_mixer[] = { |
| 611 | SOC_DAPM_SINGLE("Left Input Switch", WM8993_OUTPUT_MIXER2, 7, 1, 0), |
| 612 | SOC_DAPM_SINGLE("Right Input Switch", WM8993_OUTPUT_MIXER2, 6, 1, 0), |
| 613 | SOC_DAPM_SINGLE("IN2LN Switch", WM8993_OUTPUT_MIXER2, 5, 1, 0), |
| 614 | SOC_DAPM_SINGLE("IN2RN Switch", WM8993_OUTPUT_MIXER2, 4, 1, 0), |
| 615 | SOC_DAPM_SINGLE("IN1L Switch", WM8993_OUTPUT_MIXER2, 3, 1, 0), |
| 616 | SOC_DAPM_SINGLE("IN1R Switch", WM8993_OUTPUT_MIXER2, 2, 1, 0), |
| 617 | SOC_DAPM_SINGLE("IN2RP Switch", WM8993_OUTPUT_MIXER2, 1, 1, 0), |
| 618 | SOC_DAPM_SINGLE("DAC Switch", WM8993_OUTPUT_MIXER2, 0, 1, 0), |
| 619 | }; |
| 620 | |
| 621 | static const struct snd_kcontrol_new earpiece_mixer[] = { |
| 622 | SOC_DAPM_SINGLE("Direct Voice Switch", WM8993_HPOUT2_MIXER, 5, 1, 0), |
| 623 | SOC_DAPM_SINGLE("Left Output Switch", WM8993_HPOUT2_MIXER, 4, 1, 0), |
| 624 | SOC_DAPM_SINGLE("Right Output Switch", WM8993_HPOUT2_MIXER, 3, 1, 0), |
| 625 | }; |
| 626 | |
| 627 | static const struct snd_kcontrol_new left_speaker_boost[] = { |
| 628 | SOC_DAPM_SINGLE("Direct Voice Switch", WM8993_SPKOUT_MIXERS, 5, 1, 0), |
| 629 | SOC_DAPM_SINGLE("SPKL Switch", WM8993_SPKOUT_MIXERS, 4, 1, 0), |
| 630 | SOC_DAPM_SINGLE("SPKR Switch", WM8993_SPKOUT_MIXERS, 3, 1, 0), |
| 631 | }; |
| 632 | |
| 633 | static const struct snd_kcontrol_new right_speaker_boost[] = { |
| 634 | SOC_DAPM_SINGLE("Direct Voice Switch", WM8993_SPKOUT_MIXERS, 2, 1, 0), |
| 635 | SOC_DAPM_SINGLE("SPKL Switch", WM8993_SPKOUT_MIXERS, 1, 1, 0), |
| 636 | SOC_DAPM_SINGLE("SPKR Switch", WM8993_SPKOUT_MIXERS, 0, 1, 0), |
| 637 | }; |
| 638 | |
| 639 | static const struct snd_kcontrol_new line1_mix[] = { |
| 640 | SOC_DAPM_SINGLE("IN1R Switch", WM8993_LINE_MIXER1, 2, 1, 0), |
| 641 | SOC_DAPM_SINGLE("IN1L Switch", WM8993_LINE_MIXER1, 1, 1, 0), |
| 642 | SOC_DAPM_SINGLE("Output Switch", WM8993_LINE_MIXER1, 0, 1, 0), |
| 643 | }; |
| 644 | |
| 645 | static const struct snd_kcontrol_new line1n_mix[] = { |
| 646 | SOC_DAPM_SINGLE("Left Output Switch", WM8993_LINE_MIXER1, 6, 1, 0), |
| 647 | SOC_DAPM_SINGLE("Right Output Switch", WM8993_LINE_MIXER1, 5, 1, 0), |
| 648 | }; |
| 649 | |
| 650 | static const struct snd_kcontrol_new line1p_mix[] = { |
| 651 | SOC_DAPM_SINGLE("Left Output Switch", WM8993_LINE_MIXER1, 0, 1, 0), |
| 652 | }; |
| 653 | |
| 654 | static const struct snd_kcontrol_new line2_mix[] = { |
Mark Brown | 43b6cec | 2012-02-01 23:46:58 +0000 | [diff] [blame] | 655 | SOC_DAPM_SINGLE("IN1L Switch", WM8993_LINE_MIXER2, 2, 1, 0), |
| 656 | SOC_DAPM_SINGLE("IN1R Switch", WM8993_LINE_MIXER2, 1, 1, 0), |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 657 | SOC_DAPM_SINGLE("Output Switch", WM8993_LINE_MIXER2, 0, 1, 0), |
| 658 | }; |
| 659 | |
| 660 | static const struct snd_kcontrol_new line2n_mix[] = { |
UK KIM | 114395c | 2012-01-28 01:52:22 +0900 | [diff] [blame] | 661 | SOC_DAPM_SINGLE("Left Output Switch", WM8993_LINE_MIXER2, 5, 1, 0), |
| 662 | SOC_DAPM_SINGLE("Right Output Switch", WM8993_LINE_MIXER2, 6, 1, 0), |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 663 | }; |
| 664 | |
| 665 | static const struct snd_kcontrol_new line2p_mix[] = { |
| 666 | SOC_DAPM_SINGLE("Right Output Switch", WM8993_LINE_MIXER2, 0, 1, 0), |
| 667 | }; |
| 668 | |
| 669 | static const struct snd_soc_dapm_widget analogue_dapm_widgets[] = { |
| 670 | SND_SOC_DAPM_INPUT("IN1LN"), |
| 671 | SND_SOC_DAPM_INPUT("IN1LP"), |
| 672 | SND_SOC_DAPM_INPUT("IN2LN"), |
Joonyoung Shim | 3482594 | 2009-12-04 15:12:10 +0900 | [diff] [blame] | 673 | SND_SOC_DAPM_INPUT("IN2LP:VXRN"), |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 674 | SND_SOC_DAPM_INPUT("IN1RN"), |
| 675 | SND_SOC_DAPM_INPUT("IN1RP"), |
| 676 | SND_SOC_DAPM_INPUT("IN2RN"), |
Joonyoung Shim | 3482594 | 2009-12-04 15:12:10 +0900 | [diff] [blame] | 677 | SND_SOC_DAPM_INPUT("IN2RP:VXRP"), |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 678 | |
Mark Brown | 91e2085 | 2011-12-02 16:01:41 +0000 | [diff] [blame] | 679 | SND_SOC_DAPM_SUPPLY("MICBIAS2", WM8993_POWER_MANAGEMENT_1, 5, 0, NULL, 0), |
| 680 | SND_SOC_DAPM_SUPPLY("MICBIAS1", WM8993_POWER_MANAGEMENT_1, 4, 0, NULL, 0), |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 681 | |
| 682 | SND_SOC_DAPM_MIXER("IN1L PGA", WM8993_POWER_MANAGEMENT_2, 6, 0, |
| 683 | in1l_pga, ARRAY_SIZE(in1l_pga)), |
| 684 | SND_SOC_DAPM_MIXER("IN1R PGA", WM8993_POWER_MANAGEMENT_2, 4, 0, |
| 685 | in1r_pga, ARRAY_SIZE(in1r_pga)), |
| 686 | |
| 687 | SND_SOC_DAPM_MIXER("IN2L PGA", WM8993_POWER_MANAGEMENT_2, 7, 0, |
| 688 | in2l_pga, ARRAY_SIZE(in2l_pga)), |
| 689 | SND_SOC_DAPM_MIXER("IN2R PGA", WM8993_POWER_MANAGEMENT_2, 5, 0, |
| 690 | in2r_pga, ARRAY_SIZE(in2r_pga)), |
| 691 | |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 692 | SND_SOC_DAPM_MIXER("MIXINL", WM8993_POWER_MANAGEMENT_2, 9, 0, |
| 693 | mixinl, ARRAY_SIZE(mixinl)), |
| 694 | SND_SOC_DAPM_MIXER("MIXINR", WM8993_POWER_MANAGEMENT_2, 8, 0, |
| 695 | mixinr, ARRAY_SIZE(mixinr)), |
| 696 | |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 697 | SND_SOC_DAPM_MIXER("Left Output Mixer", WM8993_POWER_MANAGEMENT_3, 5, 0, |
| 698 | left_output_mixer, ARRAY_SIZE(left_output_mixer)), |
| 699 | SND_SOC_DAPM_MIXER("Right Output Mixer", WM8993_POWER_MANAGEMENT_3, 4, 0, |
| 700 | right_output_mixer, ARRAY_SIZE(right_output_mixer)), |
| 701 | |
| 702 | SND_SOC_DAPM_PGA("Left Output PGA", WM8993_POWER_MANAGEMENT_3, 7, 0, NULL, 0), |
| 703 | SND_SOC_DAPM_PGA("Right Output PGA", WM8993_POWER_MANAGEMENT_3, 6, 0, NULL, 0), |
| 704 | |
Mark Brown | 3ed7074 | 2010-01-20 17:39:45 +0000 | [diff] [blame] | 705 | SND_SOC_DAPM_SUPPLY("Headphone Supply", SND_SOC_NOPM, 0, 0, hp_supply_event, |
| 706 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD), |
Mark Brown | 2642262 | 2012-02-21 09:36:49 +0000 | [diff] [blame] | 707 | SND_SOC_DAPM_OUT_DRV_E("Headphone PGA", SND_SOC_NOPM, 0, 0, NULL, 0, |
| 708 | hp_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 709 | |
| 710 | SND_SOC_DAPM_MIXER("Earpiece Mixer", SND_SOC_NOPM, 0, 0, |
| 711 | earpiece_mixer, ARRAY_SIZE(earpiece_mixer)), |
| 712 | SND_SOC_DAPM_PGA_E("Earpiece Driver", WM8993_POWER_MANAGEMENT_1, 11, 0, |
| 713 | NULL, 0, earpiece_event, |
| 714 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), |
| 715 | |
| 716 | SND_SOC_DAPM_MIXER("SPKL Boost", SND_SOC_NOPM, 0, 0, |
| 717 | left_speaker_boost, ARRAY_SIZE(left_speaker_boost)), |
| 718 | SND_SOC_DAPM_MIXER("SPKR Boost", SND_SOC_NOPM, 0, 0, |
| 719 | right_speaker_boost, ARRAY_SIZE(right_speaker_boost)), |
| 720 | |
Mark Brown | 0343197 | 2011-11-04 17:11:54 +0000 | [diff] [blame] | 721 | SND_SOC_DAPM_SUPPLY("TSHUT", WM8993_POWER_MANAGEMENT_2, 14, 0, NULL, 0), |
Mark Brown | dc9c745 | 2012-02-07 14:24:57 +0000 | [diff] [blame] | 722 | SND_SOC_DAPM_OUT_DRV("SPKL Driver", WM8993_POWER_MANAGEMENT_1, 12, 0, |
| 723 | NULL, 0), |
| 724 | SND_SOC_DAPM_OUT_DRV("SPKR Driver", WM8993_POWER_MANAGEMENT_1, 13, 0, |
| 725 | NULL, 0), |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 726 | |
| 727 | SND_SOC_DAPM_MIXER("LINEOUT1 Mixer", SND_SOC_NOPM, 0, 0, |
| 728 | line1_mix, ARRAY_SIZE(line1_mix)), |
| 729 | SND_SOC_DAPM_MIXER("LINEOUT2 Mixer", SND_SOC_NOPM, 0, 0, |
| 730 | line2_mix, ARRAY_SIZE(line2_mix)), |
| 731 | |
| 732 | SND_SOC_DAPM_MIXER("LINEOUT1N Mixer", SND_SOC_NOPM, 0, 0, |
| 733 | line1n_mix, ARRAY_SIZE(line1n_mix)), |
| 734 | SND_SOC_DAPM_MIXER("LINEOUT1P Mixer", SND_SOC_NOPM, 0, 0, |
| 735 | line1p_mix, ARRAY_SIZE(line1p_mix)), |
| 736 | SND_SOC_DAPM_MIXER("LINEOUT2N Mixer", SND_SOC_NOPM, 0, 0, |
| 737 | line2n_mix, ARRAY_SIZE(line2n_mix)), |
| 738 | SND_SOC_DAPM_MIXER("LINEOUT2P Mixer", SND_SOC_NOPM, 0, 0, |
| 739 | line2p_mix, ARRAY_SIZE(line2p_mix)), |
| 740 | |
Mark Brown | 5f2f389 | 2012-02-08 18:51:42 +0000 | [diff] [blame] | 741 | SND_SOC_DAPM_OUT_DRV_E("LINEOUT1N Driver", WM8993_POWER_MANAGEMENT_3, 13, 0, |
| 742 | NULL, 0, lineout_event, |
| 743 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), |
| 744 | SND_SOC_DAPM_OUT_DRV_E("LINEOUT1P Driver", WM8993_POWER_MANAGEMENT_3, 12, 0, |
| 745 | NULL, 0, lineout_event, |
| 746 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), |
| 747 | SND_SOC_DAPM_OUT_DRV_E("LINEOUT2N Driver", WM8993_POWER_MANAGEMENT_3, 11, 0, |
| 748 | NULL, 0, lineout_event, |
| 749 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), |
| 750 | SND_SOC_DAPM_OUT_DRV_E("LINEOUT2P Driver", WM8993_POWER_MANAGEMENT_3, 10, 0, |
| 751 | NULL, 0, lineout_event, |
| 752 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 753 | |
| 754 | SND_SOC_DAPM_OUTPUT("SPKOUTLP"), |
| 755 | SND_SOC_DAPM_OUTPUT("SPKOUTLN"), |
| 756 | SND_SOC_DAPM_OUTPUT("SPKOUTRP"), |
| 757 | SND_SOC_DAPM_OUTPUT("SPKOUTRN"), |
| 758 | SND_SOC_DAPM_OUTPUT("HPOUT1L"), |
| 759 | SND_SOC_DAPM_OUTPUT("HPOUT1R"), |
| 760 | SND_SOC_DAPM_OUTPUT("HPOUT2P"), |
| 761 | SND_SOC_DAPM_OUTPUT("HPOUT2N"), |
| 762 | SND_SOC_DAPM_OUTPUT("LINEOUT1P"), |
| 763 | SND_SOC_DAPM_OUTPUT("LINEOUT1N"), |
| 764 | SND_SOC_DAPM_OUTPUT("LINEOUT2P"), |
| 765 | SND_SOC_DAPM_OUTPUT("LINEOUT2N"), |
| 766 | }; |
| 767 | |
| 768 | static const struct snd_soc_dapm_route analogue_routes[] = { |
Mark Brown | 4baafdd | 2011-02-18 15:05:53 -0800 | [diff] [blame] | 769 | { "MICBIAS1", NULL, "CLK_SYS" }, |
| 770 | { "MICBIAS2", NULL, "CLK_SYS" }, |
| 771 | |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 772 | { "IN1L PGA", "IN1LP Switch", "IN1LP" }, |
| 773 | { "IN1L PGA", "IN1LN Switch", "IN1LN" }, |
| 774 | |
Mark Brown | 4e04ada | 2011-07-15 15:12:31 +0900 | [diff] [blame] | 775 | { "IN1L PGA", NULL, "VMID" }, |
| 776 | { "IN1R PGA", NULL, "VMID" }, |
| 777 | { "IN2L PGA", NULL, "VMID" }, |
| 778 | { "IN2R PGA", NULL, "VMID" }, |
| 779 | |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 780 | { "IN1R PGA", "IN1RP Switch", "IN1RP" }, |
| 781 | { "IN1R PGA", "IN1RN Switch", "IN1RN" }, |
| 782 | |
Joonyoung Shim | 3482594 | 2009-12-04 15:12:10 +0900 | [diff] [blame] | 783 | { "IN2L PGA", "IN2LP Switch", "IN2LP:VXRN" }, |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 784 | { "IN2L PGA", "IN2LN Switch", "IN2LN" }, |
| 785 | |
Joonyoung Shim | 3482594 | 2009-12-04 15:12:10 +0900 | [diff] [blame] | 786 | { "IN2R PGA", "IN2RP Switch", "IN2RP:VXRP" }, |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 787 | { "IN2R PGA", "IN2RN Switch", "IN2RN" }, |
| 788 | |
Joonyoung Shim | 3482594 | 2009-12-04 15:12:10 +0900 | [diff] [blame] | 789 | { "Direct Voice", NULL, "IN2LP:VXRN" }, |
| 790 | { "Direct Voice", NULL, "IN2RP:VXRP" }, |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 791 | |
| 792 | { "MIXINL", "IN1L Switch", "IN1L PGA" }, |
| 793 | { "MIXINL", "IN2L Switch", "IN2L PGA" }, |
| 794 | { "MIXINL", NULL, "Direct Voice" }, |
| 795 | { "MIXINL", NULL, "IN1LP" }, |
| 796 | { "MIXINL", NULL, "Left Output Mixer" }, |
Mark Brown | 4e04ada | 2011-07-15 15:12:31 +0900 | [diff] [blame] | 797 | { "MIXINL", NULL, "VMID" }, |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 798 | |
| 799 | { "MIXINR", "IN1R Switch", "IN1R PGA" }, |
| 800 | { "MIXINR", "IN2R Switch", "IN2R PGA" }, |
| 801 | { "MIXINR", NULL, "Direct Voice" }, |
| 802 | { "MIXINR", NULL, "IN1RP" }, |
| 803 | { "MIXINR", NULL, "Right Output Mixer" }, |
Mark Brown | 4e04ada | 2011-07-15 15:12:31 +0900 | [diff] [blame] | 804 | { "MIXINR", NULL, "VMID" }, |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 805 | |
| 806 | { "ADCL", NULL, "MIXINL" }, |
| 807 | { "ADCR", NULL, "MIXINR" }, |
| 808 | |
| 809 | { "Left Output Mixer", "Left Input Switch", "MIXINL" }, |
| 810 | { "Left Output Mixer", "Right Input Switch", "MIXINR" }, |
| 811 | { "Left Output Mixer", "IN2RN Switch", "IN2RN" }, |
| 812 | { "Left Output Mixer", "IN2LN Switch", "IN2LN" }, |
Joonyoung Shim | 3482594 | 2009-12-04 15:12:10 +0900 | [diff] [blame] | 813 | { "Left Output Mixer", "IN2LP Switch", "IN2LP:VXRN" }, |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 814 | { "Left Output Mixer", "IN1L Switch", "IN1L PGA" }, |
| 815 | { "Left Output Mixer", "IN1R Switch", "IN1R PGA" }, |
| 816 | |
| 817 | { "Right Output Mixer", "Left Input Switch", "MIXINL" }, |
| 818 | { "Right Output Mixer", "Right Input Switch", "MIXINR" }, |
| 819 | { "Right Output Mixer", "IN2LN Switch", "IN2LN" }, |
| 820 | { "Right Output Mixer", "IN2RN Switch", "IN2RN" }, |
Joonyoung Shim | 3482594 | 2009-12-04 15:12:10 +0900 | [diff] [blame] | 821 | { "Right Output Mixer", "IN2RP Switch", "IN2RP:VXRP" }, |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 822 | { "Right Output Mixer", "IN1L Switch", "IN1L PGA" }, |
| 823 | { "Right Output Mixer", "IN1R Switch", "IN1R PGA" }, |
| 824 | |
| 825 | { "Left Output PGA", NULL, "Left Output Mixer" }, |
| 826 | { "Left Output PGA", NULL, "TOCLK" }, |
| 827 | |
| 828 | { "Right Output PGA", NULL, "Right Output Mixer" }, |
| 829 | { "Right Output PGA", NULL, "TOCLK" }, |
| 830 | |
| 831 | { "Earpiece Mixer", "Direct Voice Switch", "Direct Voice" }, |
| 832 | { "Earpiece Mixer", "Left Output Switch", "Left Output PGA" }, |
| 833 | { "Earpiece Mixer", "Right Output Switch", "Right Output PGA" }, |
| 834 | |
Mark Brown | 4e04ada | 2011-07-15 15:12:31 +0900 | [diff] [blame] | 835 | { "Earpiece Driver", NULL, "VMID" }, |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 836 | { "Earpiece Driver", NULL, "Earpiece Mixer" }, |
| 837 | { "HPOUT2N", NULL, "Earpiece Driver" }, |
| 838 | { "HPOUT2P", NULL, "Earpiece Driver" }, |
| 839 | |
| 840 | { "SPKL", "Input Switch", "MIXINL" }, |
| 841 | { "SPKL", "IN1LP Switch", "IN1LP" }, |
Mark Brown | 39cca16 | 2011-04-08 16:32:16 +0900 | [diff] [blame] | 842 | { "SPKL", "Output Switch", "Left Output PGA" }, |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 843 | { "SPKL", NULL, "TOCLK" }, |
| 844 | |
| 845 | { "SPKR", "Input Switch", "MIXINR" }, |
| 846 | { "SPKR", "IN1RP Switch", "IN1RP" }, |
Mark Brown | 39cca16 | 2011-04-08 16:32:16 +0900 | [diff] [blame] | 847 | { "SPKR", "Output Switch", "Right Output PGA" }, |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 848 | { "SPKR", NULL, "TOCLK" }, |
| 849 | |
| 850 | { "SPKL Boost", "Direct Voice Switch", "Direct Voice" }, |
| 851 | { "SPKL Boost", "SPKL Switch", "SPKL" }, |
| 852 | { "SPKL Boost", "SPKR Switch", "SPKR" }, |
| 853 | |
| 854 | { "SPKR Boost", "Direct Voice Switch", "Direct Voice" }, |
| 855 | { "SPKR Boost", "SPKR Switch", "SPKR" }, |
| 856 | { "SPKR Boost", "SPKL Switch", "SPKL" }, |
| 857 | |
Mark Brown | 4e04ada | 2011-07-15 15:12:31 +0900 | [diff] [blame] | 858 | { "SPKL Driver", NULL, "VMID" }, |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 859 | { "SPKL Driver", NULL, "SPKL Boost" }, |
| 860 | { "SPKL Driver", NULL, "CLK_SYS" }, |
Mark Brown | 0343197 | 2011-11-04 17:11:54 +0000 | [diff] [blame] | 861 | { "SPKL Driver", NULL, "TSHUT" }, |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 862 | |
Mark Brown | 4e04ada | 2011-07-15 15:12:31 +0900 | [diff] [blame] | 863 | { "SPKR Driver", NULL, "VMID" }, |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 864 | { "SPKR Driver", NULL, "SPKR Boost" }, |
| 865 | { "SPKR Driver", NULL, "CLK_SYS" }, |
Mark Brown | 0343197 | 2011-11-04 17:11:54 +0000 | [diff] [blame] | 866 | { "SPKR Driver", NULL, "TSHUT" }, |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 867 | |
| 868 | { "SPKOUTLP", NULL, "SPKL Driver" }, |
| 869 | { "SPKOUTLN", NULL, "SPKL Driver" }, |
| 870 | { "SPKOUTRP", NULL, "SPKR Driver" }, |
| 871 | { "SPKOUTRN", NULL, "SPKR Driver" }, |
| 872 | |
Mark Brown | 39cca16 | 2011-04-08 16:32:16 +0900 | [diff] [blame] | 873 | { "Left Headphone Mux", "Mixer", "Left Output PGA" }, |
| 874 | { "Right Headphone Mux", "Mixer", "Right Output PGA" }, |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 875 | |
| 876 | { "Headphone PGA", NULL, "Left Headphone Mux" }, |
| 877 | { "Headphone PGA", NULL, "Right Headphone Mux" }, |
Mark Brown | 4e04ada | 2011-07-15 15:12:31 +0900 | [diff] [blame] | 878 | { "Headphone PGA", NULL, "VMID" }, |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 879 | { "Headphone PGA", NULL, "CLK_SYS" }, |
Mark Brown | 3ed7074 | 2010-01-20 17:39:45 +0000 | [diff] [blame] | 880 | { "Headphone PGA", NULL, "Headphone Supply" }, |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 881 | |
| 882 | { "HPOUT1L", NULL, "Headphone PGA" }, |
| 883 | { "HPOUT1R", NULL, "Headphone PGA" }, |
| 884 | |
Mark Brown | 4e04ada | 2011-07-15 15:12:31 +0900 | [diff] [blame] | 885 | { "LINEOUT1N Driver", NULL, "VMID" }, |
| 886 | { "LINEOUT1P Driver", NULL, "VMID" }, |
| 887 | { "LINEOUT2N Driver", NULL, "VMID" }, |
| 888 | { "LINEOUT2P Driver", NULL, "VMID" }, |
| 889 | |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 890 | { "LINEOUT1N", NULL, "LINEOUT1N Driver" }, |
| 891 | { "LINEOUT1P", NULL, "LINEOUT1P Driver" }, |
| 892 | { "LINEOUT2N", NULL, "LINEOUT2N Driver" }, |
| 893 | { "LINEOUT2P", NULL, "LINEOUT2P Driver" }, |
| 894 | }; |
| 895 | |
| 896 | static const struct snd_soc_dapm_route lineout1_diff_routes[] = { |
| 897 | { "LINEOUT1 Mixer", "IN1L Switch", "IN1L PGA" }, |
| 898 | { "LINEOUT1 Mixer", "IN1R Switch", "IN1R PGA" }, |
Mark Brown | d0b48af | 2011-05-14 17:21:28 -0700 | [diff] [blame] | 899 | { "LINEOUT1 Mixer", "Output Switch", "Left Output PGA" }, |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 900 | |
| 901 | { "LINEOUT1N Driver", NULL, "LINEOUT1 Mixer" }, |
| 902 | { "LINEOUT1P Driver", NULL, "LINEOUT1 Mixer" }, |
| 903 | }; |
| 904 | |
| 905 | static const struct snd_soc_dapm_route lineout1_se_routes[] = { |
Mark Brown | d0b48af | 2011-05-14 17:21:28 -0700 | [diff] [blame] | 906 | { "LINEOUT1N Mixer", "Left Output Switch", "Left Output PGA" }, |
| 907 | { "LINEOUT1N Mixer", "Right Output Switch", "Right Output PGA" }, |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 908 | |
Mark Brown | d0b48af | 2011-05-14 17:21:28 -0700 | [diff] [blame] | 909 | { "LINEOUT1P Mixer", "Left Output Switch", "Left Output PGA" }, |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 910 | |
| 911 | { "LINEOUT1N Driver", NULL, "LINEOUT1N Mixer" }, |
| 912 | { "LINEOUT1P Driver", NULL, "LINEOUT1P Mixer" }, |
| 913 | }; |
| 914 | |
| 915 | static const struct snd_soc_dapm_route lineout2_diff_routes[] = { |
Mark Brown | ee76744 | 2012-01-31 11:55:32 +0000 | [diff] [blame] | 916 | { "LINEOUT2 Mixer", "IN1L Switch", "IN1L PGA" }, |
| 917 | { "LINEOUT2 Mixer", "IN1R Switch", "IN1R PGA" }, |
Mark Brown | d0b48af | 2011-05-14 17:21:28 -0700 | [diff] [blame] | 918 | { "LINEOUT2 Mixer", "Output Switch", "Right Output PGA" }, |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 919 | |
| 920 | { "LINEOUT2N Driver", NULL, "LINEOUT2 Mixer" }, |
| 921 | { "LINEOUT2P Driver", NULL, "LINEOUT2 Mixer" }, |
| 922 | }; |
| 923 | |
| 924 | static const struct snd_soc_dapm_route lineout2_se_routes[] = { |
Mark Brown | d0b48af | 2011-05-14 17:21:28 -0700 | [diff] [blame] | 925 | { "LINEOUT2N Mixer", "Left Output Switch", "Left Output PGA" }, |
| 926 | { "LINEOUT2N Mixer", "Right Output Switch", "Right Output PGA" }, |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 927 | |
Mark Brown | d0b48af | 2011-05-14 17:21:28 -0700 | [diff] [blame] | 928 | { "LINEOUT2P Mixer", "Right Output Switch", "Right Output PGA" }, |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 929 | |
| 930 | { "LINEOUT2N Driver", NULL, "LINEOUT2N Mixer" }, |
| 931 | { "LINEOUT2P Driver", NULL, "LINEOUT2P Mixer" }, |
| 932 | }; |
| 933 | |
| 934 | int wm_hubs_add_analogue_controls(struct snd_soc_codec *codec) |
| 935 | { |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 936 | struct snd_soc_dapm_context *dapm = &codec->dapm; |
| 937 | |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 938 | /* Latch volume update bits & default ZC on */ |
| 939 | snd_soc_update_bits(codec, WM8993_LEFT_LINE_INPUT_1_2_VOLUME, |
| 940 | WM8993_IN1_VU, WM8993_IN1_VU); |
| 941 | snd_soc_update_bits(codec, WM8993_RIGHT_LINE_INPUT_1_2_VOLUME, |
| 942 | WM8993_IN1_VU, WM8993_IN1_VU); |
| 943 | snd_soc_update_bits(codec, WM8993_LEFT_LINE_INPUT_3_4_VOLUME, |
| 944 | WM8993_IN2_VU, WM8993_IN2_VU); |
| 945 | snd_soc_update_bits(codec, WM8993_RIGHT_LINE_INPUT_3_4_VOLUME, |
| 946 | WM8993_IN2_VU, WM8993_IN2_VU); |
| 947 | |
Mark Brown | fb5af53 | 2011-05-15 12:18:38 -0700 | [diff] [blame] | 948 | snd_soc_update_bits(codec, WM8993_SPEAKER_VOLUME_LEFT, |
| 949 | WM8993_SPKOUT_VU, WM8993_SPKOUT_VU); |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 950 | snd_soc_update_bits(codec, WM8993_SPEAKER_VOLUME_RIGHT, |
| 951 | WM8993_SPKOUT_VU, WM8993_SPKOUT_VU); |
| 952 | |
| 953 | snd_soc_update_bits(codec, WM8993_LEFT_OUTPUT_VOLUME, |
Mark Brown | fb5af53 | 2011-05-15 12:18:38 -0700 | [diff] [blame] | 954 | WM8993_HPOUT1_VU | WM8993_HPOUT1L_ZC, |
| 955 | WM8993_HPOUT1_VU | WM8993_HPOUT1L_ZC); |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 956 | snd_soc_update_bits(codec, WM8993_RIGHT_OUTPUT_VOLUME, |
| 957 | WM8993_HPOUT1_VU | WM8993_HPOUT1R_ZC, |
| 958 | WM8993_HPOUT1_VU | WM8993_HPOUT1R_ZC); |
| 959 | |
| 960 | snd_soc_update_bits(codec, WM8993_LEFT_OPGA_VOLUME, |
Mark Brown | fb5af53 | 2011-05-15 12:18:38 -0700 | [diff] [blame] | 961 | WM8993_MIXOUTL_ZC | WM8993_MIXOUT_VU, |
| 962 | WM8993_MIXOUTL_ZC | WM8993_MIXOUT_VU); |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 963 | snd_soc_update_bits(codec, WM8993_RIGHT_OPGA_VOLUME, |
| 964 | WM8993_MIXOUTR_ZC | WM8993_MIXOUT_VU, |
| 965 | WM8993_MIXOUTR_ZC | WM8993_MIXOUT_VU); |
| 966 | |
Liam Girdwood | 022658b | 2012-02-03 17:43:09 +0000 | [diff] [blame] | 967 | snd_soc_add_codec_controls(codec, analogue_snd_controls, |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 968 | ARRAY_SIZE(analogue_snd_controls)); |
| 969 | |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 970 | snd_soc_dapm_new_controls(dapm, analogue_dapm_widgets, |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 971 | ARRAY_SIZE(analogue_dapm_widgets)); |
| 972 | return 0; |
| 973 | } |
| 974 | EXPORT_SYMBOL_GPL(wm_hubs_add_analogue_controls); |
| 975 | |
| 976 | int wm_hubs_add_analogue_routes(struct snd_soc_codec *codec, |
| 977 | int lineout1_diff, int lineout2_diff) |
| 978 | { |
Mark Brown | d96ca3c | 2011-07-12 15:25:03 +0900 | [diff] [blame] | 979 | struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 980 | struct snd_soc_dapm_context *dapm = &codec->dapm; |
| 981 | |
Mark Brown | d96ca3c | 2011-07-12 15:25:03 +0900 | [diff] [blame] | 982 | init_completion(&hubs->dcs_done); |
| 983 | |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 984 | snd_soc_dapm_add_routes(dapm, analogue_routes, |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 985 | ARRAY_SIZE(analogue_routes)); |
| 986 | |
| 987 | if (lineout1_diff) |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 988 | snd_soc_dapm_add_routes(dapm, |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 989 | lineout1_diff_routes, |
| 990 | ARRAY_SIZE(lineout1_diff_routes)); |
| 991 | else |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 992 | snd_soc_dapm_add_routes(dapm, |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 993 | lineout1_se_routes, |
| 994 | ARRAY_SIZE(lineout1_se_routes)); |
| 995 | |
| 996 | if (lineout2_diff) |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 997 | snd_soc_dapm_add_routes(dapm, |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 998 | lineout2_diff_routes, |
| 999 | ARRAY_SIZE(lineout2_diff_routes)); |
| 1000 | else |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 1001 | snd_soc_dapm_add_routes(dapm, |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 1002 | lineout2_se_routes, |
| 1003 | ARRAY_SIZE(lineout2_se_routes)); |
| 1004 | |
| 1005 | return 0; |
| 1006 | } |
| 1007 | EXPORT_SYMBOL_GPL(wm_hubs_add_analogue_routes); |
| 1008 | |
Mark Brown | aa983d9 | 2009-09-30 14:16:11 +0100 | [diff] [blame] | 1009 | int wm_hubs_handle_analogue_pdata(struct snd_soc_codec *codec, |
| 1010 | int lineout1_diff, int lineout2_diff, |
| 1011 | int lineout1fb, int lineout2fb, |
| 1012 | int jd_scthr, int jd_thr, int micbias1_lvl, |
| 1013 | int micbias2_lvl) |
| 1014 | { |
Mark Brown | 5f2f389 | 2012-02-08 18:51:42 +0000 | [diff] [blame] | 1015 | struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); |
| 1016 | |
| 1017 | hubs->lineout1_se = !lineout1_diff; |
| 1018 | hubs->lineout2_se = !lineout2_diff; |
| 1019 | |
Mark Brown | aa983d9 | 2009-09-30 14:16:11 +0100 | [diff] [blame] | 1020 | if (!lineout1_diff) |
| 1021 | snd_soc_update_bits(codec, WM8993_LINE_MIXER1, |
| 1022 | WM8993_LINEOUT1_MODE, |
| 1023 | WM8993_LINEOUT1_MODE); |
| 1024 | if (!lineout2_diff) |
| 1025 | snd_soc_update_bits(codec, WM8993_LINE_MIXER2, |
| 1026 | WM8993_LINEOUT2_MODE, |
| 1027 | WM8993_LINEOUT2_MODE); |
| 1028 | |
Mark Brown | 5472bbc | 2012-03-19 17:31:56 +0000 | [diff] [blame] | 1029 | if (!lineout1_diff && !lineout2_diff) |
| 1030 | snd_soc_update_bits(codec, WM8993_ANTIPOP1, |
| 1031 | WM8993_LINEOUT_VMID_BUF_ENA, |
| 1032 | WM8993_LINEOUT_VMID_BUF_ENA); |
| 1033 | |
Mark Brown | aa983d9 | 2009-09-30 14:16:11 +0100 | [diff] [blame] | 1034 | if (lineout1fb) |
| 1035 | snd_soc_update_bits(codec, WM8993_ADDITIONAL_CONTROL, |
| 1036 | WM8993_LINEOUT1_FB, WM8993_LINEOUT1_FB); |
| 1037 | |
| 1038 | if (lineout2fb) |
| 1039 | snd_soc_update_bits(codec, WM8993_ADDITIONAL_CONTROL, |
| 1040 | WM8993_LINEOUT2_FB, WM8993_LINEOUT2_FB); |
| 1041 | |
| 1042 | snd_soc_update_bits(codec, WM8993_MICBIAS, |
| 1043 | WM8993_JD_SCTHR_MASK | WM8993_JD_THR_MASK | |
| 1044 | WM8993_MICB1_LVL | WM8993_MICB2_LVL, |
| 1045 | jd_scthr << WM8993_JD_SCTHR_SHIFT | |
| 1046 | jd_thr << WM8993_JD_THR_SHIFT | |
| 1047 | micbias1_lvl | |
| 1048 | micbias2_lvl << WM8993_MICB2_LVL_SHIFT); |
| 1049 | |
| 1050 | return 0; |
| 1051 | } |
| 1052 | EXPORT_SYMBOL_GPL(wm_hubs_handle_analogue_pdata); |
| 1053 | |
Mark Brown | 5f2f389 | 2012-02-08 18:51:42 +0000 | [diff] [blame] | 1054 | void wm_hubs_vmid_ena(struct snd_soc_codec *codec) |
| 1055 | { |
| 1056 | struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); |
| 1057 | int val = 0; |
| 1058 | |
| 1059 | if (hubs->lineout1_se) |
| 1060 | val |= WM8993_LINEOUT1N_ENA | WM8993_LINEOUT1P_ENA; |
| 1061 | |
| 1062 | if (hubs->lineout2_se) |
| 1063 | val |= WM8993_LINEOUT2N_ENA | WM8993_LINEOUT2P_ENA; |
| 1064 | |
| 1065 | /* Enable the line outputs while we power up */ |
| 1066 | snd_soc_update_bits(codec, WM8993_POWER_MANAGEMENT_3, val, val); |
| 1067 | } |
| 1068 | EXPORT_SYMBOL_GPL(wm_hubs_vmid_ena); |
| 1069 | |
| 1070 | void wm_hubs_set_bias_level(struct snd_soc_codec *codec, |
| 1071 | enum snd_soc_bias_level level) |
| 1072 | { |
| 1073 | struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); |
| 1074 | int val; |
| 1075 | |
| 1076 | switch (level) { |
Mark Brown | d60d6c3 | 2012-02-10 18:09:42 +0000 | [diff] [blame] | 1077 | case SND_SOC_BIAS_STANDBY: |
| 1078 | /* Clamp the inputs to VMID while we ramp to charge caps */ |
| 1079 | snd_soc_update_bits(codec, WM8993_INPUTS_CLAMP_REG, |
| 1080 | WM8993_INPUTS_CLAMP, WM8993_INPUTS_CLAMP); |
| 1081 | break; |
| 1082 | |
Mark Brown | 5f2f389 | 2012-02-08 18:51:42 +0000 | [diff] [blame] | 1083 | case SND_SOC_BIAS_ON: |
| 1084 | /* Turn off any unneded single ended outputs */ |
| 1085 | val = 0; |
| 1086 | |
| 1087 | if (hubs->lineout1_se && hubs->lineout1n_ena) |
| 1088 | val |= WM8993_LINEOUT1N_ENA; |
| 1089 | |
| 1090 | if (hubs->lineout1_se && hubs->lineout1p_ena) |
| 1091 | val |= WM8993_LINEOUT1P_ENA; |
| 1092 | |
| 1093 | if (hubs->lineout2_se && hubs->lineout2n_ena) |
| 1094 | val |= WM8993_LINEOUT2N_ENA; |
| 1095 | |
| 1096 | if (hubs->lineout2_se && hubs->lineout2p_ena) |
| 1097 | val |= WM8993_LINEOUT2P_ENA; |
| 1098 | |
| 1099 | snd_soc_update_bits(codec, WM8993_POWER_MANAGEMENT_3, |
| 1100 | WM8993_LINEOUT1N_ENA | |
| 1101 | WM8993_LINEOUT1P_ENA | |
| 1102 | WM8993_LINEOUT2N_ENA | |
| 1103 | WM8993_LINEOUT2P_ENA, |
| 1104 | val); |
| 1105 | |
Mark Brown | d60d6c3 | 2012-02-10 18:09:42 +0000 | [diff] [blame] | 1106 | /* Remove the input clamps */ |
| 1107 | snd_soc_update_bits(codec, WM8993_INPUTS_CLAMP_REG, |
| 1108 | WM8993_INPUTS_CLAMP, 0); |
Mark Brown | 5f2f389 | 2012-02-08 18:51:42 +0000 | [diff] [blame] | 1109 | break; |
| 1110 | |
| 1111 | default: |
| 1112 | break; |
| 1113 | } |
| 1114 | } |
| 1115 | EXPORT_SYMBOL_GPL(wm_hubs_set_bias_level); |
| 1116 | |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 1117 | MODULE_DESCRIPTION("Shared support for Wolfson hubs products"); |
| 1118 | MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>"); |
| 1119 | MODULE_LICENSE("GPL"); |