tangled
alpha
login
or
join now
tjh.dev
/
kernel
Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1
fork
atom
overview
issues
pulls
pipelines
Merge branch 'topic/hda' into for-linus
Takashi Iwai
16 years ago
f1cf9a66
6679ee18
+1142
-905
9 changed files
expand all
collapse all
unified
split
sound
pci
hda
Kconfig
Makefile
hda_codec.c
hda_eld.c
hda_intel.c
patch_hdmi.c
patch_intelhdmi.c
patch_nvhdmi.c
patch_realtek.c
+1
-1
sound/pci/hda/Kconfig
···
157
157
158
158
config SND_HDA_ELD
159
159
def_bool y
160
160
-
depends on SND_HDA_CODEC_INTELHDMI
160
160
+
depends on SND_HDA_CODEC_INTELHDMI || SND_HDA_CODEC_NVHDMI
161
161
162
162
config SND_HDA_CODEC_CIRRUS
163
163
bool "Build Cirrus Logic codec support"
+2
-2
sound/pci/hda/Makefile
···
3
3
snd-hda-codec-y := hda_codec.o
4
4
snd-hda-codec-$(CONFIG_SND_HDA_GENERIC) += hda_generic.o
5
5
snd-hda-codec-$(CONFIG_PROC_FS) += hda_proc.o
6
6
-
# snd-hda-codec-$(CONFIG_SND_HDA_ELD) += hda_eld.o
6
6
+
snd-hda-codec-$(CONFIG_SND_HDA_ELD) += hda_eld.o
7
7
snd-hda-codec-$(CONFIG_SND_HDA_HWDEP) += hda_hwdep.o
8
8
snd-hda-codec-$(CONFIG_SND_HDA_INPUT_BEEP) += hda_beep.o
9
9
···
18
18
snd-hda-codec-conexant-objs := patch_conexant.o
19
19
snd-hda-codec-via-objs := patch_via.o
20
20
snd-hda-codec-nvhdmi-objs := patch_nvhdmi.o
21
21
-
snd-hda-codec-intelhdmi-objs := patch_intelhdmi.o hda_eld.o
21
21
+
snd-hda-codec-intelhdmi-objs := patch_intelhdmi.o
22
22
23
23
# common driver
24
24
obj-$(CONFIG_SND_HDA_INTEL) := snd-hda-codec.o
+38
-31
sound/pci/hda/hda_codec.c
···
978
978
*
979
979
* Returns 0 if successful, or a negative error code.
980
980
*/
981
981
-
int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr,
982
982
-
struct hda_codec **codecp)
981
981
+
int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus,
982
982
+
unsigned int codec_addr,
983
983
+
struct hda_codec **codecp)
983
984
{
984
985
struct hda_codec *codec;
985
986
char component[31];
···
1187
1186
*/
1188
1187
1189
1188
/* FIXME: more better hash key? */
1190
1190
-
#define HDA_HASH_KEY(nid,dir,idx) (u32)((nid) + ((idx) << 16) + ((dir) << 24))
1189
1189
+
#define HDA_HASH_KEY(nid, dir, idx) (u32)((nid) + ((idx) << 16) + ((dir) << 24))
1191
1190
#define HDA_HASH_PINCAP_KEY(nid) (u32)((nid) + (0x02 << 24))
1192
1191
#define HDA_HASH_PARPCM_KEY(nid) (u32)((nid) + (0x03 << 24))
1193
1192
#define HDA_HASH_PARSTR_KEY(nid) (u32)((nid) + (0x04 << 24))
···
1357
1356
if (!codec->no_trigger_sense) {
1358
1357
pincap = snd_hda_query_pin_caps(codec, nid);
1359
1358
if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */
1360
1360
-
snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0);
1359
1359
+
snd_hda_codec_read(codec, nid, 0,
1360
1360
+
AC_VERB_SET_PIN_SENSE, 0);
1361
1361
}
1362
1362
return snd_hda_codec_read(codec, nid, 0,
1363
1363
AC_VERB_GET_PIN_SENSE, 0);
···
1374
1372
*/
1375
1373
int snd_hda_jack_detect(struct hda_codec *codec, hda_nid_t nid)
1376
1374
{
1377
1377
-
u32 sense = snd_hda_pin_sense(codec, nid);
1378
1378
-
return !!(sense & AC_PINSENSE_PRESENCE);
1375
1375
+
u32 sense = snd_hda_pin_sense(codec, nid);
1376
1376
+
return !!(sense & AC_PINSENSE_PRESENCE);
1379
1377
}
1380
1378
EXPORT_SYMBOL_HDA(snd_hda_jack_detect);
1381
1379
···
1954
1952
err = snd_hda_ctl_add(codec, 0, kctl);
1955
1953
if (err < 0)
1956
1954
return err;
1957
1957
-
1955
1955
+
1958
1956
for (s = slaves; *s; s++) {
1959
1957
struct snd_kcontrol *sctl;
1960
1958
int i = 0;
···
2441
2439
{
2442
2440
.access = SNDRV_CTL_ELEM_ACCESS_READ,
2443
2441
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2444
2444
-
.name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,CON_MASK),
2442
2442
+
.name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, CON_MASK),
2445
2443
.info = snd_hda_spdif_mask_info,
2446
2444
.get = snd_hda_spdif_cmask_get,
2447
2445
},
2448
2446
{
2449
2447
.access = SNDRV_CTL_ELEM_ACCESS_READ,
2450
2448
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2451
2451
-
.name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,PRO_MASK),
2449
2449
+
.name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, PRO_MASK),
2452
2450
.info = snd_hda_spdif_mask_info,
2453
2451
.get = snd_hda_spdif_pmask_get,
2454
2452
},
2455
2453
{
2456
2454
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2457
2457
-
.name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT),
2455
2455
+
.name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, DEFAULT),
2458
2456
.info = snd_hda_spdif_mask_info,
2459
2457
.get = snd_hda_spdif_default_get,
2460
2458
.put = snd_hda_spdif_default_put,
2461
2459
},
2462
2460
{
2463
2461
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2464
2464
-
.name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,SWITCH),
2462
2462
+
.name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, SWITCH),
2465
2463
.info = snd_hda_spdif_out_switch_info,
2466
2464
.get = snd_hda_spdif_out_switch_get,
2467
2465
.put = snd_hda_spdif_out_switch_put,
···
2612
2610
static struct snd_kcontrol_new dig_in_ctls[] = {
2613
2611
{
2614
2612
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2615
2615
-
.name = SNDRV_CTL_NAME_IEC958("",CAPTURE,SWITCH),
2613
2613
+
.name = SNDRV_CTL_NAME_IEC958("", CAPTURE, SWITCH),
2616
2614
.info = snd_hda_spdif_in_switch_info,
2617
2615
.get = snd_hda_spdif_in_switch_get,
2618
2616
.put = snd_hda_spdif_in_switch_put,
···
2620
2618
{
2621
2619
.access = SNDRV_CTL_ELEM_ACCESS_READ,
2622
2620
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2623
2623
-
.name = SNDRV_CTL_NAME_IEC958("",CAPTURE,DEFAULT),
2621
2621
+
.name = SNDRV_CTL_NAME_IEC958("", CAPTURE, DEFAULT),
2624
2622
.info = snd_hda_spdif_mask_info,
2625
2623
.get = snd_hda_spdif_in_status_get,
2626
2624
},
···
2885
2883
int err = snd_hda_codec_build_controls(codec);
2886
2884
if (err < 0) {
2887
2885
printk(KERN_ERR "hda_codec: cannot build controls"
2888
2888
-
"for #%d (error %d)\n", codec->addr, err);
2886
2886
+
"for #%d (error %d)\n", codec->addr, err);
2889
2887
err = snd_hda_codec_reset(codec);
2890
2888
if (err < 0) {
2891
2889
printk(KERN_ERR
···
2981
2979
val |= channels - 1;
2982
2980
2983
2981
switch (snd_pcm_format_width(format)) {
2984
2984
-
case 8: val |= 0x00; break;
2985
2985
-
case 16: val |= 0x10; break;
2982
2982
+
case 8:
2983
2983
+
val |= 0x00;
2984
2984
+
break;
2985
2985
+
case 16:
2986
2986
+
val |= 0x10;
2987
2987
+
break;
2986
2988
case 20:
2987
2989
case 24:
2988
2990
case 32:
···
3304
3298
if (!test_and_set_bit(audio_idx[type][i], bus->pcm_dev_bits))
3305
3299
return audio_idx[type][i];
3306
3300
3307
3307
-
snd_printk(KERN_WARNING "Too many %s devices\n", snd_hda_pcm_type_name[type]);
3301
3301
+
snd_printk(KERN_WARNING "Too many %s devices\n",
3302
3302
+
snd_hda_pcm_type_name[type]);
3308
3303
return -EAGAIN;
3309
3304
}
3310
3305
···
3343
3336
err = codec->patch_ops.build_pcms(codec);
3344
3337
if (err < 0) {
3345
3338
printk(KERN_ERR "hda_codec: cannot build PCMs"
3346
3346
-
"for #%d (error %d)\n", codec->addr, err);
3339
3339
+
"for #%d (error %d)\n", codec->addr, err);
3347
3340
err = snd_hda_codec_reset(codec);
3348
3341
if (err < 0) {
3349
3342
printk(KERN_ERR
···
3473
3466
3474
3467
/**
3475
3468
* snd_hda_check_board_codec_sid_config - compare the current codec
3476
3476
-
subsystem ID with the
3477
3477
-
config table
3469
3469
+
subsystem ID with the
3470
3470
+
config table
3478
3471
3479
3472
This is important for Gateway notebooks with SB450 HDA Audio
3480
3473
where the vendor ID of the PCI device is:
···
3614
3607
*
3615
3608
* Increment the power-up counter and power up the hardware really when
3616
3609
* not turned on yet.
3617
3617
-
*/
3610
3610
+
*/
3618
3611
void snd_hda_power_up(struct hda_codec *codec)
3619
3612
{
3620
3613
struct hda_bus *bus = codec->bus;
···
3643
3636
*
3644
3637
* Decrement the power-up counter and schedules the power-off work if
3645
3638
* the counter rearches to zero.
3646
3646
-
*/
3639
3639
+
*/
3647
3640
void snd_hda_power_down(struct hda_codec *codec)
3648
3641
{
3649
3642
--codec->power_count;
···
3669
3662
*
3670
3663
* This function is supposed to be set or called from the check_power_status
3671
3664
* patch ops.
3672
3672
-
*/
3665
3665
+
*/
3673
3666
int snd_hda_check_amp_list_power(struct hda_codec *codec,
3674
3667
struct hda_loopback_check *check,
3675
3668
hda_nid_t nid)
···
3837
3830
{
3838
3831
/* turn off SPDIF once; otherwise the IEC958 bits won't be updated */
3839
3832
if (codec->spdif_status_reset && (codec->spdif_ctls & AC_DIG1_ENABLE))
3840
3840
-
set_dig_out_convert(codec, nid,
3833
3833
+
set_dig_out_convert(codec, nid,
3841
3834
codec->spdif_ctls & ~AC_DIG1_ENABLE & 0xff,
3842
3835
-1);
3843
3836
snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
···
4096
4089
/*
4097
4090
* Sort an associated group of pins according to their sequence numbers.
4098
4091
*/
4099
4099
-
static void sort_pins_by_sequence(hda_nid_t * pins, short * sequences,
4092
4092
+
static void sort_pins_by_sequence(hda_nid_t *pins, short *sequences,
4100
4093
int num_pins)
4101
4094
{
4102
4095
int i, j;
4103
4096
short seq;
4104
4097
hda_nid_t nid;
4105
4105
-
4098
4098
+
4106
4099
for (i = 0; i < num_pins; i++) {
4107
4100
for (j = i + 1; j < num_pins; j++) {
4108
4101
if (sequences[i] > sequences[j]) {
···
4130
4123
* is detected, one of speaker of HP pins is assigned as the primary
4131
4124
* output, i.e. to line_out_pins[0]. So, line_outs is always positive
4132
4125
* if any analog output exists.
4133
4133
-
*
4126
4126
+
*
4134
4127
* The analog input pins are assigned to input_pins array.
4135
4128
* The digital input/output pins are assigned to dig_in_pin and dig_out_pin,
4136
4129
* respectively.
···
4193
4186
case AC_JACK_SPEAKER:
4194
4187
seq = get_defcfg_sequence(def_conf);
4195
4188
assoc = get_defcfg_association(def_conf);
4196
4196
-
if (! assoc)
4189
4189
+
if (!assoc)
4197
4190
continue;
4198
4198
-
if (! assoc_speaker)
4191
4191
+
if (!assoc_speaker)
4199
4192
assoc_speaker = assoc;
4200
4193
else if (assoc_speaker != assoc)
4201
4194
continue;
···
4293
4286
cfg->speaker_outs);
4294
4287
sort_pins_by_sequence(cfg->hp_pins, sequences_hp,
4295
4288
cfg->hp_outs);
4296
4296
-
4289
4289
+
4297
4290
/* if we have only one mic, make it AUTO_PIN_MIC */
4298
4291
if (!cfg->input_pins[AUTO_PIN_MIC] &&
4299
4292
cfg->input_pins[AUTO_PIN_FRONT_MIC]) {
···
4443
4436
/**
4444
4437
* snd_array_new - get a new element from the given array
4445
4438
* @array: the array object
4446
4446
-
*
4439
4439
+
*
4447
4440
* Get a new element from the given array. If it exceeds the
4448
4441
* pre-allocated array size, re-allocate the array.
4449
4442
*
+6
sound/pci/hda/hda_eld.c
···
331
331
return snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_HDMI_DIP_SIZE,
332
332
AC_DIPSIZE_ELD_BUF);
333
333
}
334
334
+
EXPORT_SYMBOL_HDA(snd_hdmi_get_eld_size);
334
335
335
336
int snd_hdmi_get_eld(struct hdmi_eld *eld,
336
337
struct hda_codec *codec, hda_nid_t nid)
···
367
366
kfree(buf);
368
367
return ret;
369
368
}
369
369
+
EXPORT_SYMBOL_HDA(snd_hdmi_get_eld);
370
370
371
371
static void hdmi_show_short_audio_desc(struct cea_sad *a)
372
372
{
···
406
404
}
407
405
buf[j] = '\0'; /* necessary when j == 0 */
408
406
}
407
407
+
EXPORT_SYMBOL_HDA(snd_print_channel_allocation);
409
408
410
409
void snd_hdmi_show_eld(struct hdmi_eld *e)
411
410
{
···
425
422
for (i = 0; i < e->sad_count; i++)
426
423
hdmi_show_short_audio_desc(e->sad + i);
427
424
}
425
425
+
EXPORT_SYMBOL_HDA(snd_hdmi_show_eld);
428
426
429
427
#ifdef CONFIG_PROC_FS
430
428
···
584
580
585
581
return 0;
586
582
}
583
583
+
EXPORT_SYMBOL_HDA(snd_hda_eld_proc_new);
587
584
588
585
void snd_hda_eld_proc_free(struct hda_codec *codec, struct hdmi_eld *eld)
589
586
{
···
593
588
eld->proc_entry = NULL;
594
589
}
595
590
}
591
591
+
EXPORT_SYMBOL_HDA(snd_hda_eld_proc_free);
596
592
597
593
#endif /* CONFIG_PROC_FS */
+7
-2
sound/pci/hda/hda_intel.c
···
267
267
#define RIRB_INT_MASK 0x05
268
268
269
269
/* STATESTS int mask: S3,SD2,SD1,SD0 */
270
270
-
#define AZX_MAX_CODECS 4
270
270
+
#define AZX_MAX_CODECS 8
271
271
+
#define AZX_DEFAULT_CODECS 4
271
272
#define STATESTS_INT_MASK ((1 << AZX_MAX_CODECS) - 1)
272
273
273
274
/* SD_CTL bits */
···
1368
1367
1369
1368
/* number of codec slots for each chipset: 0 = default slots (i.e. 4) */
1370
1369
static unsigned int azx_max_codecs[AZX_NUM_DRIVERS] __devinitdata = {
1370
1370
+
[AZX_DRIVER_NVIDIA] = 8,
1371
1371
[AZX_DRIVER_TERA] = 1,
1372
1372
};
1373
1373
···
1401
1399
codecs = 0;
1402
1400
max_slots = azx_max_codecs[chip->driver_type];
1403
1401
if (!max_slots)
1404
1404
-
max_slots = AZX_MAX_CODECS;
1402
1402
+
max_slots = AZX_DEFAULT_CODECS;
1405
1403
1406
1404
/* First try to probe all given codec slots */
1407
1405
for (c = 0; c < max_slots; c++) {
···
2265
2263
static struct snd_pci_quirk position_fix_list[] __devinitdata = {
2266
2264
SND_PCI_QUIRK(0x1028, 0x01cc, "Dell D820", POS_FIX_LPIB),
2267
2265
SND_PCI_QUIRK(0x1028, 0x01de, "Dell Precision 390", POS_FIX_LPIB),
2266
2266
+
SND_PCI_QUIRK(0x1028, 0x01f6, "Dell Latitude 131L", POS_FIX_LPIB),
2268
2267
SND_PCI_QUIRK(0x103c, 0x306d, "HP dv3", POS_FIX_LPIB),
2269
2268
SND_PCI_QUIRK(0x1106, 0x3288, "ASUS M2V-MX SE", POS_FIX_LPIB),
2270
2269
SND_PCI_QUIRK(0x1043, 0x813d, "ASUS P5AD2", POS_FIX_LPIB),
2271
2270
SND_PCI_QUIRK(0x1462, 0x1002, "MSI Wind U115", POS_FIX_LPIB),
2271
2271
+
SND_PCI_QUIRK(0x1565, 0x820f, "Biostar Microtech", POS_FIX_LPIB),
2272
2272
{}
2273
2273
};
2274
2274
···
2358
2354
static struct snd_pci_quirk msi_black_list[] __devinitdata = {
2359
2355
SND_PCI_QUIRK(0x1043, 0x81f2, "ASUS", 0), /* Athlon64 X2 + nvidia */
2360
2356
SND_PCI_QUIRK(0x1043, 0x81f6, "ASUS", 0), /* nvidia */
2357
2357
+
SND_PCI_QUIRK(0x1849, 0x0888, "ASRock", 0), /* Athlon64 X2 + nvidia */
2361
2358
{}
2362
2359
};
2363
2360
+849
sound/pci/hda/patch_hdmi.c
···
1
1
+
/*
2
2
+
*
3
3
+
* patch_hdmi.c - routines for HDMI/DisplayPort codecs
4
4
+
*
5
5
+
* Copyright(c) 2008-2010 Intel Corporation. All rights reserved.
6
6
+
*
7
7
+
* Authors:
8
8
+
* Wu Fengguang <wfg@linux.intel.com>
9
9
+
*
10
10
+
* Maintained by:
11
11
+
* Wu Fengguang <wfg@linux.intel.com>
12
12
+
*
13
13
+
* This program is free software; you can redistribute it and/or modify it
14
14
+
* under the terms of the GNU General Public License as published by the Free
15
15
+
* Software Foundation; either version 2 of the License, or (at your option)
16
16
+
* any later version.
17
17
+
*
18
18
+
* This program is distributed in the hope that it will be useful, but
19
19
+
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20
20
+
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21
21
+
* for more details.
22
22
+
*
23
23
+
* You should have received a copy of the GNU General Public License
24
24
+
* along with this program; if not, write to the Free Software Foundation,
25
25
+
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26
26
+
*/
27
27
+
28
28
+
29
29
+
struct hdmi_spec {
30
30
+
int num_cvts;
31
31
+
int num_pins;
32
32
+
hda_nid_t cvt[MAX_HDMI_CVTS+1]; /* audio sources */
33
33
+
hda_nid_t pin[MAX_HDMI_PINS+1]; /* audio sinks */
34
34
+
35
35
+
/*
36
36
+
* source connection for each pin
37
37
+
*/
38
38
+
hda_nid_t pin_cvt[MAX_HDMI_PINS+1];
39
39
+
40
40
+
/*
41
41
+
* HDMI sink attached to each pin
42
42
+
*/
43
43
+
struct hdmi_eld sink_eld[MAX_HDMI_PINS];
44
44
+
45
45
+
/*
46
46
+
* export one pcm per pipe
47
47
+
*/
48
48
+
struct hda_pcm pcm_rec[MAX_HDMI_CVTS];
49
49
+
50
50
+
/*
51
51
+
* nvhdmi specific
52
52
+
*/
53
53
+
struct hda_multi_out multiout;
54
54
+
unsigned int codec_type;
55
55
+
};
56
56
+
57
57
+
58
58
+
struct hdmi_audio_infoframe {
59
59
+
u8 type; /* 0x84 */
60
60
+
u8 ver; /* 0x01 */
61
61
+
u8 len; /* 0x0a */
62
62
+
63
63
+
u8 checksum; /* PB0 */
64
64
+
u8 CC02_CT47; /* CC in bits 0:2, CT in 4:7 */
65
65
+
u8 SS01_SF24;
66
66
+
u8 CXT04;
67
67
+
u8 CA;
68
68
+
u8 LFEPBL01_LSV36_DM_INH7;
69
69
+
u8 reserved[5]; /* PB6 - PB10 */
70
70
+
};
71
71
+
72
72
+
/*
73
73
+
* CEA speaker placement:
74
74
+
*
75
75
+
* FLH FCH FRH
76
76
+
* FLW FL FLC FC FRC FR FRW
77
77
+
*
78
78
+
* LFE
79
79
+
* TC
80
80
+
*
81
81
+
* RL RLC RC RRC RR
82
82
+
*
83
83
+
* The Left/Right Surround channel _notions_ LS/RS in SMPTE 320M corresponds to
84
84
+
* CEA RL/RR; The SMPTE channel _assignment_ C/LFE is swapped to CEA LFE/FC.
85
85
+
*/
86
86
+
enum cea_speaker_placement {
87
87
+
FL = (1 << 0), /* Front Left */
88
88
+
FC = (1 << 1), /* Front Center */
89
89
+
FR = (1 << 2), /* Front Right */
90
90
+
FLC = (1 << 3), /* Front Left Center */
91
91
+
FRC = (1 << 4), /* Front Right Center */
92
92
+
RL = (1 << 5), /* Rear Left */
93
93
+
RC = (1 << 6), /* Rear Center */
94
94
+
RR = (1 << 7), /* Rear Right */
95
95
+
RLC = (1 << 8), /* Rear Left Center */
96
96
+
RRC = (1 << 9), /* Rear Right Center */
97
97
+
LFE = (1 << 10), /* Low Frequency Effect */
98
98
+
FLW = (1 << 11), /* Front Left Wide */
99
99
+
FRW = (1 << 12), /* Front Right Wide */
100
100
+
FLH = (1 << 13), /* Front Left High */
101
101
+
FCH = (1 << 14), /* Front Center High */
102
102
+
FRH = (1 << 15), /* Front Right High */
103
103
+
TC = (1 << 16), /* Top Center */
104
104
+
};
105
105
+
106
106
+
/*
107
107
+
* ELD SA bits in the CEA Speaker Allocation data block
108
108
+
*/
109
109
+
static int eld_speaker_allocation_bits[] = {
110
110
+
[0] = FL | FR,
111
111
+
[1] = LFE,
112
112
+
[2] = FC,
113
113
+
[3] = RL | RR,
114
114
+
[4] = RC,
115
115
+
[5] = FLC | FRC,
116
116
+
[6] = RLC | RRC,
117
117
+
/* the following are not defined in ELD yet */
118
118
+
[7] = FLW | FRW,
119
119
+
[8] = FLH | FRH,
120
120
+
[9] = TC,
121
121
+
[10] = FCH,
122
122
+
};
123
123
+
124
124
+
struct cea_channel_speaker_allocation {
125
125
+
int ca_index;
126
126
+
int speakers[8];
127
127
+
128
128
+
/* derived values, just for convenience */
129
129
+
int channels;
130
130
+
int spk_mask;
131
131
+
};
132
132
+
133
133
+
/*
134
134
+
* ALSA sequence is:
135
135
+
*
136
136
+
* surround40 surround41 surround50 surround51 surround71
137
137
+
* ch0 front left = = = =
138
138
+
* ch1 front right = = = =
139
139
+
* ch2 rear left = = = =
140
140
+
* ch3 rear right = = = =
141
141
+
* ch4 LFE center center center
142
142
+
* ch5 LFE LFE
143
143
+
* ch6 side left
144
144
+
* ch7 side right
145
145
+
*
146
146
+
* surround71 = {FL, FR, RLC, RRC, FC, LFE, RL, RR}
147
147
+
*/
148
148
+
static int hdmi_channel_mapping[0x32][8] = {
149
149
+
/* stereo */
150
150
+
[0x00] = { 0x00, 0x11, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7 },
151
151
+
/* 2.1 */
152
152
+
[0x01] = { 0x00, 0x11, 0x22, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7 },
153
153
+
/* Dolby Surround */
154
154
+
[0x02] = { 0x00, 0x11, 0x23, 0xf2, 0xf4, 0xf5, 0xf6, 0xf7 },
155
155
+
/* surround40 */
156
156
+
[0x08] = { 0x00, 0x11, 0x24, 0x35, 0xf3, 0xf2, 0xf6, 0xf7 },
157
157
+
/* 4ch */
158
158
+
[0x03] = { 0x00, 0x11, 0x23, 0x32, 0x44, 0xf5, 0xf6, 0xf7 },
159
159
+
/* surround41 */
160
160
+
[0x09] = { 0x00, 0x11, 0x24, 0x34, 0x43, 0xf2, 0xf6, 0xf7 },
161
161
+
/* surround50 */
162
162
+
[0x0a] = { 0x00, 0x11, 0x24, 0x35, 0x43, 0xf2, 0xf6, 0xf7 },
163
163
+
/* surround51 */
164
164
+
[0x0b] = { 0x00, 0x11, 0x24, 0x35, 0x43, 0x52, 0xf6, 0xf7 },
165
165
+
/* 7.1 */
166
166
+
[0x13] = { 0x00, 0x11, 0x26, 0x37, 0x43, 0x52, 0x64, 0x75 },
167
167
+
};
168
168
+
169
169
+
/*
170
170
+
* This is an ordered list!
171
171
+
*
172
172
+
* The preceding ones have better chances to be selected by
173
173
+
* hdmi_setup_channel_allocation().
174
174
+
*/
175
175
+
static struct cea_channel_speaker_allocation channel_allocations[] = {
176
176
+
/* channel: 7 6 5 4 3 2 1 0 */
177
177
+
{ .ca_index = 0x00, .speakers = { 0, 0, 0, 0, 0, 0, FR, FL } },
178
178
+
/* 2.1 */
179
179
+
{ .ca_index = 0x01, .speakers = { 0, 0, 0, 0, 0, LFE, FR, FL } },
180
180
+
/* Dolby Surround */
181
181
+
{ .ca_index = 0x02, .speakers = { 0, 0, 0, 0, FC, 0, FR, FL } },
182
182
+
/* surround40 */
183
183
+
{ .ca_index = 0x08, .speakers = { 0, 0, RR, RL, 0, 0, FR, FL } },
184
184
+
/* surround41 */
185
185
+
{ .ca_index = 0x09, .speakers = { 0, 0, RR, RL, 0, LFE, FR, FL } },
186
186
+
/* surround50 */
187
187
+
{ .ca_index = 0x0a, .speakers = { 0, 0, RR, RL, FC, 0, FR, FL } },
188
188
+
/* surround51 */
189
189
+
{ .ca_index = 0x0b, .speakers = { 0, 0, RR, RL, FC, LFE, FR, FL } },
190
190
+
/* 6.1 */
191
191
+
{ .ca_index = 0x0f, .speakers = { 0, RC, RR, RL, FC, LFE, FR, FL } },
192
192
+
/* surround71 */
193
193
+
{ .ca_index = 0x13, .speakers = { RRC, RLC, RR, RL, FC, LFE, FR, FL } },
194
194
+
195
195
+
{ .ca_index = 0x03, .speakers = { 0, 0, 0, 0, FC, LFE, FR, FL } },
196
196
+
{ .ca_index = 0x04, .speakers = { 0, 0, 0, RC, 0, 0, FR, FL } },
197
197
+
{ .ca_index = 0x05, .speakers = { 0, 0, 0, RC, 0, LFE, FR, FL } },
198
198
+
{ .ca_index = 0x06, .speakers = { 0, 0, 0, RC, FC, 0, FR, FL } },
199
199
+
{ .ca_index = 0x07, .speakers = { 0, 0, 0, RC, FC, LFE, FR, FL } },
200
200
+
{ .ca_index = 0x0c, .speakers = { 0, RC, RR, RL, 0, 0, FR, FL } },
201
201
+
{ .ca_index = 0x0d, .speakers = { 0, RC, RR, RL, 0, LFE, FR, FL } },
202
202
+
{ .ca_index = 0x0e, .speakers = { 0, RC, RR, RL, FC, 0, FR, FL } },
203
203
+
{ .ca_index = 0x10, .speakers = { RRC, RLC, RR, RL, 0, 0, FR, FL } },
204
204
+
{ .ca_index = 0x11, .speakers = { RRC, RLC, RR, RL, 0, LFE, FR, FL } },
205
205
+
{ .ca_index = 0x12, .speakers = { RRC, RLC, RR, RL, FC, 0, FR, FL } },
206
206
+
{ .ca_index = 0x14, .speakers = { FRC, FLC, 0, 0, 0, 0, FR, FL } },
207
207
+
{ .ca_index = 0x15, .speakers = { FRC, FLC, 0, 0, 0, LFE, FR, FL } },
208
208
+
{ .ca_index = 0x16, .speakers = { FRC, FLC, 0, 0, FC, 0, FR, FL } },
209
209
+
{ .ca_index = 0x17, .speakers = { FRC, FLC, 0, 0, FC, LFE, FR, FL } },
210
210
+
{ .ca_index = 0x18, .speakers = { FRC, FLC, 0, RC, 0, 0, FR, FL } },
211
211
+
{ .ca_index = 0x19, .speakers = { FRC, FLC, 0, RC, 0, LFE, FR, FL } },
212
212
+
{ .ca_index = 0x1a, .speakers = { FRC, FLC, 0, RC, FC, 0, FR, FL } },
213
213
+
{ .ca_index = 0x1b, .speakers = { FRC, FLC, 0, RC, FC, LFE, FR, FL } },
214
214
+
{ .ca_index = 0x1c, .speakers = { FRC, FLC, RR, RL, 0, 0, FR, FL } },
215
215
+
{ .ca_index = 0x1d, .speakers = { FRC, FLC, RR, RL, 0, LFE, FR, FL } },
216
216
+
{ .ca_index = 0x1e, .speakers = { FRC, FLC, RR, RL, FC, 0, FR, FL } },
217
217
+
{ .ca_index = 0x1f, .speakers = { FRC, FLC, RR, RL, FC, LFE, FR, FL } },
218
218
+
{ .ca_index = 0x20, .speakers = { 0, FCH, RR, RL, FC, 0, FR, FL } },
219
219
+
{ .ca_index = 0x21, .speakers = { 0, FCH, RR, RL, FC, LFE, FR, FL } },
220
220
+
{ .ca_index = 0x22, .speakers = { TC, 0, RR, RL, FC, 0, FR, FL } },
221
221
+
{ .ca_index = 0x23, .speakers = { TC, 0, RR, RL, FC, LFE, FR, FL } },
222
222
+
{ .ca_index = 0x24, .speakers = { FRH, FLH, RR, RL, 0, 0, FR, FL } },
223
223
+
{ .ca_index = 0x25, .speakers = { FRH, FLH, RR, RL, 0, LFE, FR, FL } },
224
224
+
{ .ca_index = 0x26, .speakers = { FRW, FLW, RR, RL, 0, 0, FR, FL } },
225
225
+
{ .ca_index = 0x27, .speakers = { FRW, FLW, RR, RL, 0, LFE, FR, FL } },
226
226
+
{ .ca_index = 0x28, .speakers = { TC, RC, RR, RL, FC, 0, FR, FL } },
227
227
+
{ .ca_index = 0x29, .speakers = { TC, RC, RR, RL, FC, LFE, FR, FL } },
228
228
+
{ .ca_index = 0x2a, .speakers = { FCH, RC, RR, RL, FC, 0, FR, FL } },
229
229
+
{ .ca_index = 0x2b, .speakers = { FCH, RC, RR, RL, FC, LFE, FR, FL } },
230
230
+
{ .ca_index = 0x2c, .speakers = { TC, FCH, RR, RL, FC, 0, FR, FL } },
231
231
+
{ .ca_index = 0x2d, .speakers = { TC, FCH, RR, RL, FC, LFE, FR, FL } },
232
232
+
{ .ca_index = 0x2e, .speakers = { FRH, FLH, RR, RL, FC, 0, FR, FL } },
233
233
+
{ .ca_index = 0x2f, .speakers = { FRH, FLH, RR, RL, FC, LFE, FR, FL } },
234
234
+
{ .ca_index = 0x30, .speakers = { FRW, FLW, RR, RL, FC, 0, FR, FL } },
235
235
+
{ .ca_index = 0x31, .speakers = { FRW, FLW, RR, RL, FC, LFE, FR, FL } },
236
236
+
};
237
237
+
238
238
+
239
239
+
/*
240
240
+
* HDMI routines
241
241
+
*/
242
242
+
243
243
+
static int hda_node_index(hda_nid_t *nids, hda_nid_t nid)
244
244
+
{
245
245
+
int i;
246
246
+
247
247
+
for (i = 0; nids[i]; i++)
248
248
+
if (nids[i] == nid)
249
249
+
return i;
250
250
+
251
251
+
snd_printk(KERN_WARNING "HDMI: nid %d not registered\n", nid);
252
252
+
return -EINVAL;
253
253
+
}
254
254
+
255
255
+
static void hdmi_get_show_eld(struct hda_codec *codec, hda_nid_t pin_nid,
256
256
+
struct hdmi_eld *eld)
257
257
+
{
258
258
+
if (!snd_hdmi_get_eld(eld, codec, pin_nid))
259
259
+
snd_hdmi_show_eld(eld);
260
260
+
}
261
261
+
262
262
+
#ifdef BE_PARANOID
263
263
+
static void hdmi_get_dip_index(struct hda_codec *codec, hda_nid_t pin_nid,
264
264
+
int *packet_index, int *byte_index)
265
265
+
{
266
266
+
int val;
267
267
+
268
268
+
val = snd_hda_codec_read(codec, pin_nid, 0,
269
269
+
AC_VERB_GET_HDMI_DIP_INDEX, 0);
270
270
+
271
271
+
*packet_index = val >> 5;
272
272
+
*byte_index = val & 0x1f;
273
273
+
}
274
274
+
#endif
275
275
+
276
276
+
static void hdmi_set_dip_index(struct hda_codec *codec, hda_nid_t pin_nid,
277
277
+
int packet_index, int byte_index)
278
278
+
{
279
279
+
int val;
280
280
+
281
281
+
val = (packet_index << 5) | (byte_index & 0x1f);
282
282
+
283
283
+
snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_INDEX, val);
284
284
+
}
285
285
+
286
286
+
static void hdmi_write_dip_byte(struct hda_codec *codec, hda_nid_t pin_nid,
287
287
+
unsigned char val)
288
288
+
{
289
289
+
snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_DATA, val);
290
290
+
}
291
291
+
292
292
+
static void hdmi_enable_output(struct hda_codec *codec, hda_nid_t pin_nid)
293
293
+
{
294
294
+
/* Unmute */
295
295
+
if (get_wcaps(codec, pin_nid) & AC_WCAP_OUT_AMP)
296
296
+
snd_hda_codec_write(codec, pin_nid, 0,
297
297
+
AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
298
298
+
/* Enable pin out */
299
299
+
snd_hda_codec_write(codec, pin_nid, 0,
300
300
+
AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
301
301
+
}
302
302
+
303
303
+
static int hdmi_get_channel_count(struct hda_codec *codec, hda_nid_t nid)
304
304
+
{
305
305
+
return 1 + snd_hda_codec_read(codec, nid, 0,
306
306
+
AC_VERB_GET_CVT_CHAN_COUNT, 0);
307
307
+
}
308
308
+
309
309
+
static void hdmi_set_channel_count(struct hda_codec *codec,
310
310
+
hda_nid_t nid, int chs)
311
311
+
{
312
312
+
if (chs != hdmi_get_channel_count(codec, nid))
313
313
+
snd_hda_codec_write(codec, nid, 0,
314
314
+
AC_VERB_SET_CVT_CHAN_COUNT, chs - 1);
315
315
+
}
316
316
+
317
317
+
318
318
+
/*
319
319
+
* Channel mapping routines
320
320
+
*/
321
321
+
322
322
+
/*
323
323
+
* Compute derived values in channel_allocations[].
324
324
+
*/
325
325
+
static void init_channel_allocations(void)
326
326
+
{
327
327
+
int i, j;
328
328
+
struct cea_channel_speaker_allocation *p;
329
329
+
330
330
+
for (i = 0; i < ARRAY_SIZE(channel_allocations); i++) {
331
331
+
p = channel_allocations + i;
332
332
+
p->channels = 0;
333
333
+
p->spk_mask = 0;
334
334
+
for (j = 0; j < ARRAY_SIZE(p->speakers); j++)
335
335
+
if (p->speakers[j]) {
336
336
+
p->channels++;
337
337
+
p->spk_mask |= p->speakers[j];
338
338
+
}
339
339
+
}
340
340
+
}
341
341
+
342
342
+
/*
343
343
+
* The transformation takes two steps:
344
344
+
*
345
345
+
* eld->spk_alloc => (eld_speaker_allocation_bits[]) => spk_mask
346
346
+
* spk_mask => (channel_allocations[]) => ai->CA
347
347
+
*
348
348
+
* TODO: it could select the wrong CA from multiple candidates.
349
349
+
*/
350
350
+
static int hdmi_setup_channel_allocation(struct hda_codec *codec, hda_nid_t nid,
351
351
+
struct hdmi_audio_infoframe *ai)
352
352
+
{
353
353
+
struct hdmi_spec *spec = codec->spec;
354
354
+
struct hdmi_eld *eld;
355
355
+
int i;
356
356
+
int spk_mask = 0;
357
357
+
int channels = 1 + (ai->CC02_CT47 & 0x7);
358
358
+
char buf[SND_PRINT_CHANNEL_ALLOCATION_ADVISED_BUFSIZE];
359
359
+
360
360
+
/*
361
361
+
* CA defaults to 0 for basic stereo audio
362
362
+
*/
363
363
+
if (channels <= 2)
364
364
+
return 0;
365
365
+
366
366
+
i = hda_node_index(spec->pin_cvt, nid);
367
367
+
if (i < 0)
368
368
+
return 0;
369
369
+
eld = &spec->sink_eld[i];
370
370
+
371
371
+
/*
372
372
+
* HDMI sink's ELD info cannot always be retrieved for now, e.g.
373
373
+
* in console or for audio devices. Assume the highest speakers
374
374
+
* configuration, to _not_ prohibit multi-channel audio playback.
375
375
+
*/
376
376
+
if (!eld->spk_alloc)
377
377
+
eld->spk_alloc = 0xffff;
378
378
+
379
379
+
/*
380
380
+
* expand ELD's speaker allocation mask
381
381
+
*
382
382
+
* ELD tells the speaker mask in a compact(paired) form,
383
383
+
* expand ELD's notions to match the ones used by Audio InfoFrame.
384
384
+
*/
385
385
+
for (i = 0; i < ARRAY_SIZE(eld_speaker_allocation_bits); i++) {
386
386
+
if (eld->spk_alloc & (1 << i))
387
387
+
spk_mask |= eld_speaker_allocation_bits[i];
388
388
+
}
389
389
+
390
390
+
/* search for the first working match in the CA table */
391
391
+
for (i = 0; i < ARRAY_SIZE(channel_allocations); i++) {
392
392
+
if (channels == channel_allocations[i].channels &&
393
393
+
(spk_mask & channel_allocations[i].spk_mask) ==
394
394
+
channel_allocations[i].spk_mask) {
395
395
+
ai->CA = channel_allocations[i].ca_index;
396
396
+
break;
397
397
+
}
398
398
+
}
399
399
+
400
400
+
snd_print_channel_allocation(eld->spk_alloc, buf, sizeof(buf));
401
401
+
snd_printdd("HDMI: select CA 0x%x for %d-channel allocation: %s\n",
402
402
+
ai->CA, channels, buf);
403
403
+
404
404
+
return ai->CA;
405
405
+
}
406
406
+
407
407
+
static void hdmi_debug_channel_mapping(struct hda_codec *codec,
408
408
+
hda_nid_t pin_nid)
409
409
+
{
410
410
+
#ifdef CONFIG_SND_DEBUG_VERBOSE
411
411
+
int i;
412
412
+
int slot;
413
413
+
414
414
+
for (i = 0; i < 8; i++) {
415
415
+
slot = snd_hda_codec_read(codec, pin_nid, 0,
416
416
+
AC_VERB_GET_HDMI_CHAN_SLOT, i);
417
417
+
printk(KERN_DEBUG "HDMI: ASP channel %d => slot %d\n",
418
418
+
slot >> 4, slot & 0xf);
419
419
+
}
420
420
+
#endif
421
421
+
}
422
422
+
423
423
+
424
424
+
static void hdmi_setup_channel_mapping(struct hda_codec *codec,
425
425
+
hda_nid_t pin_nid,
426
426
+
struct hdmi_audio_infoframe *ai)
427
427
+
{
428
428
+
int i;
429
429
+
int ca = ai->CA;
430
430
+
int err;
431
431
+
432
432
+
if (hdmi_channel_mapping[ca][1] == 0) {
433
433
+
for (i = 0; i < channel_allocations[ca].channels; i++)
434
434
+
hdmi_channel_mapping[ca][i] = i | (i << 4);
435
435
+
for (; i < 8; i++)
436
436
+
hdmi_channel_mapping[ca][i] = 0xf | (i << 4);
437
437
+
}
438
438
+
439
439
+
for (i = 0; i < 8; i++) {
440
440
+
err = snd_hda_codec_write(codec, pin_nid, 0,
441
441
+
AC_VERB_SET_HDMI_CHAN_SLOT,
442
442
+
hdmi_channel_mapping[ca][i]);
443
443
+
if (err) {
444
444
+
snd_printdd(KERN_NOTICE
445
445
+
"HDMI: channel mapping failed\n");
446
446
+
break;
447
447
+
}
448
448
+
}
449
449
+
450
450
+
hdmi_debug_channel_mapping(codec, pin_nid);
451
451
+
}
452
452
+
453
453
+
454
454
+
/*
455
455
+
* Audio InfoFrame routines
456
456
+
*/
457
457
+
458
458
+
/*
459
459
+
* Enable Audio InfoFrame Transmission
460
460
+
*/
461
461
+
static void hdmi_start_infoframe_trans(struct hda_codec *codec,
462
462
+
hda_nid_t pin_nid)
463
463
+
{
464
464
+
hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0);
465
465
+
snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_XMIT,
466
466
+
AC_DIPXMIT_BEST);
467
467
+
}
468
468
+
469
469
+
/*
470
470
+
* Disable Audio InfoFrame Transmission
471
471
+
*/
472
472
+
static void hdmi_stop_infoframe_trans(struct hda_codec *codec,
473
473
+
hda_nid_t pin_nid)
474
474
+
{
475
475
+
hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0);
476
476
+
snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_XMIT,
477
477
+
AC_DIPXMIT_DISABLE);
478
478
+
}
479
479
+
480
480
+
static void hdmi_debug_dip_size(struct hda_codec *codec, hda_nid_t pin_nid)
481
481
+
{
482
482
+
#ifdef CONFIG_SND_DEBUG_VERBOSE
483
483
+
int i;
484
484
+
int size;
485
485
+
486
486
+
size = snd_hdmi_get_eld_size(codec, pin_nid);
487
487
+
printk(KERN_DEBUG "HDMI: ELD buf size is %d\n", size);
488
488
+
489
489
+
for (i = 0; i < 8; i++) {
490
490
+
size = snd_hda_codec_read(codec, pin_nid, 0,
491
491
+
AC_VERB_GET_HDMI_DIP_SIZE, i);
492
492
+
printk(KERN_DEBUG "HDMI: DIP GP[%d] buf size is %d\n", i, size);
493
493
+
}
494
494
+
#endif
495
495
+
}
496
496
+
497
497
+
static void hdmi_clear_dip_buffers(struct hda_codec *codec, hda_nid_t pin_nid)
498
498
+
{
499
499
+
#ifdef BE_PARANOID
500
500
+
int i, j;
501
501
+
int size;
502
502
+
int pi, bi;
503
503
+
for (i = 0; i < 8; i++) {
504
504
+
size = snd_hda_codec_read(codec, pin_nid, 0,
505
505
+
AC_VERB_GET_HDMI_DIP_SIZE, i);
506
506
+
if (size == 0)
507
507
+
continue;
508
508
+
509
509
+
hdmi_set_dip_index(codec, pin_nid, i, 0x0);
510
510
+
for (j = 1; j < 1000; j++) {
511
511
+
hdmi_write_dip_byte(codec, pin_nid, 0x0);
512
512
+
hdmi_get_dip_index(codec, pin_nid, &pi, &bi);
513
513
+
if (pi != i)
514
514
+
snd_printd(KERN_INFO "dip index %d: %d != %d\n",
515
515
+
bi, pi, i);
516
516
+
if (bi == 0) /* byte index wrapped around */
517
517
+
break;
518
518
+
}
519
519
+
snd_printd(KERN_INFO
520
520
+
"HDMI: DIP GP[%d] buf reported size=%d, written=%d\n",
521
521
+
i, size, j);
522
522
+
}
523
523
+
#endif
524
524
+
}
525
525
+
526
526
+
static void hdmi_checksum_audio_infoframe(struct hdmi_audio_infoframe *ai)
527
527
+
{
528
528
+
u8 *bytes = (u8 *)ai;
529
529
+
u8 sum = 0;
530
530
+
int i;
531
531
+
532
532
+
ai->checksum = 0;
533
533
+
534
534
+
for (i = 0; i < sizeof(*ai); i++)
535
535
+
sum += bytes[i];
536
536
+
537
537
+
ai->checksum = -sum;
538
538
+
}
539
539
+
540
540
+
static void hdmi_fill_audio_infoframe(struct hda_codec *codec,
541
541
+
hda_nid_t pin_nid,
542
542
+
struct hdmi_audio_infoframe *ai)
543
543
+
{
544
544
+
u8 *bytes = (u8 *)ai;
545
545
+
int i;
546
546
+
547
547
+
hdmi_debug_dip_size(codec, pin_nid);
548
548
+
hdmi_clear_dip_buffers(codec, pin_nid); /* be paranoid */
549
549
+
550
550
+
hdmi_checksum_audio_infoframe(ai);
551
551
+
552
552
+
hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0);
553
553
+
for (i = 0; i < sizeof(*ai); i++)
554
554
+
hdmi_write_dip_byte(codec, pin_nid, bytes[i]);
555
555
+
}
556
556
+
557
557
+
static bool hdmi_infoframe_uptodate(struct hda_codec *codec, hda_nid_t pin_nid,
558
558
+
struct hdmi_audio_infoframe *ai)
559
559
+
{
560
560
+
u8 *bytes = (u8 *)ai;
561
561
+
u8 val;
562
562
+
int i;
563
563
+
564
564
+
if (snd_hda_codec_read(codec, pin_nid, 0, AC_VERB_GET_HDMI_DIP_XMIT, 0)
565
565
+
!= AC_DIPXMIT_BEST)
566
566
+
return false;
567
567
+
568
568
+
hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0);
569
569
+
for (i = 0; i < sizeof(*ai); i++) {
570
570
+
val = snd_hda_codec_read(codec, pin_nid, 0,
571
571
+
AC_VERB_GET_HDMI_DIP_DATA, 0);
572
572
+
if (val != bytes[i])
573
573
+
return false;
574
574
+
}
575
575
+
576
576
+
return true;
577
577
+
}
578
578
+
579
579
+
static void hdmi_setup_audio_infoframe(struct hda_codec *codec, hda_nid_t nid,
580
580
+
struct snd_pcm_substream *substream)
581
581
+
{
582
582
+
struct hdmi_spec *spec = codec->spec;
583
583
+
hda_nid_t pin_nid;
584
584
+
int i;
585
585
+
struct hdmi_audio_infoframe ai = {
586
586
+
.type = 0x84,
587
587
+
.ver = 0x01,
588
588
+
.len = 0x0a,
589
589
+
.CC02_CT47 = substream->runtime->channels - 1,
590
590
+
};
591
591
+
592
592
+
hdmi_setup_channel_allocation(codec, nid, &ai);
593
593
+
594
594
+
for (i = 0; i < spec->num_pins; i++) {
595
595
+
if (spec->pin_cvt[i] != nid)
596
596
+
continue;
597
597
+
if (!spec->sink_eld[i].monitor_present)
598
598
+
continue;
599
599
+
600
600
+
pin_nid = spec->pin[i];
601
601
+
if (!hdmi_infoframe_uptodate(codec, pin_nid, &ai)) {
602
602
+
snd_printdd("hdmi_setup_audio_infoframe: "
603
603
+
"cvt=%d pin=%d channels=%d\n",
604
604
+
nid, pin_nid,
605
605
+
substream->runtime->channels);
606
606
+
hdmi_setup_channel_mapping(codec, pin_nid, &ai);
607
607
+
hdmi_stop_infoframe_trans(codec, pin_nid);
608
608
+
hdmi_fill_audio_infoframe(codec, pin_nid, &ai);
609
609
+
hdmi_start_infoframe_trans(codec, pin_nid);
610
610
+
}
611
611
+
}
612
612
+
}
613
613
+
614
614
+
615
615
+
/*
616
616
+
* Unsolicited events
617
617
+
*/
618
618
+
619
619
+
static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res)
620
620
+
{
621
621
+
struct hdmi_spec *spec = codec->spec;
622
622
+
int tag = res >> AC_UNSOL_RES_TAG_SHIFT;
623
623
+
int pind = !!(res & AC_UNSOL_RES_PD);
624
624
+
int eldv = !!(res & AC_UNSOL_RES_ELDV);
625
625
+
int index;
626
626
+
627
627
+
printk(KERN_INFO
628
628
+
"HDMI hot plug event: Pin=%d Presence_Detect=%d ELD_Valid=%d\n",
629
629
+
tag, pind, eldv);
630
630
+
631
631
+
index = hda_node_index(spec->pin, tag);
632
632
+
if (index < 0)
633
633
+
return;
634
634
+
635
635
+
spec->sink_eld[index].monitor_present = pind;
636
636
+
spec->sink_eld[index].eld_valid = eldv;
637
637
+
638
638
+
if (pind && eldv) {
639
639
+
hdmi_get_show_eld(codec, spec->pin[index],
640
640
+
&spec->sink_eld[index]);
641
641
+
/* TODO: do real things about ELD */
642
642
+
}
643
643
+
}
644
644
+
645
645
+
static void hdmi_non_intrinsic_event(struct hda_codec *codec, unsigned int res)
646
646
+
{
647
647
+
int tag = res >> AC_UNSOL_RES_TAG_SHIFT;
648
648
+
int subtag = (res & AC_UNSOL_RES_SUBTAG) >> AC_UNSOL_RES_SUBTAG_SHIFT;
649
649
+
int cp_state = !!(res & AC_UNSOL_RES_CP_STATE);
650
650
+
int cp_ready = !!(res & AC_UNSOL_RES_CP_READY);
651
651
+
652
652
+
printk(KERN_INFO
653
653
+
"HDMI CP event: PIN=%d SUBTAG=0x%x CP_STATE=%d CP_READY=%d\n",
654
654
+
tag,
655
655
+
subtag,
656
656
+
cp_state,
657
657
+
cp_ready);
658
658
+
659
659
+
/* TODO */
660
660
+
if (cp_state)
661
661
+
;
662
662
+
if (cp_ready)
663
663
+
;
664
664
+
}
665
665
+
666
666
+
667
667
+
static void hdmi_unsol_event(struct hda_codec *codec, unsigned int res)
668
668
+
{
669
669
+
struct hdmi_spec *spec = codec->spec;
670
670
+
int tag = res >> AC_UNSOL_RES_TAG_SHIFT;
671
671
+
int subtag = (res & AC_UNSOL_RES_SUBTAG) >> AC_UNSOL_RES_SUBTAG_SHIFT;
672
672
+
673
673
+
if (hda_node_index(spec->pin, tag) < 0) {
674
674
+
snd_printd(KERN_INFO "Unexpected HDMI event tag 0x%x\n", tag);
675
675
+
return;
676
676
+
}
677
677
+
678
678
+
if (subtag == 0)
679
679
+
hdmi_intrinsic_event(codec, res);
680
680
+
else
681
681
+
hdmi_non_intrinsic_event(codec, res);
682
682
+
}
683
683
+
684
684
+
/*
685
685
+
* Callbacks
686
686
+
*/
687
687
+
688
688
+
static void hdmi_setup_stream(struct hda_codec *codec, hda_nid_t nid,
689
689
+
u32 stream_tag, int format)
690
690
+
{
691
691
+
int tag;
692
692
+
int fmt;
693
693
+
694
694
+
tag = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONV, 0) >> 4;
695
695
+
fmt = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_STREAM_FORMAT, 0);
696
696
+
697
697
+
snd_printdd("hdmi_setup_stream: "
698
698
+
"NID=0x%x, %sstream=0x%x, %sformat=0x%x\n",
699
699
+
nid,
700
700
+
tag == stream_tag ? "" : "new-",
701
701
+
stream_tag,
702
702
+
fmt == format ? "" : "new-",
703
703
+
format);
704
704
+
705
705
+
if (tag != stream_tag)
706
706
+
snd_hda_codec_write(codec, nid, 0,
707
707
+
AC_VERB_SET_CHANNEL_STREAMID,
708
708
+
stream_tag << 4);
709
709
+
if (fmt != format)
710
710
+
snd_hda_codec_write(codec, nid, 0,
711
711
+
AC_VERB_SET_STREAM_FORMAT, format);
712
712
+
}
713
713
+
714
714
+
/*
715
715
+
* HDA/HDMI auto parsing
716
716
+
*/
717
717
+
718
718
+
static int hdmi_read_pin_conn(struct hda_codec *codec, hda_nid_t pin_nid)
719
719
+
{
720
720
+
struct hdmi_spec *spec = codec->spec;
721
721
+
hda_nid_t conn_list[HDA_MAX_CONNECTIONS];
722
722
+
int conn_len, curr;
723
723
+
int index;
724
724
+
725
725
+
if (!(get_wcaps(codec, pin_nid) & AC_WCAP_CONN_LIST)) {
726
726
+
snd_printk(KERN_WARNING
727
727
+
"HDMI: pin %d wcaps %#x "
728
728
+
"does not support connection list\n",
729
729
+
pin_nid, get_wcaps(codec, pin_nid));
730
730
+
return -EINVAL;
731
731
+
}
732
732
+
733
733
+
conn_len = snd_hda_get_connections(codec, pin_nid, conn_list,
734
734
+
HDA_MAX_CONNECTIONS);
735
735
+
if (conn_len > 1)
736
736
+
curr = snd_hda_codec_read(codec, pin_nid, 0,
737
737
+
AC_VERB_GET_CONNECT_SEL, 0);
738
738
+
else
739
739
+
curr = 0;
740
740
+
741
741
+
index = hda_node_index(spec->pin, pin_nid);
742
742
+
if (index < 0)
743
743
+
return -EINVAL;
744
744
+
745
745
+
spec->pin_cvt[index] = conn_list[curr];
746
746
+
747
747
+
return 0;
748
748
+
}
749
749
+
750
750
+
static void hdmi_present_sense(struct hda_codec *codec, hda_nid_t pin_nid,
751
751
+
struct hdmi_eld *eld)
752
752
+
{
753
753
+
int present = snd_hda_pin_sense(codec, pin_nid);
754
754
+
755
755
+
eld->monitor_present = !!(present & AC_PINSENSE_PRESENCE);
756
756
+
eld->eld_valid = !!(present & AC_PINSENSE_ELDV);
757
757
+
758
758
+
if (present & AC_PINSENSE_ELDV)
759
759
+
hdmi_get_show_eld(codec, pin_nid, eld);
760
760
+
}
761
761
+
762
762
+
static int hdmi_add_pin(struct hda_codec *codec, hda_nid_t pin_nid)
763
763
+
{
764
764
+
struct hdmi_spec *spec = codec->spec;
765
765
+
766
766
+
if (spec->num_pins >= MAX_HDMI_PINS) {
767
767
+
snd_printk(KERN_WARNING
768
768
+
"HDMI: no space for pin %d\n", pin_nid);
769
769
+
return -EINVAL;
770
770
+
}
771
771
+
772
772
+
hdmi_present_sense(codec, pin_nid, &spec->sink_eld[spec->num_pins]);
773
773
+
774
774
+
spec->pin[spec->num_pins] = pin_nid;
775
775
+
spec->num_pins++;
776
776
+
777
777
+
/*
778
778
+
* It is assumed that converter nodes come first in the node list and
779
779
+
* hence have been registered and usable now.
780
780
+
*/
781
781
+
return hdmi_read_pin_conn(codec, pin_nid);
782
782
+
}
783
783
+
784
784
+
static int hdmi_add_cvt(struct hda_codec *codec, hda_nid_t nid)
785
785
+
{
786
786
+
struct hdmi_spec *spec = codec->spec;
787
787
+
788
788
+
if (spec->num_cvts >= MAX_HDMI_CVTS) {
789
789
+
snd_printk(KERN_WARNING
790
790
+
"HDMI: no space for converter %d\n", nid);
791
791
+
return -EINVAL;
792
792
+
}
793
793
+
794
794
+
spec->cvt[spec->num_cvts] = nid;
795
795
+
spec->num_cvts++;
796
796
+
797
797
+
return 0;
798
798
+
}
799
799
+
800
800
+
static int hdmi_parse_codec(struct hda_codec *codec)
801
801
+
{
802
802
+
hda_nid_t nid;
803
803
+
int i, nodes;
804
804
+
805
805
+
nodes = snd_hda_get_sub_nodes(codec, codec->afg, &nid);
806
806
+
if (!nid || nodes < 0) {
807
807
+
snd_printk(KERN_WARNING "HDMI: failed to get afg sub nodes\n");
808
808
+
return -EINVAL;
809
809
+
}
810
810
+
811
811
+
for (i = 0; i < nodes; i++, nid++) {
812
812
+
unsigned int caps;
813
813
+
unsigned int type;
814
814
+
815
815
+
caps = snd_hda_param_read(codec, nid, AC_PAR_AUDIO_WIDGET_CAP);
816
816
+
type = get_wcaps_type(caps);
817
817
+
818
818
+
if (!(caps & AC_WCAP_DIGITAL))
819
819
+
continue;
820
820
+
821
821
+
switch (type) {
822
822
+
case AC_WID_AUD_OUT:
823
823
+
if (hdmi_add_cvt(codec, nid) < 0)
824
824
+
return -EINVAL;
825
825
+
break;
826
826
+
case AC_WID_PIN:
827
827
+
caps = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
828
828
+
if (!(caps & (AC_PINCAP_HDMI | AC_PINCAP_DP)))
829
829
+
continue;
830
830
+
if (hdmi_add_pin(codec, nid) < 0)
831
831
+
return -EINVAL;
832
832
+
break;
833
833
+
}
834
834
+
}
835
835
+
836
836
+
/*
837
837
+
* G45/IbexPeak don't support EPSS: the unsolicited pin hot plug event
838
838
+
* can be lost and presence sense verb will become inaccurate if the
839
839
+
* HDA link is powered off at hot plug or hw initialization time.
840
840
+
*/
841
841
+
#ifdef CONFIG_SND_HDA_POWER_SAVE
842
842
+
if (!(snd_hda_param_read(codec, codec->afg, AC_PAR_POWER_STATE) &
843
843
+
AC_PWRST_EPSS))
844
844
+
codec->bus->power_keep_link_on = 1;
845
845
+
#endif
846
846
+
847
847
+
return 0;
848
848
+
}
849
849
+
+13
-808
sound/pci/hda/patch_intelhdmi.c
···
40
40
*
41
41
* The HDA correspondence of pipes/ports are converter/pin nodes.
42
42
*/
43
43
-
#define INTEL_HDMI_CVTS 2
44
44
-
#define INTEL_HDMI_PINS 3
43
43
+
#define MAX_HDMI_CVTS 2
44
44
+
#define MAX_HDMI_PINS 3
45
45
46
46
-
static char *intel_hdmi_pcm_names[INTEL_HDMI_CVTS] = {
46
46
+
#include "patch_hdmi.c"
47
47
+
48
48
+
static char *intel_hdmi_pcm_names[MAX_HDMI_CVTS] = {
47
49
"INTEL HDMI 0",
48
50
"INTEL HDMI 1",
49
51
};
50
52
51
51
-
struct intel_hdmi_spec {
52
52
-
int num_cvts;
53
53
-
int num_pins;
54
54
-
hda_nid_t cvt[INTEL_HDMI_CVTS+1]; /* audio sources */
55
55
-
hda_nid_t pin[INTEL_HDMI_PINS+1]; /* audio sinks */
56
56
-
57
57
-
/*
58
58
-
* source connection for each pin
59
59
-
*/
60
60
-
hda_nid_t pin_cvt[INTEL_HDMI_PINS+1];
61
61
-
62
62
-
/*
63
63
-
* HDMI sink attached to each pin
64
64
-
*/
65
65
-
struct hdmi_eld sink_eld[INTEL_HDMI_PINS];
66
66
-
67
67
-
/*
68
68
-
* export one pcm per pipe
69
69
-
*/
70
70
-
struct hda_pcm pcm_rec[INTEL_HDMI_CVTS];
71
71
-
};
72
72
-
73
73
-
struct hdmi_audio_infoframe {
74
74
-
u8 type; /* 0x84 */
75
75
-
u8 ver; /* 0x01 */
76
76
-
u8 len; /* 0x0a */
77
77
-
78
78
-
u8 checksum; /* PB0 */
79
79
-
u8 CC02_CT47; /* CC in bits 0:2, CT in 4:7 */
80
80
-
u8 SS01_SF24;
81
81
-
u8 CXT04;
82
82
-
u8 CA;
83
83
-
u8 LFEPBL01_LSV36_DM_INH7;
84
84
-
u8 reserved[5]; /* PB6 - PB10 */
85
85
-
};
86
86
-
87
53
/*
88
88
-
* CEA speaker placement:
89
89
-
*
90
90
-
* FLH FCH FRH
91
91
-
* FLW FL FLC FC FRC FR FRW
92
92
-
*
93
93
-
* LFE
94
94
-
* TC
95
95
-
*
96
96
-
* RL RLC RC RRC RR
97
97
-
*
98
98
-
* The Left/Right Surround channel _notions_ LS/RS in SMPTE 320M corresponds to
99
99
-
* CEA RL/RR; The SMPTE channel _assignment_ C/LFE is swapped to CEA LFE/FC.
54
54
+
* HDMI callbacks
100
55
*/
101
101
-
enum cea_speaker_placement {
102
102
-
FL = (1 << 0), /* Front Left */
103
103
-
FC = (1 << 1), /* Front Center */
104
104
-
FR = (1 << 2), /* Front Right */
105
105
-
FLC = (1 << 3), /* Front Left Center */
106
106
-
FRC = (1 << 4), /* Front Right Center */
107
107
-
RL = (1 << 5), /* Rear Left */
108
108
-
RC = (1 << 6), /* Rear Center */
109
109
-
RR = (1 << 7), /* Rear Right */
110
110
-
RLC = (1 << 8), /* Rear Left Center */
111
111
-
RRC = (1 << 9), /* Rear Right Center */
112
112
-
LFE = (1 << 10), /* Low Frequency Effect */
113
113
-
FLW = (1 << 11), /* Front Left Wide */
114
114
-
FRW = (1 << 12), /* Front Right Wide */
115
115
-
FLH = (1 << 13), /* Front Left High */
116
116
-
FCH = (1 << 14), /* Front Center High */
117
117
-
FRH = (1 << 15), /* Front Right High */
118
118
-
TC = (1 << 16), /* Top Center */
119
119
-
};
120
120
-
121
121
-
/*
122
122
-
* ELD SA bits in the CEA Speaker Allocation data block
123
123
-
*/
124
124
-
static int eld_speaker_allocation_bits[] = {
125
125
-
[0] = FL | FR,
126
126
-
[1] = LFE,
127
127
-
[2] = FC,
128
128
-
[3] = RL | RR,
129
129
-
[4] = RC,
130
130
-
[5] = FLC | FRC,
131
131
-
[6] = RLC | RRC,
132
132
-
/* the following are not defined in ELD yet */
133
133
-
[7] = FLW | FRW,
134
134
-
[8] = FLH | FRH,
135
135
-
[9] = TC,
136
136
-
[10] = FCH,
137
137
-
};
138
138
-
139
139
-
struct cea_channel_speaker_allocation {
140
140
-
int ca_index;
141
141
-
int speakers[8];
142
142
-
143
143
-
/* derived values, just for convenience */
144
144
-
int channels;
145
145
-
int spk_mask;
146
146
-
};
147
147
-
148
148
-
/*
149
149
-
* ALSA sequence is:
150
150
-
*
151
151
-
* surround40 surround41 surround50 surround51 surround71
152
152
-
* ch0 front left = = = =
153
153
-
* ch1 front right = = = =
154
154
-
* ch2 rear left = = = =
155
155
-
* ch3 rear right = = = =
156
156
-
* ch4 LFE center center center
157
157
-
* ch5 LFE LFE
158
158
-
* ch6 side left
159
159
-
* ch7 side right
160
160
-
*
161
161
-
* surround71 = {FL, FR, RLC, RRC, FC, LFE, RL, RR}
162
162
-
*/
163
163
-
static int hdmi_channel_mapping[0x32][8] = {
164
164
-
/* stereo */
165
165
-
[0x00] = { 0x00, 0x11, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7 },
166
166
-
/* 2.1 */
167
167
-
[0x01] = { 0x00, 0x11, 0x22, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7 },
168
168
-
/* Dolby Surround */
169
169
-
[0x02] = { 0x00, 0x11, 0x23, 0xf2, 0xf4, 0xf5, 0xf6, 0xf7 },
170
170
-
/* surround40 */
171
171
-
[0x08] = { 0x00, 0x11, 0x24, 0x35, 0xf3, 0xf2, 0xf6, 0xf7 },
172
172
-
/* 4ch */
173
173
-
[0x03] = { 0x00, 0x11, 0x23, 0x32, 0x44, 0xf5, 0xf6, 0xf7 },
174
174
-
/* surround41 */
175
175
-
[0x09] = { 0x00, 0x11, 0x24, 0x34, 0x43, 0xf2, 0xf6, 0xf7 },
176
176
-
/* surround50 */
177
177
-
[0x0a] = { 0x00, 0x11, 0x24, 0x35, 0x43, 0xf2, 0xf6, 0xf7 },
178
178
-
/* surround51 */
179
179
-
[0x0b] = { 0x00, 0x11, 0x24, 0x35, 0x43, 0x52, 0xf6, 0xf7 },
180
180
-
/* 7.1 */
181
181
-
[0x13] = { 0x00, 0x11, 0x26, 0x37, 0x43, 0x52, 0x64, 0x75 },
182
182
-
};
183
183
-
184
184
-
/*
185
185
-
* This is an ordered list!
186
186
-
*
187
187
-
* The preceding ones have better chances to be selected by
188
188
-
* hdmi_setup_channel_allocation().
189
189
-
*/
190
190
-
static struct cea_channel_speaker_allocation channel_allocations[] = {
191
191
-
/* channel: 7 6 5 4 3 2 1 0 */
192
192
-
{ .ca_index = 0x00, .speakers = { 0, 0, 0, 0, 0, 0, FR, FL } },
193
193
-
/* 2.1 */
194
194
-
{ .ca_index = 0x01, .speakers = { 0, 0, 0, 0, 0, LFE, FR, FL } },
195
195
-
/* Dolby Surround */
196
196
-
{ .ca_index = 0x02, .speakers = { 0, 0, 0, 0, FC, 0, FR, FL } },
197
197
-
/* surround40 */
198
198
-
{ .ca_index = 0x08, .speakers = { 0, 0, RR, RL, 0, 0, FR, FL } },
199
199
-
/* surround41 */
200
200
-
{ .ca_index = 0x09, .speakers = { 0, 0, RR, RL, 0, LFE, FR, FL } },
201
201
-
/* surround50 */
202
202
-
{ .ca_index = 0x0a, .speakers = { 0, 0, RR, RL, FC, 0, FR, FL } },
203
203
-
/* surround51 */
204
204
-
{ .ca_index = 0x0b, .speakers = { 0, 0, RR, RL, FC, LFE, FR, FL } },
205
205
-
/* 6.1 */
206
206
-
{ .ca_index = 0x0f, .speakers = { 0, RC, RR, RL, FC, LFE, FR, FL } },
207
207
-
/* surround71 */
208
208
-
{ .ca_index = 0x13, .speakers = { RRC, RLC, RR, RL, FC, LFE, FR, FL } },
209
209
-
210
210
-
{ .ca_index = 0x03, .speakers = { 0, 0, 0, 0, FC, LFE, FR, FL } },
211
211
-
{ .ca_index = 0x04, .speakers = { 0, 0, 0, RC, 0, 0, FR, FL } },
212
212
-
{ .ca_index = 0x05, .speakers = { 0, 0, 0, RC, 0, LFE, FR, FL } },
213
213
-
{ .ca_index = 0x06, .speakers = { 0, 0, 0, RC, FC, 0, FR, FL } },
214
214
-
{ .ca_index = 0x07, .speakers = { 0, 0, 0, RC, FC, LFE, FR, FL } },
215
215
-
{ .ca_index = 0x0c, .speakers = { 0, RC, RR, RL, 0, 0, FR, FL } },
216
216
-
{ .ca_index = 0x0d, .speakers = { 0, RC, RR, RL, 0, LFE, FR, FL } },
217
217
-
{ .ca_index = 0x0e, .speakers = { 0, RC, RR, RL, FC, 0, FR, FL } },
218
218
-
{ .ca_index = 0x10, .speakers = { RRC, RLC, RR, RL, 0, 0, FR, FL } },
219
219
-
{ .ca_index = 0x11, .speakers = { RRC, RLC, RR, RL, 0, LFE, FR, FL } },
220
220
-
{ .ca_index = 0x12, .speakers = { RRC, RLC, RR, RL, FC, 0, FR, FL } },
221
221
-
{ .ca_index = 0x14, .speakers = { FRC, FLC, 0, 0, 0, 0, FR, FL } },
222
222
-
{ .ca_index = 0x15, .speakers = { FRC, FLC, 0, 0, 0, LFE, FR, FL } },
223
223
-
{ .ca_index = 0x16, .speakers = { FRC, FLC, 0, 0, FC, 0, FR, FL } },
224
224
-
{ .ca_index = 0x17, .speakers = { FRC, FLC, 0, 0, FC, LFE, FR, FL } },
225
225
-
{ .ca_index = 0x18, .speakers = { FRC, FLC, 0, RC, 0, 0, FR, FL } },
226
226
-
{ .ca_index = 0x19, .speakers = { FRC, FLC, 0, RC, 0, LFE, FR, FL } },
227
227
-
{ .ca_index = 0x1a, .speakers = { FRC, FLC, 0, RC, FC, 0, FR, FL } },
228
228
-
{ .ca_index = 0x1b, .speakers = { FRC, FLC, 0, RC, FC, LFE, FR, FL } },
229
229
-
{ .ca_index = 0x1c, .speakers = { FRC, FLC, RR, RL, 0, 0, FR, FL } },
230
230
-
{ .ca_index = 0x1d, .speakers = { FRC, FLC, RR, RL, 0, LFE, FR, FL } },
231
231
-
{ .ca_index = 0x1e, .speakers = { FRC, FLC, RR, RL, FC, 0, FR, FL } },
232
232
-
{ .ca_index = 0x1f, .speakers = { FRC, FLC, RR, RL, FC, LFE, FR, FL } },
233
233
-
{ .ca_index = 0x20, .speakers = { 0, FCH, RR, RL, FC, 0, FR, FL } },
234
234
-
{ .ca_index = 0x21, .speakers = { 0, FCH, RR, RL, FC, LFE, FR, FL } },
235
235
-
{ .ca_index = 0x22, .speakers = { TC, 0, RR, RL, FC, 0, FR, FL } },
236
236
-
{ .ca_index = 0x23, .speakers = { TC, 0, RR, RL, FC, LFE, FR, FL } },
237
237
-
{ .ca_index = 0x24, .speakers = { FRH, FLH, RR, RL, 0, 0, FR, FL } },
238
238
-
{ .ca_index = 0x25, .speakers = { FRH, FLH, RR, RL, 0, LFE, FR, FL } },
239
239
-
{ .ca_index = 0x26, .speakers = { FRW, FLW, RR, RL, 0, 0, FR, FL } },
240
240
-
{ .ca_index = 0x27, .speakers = { FRW, FLW, RR, RL, 0, LFE, FR, FL } },
241
241
-
{ .ca_index = 0x28, .speakers = { TC, RC, RR, RL, FC, 0, FR, FL } },
242
242
-
{ .ca_index = 0x29, .speakers = { TC, RC, RR, RL, FC, LFE, FR, FL } },
243
243
-
{ .ca_index = 0x2a, .speakers = { FCH, RC, RR, RL, FC, 0, FR, FL } },
244
244
-
{ .ca_index = 0x2b, .speakers = { FCH, RC, RR, RL, FC, LFE, FR, FL } },
245
245
-
{ .ca_index = 0x2c, .speakers = { TC, FCH, RR, RL, FC, 0, FR, FL } },
246
246
-
{ .ca_index = 0x2d, .speakers = { TC, FCH, RR, RL, FC, LFE, FR, FL } },
247
247
-
{ .ca_index = 0x2e, .speakers = { FRH, FLH, RR, RL, FC, 0, FR, FL } },
248
248
-
{ .ca_index = 0x2f, .speakers = { FRH, FLH, RR, RL, FC, LFE, FR, FL } },
249
249
-
{ .ca_index = 0x30, .speakers = { FRW, FLW, RR, RL, FC, 0, FR, FL } },
250
250
-
{ .ca_index = 0x31, .speakers = { FRW, FLW, RR, RL, FC, LFE, FR, FL } },
251
251
-
};
252
252
-
253
253
-
/*
254
254
-
* HDA/HDMI auto parsing
255
255
-
*/
256
256
-
257
257
-
static int hda_node_index(hda_nid_t *nids, hda_nid_t nid)
258
258
-
{
259
259
-
int i;
260
260
-
261
261
-
for (i = 0; nids[i]; i++)
262
262
-
if (nids[i] == nid)
263
263
-
return i;
264
264
-
265
265
-
snd_printk(KERN_WARNING "HDMI: nid %d not registered\n", nid);
266
266
-
return -EINVAL;
267
267
-
}
268
268
-
269
269
-
static int intel_hdmi_read_pin_conn(struct hda_codec *codec, hda_nid_t pin_nid)
270
270
-
{
271
271
-
struct intel_hdmi_spec *spec = codec->spec;
272
272
-
hda_nid_t conn_list[HDA_MAX_CONNECTIONS];
273
273
-
int conn_len, curr;
274
274
-
int index;
275
275
-
276
276
-
if (!(get_wcaps(codec, pin_nid) & AC_WCAP_CONN_LIST)) {
277
277
-
snd_printk(KERN_WARNING
278
278
-
"HDMI: pin %d wcaps %#x "
279
279
-
"does not support connection list\n",
280
280
-
pin_nid, get_wcaps(codec, pin_nid));
281
281
-
return -EINVAL;
282
282
-
}
283
283
-
284
284
-
conn_len = snd_hda_get_connections(codec, pin_nid, conn_list,
285
285
-
HDA_MAX_CONNECTIONS);
286
286
-
if (conn_len > 1)
287
287
-
curr = snd_hda_codec_read(codec, pin_nid, 0,
288
288
-
AC_VERB_GET_CONNECT_SEL, 0);
289
289
-
else
290
290
-
curr = 0;
291
291
-
292
292
-
index = hda_node_index(spec->pin, pin_nid);
293
293
-
if (index < 0)
294
294
-
return -EINVAL;
295
295
-
296
296
-
spec->pin_cvt[index] = conn_list[curr];
297
297
-
298
298
-
return 0;
299
299
-
}
300
300
-
301
301
-
static void hdmi_get_show_eld(struct hda_codec *codec, hda_nid_t pin_nid,
302
302
-
struct hdmi_eld *eld)
303
303
-
{
304
304
-
if (!snd_hdmi_get_eld(eld, codec, pin_nid))
305
305
-
snd_hdmi_show_eld(eld);
306
306
-
}
307
307
-
308
308
-
static void hdmi_present_sense(struct hda_codec *codec, hda_nid_t pin_nid,
309
309
-
struct hdmi_eld *eld)
310
310
-
{
311
311
-
int present = snd_hda_pin_sense(codec, pin_nid);
312
312
-
313
313
-
eld->monitor_present = !!(present & AC_PINSENSE_PRESENCE);
314
314
-
eld->eld_valid = !!(present & AC_PINSENSE_ELDV);
315
315
-
316
316
-
if (present & AC_PINSENSE_ELDV)
317
317
-
hdmi_get_show_eld(codec, pin_nid, eld);
318
318
-
}
319
319
-
320
320
-
static int intel_hdmi_add_pin(struct hda_codec *codec, hda_nid_t pin_nid)
321
321
-
{
322
322
-
struct intel_hdmi_spec *spec = codec->spec;
323
323
-
324
324
-
if (spec->num_pins >= INTEL_HDMI_PINS) {
325
325
-
snd_printk(KERN_WARNING
326
326
-
"HDMI: no space for pin %d \n", pin_nid);
327
327
-
return -EINVAL;
328
328
-
}
329
329
-
330
330
-
hdmi_present_sense(codec, pin_nid, &spec->sink_eld[spec->num_pins]);
331
331
-
332
332
-
spec->pin[spec->num_pins] = pin_nid;
333
333
-
spec->num_pins++;
334
334
-
335
335
-
/*
336
336
-
* It is assumed that converter nodes come first in the node list and
337
337
-
* hence have been registered and usable now.
338
338
-
*/
339
339
-
return intel_hdmi_read_pin_conn(codec, pin_nid);
340
340
-
}
341
341
-
342
342
-
static int intel_hdmi_add_cvt(struct hda_codec *codec, hda_nid_t nid)
343
343
-
{
344
344
-
struct intel_hdmi_spec *spec = codec->spec;
345
345
-
346
346
-
if (spec->num_cvts >= INTEL_HDMI_CVTS) {
347
347
-
snd_printk(KERN_WARNING
348
348
-
"HDMI: no space for converter %d \n", nid);
349
349
-
return -EINVAL;
350
350
-
}
351
351
-
352
352
-
spec->cvt[spec->num_cvts] = nid;
353
353
-
spec->num_cvts++;
354
354
-
355
355
-
return 0;
356
356
-
}
357
357
-
358
358
-
static int intel_hdmi_parse_codec(struct hda_codec *codec)
359
359
-
{
360
360
-
hda_nid_t nid;
361
361
-
int i, nodes;
362
362
-
363
363
-
nodes = snd_hda_get_sub_nodes(codec, codec->afg, &nid);
364
364
-
if (!nid || nodes < 0) {
365
365
-
snd_printk(KERN_WARNING "HDMI: failed to get afg sub nodes\n");
366
366
-
return -EINVAL;
367
367
-
}
368
368
-
369
369
-
for (i = 0; i < nodes; i++, nid++) {
370
370
-
unsigned int caps;
371
371
-
unsigned int type;
372
372
-
373
373
-
caps = snd_hda_param_read(codec, nid, AC_PAR_AUDIO_WIDGET_CAP);
374
374
-
type = get_wcaps_type(caps);
375
375
-
376
376
-
if (!(caps & AC_WCAP_DIGITAL))
377
377
-
continue;
378
378
-
379
379
-
switch (type) {
380
380
-
case AC_WID_AUD_OUT:
381
381
-
if (intel_hdmi_add_cvt(codec, nid) < 0)
382
382
-
return -EINVAL;
383
383
-
break;
384
384
-
case AC_WID_PIN:
385
385
-
caps = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
386
386
-
if (!(caps & (AC_PINCAP_HDMI | AC_PINCAP_DP)))
387
387
-
continue;
388
388
-
if (intel_hdmi_add_pin(codec, nid) < 0)
389
389
-
return -EINVAL;
390
390
-
break;
391
391
-
}
392
392
-
}
393
393
-
394
394
-
/*
395
395
-
* G45/IbexPeak don't support EPSS: the unsolicited pin hot plug event
396
396
-
* can be lost and presence sense verb will become inaccurate if the
397
397
-
* HDA link is powered off at hot plug or hw initialization time.
398
398
-
*/
399
399
-
#ifdef CONFIG_SND_HDA_POWER_SAVE
400
400
-
if (!(snd_hda_param_read(codec, codec->afg, AC_PAR_POWER_STATE) &
401
401
-
AC_PWRST_EPSS))
402
402
-
codec->bus->power_keep_link_on = 1;
403
403
-
#endif
404
404
-
405
405
-
return 0;
406
406
-
}
407
407
-
408
408
-
/*
409
409
-
* HDMI routines
410
410
-
*/
411
411
-
412
412
-
#ifdef BE_PARANOID
413
413
-
static void hdmi_get_dip_index(struct hda_codec *codec, hda_nid_t pin_nid,
414
414
-
int *packet_index, int *byte_index)
415
415
-
{
416
416
-
int val;
417
417
-
418
418
-
val = snd_hda_codec_read(codec, pin_nid, 0,
419
419
-
AC_VERB_GET_HDMI_DIP_INDEX, 0);
420
420
-
421
421
-
*packet_index = val >> 5;
422
422
-
*byte_index = val & 0x1f;
423
423
-
}
424
424
-
#endif
425
425
-
426
426
-
static void hdmi_set_dip_index(struct hda_codec *codec, hda_nid_t pin_nid,
427
427
-
int packet_index, int byte_index)
428
428
-
{
429
429
-
int val;
430
430
-
431
431
-
val = (packet_index << 5) | (byte_index & 0x1f);
432
432
-
433
433
-
snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_INDEX, val);
434
434
-
}
435
435
-
436
436
-
static void hdmi_write_dip_byte(struct hda_codec *codec, hda_nid_t pin_nid,
437
437
-
unsigned char val)
438
438
-
{
439
439
-
snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_DATA, val);
440
440
-
}
441
441
-
442
442
-
static void hdmi_enable_output(struct hda_codec *codec, hda_nid_t pin_nid)
443
443
-
{
444
444
-
/* Unmute */
445
445
-
if (get_wcaps(codec, pin_nid) & AC_WCAP_OUT_AMP)
446
446
-
snd_hda_codec_write(codec, pin_nid, 0,
447
447
-
AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
448
448
-
/* Enable pin out */
449
449
-
snd_hda_codec_write(codec, pin_nid, 0,
450
450
-
AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
451
451
-
}
452
452
-
453
453
-
/*
454
454
-
* Enable Audio InfoFrame Transmission
455
455
-
*/
456
456
-
static void hdmi_start_infoframe_trans(struct hda_codec *codec,
457
457
-
hda_nid_t pin_nid)
458
458
-
{
459
459
-
hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0);
460
460
-
snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_XMIT,
461
461
-
AC_DIPXMIT_BEST);
462
462
-
}
463
463
-
464
464
-
/*
465
465
-
* Disable Audio InfoFrame Transmission
466
466
-
*/
467
467
-
static void hdmi_stop_infoframe_trans(struct hda_codec *codec,
468
468
-
hda_nid_t pin_nid)
469
469
-
{
470
470
-
hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0);
471
471
-
snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_XMIT,
472
472
-
AC_DIPXMIT_DISABLE);
473
473
-
}
474
474
-
475
475
-
static int hdmi_get_channel_count(struct hda_codec *codec, hda_nid_t nid)
476
476
-
{
477
477
-
return 1 + snd_hda_codec_read(codec, nid, 0,
478
478
-
AC_VERB_GET_CVT_CHAN_COUNT, 0);
479
479
-
}
480
480
-
481
481
-
static void hdmi_set_channel_count(struct hda_codec *codec,
482
482
-
hda_nid_t nid, int chs)
483
483
-
{
484
484
-
if (chs != hdmi_get_channel_count(codec, nid))
485
485
-
snd_hda_codec_write(codec, nid, 0,
486
486
-
AC_VERB_SET_CVT_CHAN_COUNT, chs - 1);
487
487
-
}
488
488
-
489
489
-
static void hdmi_debug_channel_mapping(struct hda_codec *codec,
490
490
-
hda_nid_t pin_nid)
491
491
-
{
492
492
-
#ifdef CONFIG_SND_DEBUG_VERBOSE
493
493
-
int i;
494
494
-
int slot;
495
495
-
496
496
-
for (i = 0; i < 8; i++) {
497
497
-
slot = snd_hda_codec_read(codec, pin_nid, 0,
498
498
-
AC_VERB_GET_HDMI_CHAN_SLOT, i);
499
499
-
printk(KERN_DEBUG "HDMI: ASP channel %d => slot %d\n",
500
500
-
slot >> 4, slot & 0xf);
501
501
-
}
502
502
-
#endif
503
503
-
}
504
504
-
505
505
-
506
506
-
/*
507
507
-
* Audio InfoFrame routines
508
508
-
*/
509
509
-
510
510
-
static void hdmi_debug_dip_size(struct hda_codec *codec, hda_nid_t pin_nid)
511
511
-
{
512
512
-
#ifdef CONFIG_SND_DEBUG_VERBOSE
513
513
-
int i;
514
514
-
int size;
515
515
-
516
516
-
size = snd_hdmi_get_eld_size(codec, pin_nid);
517
517
-
printk(KERN_DEBUG "HDMI: ELD buf size is %d\n", size);
518
518
-
519
519
-
for (i = 0; i < 8; i++) {
520
520
-
size = snd_hda_codec_read(codec, pin_nid, 0,
521
521
-
AC_VERB_GET_HDMI_DIP_SIZE, i);
522
522
-
printk(KERN_DEBUG "HDMI: DIP GP[%d] buf size is %d\n", i, size);
523
523
-
}
524
524
-
#endif
525
525
-
}
526
526
-
527
527
-
static void hdmi_clear_dip_buffers(struct hda_codec *codec, hda_nid_t pin_nid)
528
528
-
{
529
529
-
#ifdef BE_PARANOID
530
530
-
int i, j;
531
531
-
int size;
532
532
-
int pi, bi;
533
533
-
for (i = 0; i < 8; i++) {
534
534
-
size = snd_hda_codec_read(codec, pin_nid, 0,
535
535
-
AC_VERB_GET_HDMI_DIP_SIZE, i);
536
536
-
if (size == 0)
537
537
-
continue;
538
538
-
539
539
-
hdmi_set_dip_index(codec, pin_nid, i, 0x0);
540
540
-
for (j = 1; j < 1000; j++) {
541
541
-
hdmi_write_dip_byte(codec, pin_nid, 0x0);
542
542
-
hdmi_get_dip_index(codec, pin_nid, &pi, &bi);
543
543
-
if (pi != i)
544
544
-
snd_printd(KERN_INFO "dip index %d: %d != %d\n",
545
545
-
bi, pi, i);
546
546
-
if (bi == 0) /* byte index wrapped around */
547
547
-
break;
548
548
-
}
549
549
-
snd_printd(KERN_INFO
550
550
-
"HDMI: DIP GP[%d] buf reported size=%d, written=%d\n",
551
551
-
i, size, j);
552
552
-
}
553
553
-
#endif
554
554
-
}
555
555
-
556
556
-
static void hdmi_checksum_audio_infoframe(struct hdmi_audio_infoframe *ai)
557
557
-
{
558
558
-
u8 *bytes = (u8 *)ai;
559
559
-
u8 sum = 0;
560
560
-
int i;
561
561
-
562
562
-
ai->checksum = 0;
563
563
-
564
564
-
for (i = 0; i < sizeof(*ai); i++)
565
565
-
sum += bytes[i];
566
566
-
567
567
-
ai->checksum = - sum;
568
568
-
}
569
569
-
570
570
-
static void hdmi_fill_audio_infoframe(struct hda_codec *codec,
571
571
-
hda_nid_t pin_nid,
572
572
-
struct hdmi_audio_infoframe *ai)
573
573
-
{
574
574
-
u8 *bytes = (u8 *)ai;
575
575
-
int i;
576
576
-
577
577
-
hdmi_debug_dip_size(codec, pin_nid);
578
578
-
hdmi_clear_dip_buffers(codec, pin_nid); /* be paranoid */
579
579
-
580
580
-
hdmi_checksum_audio_infoframe(ai);
581
581
-
582
582
-
hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0);
583
583
-
for (i = 0; i < sizeof(*ai); i++)
584
584
-
hdmi_write_dip_byte(codec, pin_nid, bytes[i]);
585
585
-
}
586
586
-
587
587
-
/*
588
588
-
* Compute derived values in channel_allocations[].
589
589
-
*/
590
590
-
static void init_channel_allocations(void)
591
591
-
{
592
592
-
int i, j;
593
593
-
struct cea_channel_speaker_allocation *p;
594
594
-
595
595
-
for (i = 0; i < ARRAY_SIZE(channel_allocations); i++) {
596
596
-
p = channel_allocations + i;
597
597
-
p->channels = 0;
598
598
-
p->spk_mask = 0;
599
599
-
for (j = 0; j < ARRAY_SIZE(p->speakers); j++)
600
600
-
if (p->speakers[j]) {
601
601
-
p->channels++;
602
602
-
p->spk_mask |= p->speakers[j];
603
603
-
}
604
604
-
}
605
605
-
}
606
606
-
607
607
-
/*
608
608
-
* The transformation takes two steps:
609
609
-
*
610
610
-
* eld->spk_alloc => (eld_speaker_allocation_bits[]) => spk_mask
611
611
-
* spk_mask => (channel_allocations[]) => ai->CA
612
612
-
*
613
613
-
* TODO: it could select the wrong CA from multiple candidates.
614
614
-
*/
615
615
-
static int hdmi_setup_channel_allocation(struct hda_codec *codec, hda_nid_t nid,
616
616
-
struct hdmi_audio_infoframe *ai)
617
617
-
{
618
618
-
struct intel_hdmi_spec *spec = codec->spec;
619
619
-
struct hdmi_eld *eld;
620
620
-
int i;
621
621
-
int spk_mask = 0;
622
622
-
int channels = 1 + (ai->CC02_CT47 & 0x7);
623
623
-
char buf[SND_PRINT_CHANNEL_ALLOCATION_ADVISED_BUFSIZE];
624
624
-
625
625
-
/*
626
626
-
* CA defaults to 0 for basic stereo audio
627
627
-
*/
628
628
-
if (channels <= 2)
629
629
-
return 0;
630
630
-
631
631
-
i = hda_node_index(spec->pin_cvt, nid);
632
632
-
if (i < 0)
633
633
-
return 0;
634
634
-
eld = &spec->sink_eld[i];
635
635
-
636
636
-
/*
637
637
-
* HDMI sink's ELD info cannot always be retrieved for now, e.g.
638
638
-
* in console or for audio devices. Assume the highest speakers
639
639
-
* configuration, to _not_ prohibit multi-channel audio playback.
640
640
-
*/
641
641
-
if (!eld->spk_alloc)
642
642
-
eld->spk_alloc = 0xffff;
643
643
-
644
644
-
/*
645
645
-
* expand ELD's speaker allocation mask
646
646
-
*
647
647
-
* ELD tells the speaker mask in a compact(paired) form,
648
648
-
* expand ELD's notions to match the ones used by Audio InfoFrame.
649
649
-
*/
650
650
-
for (i = 0; i < ARRAY_SIZE(eld_speaker_allocation_bits); i++) {
651
651
-
if (eld->spk_alloc & (1 << i))
652
652
-
spk_mask |= eld_speaker_allocation_bits[i];
653
653
-
}
654
654
-
655
655
-
/* search for the first working match in the CA table */
656
656
-
for (i = 0; i < ARRAY_SIZE(channel_allocations); i++) {
657
657
-
if (channels == channel_allocations[i].channels &&
658
658
-
(spk_mask & channel_allocations[i].spk_mask) ==
659
659
-
channel_allocations[i].spk_mask) {
660
660
-
ai->CA = channel_allocations[i].ca_index;
661
661
-
break;
662
662
-
}
663
663
-
}
664
664
-
665
665
-
snd_print_channel_allocation(eld->spk_alloc, buf, sizeof(buf));
666
666
-
snd_printdd(KERN_INFO
667
667
-
"HDMI: select CA 0x%x for %d-channel allocation: %s\n",
668
668
-
ai->CA, channels, buf);
669
669
-
670
670
-
return ai->CA;
671
671
-
}
672
672
-
673
673
-
static void hdmi_setup_channel_mapping(struct hda_codec *codec,
674
674
-
hda_nid_t pin_nid,
675
675
-
struct hdmi_audio_infoframe *ai)
676
676
-
{
677
677
-
int i;
678
678
-
int ca = ai->CA;
679
679
-
int err;
680
680
-
681
681
-
if (hdmi_channel_mapping[ca][1] == 0) {
682
682
-
for (i = 0; i < channel_allocations[ca].channels; i++)
683
683
-
hdmi_channel_mapping[ca][i] = i | (i << 4);
684
684
-
for (; i < 8; i++)
685
685
-
hdmi_channel_mapping[ca][i] = 0xf | (i << 4);
686
686
-
}
687
687
-
688
688
-
for (i = 0; i < 8; i++) {
689
689
-
err = snd_hda_codec_write(codec, pin_nid, 0,
690
690
-
AC_VERB_SET_HDMI_CHAN_SLOT,
691
691
-
hdmi_channel_mapping[ca][i]);
692
692
-
if (err) {
693
693
-
snd_printdd(KERN_INFO "HDMI: channel mapping failed\n");
694
694
-
break;
695
695
-
}
696
696
-
}
697
697
-
698
698
-
hdmi_debug_channel_mapping(codec, pin_nid);
699
699
-
}
700
700
-
701
701
-
static bool hdmi_infoframe_uptodate(struct hda_codec *codec, hda_nid_t pin_nid,
702
702
-
struct hdmi_audio_infoframe *ai)
703
703
-
{
704
704
-
u8 *bytes = (u8 *)ai;
705
705
-
u8 val;
706
706
-
int i;
707
707
-
708
708
-
if (snd_hda_codec_read(codec, pin_nid, 0, AC_VERB_GET_HDMI_DIP_XMIT, 0)
709
709
-
!= AC_DIPXMIT_BEST)
710
710
-
return false;
711
711
-
712
712
-
hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0);
713
713
-
for (i = 0; i < sizeof(*ai); i++) {
714
714
-
val = snd_hda_codec_read(codec, pin_nid, 0,
715
715
-
AC_VERB_GET_HDMI_DIP_DATA, 0);
716
716
-
if (val != bytes[i])
717
717
-
return false;
718
718
-
}
719
719
-
720
720
-
return true;
721
721
-
}
722
722
-
723
723
-
static void hdmi_setup_audio_infoframe(struct hda_codec *codec, hda_nid_t nid,
724
724
-
struct snd_pcm_substream *substream)
725
725
-
{
726
726
-
struct intel_hdmi_spec *spec = codec->spec;
727
727
-
hda_nid_t pin_nid;
728
728
-
int i;
729
729
-
struct hdmi_audio_infoframe ai = {
730
730
-
.type = 0x84,
731
731
-
.ver = 0x01,
732
732
-
.len = 0x0a,
733
733
-
.CC02_CT47 = substream->runtime->channels - 1,
734
734
-
};
735
735
-
736
736
-
hdmi_setup_channel_allocation(codec, nid, &ai);
737
737
-
738
738
-
for (i = 0; i < spec->num_pins; i++) {
739
739
-
if (spec->pin_cvt[i] != nid)
740
740
-
continue;
741
741
-
if (!spec->sink_eld[i].monitor_present)
742
742
-
continue;
743
743
-
744
744
-
pin_nid = spec->pin[i];
745
745
-
if (!hdmi_infoframe_uptodate(codec, pin_nid, &ai)) {
746
746
-
hdmi_setup_channel_mapping(codec, pin_nid, &ai);
747
747
-
hdmi_stop_infoframe_trans(codec, pin_nid);
748
748
-
hdmi_fill_audio_infoframe(codec, pin_nid, &ai);
749
749
-
hdmi_start_infoframe_trans(codec, pin_nid);
750
750
-
}
751
751
-
}
752
752
-
}
753
753
-
754
754
-
755
755
-
/*
756
756
-
* Unsolicited events
757
757
-
*/
758
758
-
759
759
-
static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res)
760
760
-
{
761
761
-
struct intel_hdmi_spec *spec = codec->spec;
762
762
-
int tag = res >> AC_UNSOL_RES_TAG_SHIFT;
763
763
-
int pind = !!(res & AC_UNSOL_RES_PD);
764
764
-
int eldv = !!(res & AC_UNSOL_RES_ELDV);
765
765
-
int index;
766
766
-
767
767
-
printk(KERN_INFO
768
768
-
"HDMI hot plug event: Pin=%d Presence_Detect=%d ELD_Valid=%d\n",
769
769
-
tag, pind, eldv);
770
770
-
771
771
-
index = hda_node_index(spec->pin, tag);
772
772
-
if (index < 0)
773
773
-
return;
774
774
-
775
775
-
spec->sink_eld[index].monitor_present = pind;
776
776
-
spec->sink_eld[index].eld_valid = eldv;
777
777
-
778
778
-
if (pind && eldv) {
779
779
-
hdmi_get_show_eld(codec, spec->pin[index], &spec->sink_eld[index]);
780
780
-
/* TODO: do real things about ELD */
781
781
-
}
782
782
-
}
783
783
-
784
784
-
static void hdmi_non_intrinsic_event(struct hda_codec *codec, unsigned int res)
785
785
-
{
786
786
-
int tag = res >> AC_UNSOL_RES_TAG_SHIFT;
787
787
-
int subtag = (res & AC_UNSOL_RES_SUBTAG) >> AC_UNSOL_RES_SUBTAG_SHIFT;
788
788
-
int cp_state = !!(res & AC_UNSOL_RES_CP_STATE);
789
789
-
int cp_ready = !!(res & AC_UNSOL_RES_CP_READY);
790
790
-
791
791
-
printk(KERN_INFO
792
792
-
"HDMI CP event: PIN=%d SUBTAG=0x%x CP_STATE=%d CP_READY=%d\n",
793
793
-
tag,
794
794
-
subtag,
795
795
-
cp_state,
796
796
-
cp_ready);
797
797
-
798
798
-
/* TODO */
799
799
-
if (cp_state)
800
800
-
;
801
801
-
if (cp_ready)
802
802
-
;
803
803
-
}
804
804
-
805
805
-
806
806
-
static void intel_hdmi_unsol_event(struct hda_codec *codec, unsigned int res)
807
807
-
{
808
808
-
struct intel_hdmi_spec *spec = codec->spec;
809
809
-
int tag = res >> AC_UNSOL_RES_TAG_SHIFT;
810
810
-
int subtag = (res & AC_UNSOL_RES_SUBTAG) >> AC_UNSOL_RES_SUBTAG_SHIFT;
811
811
-
812
812
-
if (hda_node_index(spec->pin, tag) < 0) {
813
813
-
snd_printd(KERN_INFO "Unexpected HDMI event tag 0x%x\n", tag);
814
814
-
return;
815
815
-
}
816
816
-
817
817
-
if (subtag == 0)
818
818
-
hdmi_intrinsic_event(codec, res);
819
819
-
else
820
820
-
hdmi_non_intrinsic_event(codec, res);
821
821
-
}
822
822
-
823
823
-
/*
824
824
-
* Callbacks
825
825
-
*/
826
826
-
827
827
-
static void hdmi_setup_stream(struct hda_codec *codec, hda_nid_t nid,
828
828
-
u32 stream_tag, int format)
829
829
-
{
830
830
-
int tag;
831
831
-
int fmt;
832
832
-
833
833
-
tag = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONV, 0) >> 4;
834
834
-
fmt = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_STREAM_FORMAT, 0);
835
835
-
836
836
-
snd_printdd("hdmi_setup_stream: "
837
837
-
"NID=0x%x, %sstream=0x%x, %sformat=0x%x\n",
838
838
-
nid,
839
839
-
tag == stream_tag ? "" : "new-",
840
840
-
stream_tag,
841
841
-
fmt == format ? "" : "new-",
842
842
-
format);
843
843
-
844
844
-
if (tag != stream_tag)
845
845
-
snd_hda_codec_write(codec, nid, 0,
846
846
-
AC_VERB_SET_CHANNEL_STREAMID, stream_tag << 4);
847
847
-
if (fmt != format)
848
848
-
snd_hda_codec_write(codec, nid, 0,
849
849
-
AC_VERB_SET_STREAM_FORMAT, format);
850
850
-
}
851
56
852
57
static int intel_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
853
58
struct hda_codec *codec,
···
87
882
88
883
static int intel_hdmi_build_pcms(struct hda_codec *codec)
89
884
{
90
90
-
struct intel_hdmi_spec *spec = codec->spec;
885
885
+
struct hdmi_spec *spec = codec->spec;
91
886
struct hda_pcm *info = spec->pcm_rec;
92
887
int i;
93
888
···
113
908
114
909
static int intel_hdmi_build_controls(struct hda_codec *codec)
115
910
{
116
116
-
struct intel_hdmi_spec *spec = codec->spec;
911
911
+
struct hdmi_spec *spec = codec->spec;
117
912
int err;
118
913
int i;
119
914
···
128
923
129
924
static int intel_hdmi_init(struct hda_codec *codec)
130
925
{
131
131
-
struct intel_hdmi_spec *spec = codec->spec;
926
926
+
struct hdmi_spec *spec = codec->spec;
132
927
int i;
133
928
134
929
for (i = 0; spec->pin[i]; i++) {
···
142
937
143
938
static void intel_hdmi_free(struct hda_codec *codec)
144
939
{
145
145
-
struct intel_hdmi_spec *spec = codec->spec;
940
940
+
struct hdmi_spec *spec = codec->spec;
146
941
int i;
147
942
148
943
for (i = 0; i < spec->num_pins; i++)
···
156
951
.free = intel_hdmi_free,
157
952
.build_pcms = intel_hdmi_build_pcms,
158
953
.build_controls = intel_hdmi_build_controls,
159
159
-
.unsol_event = intel_hdmi_unsol_event,
954
954
+
.unsol_event = hdmi_unsol_event,
160
955
};
161
956
162
957
static int patch_intel_hdmi(struct hda_codec *codec)
163
958
{
164
164
-
struct intel_hdmi_spec *spec;
959
959
+
struct hdmi_spec *spec;
165
960
int i;
166
961
167
962
spec = kzalloc(sizeof(*spec), GFP_KERNEL);
···
169
964
return -ENOMEM;
170
965
171
966
codec->spec = spec;
172
172
-
if (intel_hdmi_parse_codec(codec) < 0) {
967
967
+
if (hdmi_parse_codec(codec) < 0) {
173
968
codec->spec = NULL;
174
969
kfree(spec);
175
970
return -EINVAL;
+217
-60
sound/pci/hda/patch_nvhdmi.c
···
29
29
#include "hda_codec.h"
30
30
#include "hda_local.h"
31
31
32
32
+
#define MAX_HDMI_CVTS 1
33
33
+
#define MAX_HDMI_PINS 1
34
34
+
35
35
+
#include "patch_hdmi.c"
36
36
+
37
37
+
static char *nvhdmi_pcm_names[MAX_HDMI_CVTS] = {
38
38
+
"NVIDIA HDMI",
39
39
+
};
40
40
+
32
41
/* define below to restrict the supported rates and formats */
33
42
/* #define LIMITED_RATE_FMT_SUPPORT */
34
43
35
35
-
struct nvhdmi_spec {
36
36
-
struct hda_multi_out multiout;
37
37
-
38
38
-
struct hda_pcm pcm_rec;
44
44
+
enum HDACodec {
45
45
+
HDA_CODEC_NVIDIA_MCP7X,
46
46
+
HDA_CODEC_NVIDIA_MCP89,
47
47
+
HDA_CODEC_NVIDIA_GT21X,
48
48
+
HDA_CODEC_INVALID
39
49
};
40
50
41
51
#define Nv_VERB_SET_Channel_Allocation 0xF79
···
53
43
#define Nv_VERB_SET_Audio_Protection_On 0xF98
54
44
#define Nv_VERB_SET_Audio_Protection_Off 0xF99
55
45
56
56
-
#define Nv_Master_Convert_nid 0x04
57
57
-
#define Nv_Master_Pin_nid 0x05
46
46
+
#define nvhdmi_master_con_nid_7x 0x04
47
47
+
#define nvhdmi_master_pin_nid_7x 0x05
58
48
59
59
-
static hda_nid_t nvhdmi_convert_nids[4] = {
49
49
+
#define nvhdmi_master_con_nid_89 0x04
50
50
+
#define nvhdmi_master_pin_nid_89 0x05
51
51
+
52
52
+
static hda_nid_t nvhdmi_con_nids_7x[4] = {
60
53
/*front, rear, clfe, rear_surr */
61
54
0x6, 0x8, 0xa, 0xc,
62
55
};
63
56
64
64
-
static struct hda_verb nvhdmi_basic_init[] = {
57
57
+
static struct hda_verb nvhdmi_basic_init_7x[] = {
65
58
/* set audio protect on */
66
59
{ 0x1, Nv_VERB_SET_Audio_Protection_On, 0x1},
67
60
/* enable digital output on pin widget */
···
97
84
*/
98
85
static int nvhdmi_build_controls(struct hda_codec *codec)
99
86
{
100
100
-
struct nvhdmi_spec *spec = codec->spec;
87
87
+
struct hdmi_spec *spec = codec->spec;
101
88
int err;
89
89
+
int i;
102
90
103
103
-
err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
104
104
-
if (err < 0)
105
105
-
return err;
91
91
+
if ((spec->codec_type == HDA_CODEC_NVIDIA_MCP89)
92
92
+
|| (spec->codec_type == HDA_CODEC_NVIDIA_GT21X)) {
93
93
+
for (i = 0; i < codec->num_pcms; i++) {
94
94
+
err = snd_hda_create_spdif_out_ctls(codec,
95
95
+
spec->cvt[i]);
96
96
+
if (err < 0)
97
97
+
return err;
98
98
+
}
99
99
+
} else {
100
100
+
err = snd_hda_create_spdif_out_ctls(codec,
101
101
+
spec->multiout.dig_out_nid);
102
102
+
if (err < 0)
103
103
+
return err;
104
104
+
}
106
105
107
106
return 0;
108
107
}
109
108
110
109
static int nvhdmi_init(struct hda_codec *codec)
111
110
{
112
112
-
snd_hda_sequence_write(codec, nvhdmi_basic_init);
111
111
+
struct hdmi_spec *spec = codec->spec;
112
112
+
int i;
113
113
+
if ((spec->codec_type == HDA_CODEC_NVIDIA_MCP89)
114
114
+
|| (spec->codec_type == HDA_CODEC_NVIDIA_GT21X)) {
115
115
+
for (i = 0; spec->pin[i]; i++) {
116
116
+
hdmi_enable_output(codec, spec->pin[i]);
117
117
+
snd_hda_codec_write(codec, spec->pin[i], 0,
118
118
+
AC_VERB_SET_UNSOLICITED_ENABLE,
119
119
+
AC_USRSP_EN | spec->pin[i]);
120
120
+
}
121
121
+
} else {
122
122
+
snd_hda_sequence_write(codec, nvhdmi_basic_init_7x);
123
123
+
}
113
124
return 0;
125
125
+
}
126
126
+
127
127
+
static void nvhdmi_free(struct hda_codec *codec)
128
128
+
{
129
129
+
struct hdmi_spec *spec = codec->spec;
130
130
+
int i;
131
131
+
132
132
+
if ((spec->codec_type == HDA_CODEC_NVIDIA_MCP89)
133
133
+
|| (spec->codec_type == HDA_CODEC_NVIDIA_GT21X)) {
134
134
+
for (i = 0; i < spec->num_pins; i++)
135
135
+
snd_hda_eld_proc_free(codec, &spec->sink_eld[i]);
136
136
+
}
137
137
+
138
138
+
kfree(spec);
114
139
}
115
140
116
141
/*
···
158
107
struct hda_codec *codec,
159
108
struct snd_pcm_substream *substream)
160
109
{
161
161
-
struct nvhdmi_spec *spec = codec->spec;
110
110
+
struct hdmi_spec *spec = codec->spec;
162
111
return snd_hda_multi_out_dig_open(codec, &spec->multiout);
163
112
}
164
113
165
165
-
static int nvhdmi_dig_playback_pcm_close_8ch(struct hda_pcm_stream *hinfo,
114
114
+
static int nvhdmi_dig_playback_pcm_close_8ch_7x(struct hda_pcm_stream *hinfo,
166
115
struct hda_codec *codec,
167
116
struct snd_pcm_substream *substream)
168
117
{
169
169
-
struct nvhdmi_spec *spec = codec->spec;
118
118
+
struct hdmi_spec *spec = codec->spec;
170
119
int i;
171
120
172
172
-
snd_hda_codec_write(codec, Nv_Master_Convert_nid,
121
121
+
snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x,
173
122
0, AC_VERB_SET_CHANNEL_STREAMID, 0);
174
123
for (i = 0; i < 4; i++) {
175
124
/* set the stream id */
176
176
-
snd_hda_codec_write(codec, nvhdmi_convert_nids[i], 0,
125
125
+
snd_hda_codec_write(codec, nvhdmi_con_nids_7x[i], 0,
177
126
AC_VERB_SET_CHANNEL_STREAMID, 0);
178
127
/* set the stream format */
179
179
-
snd_hda_codec_write(codec, nvhdmi_convert_nids[i], 0,
128
128
+
snd_hda_codec_write(codec, nvhdmi_con_nids_7x[i], 0,
180
129
AC_VERB_SET_STREAM_FORMAT, 0);
181
130
}
182
131
···
187
136
struct hda_codec *codec,
188
137
struct snd_pcm_substream *substream)
189
138
{
190
190
-
struct nvhdmi_spec *spec = codec->spec;
139
139
+
struct hdmi_spec *spec = codec->spec;
191
140
return snd_hda_multi_out_dig_close(codec, &spec->multiout);
141
141
+
}
142
142
+
143
143
+
static int nvhdmi_dig_playback_pcm_prepare_8ch_89(struct hda_pcm_stream *hinfo,
144
144
+
struct hda_codec *codec,
145
145
+
unsigned int stream_tag,
146
146
+
unsigned int format,
147
147
+
struct snd_pcm_substream *substream)
148
148
+
{
149
149
+
hdmi_set_channel_count(codec, hinfo->nid,
150
150
+
substream->runtime->channels);
151
151
+
152
152
+
hdmi_setup_audio_infoframe(codec, hinfo->nid, substream);
153
153
+
154
154
+
hdmi_setup_stream(codec, hinfo->nid, stream_tag, format);
155
155
+
return 0;
192
156
}
193
157
194
158
static int nvhdmi_dig_playback_pcm_prepare_8ch(struct hda_pcm_stream *hinfo,
···
247
181
/* turn off SPDIF once; otherwise the IEC958 bits won't be updated */
248
182
if (codec->spdif_status_reset && (codec->spdif_ctls & AC_DIG1_ENABLE))
249
183
snd_hda_codec_write(codec,
250
250
-
Nv_Master_Convert_nid,
184
184
+
nvhdmi_master_con_nid_7x,
251
185
0,
252
186
AC_VERB_SET_DIGI_CONVERT_1,
253
187
codec->spdif_ctls & ~AC_DIG1_ENABLE & 0xff);
254
188
255
189
/* set the stream id */
256
256
-
snd_hda_codec_write(codec, Nv_Master_Convert_nid, 0,
190
190
+
snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, 0,
257
191
AC_VERB_SET_CHANNEL_STREAMID, (stream_tag << 4) | 0x0);
258
192
259
193
/* set the stream format */
260
260
-
snd_hda_codec_write(codec, Nv_Master_Convert_nid, 0,
194
194
+
snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, 0,
261
195
AC_VERB_SET_STREAM_FORMAT, format);
262
196
263
197
/* turn on again (if needed) */
264
198
/* enable and set the channel status audio/data flag */
265
199
if (codec->spdif_status_reset && (codec->spdif_ctls & AC_DIG1_ENABLE)) {
266
200
snd_hda_codec_write(codec,
267
267
-
Nv_Master_Convert_nid,
201
201
+
nvhdmi_master_con_nid_7x,
268
202
0,
269
203
AC_VERB_SET_DIGI_CONVERT_1,
270
204
codec->spdif_ctls & 0xff);
271
205
snd_hda_codec_write(codec,
272
272
-
Nv_Master_Convert_nid,
206
206
+
nvhdmi_master_con_nid_7x,
273
207
0,
274
208
AC_VERB_SET_DIGI_CONVERT_2, dataDCC2);
275
209
}
···
286
220
if (codec->spdif_status_reset &&
287
221
(codec->spdif_ctls & AC_DIG1_ENABLE))
288
222
snd_hda_codec_write(codec,
289
289
-
nvhdmi_convert_nids[i],
223
223
+
nvhdmi_con_nids_7x[i],
290
224
0,
291
225
AC_VERB_SET_DIGI_CONVERT_1,
292
226
codec->spdif_ctls & ~AC_DIG1_ENABLE & 0xff);
293
227
/* set the stream id */
294
228
snd_hda_codec_write(codec,
295
295
-
nvhdmi_convert_nids[i],
229
229
+
nvhdmi_con_nids_7x[i],
296
230
0,
297
231
AC_VERB_SET_CHANNEL_STREAMID,
298
232
(stream_tag << 4) | channel_id);
299
233
/* set the stream format */
300
234
snd_hda_codec_write(codec,
301
301
-
nvhdmi_convert_nids[i],
235
235
+
nvhdmi_con_nids_7x[i],
302
236
0,
303
237
AC_VERB_SET_STREAM_FORMAT,
304
238
format);
···
307
241
if (codec->spdif_status_reset &&
308
242
(codec->spdif_ctls & AC_DIG1_ENABLE)) {
309
243
snd_hda_codec_write(codec,
310
310
-
nvhdmi_convert_nids[i],
244
244
+
nvhdmi_con_nids_7x[i],
311
245
0,
312
246
AC_VERB_SET_DIGI_CONVERT_1,
313
247
codec->spdif_ctls & 0xff);
314
248
snd_hda_codec_write(codec,
315
315
-
nvhdmi_convert_nids[i],
249
249
+
nvhdmi_con_nids_7x[i],
316
250
0,
317
251
AC_VERB_SET_DIGI_CONVERT_2, dataDCC2);
318
252
}
···
327
261
return 0;
328
262
}
329
263
264
264
+
static int nvhdmi_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
265
265
+
struct hda_codec *codec,
266
266
+
struct snd_pcm_substream *substream)
267
267
+
{
268
268
+
return 0;
269
269
+
}
270
270
+
330
271
static int nvhdmi_dig_playback_pcm_prepare_2ch(struct hda_pcm_stream *hinfo,
331
272
struct hda_codec *codec,
332
273
unsigned int stream_tag,
333
274
unsigned int format,
334
275
struct snd_pcm_substream *substream)
335
276
{
336
336
-
struct nvhdmi_spec *spec = codec->spec;
277
277
+
struct hdmi_spec *spec = codec->spec;
337
278
return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, stream_tag,
338
279
format, substream);
339
280
}
340
281
341
341
-
static struct hda_pcm_stream nvhdmi_pcm_digital_playback_8ch = {
282
282
+
static struct hda_pcm_stream nvhdmi_pcm_digital_playback_8ch_89 = {
283
283
+
.substreams = 1,
284
284
+
.channels_min = 2,
285
285
+
.rates = SUPPORTED_RATES,
286
286
+
.maxbps = SUPPORTED_MAXBPS,
287
287
+
.formats = SUPPORTED_FORMATS,
288
288
+
.ops = {
289
289
+
.prepare = nvhdmi_dig_playback_pcm_prepare_8ch_89,
290
290
+
.cleanup = nvhdmi_playback_pcm_cleanup,
291
291
+
},
292
292
+
};
293
293
+
294
294
+
static struct hda_pcm_stream nvhdmi_pcm_digital_playback_8ch_7x = {
342
295
.substreams = 1,
343
296
.channels_min = 2,
344
297
.channels_max = 8,
345
345
-
.nid = Nv_Master_Convert_nid,
298
298
+
.nid = nvhdmi_master_con_nid_7x,
346
299
.rates = SUPPORTED_RATES,
347
300
.maxbps = SUPPORTED_MAXBPS,
348
301
.formats = SUPPORTED_FORMATS,
349
302
.ops = {
350
303
.open = nvhdmi_dig_playback_pcm_open,
351
351
-
.close = nvhdmi_dig_playback_pcm_close_8ch,
304
304
+
.close = nvhdmi_dig_playback_pcm_close_8ch_7x,
352
305
.prepare = nvhdmi_dig_playback_pcm_prepare_8ch
353
306
},
354
307
};
···
376
291
.substreams = 1,
377
292
.channels_min = 2,
378
293
.channels_max = 2,
379
379
-
.nid = Nv_Master_Convert_nid,
294
294
+
.nid = nvhdmi_master_con_nid_7x,
380
295
.rates = SUPPORTED_RATES,
381
296
.maxbps = SUPPORTED_MAXBPS,
382
297
.formats = SUPPORTED_FORMATS,
···
387
302
},
388
303
};
389
304
390
390
-
static int nvhdmi_build_pcms_8ch(struct hda_codec *codec)
305
305
+
static int nvhdmi_build_pcms_8ch_89(struct hda_codec *codec)
391
306
{
392
392
-
struct nvhdmi_spec *spec = codec->spec;
393
393
-
struct hda_pcm *info = &spec->pcm_rec;
307
307
+
struct hdmi_spec *spec = codec->spec;
308
308
+
struct hda_pcm *info = spec->pcm_rec;
309
309
+
int i;
310
310
+
311
311
+
codec->num_pcms = spec->num_cvts;
312
312
+
codec->pcm_info = info;
313
313
+
314
314
+
for (i = 0; i < codec->num_pcms; i++, info++) {
315
315
+
unsigned int chans;
316
316
+
317
317
+
chans = get_wcaps(codec, spec->cvt[i]);
318
318
+
chans = get_wcaps_channels(chans);
319
319
+
320
320
+
info->name = nvhdmi_pcm_names[i];
321
321
+
info->pcm_type = HDA_PCM_TYPE_HDMI;
322
322
+
info->stream[SNDRV_PCM_STREAM_PLAYBACK]
323
323
+
= nvhdmi_pcm_digital_playback_8ch_89;
324
324
+
info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->cvt[i];
325
325
+
info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = chans;
326
326
+
}
327
327
+
328
328
+
return 0;
329
329
+
}
330
330
+
331
331
+
static int nvhdmi_build_pcms_8ch_7x(struct hda_codec *codec)
332
332
+
{
333
333
+
struct hdmi_spec *spec = codec->spec;
334
334
+
struct hda_pcm *info = spec->pcm_rec;
394
335
395
336
codec->num_pcms = 1;
396
337
codec->pcm_info = info;
···
424
313
info->name = "NVIDIA HDMI";
425
314
info->pcm_type = HDA_PCM_TYPE_HDMI;
426
315
info->stream[SNDRV_PCM_STREAM_PLAYBACK]
427
427
-
= nvhdmi_pcm_digital_playback_8ch;
316
316
+
= nvhdmi_pcm_digital_playback_8ch_7x;
428
317
429
318
return 0;
430
319
}
431
320
432
321
static int nvhdmi_build_pcms_2ch(struct hda_codec *codec)
433
322
{
434
434
-
struct nvhdmi_spec *spec = codec->spec;
435
435
-
struct hda_pcm *info = &spec->pcm_rec;
323
323
+
struct hdmi_spec *spec = codec->spec;
324
324
+
struct hda_pcm *info = spec->pcm_rec;
436
325
437
326
codec->num_pcms = 1;
438
327
codec->pcm_info = info;
···
445
334
return 0;
446
335
}
447
336
448
448
-
static void nvhdmi_free(struct hda_codec *codec)
449
449
-
{
450
450
-
kfree(codec->spec);
451
451
-
}
452
452
-
453
453
-
static struct hda_codec_ops nvhdmi_patch_ops_8ch = {
337
337
+
static struct hda_codec_ops nvhdmi_patch_ops_8ch_89 = {
454
338
.build_controls = nvhdmi_build_controls,
455
455
-
.build_pcms = nvhdmi_build_pcms_8ch,
339
339
+
.build_pcms = nvhdmi_build_pcms_8ch_89,
340
340
+
.init = nvhdmi_init,
341
341
+
.free = nvhdmi_free,
342
342
+
.unsol_event = hdmi_unsol_event,
343
343
+
};
344
344
+
345
345
+
static struct hda_codec_ops nvhdmi_patch_ops_8ch_7x = {
346
346
+
.build_controls = nvhdmi_build_controls,
347
347
+
.build_pcms = nvhdmi_build_pcms_8ch_7x,
456
348
.init = nvhdmi_init,
457
349
.free = nvhdmi_free,
458
350
};
···
467
353
.free = nvhdmi_free,
468
354
};
469
355
470
470
-
static int patch_nvhdmi_8ch(struct hda_codec *codec)
356
356
+
static int patch_nvhdmi_8ch_89(struct hda_codec *codec)
471
357
{
472
472
-
struct nvhdmi_spec *spec;
358
358
+
struct hdmi_spec *spec;
359
359
+
int i;
360
360
+
361
361
+
spec = kzalloc(sizeof(*spec), GFP_KERNEL);
362
362
+
if (spec == NULL)
363
363
+
return -ENOMEM;
364
364
+
365
365
+
codec->spec = spec;
366
366
+
spec->codec_type = HDA_CODEC_NVIDIA_MCP89;
367
367
+
368
368
+
if (hdmi_parse_codec(codec) < 0) {
369
369
+
codec->spec = NULL;
370
370
+
kfree(spec);
371
371
+
return -EINVAL;
372
372
+
}
373
373
+
codec->patch_ops = nvhdmi_patch_ops_8ch_89;
374
374
+
375
375
+
for (i = 0; i < spec->num_pins; i++)
376
376
+
snd_hda_eld_proc_new(codec, &spec->sink_eld[i], i);
377
377
+
378
378
+
init_channel_allocations();
379
379
+
380
380
+
return 0;
381
381
+
}
382
382
+
383
383
+
static int patch_nvhdmi_8ch_7x(struct hda_codec *codec)
384
384
+
{
385
385
+
struct hdmi_spec *spec;
473
386
474
387
spec = kzalloc(sizeof(*spec), GFP_KERNEL);
475
388
if (spec == NULL)
···
506
365
507
366
spec->multiout.num_dacs = 0; /* no analog */
508
367
spec->multiout.max_channels = 8;
509
509
-
spec->multiout.dig_out_nid = Nv_Master_Convert_nid;
368
368
+
spec->multiout.dig_out_nid = nvhdmi_master_con_nid_7x;
369
369
+
spec->codec_type = HDA_CODEC_NVIDIA_MCP7X;
510
370
511
511
-
codec->patch_ops = nvhdmi_patch_ops_8ch;
371
371
+
codec->patch_ops = nvhdmi_patch_ops_8ch_7x;
512
372
513
373
return 0;
514
374
}
515
375
516
376
static int patch_nvhdmi_2ch(struct hda_codec *codec)
517
377
{
518
518
-
struct nvhdmi_spec *spec;
378
378
+
struct hdmi_spec *spec;
519
379
520
380
spec = kzalloc(sizeof(*spec), GFP_KERNEL);
521
381
if (spec == NULL)
···
526
384
527
385
spec->multiout.num_dacs = 0; /* no analog */
528
386
spec->multiout.max_channels = 2;
529
529
-
spec->multiout.dig_out_nid = Nv_Master_Convert_nid;
387
387
+
spec->multiout.dig_out_nid = nvhdmi_master_con_nid_7x;
388
388
+
spec->codec_type = HDA_CODEC_NVIDIA_MCP7X;
530
389
531
390
codec->patch_ops = nvhdmi_patch_ops_2ch;
532
391
···
538
395
* patch entries
539
396
*/
540
397
static struct hda_codec_preset snd_hda_preset_nvhdmi[] = {
541
541
-
{ .id = 0x10de0002, .name = "MCP78 HDMI", .patch = patch_nvhdmi_8ch },
542
542
-
{ .id = 0x10de0003, .name = "MCP78 HDMI", .patch = patch_nvhdmi_8ch },
543
543
-
{ .id = 0x10de0005, .name = "MCP78 HDMI", .patch = patch_nvhdmi_8ch },
544
544
-
{ .id = 0x10de0006, .name = "MCP78 HDMI", .patch = patch_nvhdmi_8ch },
545
545
-
{ .id = 0x10de0007, .name = "MCP7A HDMI", .patch = patch_nvhdmi_8ch },
546
398
{ .id = 0x10de0067, .name = "MCP67 HDMI", .patch = patch_nvhdmi_2ch },
547
399
{ .id = 0x10de8001, .name = "MCP73 HDMI", .patch = patch_nvhdmi_2ch },
400
400
+
{ .id = 0x10de0002, .name = "MCP77/78 HDMI",
401
401
+
.patch = patch_nvhdmi_8ch_7x },
402
402
+
{ .id = 0x10de0003, .name = "MCP77/78 HDMI",
403
403
+
.patch = patch_nvhdmi_8ch_7x },
404
404
+
{ .id = 0x10de0005, .name = "MCP77/78 HDMI",
405
405
+
.patch = patch_nvhdmi_8ch_7x },
406
406
+
{ .id = 0x10de0006, .name = "MCP77/78 HDMI",
407
407
+
.patch = patch_nvhdmi_8ch_7x },
408
408
+
{ .id = 0x10de0007, .name = "MCP79/7A HDMI",
409
409
+
.patch = patch_nvhdmi_8ch_7x },
410
410
+
{ .id = 0x10de000c, .name = "MCP89 HDMI",
411
411
+
.patch = patch_nvhdmi_8ch_89 },
412
412
+
{ .id = 0x10de000b, .name = "GT21x HDMI",
413
413
+
.patch = patch_nvhdmi_8ch_89 },
414
414
+
{ .id = 0x10de000d, .name = "GT240 HDMI",
415
415
+
.patch = patch_nvhdmi_8ch_89 },
548
416
{} /* terminator */
549
417
};
550
418
···
566
412
MODULE_ALIAS("snd-hda-codec-id:10de0007");
567
413
MODULE_ALIAS("snd-hda-codec-id:10de0067");
568
414
MODULE_ALIAS("snd-hda-codec-id:10de8001");
415
415
+
MODULE_ALIAS("snd-hda-codec-id:10de000c");
416
416
+
MODULE_ALIAS("snd-hda-codec-id:10de000b");
417
417
+
MODULE_ALIAS("snd-hda-codec-id:10de000d");
569
418
570
419
MODULE_LICENSE("GPL");
571
571
-
MODULE_DESCRIPTION("Nvidia HDMI HD-audio codec");
420
420
+
MODULE_DESCRIPTION("NVIDIA HDMI HD-audio codec");
572
421
573
422
static struct hda_codec_preset_list nvhdmi_list = {
574
423
.preset = snd_hda_preset_nvhdmi,
+9
-1
sound/pci/hda/patch_realtek.c
···
4915
4915
static void fixup_single_adc(struct hda_codec *codec)
4916
4916
{
4917
4917
struct alc_spec *spec = codec->spec;
4918
4918
-
hda_nid_t pin;
4918
4918
+
hda_nid_t pin = 0;
4919
4919
int i;
4920
4920
4921
4921
/* search for the input pin; there must be only one */
···
13561
13561
static void alc269_quanta_fl1_setup(struct hda_codec *codec)
13562
13562
{
13563
13563
struct alc_spec *spec = codec->spec;
13564
13564
+
spec->autocfg.hp_pins[0] = 0x15;
13565
13565
+
spec->autocfg.speaker_pins[0] = 0x14;
13564
13566
spec->ext_mic.pin = 0x18;
13565
13567
spec->ext_mic.mux_idx = 0;
13566
13568
spec->int_mic.pin = 0x19;
···
13658
13656
static void alc269_laptop_dmic_setup(struct hda_codec *codec)
13659
13657
{
13660
13658
struct alc_spec *spec = codec->spec;
13659
13659
+
spec->autocfg.hp_pins[0] = 0x15;
13660
13660
+
spec->autocfg.speaker_pins[0] = 0x14;
13661
13661
spec->ext_mic.pin = 0x18;
13662
13662
spec->ext_mic.mux_idx = 0;
13663
13663
spec->int_mic.pin = 0x12;
···
13670
13666
static void alc269vb_laptop_dmic_setup(struct hda_codec *codec)
13671
13667
{
13672
13668
struct alc_spec *spec = codec->spec;
13669
13669
+
spec->autocfg.hp_pins[0] = 0x15;
13670
13670
+
spec->autocfg.speaker_pins[0] = 0x14;
13673
13671
spec->ext_mic.pin = 0x18;
13674
13672
spec->ext_mic.mux_idx = 0;
13675
13673
spec->int_mic.pin = 0x12;
···
13682
13676
static void alc269_laptop_amic_setup(struct hda_codec *codec)
13683
13677
{
13684
13678
struct alc_spec *spec = codec->spec;
13679
13679
+
spec->autocfg.hp_pins[0] = 0x15;
13680
13680
+
spec->autocfg.speaker_pins[0] = 0x14;
13685
13681
spec->ext_mic.pin = 0x18;
13686
13682
spec->ext_mic.mux_idx = 0;
13687
13683
spec->int_mic.pin = 0x19;