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