Commit c94800a3 authored by Sameer Pujar's avatar Sameer Pujar Committed by Takashi Iwai

ALSA: hda/tegra: compatible string as shortname

By default HDA sound card is registered with shortname "tegra-hda".
Same driver is used across tegra platforms and it is necessary to
distinguish between platforms to use platform specific settings from
userspace. One such example is, hdmi port on different platforms use
different alsa pcm device ID. For hdmi playback to work it should
open correct pcm device depending on the platform.

This patch applies shortname from first compatible string provided
in root node of device tree. Userspace then can use this card name
to apply specific settings.
Signed-off-by: default avatarSameer Pujar <spujar@nvidia.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 3103c08f
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/time.h> #include <linux/time.h>
#include <linux/string.h>
#include <sound/core.h> #include <sound/core.h>
#include <sound/initval.h> #include <sound/initval.h>
...@@ -344,6 +345,8 @@ static int hda_tegra_first_init(struct azx *chip, struct platform_device *pdev) ...@@ -344,6 +345,8 @@ static int hda_tegra_first_init(struct azx *chip, struct platform_device *pdev)
int err; int err;
unsigned short gcap; unsigned short gcap;
int irq_id = platform_get_irq(pdev, 0); int irq_id = platform_get_irq(pdev, 0);
const char *sname;
struct device_node *root;
err = hda_tegra_init_chip(chip, pdev); err = hda_tegra_init_chip(chip, pdev);
if (err) if (err)
...@@ -401,8 +404,23 @@ static int hda_tegra_first_init(struct azx *chip, struct platform_device *pdev) ...@@ -401,8 +404,23 @@ static int hda_tegra_first_init(struct azx *chip, struct platform_device *pdev)
return -ENODEV; return -ENODEV;
} }
/* driver name */
strcpy(card->driver, "tegra-hda"); strcpy(card->driver, "tegra-hda");
strcpy(card->shortname, "tegra-hda");
root = of_find_node_by_path("/");
sname = of_get_property(root, "compatible", NULL);
of_node_put(root);
if (!sname) {
dev_err(card->dev,
"failed to get compatible property from root node\n");
return -ENODEV;
}
/* shortname for card */
if (strlen(sname) > sizeof(card->shortname))
dev_info(card->dev, "truncating shortname for card\n");
strncpy(card->shortname, sname, sizeof(card->shortname));
/* longname for card */
snprintf(card->longname, sizeof(card->longname), snprintf(card->longname, sizeof(card->longname),
"%s at 0x%lx irq %i", "%s at 0x%lx irq %i",
card->shortname, bus->addr, bus->irq); card->shortname, bus->addr, bus->irq);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment