aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/hda/patch_hdmi.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2012-06-15 06:45:43 -0400
committerTakashi Iwai <tiwai@suse.de>2012-06-15 06:53:39 -0400
commit4f0110ced1b5d61e6df4871f6f800a9d3678bf26 (patch)
treebbdeee1db0755e90ff129a59203542916341b3ec /sound/pci/hda/patch_hdmi.c
parent4b6ace9e7176d93f819cec9df47faadaaceead4b (diff)
ALSA: hda - Merge ATI/VIA HDMI simple init functions
Just a minor code cleanup to use the same function for both AMD and VIA simple_hdmi*(). Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/hda/patch_hdmi.c')
-rw-r--r--sound/pci/hda/patch_hdmi.c56
1 files changed, 22 insertions, 34 deletions
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
index 8e7333b07b58..c9d0c98bbe86 100644
--- a/sound/pci/hda/patch_hdmi.c
+++ b/sound/pci/hda/patch_hdmi.c
@@ -1412,6 +1412,24 @@ static int simple_playback_build_controls(struct hda_codec *codec)
1412 return 0; 1412 return 0;
1413} 1413}
1414 1414
1415static int simple_playback_init(struct hda_codec *codec)
1416{
1417 struct hdmi_spec *spec = codec->spec;
1418 int i;
1419
1420 for (i = 0; i < spec->num_pins; i++) {
1421 snd_hda_codec_write(codec, spec->pins[i].pin_nid, 0,
1422 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
1423 /* some codecs require to unmute the pin */
1424 if (get_wcaps(codec, spec->pins[i].pin_nid) & AC_WCAP_OUT_AMP)
1425 snd_hda_codec_write(codec, spec->pins[i].pin_nid, 0,
1426 AC_VERB_SET_AMP_GAIN_MUTE,
1427 AMP_OUT_UNMUTE);
1428 }
1429 snd_hda_jack_report_sync(codec);
1430 return 0;
1431}
1432
1415static void simple_playback_free(struct hda_codec *codec) 1433static void simple_playback_free(struct hda_codec *codec)
1416{ 1434{
1417 struct hdmi_spec *spec = codec->spec; 1435 struct hdmi_spec *spec = codec->spec;
@@ -1831,29 +1849,10 @@ static const struct hda_pcm_stream atihdmi_pcm_digital_playback = {
1831 }, 1849 },
1832}; 1850};
1833 1851
1834static const struct hda_verb atihdmi_basic_init[] = {
1835 /* enable digital output on pin widget */
1836 { 0x03, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1837 {} /* terminator */
1838};
1839
1840static int atihdmi_init(struct hda_codec *codec)
1841{
1842 struct hdmi_spec *spec = codec->spec;
1843
1844 snd_hda_sequence_write(codec, atihdmi_basic_init);
1845 /* SI codec requires to unmute the pin */
1846 if (get_wcaps(codec, spec->pins[0].pin_nid) & AC_WCAP_OUT_AMP)
1847 snd_hda_codec_write(codec, spec->pins[0].pin_nid, 0,
1848 AC_VERB_SET_AMP_GAIN_MUTE,
1849 AMP_OUT_UNMUTE);
1850 return 0;
1851}
1852
1853static const struct hda_codec_ops atihdmi_patch_ops = { 1852static const struct hda_codec_ops atihdmi_patch_ops = {
1854 .build_controls = simple_playback_build_controls, 1853 .build_controls = simple_playback_build_controls,
1855 .build_pcms = simple_playback_build_pcms, 1854 .build_pcms = simple_playback_build_pcms,
1856 .init = atihdmi_init, 1855 .init = simple_playback_init,
1857 .free = simple_playback_free, 1856 .free = simple_playback_free,
1858}; 1857};
1859 1858
@@ -1872,6 +1871,7 @@ static int patch_atihdmi(struct hda_codec *codec)
1872 spec->multiout.max_channels = 2; 1871 spec->multiout.max_channels = 2;
1873 spec->multiout.dig_out_nid = ATIHDMI_CVT_NID; 1872 spec->multiout.dig_out_nid = ATIHDMI_CVT_NID;
1874 spec->num_cvts = 1; 1873 spec->num_cvts = 1;
1874 spec->num_pins = 1;
1875 spec->cvts[0].cvt_nid = ATIHDMI_CVT_NID; 1875 spec->cvts[0].cvt_nid = ATIHDMI_CVT_NID;
1876 spec->pins[0].pin_nid = ATIHDMI_PIN_NID; 1876 spec->pins[0].pin_nid = ATIHDMI_PIN_NID;
1877 spec->pcm_playback = &atihdmi_pcm_digital_playback; 1877 spec->pcm_playback = &atihdmi_pcm_digital_playback;
@@ -1885,23 +1885,10 @@ static int patch_atihdmi(struct hda_codec *codec)
1885#define VIAHDMI_CVT_NID 0x02 /* audio converter1 */ 1885#define VIAHDMI_CVT_NID 0x02 /* audio converter1 */
1886#define VIAHDMI_PIN_NID 0x03 /* HDMI output pin1 */ 1886#define VIAHDMI_PIN_NID 0x03 /* HDMI output pin1 */
1887 1887
1888static struct hda_verb viahdmi_basic_init[] = {
1889 /* enable digital output on pin widget */
1890 { VIAHDMI_PIN_NID, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1891 {} /* terminator */
1892};
1893
1894static int via_hdmi_init(struct hda_codec *codec)
1895{
1896 snd_hda_sequence_write(codec, viahdmi_basic_init);
1897 snd_hda_jack_report_sync(codec);
1898 return 0;
1899}
1900
1901static const struct hda_codec_ops via_hdmi_patch_ops = { 1888static const struct hda_codec_ops via_hdmi_patch_ops = {
1902 .build_controls = simple_playback_build_controls, 1889 .build_controls = simple_playback_build_controls,
1903 .build_pcms = simple_playback_build_pcms, 1890 .build_pcms = simple_playback_build_pcms,
1904 .init = via_hdmi_init, 1891 .init = simple_playback_init,
1905 .free = simple_playback_free, 1892 .free = simple_playback_free,
1906 .unsol_event = simple_hdmi_unsol_event, 1893 .unsol_event = simple_hdmi_unsol_event,
1907}; 1894};
@@ -1930,6 +1917,7 @@ static int patch_via_hdmi(struct hda_codec *codec)
1930 spec->multiout.max_channels = 2; 1917 spec->multiout.max_channels = 2;
1931 spec->multiout.dig_out_nid = VIAHDMI_CVT_NID; /* pure-digital case */ 1918 spec->multiout.dig_out_nid = VIAHDMI_CVT_NID; /* pure-digital case */
1932 spec->num_cvts = 1; 1919 spec->num_cvts = 1;
1920 spec->num_pins = 1;
1933 spec->cvts[0].cvt_nid = VIAHDMI_CVT_NID; 1921 spec->cvts[0].cvt_nid = VIAHDMI_CVT_NID;
1934 spec->pins[0].pin_nid = VIAHDMI_PIN_NID; 1922 spec->pins[0].pin_nid = VIAHDMI_PIN_NID;
1935 spec->pcm_playback = &via_hdmi_digital_playback; 1923 spec->pcm_playback = &via_hdmi_digital_playback;