Takashi Iwai | 1835a0f | 2011-10-27 22:12:46 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Jack-detection handling for HD-audio |
| 3 | * |
| 4 | * Copyright (c) 2011 Takashi Iwai <tiwai@suse.de> |
| 5 | * |
| 6 | * This driver is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | */ |
| 11 | |
| 12 | #include <linux/init.h> |
| 13 | #include <linux/slab.h> |
Takashi Iwai | bf815bf | 2011-11-16 14:28:33 +0100 | [diff] [blame] | 14 | #include <linux/export.h> |
Takashi Iwai | 1835a0f | 2011-10-27 22:12:46 +0200 | [diff] [blame] | 15 | #include <sound/core.h> |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 16 | #include <sound/control.h> |
Takashi Iwai | aad37db | 2011-11-02 08:54:51 +0100 | [diff] [blame] | 17 | #include <sound/jack.h> |
Takashi Iwai | 1835a0f | 2011-10-27 22:12:46 +0200 | [diff] [blame] | 18 | #include "hda_codec.h" |
| 19 | #include "hda_local.h" |
| 20 | #include "hda_jack.h" |
| 21 | |
| 22 | /* execute pin sense measurement */ |
| 23 | static u32 read_pin_sense(struct hda_codec *codec, hda_nid_t nid) |
| 24 | { |
| 25 | u32 pincap; |
| 26 | |
| 27 | if (!codec->no_trigger_sense) { |
| 28 | pincap = snd_hda_query_pin_caps(codec, nid); |
| 29 | if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */ |
| 30 | snd_hda_codec_read(codec, nid, 0, |
| 31 | AC_VERB_SET_PIN_SENSE, 0); |
| 32 | } |
| 33 | return snd_hda_codec_read(codec, nid, 0, |
| 34 | AC_VERB_GET_PIN_SENSE, 0); |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * snd_hda_jack_tbl_get - query the jack-table entry for the given NID |
| 39 | */ |
| 40 | struct hda_jack_tbl * |
| 41 | snd_hda_jack_tbl_get(struct hda_codec *codec, hda_nid_t nid) |
| 42 | { |
| 43 | struct hda_jack_tbl *jack = codec->jacktbl.list; |
| 44 | int i; |
| 45 | |
| 46 | if (!nid || !jack) |
| 47 | return NULL; |
| 48 | for (i = 0; i < codec->jacktbl.used; i++, jack++) |
| 49 | if (jack->nid == nid) |
| 50 | return jack; |
| 51 | return NULL; |
| 52 | } |
| 53 | EXPORT_SYMBOL_HDA(snd_hda_jack_tbl_get); |
| 54 | |
| 55 | /** |
Takashi Iwai | 3a93897 | 2011-10-28 01:16:55 +0200 | [diff] [blame] | 56 | * snd_hda_jack_tbl_get_from_tag - query the jack-table entry for the given tag |
| 57 | */ |
| 58 | struct hda_jack_tbl * |
| 59 | snd_hda_jack_tbl_get_from_tag(struct hda_codec *codec, unsigned char tag) |
| 60 | { |
| 61 | struct hda_jack_tbl *jack = codec->jacktbl.list; |
| 62 | int i; |
| 63 | |
| 64 | if (!tag || !jack) |
| 65 | return NULL; |
| 66 | for (i = 0; i < codec->jacktbl.used; i++, jack++) |
| 67 | if (jack->tag == tag) |
| 68 | return jack; |
| 69 | return NULL; |
| 70 | } |
| 71 | EXPORT_SYMBOL_HDA(snd_hda_jack_tbl_get_from_tag); |
| 72 | |
| 73 | /** |
Takashi Iwai | 1835a0f | 2011-10-27 22:12:46 +0200 | [diff] [blame] | 74 | * snd_hda_jack_tbl_new - create a jack-table entry for the given NID |
| 75 | */ |
| 76 | struct hda_jack_tbl * |
| 77 | snd_hda_jack_tbl_new(struct hda_codec *codec, hda_nid_t nid) |
| 78 | { |
| 79 | struct hda_jack_tbl *jack = snd_hda_jack_tbl_get(codec, nid); |
| 80 | if (jack) |
| 81 | return jack; |
| 82 | snd_array_init(&codec->jacktbl, sizeof(*jack), 16); |
| 83 | jack = snd_array_new(&codec->jacktbl); |
| 84 | if (!jack) |
| 85 | return NULL; |
| 86 | jack->nid = nid; |
| 87 | jack->jack_dirty = 1; |
Takashi Iwai | 3a93897 | 2011-10-28 01:16:55 +0200 | [diff] [blame] | 88 | jack->tag = codec->jacktbl.used; |
Takashi Iwai | 1835a0f | 2011-10-27 22:12:46 +0200 | [diff] [blame] | 89 | return jack; |
| 90 | } |
David Henningsson | d1cb620 | 2011-11-11 17:13:15 +0100 | [diff] [blame] | 91 | EXPORT_SYMBOL_HDA(snd_hda_jack_tbl_new); |
Takashi Iwai | 1835a0f | 2011-10-27 22:12:46 +0200 | [diff] [blame] | 92 | |
| 93 | void snd_hda_jack_tbl_clear(struct hda_codec *codec) |
| 94 | { |
Takashi Iwai | 31ef225 | 2011-12-01 17:41:36 +0100 | [diff] [blame] | 95 | #ifdef CONFIG_SND_HDA_INPUT_JACK |
| 96 | /* free jack instances manually when clearing/reconfiguring */ |
| 97 | if (!codec->bus->shutdown && codec->jacktbl.list) { |
| 98 | struct hda_jack_tbl *jack = codec->jacktbl.list; |
| 99 | int i; |
| 100 | for (i = 0; i < codec->jacktbl.used; i++, jack++) { |
| 101 | if (jack->jack) |
| 102 | snd_device_free(codec->bus->card, jack->jack); |
| 103 | } |
| 104 | } |
| 105 | #endif |
Takashi Iwai | 1835a0f | 2011-10-27 22:12:46 +0200 | [diff] [blame] | 106 | snd_array_free(&codec->jacktbl); |
| 107 | } |
| 108 | |
| 109 | /* update the cached value and notification flag if needed */ |
| 110 | static void jack_detect_update(struct hda_codec *codec, |
| 111 | struct hda_jack_tbl *jack) |
| 112 | { |
Takashi Iwai | 3a93897 | 2011-10-28 01:16:55 +0200 | [diff] [blame] | 113 | if (jack->jack_dirty || !jack->jack_detect) { |
Takashi Iwai | 35be544 | 2011-11-02 08:36:06 +0100 | [diff] [blame] | 114 | jack->pin_sense = read_pin_sense(codec, jack->nid); |
Takashi Iwai | 1835a0f | 2011-10-27 22:12:46 +0200 | [diff] [blame] | 115 | jack->jack_dirty = 0; |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | /** |
| 120 | * snd_hda_set_dirty_all - Mark all the cached as dirty |
| 121 | * |
| 122 | * This function sets the dirty flag to all entries of jack table. |
| 123 | * It's called from the resume path in hda_codec.c. |
| 124 | */ |
| 125 | void snd_hda_jack_set_dirty_all(struct hda_codec *codec) |
| 126 | { |
| 127 | struct hda_jack_tbl *jack = codec->jacktbl.list; |
| 128 | int i; |
| 129 | |
| 130 | for (i = 0; i < codec->jacktbl.used; i++, jack++) |
| 131 | if (jack->nid) |
| 132 | jack->jack_dirty = 1; |
| 133 | } |
| 134 | EXPORT_SYMBOL_HDA(snd_hda_jack_set_dirty_all); |
| 135 | |
| 136 | /** |
| 137 | * snd_hda_pin_sense - execute pin sense measurement |
| 138 | * @codec: the CODEC to sense |
| 139 | * @nid: the pin NID to sense |
| 140 | * |
| 141 | * Execute necessary pin sense measurement and return its Presence Detect, |
| 142 | * Impedance, ELD Valid etc. status bits. |
| 143 | */ |
| 144 | u32 snd_hda_pin_sense(struct hda_codec *codec, hda_nid_t nid) |
| 145 | { |
| 146 | struct hda_jack_tbl *jack = snd_hda_jack_tbl_get(codec, nid); |
| 147 | if (jack) { |
| 148 | jack_detect_update(codec, jack); |
| 149 | return jack->pin_sense; |
| 150 | } |
| 151 | return read_pin_sense(codec, nid); |
| 152 | } |
| 153 | EXPORT_SYMBOL_HDA(snd_hda_pin_sense); |
| 154 | |
Takashi Iwai | 35be544 | 2011-11-02 08:36:06 +0100 | [diff] [blame] | 155 | #define get_jack_plug_state(sense) !!(sense & AC_PINSENSE_PRESENCE) |
| 156 | |
Takashi Iwai | 1835a0f | 2011-10-27 22:12:46 +0200 | [diff] [blame] | 157 | /** |
| 158 | * snd_hda_jack_detect - query pin Presence Detect status |
| 159 | * @codec: the CODEC to sense |
| 160 | * @nid: the pin NID to sense |
| 161 | * |
| 162 | * Query and return the pin's Presence Detect status. |
| 163 | */ |
| 164 | int snd_hda_jack_detect(struct hda_codec *codec, hda_nid_t nid) |
| 165 | { |
| 166 | u32 sense = snd_hda_pin_sense(codec, nid); |
Takashi Iwai | 35be544 | 2011-11-02 08:36:06 +0100 | [diff] [blame] | 167 | return get_jack_plug_state(sense); |
Takashi Iwai | 1835a0f | 2011-10-27 22:12:46 +0200 | [diff] [blame] | 168 | } |
| 169 | EXPORT_SYMBOL_HDA(snd_hda_jack_detect); |
| 170 | |
| 171 | /** |
| 172 | * snd_hda_jack_detect_enable - enable the jack-detection |
| 173 | */ |
| 174 | int snd_hda_jack_detect_enable(struct hda_codec *codec, hda_nid_t nid, |
Takashi Iwai | 3a93897 | 2011-10-28 01:16:55 +0200 | [diff] [blame] | 175 | unsigned char action) |
Takashi Iwai | 1835a0f | 2011-10-27 22:12:46 +0200 | [diff] [blame] | 176 | { |
| 177 | struct hda_jack_tbl *jack = snd_hda_jack_tbl_new(codec, nid); |
| 178 | if (!jack) |
| 179 | return -ENOMEM; |
Takashi Iwai | 3a93897 | 2011-10-28 01:16:55 +0200 | [diff] [blame] | 180 | if (jack->jack_detect) |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 181 | return 0; /* already registered */ |
Takashi Iwai | 3a93897 | 2011-10-28 01:16:55 +0200 | [diff] [blame] | 182 | jack->jack_detect = 1; |
| 183 | if (action) |
| 184 | jack->action = action; |
Takashi Iwai | 1835a0f | 2011-10-27 22:12:46 +0200 | [diff] [blame] | 185 | return snd_hda_codec_write_cache(codec, nid, 0, |
| 186 | AC_VERB_SET_UNSOLICITED_ENABLE, |
Takashi Iwai | 3a93897 | 2011-10-28 01:16:55 +0200 | [diff] [blame] | 187 | AC_USRSP_EN | jack->tag); |
Takashi Iwai | 1835a0f | 2011-10-27 22:12:46 +0200 | [diff] [blame] | 188 | } |
| 189 | EXPORT_SYMBOL_HDA(snd_hda_jack_detect_enable); |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 190 | |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 191 | /** |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 192 | * snd_hda_jack_report_sync - sync the states of all jacks and report if changed |
| 193 | */ |
| 194 | void snd_hda_jack_report_sync(struct hda_codec *codec) |
| 195 | { |
| 196 | struct hda_jack_tbl *jack = codec->jacktbl.list; |
Takashi Iwai | 35be544 | 2011-11-02 08:36:06 +0100 | [diff] [blame] | 197 | int i, state; |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 198 | |
| 199 | for (i = 0; i < codec->jacktbl.used; i++, jack++) |
| 200 | if (jack->nid) { |
| 201 | jack_detect_update(codec, jack); |
Takashi Iwai | cfc7c9d | 2011-11-11 17:53:03 +0100 | [diff] [blame] | 202 | if (!jack->kctl) |
| 203 | continue; |
Takashi Iwai | 35be544 | 2011-11-02 08:36:06 +0100 | [diff] [blame] | 204 | state = get_jack_plug_state(jack->pin_sense); |
Takashi Iwai | aad37db | 2011-11-02 08:54:51 +0100 | [diff] [blame] | 205 | snd_kctl_jack_report(codec->bus->card, jack->kctl, state); |
Takashi Iwai | 31ef225 | 2011-12-01 17:41:36 +0100 | [diff] [blame] | 206 | #ifdef CONFIG_SND_HDA_INPUT_JACK |
| 207 | if (jack->jack) |
| 208 | snd_jack_report(jack->jack, |
| 209 | state ? jack->type : 0); |
| 210 | #endif |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 211 | } |
| 212 | } |
| 213 | EXPORT_SYMBOL_HDA(snd_hda_jack_report_sync); |
| 214 | |
Takashi Iwai | 31ef225 | 2011-12-01 17:41:36 +0100 | [diff] [blame] | 215 | #ifdef CONFIG_SND_HDA_INPUT_JACK |
| 216 | /* guess the jack type from the pin-config */ |
| 217 | static int get_input_jack_type(struct hda_codec *codec, hda_nid_t nid) |
| 218 | { |
| 219 | unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid); |
| 220 | switch (get_defcfg_device(def_conf)) { |
| 221 | case AC_JACK_LINE_OUT: |
| 222 | case AC_JACK_SPEAKER: |
| 223 | return SND_JACK_LINEOUT; |
| 224 | case AC_JACK_HP_OUT: |
| 225 | return SND_JACK_HEADPHONE; |
| 226 | case AC_JACK_SPDIF_OUT: |
| 227 | case AC_JACK_DIG_OTHER_OUT: |
| 228 | return SND_JACK_AVOUT; |
| 229 | case AC_JACK_MIC_IN: |
| 230 | return SND_JACK_MICROPHONE; |
| 231 | default: |
| 232 | return SND_JACK_LINEIN; |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | static void hda_free_jack_priv(struct snd_jack *jack) |
| 237 | { |
| 238 | struct hda_jack_tbl *jacks = jack->private_data; |
| 239 | jacks->nid = 0; |
| 240 | jacks->jack = NULL; |
| 241 | } |
| 242 | #endif |
| 243 | |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 244 | /** |
| 245 | * snd_hda_jack_add_kctl - Add a kctl for the given pin |
| 246 | * |
| 247 | * This assigns a jack-detection kctl to the given pin. The kcontrol |
| 248 | * will have the given name and index. |
| 249 | */ |
| 250 | int snd_hda_jack_add_kctl(struct hda_codec *codec, hda_nid_t nid, |
| 251 | const char *name, int idx) |
| 252 | { |
| 253 | struct hda_jack_tbl *jack; |
| 254 | struct snd_kcontrol *kctl; |
Takashi Iwai | 31ef225 | 2011-12-01 17:41:36 +0100 | [diff] [blame] | 255 | int err, state; |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 256 | |
Takashi Iwai | 3a93897 | 2011-10-28 01:16:55 +0200 | [diff] [blame] | 257 | jack = snd_hda_jack_tbl_new(codec, nid); |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 258 | if (!jack) |
| 259 | return 0; |
| 260 | if (jack->kctl) |
| 261 | return 0; /* already created */ |
Takashi Iwai | 35be544 | 2011-11-02 08:36:06 +0100 | [diff] [blame] | 262 | kctl = snd_kctl_jack_new(name, idx, codec); |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 263 | if (!kctl) |
| 264 | return -ENOMEM; |
Takashi Iwai | 31ef225 | 2011-12-01 17:41:36 +0100 | [diff] [blame] | 265 | err = snd_hda_ctl_add(codec, nid, kctl); |
| 266 | if (err < 0) |
| 267 | return err; |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 268 | jack->kctl = kctl; |
Takashi Iwai | 31ef225 | 2011-12-01 17:41:36 +0100 | [diff] [blame] | 269 | state = snd_hda_jack_detect(codec, nid); |
| 270 | snd_kctl_jack_report(codec->bus->card, kctl, state); |
| 271 | #ifdef CONFIG_SND_HDA_INPUT_JACK |
| 272 | jack->type = get_input_jack_type(codec, nid); |
| 273 | err = snd_jack_new(codec->bus->card, name, jack->type, &jack->jack); |
| 274 | if (err < 0) |
| 275 | return err; |
| 276 | jack->jack->private_data = jack; |
| 277 | jack->jack->private_free = hda_free_jack_priv; |
| 278 | snd_jack_report(jack->jack, state ? jack->type : 0); |
| 279 | #endif |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 280 | return 0; |
| 281 | } |
David Henningsson | d1cb620 | 2011-11-11 17:13:15 +0100 | [diff] [blame] | 282 | EXPORT_SYMBOL_HDA(snd_hda_jack_add_kctl); |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 283 | |
Takashi Iwai | 201e06f | 2011-11-16 15:33:26 +0100 | [diff] [blame] | 284 | static int add_jack_kctl(struct hda_codec *codec, hda_nid_t nid, |
David Henningsson | 05c3b36 | 2012-01-31 09:04:15 +0100 | [diff] [blame] | 285 | const struct auto_pin_cfg *cfg, |
| 286 | char *lastname, int *lastidx) |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 287 | { |
Takashi Iwai | 3a93897 | 2011-10-28 01:16:55 +0200 | [diff] [blame] | 288 | unsigned int def_conf, conn; |
Takashi Iwai | 201e06f | 2011-11-16 15:33:26 +0100 | [diff] [blame] | 289 | char name[44]; |
| 290 | int idx, err; |
Takashi Iwai | 3a93897 | 2011-10-28 01:16:55 +0200 | [diff] [blame] | 291 | |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 292 | if (!nid) |
| 293 | return 0; |
| 294 | if (!is_jack_detectable(codec, nid)) |
| 295 | return 0; |
Takashi Iwai | 3a93897 | 2011-10-28 01:16:55 +0200 | [diff] [blame] | 296 | def_conf = snd_hda_codec_get_pincfg(codec, nid); |
| 297 | conn = get_defcfg_connect(def_conf); |
| 298 | if (conn != AC_JACK_PORT_COMPLEX) |
| 299 | return 0; |
| 300 | |
Takashi Iwai | 201e06f | 2011-11-16 15:33:26 +0100 | [diff] [blame] | 301 | snd_hda_get_pin_label(codec, nid, cfg, name, sizeof(name), &idx); |
David Henningsson | 05c3b36 | 2012-01-31 09:04:15 +0100 | [diff] [blame] | 302 | if (!strcmp(name, lastname) && idx == *lastidx) |
| 303 | idx++; |
| 304 | strncpy(lastname, name, 44); |
| 305 | *lastidx = idx; |
Takashi Iwai | 201e06f | 2011-11-16 15:33:26 +0100 | [diff] [blame] | 306 | err = snd_hda_jack_add_kctl(codec, nid, name, idx); |
Takashi Iwai | 3a93897 | 2011-10-28 01:16:55 +0200 | [diff] [blame] | 307 | if (err < 0) |
| 308 | return err; |
| 309 | return snd_hda_jack_detect_enable(codec, nid, 0); |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 310 | } |
| 311 | |
| 312 | /** |
| 313 | * snd_hda_jack_add_kctls - Add kctls for all pins included in the given pincfg |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 314 | */ |
| 315 | int snd_hda_jack_add_kctls(struct hda_codec *codec, |
| 316 | const struct auto_pin_cfg *cfg) |
| 317 | { |
| 318 | const hda_nid_t *p; |
David Henningsson | 05c3b36 | 2012-01-31 09:04:15 +0100 | [diff] [blame] | 319 | int i, err, lastidx = 0; |
| 320 | char lastname[44] = ""; |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 321 | |
| 322 | for (i = 0, p = cfg->line_out_pins; i < cfg->line_outs; i++, p++) { |
David Henningsson | 05c3b36 | 2012-01-31 09:04:15 +0100 | [diff] [blame] | 323 | err = add_jack_kctl(codec, *p, cfg, lastname, &lastidx); |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 324 | if (err < 0) |
| 325 | return err; |
| 326 | } |
| 327 | for (i = 0, p = cfg->hp_pins; i < cfg->hp_outs; i++, p++) { |
| 328 | if (*p == *cfg->line_out_pins) /* might be duplicated */ |
| 329 | break; |
David Henningsson | 05c3b36 | 2012-01-31 09:04:15 +0100 | [diff] [blame] | 330 | err = add_jack_kctl(codec, *p, cfg, lastname, &lastidx); |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 331 | if (err < 0) |
| 332 | return err; |
| 333 | } |
| 334 | for (i = 0, p = cfg->speaker_pins; i < cfg->speaker_outs; i++, p++) { |
| 335 | if (*p == *cfg->line_out_pins) /* might be duplicated */ |
| 336 | break; |
David Henningsson | 05c3b36 | 2012-01-31 09:04:15 +0100 | [diff] [blame] | 337 | err = add_jack_kctl(codec, *p, cfg, lastname, &lastidx); |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 338 | if (err < 0) |
| 339 | return err; |
| 340 | } |
| 341 | for (i = 0; i < cfg->num_inputs; i++) { |
David Henningsson | 05c3b36 | 2012-01-31 09:04:15 +0100 | [diff] [blame] | 342 | err = add_jack_kctl(codec, cfg->inputs[i].pin, cfg, lastname, &lastidx); |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 343 | if (err < 0) |
| 344 | return err; |
| 345 | } |
| 346 | for (i = 0, p = cfg->dig_out_pins; i < cfg->dig_outs; i++, p++) { |
David Henningsson | 05c3b36 | 2012-01-31 09:04:15 +0100 | [diff] [blame] | 347 | err = add_jack_kctl(codec, *p, cfg, lastname, &lastidx); |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 348 | if (err < 0) |
| 349 | return err; |
| 350 | } |
David Henningsson | 05c3b36 | 2012-01-31 09:04:15 +0100 | [diff] [blame] | 351 | err = add_jack_kctl(codec, cfg->dig_in_pin, cfg, lastname, &lastidx); |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 352 | if (err < 0) |
| 353 | return err; |
David Henningsson | 05c3b36 | 2012-01-31 09:04:15 +0100 | [diff] [blame] | 354 | err = add_jack_kctl(codec, cfg->mono_out_pin, cfg, lastname, &lastidx); |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 355 | if (err < 0) |
| 356 | return err; |
| 357 | return 0; |
| 358 | } |
| 359 | EXPORT_SYMBOL_HDA(snd_hda_jack_add_kctls); |