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> |
| 20 | #include <linux/platform_device.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[] = { |
| 42 | TLV_DB_RANGE_HEAD(7), |
| 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 | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 112 | /* |
Mark Brown | 3ed7074 | 2010-01-20 17:39:45 +0000 | [diff] [blame] | 113 | * Startup calibration of the DC servo |
| 114 | */ |
| 115 | static void calibrate_dc_servo(struct snd_soc_codec *codec) |
| 116 | { |
Mark Brown | b2c812e | 2010-04-14 15:35:19 +0900 | [diff] [blame] | 117 | struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); |
Mark Brown | 20a4e7f | 2011-01-21 12:47:33 +0000 | [diff] [blame] | 118 | s8 offset; |
Mark Brown | 8437f70 | 2010-03-29 17:09:45 +0100 | [diff] [blame] | 119 | u16 reg, reg_l, reg_r, dcs_cfg; |
Mark Brown | 3ed7074 | 2010-01-20 17:39:45 +0000 | [diff] [blame] | 120 | |
Mark Brown | fec6dd8 | 2010-10-27 13:48:36 -0700 | [diff] [blame] | 121 | /* If we're using a digital only path and have a previously |
| 122 | * callibrated DC servo offset stored then use that. */ |
| 123 | if (hubs->class_w && hubs->class_w_dcs) { |
| 124 | dev_dbg(codec->dev, "Using cached DC servo offset %x\n", |
| 125 | hubs->class_w_dcs); |
| 126 | snd_soc_write(codec, WM8993_DC_SERVO_3, hubs->class_w_dcs); |
| 127 | wait_for_dc_servo(codec, |
| 128 | WM8993_DCS_TRIG_DAC_WR_0 | |
| 129 | WM8993_DCS_TRIG_DAC_WR_1); |
| 130 | return; |
| 131 | } |
| 132 | |
Mark Brown | f9acf9f | 2011-06-07 23:23:52 +0100 | [diff] [blame] | 133 | if (hubs->series_startup) { |
Mark Brown | 11cef5f | 2010-11-26 17:23:44 +0000 | [diff] [blame] | 134 | /* Set for 32 series updates */ |
| 135 | snd_soc_update_bits(codec, WM8993_DC_SERVO_1, |
| 136 | WM8993_DCS_SERIES_NO_01_MASK, |
| 137 | 32 << WM8993_DCS_SERIES_NO_01_SHIFT); |
| 138 | wait_for_dc_servo(codec, |
| 139 | WM8993_DCS_TRIG_SERIES_0 | |
| 140 | WM8993_DCS_TRIG_SERIES_1); |
| 141 | } else { |
| 142 | wait_for_dc_servo(codec, |
| 143 | WM8993_DCS_TRIG_STARTUP_0 | |
| 144 | WM8993_DCS_TRIG_STARTUP_1); |
| 145 | } |
Mark Brown | 3ed7074 | 2010-01-20 17:39:45 +0000 | [diff] [blame] | 146 | |
Mark Brown | fec6dd8 | 2010-10-27 13:48:36 -0700 | [diff] [blame] | 147 | /* Different chips in the family support different readback |
| 148 | * methods. |
| 149 | */ |
| 150 | switch (hubs->dcs_readback_mode) { |
| 151 | case 0: |
| 152 | reg_l = snd_soc_read(codec, WM8993_DC_SERVO_READBACK_1) |
Joe Perches | ef995e3 | 2010-11-15 09:09:17 -0800 | [diff] [blame] | 153 | & WM8993_DCS_INTEG_CHAN_0_MASK; |
Mark Brown | fec6dd8 | 2010-10-27 13:48:36 -0700 | [diff] [blame] | 154 | reg_r = snd_soc_read(codec, WM8993_DC_SERVO_READBACK_2) |
| 155 | & WM8993_DCS_INTEG_CHAN_1_MASK; |
| 156 | break; |
| 157 | case 1: |
| 158 | reg = snd_soc_read(codec, WM8993_DC_SERVO_3); |
Mark Brown | d5b040c | 2011-06-07 23:28:45 +0100 | [diff] [blame] | 159 | reg_r = (reg & WM8993_DCS_DAC_WR_VAL_1_MASK) |
Mark Brown | fec6dd8 | 2010-10-27 13:48:36 -0700 | [diff] [blame] | 160 | >> WM8993_DCS_DAC_WR_VAL_1_SHIFT; |
Mark Brown | d5b040c | 2011-06-07 23:28:45 +0100 | [diff] [blame] | 161 | reg_l = reg & WM8993_DCS_DAC_WR_VAL_0_MASK; |
Mark Brown | fec6dd8 | 2010-10-27 13:48:36 -0700 | [diff] [blame] | 162 | break; |
| 163 | default: |
Mark Brown | 9e3be1e | 2010-11-02 09:58:49 -0400 | [diff] [blame] | 164 | WARN(1, "Unknown DCS readback method\n"); |
Mark Brown | fec6dd8 | 2010-10-27 13:48:36 -0700 | [diff] [blame] | 165 | break; |
| 166 | } |
| 167 | |
| 168 | dev_dbg(codec->dev, "DCS input: %x %x\n", reg_l, reg_r); |
| 169 | |
Mark Brown | 3ed7074 | 2010-01-20 17:39:45 +0000 | [diff] [blame] | 170 | /* Apply correction to DC servo result */ |
| 171 | if (hubs->dcs_codes) { |
| 172 | dev_dbg(codec->dev, "Applying %d code DC servo correction\n", |
| 173 | hubs->dcs_codes); |
| 174 | |
Mark Brown | d5b040c | 2011-06-07 23:28:45 +0100 | [diff] [blame] | 175 | /* HPOUT1R */ |
| 176 | offset = reg_r; |
Mark Brown | 20a4e7f | 2011-01-21 12:47:33 +0000 | [diff] [blame] | 177 | offset += hubs->dcs_codes; |
| 178 | dcs_cfg = (u8)offset << WM8993_DCS_DAC_WR_VAL_1_SHIFT; |
Mark Brown | 3ed7074 | 2010-01-20 17:39:45 +0000 | [diff] [blame] | 179 | |
Mark Brown | d5b040c | 2011-06-07 23:28:45 +0100 | [diff] [blame] | 180 | /* HPOUT1L */ |
| 181 | offset = reg_l; |
Mark Brown | 20a4e7f | 2011-01-21 12:47:33 +0000 | [diff] [blame] | 182 | offset += hubs->dcs_codes; |
| 183 | dcs_cfg |= (u8)offset; |
Mark Brown | 3ed7074 | 2010-01-20 17:39:45 +0000 | [diff] [blame] | 184 | |
Mark Brown | 3254d28 | 2010-05-10 14:56:03 +0100 | [diff] [blame] | 185 | dev_dbg(codec->dev, "DCS result: %x\n", dcs_cfg); |
| 186 | |
Mark Brown | 3ed7074 | 2010-01-20 17:39:45 +0000 | [diff] [blame] | 187 | /* Do it */ |
| 188 | snd_soc_write(codec, WM8993_DC_SERVO_3, dcs_cfg); |
Mark Brown | 4dcc93d | 2010-03-29 17:18:41 +0100 | [diff] [blame] | 189 | wait_for_dc_servo(codec, |
| 190 | WM8993_DCS_TRIG_DAC_WR_0 | |
| 191 | WM8993_DCS_TRIG_DAC_WR_1); |
Mark Brown | fec6dd8 | 2010-10-27 13:48:36 -0700 | [diff] [blame] | 192 | } else { |
Mark Brown | d5b040c | 2011-06-07 23:28:45 +0100 | [diff] [blame] | 193 | dcs_cfg = reg_r << WM8993_DCS_DAC_WR_VAL_1_SHIFT; |
| 194 | dcs_cfg |= reg_l; |
Mark Brown | 3ed7074 | 2010-01-20 17:39:45 +0000 | [diff] [blame] | 195 | } |
Mark Brown | fec6dd8 | 2010-10-27 13:48:36 -0700 | [diff] [blame] | 196 | |
| 197 | /* Save the callibrated offset if we're in class W mode and |
| 198 | * therefore don't have any analogue signal mixed in. */ |
| 199 | if (hubs->class_w) |
| 200 | hubs->class_w_dcs = dcs_cfg; |
Mark Brown | 3ed7074 | 2010-01-20 17:39:45 +0000 | [diff] [blame] | 201 | } |
| 202 | |
| 203 | /* |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 204 | * Update the DC servo calibration on gain changes |
| 205 | */ |
| 206 | static int wm8993_put_dc_servo(struct snd_kcontrol *kcontrol, |
Mark Brown | 3ed7074 | 2010-01-20 17:39:45 +0000 | [diff] [blame] | 207 | struct snd_ctl_elem_value *ucontrol) |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 208 | { |
| 209 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
Mark Brown | b2c812e | 2010-04-14 15:35:19 +0900 | [diff] [blame] | 210 | struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 211 | int ret; |
| 212 | |
| 213 | ret = snd_soc_put_volsw_2r(kcontrol, ucontrol); |
| 214 | |
Mark Brown | fec6dd8 | 2010-10-27 13:48:36 -0700 | [diff] [blame] | 215 | /* Updating the analogue gains invalidates the DC servo cache */ |
| 216 | hubs->class_w_dcs = 0; |
| 217 | |
Mark Brown | ae9d860 | 2010-03-29 16:34:42 +0100 | [diff] [blame] | 218 | /* If we're applying an offset correction then updating the |
| 219 | * callibration would be likely to introduce further offsets. */ |
Mark Brown | 780b75b | 2011-06-07 23:32:46 +0100 | [diff] [blame] | 220 | if (hubs->dcs_codes || hubs->no_series_update) |
Mark Brown | ae9d860 | 2010-03-29 16:34:42 +0100 | [diff] [blame] | 221 | return ret; |
| 222 | |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 223 | /* Only need to do this if the outputs are active */ |
| 224 | if (snd_soc_read(codec, WM8993_POWER_MANAGEMENT_1) |
| 225 | & (WM8993_HPOUT1L_ENA | WM8993_HPOUT1R_ENA)) |
| 226 | snd_soc_update_bits(codec, |
| 227 | WM8993_DC_SERVO_0, |
| 228 | WM8993_DCS_TRIG_SINGLE_0 | |
| 229 | WM8993_DCS_TRIG_SINGLE_1, |
| 230 | WM8993_DCS_TRIG_SINGLE_0 | |
| 231 | WM8993_DCS_TRIG_SINGLE_1); |
| 232 | |
| 233 | return ret; |
| 234 | } |
| 235 | |
| 236 | static const struct snd_kcontrol_new analogue_snd_controls[] = { |
| 237 | SOC_SINGLE_TLV("IN1L Volume", WM8993_LEFT_LINE_INPUT_1_2_VOLUME, 0, 31, 0, |
| 238 | inpga_tlv), |
| 239 | 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] | 240 | 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] | 241 | |
| 242 | SOC_SINGLE_TLV("IN1R Volume", WM8993_RIGHT_LINE_INPUT_1_2_VOLUME, 0, 31, 0, |
| 243 | inpga_tlv), |
| 244 | 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] | 245 | 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] | 246 | |
| 247 | |
| 248 | SOC_SINGLE_TLV("IN2L Volume", WM8993_LEFT_LINE_INPUT_3_4_VOLUME, 0, 31, 0, |
| 249 | inpga_tlv), |
| 250 | 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] | 251 | 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] | 252 | |
| 253 | SOC_SINGLE_TLV("IN2R Volume", WM8993_RIGHT_LINE_INPUT_3_4_VOLUME, 0, 31, 0, |
| 254 | inpga_tlv), |
| 255 | 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] | 256 | 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] | 257 | |
| 258 | SOC_SINGLE_TLV("MIXINL IN2L Volume", WM8993_INPUT_MIXER3, 7, 1, 0, |
| 259 | inmix_sw_tlv), |
| 260 | SOC_SINGLE_TLV("MIXINL IN1L Volume", WM8993_INPUT_MIXER3, 4, 1, 0, |
| 261 | inmix_sw_tlv), |
| 262 | SOC_SINGLE_TLV("MIXINL Output Record Volume", WM8993_INPUT_MIXER3, 0, 7, 0, |
| 263 | inmix_tlv), |
| 264 | SOC_SINGLE_TLV("MIXINL IN1LP Volume", WM8993_INPUT_MIXER5, 6, 7, 0, inmix_tlv), |
| 265 | SOC_SINGLE_TLV("MIXINL Direct Voice Volume", WM8993_INPUT_MIXER5, 0, 6, 0, |
| 266 | inmix_tlv), |
| 267 | |
| 268 | SOC_SINGLE_TLV("MIXINR IN2R Volume", WM8993_INPUT_MIXER4, 7, 1, 0, |
| 269 | inmix_sw_tlv), |
| 270 | SOC_SINGLE_TLV("MIXINR IN1R Volume", WM8993_INPUT_MIXER4, 4, 1, 0, |
| 271 | inmix_sw_tlv), |
| 272 | SOC_SINGLE_TLV("MIXINR Output Record Volume", WM8993_INPUT_MIXER4, 0, 7, 0, |
| 273 | inmix_tlv), |
| 274 | SOC_SINGLE_TLV("MIXINR IN1RP Volume", WM8993_INPUT_MIXER6, 6, 7, 0, inmix_tlv), |
| 275 | SOC_SINGLE_TLV("MIXINR Direct Voice Volume", WM8993_INPUT_MIXER6, 0, 6, 0, |
| 276 | inmix_tlv), |
| 277 | |
| 278 | SOC_SINGLE_TLV("Left Output Mixer IN2RN Volume", WM8993_OUTPUT_MIXER5, 6, 7, 1, |
| 279 | outmix_tlv), |
| 280 | SOC_SINGLE_TLV("Left Output Mixer IN2LN Volume", WM8993_OUTPUT_MIXER3, 6, 7, 1, |
| 281 | outmix_tlv), |
| 282 | SOC_SINGLE_TLV("Left Output Mixer IN2LP Volume", WM8993_OUTPUT_MIXER3, 9, 7, 1, |
| 283 | outmix_tlv), |
| 284 | SOC_SINGLE_TLV("Left Output Mixer IN1L Volume", WM8993_OUTPUT_MIXER3, 0, 7, 1, |
| 285 | outmix_tlv), |
| 286 | SOC_SINGLE_TLV("Left Output Mixer IN1R Volume", WM8993_OUTPUT_MIXER3, 3, 7, 1, |
| 287 | outmix_tlv), |
| 288 | SOC_SINGLE_TLV("Left Output Mixer Right Input Volume", |
| 289 | WM8993_OUTPUT_MIXER5, 3, 7, 1, outmix_tlv), |
| 290 | SOC_SINGLE_TLV("Left Output Mixer Left Input Volume", |
| 291 | WM8993_OUTPUT_MIXER5, 0, 7, 1, outmix_tlv), |
| 292 | SOC_SINGLE_TLV("Left Output Mixer DAC Volume", WM8993_OUTPUT_MIXER5, 9, 7, 1, |
| 293 | outmix_tlv), |
| 294 | |
| 295 | SOC_SINGLE_TLV("Right Output Mixer IN2LN Volume", |
| 296 | WM8993_OUTPUT_MIXER6, 6, 7, 1, outmix_tlv), |
| 297 | SOC_SINGLE_TLV("Right Output Mixer IN2RN Volume", |
| 298 | WM8993_OUTPUT_MIXER4, 6, 7, 1, outmix_tlv), |
| 299 | SOC_SINGLE_TLV("Right Output Mixer IN1L Volume", |
| 300 | WM8993_OUTPUT_MIXER4, 3, 7, 1, outmix_tlv), |
| 301 | SOC_SINGLE_TLV("Right Output Mixer IN1R Volume", |
| 302 | WM8993_OUTPUT_MIXER4, 0, 7, 1, outmix_tlv), |
| 303 | SOC_SINGLE_TLV("Right Output Mixer IN2RP Volume", |
| 304 | WM8993_OUTPUT_MIXER4, 9, 7, 1, outmix_tlv), |
| 305 | SOC_SINGLE_TLV("Right Output Mixer Left Input Volume", |
| 306 | WM8993_OUTPUT_MIXER6, 3, 7, 1, outmix_tlv), |
| 307 | SOC_SINGLE_TLV("Right Output Mixer Right Input Volume", |
| 308 | WM8993_OUTPUT_MIXER6, 6, 7, 1, outmix_tlv), |
| 309 | SOC_SINGLE_TLV("Right Output Mixer DAC Volume", |
| 310 | WM8993_OUTPUT_MIXER6, 9, 7, 1, outmix_tlv), |
| 311 | |
| 312 | SOC_DOUBLE_R_TLV("Output Volume", WM8993_LEFT_OPGA_VOLUME, |
| 313 | WM8993_RIGHT_OPGA_VOLUME, 0, 63, 0, outpga_tlv), |
| 314 | SOC_DOUBLE_R("Output Switch", WM8993_LEFT_OPGA_VOLUME, |
| 315 | WM8993_RIGHT_OPGA_VOLUME, 6, 1, 0), |
| 316 | SOC_DOUBLE_R("Output ZC Switch", WM8993_LEFT_OPGA_VOLUME, |
| 317 | WM8993_RIGHT_OPGA_VOLUME, 7, 1, 0), |
| 318 | |
| 319 | SOC_SINGLE("Earpiece Switch", WM8993_HPOUT2_VOLUME, 5, 1, 1), |
| 320 | SOC_SINGLE_TLV("Earpiece Volume", WM8993_HPOUT2_VOLUME, 4, 1, 1, earpiece_tlv), |
| 321 | |
| 322 | SOC_SINGLE_TLV("SPKL Input Volume", WM8993_SPKMIXL_ATTENUATION, |
| 323 | 5, 1, 1, wm_hubs_spkmix_tlv), |
| 324 | SOC_SINGLE_TLV("SPKL IN1LP Volume", WM8993_SPKMIXL_ATTENUATION, |
| 325 | 4, 1, 1, wm_hubs_spkmix_tlv), |
| 326 | SOC_SINGLE_TLV("SPKL Output Volume", WM8993_SPKMIXL_ATTENUATION, |
| 327 | 3, 1, 1, wm_hubs_spkmix_tlv), |
| 328 | |
| 329 | SOC_SINGLE_TLV("SPKR Input Volume", WM8993_SPKMIXR_ATTENUATION, |
| 330 | 5, 1, 1, wm_hubs_spkmix_tlv), |
| 331 | SOC_SINGLE_TLV("SPKR IN1RP Volume", WM8993_SPKMIXR_ATTENUATION, |
| 332 | 4, 1, 1, wm_hubs_spkmix_tlv), |
| 333 | SOC_SINGLE_TLV("SPKR Output Volume", WM8993_SPKMIXR_ATTENUATION, |
| 334 | 3, 1, 1, wm_hubs_spkmix_tlv), |
| 335 | |
| 336 | SOC_DOUBLE_R_TLV("Speaker Mixer Volume", |
| 337 | WM8993_SPKMIXL_ATTENUATION, WM8993_SPKMIXR_ATTENUATION, |
| 338 | 0, 3, 1, spkmixout_tlv), |
| 339 | SOC_DOUBLE_R_TLV("Speaker Volume", |
| 340 | WM8993_SPEAKER_VOLUME_LEFT, WM8993_SPEAKER_VOLUME_RIGHT, |
| 341 | 0, 63, 0, outpga_tlv), |
| 342 | SOC_DOUBLE_R("Speaker Switch", |
| 343 | WM8993_SPEAKER_VOLUME_LEFT, WM8993_SPEAKER_VOLUME_RIGHT, |
| 344 | 6, 1, 0), |
| 345 | SOC_DOUBLE_R("Speaker ZC Switch", |
| 346 | WM8993_SPEAKER_VOLUME_LEFT, WM8993_SPEAKER_VOLUME_RIGHT, |
| 347 | 7, 1, 0), |
Uk Kim | ed8cc47 | 2010-12-05 17:26:07 +0900 | [diff] [blame] | 348 | 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] | 349 | spkboost_tlv), |
| 350 | SOC_ENUM("Speaker Reference", speaker_ref), |
| 351 | SOC_ENUM("Speaker Mode", speaker_mode), |
| 352 | |
| 353 | { |
| 354 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Headphone Volume", |
| 355 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | |
| 356 | SNDRV_CTL_ELEM_ACCESS_READWRITE, |
| 357 | .tlv.p = outpga_tlv, |
| 358 | .info = snd_soc_info_volsw_2r, |
| 359 | .get = snd_soc_get_volsw_2r, .put = wm8993_put_dc_servo, |
| 360 | .private_value = (unsigned long)&(struct soc_mixer_control) { |
| 361 | .reg = WM8993_LEFT_OUTPUT_VOLUME, |
| 362 | .rreg = WM8993_RIGHT_OUTPUT_VOLUME, |
| 363 | .shift = 0, .max = 63 |
| 364 | }, |
| 365 | }, |
| 366 | SOC_DOUBLE_R("Headphone Switch", WM8993_LEFT_OUTPUT_VOLUME, |
| 367 | WM8993_RIGHT_OUTPUT_VOLUME, 6, 1, 0), |
| 368 | SOC_DOUBLE_R("Headphone ZC Switch", WM8993_LEFT_OUTPUT_VOLUME, |
| 369 | WM8993_RIGHT_OUTPUT_VOLUME, 7, 1, 0), |
| 370 | |
| 371 | SOC_SINGLE("LINEOUT1N Switch", WM8993_LINE_OUTPUTS_VOLUME, 6, 1, 1), |
| 372 | SOC_SINGLE("LINEOUT1P Switch", WM8993_LINE_OUTPUTS_VOLUME, 5, 1, 1), |
| 373 | SOC_SINGLE_TLV("LINEOUT1 Volume", WM8993_LINE_OUTPUTS_VOLUME, 4, 1, 1, |
| 374 | line_tlv), |
| 375 | |
| 376 | SOC_SINGLE("LINEOUT2N Switch", WM8993_LINE_OUTPUTS_VOLUME, 2, 1, 1), |
| 377 | SOC_SINGLE("LINEOUT2P Switch", WM8993_LINE_OUTPUTS_VOLUME, 1, 1, 1), |
| 378 | SOC_SINGLE_TLV("LINEOUT2 Volume", WM8993_LINE_OUTPUTS_VOLUME, 0, 1, 1, |
| 379 | line_tlv), |
| 380 | }; |
| 381 | |
Mark Brown | 3ed7074 | 2010-01-20 17:39:45 +0000 | [diff] [blame] | 382 | static int hp_supply_event(struct snd_soc_dapm_widget *w, |
| 383 | struct snd_kcontrol *kcontrol, int event) |
| 384 | { |
| 385 | struct snd_soc_codec *codec = w->codec; |
Mark Brown | b2c812e | 2010-04-14 15:35:19 +0900 | [diff] [blame] | 386 | struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); |
Mark Brown | 3ed7074 | 2010-01-20 17:39:45 +0000 | [diff] [blame] | 387 | |
| 388 | switch (event) { |
| 389 | case SND_SOC_DAPM_PRE_PMU: |
| 390 | switch (hubs->hp_startup_mode) { |
| 391 | case 0: |
| 392 | break; |
| 393 | case 1: |
| 394 | /* Enable the headphone amp */ |
| 395 | snd_soc_update_bits(codec, WM8993_POWER_MANAGEMENT_1, |
| 396 | WM8993_HPOUT1L_ENA | |
| 397 | WM8993_HPOUT1R_ENA, |
| 398 | WM8993_HPOUT1L_ENA | |
| 399 | WM8993_HPOUT1R_ENA); |
| 400 | |
| 401 | /* Enable the second stage */ |
| 402 | snd_soc_update_bits(codec, WM8993_ANALOGUE_HP_0, |
| 403 | WM8993_HPOUT1L_DLY | |
| 404 | WM8993_HPOUT1R_DLY, |
| 405 | WM8993_HPOUT1L_DLY | |
| 406 | WM8993_HPOUT1R_DLY); |
| 407 | break; |
| 408 | default: |
| 409 | dev_err(codec->dev, "Unknown HP startup mode %d\n", |
| 410 | hubs->hp_startup_mode); |
| 411 | break; |
| 412 | } |
| 413 | |
| 414 | case SND_SOC_DAPM_PRE_PMD: |
| 415 | snd_soc_update_bits(codec, WM8993_CHARGE_PUMP_1, |
| 416 | WM8993_CP_ENA, 0); |
| 417 | break; |
| 418 | } |
| 419 | |
| 420 | return 0; |
| 421 | } |
| 422 | |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 423 | static int hp_event(struct snd_soc_dapm_widget *w, |
| 424 | struct snd_kcontrol *kcontrol, int event) |
| 425 | { |
| 426 | struct snd_soc_codec *codec = w->codec; |
| 427 | unsigned int reg = snd_soc_read(codec, WM8993_ANALOGUE_HP_0); |
| 428 | |
| 429 | switch (event) { |
| 430 | case SND_SOC_DAPM_POST_PMU: |
| 431 | snd_soc_update_bits(codec, WM8993_CHARGE_PUMP_1, |
| 432 | WM8993_CP_ENA, WM8993_CP_ENA); |
| 433 | |
| 434 | msleep(5); |
| 435 | |
| 436 | snd_soc_update_bits(codec, WM8993_POWER_MANAGEMENT_1, |
| 437 | WM8993_HPOUT1L_ENA | WM8993_HPOUT1R_ENA, |
| 438 | WM8993_HPOUT1L_ENA | WM8993_HPOUT1R_ENA); |
| 439 | |
| 440 | reg |= WM8993_HPOUT1L_DLY | WM8993_HPOUT1R_DLY; |
| 441 | snd_soc_write(codec, WM8993_ANALOGUE_HP_0, reg); |
| 442 | |
Mark Brown | 3ed7074 | 2010-01-20 17:39:45 +0000 | [diff] [blame] | 443 | /* Smallest supported update interval */ |
| 444 | snd_soc_update_bits(codec, WM8993_DC_SERVO_1, |
| 445 | WM8993_DCS_TIMER_PERIOD_01_MASK, 1); |
| 446 | |
| 447 | calibrate_dc_servo(codec); |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 448 | |
| 449 | reg |= WM8993_HPOUT1R_OUTP | WM8993_HPOUT1R_RMV_SHORT | |
| 450 | WM8993_HPOUT1L_OUTP | WM8993_HPOUT1L_RMV_SHORT; |
| 451 | snd_soc_write(codec, WM8993_ANALOGUE_HP_0, reg); |
| 452 | break; |
| 453 | |
| 454 | case SND_SOC_DAPM_PRE_PMD: |
Mark Brown | 3ed7074 | 2010-01-20 17:39:45 +0000 | [diff] [blame] | 455 | snd_soc_update_bits(codec, WM8993_ANALOGUE_HP_0, |
Mark Brown | 6adb26b | 2010-05-10 16:13:11 +0100 | [diff] [blame] | 456 | WM8993_HPOUT1L_OUTP | |
| 457 | WM8993_HPOUT1R_OUTP | |
Mark Brown | 3ed7074 | 2010-01-20 17:39:45 +0000 | [diff] [blame] | 458 | WM8993_HPOUT1L_RMV_SHORT | |
| 459 | WM8993_HPOUT1R_RMV_SHORT, 0); |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 460 | |
Mark Brown | 3ed7074 | 2010-01-20 17:39:45 +0000 | [diff] [blame] | 461 | snd_soc_update_bits(codec, WM8993_ANALOGUE_HP_0, |
Mark Brown | 6adb26b | 2010-05-10 16:13:11 +0100 | [diff] [blame] | 462 | WM8993_HPOUT1L_DLY | |
| 463 | WM8993_HPOUT1R_DLY, 0); |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 464 | |
Mark Brown | 395e4b7 | 2010-05-10 21:06:14 +0100 | [diff] [blame] | 465 | snd_soc_write(codec, WM8993_DC_SERVO_0, 0); |
| 466 | |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 467 | snd_soc_update_bits(codec, WM8993_POWER_MANAGEMENT_1, |
| 468 | WM8993_HPOUT1L_ENA | WM8993_HPOUT1R_ENA, |
| 469 | 0); |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 470 | break; |
| 471 | } |
| 472 | |
| 473 | return 0; |
| 474 | } |
| 475 | |
| 476 | static int earpiece_event(struct snd_soc_dapm_widget *w, |
| 477 | struct snd_kcontrol *control, int event) |
| 478 | { |
| 479 | struct snd_soc_codec *codec = w->codec; |
| 480 | u16 reg = snd_soc_read(codec, WM8993_ANTIPOP1) & ~WM8993_HPOUT2_IN_ENA; |
| 481 | |
| 482 | switch (event) { |
| 483 | case SND_SOC_DAPM_PRE_PMU: |
| 484 | reg |= WM8993_HPOUT2_IN_ENA; |
| 485 | snd_soc_write(codec, WM8993_ANTIPOP1, reg); |
| 486 | udelay(50); |
| 487 | break; |
| 488 | |
| 489 | case SND_SOC_DAPM_POST_PMD: |
| 490 | snd_soc_write(codec, WM8993_ANTIPOP1, reg); |
| 491 | break; |
| 492 | |
| 493 | default: |
| 494 | BUG(); |
| 495 | break; |
| 496 | } |
| 497 | |
| 498 | return 0; |
| 499 | } |
| 500 | |
| 501 | static const struct snd_kcontrol_new in1l_pga[] = { |
| 502 | SOC_DAPM_SINGLE("IN1LP Switch", WM8993_INPUT_MIXER2, 5, 1, 0), |
| 503 | SOC_DAPM_SINGLE("IN1LN Switch", WM8993_INPUT_MIXER2, 4, 1, 0), |
| 504 | }; |
| 505 | |
| 506 | static const struct snd_kcontrol_new in1r_pga[] = { |
| 507 | SOC_DAPM_SINGLE("IN1RP Switch", WM8993_INPUT_MIXER2, 1, 1, 0), |
| 508 | SOC_DAPM_SINGLE("IN1RN Switch", WM8993_INPUT_MIXER2, 0, 1, 0), |
| 509 | }; |
| 510 | |
| 511 | static const struct snd_kcontrol_new in2l_pga[] = { |
| 512 | SOC_DAPM_SINGLE("IN2LP Switch", WM8993_INPUT_MIXER2, 7, 1, 0), |
| 513 | SOC_DAPM_SINGLE("IN2LN Switch", WM8993_INPUT_MIXER2, 6, 1, 0), |
| 514 | }; |
| 515 | |
| 516 | static const struct snd_kcontrol_new in2r_pga[] = { |
| 517 | SOC_DAPM_SINGLE("IN2RP Switch", WM8993_INPUT_MIXER2, 3, 1, 0), |
| 518 | SOC_DAPM_SINGLE("IN2RN Switch", WM8993_INPUT_MIXER2, 2, 1, 0), |
| 519 | }; |
| 520 | |
| 521 | static const struct snd_kcontrol_new mixinl[] = { |
| 522 | SOC_DAPM_SINGLE("IN2L Switch", WM8993_INPUT_MIXER3, 8, 1, 0), |
| 523 | SOC_DAPM_SINGLE("IN1L Switch", WM8993_INPUT_MIXER3, 5, 1, 0), |
| 524 | }; |
| 525 | |
| 526 | static const struct snd_kcontrol_new mixinr[] = { |
| 527 | SOC_DAPM_SINGLE("IN2R Switch", WM8993_INPUT_MIXER4, 8, 1, 0), |
| 528 | SOC_DAPM_SINGLE("IN1R Switch", WM8993_INPUT_MIXER4, 5, 1, 0), |
| 529 | }; |
| 530 | |
| 531 | static const struct snd_kcontrol_new left_output_mixer[] = { |
| 532 | SOC_DAPM_SINGLE("Right Input Switch", WM8993_OUTPUT_MIXER1, 7, 1, 0), |
| 533 | SOC_DAPM_SINGLE("Left Input Switch", WM8993_OUTPUT_MIXER1, 6, 1, 0), |
| 534 | SOC_DAPM_SINGLE("IN2RN Switch", WM8993_OUTPUT_MIXER1, 5, 1, 0), |
| 535 | SOC_DAPM_SINGLE("IN2LN Switch", WM8993_OUTPUT_MIXER1, 4, 1, 0), |
| 536 | SOC_DAPM_SINGLE("IN2LP Switch", WM8993_OUTPUT_MIXER1, 1, 1, 0), |
| 537 | SOC_DAPM_SINGLE("IN1R Switch", WM8993_OUTPUT_MIXER1, 3, 1, 0), |
| 538 | SOC_DAPM_SINGLE("IN1L Switch", WM8993_OUTPUT_MIXER1, 2, 1, 0), |
| 539 | SOC_DAPM_SINGLE("DAC Switch", WM8993_OUTPUT_MIXER1, 0, 1, 0), |
| 540 | }; |
| 541 | |
| 542 | static const struct snd_kcontrol_new right_output_mixer[] = { |
| 543 | SOC_DAPM_SINGLE("Left Input Switch", WM8993_OUTPUT_MIXER2, 7, 1, 0), |
| 544 | SOC_DAPM_SINGLE("Right Input Switch", WM8993_OUTPUT_MIXER2, 6, 1, 0), |
| 545 | SOC_DAPM_SINGLE("IN2LN Switch", WM8993_OUTPUT_MIXER2, 5, 1, 0), |
| 546 | SOC_DAPM_SINGLE("IN2RN Switch", WM8993_OUTPUT_MIXER2, 4, 1, 0), |
| 547 | SOC_DAPM_SINGLE("IN1L Switch", WM8993_OUTPUT_MIXER2, 3, 1, 0), |
| 548 | SOC_DAPM_SINGLE("IN1R Switch", WM8993_OUTPUT_MIXER2, 2, 1, 0), |
| 549 | SOC_DAPM_SINGLE("IN2RP Switch", WM8993_OUTPUT_MIXER2, 1, 1, 0), |
| 550 | SOC_DAPM_SINGLE("DAC Switch", WM8993_OUTPUT_MIXER2, 0, 1, 0), |
| 551 | }; |
| 552 | |
| 553 | static const struct snd_kcontrol_new earpiece_mixer[] = { |
| 554 | SOC_DAPM_SINGLE("Direct Voice Switch", WM8993_HPOUT2_MIXER, 5, 1, 0), |
| 555 | SOC_DAPM_SINGLE("Left Output Switch", WM8993_HPOUT2_MIXER, 4, 1, 0), |
| 556 | SOC_DAPM_SINGLE("Right Output Switch", WM8993_HPOUT2_MIXER, 3, 1, 0), |
| 557 | }; |
| 558 | |
| 559 | static const struct snd_kcontrol_new left_speaker_boost[] = { |
| 560 | SOC_DAPM_SINGLE("Direct Voice Switch", WM8993_SPKOUT_MIXERS, 5, 1, 0), |
| 561 | SOC_DAPM_SINGLE("SPKL Switch", WM8993_SPKOUT_MIXERS, 4, 1, 0), |
| 562 | SOC_DAPM_SINGLE("SPKR Switch", WM8993_SPKOUT_MIXERS, 3, 1, 0), |
| 563 | }; |
| 564 | |
| 565 | static const struct snd_kcontrol_new right_speaker_boost[] = { |
| 566 | SOC_DAPM_SINGLE("Direct Voice Switch", WM8993_SPKOUT_MIXERS, 2, 1, 0), |
| 567 | SOC_DAPM_SINGLE("SPKL Switch", WM8993_SPKOUT_MIXERS, 1, 1, 0), |
| 568 | SOC_DAPM_SINGLE("SPKR Switch", WM8993_SPKOUT_MIXERS, 0, 1, 0), |
| 569 | }; |
| 570 | |
| 571 | static const struct snd_kcontrol_new line1_mix[] = { |
| 572 | SOC_DAPM_SINGLE("IN1R Switch", WM8993_LINE_MIXER1, 2, 1, 0), |
| 573 | SOC_DAPM_SINGLE("IN1L Switch", WM8993_LINE_MIXER1, 1, 1, 0), |
| 574 | SOC_DAPM_SINGLE("Output Switch", WM8993_LINE_MIXER1, 0, 1, 0), |
| 575 | }; |
| 576 | |
| 577 | static const struct snd_kcontrol_new line1n_mix[] = { |
| 578 | SOC_DAPM_SINGLE("Left Output Switch", WM8993_LINE_MIXER1, 6, 1, 0), |
| 579 | SOC_DAPM_SINGLE("Right Output Switch", WM8993_LINE_MIXER1, 5, 1, 0), |
| 580 | }; |
| 581 | |
| 582 | static const struct snd_kcontrol_new line1p_mix[] = { |
| 583 | SOC_DAPM_SINGLE("Left Output Switch", WM8993_LINE_MIXER1, 0, 1, 0), |
| 584 | }; |
| 585 | |
| 586 | static const struct snd_kcontrol_new line2_mix[] = { |
| 587 | SOC_DAPM_SINGLE("IN2R Switch", WM8993_LINE_MIXER2, 2, 1, 0), |
| 588 | SOC_DAPM_SINGLE("IN2L Switch", WM8993_LINE_MIXER2, 1, 1, 0), |
| 589 | SOC_DAPM_SINGLE("Output Switch", WM8993_LINE_MIXER2, 0, 1, 0), |
| 590 | }; |
| 591 | |
| 592 | static const struct snd_kcontrol_new line2n_mix[] = { |
| 593 | SOC_DAPM_SINGLE("Left Output Switch", WM8993_LINE_MIXER2, 6, 1, 0), |
| 594 | SOC_DAPM_SINGLE("Right Output Switch", WM8993_LINE_MIXER2, 5, 1, 0), |
| 595 | }; |
| 596 | |
| 597 | static const struct snd_kcontrol_new line2p_mix[] = { |
| 598 | SOC_DAPM_SINGLE("Right Output Switch", WM8993_LINE_MIXER2, 0, 1, 0), |
| 599 | }; |
| 600 | |
| 601 | static const struct snd_soc_dapm_widget analogue_dapm_widgets[] = { |
| 602 | SND_SOC_DAPM_INPUT("IN1LN"), |
| 603 | SND_SOC_DAPM_INPUT("IN1LP"), |
| 604 | SND_SOC_DAPM_INPUT("IN2LN"), |
Joonyoung Shim | 3482594 | 2009-12-04 15:12:10 +0900 | [diff] [blame] | 605 | SND_SOC_DAPM_INPUT("IN2LP:VXRN"), |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 606 | SND_SOC_DAPM_INPUT("IN1RN"), |
| 607 | SND_SOC_DAPM_INPUT("IN1RP"), |
| 608 | SND_SOC_DAPM_INPUT("IN2RN"), |
Joonyoung Shim | 3482594 | 2009-12-04 15:12:10 +0900 | [diff] [blame] | 609 | SND_SOC_DAPM_INPUT("IN2RP:VXRP"), |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 610 | |
| 611 | SND_SOC_DAPM_MICBIAS("MICBIAS2", WM8993_POWER_MANAGEMENT_1, 5, 0), |
| 612 | SND_SOC_DAPM_MICBIAS("MICBIAS1", WM8993_POWER_MANAGEMENT_1, 4, 0), |
| 613 | |
| 614 | SND_SOC_DAPM_MIXER("IN1L PGA", WM8993_POWER_MANAGEMENT_2, 6, 0, |
| 615 | in1l_pga, ARRAY_SIZE(in1l_pga)), |
| 616 | SND_SOC_DAPM_MIXER("IN1R PGA", WM8993_POWER_MANAGEMENT_2, 4, 0, |
| 617 | in1r_pga, ARRAY_SIZE(in1r_pga)), |
| 618 | |
| 619 | SND_SOC_DAPM_MIXER("IN2L PGA", WM8993_POWER_MANAGEMENT_2, 7, 0, |
| 620 | in2l_pga, ARRAY_SIZE(in2l_pga)), |
| 621 | SND_SOC_DAPM_MIXER("IN2R PGA", WM8993_POWER_MANAGEMENT_2, 5, 0, |
| 622 | in2r_pga, ARRAY_SIZE(in2r_pga)), |
| 623 | |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 624 | SND_SOC_DAPM_MIXER("MIXINL", WM8993_POWER_MANAGEMENT_2, 9, 0, |
| 625 | mixinl, ARRAY_SIZE(mixinl)), |
| 626 | SND_SOC_DAPM_MIXER("MIXINR", WM8993_POWER_MANAGEMENT_2, 8, 0, |
| 627 | mixinr, ARRAY_SIZE(mixinr)), |
| 628 | |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 629 | SND_SOC_DAPM_MIXER("Left Output Mixer", WM8993_POWER_MANAGEMENT_3, 5, 0, |
| 630 | left_output_mixer, ARRAY_SIZE(left_output_mixer)), |
| 631 | SND_SOC_DAPM_MIXER("Right Output Mixer", WM8993_POWER_MANAGEMENT_3, 4, 0, |
| 632 | right_output_mixer, ARRAY_SIZE(right_output_mixer)), |
| 633 | |
| 634 | SND_SOC_DAPM_PGA("Left Output PGA", WM8993_POWER_MANAGEMENT_3, 7, 0, NULL, 0), |
| 635 | SND_SOC_DAPM_PGA("Right Output PGA", WM8993_POWER_MANAGEMENT_3, 6, 0, NULL, 0), |
| 636 | |
Mark Brown | 3ed7074 | 2010-01-20 17:39:45 +0000 | [diff] [blame] | 637 | SND_SOC_DAPM_SUPPLY("Headphone Supply", SND_SOC_NOPM, 0, 0, hp_supply_event, |
| 638 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD), |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 639 | SND_SOC_DAPM_PGA_E("Headphone PGA", SND_SOC_NOPM, 0, 0, |
| 640 | NULL, 0, |
| 641 | hp_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), |
| 642 | |
| 643 | SND_SOC_DAPM_MIXER("Earpiece Mixer", SND_SOC_NOPM, 0, 0, |
| 644 | earpiece_mixer, ARRAY_SIZE(earpiece_mixer)), |
| 645 | SND_SOC_DAPM_PGA_E("Earpiece Driver", WM8993_POWER_MANAGEMENT_1, 11, 0, |
| 646 | NULL, 0, earpiece_event, |
| 647 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), |
| 648 | |
| 649 | SND_SOC_DAPM_MIXER("SPKL Boost", SND_SOC_NOPM, 0, 0, |
| 650 | left_speaker_boost, ARRAY_SIZE(left_speaker_boost)), |
| 651 | SND_SOC_DAPM_MIXER("SPKR Boost", SND_SOC_NOPM, 0, 0, |
| 652 | right_speaker_boost, ARRAY_SIZE(right_speaker_boost)), |
| 653 | |
| 654 | SND_SOC_DAPM_PGA("SPKL Driver", WM8993_POWER_MANAGEMENT_1, 12, 0, |
| 655 | NULL, 0), |
| 656 | SND_SOC_DAPM_PGA("SPKR Driver", WM8993_POWER_MANAGEMENT_1, 13, 0, |
| 657 | NULL, 0), |
| 658 | |
| 659 | SND_SOC_DAPM_MIXER("LINEOUT1 Mixer", SND_SOC_NOPM, 0, 0, |
| 660 | line1_mix, ARRAY_SIZE(line1_mix)), |
| 661 | SND_SOC_DAPM_MIXER("LINEOUT2 Mixer", SND_SOC_NOPM, 0, 0, |
| 662 | line2_mix, ARRAY_SIZE(line2_mix)), |
| 663 | |
| 664 | SND_SOC_DAPM_MIXER("LINEOUT1N Mixer", SND_SOC_NOPM, 0, 0, |
| 665 | line1n_mix, ARRAY_SIZE(line1n_mix)), |
| 666 | SND_SOC_DAPM_MIXER("LINEOUT1P Mixer", SND_SOC_NOPM, 0, 0, |
| 667 | line1p_mix, ARRAY_SIZE(line1p_mix)), |
| 668 | SND_SOC_DAPM_MIXER("LINEOUT2N Mixer", SND_SOC_NOPM, 0, 0, |
| 669 | line2n_mix, ARRAY_SIZE(line2n_mix)), |
| 670 | SND_SOC_DAPM_MIXER("LINEOUT2P Mixer", SND_SOC_NOPM, 0, 0, |
| 671 | line2p_mix, ARRAY_SIZE(line2p_mix)), |
| 672 | |
| 673 | SND_SOC_DAPM_PGA("LINEOUT1N Driver", WM8993_POWER_MANAGEMENT_3, 13, 0, |
| 674 | NULL, 0), |
| 675 | SND_SOC_DAPM_PGA("LINEOUT1P Driver", WM8993_POWER_MANAGEMENT_3, 12, 0, |
| 676 | NULL, 0), |
| 677 | SND_SOC_DAPM_PGA("LINEOUT2N Driver", WM8993_POWER_MANAGEMENT_3, 11, 0, |
| 678 | NULL, 0), |
| 679 | SND_SOC_DAPM_PGA("LINEOUT2P Driver", WM8993_POWER_MANAGEMENT_3, 10, 0, |
| 680 | NULL, 0), |
| 681 | |
| 682 | SND_SOC_DAPM_OUTPUT("SPKOUTLP"), |
| 683 | SND_SOC_DAPM_OUTPUT("SPKOUTLN"), |
| 684 | SND_SOC_DAPM_OUTPUT("SPKOUTRP"), |
| 685 | SND_SOC_DAPM_OUTPUT("SPKOUTRN"), |
| 686 | SND_SOC_DAPM_OUTPUT("HPOUT1L"), |
| 687 | SND_SOC_DAPM_OUTPUT("HPOUT1R"), |
| 688 | SND_SOC_DAPM_OUTPUT("HPOUT2P"), |
| 689 | SND_SOC_DAPM_OUTPUT("HPOUT2N"), |
| 690 | SND_SOC_DAPM_OUTPUT("LINEOUT1P"), |
| 691 | SND_SOC_DAPM_OUTPUT("LINEOUT1N"), |
| 692 | SND_SOC_DAPM_OUTPUT("LINEOUT2P"), |
| 693 | SND_SOC_DAPM_OUTPUT("LINEOUT2N"), |
| 694 | }; |
| 695 | |
| 696 | static const struct snd_soc_dapm_route analogue_routes[] = { |
Mark Brown | 4baafdd | 2011-02-18 15:05:53 -0800 | [diff] [blame] | 697 | { "MICBIAS1", NULL, "CLK_SYS" }, |
| 698 | { "MICBIAS2", NULL, "CLK_SYS" }, |
| 699 | |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 700 | { "IN1L PGA", "IN1LP Switch", "IN1LP" }, |
| 701 | { "IN1L PGA", "IN1LN Switch", "IN1LN" }, |
| 702 | |
| 703 | { "IN1R PGA", "IN1RP Switch", "IN1RP" }, |
| 704 | { "IN1R PGA", "IN1RN Switch", "IN1RN" }, |
| 705 | |
Joonyoung Shim | 3482594 | 2009-12-04 15:12:10 +0900 | [diff] [blame] | 706 | { "IN2L PGA", "IN2LP Switch", "IN2LP:VXRN" }, |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 707 | { "IN2L PGA", "IN2LN Switch", "IN2LN" }, |
| 708 | |
Joonyoung Shim | 3482594 | 2009-12-04 15:12:10 +0900 | [diff] [blame] | 709 | { "IN2R PGA", "IN2RP Switch", "IN2RP:VXRP" }, |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 710 | { "IN2R PGA", "IN2RN Switch", "IN2RN" }, |
| 711 | |
Joonyoung Shim | 3482594 | 2009-12-04 15:12:10 +0900 | [diff] [blame] | 712 | { "Direct Voice", NULL, "IN2LP:VXRN" }, |
| 713 | { "Direct Voice", NULL, "IN2RP:VXRP" }, |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 714 | |
| 715 | { "MIXINL", "IN1L Switch", "IN1L PGA" }, |
| 716 | { "MIXINL", "IN2L Switch", "IN2L PGA" }, |
| 717 | { "MIXINL", NULL, "Direct Voice" }, |
| 718 | { "MIXINL", NULL, "IN1LP" }, |
| 719 | { "MIXINL", NULL, "Left Output Mixer" }, |
| 720 | |
| 721 | { "MIXINR", "IN1R Switch", "IN1R PGA" }, |
| 722 | { "MIXINR", "IN2R Switch", "IN2R PGA" }, |
| 723 | { "MIXINR", NULL, "Direct Voice" }, |
| 724 | { "MIXINR", NULL, "IN1RP" }, |
| 725 | { "MIXINR", NULL, "Right Output Mixer" }, |
| 726 | |
| 727 | { "ADCL", NULL, "MIXINL" }, |
| 728 | { "ADCR", NULL, "MIXINR" }, |
| 729 | |
| 730 | { "Left Output Mixer", "Left Input Switch", "MIXINL" }, |
| 731 | { "Left Output Mixer", "Right Input Switch", "MIXINR" }, |
| 732 | { "Left Output Mixer", "IN2RN Switch", "IN2RN" }, |
| 733 | { "Left Output Mixer", "IN2LN Switch", "IN2LN" }, |
Joonyoung Shim | 3482594 | 2009-12-04 15:12:10 +0900 | [diff] [blame] | 734 | { "Left Output Mixer", "IN2LP Switch", "IN2LP:VXRN" }, |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 735 | { "Left Output Mixer", "IN1L Switch", "IN1L PGA" }, |
| 736 | { "Left Output Mixer", "IN1R Switch", "IN1R PGA" }, |
| 737 | |
| 738 | { "Right Output Mixer", "Left Input Switch", "MIXINL" }, |
| 739 | { "Right Output Mixer", "Right Input Switch", "MIXINR" }, |
| 740 | { "Right Output Mixer", "IN2LN Switch", "IN2LN" }, |
| 741 | { "Right Output Mixer", "IN2RN Switch", "IN2RN" }, |
Joonyoung Shim | 3482594 | 2009-12-04 15:12:10 +0900 | [diff] [blame] | 742 | { "Right Output Mixer", "IN2RP Switch", "IN2RP:VXRP" }, |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 743 | { "Right Output Mixer", "IN1L Switch", "IN1L PGA" }, |
| 744 | { "Right Output Mixer", "IN1R Switch", "IN1R PGA" }, |
| 745 | |
| 746 | { "Left Output PGA", NULL, "Left Output Mixer" }, |
| 747 | { "Left Output PGA", NULL, "TOCLK" }, |
| 748 | |
| 749 | { "Right Output PGA", NULL, "Right Output Mixer" }, |
| 750 | { "Right Output PGA", NULL, "TOCLK" }, |
| 751 | |
| 752 | { "Earpiece Mixer", "Direct Voice Switch", "Direct Voice" }, |
| 753 | { "Earpiece Mixer", "Left Output Switch", "Left Output PGA" }, |
| 754 | { "Earpiece Mixer", "Right Output Switch", "Right Output PGA" }, |
| 755 | |
| 756 | { "Earpiece Driver", NULL, "Earpiece Mixer" }, |
| 757 | { "HPOUT2N", NULL, "Earpiece Driver" }, |
| 758 | { "HPOUT2P", NULL, "Earpiece Driver" }, |
| 759 | |
| 760 | { "SPKL", "Input Switch", "MIXINL" }, |
| 761 | { "SPKL", "IN1LP Switch", "IN1LP" }, |
Mark Brown | 39cca16 | 2011-04-08 16:32:16 +0900 | [diff] [blame] | 762 | { "SPKL", "Output Switch", "Left Output PGA" }, |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 763 | { "SPKL", NULL, "TOCLK" }, |
| 764 | |
| 765 | { "SPKR", "Input Switch", "MIXINR" }, |
| 766 | { "SPKR", "IN1RP Switch", "IN1RP" }, |
Mark Brown | 39cca16 | 2011-04-08 16:32:16 +0900 | [diff] [blame] | 767 | { "SPKR", "Output Switch", "Right Output PGA" }, |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 768 | { "SPKR", NULL, "TOCLK" }, |
| 769 | |
| 770 | { "SPKL Boost", "Direct Voice Switch", "Direct Voice" }, |
| 771 | { "SPKL Boost", "SPKL Switch", "SPKL" }, |
| 772 | { "SPKL Boost", "SPKR Switch", "SPKR" }, |
| 773 | |
| 774 | { "SPKR Boost", "Direct Voice Switch", "Direct Voice" }, |
| 775 | { "SPKR Boost", "SPKR Switch", "SPKR" }, |
| 776 | { "SPKR Boost", "SPKL Switch", "SPKL" }, |
| 777 | |
| 778 | { "SPKL Driver", NULL, "SPKL Boost" }, |
| 779 | { "SPKL Driver", NULL, "CLK_SYS" }, |
| 780 | |
| 781 | { "SPKR Driver", NULL, "SPKR Boost" }, |
| 782 | { "SPKR Driver", NULL, "CLK_SYS" }, |
| 783 | |
| 784 | { "SPKOUTLP", NULL, "SPKL Driver" }, |
| 785 | { "SPKOUTLN", NULL, "SPKL Driver" }, |
| 786 | { "SPKOUTRP", NULL, "SPKR Driver" }, |
| 787 | { "SPKOUTRN", NULL, "SPKR Driver" }, |
| 788 | |
Mark Brown | 39cca16 | 2011-04-08 16:32:16 +0900 | [diff] [blame] | 789 | { "Left Headphone Mux", "Mixer", "Left Output PGA" }, |
| 790 | { "Right Headphone Mux", "Mixer", "Right Output PGA" }, |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 791 | |
| 792 | { "Headphone PGA", NULL, "Left Headphone Mux" }, |
| 793 | { "Headphone PGA", NULL, "Right Headphone Mux" }, |
| 794 | { "Headphone PGA", NULL, "CLK_SYS" }, |
Mark Brown | 3ed7074 | 2010-01-20 17:39:45 +0000 | [diff] [blame] | 795 | { "Headphone PGA", NULL, "Headphone Supply" }, |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 796 | |
| 797 | { "HPOUT1L", NULL, "Headphone PGA" }, |
| 798 | { "HPOUT1R", NULL, "Headphone PGA" }, |
| 799 | |
| 800 | { "LINEOUT1N", NULL, "LINEOUT1N Driver" }, |
| 801 | { "LINEOUT1P", NULL, "LINEOUT1P Driver" }, |
| 802 | { "LINEOUT2N", NULL, "LINEOUT2N Driver" }, |
| 803 | { "LINEOUT2P", NULL, "LINEOUT2P Driver" }, |
| 804 | }; |
| 805 | |
| 806 | static const struct snd_soc_dapm_route lineout1_diff_routes[] = { |
| 807 | { "LINEOUT1 Mixer", "IN1L Switch", "IN1L PGA" }, |
| 808 | { "LINEOUT1 Mixer", "IN1R Switch", "IN1R PGA" }, |
Mark Brown | d0b48af | 2011-05-14 17:21:28 -0700 | [diff] [blame] | 809 | { "LINEOUT1 Mixer", "Output Switch", "Left Output PGA" }, |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 810 | |
| 811 | { "LINEOUT1N Driver", NULL, "LINEOUT1 Mixer" }, |
| 812 | { "LINEOUT1P Driver", NULL, "LINEOUT1 Mixer" }, |
| 813 | }; |
| 814 | |
| 815 | static const struct snd_soc_dapm_route lineout1_se_routes[] = { |
Mark Brown | d0b48af | 2011-05-14 17:21:28 -0700 | [diff] [blame] | 816 | { "LINEOUT1N Mixer", "Left Output Switch", "Left Output PGA" }, |
| 817 | { "LINEOUT1N Mixer", "Right Output Switch", "Right Output PGA" }, |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 818 | |
Mark Brown | d0b48af | 2011-05-14 17:21:28 -0700 | [diff] [blame] | 819 | { "LINEOUT1P Mixer", "Left Output Switch", "Left Output PGA" }, |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 820 | |
| 821 | { "LINEOUT1N Driver", NULL, "LINEOUT1N Mixer" }, |
| 822 | { "LINEOUT1P Driver", NULL, "LINEOUT1P Mixer" }, |
| 823 | }; |
| 824 | |
| 825 | static const struct snd_soc_dapm_route lineout2_diff_routes[] = { |
| 826 | { "LINEOUT2 Mixer", "IN2L Switch", "IN2L PGA" }, |
| 827 | { "LINEOUT2 Mixer", "IN2R Switch", "IN2R PGA" }, |
Mark Brown | d0b48af | 2011-05-14 17:21:28 -0700 | [diff] [blame] | 828 | { "LINEOUT2 Mixer", "Output Switch", "Right Output PGA" }, |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 829 | |
| 830 | { "LINEOUT2N Driver", NULL, "LINEOUT2 Mixer" }, |
| 831 | { "LINEOUT2P Driver", NULL, "LINEOUT2 Mixer" }, |
| 832 | }; |
| 833 | |
| 834 | static const struct snd_soc_dapm_route lineout2_se_routes[] = { |
Mark Brown | d0b48af | 2011-05-14 17:21:28 -0700 | [diff] [blame] | 835 | { "LINEOUT2N Mixer", "Left Output Switch", "Left Output PGA" }, |
| 836 | { "LINEOUT2N Mixer", "Right Output Switch", "Right Output PGA" }, |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 837 | |
Mark Brown | d0b48af | 2011-05-14 17:21:28 -0700 | [diff] [blame] | 838 | { "LINEOUT2P Mixer", "Right Output Switch", "Right Output PGA" }, |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 839 | |
| 840 | { "LINEOUT2N Driver", NULL, "LINEOUT2N Mixer" }, |
| 841 | { "LINEOUT2P Driver", NULL, "LINEOUT2P Mixer" }, |
| 842 | }; |
| 843 | |
| 844 | int wm_hubs_add_analogue_controls(struct snd_soc_codec *codec) |
| 845 | { |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 846 | struct snd_soc_dapm_context *dapm = &codec->dapm; |
| 847 | |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 848 | /* Latch volume update bits & default ZC on */ |
| 849 | snd_soc_update_bits(codec, WM8993_LEFT_LINE_INPUT_1_2_VOLUME, |
| 850 | WM8993_IN1_VU, WM8993_IN1_VU); |
| 851 | snd_soc_update_bits(codec, WM8993_RIGHT_LINE_INPUT_1_2_VOLUME, |
| 852 | WM8993_IN1_VU, WM8993_IN1_VU); |
| 853 | snd_soc_update_bits(codec, WM8993_LEFT_LINE_INPUT_3_4_VOLUME, |
| 854 | WM8993_IN2_VU, WM8993_IN2_VU); |
| 855 | snd_soc_update_bits(codec, WM8993_RIGHT_LINE_INPUT_3_4_VOLUME, |
| 856 | WM8993_IN2_VU, WM8993_IN2_VU); |
| 857 | |
Mark Brown | fb5af53 | 2011-05-15 12:18:38 -0700 | [diff] [blame] | 858 | snd_soc_update_bits(codec, WM8993_SPEAKER_VOLUME_LEFT, |
| 859 | WM8993_SPKOUT_VU, WM8993_SPKOUT_VU); |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 860 | snd_soc_update_bits(codec, WM8993_SPEAKER_VOLUME_RIGHT, |
| 861 | WM8993_SPKOUT_VU, WM8993_SPKOUT_VU); |
| 862 | |
| 863 | snd_soc_update_bits(codec, WM8993_LEFT_OUTPUT_VOLUME, |
Mark Brown | fb5af53 | 2011-05-15 12:18:38 -0700 | [diff] [blame] | 864 | WM8993_HPOUT1_VU | WM8993_HPOUT1L_ZC, |
| 865 | WM8993_HPOUT1_VU | WM8993_HPOUT1L_ZC); |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 866 | snd_soc_update_bits(codec, WM8993_RIGHT_OUTPUT_VOLUME, |
| 867 | WM8993_HPOUT1_VU | WM8993_HPOUT1R_ZC, |
| 868 | WM8993_HPOUT1_VU | WM8993_HPOUT1R_ZC); |
| 869 | |
| 870 | snd_soc_update_bits(codec, WM8993_LEFT_OPGA_VOLUME, |
Mark Brown | fb5af53 | 2011-05-15 12:18:38 -0700 | [diff] [blame] | 871 | WM8993_MIXOUTL_ZC | WM8993_MIXOUT_VU, |
| 872 | WM8993_MIXOUTL_ZC | WM8993_MIXOUT_VU); |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 873 | snd_soc_update_bits(codec, WM8993_RIGHT_OPGA_VOLUME, |
| 874 | WM8993_MIXOUTR_ZC | WM8993_MIXOUT_VU, |
| 875 | WM8993_MIXOUTR_ZC | WM8993_MIXOUT_VU); |
| 876 | |
| 877 | snd_soc_add_controls(codec, analogue_snd_controls, |
| 878 | ARRAY_SIZE(analogue_snd_controls)); |
| 879 | |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 880 | snd_soc_dapm_new_controls(dapm, analogue_dapm_widgets, |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 881 | ARRAY_SIZE(analogue_dapm_widgets)); |
| 882 | return 0; |
| 883 | } |
| 884 | EXPORT_SYMBOL_GPL(wm_hubs_add_analogue_controls); |
| 885 | |
| 886 | int wm_hubs_add_analogue_routes(struct snd_soc_codec *codec, |
| 887 | int lineout1_diff, int lineout2_diff) |
| 888 | { |
Mark Brown | d96ca3c | 2011-07-12 15:25:03 +0900 | [diff] [blame] | 889 | struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 890 | struct snd_soc_dapm_context *dapm = &codec->dapm; |
| 891 | |
Mark Brown | d96ca3c | 2011-07-12 15:25:03 +0900 | [diff] [blame] | 892 | init_completion(&hubs->dcs_done); |
| 893 | |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 894 | snd_soc_dapm_add_routes(dapm, analogue_routes, |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 895 | ARRAY_SIZE(analogue_routes)); |
| 896 | |
| 897 | if (lineout1_diff) |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 898 | snd_soc_dapm_add_routes(dapm, |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 899 | lineout1_diff_routes, |
| 900 | ARRAY_SIZE(lineout1_diff_routes)); |
| 901 | else |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 902 | snd_soc_dapm_add_routes(dapm, |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 903 | lineout1_se_routes, |
| 904 | ARRAY_SIZE(lineout1_se_routes)); |
| 905 | |
| 906 | if (lineout2_diff) |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 907 | snd_soc_dapm_add_routes(dapm, |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 908 | lineout2_diff_routes, |
| 909 | ARRAY_SIZE(lineout2_diff_routes)); |
| 910 | else |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 911 | snd_soc_dapm_add_routes(dapm, |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 912 | lineout2_se_routes, |
| 913 | ARRAY_SIZE(lineout2_se_routes)); |
| 914 | |
| 915 | return 0; |
| 916 | } |
| 917 | EXPORT_SYMBOL_GPL(wm_hubs_add_analogue_routes); |
| 918 | |
Mark Brown | aa983d9 | 2009-09-30 14:16:11 +0100 | [diff] [blame] | 919 | int wm_hubs_handle_analogue_pdata(struct snd_soc_codec *codec, |
| 920 | int lineout1_diff, int lineout2_diff, |
| 921 | int lineout1fb, int lineout2fb, |
| 922 | int jd_scthr, int jd_thr, int micbias1_lvl, |
| 923 | int micbias2_lvl) |
| 924 | { |
| 925 | if (!lineout1_diff) |
| 926 | snd_soc_update_bits(codec, WM8993_LINE_MIXER1, |
| 927 | WM8993_LINEOUT1_MODE, |
| 928 | WM8993_LINEOUT1_MODE); |
| 929 | if (!lineout2_diff) |
| 930 | snd_soc_update_bits(codec, WM8993_LINE_MIXER2, |
| 931 | WM8993_LINEOUT2_MODE, |
| 932 | WM8993_LINEOUT2_MODE); |
| 933 | |
Mark Brown | 821dd91 | 2010-01-21 11:33:20 +0000 | [diff] [blame] | 934 | /* If the line outputs are differential then we aren't presenting |
| 935 | * VMID as an output and can disable it. |
| 936 | */ |
| 937 | if (lineout1_diff && lineout2_diff) |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 938 | codec->dapm.idle_bias_off = 1; |
Mark Brown | 821dd91 | 2010-01-21 11:33:20 +0000 | [diff] [blame] | 939 | |
Mark Brown | aa983d9 | 2009-09-30 14:16:11 +0100 | [diff] [blame] | 940 | if (lineout1fb) |
| 941 | snd_soc_update_bits(codec, WM8993_ADDITIONAL_CONTROL, |
| 942 | WM8993_LINEOUT1_FB, WM8993_LINEOUT1_FB); |
| 943 | |
| 944 | if (lineout2fb) |
| 945 | snd_soc_update_bits(codec, WM8993_ADDITIONAL_CONTROL, |
| 946 | WM8993_LINEOUT2_FB, WM8993_LINEOUT2_FB); |
| 947 | |
| 948 | snd_soc_update_bits(codec, WM8993_MICBIAS, |
| 949 | WM8993_JD_SCTHR_MASK | WM8993_JD_THR_MASK | |
| 950 | WM8993_MICB1_LVL | WM8993_MICB2_LVL, |
| 951 | jd_scthr << WM8993_JD_SCTHR_SHIFT | |
| 952 | jd_thr << WM8993_JD_THR_SHIFT | |
| 953 | micbias1_lvl | |
| 954 | micbias2_lvl << WM8993_MICB2_LVL_SHIFT); |
| 955 | |
| 956 | return 0; |
| 957 | } |
| 958 | EXPORT_SYMBOL_GPL(wm_hubs_handle_analogue_pdata); |
| 959 | |
Mark Brown | a2342ae | 2009-07-29 21:21:49 +0100 | [diff] [blame] | 960 | MODULE_DESCRIPTION("Shared support for Wolfson hubs products"); |
| 961 | MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>"); |
| 962 | MODULE_LICENSE("GPL"); |