@@ -105,12 +105,6 @@ struct hdmi_ops {
105105 int (* pin_get_eld )(struct hda_codec * codec , hda_nid_t pin_nid ,
106106 unsigned char * buf , int * eld_size );
107107
108- /* get and set channel assigned to each HDMI ASP (audio sample packet) slot */
109- int (* pin_get_slot_channel )(struct hda_codec * codec , hda_nid_t pin_nid ,
110- int asp_slot );
111- int (* pin_set_slot_channel )(struct hda_codec * codec , hda_nid_t pin_nid ,
112- int asp_slot , int channel );
113-
114108 void (* pin_setup_infoframe )(struct hda_codec * codec , hda_nid_t pin_nid ,
115109 int ca , int active_channels , int conn_type );
116110
@@ -596,20 +590,6 @@ static void hdmi_init_pin(struct hda_codec *codec, hda_nid_t pin_nid)
596590 AC_VERB_SET_PIN_WIDGET_CONTROL , pin_out );
597591}
598592
599- static int hdmi_get_channel_count (struct hda_codec * codec , hda_nid_t cvt_nid )
600- {
601- return 1 + snd_hda_codec_read (codec , cvt_nid , 0 ,
602- AC_VERB_GET_CVT_CHAN_COUNT , 0 );
603- }
604-
605- static void hdmi_set_channel_count (struct hda_codec * codec ,
606- hda_nid_t cvt_nid , int chs )
607- {
608- if (chs != hdmi_get_channel_count (codec , cvt_nid ))
609- snd_hda_codec_write (codec , cvt_nid , 0 ,
610- AC_VERB_SET_CVT_CHAN_COUNT , chs - 1 );
611- }
612-
613593/*
614594 * ELD proc files
615595 */
@@ -778,7 +758,8 @@ static void hdmi_debug_channel_mapping(struct hda_codec *codec,
778758 int channel ;
779759
780760 for (i = 0 ; i < 8 ; i ++ ) {
781- channel = spec -> ops .pin_get_slot_channel (codec , pin_nid , i );
761+ channel = spec -> chmap .ops .pin_get_slot_channel (
762+ & codec -> core , pin_nid , i );
782763 codec_dbg (codec , "HDMI: ASP channel %d => slot %d\n" ,
783764 channel , i );
784765 }
@@ -826,7 +807,8 @@ static void hdmi_std_setup_channel_mapping(struct hda_codec *codec,
826807 int slotsetup = non_pcm ? non_pcm_mapping [i ] : hdmi_channel_mapping [ca ][i ];
827808 int hdmi_slot = slotsetup & 0x0f ;
828809 int channel = (slotsetup & 0xf0 ) >> 4 ;
829- err = spec -> ops .pin_set_slot_channel (codec , pin_nid , hdmi_slot , channel );
810+ err = spec -> chmap .ops .pin_set_slot_channel (
811+ & codec -> core , pin_nid , hdmi_slot , channel );
830812 if (err ) {
831813 codec_dbg (codec , "HDMI: channel mapping failed\n" );
832814 break ;
@@ -953,8 +935,8 @@ static int hdmi_manual_setup_channel_mapping(struct hda_codec *codec,
953935 for (hdmi_slot = 0 ; hdmi_slot < 8 ; hdmi_slot ++ ) {
954936 int err ;
955937
956- err = spec -> ops .pin_set_slot_channel (codec , pin_nid , hdmi_slot ,
957- assignments [hdmi_slot ]);
938+ err = spec -> chmap . ops .pin_set_slot_channel (& codec -> core ,
939+ pin_nid , hdmi_slot , assignments [hdmi_slot ]);
958940 if (err )
959941 return - EINVAL ;
960942 }
@@ -990,22 +972,6 @@ static void hdmi_setup_channel_mapping(struct hda_codec *codec,
990972 hdmi_debug_channel_mapping (codec , pin_nid );
991973}
992974
993- static int hdmi_pin_set_slot_channel (struct hda_codec * codec , hda_nid_t pin_nid ,
994- int asp_slot , int channel )
995- {
996- return snd_hda_codec_write (codec , pin_nid , 0 ,
997- AC_VERB_SET_HDMI_CHAN_SLOT ,
998- (channel << 4 ) | asp_slot );
999- }
1000-
1001- static int hdmi_pin_get_slot_channel (struct hda_codec * codec , hda_nid_t pin_nid ,
1002- int asp_slot )
1003- {
1004- return (snd_hda_codec_read (codec , pin_nid , 0 ,
1005- AC_VERB_GET_HDMI_CHAN_SLOT ,
1006- asp_slot ) & 0xf0 ) >> 4 ;
1007- }
1008-
1009975/*
1010976 * Audio InfoFrame routines
1011977 */
@@ -1181,6 +1147,7 @@ static void hdmi_setup_audio_infoframe(struct hda_codec *codec,
11811147 bool non_pcm )
11821148{
11831149 struct hdmi_spec * spec = codec -> spec ;
1150+ struct hdac_chmap * chmap = & spec -> chmap ;
11841151 hda_nid_t pin_nid = per_pin -> pin_nid ;
11851152 int channels = per_pin -> channels ;
11861153 int active_channels ;
@@ -1207,7 +1174,8 @@ static void hdmi_setup_audio_infoframe(struct hda_codec *codec,
12071174 ordered_ca = get_channel_allocation_order (ca );
12081175 active_channels = channel_allocations [ordered_ca ].channels ;
12091176
1210- hdmi_set_channel_count (codec , per_pin -> cvt_nid , active_channels );
1177+ chmap -> ops .set_channel_count (& codec -> core , per_pin -> cvt_nid ,
1178+ active_channels );
12111179
12121180 /*
12131181 * always configure channel mapping, it may have been changed by the
@@ -2815,21 +2783,11 @@ static const struct hda_codec_ops generic_hdmi_patch_ops = {
28152783
28162784static const struct hdmi_ops generic_standard_hdmi_ops = {
28172785 .pin_get_eld = snd_hdmi_get_eld ,
2818- .pin_get_slot_channel = hdmi_pin_get_slot_channel ,
2819- .pin_set_slot_channel = hdmi_pin_set_slot_channel ,
28202786 .pin_setup_infoframe = hdmi_pin_setup_infoframe ,
28212787 .pin_hbr_setup = hdmi_pin_hbr_setup ,
28222788 .setup_stream = hdmi_setup_stream ,
28232789};
28242790
2825- static const struct hdac_chmap_ops chmap_ops = {
2826- .chmap_cea_alloc_validate_get_type = hdmi_chmap_cea_alloc_validate_get_type ,
2827- .cea_alloc_to_tlv_chmap = hdmi_cea_alloc_to_tlv_chmap ,
2828- .get_chmap = hdmi_get_chmap ,
2829- .set_chmap = hdmi_set_chmap ,
2830- .is_pcm_attached = is_hdmi_pcm_attached ,
2831- };
2832-
28332791static void intel_haswell_fixup_connect_list (struct hda_codec * codec ,
28342792 hda_nid_t nid )
28352793{
@@ -2931,8 +2889,15 @@ static int patch_generic_hdmi(struct hda_codec *codec)
29312889
29322890 spec -> ops = generic_standard_hdmi_ops ;
29332891 mutex_init (& spec -> pcm_lock );
2934- spec -> chmap .ops = chmap_ops ;
2935- spec -> chmap .hdac = & codec -> core ;
2892+ snd_hdac_register_chmap_ops (& codec -> core , & spec -> chmap );
2893+
2894+ spec -> chmap .ops .chmap_cea_alloc_validate_get_type =
2895+ hdmi_chmap_cea_alloc_validate_get_type ;
2896+ spec -> chmap .ops .cea_alloc_to_tlv_chmap = hdmi_cea_alloc_to_tlv_chmap ;
2897+ spec -> chmap .ops .get_chmap = hdmi_get_chmap ;
2898+ spec -> chmap .ops .set_chmap = hdmi_set_chmap ;
2899+ spec -> chmap .ops .is_pcm_attached = is_hdmi_pcm_attached ;
2900+
29362901 codec -> spec = spec ;
29372902 hdmi_array_init (spec , 4 );
29382903
@@ -3851,9 +3816,10 @@ static int atihdmi_paired_chmap_validate(int ca, int chs, unsigned char *map)
38513816 return 0 ;
38523817}
38533818
3854- static int atihdmi_pin_set_slot_channel (struct hda_codec * codec , hda_nid_t pin_nid ,
3855- int hdmi_slot , int stream_channel )
3819+ static int atihdmi_pin_set_slot_channel (struct hdac_device * hdac ,
3820+ hda_nid_t pin_nid , int hdmi_slot , int stream_channel )
38563821{
3822+ struct hda_codec * codec = container_of (hdac , struct hda_codec , core );
38573823 int verb ;
38583824 int ati_channel_setup = 0 ;
38593825
@@ -3886,9 +3852,10 @@ static int atihdmi_pin_set_slot_channel(struct hda_codec *codec, hda_nid_t pin_n
38863852 return snd_hda_codec_write (codec , pin_nid , 0 , verb , ati_channel_setup );
38873853}
38883854
3889- static int atihdmi_pin_get_slot_channel (struct hda_codec * codec , hda_nid_t pin_nid ,
3890- int asp_slot )
3855+ static int atihdmi_pin_get_slot_channel (struct hdac_device * hdac ,
3856+ hda_nid_t pin_nid , int asp_slot )
38913857{
3858+ struct hda_codec * codec = container_of (hdac , struct hda_codec , core );
38923859 bool was_odd = false;
38933860 int ati_asp_slot = asp_slot ;
38943861 int verb ;
@@ -4058,8 +4025,6 @@ static int patch_atihdmi(struct hda_codec *codec)
40584025 spec = codec -> spec ;
40594026
40604027 spec -> ops .pin_get_eld = atihdmi_pin_get_eld ;
4061- spec -> ops .pin_get_slot_channel = atihdmi_pin_get_slot_channel ;
4062- spec -> ops .pin_set_slot_channel = atihdmi_pin_set_slot_channel ;
40634028 spec -> ops .pin_setup_infoframe = atihdmi_pin_setup_infoframe ;
40644029 spec -> ops .pin_hbr_setup = atihdmi_pin_hbr_setup ;
40654030 spec -> ops .setup_stream = atihdmi_setup_stream ;
@@ -4071,6 +4036,10 @@ static int patch_atihdmi(struct hda_codec *codec)
40714036 spec -> chmap .ops .cea_alloc_to_tlv_chmap =
40724037 atihdmi_paired_cea_alloc_to_tlv_chmap ;
40734038 spec -> chmap .ops .chmap_validate = atihdmi_paired_chmap_validate ;
4039+ spec -> chmap .ops .pin_get_slot_channel =
4040+ atihdmi_pin_get_slot_channel ;
4041+ spec -> chmap .ops .pin_set_slot_channel =
4042+ atihdmi_pin_set_slot_channel ;
40744043 }
40754044
40764045 /* ATI/AMD converters do not advertise all of their capabilities */
0 commit comments