43
43
typedef uint16_t hda_nid_t ;
44
44
45
45
struct hda_gnode {
46
- hda_nid_t nid ; /* NID of this widget */
47
- unsigned short nconns ; /* number of input connections */
46
+ hda_nid_t nid ; /* NID of this widget */
47
+ unsigned short nconns ; /* number of input connections */
48
48
hda_nid_t conn_list [HDA_MAX_CONNECTIONS ];
49
49
unsigned int wid_caps ; /* widget capabilities */
50
- unsigned char type ; /* widget type */
51
- unsigned char pin_ctl ; /* pin controls */
52
- unsigned char checked ; /* the flag indicates that the node is already parsed */
50
+ unsigned char type ; /* widget type */
51
+ unsigned char pin_ctl ; /* pin controls */
52
+ unsigned char checked ; /* the flag indicates that the node is already parsed */
53
53
unsigned int pin_caps ; /* pin widget capabilities */
54
- unsigned int def_cfg ; /* default configuration */
55
- unsigned int amp_out_caps ; /* AMP out capabilities */
56
- unsigned int amp_in_caps ; /* AMP in capabilities */
57
- unsigned long supported_formats ; // format_val
54
+ unsigned int def_cfg ; /* default configuration */
55
+ unsigned int amp_out_caps ;/* AMP out capabilities */
56
+ unsigned int amp_in_caps ; /* AMP in capabilities */
57
+ unsigned long supported_formats ; /* format_val */
58
58
};
59
59
60
60
struct pcm_vol_s {
@@ -74,8 +74,8 @@ struct intelhd_card_s
74
74
hda_nid_t afg_root_nodenum ;
75
75
int afg_num_nodes ;
76
76
struct hda_gnode * afg_nodes ;
77
- unsigned int def_amp_out_caps ;
78
- unsigned int def_amp_in_caps ;
77
+ unsigned int def_amp_out_caps ; /* default amp caps set by audio function group */
78
+ unsigned int def_amp_in_caps ; /* default amp caps set by audio function group */
79
79
struct hda_gnode * dac_node [2 ]; // DAC nodes
80
80
struct hda_gnode * out_pin_node [MAX_PCM_VOLS ]; // Output pin (Line-Out) nodes
81
81
unsigned int pcm_num_vols ; // number of PCM volumes
@@ -386,6 +386,8 @@ static int hda_get_connections(struct intelhd_card_s *card, hda_nid_t nid, hda_n
386
386
return conns ;
387
387
}
388
388
389
+ /* add a widget to the widget array */
390
+
389
391
static int hda_add_node (struct intelhd_card_s * card , struct hda_gnode * node , hda_nid_t nid )
390
392
///////////////////////////////////////////////////////////////////////////////////////////
391
393
{
@@ -542,12 +544,14 @@ static int parse_output_path(struct intelhd_card_s *card,struct hda_gnode *node,
542
544
hda_codec_write (card , node -> nid , 0 , AC_VERB_SET_POWER_STATE , 0 );
543
545
#endif
544
546
node -> checked = 1 ;
547
+ /* is node an "Audio Out" widget (=DAC)? */
545
548
if (node -> type == AC_WID_AUD_OUT ) {
546
549
if (node -> wid_caps & AC_WCAP_DIGITAL )
547
550
return 0 ;
548
551
if (card -> dac_node [dac_idx ])
549
552
return (node == card -> dac_node [dac_idx ]);
550
553
554
+ /* store (one of) the volume nodes if the DAC has an output amplifier */
551
555
card -> dac_node [dac_idx ] = node ;
552
556
if ((node -> wid_caps & AC_WCAP_OUT_AMP ) && (card -> pcm_num_vols < MAX_PCM_VOLS )){
553
557
card -> pcm_vols [card -> pcm_num_vols ].node = node ;
@@ -569,9 +573,11 @@ static int parse_output_path(struct intelhd_card_s *card,struct hda_gnode *node,
569
573
select_input_connection (card , node , i );
570
574
hda_unmute_input (card , node , i );
571
575
hda_unmute_output (card , node );
576
+ /* if the selected DAC has no OUT amplifier, use this node to set volume */
572
577
if ( card -> dac_node [dac_idx ] && ( card -> pcm_num_vols < MAX_PCM_VOLS ) && !( card -> dac_node [dac_idx ]-> wid_caps & AC_WCAP_OUT_AMP ) ) {
573
- if (( node -> wid_caps & AC_WCAP_IN_AMP ) || ( node -> wid_caps & AC_WCAP_OUT_AMP )) {
578
+ if ( node -> wid_caps & ( AC_WCAP_IN_AMP | AC_WCAP_OUT_AMP ) ) {
574
579
int n = card -> pcm_num_vols ;
580
+ dbgprintf (("parse_output_path: widget %u, index %u used for volume setting\n" , node -> nid , i ));
575
581
card -> pcm_vols [n ].node = node ;
576
582
card -> pcm_vols [n ].index = i ;
577
583
card -> pcm_num_vols ++ ;
@@ -953,7 +959,10 @@ static unsigned int hda_mixer_init(struct intelhd_card_s *card)
953
959
//hda_master_vol.submixerchans[i].submixch_max = (card->pcm_vols[i].node->amp_out_caps >> AC_AMPCAP_NUM_STEPS_SHIFT ) & AC_AMPCAP_NUM_STEPS_MASK;
954
960
}
955
961
956
- dbgprintf (("hda_mixer_init: dac[0]=%d dac[1]=%d out[0]=%d out[1]=%d vol[0]=%d vol[1]=%d\n" ,
962
+ /* this is the important log if something goes wrong with the volume;
963
+ * the card->pcm_vols should be DACs or Mixer widgets.
964
+ */
965
+ dbgprintf (("hda_mixer_init nodes: dac[0]=%d dac[1]=%d out[0]=%d out[1]=%d vol[0]=%d vol[1]=%d\n" ,
957
966
(int )((card -> dac_node [0 ]) ? card -> dac_node [0 ]-> nid : 0 ),
958
967
(int )((card -> dac_node [1 ]) ? card -> dac_node [1 ]-> nid : 0 ),
959
968
(int )((card -> out_pin_node [0 ]) ? card -> out_pin_node [0 ]-> nid : 0 ),
@@ -1440,6 +1449,10 @@ static int HDA_adetect( struct audioout_info_s *aui )
1440
1449
card -> codec_index = i ;
1441
1450
if ( hda_mixer_init ( card ) ) {
1442
1451
dbgprintf (("HDA_adetect: exit, found mixer for codec %u\n" , i ));
1452
+ printf ("HDA widgets to be used: DAC=%d Pin=%d Volume=%d\n" ,
1453
+ (int )((card -> dac_node [0 ]) ? card -> dac_node [0 ]-> nid : 0 ),
1454
+ (int )((card -> out_pin_node [0 ]) ? card -> out_pin_node [0 ]-> nid : 0 ),
1455
+ (int )((card -> pcm_vols [0 ].node ) ? card -> pcm_vols [0 ].node -> nid : 0 ));
1443
1456
return ( 1 );
1444
1457
}
1445
1458
}
@@ -1594,7 +1607,9 @@ static void HDA_writeMIXER( struct audioout_info_s *aui, unsigned long reg, unsi
1594
1607
///////////////////////////////////////////////////////////////////////////////////////////////
1595
1608
{
1596
1609
struct intelhd_card_s * card = aui -> card_private_data ;
1597
- int maxstep = ( card -> dac_node [0 ]-> amp_out_caps >> 8 ) & 0x7F ;
1610
+ /* v1.6: use pcm_vols[] instead of dac_node[] */
1611
+ //int maxstep = ( card->dac_node[0]->amp_out_caps >> 8 ) & 0x7F;
1612
+ int maxstep = ( card -> pcm_vols [0 ].node -> amp_out_caps >> 8 ) & 0x7F ;
1598
1613
val = maxstep * val / 100 ;
1599
1614
hda_set_vol_mute ( card , reg , 0 , HDA_OUTPUT , 0 , val ); /* left channel */
1600
1615
hda_set_vol_mute ( card , reg , 1 , HDA_OUTPUT , 0 , val ); /* right channel */
@@ -1609,7 +1624,9 @@ static unsigned long HDA_readMIXER( struct audioout_info_s *aui, unsigned long r
1609
1624
{
1610
1625
struct intelhd_card_s * card = aui -> card_private_data ;
1611
1626
uint32_t val ;
1612
- int maxstep = ( card -> dac_node [0 ]-> amp_out_caps >> 8 ) & 0x7F ;
1627
+ /* v1.6: use pcm_vols[] instead of dac_node[] */
1628
+ //int maxstep = ( card->dac_node[0]->amp_out_caps >> 8 ) & 0x7F;
1629
+ int maxstep = ( card -> pcm_vols [0 ].node -> amp_out_caps >> 8 ) & 0x7F ;
1613
1630
val = hda_get_vol_mute ( card , reg , 0 , HDA_OUTPUT , 0 );
1614
1631
if ( maxstep )
1615
1632
val = val * 100 / maxstep ;
0 commit comments