aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/hda/patch_hdmi.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pci/hda/patch_hdmi.c')
-rw-r--r--sound/pci/hda/patch_hdmi.c71
1 files changed, 20 insertions, 51 deletions
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
index b422e406a9cb..7e9ff7b16e56 100644
--- a/sound/pci/hda/patch_hdmi.c
+++ b/sound/pci/hda/patch_hdmi.c
@@ -86,7 +86,6 @@ struct hdmi_spec_per_pin {
86 bool non_pcm; 86 bool non_pcm;
87 bool chmap_set; /* channel-map override by ALSA API? */ 87 bool chmap_set; /* channel-map override by ALSA API? */
88 unsigned char chmap[8]; /* ALSA API channel-map */ 88 unsigned char chmap[8]; /* ALSA API channel-map */
89 char pcm_name[8]; /* filled in build_pcm callbacks */
90#ifdef CONFIG_PROC_FS 89#ifdef CONFIG_PROC_FS
91 struct snd_info_entry *proc_entry; 90 struct snd_info_entry *proc_entry;
92#endif 91#endif
@@ -132,7 +131,7 @@ struct hdmi_spec {
132 131
133 int num_pins; 132 int num_pins;
134 struct snd_array pins; /* struct hdmi_spec_per_pin */ 133 struct snd_array pins; /* struct hdmi_spec_per_pin */
135 struct snd_array pcm_rec; /* struct hda_pcm */ 134 struct hda_pcm *pcm_rec[16];
136 unsigned int channels_max; /* max over all cvts */ 135 unsigned int channels_max; /* max over all cvts */
137 136
138 struct hdmi_eld temp_eld; 137 struct hdmi_eld temp_eld;
@@ -355,8 +354,7 @@ static struct cea_channel_speaker_allocation channel_allocations[] = {
355 ((struct hdmi_spec_per_pin *)snd_array_elem(&spec->pins, idx)) 354 ((struct hdmi_spec_per_pin *)snd_array_elem(&spec->pins, idx))
356#define get_cvt(spec, idx) \ 355#define get_cvt(spec, idx) \
357 ((struct hdmi_spec_per_cvt *)snd_array_elem(&spec->cvts, idx)) 356 ((struct hdmi_spec_per_cvt *)snd_array_elem(&spec->cvts, idx))
358#define get_pcm_rec(spec, idx) \ 357#define get_pcm_rec(spec, idx) ((spec)->pcm_rec[idx])
359 ((struct hda_pcm *)snd_array_elem(&spec->pcm_rec, idx))
360 358
361static int pin_nid_to_pin_index(struct hda_codec *codec, hda_nid_t pin_nid) 359static int pin_nid_to_pin_index(struct hda_codec *codec, hda_nid_t pin_nid)
362{ 360{
@@ -579,7 +577,7 @@ static int eld_proc_new(struct hdmi_spec_per_pin *per_pin, int index)
579 int err; 577 int err;
580 578
581 snprintf(name, sizeof(name), "eld#%d.%d", codec->addr, index); 579 snprintf(name, sizeof(name), "eld#%d.%d", codec->addr, index);
582 err = snd_card_proc_new(codec->bus->card, name, &entry); 580 err = snd_card_proc_new(codec->card, name, &entry);
583 if (err < 0) 581 if (err < 0)
584 return err; 582 return err;
585 583
@@ -594,7 +592,7 @@ static int eld_proc_new(struct hdmi_spec_per_pin *per_pin, int index)
594static void eld_proc_free(struct hdmi_spec_per_pin *per_pin) 592static void eld_proc_free(struct hdmi_spec_per_pin *per_pin)
595{ 593{
596 if (!per_pin->codec->bus->shutdown && per_pin->proc_entry) { 594 if (!per_pin->codec->bus->shutdown && per_pin->proc_entry) {
597 snd_device_free(per_pin->codec->bus->card, per_pin->proc_entry); 595 snd_device_free(per_pin->codec->card, per_pin->proc_entry);
598 per_pin->proc_entry = NULL; 596 per_pin->proc_entry = NULL;
599 } 597 }
600} 598}
@@ -1578,9 +1576,8 @@ static bool hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll)
1578 update_eld = true; 1576 update_eld = true;
1579 } 1577 }
1580 else if (repoll) { 1578 else if (repoll) {
1581 queue_delayed_work(codec->bus->workq, 1579 schedule_delayed_work(&per_pin->work,
1582 &per_pin->work, 1580 msecs_to_jiffies(300));
1583 msecs_to_jiffies(300));
1584 goto unlock; 1581 goto unlock;
1585 } 1582 }
1586 } 1583 }
@@ -1624,7 +1621,7 @@ static bool hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll)
1624 } 1621 }
1625 1622
1626 if (eld_changed) 1623 if (eld_changed)
1627 snd_ctl_notify(codec->bus->card, 1624 snd_ctl_notify(codec->card,
1628 SNDRV_CTL_EVENT_MASK_VALUE | SNDRV_CTL_EVENT_MASK_INFO, 1625 SNDRV_CTL_EVENT_MASK_VALUE | SNDRV_CTL_EVENT_MASK_INFO,
1629 &per_pin->eld_ctl->id); 1626 &per_pin->eld_ctl->id);
1630 unlock: 1627 unlock:
@@ -2056,11 +2053,10 @@ static int generic_hdmi_build_pcms(struct hda_codec *codec)
2056 struct hdmi_spec_per_pin *per_pin; 2053 struct hdmi_spec_per_pin *per_pin;
2057 2054
2058 per_pin = get_pin(spec, pin_idx); 2055 per_pin = get_pin(spec, pin_idx);
2059 sprintf(per_pin->pcm_name, "HDMI %d", pin_idx); 2056 info = snd_hda_codec_pcm_new(codec, "HDMI %d", pin_idx);
2060 info = snd_array_new(&spec->pcm_rec);
2061 if (!info) 2057 if (!info)
2062 return -ENOMEM; 2058 return -ENOMEM;
2063 info->name = per_pin->pcm_name; 2059 spec->pcm_rec[pin_idx] = info;
2064 info->pcm_type = HDA_PCM_TYPE_HDMI; 2060 info->pcm_type = HDA_PCM_TYPE_HDMI;
2065 info->own_chmap = true; 2061 info->own_chmap = true;
2066 2062
@@ -2070,9 +2066,6 @@ static int generic_hdmi_build_pcms(struct hda_codec *codec)
2070 /* other pstr fields are set in open */ 2066 /* other pstr fields are set in open */
2071 } 2067 }
2072 2068
2073 codec->num_pcms = spec->num_pins;
2074 codec->pcm_info = spec->pcm_rec.list;
2075
2076 return 0; 2069 return 0;
2077} 2070}
2078 2071
@@ -2125,13 +2118,15 @@ static int generic_hdmi_build_controls(struct hda_codec *codec)
2125 2118
2126 /* add channel maps */ 2119 /* add channel maps */
2127 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { 2120 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) {
2121 struct hda_pcm *pcm;
2128 struct snd_pcm_chmap *chmap; 2122 struct snd_pcm_chmap *chmap;
2129 struct snd_kcontrol *kctl; 2123 struct snd_kcontrol *kctl;
2130 int i; 2124 int i;
2131 2125
2132 if (!codec->pcm_info[pin_idx].pcm) 2126 pcm = spec->pcm_rec[pin_idx];
2127 if (!pcm || !pcm->pcm)
2133 break; 2128 break;
2134 err = snd_pcm_add_chmap_ctls(codec->pcm_info[pin_idx].pcm, 2129 err = snd_pcm_add_chmap_ctls(pcm->pcm,
2135 SNDRV_PCM_STREAM_PLAYBACK, 2130 SNDRV_PCM_STREAM_PLAYBACK,
2136 NULL, 0, pin_idx, &chmap); 2131 NULL, 0, pin_idx, &chmap);
2137 if (err < 0) 2132 if (err < 0)
@@ -2186,14 +2181,12 @@ static void hdmi_array_init(struct hdmi_spec *spec, int nums)
2186{ 2181{
2187 snd_array_init(&spec->pins, sizeof(struct hdmi_spec_per_pin), nums); 2182 snd_array_init(&spec->pins, sizeof(struct hdmi_spec_per_pin), nums);
2188 snd_array_init(&spec->cvts, sizeof(struct hdmi_spec_per_cvt), nums); 2183 snd_array_init(&spec->cvts, sizeof(struct hdmi_spec_per_cvt), nums);
2189 snd_array_init(&spec->pcm_rec, sizeof(struct hda_pcm), nums);
2190} 2184}
2191 2185
2192static void hdmi_array_free(struct hdmi_spec *spec) 2186static void hdmi_array_free(struct hdmi_spec *spec)
2193{ 2187{
2194 snd_array_free(&spec->pins); 2188 snd_array_free(&spec->pins);
2195 snd_array_free(&spec->cvts); 2189 snd_array_free(&spec->cvts);
2196 snd_array_free(&spec->pcm_rec);
2197} 2190}
2198 2191
2199static void generic_hdmi_free(struct hda_codec *codec) 2192static void generic_hdmi_free(struct hda_codec *codec)
@@ -2204,11 +2197,10 @@ static void generic_hdmi_free(struct hda_codec *codec)
2204 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { 2197 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) {
2205 struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx); 2198 struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx);
2206 2199
2207 cancel_delayed_work(&per_pin->work); 2200 cancel_delayed_work_sync(&per_pin->work);
2208 eld_proc_free(per_pin); 2201 eld_proc_free(per_pin);
2209 } 2202 }
2210 2203
2211 flush_workqueue(codec->bus->workq);
2212 hdmi_array_free(spec); 2204 hdmi_array_free(spec);
2213 kfree(spec); 2205 kfree(spec);
2214} 2206}
@@ -2381,11 +2373,10 @@ static int simple_playback_build_pcms(struct hda_codec *codec)
2381 chans = get_wcaps(codec, per_cvt->cvt_nid); 2373 chans = get_wcaps(codec, per_cvt->cvt_nid);
2382 chans = get_wcaps_channels(chans); 2374 chans = get_wcaps_channels(chans);
2383 2375
2384 info = snd_array_new(&spec->pcm_rec); 2376 info = snd_hda_codec_pcm_new(codec, "HDMI 0");
2385 if (!info) 2377 if (!info)
2386 return -ENOMEM; 2378 return -ENOMEM;
2387 info->name = get_pin(spec, 0)->pcm_name; 2379 spec->pcm_rec[0] = info;
2388 sprintf(info->name, "HDMI 0");
2389 info->pcm_type = HDA_PCM_TYPE_HDMI; 2380 info->pcm_type = HDA_PCM_TYPE_HDMI;
2390 pstr = &info->stream[SNDRV_PCM_STREAM_PLAYBACK]; 2381 pstr = &info->stream[SNDRV_PCM_STREAM_PLAYBACK];
2391 *pstr = spec->pcm_playback; 2382 *pstr = spec->pcm_playback;
@@ -2393,9 +2384,6 @@ static int simple_playback_build_pcms(struct hda_codec *codec)
2393 if (pstr->channels_max <= 2 && chans && chans <= 16) 2384 if (pstr->channels_max <= 2 && chans && chans <= 16)
2394 pstr->channels_max = chans; 2385 pstr->channels_max = chans;
2395 2386
2396 codec->num_pcms = 1;
2397 codec->pcm_info = info;
2398
2399 return 0; 2387 return 0;
2400} 2388}
2401 2389
@@ -3301,15 +3289,6 @@ static int patch_via_hdmi(struct hda_codec *codec)
3301} 3289}
3302 3290
3303/* 3291/*
3304 * called from hda_codec.c for generic HDMI support
3305 */
3306int snd_hda_parse_hdmi_codec(struct hda_codec *codec)
3307{
3308 return patch_generic_hdmi(codec);
3309}
3310EXPORT_SYMBOL_GPL(snd_hda_parse_hdmi_codec);
3311
3312/*
3313 * patch entries 3292 * patch entries
3314 */ 3293 */
3315static const struct hda_codec_preset snd_hda_preset_hdmi[] = { 3294static const struct hda_codec_preset snd_hda_preset_hdmi[] = {
@@ -3373,6 +3352,8 @@ static const struct hda_codec_preset snd_hda_preset_hdmi[] = {
3373{ .id = 0x80862882, .name = "Valleyview2 HDMI", .patch = patch_generic_hdmi }, 3352{ .id = 0x80862882, .name = "Valleyview2 HDMI", .patch = patch_generic_hdmi },
3374{ .id = 0x80862883, .name = "Braswell HDMI", .patch = patch_generic_hdmi }, 3353{ .id = 0x80862883, .name = "Braswell HDMI", .patch = patch_generic_hdmi },
3375{ .id = 0x808629fb, .name = "Crestline HDMI", .patch = patch_generic_hdmi }, 3354{ .id = 0x808629fb, .name = "Crestline HDMI", .patch = patch_generic_hdmi },
3355/* special ID for generic HDMI */
3356{ .id = HDA_CODEC_ID_GENERIC_HDMI, .patch = patch_generic_hdmi },
3376{} /* terminator */ 3357{} /* terminator */
3377}; 3358};
3378 3359
@@ -3442,20 +3423,8 @@ MODULE_ALIAS("snd-hda-codec-intelhdmi");
3442MODULE_ALIAS("snd-hda-codec-nvhdmi"); 3423MODULE_ALIAS("snd-hda-codec-nvhdmi");
3443MODULE_ALIAS("snd-hda-codec-atihdmi"); 3424MODULE_ALIAS("snd-hda-codec-atihdmi");
3444 3425
3445static struct hda_codec_preset_list intel_list = { 3426static struct hda_codec_driver hdmi_driver = {
3446 .preset = snd_hda_preset_hdmi, 3427 .preset = snd_hda_preset_hdmi,
3447 .owner = THIS_MODULE,
3448}; 3428};
3449 3429
3450static int __init patch_hdmi_init(void) 3430module_hda_codec_driver(hdmi_driver);
3451{
3452 return snd_hda_add_codec_preset(&intel_list);
3453}
3454
3455static void __exit patch_hdmi_exit(void)
3456{
3457 snd_hda_delete_codec_preset(&intel_list);
3458}
3459
3460module_init(patch_hdmi_init)
3461module_exit(patch_hdmi_exit)