From patchwork Fri Jun 12 03:36:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Goode X-Patchwork-Id: 6594101 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 38B35C0020 for ; Fri, 12 Jun 2015 03:36:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5A98C20660 for ; Fri, 12 Jun 2015 03:36:48 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id D88B32065D for ; Fri, 12 Jun 2015 03:36:46 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 5589F2666A4; Fri, 12 Jun 2015 05:36:45 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 2DD82266643; Fri, 12 Jun 2015 05:36:37 +0200 (CEST) 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 3D198266684; Fri, 12 Jun 2015 05:36:36 +0200 (CEST) Received: from mail-yh0-f46.google.com (mail-yh0-f46.google.com [209.85.213.46]) by alsa0.perex.cz (Postfix) with ESMTP id 3ADB0266640 for ; Fri, 12 Jun 2015 05:36:29 +0200 (CEST) Received: by yhid80 with SMTP id d80so9469363yhi.1 for ; Thu, 11 Jun 2015 20:36:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=A7Bz4a3C/AKgw5HNtRh1WPrbTJuxL+Cm4/DCyqgw0BE=; b=H7ErzlTqQ9SZvb0M1DGDnOMLNhk2EtTLsKSs0JVqoAtfjjFc0hnf8NXozxrC3CVHow WVpNP30sfFN2kA01gtF8rURFceDjTZhmDRJPZAkAd4U0BRTawO25AsmOXLas51QF7/f2 C0B0QIK6qedZpyutKSIFawZ4chAKrilEbF8a8sj558yalvfF6VvzIeDoclOWL9hee+4F wI38T7Yn5zrooDo5mS0gBEdix8tWwYrdr8FN61D46YnsqbNsRYGl8FMHsgp6QIslmNnA 0vmreEK6cDH9ZSNY3wivAdKtHFdPlSlIwbECe/tPXPlC07sxdsTNjZmtuvQYLbPjSxNj Yshg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=A7Bz4a3C/AKgw5HNtRh1WPrbTJuxL+Cm4/DCyqgw0BE=; b=SNarYfWTpudxym3QHj2K6IBNmxz5m8+/nkNKeWedr7/yFNQVkwk89ED2et2x47B+jc 8410dLN9GAANuhrbbGNu9xDC1Xjx1ehCk6WHVGBUZp8eUBUq4VwHxxCZ96gMn88+JJkV mbrVvn5opU6o6XwyeHPIYCHg0Zm+0O5eH0m+fg7/mKaZnDPTWYk+KcfjJ6dfgb0QfC2s EAcCDHQzKu9GTTPTlQajPRall4Uf6wQvsEVKDtI2eKeqvO27uJFBX5xKwY3bUISzCw1H Dy/hjvmVv+sD1OjmdHmqFrvS2b4KlaFKuLPCG3J9x3nfk4KNUm3aocN9eHlWUOFcyz6j Zs9w== X-Gm-Message-State: ALoCoQnEzQUNxYGPFkl6YLtG4/fVlD4Ygw6Buz8gRKJs0v0wjlrVhyIyHEkCv2u7nCFA3uJX2nG9 X-Received: by 10.129.148.4 with SMTP id l4mr16413344ywg.142.1434080188101; Thu, 11 Jun 2015 20:36:28 -0700 (PDT) Received: from wpg-ubiq154.hot.corp.google.com ([172.24.166.195]) by mx.google.com with ESMTPSA id 28sm1093085yhf.25.2015.06.11.20.36.25 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 11 Jun 2015 20:36:25 -0700 (PDT) From: Adam Goode To: patch@alsa-project.org Date: Thu, 11 Jun 2015 23:36:22 -0400 Message-Id: <1434080182-25438-1-git-send-email-agoode@google.com> X-Mailer: git-send-email 2.2.0.rc0.207.ga3a616c Cc: Adam Goode , alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH v2 - seq 1/1] ALSA seq: expose the card number of ALSA seq clients 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: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Expose the card number of seq clients. This allows interested userspace programs to discover the hardware device that backs a particular seq client. Before this change, the only way to get information about the hardware for a client was by using brittle heuristics. SNDRV_SEQ_VERSION is not yet incremented in this patch, but should be relatively soon. Signed-off-by: Adam Goode diff --git a/include/uapi/sound/asequencer.h b/include/uapi/sound/asequencer.h index 5a5fa49..2627bee 100644 --- a/include/uapi/sound/asequencer.h +++ b/include/uapi/sound/asequencer.h @@ -357,7 +357,8 @@ struct snd_seq_client_info { unsigned char event_filter[32]; /* event filter bitmap */ int num_ports; /* RO: number of ports */ int event_lost; /* number of lost events */ - char reserved[64]; /* for future use */ + int card_number; /* RO: card number, or -1 if no card. Added in protocol version 1.0.2 */ + char reserved[60]; /* for future use */ }; diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c index edbdab8..5f2e3bf 100644 --- a/sound/core/seq/seq_clientmgr.c +++ b/sound/core/seq/seq_clientmgr.c @@ -216,7 +216,7 @@ int __init client_init_data(void) } -static struct snd_seq_client *seq_create_client1(int client_index, int poolsize) +static struct snd_seq_client *seq_create_client1(int client_index, int poolsize, int card_number) { unsigned long flags; int c; @@ -232,6 +232,7 @@ static struct snd_seq_client *seq_create_client1(int client_index, int poolsize) return NULL; } client->type = NO_CLIENT; + client->card_number = card_number; snd_use_lock_init(&client->use_lock); rwlock_init(&client->ports_lock); mutex_init(&client->ports_mutex); @@ -327,7 +328,7 @@ static int snd_seq_open(struct inode *inode, struct file *file) if (mutex_lock_interruptible(®ister_mutex)) return -ERESTARTSYS; - client = seq_create_client1(-1, SNDRV_SEQ_DEFAULT_EVENTS); + client = seq_create_client1(-1, SNDRV_SEQ_DEFAULT_EVENTS, -1); if (client == NULL) { mutex_unlock(®ister_mutex); return -ENOMEM; /* failure code */ @@ -1194,6 +1195,7 @@ static void get_client_info(struct snd_seq_client *cptr, info->event_lost = cptr->event_lost; memcpy(info->event_filter, cptr->event_filter, 32); info->num_ports = cptr->num_ports; + info->card_number = cptr->card_number; memset(info->reserved, 0, sizeof(info->reserved)); } @@ -2239,6 +2241,7 @@ int snd_seq_create_kernel_client(struct snd_card *card, int client_index, { struct snd_seq_client *client; va_list args; + int card_number = -1; if (snd_BUG_ON(in_interrupt())) return -EBUSY; @@ -2252,6 +2255,7 @@ int snd_seq_create_kernel_client(struct snd_card *card, int client_index, return -ERESTARTSYS; if (card) { + card_number = card->number; client_index += SNDRV_SEQ_GLOBAL_CLIENTS + card->number * SNDRV_SEQ_CLIENTS_PER_CARD; if (client_index >= SNDRV_SEQ_DYNAMIC_CLIENTS_BEGIN) @@ -2259,7 +2263,7 @@ int snd_seq_create_kernel_client(struct snd_card *card, int client_index, } /* empty write queue as default */ - client = seq_create_client1(client_index, 0); + client = seq_create_client1(client_index, 0, card_number); if (client == NULL) { mutex_unlock(®ister_mutex); return -EBUSY; /* failure code */ @@ -2533,9 +2537,12 @@ void snd_seq_info_clients_read(struct snd_info_entry *entry, continue; } - snd_iprintf(buffer, "Client %3d : \"%s\" [%s]\n", + snd_iprintf(buffer, "Client %3d : \"%s\" [%s]", c, client->name, client->type == USER_CLIENT ? "User" : "Kernel"); + if (client->card_number != -1) + snd_iprintf(buffer, ", card %d", client->card_number); + snd_iprintf(buffer, "\n"); snd_seq_info_dump_ports(buffer, client); if (snd_seq_write_pool_allocated(client)) { snd_iprintf(buffer, " Output pool :\n"); diff --git a/sound/core/seq/seq_clientmgr.h b/sound/core/seq/seq_clientmgr.h index 20f0a72..627be9d 100644 --- a/sound/core/seq/seq_clientmgr.h +++ b/sound/core/seq/seq_clientmgr.h @@ -50,6 +50,7 @@ struct snd_seq_client { accept_output: 1; char name[64]; /* client name */ int number; /* client number */ + int card_number; /* card number, or -1 if no card */ unsigned int filter; /* filter flags */ DECLARE_BITMAP(event_filter, 256); snd_use_lock_t use_lock;