@@ -3372,18 +3372,26 @@ static int fill_cx_auto_dacs(struct hda_codec *codec, hda_nid_t *dacs)
3372
3372
/* fill pin_dac_pair list from the pin and dac list */
3373
3373
static int fill_dacs_for_pins (struct hda_codec * codec , hda_nid_t * pins ,
3374
3374
int num_pins , hda_nid_t * dacs , int * rest ,
3375
- struct pin_dac_pair * filled , int type )
3375
+ struct pin_dac_pair * filled , int nums ,
3376
+ int type )
3376
3377
{
3377
- int i , nums ;
3378
+ int i , start = nums ;
3378
3379
3379
- nums = 0 ;
3380
- for (i = 0 ; i < num_pins ; i ++ ) {
3380
+ for (i = 0 ; i < num_pins ; i ++ , nums ++ ) {
3381
3381
filled [nums ].pin = pins [i ];
3382
3382
filled [nums ].type = type ;
3383
3383
filled [nums ].dac = get_unassigned_dac (codec , pins [i ], dacs , rest );
3384
- if (!filled [nums ].dac && i > 0 && filled [0 ].dac )
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 ) {
3385
3391
filled [nums ].dac = filled [0 ].dac | DAC_SLAVE_FLAG ;
3386
- nums ++ ;
3392
+ continue ;
3393
+ }
3394
+ snd_printdd ("Failed to find a DAC for pin 0x%x" , pins [i ]);
3387
3395
}
3388
3396
return nums ;
3389
3397
}
@@ -3399,14 +3407,14 @@ static void cx_auto_parse_output(struct hda_codec *codec)
3399
3407
rest = fill_cx_auto_dacs (codec , dacs );
3400
3408
/* parse all analog output pins */
3401
3409
nums = fill_dacs_for_pins (codec , cfg -> line_out_pins , cfg -> line_outs ,
3402
- dacs , & rest , spec -> dac_info ,
3403
- AUTO_PIN_LINE_OUT );
3404
- nums + = fill_dacs_for_pins (codec , cfg -> hp_pins , cfg -> hp_outs ,
3405
- dacs , & rest , spec -> dac_info + nums ,
3406
- AUTO_PIN_HP_OUT );
3407
- nums + = fill_dacs_for_pins (codec , cfg -> speaker_pins , cfg -> speaker_outs ,
3408
- dacs , & rest , spec -> dac_info + nums ,
3409
- 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 );
3410
3418
spec -> dac_info_filled = nums ;
3411
3419
/* fill multiout struct */
3412
3420
for (i = 0 ; i < nums ; i ++ ) {
@@ -4173,9 +4181,11 @@ static int try_add_pb_volume(struct hda_codec *codec, hda_nid_t dac,
4173
4181
hda_nid_t pin , const char * name , int idx )
4174
4182
{
4175
4183
unsigned int caps ;
4176
- caps = query_amp_caps (codec , dac , HDA_OUTPUT );
4177
- if (caps & AC_AMPCAP_NUM_STEPS )
4178
- 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
+ }
4179
4189
caps = query_amp_caps (codec , pin , HDA_OUTPUT );
4180
4190
if (caps & AC_AMPCAP_NUM_STEPS )
4181
4191
return cx_auto_add_pb_volume (codec , pin , name , idx );
@@ -4198,8 +4208,6 @@ static int cx_auto_build_output_controls(struct hda_codec *codec)
4198
4208
const char * label ;
4199
4209
int idx , type ;
4200
4210
hda_nid_t dac = spec -> dac_info [i ].dac ;
4201
- if (!dac || (dac & DAC_SLAVE_FLAG ))
4202
- continue ;
4203
4211
type = spec -> dac_info [i ].type ;
4204
4212
if (type == AUTO_PIN_LINE_OUT )
4205
4213
type = spec -> autocfg .line_out_type ;
0 commit comments