Skip to content

Commit f686c74

Browse files
committed
Merge branch 'topic/hda' into for-linus
2 parents 7ec298d + 50e3bbf commit f686c74

15 files changed

Lines changed: 4127 additions & 3296 deletions

‎Documentation/sound/alsa/HD-Audio-Models.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ ALC662/663/272
9494
3stack-dig 3-stack (2-channel) with SPDIF
9595
3stack-6ch 3-stack (6-channel)
9696
3stack-6ch-dig 3-stack (6-channel) with SPDIF
97-
6stack-dig 6-stack with SPDIF
97+
5stack-dig 5-stack with SPDIF
9898
lenovo-101e Lenovo laptop
9999
eeepc-p701 ASUS Eeepc P701
100100
eeepc-ep20 ASUS Eeepc EP20

‎sound/pci/hda/hda_codec.c‎

Lines changed: 84 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,12 @@ int snd_hda_get_sub_nodes(struct hda_codec *codec, hda_nid_t nid,
307307
}
308308
EXPORT_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
*/
322328
int 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)
25562621
static 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);
43354401
int 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
*/
44424508
int 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
}

‎sound/pci/hda/hda_codec.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,12 +825,14 @@ struct hda_codec {
825825
struct hda_cache_rec amp_cache; /* cache for amp access */
826826
struct hda_cache_rec cmd_cache; /* cache for other commands */
827827

828+
struct snd_array conn_lists; /* connection-list array */
829+
828830
struct mutex spdif_mutex;
829831
struct mutex control_mutex;
830832
unsigned int spdif_status; /* IEC958 status bits */
831833
unsigned short spdif_ctls; /* SPDIF control bits */
832834
unsigned int spdif_in_enable; /* SPDIF input enable? */
833-
hda_nid_t *slave_dig_outs; /* optional digital out slave widgets */
835+
const hda_nid_t *slave_dig_outs; /* optional digital out slave widgets */
834836
struct snd_array init_pins; /* initial (BIOS) pin configurations */
835837
struct snd_array driver_pins; /* pin configs set by codec parser */
836838
struct snd_array cvt_setups; /* audio convert setups */

‎sound/pci/hda/hda_intel.c‎

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ MODULE_SUPPORTED_DEVICE("{{Intel, ICH6},"
126126
"{Intel, ICH10},"
127127
"{Intel, PCH},"
128128
"{Intel, CPT},"
129+
"{Intel, PPT},"
129130
"{Intel, PBG},"
130131
"{Intel, SCH},"
131132
"{ATI, SB450},"
@@ -1091,7 +1092,13 @@ static void azx_init_pci(struct azx *chip)
10911092
? "Failed" : "OK");
10921093
}
10931094
break;
1094-
1095+
default:
1096+
/* AMD Hudson needs the similar snoop, as it seems... */
1097+
if (chip->pci->vendor == PCI_VENDOR_ID_AMD)
1098+
update_pci_byte(chip->pci,
1099+
ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR,
1100+
0x07, ATI_SB450_HDAUDIO_ENABLE_SNOOP);
1101+
break;
10951102
}
10961103
}
10971104

@@ -1446,6 +1453,17 @@ static int __devinit azx_codec_create(struct azx *chip, const char *model)
14461453
}
14471454
}
14481455

1456+
/* AMD chipsets often cause the communication stalls upon certain
1457+
* sequence like the pin-detection. It seems that forcing the synced
1458+
* access works around the stall. Grrr...
1459+
*/
1460+
if (chip->pci->vendor == PCI_VENDOR_ID_AMD ||
1461+
chip->pci->vendor == PCI_VENDOR_ID_ATI) {
1462+
snd_printk(KERN_INFO SFX "Enable sync_write for AMD chipset\n");
1463+
chip->bus->sync_write = 1;
1464+
chip->bus->allow_bus_reset = 1;
1465+
}
1466+
14491467
/* Then create codec instances */
14501468
for (c = 0; c < max_slots; c++) {
14511469
if ((chip->codec_mask & (1 << c)) & chip->codec_probe_mask) {
@@ -2349,9 +2367,16 @@ static int __devinit check_position_fix(struct azx *chip, int fix)
23492367
/* Check VIA/ATI HD Audio Controller exist */
23502368
switch (chip->driver_type) {
23512369
case AZX_DRIVER_VIA:
2352-
case AZX_DRIVER_ATI:
23532370
/* Use link position directly, avoid any transfer problem. */
23542371
return POS_FIX_VIACOMBO;
2372+
case AZX_DRIVER_ATI:
2373+
/* ATI chipsets don't work well with position-buffer */
2374+
return POS_FIX_LPIB;
2375+
case AZX_DRIVER_GENERIC:
2376+
/* AMD chipsets also don't work with position-buffer */
2377+
if (chip->pci->vendor == PCI_VENDOR_ID_AMD)
2378+
return POS_FIX_LPIB;
2379+
break;
23552380
}
23562381

23572382
return POS_FIX_AUTO;
@@ -2549,6 +2574,13 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci,
25492574
gcap &= ~ICH6_GCAP_64OK;
25502575
pci_dev_put(p_smbus);
25512576
}
2577+
} else {
2578+
/* FIXME: not sure whether this is really needed, but
2579+
* Hudson isn't stable enough for allowing everything...
2580+
* let's check later again.
2581+
*/
2582+
if (chip->pci->vendor == PCI_VENDOR_ID_AMD)
2583+
gcap &= ~ICH6_GCAP_64OK;
25522584
}
25532585

25542586
/* disable 64bit DMA address for Teradici */
@@ -2759,6 +2791,8 @@ static DEFINE_PCI_DEVICE_TABLE(azx_ids) = {
27592791
{ PCI_DEVICE(0x8086, 0x1c20), .driver_data = AZX_DRIVER_PCH },
27602792
/* PBG */
27612793
{ PCI_DEVICE(0x8086, 0x1d20), .driver_data = AZX_DRIVER_PCH },
2794+
/* Panther Point */
2795+
{ PCI_DEVICE(0x8086, 0x1e20), .driver_data = AZX_DRIVER_PCH },
27622796
/* SCH */
27632797
{ PCI_DEVICE(0x8086, 0x811b), .driver_data = AZX_DRIVER_SCH },
27642798
/* Generic Intel */

‎sound/pci/hda/hda_local.h‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -267,11 +267,11 @@ enum { HDA_DIG_NONE, HDA_DIG_EXCLUSIVE, HDA_DIG_ANALOG_DUP }; /* dig_out_used */
267267

268268
struct hda_multi_out {
269269
int num_dacs; /* # of DACs, must be more than 1 */
270-
hda_nid_t *dac_nids; /* DAC list */
270+
const hda_nid_t *dac_nids; /* DAC list */
271271
hda_nid_t hp_nid; /* optional DAC for HP, 0 when not exists */
272272
hda_nid_t extra_out_nid[3]; /* optional DACs, 0 when not exists */
273273
hda_nid_t dig_out_nid; /* digital out audio widget */
274-
hda_nid_t *slave_dig_outs;
274+
const hda_nid_t *slave_dig_outs;
275275
int max_channels; /* currently supported analog channels */
276276
int dig_out_used; /* current usage of digital out (HDA_DIG_XXX) */
277277
int no_share_stream; /* don't share a stream with multiple pins */
@@ -347,7 +347,7 @@ int snd_hda_check_board_codec_sid_config(struct hda_codec *codec,
347347
int num_configs, const char * const *models,
348348
const struct snd_pci_quirk *tbl);
349349
int snd_hda_add_new_ctls(struct hda_codec *codec,
350-
struct snd_kcontrol_new *knew);
350+
const struct snd_kcontrol_new *knew);
351351

352352
/*
353353
* unsolicited event handler
@@ -443,7 +443,7 @@ struct auto_pin_cfg {
443443

444444
int snd_hda_parse_pin_def_config(struct hda_codec *codec,
445445
struct auto_pin_cfg *cfg,
446-
hda_nid_t *ignore_nids);
446+
const hda_nid_t *ignore_nids);
447447

448448
/* amp values */
449449
#define AMP_IN_MUTE(idx) (0x7080 | ((idx)<<8))
@@ -493,6 +493,12 @@ u32 snd_hda_query_pin_caps(struct hda_codec *codec, hda_nid_t nid);
493493
u32 snd_hda_pin_sense(struct hda_codec *codec, hda_nid_t nid);
494494
int snd_hda_jack_detect(struct hda_codec *codec, hda_nid_t nid);
495495

496+
static inline bool is_jack_detectable(struct hda_codec *codec, hda_nid_t nid)
497+
{
498+
return (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_PRES_DETECT) &&
499+
(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP);
500+
}
501+
496502
/* flags for hda_nid_item */
497503
#define HDA_NID_ITEM_AMP (1<<0)
498504

@@ -567,7 +573,7 @@ struct hda_amp_list {
567573
};
568574

569575
struct hda_loopback_check {
570-
struct hda_amp_list *amplist;
576+
const struct hda_amp_list *amplist;
571577
int power_on;
572578
};
573579

0 commit comments

Comments
 (0)