Wu Fengguang | 079d88c | 2010-03-08 10:44:23 +0800 | [diff] [blame] | 1 | /* |
| 2 | * |
| 3 | * patch_hdmi.c - routines for HDMI/DisplayPort codecs |
| 4 | * |
| 5 | * Copyright(c) 2008-2010 Intel Corporation. All rights reserved. |
| 6 | * |
| 7 | * Authors: |
| 8 | * Wu Fengguang <wfg@linux.intel.com> |
| 9 | * |
| 10 | * Maintained by: |
| 11 | * Wu Fengguang <wfg@linux.intel.com> |
| 12 | * |
| 13 | * This program is free software; you can redistribute it and/or modify it |
| 14 | * under the terms of the GNU General Public License as published by the Free |
| 15 | * Software Foundation; either version 2 of the License, or (at your option) |
| 16 | * any later version. |
| 17 | * |
| 18 | * This program is distributed in the hope that it will be useful, but |
| 19 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 20 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 21 | * for more details. |
| 22 | * |
| 23 | * You should have received a copy of the GNU General Public License |
| 24 | * along with this program; if not, write to the Free Software Foundation, |
| 25 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 26 | */ |
| 27 | |
| 28 | |
| 29 | struct hdmi_spec { |
| 30 | int num_cvts; |
| 31 | int num_pins; |
| 32 | hda_nid_t cvt[MAX_HDMI_CVTS+1]; /* audio sources */ |
| 33 | hda_nid_t pin[MAX_HDMI_PINS+1]; /* audio sinks */ |
| 34 | |
| 35 | /* |
| 36 | * source connection for each pin |
| 37 | */ |
| 38 | hda_nid_t pin_cvt[MAX_HDMI_PINS+1]; |
| 39 | |
| 40 | /* |
| 41 | * HDMI sink attached to each pin |
| 42 | */ |
| 43 | struct hdmi_eld sink_eld[MAX_HDMI_PINS]; |
| 44 | |
| 45 | /* |
| 46 | * export one pcm per pipe |
| 47 | */ |
| 48 | struct hda_pcm pcm_rec[MAX_HDMI_CVTS]; |
| 49 | |
| 50 | /* |
| 51 | * nvhdmi specific |
| 52 | */ |
| 53 | struct hda_multi_out multiout; |
| 54 | unsigned int codec_type; |
Takashi Iwai | 38faddb | 2010-07-28 14:21:55 +0200 | [diff] [blame] | 55 | |
| 56 | /* misc flags */ |
| 57 | /* PD bit indicates only the update, not the current state */ |
| 58 | unsigned int old_pin_detect:1; |
Wu Fengguang | 079d88c | 2010-03-08 10:44:23 +0800 | [diff] [blame] | 59 | }; |
| 60 | |
| 61 | |
| 62 | struct hdmi_audio_infoframe { |
| 63 | u8 type; /* 0x84 */ |
| 64 | u8 ver; /* 0x01 */ |
| 65 | u8 len; /* 0x0a */ |
| 66 | |
| 67 | u8 checksum; /* PB0 */ |
| 68 | u8 CC02_CT47; /* CC in bits 0:2, CT in 4:7 */ |
| 69 | u8 SS01_SF24; |
| 70 | u8 CXT04; |
| 71 | u8 CA; |
| 72 | u8 LFEPBL01_LSV36_DM_INH7; |
| 73 | u8 reserved[5]; /* PB6 - PB10 */ |
| 74 | }; |
| 75 | |
| 76 | /* |
| 77 | * CEA speaker placement: |
| 78 | * |
| 79 | * FLH FCH FRH |
| 80 | * FLW FL FLC FC FRC FR FRW |
| 81 | * |
| 82 | * LFE |
| 83 | * TC |
| 84 | * |
| 85 | * RL RLC RC RRC RR |
| 86 | * |
| 87 | * The Left/Right Surround channel _notions_ LS/RS in SMPTE 320M corresponds to |
| 88 | * CEA RL/RR; The SMPTE channel _assignment_ C/LFE is swapped to CEA LFE/FC. |
| 89 | */ |
| 90 | enum cea_speaker_placement { |
| 91 | FL = (1 << 0), /* Front Left */ |
| 92 | FC = (1 << 1), /* Front Center */ |
| 93 | FR = (1 << 2), /* Front Right */ |
| 94 | FLC = (1 << 3), /* Front Left Center */ |
| 95 | FRC = (1 << 4), /* Front Right Center */ |
| 96 | RL = (1 << 5), /* Rear Left */ |
| 97 | RC = (1 << 6), /* Rear Center */ |
| 98 | RR = (1 << 7), /* Rear Right */ |
| 99 | RLC = (1 << 8), /* Rear Left Center */ |
| 100 | RRC = (1 << 9), /* Rear Right Center */ |
| 101 | LFE = (1 << 10), /* Low Frequency Effect */ |
| 102 | FLW = (1 << 11), /* Front Left Wide */ |
| 103 | FRW = (1 << 12), /* Front Right Wide */ |
| 104 | FLH = (1 << 13), /* Front Left High */ |
| 105 | FCH = (1 << 14), /* Front Center High */ |
| 106 | FRH = (1 << 15), /* Front Right High */ |
| 107 | TC = (1 << 16), /* Top Center */ |
| 108 | }; |
| 109 | |
| 110 | /* |
| 111 | * ELD SA bits in the CEA Speaker Allocation data block |
| 112 | */ |
| 113 | static int eld_speaker_allocation_bits[] = { |
| 114 | [0] = FL | FR, |
| 115 | [1] = LFE, |
| 116 | [2] = FC, |
| 117 | [3] = RL | RR, |
| 118 | [4] = RC, |
| 119 | [5] = FLC | FRC, |
| 120 | [6] = RLC | RRC, |
| 121 | /* the following are not defined in ELD yet */ |
| 122 | [7] = FLW | FRW, |
| 123 | [8] = FLH | FRH, |
| 124 | [9] = TC, |
| 125 | [10] = FCH, |
| 126 | }; |
| 127 | |
| 128 | struct cea_channel_speaker_allocation { |
| 129 | int ca_index; |
| 130 | int speakers[8]; |
| 131 | |
| 132 | /* derived values, just for convenience */ |
| 133 | int channels; |
| 134 | int spk_mask; |
| 135 | }; |
| 136 | |
| 137 | /* |
| 138 | * ALSA sequence is: |
| 139 | * |
| 140 | * surround40 surround41 surround50 surround51 surround71 |
| 141 | * ch0 front left = = = = |
| 142 | * ch1 front right = = = = |
| 143 | * ch2 rear left = = = = |
| 144 | * ch3 rear right = = = = |
| 145 | * ch4 LFE center center center |
| 146 | * ch5 LFE LFE |
| 147 | * ch6 side left |
| 148 | * ch7 side right |
| 149 | * |
| 150 | * surround71 = {FL, FR, RLC, RRC, FC, LFE, RL, RR} |
| 151 | */ |
| 152 | static int hdmi_channel_mapping[0x32][8] = { |
| 153 | /* stereo */ |
| 154 | [0x00] = { 0x00, 0x11, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7 }, |
| 155 | /* 2.1 */ |
| 156 | [0x01] = { 0x00, 0x11, 0x22, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7 }, |
| 157 | /* Dolby Surround */ |
| 158 | [0x02] = { 0x00, 0x11, 0x23, 0xf2, 0xf4, 0xf5, 0xf6, 0xf7 }, |
| 159 | /* surround40 */ |
| 160 | [0x08] = { 0x00, 0x11, 0x24, 0x35, 0xf3, 0xf2, 0xf6, 0xf7 }, |
| 161 | /* 4ch */ |
| 162 | [0x03] = { 0x00, 0x11, 0x23, 0x32, 0x44, 0xf5, 0xf6, 0xf7 }, |
| 163 | /* surround41 */ |
| 164 | [0x09] = { 0x00, 0x11, 0x24, 0x34, 0x43, 0xf2, 0xf6, 0xf7 }, |
| 165 | /* surround50 */ |
| 166 | [0x0a] = { 0x00, 0x11, 0x24, 0x35, 0x43, 0xf2, 0xf6, 0xf7 }, |
| 167 | /* surround51 */ |
| 168 | [0x0b] = { 0x00, 0x11, 0x24, 0x35, 0x43, 0x52, 0xf6, 0xf7 }, |
| 169 | /* 7.1 */ |
| 170 | [0x13] = { 0x00, 0x11, 0x26, 0x37, 0x43, 0x52, 0x64, 0x75 }, |
| 171 | }; |
| 172 | |
| 173 | /* |
| 174 | * This is an ordered list! |
| 175 | * |
| 176 | * The preceding ones have better chances to be selected by |
| 177 | * hdmi_setup_channel_allocation(). |
| 178 | */ |
| 179 | static struct cea_channel_speaker_allocation channel_allocations[] = { |
| 180 | /* channel: 7 6 5 4 3 2 1 0 */ |
| 181 | { .ca_index = 0x00, .speakers = { 0, 0, 0, 0, 0, 0, FR, FL } }, |
| 182 | /* 2.1 */ |
| 183 | { .ca_index = 0x01, .speakers = { 0, 0, 0, 0, 0, LFE, FR, FL } }, |
| 184 | /* Dolby Surround */ |
| 185 | { .ca_index = 0x02, .speakers = { 0, 0, 0, 0, FC, 0, FR, FL } }, |
| 186 | /* surround40 */ |
| 187 | { .ca_index = 0x08, .speakers = { 0, 0, RR, RL, 0, 0, FR, FL } }, |
| 188 | /* surround41 */ |
| 189 | { .ca_index = 0x09, .speakers = { 0, 0, RR, RL, 0, LFE, FR, FL } }, |
| 190 | /* surround50 */ |
| 191 | { .ca_index = 0x0a, .speakers = { 0, 0, RR, RL, FC, 0, FR, FL } }, |
| 192 | /* surround51 */ |
| 193 | { .ca_index = 0x0b, .speakers = { 0, 0, RR, RL, FC, LFE, FR, FL } }, |
| 194 | /* 6.1 */ |
| 195 | { .ca_index = 0x0f, .speakers = { 0, RC, RR, RL, FC, LFE, FR, FL } }, |
| 196 | /* surround71 */ |
| 197 | { .ca_index = 0x13, .speakers = { RRC, RLC, RR, RL, FC, LFE, FR, FL } }, |
| 198 | |
| 199 | { .ca_index = 0x03, .speakers = { 0, 0, 0, 0, FC, LFE, FR, FL } }, |
| 200 | { .ca_index = 0x04, .speakers = { 0, 0, 0, RC, 0, 0, FR, FL } }, |
| 201 | { .ca_index = 0x05, .speakers = { 0, 0, 0, RC, 0, LFE, FR, FL } }, |
| 202 | { .ca_index = 0x06, .speakers = { 0, 0, 0, RC, FC, 0, FR, FL } }, |
| 203 | { .ca_index = 0x07, .speakers = { 0, 0, 0, RC, FC, LFE, FR, FL } }, |
| 204 | { .ca_index = 0x0c, .speakers = { 0, RC, RR, RL, 0, 0, FR, FL } }, |
| 205 | { .ca_index = 0x0d, .speakers = { 0, RC, RR, RL, 0, LFE, FR, FL } }, |
| 206 | { .ca_index = 0x0e, .speakers = { 0, RC, RR, RL, FC, 0, FR, FL } }, |
| 207 | { .ca_index = 0x10, .speakers = { RRC, RLC, RR, RL, 0, 0, FR, FL } }, |
| 208 | { .ca_index = 0x11, .speakers = { RRC, RLC, RR, RL, 0, LFE, FR, FL } }, |
| 209 | { .ca_index = 0x12, .speakers = { RRC, RLC, RR, RL, FC, 0, FR, FL } }, |
| 210 | { .ca_index = 0x14, .speakers = { FRC, FLC, 0, 0, 0, 0, FR, FL } }, |
| 211 | { .ca_index = 0x15, .speakers = { FRC, FLC, 0, 0, 0, LFE, FR, FL } }, |
| 212 | { .ca_index = 0x16, .speakers = { FRC, FLC, 0, 0, FC, 0, FR, FL } }, |
| 213 | { .ca_index = 0x17, .speakers = { FRC, FLC, 0, 0, FC, LFE, FR, FL } }, |
| 214 | { .ca_index = 0x18, .speakers = { FRC, FLC, 0, RC, 0, 0, FR, FL } }, |
| 215 | { .ca_index = 0x19, .speakers = { FRC, FLC, 0, RC, 0, LFE, FR, FL } }, |
| 216 | { .ca_index = 0x1a, .speakers = { FRC, FLC, 0, RC, FC, 0, FR, FL } }, |
| 217 | { .ca_index = 0x1b, .speakers = { FRC, FLC, 0, RC, FC, LFE, FR, FL } }, |
| 218 | { .ca_index = 0x1c, .speakers = { FRC, FLC, RR, RL, 0, 0, FR, FL } }, |
| 219 | { .ca_index = 0x1d, .speakers = { FRC, FLC, RR, RL, 0, LFE, FR, FL } }, |
| 220 | { .ca_index = 0x1e, .speakers = { FRC, FLC, RR, RL, FC, 0, FR, FL } }, |
| 221 | { .ca_index = 0x1f, .speakers = { FRC, FLC, RR, RL, FC, LFE, FR, FL } }, |
| 222 | { .ca_index = 0x20, .speakers = { 0, FCH, RR, RL, FC, 0, FR, FL } }, |
| 223 | { .ca_index = 0x21, .speakers = { 0, FCH, RR, RL, FC, LFE, FR, FL } }, |
| 224 | { .ca_index = 0x22, .speakers = { TC, 0, RR, RL, FC, 0, FR, FL } }, |
| 225 | { .ca_index = 0x23, .speakers = { TC, 0, RR, RL, FC, LFE, FR, FL } }, |
| 226 | { .ca_index = 0x24, .speakers = { FRH, FLH, RR, RL, 0, 0, FR, FL } }, |
| 227 | { .ca_index = 0x25, .speakers = { FRH, FLH, RR, RL, 0, LFE, FR, FL } }, |
| 228 | { .ca_index = 0x26, .speakers = { FRW, FLW, RR, RL, 0, 0, FR, FL } }, |
| 229 | { .ca_index = 0x27, .speakers = { FRW, FLW, RR, RL, 0, LFE, FR, FL } }, |
| 230 | { .ca_index = 0x28, .speakers = { TC, RC, RR, RL, FC, 0, FR, FL } }, |
| 231 | { .ca_index = 0x29, .speakers = { TC, RC, RR, RL, FC, LFE, FR, FL } }, |
| 232 | { .ca_index = 0x2a, .speakers = { FCH, RC, RR, RL, FC, 0, FR, FL } }, |
| 233 | { .ca_index = 0x2b, .speakers = { FCH, RC, RR, RL, FC, LFE, FR, FL } }, |
| 234 | { .ca_index = 0x2c, .speakers = { TC, FCH, RR, RL, FC, 0, FR, FL } }, |
| 235 | { .ca_index = 0x2d, .speakers = { TC, FCH, RR, RL, FC, LFE, FR, FL } }, |
| 236 | { .ca_index = 0x2e, .speakers = { FRH, FLH, RR, RL, FC, 0, FR, FL } }, |
| 237 | { .ca_index = 0x2f, .speakers = { FRH, FLH, RR, RL, FC, LFE, FR, FL } }, |
| 238 | { .ca_index = 0x30, .speakers = { FRW, FLW, RR, RL, FC, 0, FR, FL } }, |
| 239 | { .ca_index = 0x31, .speakers = { FRW, FLW, RR, RL, FC, LFE, FR, FL } }, |
| 240 | }; |
| 241 | |
| 242 | |
| 243 | /* |
| 244 | * HDMI routines |
| 245 | */ |
| 246 | |
| 247 | static int hda_node_index(hda_nid_t *nids, hda_nid_t nid) |
| 248 | { |
| 249 | int i; |
| 250 | |
| 251 | for (i = 0; nids[i]; i++) |
| 252 | if (nids[i] == nid) |
| 253 | return i; |
| 254 | |
| 255 | snd_printk(KERN_WARNING "HDMI: nid %d not registered\n", nid); |
| 256 | return -EINVAL; |
| 257 | } |
| 258 | |
| 259 | static void hdmi_get_show_eld(struct hda_codec *codec, hda_nid_t pin_nid, |
| 260 | struct hdmi_eld *eld) |
| 261 | { |
| 262 | if (!snd_hdmi_get_eld(eld, codec, pin_nid)) |
| 263 | snd_hdmi_show_eld(eld); |
| 264 | } |
| 265 | |
| 266 | #ifdef BE_PARANOID |
| 267 | static void hdmi_get_dip_index(struct hda_codec *codec, hda_nid_t pin_nid, |
| 268 | int *packet_index, int *byte_index) |
| 269 | { |
| 270 | int val; |
| 271 | |
| 272 | val = snd_hda_codec_read(codec, pin_nid, 0, |
| 273 | AC_VERB_GET_HDMI_DIP_INDEX, 0); |
| 274 | |
| 275 | *packet_index = val >> 5; |
| 276 | *byte_index = val & 0x1f; |
| 277 | } |
| 278 | #endif |
| 279 | |
| 280 | static void hdmi_set_dip_index(struct hda_codec *codec, hda_nid_t pin_nid, |
| 281 | int packet_index, int byte_index) |
| 282 | { |
| 283 | int val; |
| 284 | |
| 285 | val = (packet_index << 5) | (byte_index & 0x1f); |
| 286 | |
| 287 | snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_INDEX, val); |
| 288 | } |
| 289 | |
| 290 | static void hdmi_write_dip_byte(struct hda_codec *codec, hda_nid_t pin_nid, |
| 291 | unsigned char val) |
| 292 | { |
| 293 | snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_DATA, val); |
| 294 | } |
| 295 | |
| 296 | static void hdmi_enable_output(struct hda_codec *codec, hda_nid_t pin_nid) |
| 297 | { |
| 298 | /* Unmute */ |
| 299 | if (get_wcaps(codec, pin_nid) & AC_WCAP_OUT_AMP) |
| 300 | snd_hda_codec_write(codec, pin_nid, 0, |
| 301 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); |
| 302 | /* Enable pin out */ |
| 303 | snd_hda_codec_write(codec, pin_nid, 0, |
| 304 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); |
| 305 | } |
| 306 | |
| 307 | static int hdmi_get_channel_count(struct hda_codec *codec, hda_nid_t nid) |
| 308 | { |
| 309 | return 1 + snd_hda_codec_read(codec, nid, 0, |
| 310 | AC_VERB_GET_CVT_CHAN_COUNT, 0); |
| 311 | } |
| 312 | |
| 313 | static void hdmi_set_channel_count(struct hda_codec *codec, |
| 314 | hda_nid_t nid, int chs) |
| 315 | { |
| 316 | if (chs != hdmi_get_channel_count(codec, nid)) |
| 317 | snd_hda_codec_write(codec, nid, 0, |
| 318 | AC_VERB_SET_CVT_CHAN_COUNT, chs - 1); |
| 319 | } |
| 320 | |
| 321 | |
| 322 | /* |
| 323 | * Channel mapping routines |
| 324 | */ |
| 325 | |
| 326 | /* |
| 327 | * Compute derived values in channel_allocations[]. |
| 328 | */ |
| 329 | static void init_channel_allocations(void) |
| 330 | { |
| 331 | int i, j; |
| 332 | struct cea_channel_speaker_allocation *p; |
| 333 | |
| 334 | for (i = 0; i < ARRAY_SIZE(channel_allocations); i++) { |
| 335 | p = channel_allocations + i; |
| 336 | p->channels = 0; |
| 337 | p->spk_mask = 0; |
| 338 | for (j = 0; j < ARRAY_SIZE(p->speakers); j++) |
| 339 | if (p->speakers[j]) { |
| 340 | p->channels++; |
| 341 | p->spk_mask |= p->speakers[j]; |
| 342 | } |
| 343 | } |
| 344 | } |
| 345 | |
| 346 | /* |
| 347 | * The transformation takes two steps: |
| 348 | * |
| 349 | * eld->spk_alloc => (eld_speaker_allocation_bits[]) => spk_mask |
| 350 | * spk_mask => (channel_allocations[]) => ai->CA |
| 351 | * |
| 352 | * TODO: it could select the wrong CA from multiple candidates. |
| 353 | */ |
| 354 | static int hdmi_setup_channel_allocation(struct hda_codec *codec, hda_nid_t nid, |
| 355 | struct hdmi_audio_infoframe *ai) |
| 356 | { |
| 357 | struct hdmi_spec *spec = codec->spec; |
| 358 | struct hdmi_eld *eld; |
| 359 | int i; |
| 360 | int spk_mask = 0; |
| 361 | int channels = 1 + (ai->CC02_CT47 & 0x7); |
| 362 | char buf[SND_PRINT_CHANNEL_ALLOCATION_ADVISED_BUFSIZE]; |
| 363 | |
| 364 | /* |
| 365 | * CA defaults to 0 for basic stereo audio |
| 366 | */ |
| 367 | if (channels <= 2) |
| 368 | return 0; |
| 369 | |
| 370 | i = hda_node_index(spec->pin_cvt, nid); |
| 371 | if (i < 0) |
| 372 | return 0; |
| 373 | eld = &spec->sink_eld[i]; |
| 374 | |
| 375 | /* |
| 376 | * HDMI sink's ELD info cannot always be retrieved for now, e.g. |
| 377 | * in console or for audio devices. Assume the highest speakers |
| 378 | * configuration, to _not_ prohibit multi-channel audio playback. |
| 379 | */ |
| 380 | if (!eld->spk_alloc) |
| 381 | eld->spk_alloc = 0xffff; |
| 382 | |
| 383 | /* |
| 384 | * expand ELD's speaker allocation mask |
| 385 | * |
| 386 | * ELD tells the speaker mask in a compact(paired) form, |
| 387 | * expand ELD's notions to match the ones used by Audio InfoFrame. |
| 388 | */ |
| 389 | for (i = 0; i < ARRAY_SIZE(eld_speaker_allocation_bits); i++) { |
| 390 | if (eld->spk_alloc & (1 << i)) |
| 391 | spk_mask |= eld_speaker_allocation_bits[i]; |
| 392 | } |
| 393 | |
| 394 | /* search for the first working match in the CA table */ |
| 395 | for (i = 0; i < ARRAY_SIZE(channel_allocations); i++) { |
| 396 | if (channels == channel_allocations[i].channels && |
| 397 | (spk_mask & channel_allocations[i].spk_mask) == |
| 398 | channel_allocations[i].spk_mask) { |
| 399 | ai->CA = channel_allocations[i].ca_index; |
| 400 | break; |
| 401 | } |
| 402 | } |
| 403 | |
| 404 | snd_print_channel_allocation(eld->spk_alloc, buf, sizeof(buf)); |
Wu Fengguang | 2abbf43 | 2010-03-08 10:45:38 +0800 | [diff] [blame] | 405 | snd_printdd("HDMI: select CA 0x%x for %d-channel allocation: %s\n", |
| 406 | ai->CA, channels, buf); |
Wu Fengguang | 079d88c | 2010-03-08 10:44:23 +0800 | [diff] [blame] | 407 | |
| 408 | return ai->CA; |
| 409 | } |
| 410 | |
| 411 | static void hdmi_debug_channel_mapping(struct hda_codec *codec, |
| 412 | hda_nid_t pin_nid) |
| 413 | { |
| 414 | #ifdef CONFIG_SND_DEBUG_VERBOSE |
| 415 | int i; |
| 416 | int slot; |
| 417 | |
| 418 | for (i = 0; i < 8; i++) { |
| 419 | slot = snd_hda_codec_read(codec, pin_nid, 0, |
| 420 | AC_VERB_GET_HDMI_CHAN_SLOT, i); |
| 421 | printk(KERN_DEBUG "HDMI: ASP channel %d => slot %d\n", |
| 422 | slot >> 4, slot & 0xf); |
| 423 | } |
| 424 | #endif |
| 425 | } |
| 426 | |
| 427 | |
| 428 | static void hdmi_setup_channel_mapping(struct hda_codec *codec, |
| 429 | hda_nid_t pin_nid, |
| 430 | struct hdmi_audio_infoframe *ai) |
| 431 | { |
| 432 | int i; |
| 433 | int ca = ai->CA; |
| 434 | int err; |
| 435 | |
| 436 | if (hdmi_channel_mapping[ca][1] == 0) { |
| 437 | for (i = 0; i < channel_allocations[ca].channels; i++) |
| 438 | hdmi_channel_mapping[ca][i] = i | (i << 4); |
| 439 | for (; i < 8; i++) |
| 440 | hdmi_channel_mapping[ca][i] = 0xf | (i << 4); |
| 441 | } |
| 442 | |
| 443 | for (i = 0; i < 8; i++) { |
| 444 | err = snd_hda_codec_write(codec, pin_nid, 0, |
| 445 | AC_VERB_SET_HDMI_CHAN_SLOT, |
| 446 | hdmi_channel_mapping[ca][i]); |
| 447 | if (err) { |
Wu Fengguang | 2abbf43 | 2010-03-08 10:45:38 +0800 | [diff] [blame] | 448 | snd_printdd(KERN_NOTICE |
| 449 | "HDMI: channel mapping failed\n"); |
Wu Fengguang | 079d88c | 2010-03-08 10:44:23 +0800 | [diff] [blame] | 450 | break; |
| 451 | } |
| 452 | } |
| 453 | |
| 454 | hdmi_debug_channel_mapping(codec, pin_nid); |
| 455 | } |
| 456 | |
| 457 | |
| 458 | /* |
| 459 | * Audio InfoFrame routines |
| 460 | */ |
| 461 | |
| 462 | /* |
| 463 | * Enable Audio InfoFrame Transmission |
| 464 | */ |
| 465 | static void hdmi_start_infoframe_trans(struct hda_codec *codec, |
| 466 | hda_nid_t pin_nid) |
| 467 | { |
| 468 | hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); |
| 469 | snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_XMIT, |
| 470 | AC_DIPXMIT_BEST); |
| 471 | } |
| 472 | |
| 473 | /* |
| 474 | * Disable Audio InfoFrame Transmission |
| 475 | */ |
| 476 | static void hdmi_stop_infoframe_trans(struct hda_codec *codec, |
| 477 | hda_nid_t pin_nid) |
| 478 | { |
| 479 | hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); |
| 480 | snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_XMIT, |
| 481 | AC_DIPXMIT_DISABLE); |
| 482 | } |
| 483 | |
| 484 | static void hdmi_debug_dip_size(struct hda_codec *codec, hda_nid_t pin_nid) |
| 485 | { |
| 486 | #ifdef CONFIG_SND_DEBUG_VERBOSE |
| 487 | int i; |
| 488 | int size; |
| 489 | |
| 490 | size = snd_hdmi_get_eld_size(codec, pin_nid); |
| 491 | printk(KERN_DEBUG "HDMI: ELD buf size is %d\n", size); |
| 492 | |
| 493 | for (i = 0; i < 8; i++) { |
| 494 | size = snd_hda_codec_read(codec, pin_nid, 0, |
| 495 | AC_VERB_GET_HDMI_DIP_SIZE, i); |
| 496 | printk(KERN_DEBUG "HDMI: DIP GP[%d] buf size is %d\n", i, size); |
| 497 | } |
| 498 | #endif |
| 499 | } |
| 500 | |
| 501 | static void hdmi_clear_dip_buffers(struct hda_codec *codec, hda_nid_t pin_nid) |
| 502 | { |
| 503 | #ifdef BE_PARANOID |
| 504 | int i, j; |
| 505 | int size; |
| 506 | int pi, bi; |
| 507 | for (i = 0; i < 8; i++) { |
| 508 | size = snd_hda_codec_read(codec, pin_nid, 0, |
| 509 | AC_VERB_GET_HDMI_DIP_SIZE, i); |
| 510 | if (size == 0) |
| 511 | continue; |
| 512 | |
| 513 | hdmi_set_dip_index(codec, pin_nid, i, 0x0); |
| 514 | for (j = 1; j < 1000; j++) { |
| 515 | hdmi_write_dip_byte(codec, pin_nid, 0x0); |
| 516 | hdmi_get_dip_index(codec, pin_nid, &pi, &bi); |
| 517 | if (pi != i) |
| 518 | snd_printd(KERN_INFO "dip index %d: %d != %d\n", |
| 519 | bi, pi, i); |
| 520 | if (bi == 0) /* byte index wrapped around */ |
| 521 | break; |
| 522 | } |
| 523 | snd_printd(KERN_INFO |
| 524 | "HDMI: DIP GP[%d] buf reported size=%d, written=%d\n", |
| 525 | i, size, j); |
| 526 | } |
| 527 | #endif |
| 528 | } |
| 529 | |
| 530 | static void hdmi_checksum_audio_infoframe(struct hdmi_audio_infoframe *ai) |
| 531 | { |
| 532 | u8 *bytes = (u8 *)ai; |
| 533 | u8 sum = 0; |
| 534 | int i; |
| 535 | |
| 536 | ai->checksum = 0; |
| 537 | |
| 538 | for (i = 0; i < sizeof(*ai); i++) |
| 539 | sum += bytes[i]; |
| 540 | |
| 541 | ai->checksum = -sum; |
| 542 | } |
| 543 | |
| 544 | static void hdmi_fill_audio_infoframe(struct hda_codec *codec, |
| 545 | hda_nid_t pin_nid, |
| 546 | struct hdmi_audio_infoframe *ai) |
| 547 | { |
| 548 | u8 *bytes = (u8 *)ai; |
| 549 | int i; |
| 550 | |
| 551 | hdmi_debug_dip_size(codec, pin_nid); |
| 552 | hdmi_clear_dip_buffers(codec, pin_nid); /* be paranoid */ |
| 553 | |
| 554 | hdmi_checksum_audio_infoframe(ai); |
| 555 | |
| 556 | hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); |
| 557 | for (i = 0; i < sizeof(*ai); i++) |
| 558 | hdmi_write_dip_byte(codec, pin_nid, bytes[i]); |
| 559 | } |
| 560 | |
| 561 | static bool hdmi_infoframe_uptodate(struct hda_codec *codec, hda_nid_t pin_nid, |
| 562 | struct hdmi_audio_infoframe *ai) |
| 563 | { |
| 564 | u8 *bytes = (u8 *)ai; |
| 565 | u8 val; |
| 566 | int i; |
| 567 | |
| 568 | if (snd_hda_codec_read(codec, pin_nid, 0, AC_VERB_GET_HDMI_DIP_XMIT, 0) |
| 569 | != AC_DIPXMIT_BEST) |
| 570 | return false; |
| 571 | |
| 572 | hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); |
| 573 | for (i = 0; i < sizeof(*ai); i++) { |
| 574 | val = snd_hda_codec_read(codec, pin_nid, 0, |
| 575 | AC_VERB_GET_HDMI_DIP_DATA, 0); |
| 576 | if (val != bytes[i]) |
| 577 | return false; |
| 578 | } |
| 579 | |
| 580 | return true; |
| 581 | } |
| 582 | |
| 583 | static void hdmi_setup_audio_infoframe(struct hda_codec *codec, hda_nid_t nid, |
| 584 | struct snd_pcm_substream *substream) |
| 585 | { |
| 586 | struct hdmi_spec *spec = codec->spec; |
| 587 | hda_nid_t pin_nid; |
| 588 | int i; |
| 589 | struct hdmi_audio_infoframe ai = { |
| 590 | .type = 0x84, |
| 591 | .ver = 0x01, |
| 592 | .len = 0x0a, |
| 593 | .CC02_CT47 = substream->runtime->channels - 1, |
| 594 | }; |
| 595 | |
| 596 | hdmi_setup_channel_allocation(codec, nid, &ai); |
| 597 | |
| 598 | for (i = 0; i < spec->num_pins; i++) { |
| 599 | if (spec->pin_cvt[i] != nid) |
| 600 | continue; |
| 601 | if (!spec->sink_eld[i].monitor_present) |
| 602 | continue; |
| 603 | |
| 604 | pin_nid = spec->pin[i]; |
| 605 | if (!hdmi_infoframe_uptodate(codec, pin_nid, &ai)) { |
Wu Fengguang | 2abbf43 | 2010-03-08 10:45:38 +0800 | [diff] [blame] | 606 | snd_printdd("hdmi_setup_audio_infoframe: " |
| 607 | "cvt=%d pin=%d channels=%d\n", |
| 608 | nid, pin_nid, |
| 609 | substream->runtime->channels); |
Wu Fengguang | 079d88c | 2010-03-08 10:44:23 +0800 | [diff] [blame] | 610 | hdmi_setup_channel_mapping(codec, pin_nid, &ai); |
| 611 | hdmi_stop_infoframe_trans(codec, pin_nid); |
| 612 | hdmi_fill_audio_infoframe(codec, pin_nid, &ai); |
| 613 | hdmi_start_infoframe_trans(codec, pin_nid); |
| 614 | } |
| 615 | } |
| 616 | } |
| 617 | |
| 618 | |
| 619 | /* |
| 620 | * Unsolicited events |
| 621 | */ |
| 622 | |
Takashi Iwai | 38faddb | 2010-07-28 14:21:55 +0200 | [diff] [blame] | 623 | static void hdmi_present_sense(struct hda_codec *codec, hda_nid_t pin_nid, |
| 624 | struct hdmi_eld *eld); |
| 625 | |
Wu Fengguang | 079d88c | 2010-03-08 10:44:23 +0800 | [diff] [blame] | 626 | static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res) |
| 627 | { |
| 628 | struct hdmi_spec *spec = codec->spec; |
| 629 | int tag = res >> AC_UNSOL_RES_TAG_SHIFT; |
| 630 | int pind = !!(res & AC_UNSOL_RES_PD); |
| 631 | int eldv = !!(res & AC_UNSOL_RES_ELDV); |
| 632 | int index; |
| 633 | |
| 634 | printk(KERN_INFO |
| 635 | "HDMI hot plug event: Pin=%d Presence_Detect=%d ELD_Valid=%d\n", |
| 636 | tag, pind, eldv); |
| 637 | |
| 638 | index = hda_node_index(spec->pin, tag); |
| 639 | if (index < 0) |
| 640 | return; |
| 641 | |
Takashi Iwai | 38faddb | 2010-07-28 14:21:55 +0200 | [diff] [blame] | 642 | if (spec->old_pin_detect) { |
| 643 | if (pind) |
| 644 | hdmi_present_sense(codec, tag, &spec->sink_eld[index]); |
| 645 | pind = spec->sink_eld[index].monitor_present; |
| 646 | } |
| 647 | |
Wu Fengguang | 079d88c | 2010-03-08 10:44:23 +0800 | [diff] [blame] | 648 | spec->sink_eld[index].monitor_present = pind; |
| 649 | spec->sink_eld[index].eld_valid = eldv; |
| 650 | |
| 651 | if (pind && eldv) { |
| 652 | hdmi_get_show_eld(codec, spec->pin[index], |
| 653 | &spec->sink_eld[index]); |
| 654 | /* TODO: do real things about ELD */ |
| 655 | } |
| 656 | } |
| 657 | |
| 658 | static void hdmi_non_intrinsic_event(struct hda_codec *codec, unsigned int res) |
| 659 | { |
| 660 | int tag = res >> AC_UNSOL_RES_TAG_SHIFT; |
| 661 | int subtag = (res & AC_UNSOL_RES_SUBTAG) >> AC_UNSOL_RES_SUBTAG_SHIFT; |
| 662 | int cp_state = !!(res & AC_UNSOL_RES_CP_STATE); |
| 663 | int cp_ready = !!(res & AC_UNSOL_RES_CP_READY); |
| 664 | |
| 665 | printk(KERN_INFO |
| 666 | "HDMI CP event: PIN=%d SUBTAG=0x%x CP_STATE=%d CP_READY=%d\n", |
| 667 | tag, |
| 668 | subtag, |
| 669 | cp_state, |
| 670 | cp_ready); |
| 671 | |
| 672 | /* TODO */ |
| 673 | if (cp_state) |
| 674 | ; |
| 675 | if (cp_ready) |
| 676 | ; |
| 677 | } |
| 678 | |
| 679 | |
| 680 | static void hdmi_unsol_event(struct hda_codec *codec, unsigned int res) |
| 681 | { |
| 682 | struct hdmi_spec *spec = codec->spec; |
| 683 | int tag = res >> AC_UNSOL_RES_TAG_SHIFT; |
| 684 | int subtag = (res & AC_UNSOL_RES_SUBTAG) >> AC_UNSOL_RES_SUBTAG_SHIFT; |
| 685 | |
| 686 | if (hda_node_index(spec->pin, tag) < 0) { |
| 687 | snd_printd(KERN_INFO "Unexpected HDMI event tag 0x%x\n", tag); |
| 688 | return; |
| 689 | } |
| 690 | |
| 691 | if (subtag == 0) |
| 692 | hdmi_intrinsic_event(codec, res); |
| 693 | else |
| 694 | hdmi_non_intrinsic_event(codec, res); |
| 695 | } |
| 696 | |
| 697 | /* |
| 698 | * Callbacks |
| 699 | */ |
| 700 | |
Takashi Iwai | 92f10b3 | 2010-08-03 14:21:00 +0200 | [diff] [blame^] | 701 | /* HBR should be Non-PCM, 8 channels */ |
| 702 | #define is_hbr_format(format) \ |
| 703 | ((format & AC_FMT_TYPE_NON_PCM) && (format & AC_FMT_CHAN_MASK) == 7) |
| 704 | |
Anssi Hannula | ea87d1c | 2010-08-03 13:28:58 +0300 | [diff] [blame] | 705 | static int hdmi_setup_stream(struct hda_codec *codec, hda_nid_t nid, |
Wu Fengguang | 079d88c | 2010-03-08 10:44:23 +0800 | [diff] [blame] | 706 | u32 stream_tag, int format) |
| 707 | { |
Anssi Hannula | ea87d1c | 2010-08-03 13:28:58 +0300 | [diff] [blame] | 708 | struct hdmi_spec *spec = codec->spec; |
Wu Fengguang | 079d88c | 2010-03-08 10:44:23 +0800 | [diff] [blame] | 709 | int tag; |
| 710 | int fmt; |
Anssi Hannula | ea87d1c | 2010-08-03 13:28:58 +0300 | [diff] [blame] | 711 | int pinctl; |
| 712 | int new_pinctl = 0; |
| 713 | int i; |
| 714 | |
| 715 | for (i = 0; i < spec->num_pins; i++) { |
| 716 | if (spec->pin_cvt[i] != nid) |
| 717 | continue; |
| 718 | if (!(snd_hda_query_pin_caps(codec, spec->pin[i]) & AC_PINCAP_HBR)) |
| 719 | continue; |
| 720 | |
| 721 | pinctl = snd_hda_codec_read(codec, spec->pin[i], 0, |
| 722 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 723 | |
| 724 | new_pinctl = pinctl & ~AC_PINCTL_EPT; |
Takashi Iwai | 92f10b3 | 2010-08-03 14:21:00 +0200 | [diff] [blame^] | 725 | if (is_hbr_format(format)) |
Anssi Hannula | ea87d1c | 2010-08-03 13:28:58 +0300 | [diff] [blame] | 726 | new_pinctl |= AC_PINCTL_EPT_HBR; |
| 727 | else |
| 728 | new_pinctl |= AC_PINCTL_EPT_NATIVE; |
| 729 | |
| 730 | snd_printdd("hdmi_setup_stream: " |
| 731 | "NID=0x%x, %spinctl=0x%x\n", |
| 732 | spec->pin[i], |
| 733 | pinctl == new_pinctl ? "" : "new-", |
| 734 | new_pinctl); |
| 735 | |
| 736 | if (pinctl != new_pinctl) |
| 737 | snd_hda_codec_write(codec, spec->pin[i], 0, |
| 738 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 739 | new_pinctl); |
| 740 | } |
| 741 | |
Takashi Iwai | 92f10b3 | 2010-08-03 14:21:00 +0200 | [diff] [blame^] | 742 | if (is_hbr_format(format) && !new_pinctl) { |
Anssi Hannula | ea87d1c | 2010-08-03 13:28:58 +0300 | [diff] [blame] | 743 | snd_printdd("hdmi_setup_stream: HBR is not supported\n"); |
| 744 | return -EINVAL; |
| 745 | } |
Wu Fengguang | 079d88c | 2010-03-08 10:44:23 +0800 | [diff] [blame] | 746 | |
| 747 | tag = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONV, 0) >> 4; |
| 748 | fmt = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_STREAM_FORMAT, 0); |
| 749 | |
| 750 | snd_printdd("hdmi_setup_stream: " |
| 751 | "NID=0x%x, %sstream=0x%x, %sformat=0x%x\n", |
| 752 | nid, |
| 753 | tag == stream_tag ? "" : "new-", |
| 754 | stream_tag, |
| 755 | fmt == format ? "" : "new-", |
| 756 | format); |
| 757 | |
| 758 | if (tag != stream_tag) |
| 759 | snd_hda_codec_write(codec, nid, 0, |
| 760 | AC_VERB_SET_CHANNEL_STREAMID, |
| 761 | stream_tag << 4); |
| 762 | if (fmt != format) |
| 763 | snd_hda_codec_write(codec, nid, 0, |
| 764 | AC_VERB_SET_STREAM_FORMAT, format); |
Anssi Hannula | ea87d1c | 2010-08-03 13:28:58 +0300 | [diff] [blame] | 765 | return 0; |
Wu Fengguang | 079d88c | 2010-03-08 10:44:23 +0800 | [diff] [blame] | 766 | } |
| 767 | |
| 768 | /* |
| 769 | * HDA/HDMI auto parsing |
| 770 | */ |
| 771 | |
| 772 | static int hdmi_read_pin_conn(struct hda_codec *codec, hda_nid_t pin_nid) |
| 773 | { |
| 774 | struct hdmi_spec *spec = codec->spec; |
| 775 | hda_nid_t conn_list[HDA_MAX_CONNECTIONS]; |
| 776 | int conn_len, curr; |
| 777 | int index; |
| 778 | |
| 779 | if (!(get_wcaps(codec, pin_nid) & AC_WCAP_CONN_LIST)) { |
| 780 | snd_printk(KERN_WARNING |
| 781 | "HDMI: pin %d wcaps %#x " |
| 782 | "does not support connection list\n", |
| 783 | pin_nid, get_wcaps(codec, pin_nid)); |
| 784 | return -EINVAL; |
| 785 | } |
| 786 | |
| 787 | conn_len = snd_hda_get_connections(codec, pin_nid, conn_list, |
| 788 | HDA_MAX_CONNECTIONS); |
| 789 | if (conn_len > 1) |
| 790 | curr = snd_hda_codec_read(codec, pin_nid, 0, |
| 791 | AC_VERB_GET_CONNECT_SEL, 0); |
| 792 | else |
| 793 | curr = 0; |
| 794 | |
| 795 | index = hda_node_index(spec->pin, pin_nid); |
| 796 | if (index < 0) |
| 797 | return -EINVAL; |
| 798 | |
| 799 | spec->pin_cvt[index] = conn_list[curr]; |
| 800 | |
| 801 | return 0; |
| 802 | } |
| 803 | |
| 804 | static void hdmi_present_sense(struct hda_codec *codec, hda_nid_t pin_nid, |
| 805 | struct hdmi_eld *eld) |
| 806 | { |
| 807 | int present = snd_hda_pin_sense(codec, pin_nid); |
| 808 | |
| 809 | eld->monitor_present = !!(present & AC_PINSENSE_PRESENCE); |
| 810 | eld->eld_valid = !!(present & AC_PINSENSE_ELDV); |
| 811 | |
| 812 | if (present & AC_PINSENSE_ELDV) |
| 813 | hdmi_get_show_eld(codec, pin_nid, eld); |
| 814 | } |
| 815 | |
| 816 | static int hdmi_add_pin(struct hda_codec *codec, hda_nid_t pin_nid) |
| 817 | { |
| 818 | struct hdmi_spec *spec = codec->spec; |
| 819 | |
| 820 | if (spec->num_pins >= MAX_HDMI_PINS) { |
| 821 | snd_printk(KERN_WARNING |
| 822 | "HDMI: no space for pin %d\n", pin_nid); |
Wu Fengguang | 3eaead5 | 2010-05-14 16:36:15 +0800 | [diff] [blame] | 823 | return -E2BIG; |
Wu Fengguang | 079d88c | 2010-03-08 10:44:23 +0800 | [diff] [blame] | 824 | } |
| 825 | |
| 826 | hdmi_present_sense(codec, pin_nid, &spec->sink_eld[spec->num_pins]); |
| 827 | |
| 828 | spec->pin[spec->num_pins] = pin_nid; |
| 829 | spec->num_pins++; |
| 830 | |
| 831 | /* |
| 832 | * It is assumed that converter nodes come first in the node list and |
| 833 | * hence have been registered and usable now. |
| 834 | */ |
| 835 | return hdmi_read_pin_conn(codec, pin_nid); |
| 836 | } |
| 837 | |
| 838 | static int hdmi_add_cvt(struct hda_codec *codec, hda_nid_t nid) |
| 839 | { |
| 840 | struct hdmi_spec *spec = codec->spec; |
| 841 | |
| 842 | if (spec->num_cvts >= MAX_HDMI_CVTS) { |
| 843 | snd_printk(KERN_WARNING |
| 844 | "HDMI: no space for converter %d\n", nid); |
Wu Fengguang | 3eaead5 | 2010-05-14 16:36:15 +0800 | [diff] [blame] | 845 | return -E2BIG; |
Wu Fengguang | 079d88c | 2010-03-08 10:44:23 +0800 | [diff] [blame] | 846 | } |
| 847 | |
| 848 | spec->cvt[spec->num_cvts] = nid; |
| 849 | spec->num_cvts++; |
| 850 | |
| 851 | return 0; |
| 852 | } |
| 853 | |
| 854 | static int hdmi_parse_codec(struct hda_codec *codec) |
| 855 | { |
| 856 | hda_nid_t nid; |
| 857 | int i, nodes; |
| 858 | |
| 859 | nodes = snd_hda_get_sub_nodes(codec, codec->afg, &nid); |
| 860 | if (!nid || nodes < 0) { |
| 861 | snd_printk(KERN_WARNING "HDMI: failed to get afg sub nodes\n"); |
| 862 | return -EINVAL; |
| 863 | } |
| 864 | |
| 865 | for (i = 0; i < nodes; i++, nid++) { |
| 866 | unsigned int caps; |
| 867 | unsigned int type; |
| 868 | |
| 869 | caps = snd_hda_param_read(codec, nid, AC_PAR_AUDIO_WIDGET_CAP); |
| 870 | type = get_wcaps_type(caps); |
| 871 | |
| 872 | if (!(caps & AC_WCAP_DIGITAL)) |
| 873 | continue; |
| 874 | |
| 875 | switch (type) { |
| 876 | case AC_WID_AUD_OUT: |
Wu Fengguang | 3eaead5 | 2010-05-14 16:36:15 +0800 | [diff] [blame] | 877 | hdmi_add_cvt(codec, nid); |
Wu Fengguang | 079d88c | 2010-03-08 10:44:23 +0800 | [diff] [blame] | 878 | break; |
| 879 | case AC_WID_PIN: |
| 880 | caps = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP); |
| 881 | if (!(caps & (AC_PINCAP_HDMI | AC_PINCAP_DP))) |
| 882 | continue; |
Wu Fengguang | 3eaead5 | 2010-05-14 16:36:15 +0800 | [diff] [blame] | 883 | hdmi_add_pin(codec, nid); |
Wu Fengguang | 079d88c | 2010-03-08 10:44:23 +0800 | [diff] [blame] | 884 | break; |
| 885 | } |
| 886 | } |
| 887 | |
| 888 | /* |
| 889 | * G45/IbexPeak don't support EPSS: the unsolicited pin hot plug event |
| 890 | * can be lost and presence sense verb will become inaccurate if the |
| 891 | * HDA link is powered off at hot plug or hw initialization time. |
| 892 | */ |
| 893 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 894 | if (!(snd_hda_param_read(codec, codec->afg, AC_PAR_POWER_STATE) & |
| 895 | AC_PWRST_EPSS)) |
| 896 | codec->bus->power_keep_link_on = 1; |
| 897 | #endif |
| 898 | |
| 899 | return 0; |
| 900 | } |
| 901 | |