From patchwork Thu Nov 29 03:58:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sameer Pujar X-Patchwork-Id: 10704085 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DFCD8109C for ; Thu, 29 Nov 2018 07:01:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D03C02EA50 for ; Thu, 29 Nov 2018 07:01:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BF5472EA52; Thu, 29 Nov 2018 07:01:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DC89B2EA50 for ; Thu, 29 Nov 2018 07:01:20 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 5D9AB267AF3; Thu, 29 Nov 2018 08:01:03 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 938AC267B35; Thu, 29 Nov 2018 04:59:07 +0100 (CET) Received: from hqemgate15.nvidia.com (hqemgate15.nvidia.com [216.228.121.64]) by alsa0.perex.cz (Postfix) with ESMTP id 6EEEC267B2C for ; Thu, 29 Nov 2018 04:59:04 +0100 (CET) Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate15.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Wed, 28 Nov 2018 19:58:20 -0800 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Wed, 28 Nov 2018 19:59:03 -0800 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Wed, 28 Nov 2018 19:59:03 -0800 Received: from HQMAIL106.nvidia.com (172.18.146.12) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Thu, 29 Nov 2018 03:59:02 +0000 Received: from hqnvemgw01.nvidia.com (172.20.150.20) by HQMAIL106.nvidia.com (172.18.146.12) with Microsoft SMTP Server (TLS) id 15.0.1395.4 via Frontend Transport; Thu, 29 Nov 2018 03:59:02 +0000 Received: from linux.nvidia.com (Not Verified[10.24.34.185]) by hqnvemgw01.nvidia.com with Trustwave SEG (v7, 5, 8, 10121) id ; Wed, 28 Nov 2018 19:59:02 -0800 From: Sameer Pujar To: , , Date: Thu, 29 Nov 2018 09:28:52 +0530 Message-ID: <1543463932-27625-1-git-send-email-spujar@nvidia.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1543463901; bh=i1wkDrhDICfKVfQ5+/cOkoBmPB216k05p3OFGa0UD9Q=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: MIME-Version:Content-Type; b=kuWgawLvqabTgv7ordZdpNKWpRdK/AFc9X/e61Xg89MKlZvsqMpc0nIDkbIuyufYI 1UEDJ5R5QRdTbS7Um43QgmLA4t5Ubt4vgKWJEP2oYaIsqt+4qIMDamltU0YuXvZHrV wUvWcoEdg+ZL/oANmuCEJvZ1r3EiVNwDGJYYPGb/LzGNjDv+XvCAt9vO2XPAz/eHDE HTIXTWQkOGBexq/6lIxqIk3U+K8zrc4mBsuQPYd3ZbFaDg9cePyisa3euX8zjsaIl7 Y8iTNw4+Lxb3UJCjfsUL6XooMVeFHBynzMcHxk99qMn805zg25J1k9GsKXsFcQDfdx I80SRIAHGYXnA== X-Mailman-Approved-At: Thu, 29 Nov 2018 08:00:55 +0100 Cc: alsa-devel@alsa-project.org, Sameer Pujar Subject: [alsa-devel] [PATCH] ALSA: hda/tegra: compatible string as shortname X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP 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: Sameer Pujar --- sound/pci/hda/hda_tegra.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/sound/pci/hda/hda_tegra.c b/sound/pci/hda/hda_tegra.c index dd7d424..84ea606 100644 --- a/sound/pci/hda/hda_tegra.c +++ b/sound/pci/hda/hda_tegra.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -344,6 +345,8 @@ static int hda_tegra_first_init(struct azx *chip, struct platform_device *pdev) int err; unsigned short gcap; int irq_id = platform_get_irq(pdev, 0); + const char *sname; + struct device_node *root; err = hda_tegra_init_chip(chip, pdev); if (err) @@ -401,8 +404,23 @@ static int hda_tegra_first_init(struct azx *chip, struct platform_device *pdev) return -ENODEV; } + /* driver name */ 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), "%s at 0x%lx irq %i", card->shortname, bus->addr, bus->irq);