aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorWu Fengguang <fengguang.wu@intel.com>2009-11-17 23:38:04 -0500
committerTakashi Iwai <tiwai@suse.de>2009-11-18 01:43:12 -0500
commit978be6d711be237e0344eca21c3922ae88a240bc (patch)
treeaa1f40beeea1f27c2a4ac8c7a9a04d72957d2d75 /sound
parent3f54aa5091f48e9d8ce6e99b248449d08acccb26 (diff)
ALSA: intelhdmi - separate out infoframe checksum routine
And make it right when called for more than one times. Signed-off-by: Wu Fengguang <fengguang.wu@intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r--sound/pci/hda/patch_intelhdmi.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/sound/pci/hda/patch_intelhdmi.c b/sound/pci/hda/patch_intelhdmi.c
index c5fd011567fb..d68dba9ac113 100644
--- a/sound/pci/hda/patch_intelhdmi.c
+++ b/sound/pci/hda/patch_intelhdmi.c
@@ -508,24 +508,35 @@ static void hdmi_clear_dip_buffers(struct hda_codec *codec, hda_nid_t pin_nid)
508#endif 508#endif
509} 509}
510 510
511static void hdmi_checksum_audio_infoframe(struct hdmi_audio_infoframe *ai)
512{
513 u8 *bytes = (u8 *)ai;
514 u8 sum = 0;
515 int i;
516
517 ai->checksum = 0;
518
519 for (i = 0; i < sizeof(*ai); i++)
520 sum += bytes[i];
521
522 ai->checksum = - sum;
523}
524
511static void hdmi_fill_audio_infoframe(struct hda_codec *codec, 525static void hdmi_fill_audio_infoframe(struct hda_codec *codec,
512 hda_nid_t pin_nid, 526 hda_nid_t pin_nid,
513 struct hdmi_audio_infoframe *ai) 527 struct hdmi_audio_infoframe *ai)
514{ 528{
515 u8 *params = (u8 *)ai; 529 u8 *bytes = (u8 *)ai;
516 u8 sum = 0;
517 int i; 530 int i;
518 531
519 hdmi_debug_dip_size(codec, pin_nid); 532 hdmi_debug_dip_size(codec, pin_nid);
520 hdmi_clear_dip_buffers(codec, pin_nid); /* be paranoid */ 533 hdmi_clear_dip_buffers(codec, pin_nid); /* be paranoid */
521 534
522 for (i = 0; i < sizeof(*ai); i++) 535 hdmi_checksum_audio_infoframe(ai);
523 sum += params[i];
524 ai->checksum = - sum;
525 536
526 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); 537 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0);
527 for (i = 0; i < sizeof(*ai); i++) 538 for (i = 0; i < sizeof(*ai); i++)
528 hdmi_write_dip_byte(codec, pin_nid, params[i]); 539 hdmi_write_dip_byte(codec, pin_nid, bytes[i]);
529} 540}
530 541
531/* 542/*