307
308
EXPORT_SYMBOL_HDA(snd_hda_get_sub_nodes);
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);
310
317
* snd_hda_get_connections - get connection list
311
318
* @codec: the HDA codec
319
326
* Returns the number of connections, or a negative error code.
321
328
int snd_hda_get_connections(struct hda_codec *codec, hda_nid_t nid,
322
hda_nid_t *conn_list, int max_conns)
329
hda_nid_t *conn_list, int max_conns)
331
struct snd_array *array = &codec->conn_lists;
332
int i, len, old_used;
333
hda_nid_t list[HDA_MAX_CONNECTIONS];
335
/* look up the cached results */
336
for (i = 0; i < array->used; ) {
337
hda_nid_t *p = snd_array_elem(array, i);
340
return copy_conn_list(nid, conn_list, max_conns,
345
len = _hda_get_connections(codec, nid, list, HDA_MAX_CONNECTIONS);
349
/* add to the cache */
350
old_used = array->used;
351
if (!add_conn_list(array, nid) || !add_conn_list(array, len))
353
for (i = 0; i < len; i++)
354
if (!add_conn_list(array, list[i]))
357
return copy_conn_list(nid, conn_list, max_conns, list, len);
360
array->used = old_used;
363
EXPORT_SYMBOL_HDA(snd_hda_get_connections);
365
static int _hda_get_connections(struct hda_codec *codec, hda_nid_t nid,
366
hda_nid_t *conn_list, int max_conns)
324
368
unsigned int parm;
325
369
int i, conn_len, conns;
419
EXPORT_SYMBOL_HDA(snd_hda_get_connections);
464
static bool add_conn_list(struct snd_array *array, hda_nid_t nid)
466
hda_nid_t *p = snd_array_new(array);
473
static int copy_conn_list(hda_nid_t nid, hda_nid_t *dst, int max_dst,
474
hda_nid_t *src, int len)
477
snd_printk(KERN_ERR "hda_codec: "
478
"Too many connections %d for NID 0x%x\n",
482
memcpy(dst, src, len * sizeof(hda_nid_t));
423
487
* snd_hda_queue_unsol_event - add an unsolicited event to queue
1076
1143
snd_array_init(&codec->init_pins, sizeof(struct hda_pincfg), 16);
1077
1144
snd_array_init(&codec->driver_pins, sizeof(struct hda_pincfg), 16);
1078
1145
snd_array_init(&codec->cvt_setups, sizeof(struct hda_cvt_setup), 8);
1146
snd_array_init(&codec->conn_lists, sizeof(hda_nid_t), 64);
1079
1147
if (codec->bus->modelname) {
1080
1148
codec->modelname = kstrdup(codec->bus->modelname, GFP_KERNEL);
1081
1149
if (!codec->modelname) {
3660
3730
* with the proper parameters for set up.
3661
3731
* ops.cleanup should be called in hw_free for clean up of streams.
3663
* This function returns 0 if successfull, or a negative error code.
3733
* This function returns 0 if successful, or a negative error code.
3665
3735
int __devinit snd_hda_build_pcms(struct hda_bus *bus)
4114
4185
snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
4115
4186
if (codec->slave_dig_outs) {
4117
4188
for (d = codec->slave_dig_outs; *d; d++)
4118
4189
snd_hda_codec_setup_stream(codec, *d, stream_tag, 0,
4628
4699
* debug prints of the parsed results
4630
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",
4631
4702
cfg->line_outs, cfg->line_out_pins[0], cfg->line_out_pins[1],
4632
4703
cfg->line_out_pins[2], cfg->line_out_pins[3],
4633
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"));
4634
4708
snd_printd(" speaker_outs=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
4635
4709
cfg->speaker_outs, cfg->speaker_pins[0],
4636
4710
cfg->speaker_pins[1], cfg->speaker_pins[2],
4960
5034
EXPORT_SYMBOL_HDA(snd_print_pcm_bits);
5036
#ifdef CONFIG_SND_HDA_INPUT_JACK
5038
* Input-jack notification support
5040
struct hda_jack_item {
5043
struct snd_jack *jack;
5046
static const char *get_jack_default_name(struct hda_codec *codec, hda_nid_t nid,
5050
case SND_JACK_HEADPHONE:
5052
case SND_JACK_MICROPHONE:
5054
case SND_JACK_LINEOUT:
5056
case SND_JACK_HEADSET:
5058
case SND_JACK_VIDEOOUT:
5065
static void hda_free_jack_priv(struct snd_jack *jack)
5067
struct hda_jack_item *jacks = jack->private_data;
5072
int snd_hda_input_jack_add(struct hda_codec *codec, hda_nid_t nid, int type,
5075
struct hda_jack_item *jack;
5078
snd_array_init(&codec->jacks, sizeof(*jack), 32);
5079
jack = snd_array_new(&codec->jacks);
5086
name = get_jack_default_name(codec, nid, type);
5087
err = snd_jack_new(codec->bus->card, name, type, &jack->jack);
5092
jack->jack->private_data = jack;
5093
jack->jack->private_free = hda_free_jack_priv;
5096
EXPORT_SYMBOL_HDA(snd_hda_input_jack_add);
5098
void snd_hda_input_jack_report(struct hda_codec *codec, hda_nid_t nid)
5100
struct hda_jack_item *jacks = codec->jacks.list;
5106
for (i = 0; i < codec->jacks.used; i++, jacks++) {
5107
unsigned int pin_ctl;
5108
unsigned int present;
5111
if (jacks->nid != nid)
5113
present = snd_hda_jack_detect(codec, nid);
5115
if (type == (SND_JACK_HEADPHONE | SND_JACK_LINEOUT)) {
5116
pin_ctl = snd_hda_codec_read(codec, nid, 0,
5117
AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
5118
type = (pin_ctl & AC_PINCTL_HP_EN) ?
5119
SND_JACK_HEADPHONE : SND_JACK_LINEOUT;
5121
snd_jack_report(jacks->jack, present ? type : 0);
5124
EXPORT_SYMBOL_HDA(snd_hda_input_jack_report);
5126
/* free jack instances manually when clearing/reconfiguring */
5127
void snd_hda_input_jack_free(struct hda_codec *codec)
5129
if (!codec->bus->shutdown && codec->jacks.list) {
5130
struct hda_jack_item *jacks = codec->jacks.list;
5132
for (i = 0; i < codec->jacks.used; i++, jacks++) {
5134
snd_device_free(codec->bus->card, jacks->jack);
5137
snd_array_free(&codec->jacks);
5139
EXPORT_SYMBOL_HDA(snd_hda_input_jack_free);
5140
#endif /* CONFIG_SND_HDA_INPUT_JACK */
4962
5142
MODULE_DESCRIPTION("HDA codec core");
4963
5143
MODULE_LICENSE("GPL");