@@ -3348,6 +3348,8 @@ static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t pin,
33483348
33493349#define MAX_AUTO_DACS 5
33503350
3351+ #define DAC_SLAVE_FLAG 0x8000 /* filled dac is a slave */
3352+
33513353/* fill analog DAC list from the widget tree */
33523354static int fill_cx_auto_dacs (struct hda_codec * codec , hda_nid_t * dacs )
33533355{
@@ -3370,16 +3372,26 @@ static int fill_cx_auto_dacs(struct hda_codec *codec, hda_nid_t *dacs)
33703372/* fill pin_dac_pair list from the pin and dac list */
33713373static int fill_dacs_for_pins (struct hda_codec * codec , hda_nid_t * pins ,
33723374 int num_pins , hda_nid_t * dacs , int * rest ,
3373- struct pin_dac_pair * filled , int type )
3375+ struct pin_dac_pair * filled , int nums ,
3376+ int type )
33743377{
3375- int i , nums ;
3378+ int i , start = nums ;
33763379
3377- nums = 0 ;
3378- for (i = 0 ; i < num_pins ; i ++ ) {
3380+ for (i = 0 ; i < num_pins ; i ++ , nums ++ ) {
33793381 filled [nums ].pin = pins [i ];
33803382 filled [nums ].type = type ;
33813383 filled [nums ].dac = get_unassigned_dac (codec , pins [i ], dacs , rest );
3382- nums ++ ;
3384+ if (filled [nums ].dac )
3385+ continue ;
3386+ if (filled [start ].dac && get_connection_index (codec , pins [i ], filled [start ].dac ) >= 0 ) {
3387+ filled [nums ].dac = filled [start ].dac | DAC_SLAVE_FLAG ;
3388+ continue ;
3389+ }
3390+ if (filled [0 ].dac && get_connection_index (codec , pins [i ], filled [0 ].dac ) >= 0 ) {
3391+ filled [nums ].dac = filled [0 ].dac | DAC_SLAVE_FLAG ;
3392+ continue ;
3393+ }
3394+ snd_printdd ("Failed to find a DAC for pin 0x%x" , pins [i ]);
33833395 }
33843396 return nums ;
33853397}
@@ -3395,19 +3407,19 @@ static void cx_auto_parse_output(struct hda_codec *codec)
33953407 rest = fill_cx_auto_dacs (codec , dacs );
33963408 /* parse all analog output pins */
33973409 nums = fill_dacs_for_pins (codec , cfg -> line_out_pins , cfg -> line_outs ,
3398- dacs , & rest , spec -> dac_info ,
3399- AUTO_PIN_LINE_OUT );
3400- nums + = fill_dacs_for_pins (codec , cfg -> hp_pins , cfg -> hp_outs ,
3401- dacs , & rest , spec -> dac_info + nums ,
3402- AUTO_PIN_HP_OUT );
3403- nums + = fill_dacs_for_pins (codec , cfg -> speaker_pins , cfg -> speaker_outs ,
3404- dacs , & rest , spec -> dac_info + nums ,
3405- AUTO_PIN_SPEAKER_OUT );
3410+ dacs , & rest , spec -> dac_info , 0 ,
3411+ AUTO_PIN_LINE_OUT );
3412+ nums = fill_dacs_for_pins (codec , cfg -> hp_pins , cfg -> hp_outs ,
3413+ dacs , & rest , spec -> dac_info , nums ,
3414+ AUTO_PIN_HP_OUT );
3415+ nums = fill_dacs_for_pins (codec , cfg -> speaker_pins , cfg -> speaker_outs ,
3416+ dacs , & rest , spec -> dac_info , nums ,
3417+ AUTO_PIN_SPEAKER_OUT );
34063418 spec -> dac_info_filled = nums ;
34073419 /* fill multiout struct */
34083420 for (i = 0 ; i < nums ; i ++ ) {
34093421 hda_nid_t dac = spec -> dac_info [i ].dac ;
3410- if (!dac )
3422+ if (!dac || ( dac & DAC_SLAVE_FLAG ) )
34113423 continue ;
34123424 switch (spec -> dac_info [i ].type ) {
34133425 case AUTO_PIN_LINE_OUT :
@@ -3862,7 +3874,7 @@ static void cx_auto_parse_input(struct hda_codec *codec)
38623874 }
38633875 if (imux -> num_items >= 2 && cfg -> num_inputs == imux -> num_items )
38643876 cx_auto_check_auto_mic (codec );
3865- if (imux -> num_items > 1 && ! spec -> auto_mic ) {
3877+ if (imux -> num_items > 1 ) {
38663878 for (i = 1 ; i < imux -> num_items ; i ++ ) {
38673879 if (spec -> imux_info [i ].adc != spec -> imux_info [0 ].adc ) {
38683880 spec -> adc_switching = 1 ;
@@ -4035,6 +4047,8 @@ static void cx_auto_init_output(struct hda_codec *codec)
40354047 nid = spec -> dac_info [i ].dac ;
40364048 if (!nid )
40374049 nid = spec -> multiout .dac_nids [0 ];
4050+ else if (nid & DAC_SLAVE_FLAG )
4051+ nid &= ~DAC_SLAVE_FLAG ;
40384052 select_connection (codec , spec -> dac_info [i ].pin , nid );
40394053 }
40404054 if (spec -> auto_mute ) {
@@ -4167,9 +4181,11 @@ static int try_add_pb_volume(struct hda_codec *codec, hda_nid_t dac,
41674181 hda_nid_t pin , const char * name , int idx )
41684182{
41694183 unsigned int caps ;
4170- caps = query_amp_caps (codec , dac , HDA_OUTPUT );
4171- if (caps & AC_AMPCAP_NUM_STEPS )
4172- return cx_auto_add_pb_volume (codec , dac , name , idx );
4184+ if (dac && !(dac & DAC_SLAVE_FLAG )) {
4185+ caps = query_amp_caps (codec , dac , HDA_OUTPUT );
4186+ if (caps & AC_AMPCAP_NUM_STEPS )
4187+ return cx_auto_add_pb_volume (codec , dac , name , idx );
4188+ }
41734189 caps = query_amp_caps (codec , pin , HDA_OUTPUT );
41744190 if (caps & AC_AMPCAP_NUM_STEPS )
41754191 return cx_auto_add_pb_volume (codec , pin , name , idx );
@@ -4191,8 +4207,7 @@ static int cx_auto_build_output_controls(struct hda_codec *codec)
41914207 for (i = 0 ; i < spec -> dac_info_filled ; i ++ ) {
41924208 const char * label ;
41934209 int idx , type ;
4194- if (!spec -> dac_info [i ].dac )
4195- continue ;
4210+ hda_nid_t dac = spec -> dac_info [i ].dac ;
41964211 type = spec -> dac_info [i ].type ;
41974212 if (type == AUTO_PIN_LINE_OUT )
41984213 type = spec -> autocfg .line_out_type ;
@@ -4211,7 +4226,7 @@ static int cx_auto_build_output_controls(struct hda_codec *codec)
42114226 idx = num_spk ++ ;
42124227 break ;
42134228 }
4214- err = try_add_pb_volume (codec , spec -> dac_info [ i ]. dac ,
4229+ err = try_add_pb_volume (codec , dac ,
42154230 spec -> dac_info [i ].pin ,
42164231 label , idx );
42174232 if (err < 0 )
0 commit comments