@@ -307,6 +307,12 @@ int snd_hda_get_sub_nodes(struct hda_codec *codec, hda_nid_t nid,
307307}
308308EXPORT_SYMBOL_HDA (snd_hda_get_sub_nodes );
309309
310+ static int _hda_get_connections (struct hda_codec * codec , hda_nid_t nid ,
311+ hda_nid_t * conn_list , int max_conns );
312+ static bool add_conn_list (struct snd_array * array , hda_nid_t nid );
313+ static int copy_conn_list (hda_nid_t nid , hda_nid_t * dst , int max_dst ,
314+ hda_nid_t * src , int len );
315+
310316/**
311317 * snd_hda_get_connections - get connection list
312318 * @codec: the HDA codec
@@ -320,7 +326,44 @@ EXPORT_SYMBOL_HDA(snd_hda_get_sub_nodes);
320326 * Returns the number of connections, or a negative error code.
321327 */
322328int snd_hda_get_connections (struct hda_codec * codec , hda_nid_t nid ,
323- hda_nid_t * conn_list , int max_conns )
329+ hda_nid_t * conn_list , int max_conns )
330+ {
331+ struct snd_array * array = & codec -> conn_lists ;
332+ int i , len , old_used ;
333+ hda_nid_t list [HDA_MAX_CONNECTIONS ];
334+
335+ /* look up the cached results */
336+ for (i = 0 ; i < array -> used ; ) {
337+ hda_nid_t * p = snd_array_elem (array , i );
338+ len = p [1 ];
339+ if (nid == * p )
340+ return copy_conn_list (nid , conn_list , max_conns ,
341+ p + 2 , len );
342+ i += len + 2 ;
343+ }
344+
345+ len = _hda_get_connections (codec , nid , list , HDA_MAX_CONNECTIONS );
346+ if (len < 0 )
347+ return len ;
348+
349+ /* add to the cache */
350+ old_used = array -> used ;
351+ if (!add_conn_list (array , nid ) || !add_conn_list (array , len ))
352+ goto error_add ;
353+ for (i = 0 ; i < len ; i ++ )
354+ if (!add_conn_list (array , list [i ]))
355+ goto error_add ;
356+
357+ return copy_conn_list (nid , conn_list , max_conns , list , len );
358+
359+ error_add :
360+ array -> used = old_used ;
361+ return - ENOMEM ;
362+ }
363+ EXPORT_SYMBOL_HDA (snd_hda_get_connections );
364+
365+ static int _hda_get_connections (struct hda_codec * codec , hda_nid_t nid ,
366+ hda_nid_t * conn_list , int max_conns )
324367{
325368 unsigned int parm ;
326369 int i , conn_len , conns ;
@@ -417,8 +460,28 @@ int snd_hda_get_connections(struct hda_codec *codec, hda_nid_t nid,
417460 }
418461 return conns ;
419462}
420- EXPORT_SYMBOL_HDA (snd_hda_get_connections );
421463
464+ static bool add_conn_list (struct snd_array * array , hda_nid_t nid )
465+ {
466+ hda_nid_t * p = snd_array_new (array );
467+ if (!p )
468+ return false;
469+ * p = nid ;
470+ return true;
471+ }
472+
473+ static int copy_conn_list (hda_nid_t nid , hda_nid_t * dst , int max_dst ,
474+ hda_nid_t * src , int len )
475+ {
476+ if (len > max_dst ) {
477+ snd_printk (KERN_ERR "hda_codec: "
478+ "Too many connections %d for NID 0x%x\n" ,
479+ len , nid );
480+ return - EINVAL ;
481+ }
482+ memcpy (dst , src , len * sizeof (hda_nid_t ));
483+ return len ;
484+ }
422485
423486/**
424487 * snd_hda_queue_unsol_event - add an unsolicited event to queue
@@ -1019,6 +1082,7 @@ static void snd_hda_codec_free(struct hda_codec *codec)
10191082 list_del (& codec -> list );
10201083 snd_array_free (& codec -> mixers );
10211084 snd_array_free (& codec -> nids );
1085+ snd_array_free (& codec -> conn_lists );
10221086 codec -> bus -> caddr_tbl [codec -> addr ] = NULL ;
10231087 if (codec -> patch_ops .free )
10241088 codec -> patch_ops .free (codec );
@@ -1079,6 +1143,7 @@ int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus,
10791143 snd_array_init (& codec -> init_pins , sizeof (struct hda_pincfg ), 16 );
10801144 snd_array_init (& codec -> driver_pins , sizeof (struct hda_pincfg ), 16 );
10811145 snd_array_init (& codec -> cvt_setups , sizeof (struct hda_cvt_setup ), 8 );
1146+ snd_array_init (& codec -> conn_lists , sizeof (hda_nid_t ), 64 );
10821147 if (codec -> bus -> modelname ) {
10831148 codec -> modelname = kstrdup (codec -> bus -> modelname , GFP_KERNEL );
10841149 if (!codec -> modelname ) {
@@ -2556,7 +2621,7 @@ static unsigned int convert_to_spdif_status(unsigned short val)
25562621static void set_dig_out (struct hda_codec * codec , hda_nid_t nid ,
25572622 int verb , int val )
25582623{
2559- hda_nid_t * d ;
2624+ const hda_nid_t * d ;
25602625
25612626 snd_hda_codec_write_cache (codec , nid , 0 , verb , val );
25622627 d = codec -> slave_dig_outs ;
@@ -3807,7 +3872,8 @@ EXPORT_SYMBOL_HDA(snd_hda_check_board_codec_sid_config);
38073872 *
38083873 * Returns 0 if successful, or a negative error code.
38093874 */
3810- int snd_hda_add_new_ctls (struct hda_codec * codec , struct snd_kcontrol_new * knew )
3875+ int snd_hda_add_new_ctls (struct hda_codec * codec ,
3876+ const struct snd_kcontrol_new * knew )
38113877{
38123878 int err ;
38133879
@@ -3950,7 +4016,7 @@ int snd_hda_check_amp_list_power(struct hda_codec *codec,
39504016 struct hda_loopback_check * check ,
39514017 hda_nid_t nid )
39524018{
3953- struct hda_amp_list * p ;
4019+ const struct hda_amp_list * p ;
39544020 int ch , v ;
39554021
39564022 if (!check -> amplist )
@@ -4118,7 +4184,7 @@ static void setup_dig_out_stream(struct hda_codec *codec, hda_nid_t nid,
41184184 -1 );
41194185 snd_hda_codec_setup_stream (codec , nid , stream_tag , 0 , format );
41204186 if (codec -> slave_dig_outs ) {
4121- hda_nid_t * d ;
4187+ const hda_nid_t * d ;
41224188 for (d = codec -> slave_dig_outs ; * d ; d ++ )
41234189 snd_hda_codec_setup_stream (codec , * d , stream_tag , 0 ,
41244190 format );
@@ -4133,7 +4199,7 @@ static void cleanup_dig_out_stream(struct hda_codec *codec, hda_nid_t nid)
41334199{
41344200 snd_hda_codec_cleanup_stream (codec , nid );
41354201 if (codec -> slave_dig_outs ) {
4136- hda_nid_t * d ;
4202+ const hda_nid_t * d ;
41374203 for (d = codec -> slave_dig_outs ; * d ; d ++ )
41384204 snd_hda_codec_cleanup_stream (codec , * d );
41394205 }
@@ -4280,7 +4346,7 @@ int snd_hda_multi_out_analog_prepare(struct hda_codec *codec,
42804346 unsigned int format ,
42814347 struct snd_pcm_substream * substream )
42824348{
4283- hda_nid_t * nids = mout -> dac_nids ;
4349+ const hda_nid_t * nids = mout -> dac_nids ;
42844350 int chs = substream -> runtime -> channels ;
42854351 int i ;
42864352
@@ -4335,7 +4401,7 @@ EXPORT_SYMBOL_HDA(snd_hda_multi_out_analog_prepare);
43354401int snd_hda_multi_out_analog_cleanup (struct hda_codec * codec ,
43364402 struct hda_multi_out * mout )
43374403{
4338- hda_nid_t * nids = mout -> dac_nids ;
4404+ const hda_nid_t * nids = mout -> dac_nids ;
43394405 int i ;
43404406
43414407 for (i = 0 ; i < mout -> num_dacs ; i ++ )
@@ -4360,7 +4426,7 @@ EXPORT_SYMBOL_HDA(snd_hda_multi_out_analog_cleanup);
43604426 * Helper for automatic pin configuration
43614427 */
43624428
4363- static int is_in_nid_list (hda_nid_t nid , hda_nid_t * list )
4429+ static int is_in_nid_list (hda_nid_t nid , const hda_nid_t * list )
43644430{
43654431 for (; * list ; list ++ )
43664432 if (* list == nid )
@@ -4441,7 +4507,7 @@ static void sort_autocfg_input_pins(struct auto_pin_cfg *cfg)
44414507 */
44424508int snd_hda_parse_pin_def_config (struct hda_codec * codec ,
44434509 struct auto_pin_cfg * cfg ,
4444- hda_nid_t * ignore_nids )
4510+ const hda_nid_t * ignore_nids )
44454511{
44464512 hda_nid_t nid , end_nid ;
44474513 short seq , assoc_line_out , assoc_speaker ;
@@ -4632,10 +4698,13 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec,
46324698 /*
46334699 * debug prints of the parsed results
46344700 */
4635- snd_printd ("autoconfig: line_outs=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n" ,
4701+ snd_printd ("autoconfig: line_outs=%d (0x%x/0x%x/0x%x/0x%x/0x%x) type:%s \n" ,
46364702 cfg -> line_outs , cfg -> line_out_pins [0 ], cfg -> line_out_pins [1 ],
46374703 cfg -> line_out_pins [2 ], cfg -> line_out_pins [3 ],
4638- cfg -> line_out_pins [4 ]);
4704+ cfg -> line_out_pins [4 ],
4705+ cfg -> line_out_type == AUTO_PIN_HP_OUT ? "hp" :
4706+ (cfg -> line_out_type == AUTO_PIN_SPEAKER_OUT ?
4707+ "speaker" : "line" ));
46394708 snd_printd (" speaker_outs=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n" ,
46404709 cfg -> speaker_outs , cfg -> speaker_pins [0 ],
46414710 cfg -> speaker_pins [1 ], cfg -> speaker_pins [2 ],
@@ -4986,6 +5055,8 @@ static const char *get_jack_default_name(struct hda_codec *codec, hda_nid_t nid,
49865055 return "Line-out" ;
49875056 case SND_JACK_HEADSET :
49885057 return "Headset" ;
5058+ case SND_JACK_VIDEOOUT :
5059+ return "HDMI/DP" ;
49895060 default :
49905061 return "Misc" ;
49915062 }
0 commit comments