aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/hda/patch_intelhdmi.c
diff options
context:
space:
mode:
authorWu Fengguang <fengguang.wu@intel.com>2009-10-30 06:40:40 -0400
committerTakashi Iwai <tiwai@suse.de>2009-10-30 06:40:40 -0400
commit6797cf2bfcbf2fa1fd05c0b785dc1402f73e2ce5 (patch)
tree3aa5792451add726ae3506b01a568a4a00920999 /sound/pci/hda/patch_intelhdmi.c
parent92608badc519a8c1f65d93743396517aaa582b53 (diff)
ALSA: hda - convert intelhdmi global references to local parameters
No behavior change. Signed-off-by: Wu Fengguang <fengguang.wu@intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/hda/patch_intelhdmi.c')
-rw-r--r--sound/pci/hda/patch_intelhdmi.c80
1 files changed, 43 insertions, 37 deletions
diff --git a/sound/pci/hda/patch_intelhdmi.c b/sound/pci/hda/patch_intelhdmi.c
index 7c23016fe8fa..2dfb1efc2d08 100644
--- a/sound/pci/hda/patch_intelhdmi.c
+++ b/sound/pci/hda/patch_intelhdmi.c
@@ -189,35 +189,36 @@ static struct cea_channel_speaker_allocation channel_allocations[] = {
189 */ 189 */
190 190
191#ifdef BE_PARANOID 191#ifdef BE_PARANOID
192static void hdmi_get_dip_index(struct hda_codec *codec, hda_nid_t nid, 192static void hdmi_get_dip_index(struct hda_codec *codec, hda_nid_t pin_nid,
193 int *packet_index, int *byte_index) 193 int *packet_index, int *byte_index)
194{ 194{
195 int val; 195 int val;
196 196
197 val = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_HDMI_DIP_INDEX, 0); 197 val = snd_hda_codec_read(codec, pin_nid, 0,
198 AC_VERB_GET_HDMI_DIP_INDEX, 0);
198 199
199 *packet_index = val >> 5; 200 *packet_index = val >> 5;
200 *byte_index = val & 0x1f; 201 *byte_index = val & 0x1f;
201} 202}
202#endif 203#endif
203 204
204static void hdmi_set_dip_index(struct hda_codec *codec, hda_nid_t nid, 205static void hdmi_set_dip_index(struct hda_codec *codec, hda_nid_t pin_nid,
205 int packet_index, int byte_index) 206 int packet_index, int byte_index)
206{ 207{
207 int val; 208 int val;
208 209
209 val = (packet_index << 5) | (byte_index & 0x1f); 210 val = (packet_index << 5) | (byte_index & 0x1f);
210 211
211 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_HDMI_DIP_INDEX, val); 212 snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_INDEX, val);
212} 213}
213 214
214static void hdmi_write_dip_byte(struct hda_codec *codec, hda_nid_t nid, 215static void hdmi_write_dip_byte(struct hda_codec *codec, hda_nid_t pin_nid,
215 unsigned char val) 216 unsigned char val)
216{ 217{
217 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_HDMI_DIP_DATA, val); 218 snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_DATA, val);
218} 219}
219 220
220static void hdmi_enable_output(struct hda_codec *codec) 221static void hdmi_enable_output(struct hda_codec *codec, hda_nid_t pin_nid)
221{ 222{
222 /* Unmute */ 223 /* Unmute */
223 if (get_wcaps(codec, pin_nid) & AC_WCAP_OUT_AMP) 224 if (get_wcaps(codec, pin_nid) & AC_WCAP_OUT_AMP)
@@ -231,7 +232,8 @@ static void hdmi_enable_output(struct hda_codec *codec)
231/* 232/*
232 * Enable Audio InfoFrame Transmission 233 * Enable Audio InfoFrame Transmission
233 */ 234 */
234static void hdmi_start_infoframe_trans(struct hda_codec *codec) 235static void hdmi_start_infoframe_trans(struct hda_codec *codec,
236 hda_nid_t pin_nid)
235{ 237{
236 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); 238 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0);
237 snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_XMIT, 239 snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_XMIT,
@@ -241,37 +243,40 @@ static void hdmi_start_infoframe_trans(struct hda_codec *codec)
241/* 243/*
242 * Disable Audio InfoFrame Transmission 244 * Disable Audio InfoFrame Transmission
243 */ 245 */
244static void hdmi_stop_infoframe_trans(struct hda_codec *codec) 246static void hdmi_stop_infoframe_trans(struct hda_codec *codec,
247 hda_nid_t pin_nid)
245{ 248{
246 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); 249 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0);
247 snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_XMIT, 250 snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_XMIT,
248 AC_DIPXMIT_DISABLE); 251 AC_DIPXMIT_DISABLE);
249} 252}
250 253
251static int hdmi_get_channel_count(struct hda_codec *codec) 254static int hdmi_get_channel_count(struct hda_codec *codec, hda_nid_t nid)
252{ 255{
253 return 1 + snd_hda_codec_read(codec, cvt_nid, 0, 256 return 1 + snd_hda_codec_read(codec, nid, 0,
254 AC_VERB_GET_CVT_CHAN_COUNT, 0); 257 AC_VERB_GET_CVT_CHAN_COUNT, 0);
255} 258}
256 259
257static void hdmi_set_channel_count(struct hda_codec *codec, int chs) 260static void hdmi_set_channel_count(struct hda_codec *codec,
261 hda_nid_t nid, int chs)
258{ 262{
259 snd_hda_codec_write(codec, cvt_nid, 0, 263 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CVT_CHAN_COUNT, chs - 1);
260 AC_VERB_SET_CVT_CHAN_COUNT, chs - 1);
261 264
262 if (chs != hdmi_get_channel_count(codec)) 265#ifdef CONFIG_SND_DEBUG_VERBOSE
266 if (chs != hdmi_get_channel_count(codec, nid))
263 snd_printd(KERN_INFO "HDMI channel count: expect %d, get %d\n", 267 snd_printd(KERN_INFO "HDMI channel count: expect %d, get %d\n",
264 chs, hdmi_get_channel_count(codec)); 268 chs, hdmi_get_channel_count(codec, nid));
269#endif
265} 270}
266 271
267static void hdmi_debug_channel_mapping(struct hda_codec *codec) 272static void hdmi_debug_channel_mapping(struct hda_codec *codec, hda_nid_t nid)
268{ 273{
269#ifdef CONFIG_SND_DEBUG_VERBOSE 274#ifdef CONFIG_SND_DEBUG_VERBOSE
270 int i; 275 int i;
271 int slot; 276 int slot;
272 277
273 for (i = 0; i < 8; i++) { 278 for (i = 0; i < 8; i++) {
274 slot = snd_hda_codec_read(codec, cvt_nid, 0, 279 slot = snd_hda_codec_read(codec, nid, 0,
275 AC_VERB_GET_HDMI_CHAN_SLOT, i); 280 AC_VERB_GET_HDMI_CHAN_SLOT, i);
276 printk(KERN_DEBUG "HDMI: ASP channel %d => slot %d\n", 281 printk(KERN_DEBUG "HDMI: ASP channel %d => slot %d\n",
277 slot >> 4, slot & 0x7); 282 slot >> 4, slot & 0x7);
@@ -293,7 +298,7 @@ static void hdmi_parse_eld(struct hda_codec *codec)
293 * Audio InfoFrame routines 298 * Audio InfoFrame routines
294 */ 299 */
295 300
296static void hdmi_debug_dip_size(struct hda_codec *codec) 301static void hdmi_debug_dip_size(struct hda_codec *codec, hda_nid_t pin_nid)
297{ 302{
298#ifdef CONFIG_SND_DEBUG_VERBOSE 303#ifdef CONFIG_SND_DEBUG_VERBOSE
299 int i; 304 int i;
@@ -310,7 +315,7 @@ static void hdmi_debug_dip_size(struct hda_codec *codec)
310#endif 315#endif
311} 316}
312 317
313static void hdmi_clear_dip_buffers(struct hda_codec *codec) 318static void hdmi_clear_dip_buffers(struct hda_codec *codec, hda_nid_t pin_nid)
314{ 319{
315#ifdef BE_PARANOID 320#ifdef BE_PARANOID
316 int i, j; 321 int i, j;
@@ -340,14 +345,15 @@ static void hdmi_clear_dip_buffers(struct hda_codec *codec)
340} 345}
341 346
342static void hdmi_fill_audio_infoframe(struct hda_codec *codec, 347static void hdmi_fill_audio_infoframe(struct hda_codec *codec,
343 struct hdmi_audio_infoframe *ai) 348 hda_nid_t pin_nid,
349 struct hdmi_audio_infoframe *ai)
344{ 350{
345 u8 *params = (u8 *)ai; 351 u8 *params = (u8 *)ai;
346 u8 sum = 0; 352 u8 sum = 0;
347 int i; 353 int i;
348 354
349 hdmi_debug_dip_size(codec); 355 hdmi_debug_dip_size(codec, pin_nid);
350 hdmi_clear_dip_buffers(codec); /* be paranoid */ 356 hdmi_clear_dip_buffers(codec, pin_nid); /* be paranoid */
351 357
352 for (i = 0; i < sizeof(ai); i++) 358 for (i = 0; i < sizeof(ai); i++)
353 sum += params[i]; 359 sum += params[i];
@@ -386,7 +392,7 @@ static void init_channel_allocations(void)
386 * 392 *
387 * TODO: it could select the wrong CA from multiple candidates. 393 * TODO: it could select the wrong CA from multiple candidates.
388*/ 394*/
389static int hdmi_setup_channel_allocation(struct hda_codec *codec, 395static int hdmi_setup_channel_allocation(struct hda_codec *codec, hda_nid_t nid,
390 struct hdmi_audio_infoframe *ai) 396 struct hdmi_audio_infoframe *ai)
391{ 397{
392 struct intel_hdmi_spec *spec = codec->spec; 398 struct intel_hdmi_spec *spec = codec->spec;
@@ -439,8 +445,8 @@ static int hdmi_setup_channel_allocation(struct hda_codec *codec,
439 return ai->CA; 445 return ai->CA;
440} 446}
441 447
442static void hdmi_setup_channel_mapping(struct hda_codec *codec, 448static void hdmi_setup_channel_mapping(struct hda_codec *codec, hda_nid_t nid,
443 struct hdmi_audio_infoframe *ai) 449 struct hdmi_audio_infoframe *ai)
444{ 450{
445 int i; 451 int i;
446 452
@@ -453,15 +459,15 @@ static void hdmi_setup_channel_mapping(struct hda_codec *codec,
453 */ 459 */
454 460
455 for (i = 0; i < 8; i++) 461 for (i = 0; i < 8; i++)
456 snd_hda_codec_write(codec, cvt_nid, 0, 462 snd_hda_codec_write(codec, nid, 0,
457 AC_VERB_SET_HDMI_CHAN_SLOT, 463 AC_VERB_SET_HDMI_CHAN_SLOT,
458 (i << 4) | i); 464 (i << 4) | i);
459 465
460 hdmi_debug_channel_mapping(codec); 466 hdmi_debug_channel_mapping(codec, nid);
461} 467}
462 468
463 469
464static void hdmi_setup_audio_infoframe(struct hda_codec *codec, 470static void hdmi_setup_audio_infoframe(struct hda_codec *codec, hda_nid_t nid,
465 struct snd_pcm_substream *substream) 471 struct snd_pcm_substream *substream)
466{ 472{
467 struct hdmi_audio_infoframe ai = { 473 struct hdmi_audio_infoframe ai = {
@@ -471,11 +477,11 @@ static void hdmi_setup_audio_infoframe(struct hda_codec *codec,
471 .CC02_CT47 = substream->runtime->channels - 1, 477 .CC02_CT47 = substream->runtime->channels - 1,
472 }; 478 };
473 479
474 hdmi_setup_channel_allocation(codec, &ai); 480 hdmi_setup_channel_allocation(codec, nid, &ai);
475 hdmi_setup_channel_mapping(codec, &ai); 481 hdmi_setup_channel_mapping(codec, nid, &ai);
476 482
477 hdmi_fill_audio_infoframe(codec, &ai); 483 hdmi_fill_audio_infoframe(codec, pin_nid, &ai);
478 hdmi_start_infoframe_trans(codec); 484 hdmi_start_infoframe_trans(codec, pin_nid);
479} 485}
480 486
481 487
@@ -553,7 +559,7 @@ static int intel_hdmi_playback_pcm_close(struct hda_pcm_stream *hinfo,
553{ 559{
554 struct intel_hdmi_spec *spec = codec->spec; 560 struct intel_hdmi_spec *spec = codec->spec;
555 561
556 hdmi_stop_infoframe_trans(codec); 562 hdmi_stop_infoframe_trans(codec, pin_nid);
557 563
558 return snd_hda_multi_out_dig_close(codec, &spec->multiout); 564 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
559} 565}
@@ -569,9 +575,9 @@ static int intel_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
569 snd_hda_multi_out_dig_prepare(codec, &spec->multiout, stream_tag, 575 snd_hda_multi_out_dig_prepare(codec, &spec->multiout, stream_tag,
570 format, substream); 576 format, substream);
571 577
572 hdmi_set_channel_count(codec, substream->runtime->channels); 578 hdmi_set_channel_count(codec, cvt_nid, substream->runtime->channels);
573 579
574 hdmi_setup_audio_infoframe(codec, substream); 580 hdmi_setup_audio_infoframe(codec, cvt_nid, substream);
575 581
576 return 0; 582 return 0;
577} 583}
@@ -619,7 +625,7 @@ static int intel_hdmi_build_controls(struct hda_codec *codec)
619 625
620static int intel_hdmi_init(struct hda_codec *codec) 626static int intel_hdmi_init(struct hda_codec *codec)
621{ 627{
622 hdmi_enable_output(codec); 628 hdmi_enable_output(codec, pin_nid);
623 629
624 snd_hda_codec_write(codec, pin_nid, 0, 630 snd_hda_codec_write(codec, pin_nid, 0,
625 AC_VERB_SET_UNSOLICITED_ENABLE, 631 AC_VERB_SET_UNSOLICITED_ENABLE,