aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2011-02-11 06:17:30 -0500
committerTakashi Iwai <tiwai@suse.de>2011-02-11 06:18:57 -0500
commit2b203dbbcbac731b07bd0e27c3eda26a26aecb72 (patch)
treea89000e967bb774643e940710da6c95f0f944166
parent965b76d23ea354848dea8d34059d04e150dcd464 (diff)
ALSA: hda - Avoid cast with union data for HDMI audio infoframe
Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r--sound/pci/hda/patch_hdmi.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
index a58767736727..bb4930484ec4 100644
--- a/sound/pci/hda/patch_hdmi.c
+++ b/sound/pci/hda/patch_hdmi.c
@@ -110,6 +110,12 @@ struct dp_audio_infoframe {
110 u8 LFEPBL01_LSV36_DM_INH7; 110 u8 LFEPBL01_LSV36_DM_INH7;
111}; 111};
112 112
113union audio_infoframe {
114 struct hdmi_audio_infoframe hdmi;
115 struct dp_audio_infoframe dp;
116 u8 bytes[0];
117};
118
113/* 119/*
114 * CEA speaker placement: 120 * CEA speaker placement:
115 * 121 *
@@ -620,8 +626,7 @@ static void hdmi_setup_audio_infoframe(struct hda_codec *codec, hda_nid_t nid,
620 int channels = substream->runtime->channels; 626 int channels = substream->runtime->channels;
621 int ca; 627 int ca;
622 int i; 628 int i;
623 u8 ai[max(sizeof(struct hdmi_audio_infoframe), 629 union audio_infoframe ai;
624 sizeof(struct dp_audio_infoframe))];
625 630
626 ca = hdmi_channel_allocation(codec, nid, channels); 631 ca = hdmi_channel_allocation(codec, nid, channels);
627 632
@@ -633,11 +638,10 @@ static void hdmi_setup_audio_infoframe(struct hda_codec *codec, hda_nid_t nid,
633 638
634 pin_nid = spec->pin[i]; 639 pin_nid = spec->pin[i];
635 640
636 memset(ai, 0, sizeof(ai)); 641 memset(&ai, 0, sizeof(ai));
637 if (spec->sink_eld[i].conn_type == 0) { /* HDMI */ 642 if (spec->sink_eld[i].conn_type == 0) { /* HDMI */
638 struct hdmi_audio_infoframe *hdmi_ai; 643 struct hdmi_audio_infoframe *hdmi_ai = &ai.hdmi;
639 644
640 hdmi_ai = (struct hdmi_audio_infoframe *)ai;
641 hdmi_ai->type = 0x84; 645 hdmi_ai->type = 0x84;
642 hdmi_ai->ver = 0x01; 646 hdmi_ai->ver = 0x01;
643 hdmi_ai->len = 0x0a; 647 hdmi_ai->len = 0x0a;
@@ -645,9 +649,8 @@ static void hdmi_setup_audio_infoframe(struct hda_codec *codec, hda_nid_t nid,
645 hdmi_ai->CA = ca; 649 hdmi_ai->CA = ca;
646 hdmi_checksum_audio_infoframe(hdmi_ai); 650 hdmi_checksum_audio_infoframe(hdmi_ai);
647 } else if (spec->sink_eld[i].conn_type == 1) { /* DisplayPort */ 651 } else if (spec->sink_eld[i].conn_type == 1) { /* DisplayPort */
648 struct dp_audio_infoframe *dp_ai; 652 struct dp_audio_infoframe *dp_ai = &ai.dp;
649 653
650 dp_ai = (struct dp_audio_infoframe *)ai;
651 dp_ai->type = 0x84; 654 dp_ai->type = 0x84;
652 dp_ai->len = 0x1b; 655 dp_ai->len = 0x1b;
653 dp_ai->ver = 0x11 << 2; 656 dp_ai->ver = 0x11 << 2;
@@ -664,7 +667,8 @@ static void hdmi_setup_audio_infoframe(struct hda_codec *codec, hda_nid_t nid,
664 * sizeof(*dp_ai) to avoid partial match/update problems when 667 * sizeof(*dp_ai) to avoid partial match/update problems when
665 * the user switches between HDMI/DP monitors. 668 * the user switches between HDMI/DP monitors.
666 */ 669 */
667 if (!hdmi_infoframe_uptodate(codec, pin_nid, ai, sizeof(ai))) { 670 if (!hdmi_infoframe_uptodate(codec, pin_nid, ai.bytes,
671 sizeof(ai))) {
668 snd_printdd("hdmi_setup_audio_infoframe: " 672 snd_printdd("hdmi_setup_audio_infoframe: "
669 "cvt=%d pin=%d channels=%d\n", 673 "cvt=%d pin=%d channels=%d\n",
670 nid, pin_nid, 674 nid, pin_nid,
@@ -672,7 +676,7 @@ static void hdmi_setup_audio_infoframe(struct hda_codec *codec, hda_nid_t nid,
672 hdmi_setup_channel_mapping(codec, pin_nid, ca); 676 hdmi_setup_channel_mapping(codec, pin_nid, ca);
673 hdmi_stop_infoframe_trans(codec, pin_nid); 677 hdmi_stop_infoframe_trans(codec, pin_nid);
674 hdmi_fill_audio_infoframe(codec, pin_nid, 678 hdmi_fill_audio_infoframe(codec, pin_nid,
675 ai, sizeof(ai)); 679 ai.bytes, sizeof(ai));
676 hdmi_start_infoframe_trans(codec, pin_nid); 680 hdmi_start_infoframe_trans(codec, pin_nid);
677 } 681 }
678 } 682 }