summaryrefslogtreecommitdiffstats
path: root/sound/x86
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2017-02-02 10:38:39 -0500
committerTakashi Iwai <tiwai@suse.de>2017-02-03 11:37:23 -0500
commit4aedb9465f717a8393bb5f40581eb7942af12506 (patch)
tree4ce41c4f29ca703a82d8ce7a97e6a990c57091fb /sound/x86
parent03c3437755881a9f6f1b5f8c05e62edf7898a87f (diff)
ALSA: x86: Create ELD control element
Like other drivers, expose the ELD bytes via a control element so that user-space can parse it. For the simplicity, the code to register the ctl elements is refactored using an array. Also, since ELD ctl read copies the bytes also during disconnection, clear the ELD bytes at hot-unplug, in order to avoid the leak of the previous bogus ELD. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/x86')
-rw-r--r--sound/x86/intel_hdmi_audio.c72
1 files changed, 51 insertions, 21 deletions
diff --git a/sound/x86/intel_hdmi_audio.c b/sound/x86/intel_hdmi_audio.c
index 82f48fbcd74b..f49520117dd6 100644
--- a/sound/x86/intel_hdmi_audio.c
+++ b/sound/x86/intel_hdmi_audio.c
@@ -1669,22 +1669,52 @@ static int had_iec958_put(struct snd_kcontrol *kcontrol,
1669 return changed; 1669 return changed;
1670} 1670}
1671 1671
1672static struct snd_kcontrol_new had_control_iec958_mask = { 1672static int had_ctl_eld_info(struct snd_kcontrol *kcontrol,
1673 .access = SNDRV_CTL_ELEM_ACCESS_READ, 1673 struct snd_ctl_elem_info *uinfo)
1674 .iface = SNDRV_CTL_ELEM_IFACE_PCM, 1674{
1675 .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, MASK), 1675 uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
1676 .info = had_iec958_info, /* shared */ 1676 uinfo->count = HDMI_MAX_ELD_BYTES;
1677 .get = had_iec958_mask_get, 1677 return 0;
1678}; 1678}
1679 1679
1680static struct snd_kcontrol_new had_control_iec958 = { 1680static int had_ctl_eld_get(struct snd_kcontrol *kcontrol,
1681 .iface = SNDRV_CTL_ELEM_IFACE_PCM, 1681 struct snd_ctl_elem_value *ucontrol)
1682 .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, DEFAULT), 1682{
1683 .info = had_iec958_info, 1683 struct snd_intelhad *intelhaddata = snd_kcontrol_chip(kcontrol);
1684 .get = had_iec958_get, 1684
1685 .put = had_iec958_put 1685 mutex_lock(&intelhaddata->mutex);
1686 memcpy(ucontrol->value.bytes.data, intelhaddata->eld,
1687 HDMI_MAX_ELD_BYTES);
1688 mutex_unlock(&intelhaddata->mutex);
1689 return 0;
1690}
1691
1692static struct snd_kcontrol_new had_controls[] = {
1693 {
1694 .access = SNDRV_CTL_ELEM_ACCESS_READ,
1695 .iface = SNDRV_CTL_ELEM_IFACE_PCM,
1696 .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, MASK),
1697 .info = had_iec958_info, /* shared */
1698 .get = had_iec958_mask_get,
1699 },
1700 {
1701 .iface = SNDRV_CTL_ELEM_IFACE_PCM,
1702 .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, DEFAULT),
1703 .info = had_iec958_info,
1704 .get = had_iec958_get,
1705 .put = had_iec958_put,
1706 },
1707 {
1708 .access = (SNDRV_CTL_ELEM_ACCESS_READ |
1709 SNDRV_CTL_ELEM_ACCESS_VOLATILE),
1710 .iface = SNDRV_CTL_ELEM_IFACE_PCM,
1711 .name = "ELD",
1712 .info = had_ctl_eld_info,
1713 .get = had_ctl_eld_get,
1714 },
1686}; 1715};
1687 1716
1717
1688static irqreturn_t display_pipe_interrupt_handler(int irq, void *dev_id) 1718static irqreturn_t display_pipe_interrupt_handler(int irq, void *dev_id)
1689{ 1719{
1690 struct snd_intelhad *ctx = dev_id; 1720 struct snd_intelhad *ctx = dev_id;
@@ -1724,6 +1754,7 @@ static void had_audio_wq(struct work_struct *work)
1724 if (!pdata->hdmi_connected) { 1754 if (!pdata->hdmi_connected) {
1725 dev_dbg(ctx->dev, "%s: Event: HAD_NOTIFY_HOT_UNPLUG\n", 1755 dev_dbg(ctx->dev, "%s: Event: HAD_NOTIFY_HOT_UNPLUG\n",
1726 __func__); 1756 __func__);
1757 memset(ctx->eld, 0, sizeof(ctx->eld)); /* clear the old ELD */
1727 had_process_hot_unplug(ctx); 1758 had_process_hot_unplug(ctx);
1728 } else { 1759 } else {
1729 struct intel_hdmi_lpe_audio_eld *eld = &pdata->eld; 1760 struct intel_hdmi_lpe_audio_eld *eld = &pdata->eld;
@@ -1826,7 +1857,7 @@ static int hdmi_lpe_audio_probe(struct platform_device *pdev)
1826 struct intel_hdmi_lpe_audio_pdata *pdata; 1857 struct intel_hdmi_lpe_audio_pdata *pdata;
1827 int irq; 1858 int irq;
1828 struct resource *res_mmio; 1859 struct resource *res_mmio;
1829 int ret; 1860 int i, ret;
1830 1861
1831 dev_dbg(&pdev->dev, "dma_mask: %p\n", pdev->dev.dma_mask); 1862 dev_dbg(&pdev->dev, "dma_mask: %p\n", pdev->dev.dma_mask);
1832 1863
@@ -1918,13 +1949,12 @@ static int hdmi_lpe_audio_probe(struct platform_device *pdev)
1918 SNDRV_DMA_TYPE_DEV, NULL, 1949 SNDRV_DMA_TYPE_DEV, NULL,
1919 HAD_MAX_BUFFER, HAD_MAX_BUFFER); 1950 HAD_MAX_BUFFER, HAD_MAX_BUFFER);
1920 1951
1921 /* IEC958 controls */ 1952 /* create controls */
1922 ret = snd_ctl_add(card, snd_ctl_new1(&had_control_iec958_mask, ctx)); 1953 for (i = 0; i < ARRAY_SIZE(had_controls); i++) {
1923 if (ret < 0) 1954 ret = snd_ctl_add(card, snd_ctl_new1(&had_controls[i], ctx));
1924 goto err; 1955 if (ret < 0)
1925 ret = snd_ctl_add(card, snd_ctl_new1(&had_control_iec958, ctx)); 1956 goto err;
1926 if (ret < 0) 1957 }
1927 goto err;
1928 1958
1929 init_channel_allocations(); 1959 init_channel_allocations();
1930 1960