From patchwork Fri Jun 5 01:05:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Goode X-Patchwork-Id: 6550721 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 2E686C0020 for ; Fri, 5 Jun 2015 01:06:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 319A2207C0 for ; Fri, 5 Jun 2015 01:06:20 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 47CC020718 for ; Fri, 5 Jun 2015 01:06:18 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 6400E2666B7; Fri, 5 Jun 2015 03:06:17 +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=-0.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, T_DKIM_INVALID, UNPARSEABLE_RELAY, URIBL_BLACK autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 04F9B2666C5; Fri, 5 Jun 2015 03:06:03 +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 785432666BE; Fri, 5 Jun 2015 03:06:00 +0200 (CEST) Received: from mail-yh0-f43.google.com (mail-yh0-f43.google.com [209.85.213.43]) by alsa0.perex.cz (Postfix) with ESMTP id CF1592666BE for ; Fri, 5 Jun 2015 03:05:20 +0200 (CEST) Received: by yhpn97 with SMTP id n97so15074447yhp.0 for ; Thu, 04 Jun 2015 18:05:20 -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=FZEvNrsm7lmY8titqL61UaCHUs1+GHI6TN456ysKDuQ=; b=WsRw1jMpskJrp8lsntXhzuL4xSFD2POKo/3T1OZiQY0HZGdhO9j4G6jhnu9hT0rxnK C052TC27PawCI4qSrI8dIPtVSlv+MDoLi54RcGn2UI3qS+Uuk+3ZQSdNHiyRlekkbFmF EujvGsDx1FpTF47SSrj93KVvcgbmlPSF9pwi1idvVHs1IDAkw5m0pxDYXRJ6QmpEx8H8 7K97Q+wPIatDiv7ncQc2s2VSFVZMdvH1jCxf03wrhQ03cPNa68rHOl+WjjXcw4kA+gGc U+F1/H2+r+QVdwGjTzqQD+6j2PeXPJzIJoplou7idVxiBabZdy0VbmiMsv8LGGOmonbZ wHZQ== 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=FZEvNrsm7lmY8titqL61UaCHUs1+GHI6TN456ysKDuQ=; b=WW33r2Q3z4PywEp5pPjKgzMS09C64A4PowzTcr4p7sLCchAWRliAkwzal3bBKXZJE4 3mzQDRAngyAp42JemvV7uFMX+ZFh3+biGLdy5qqtd2UfjQLtnebF4P6PfH4ULlMPVDnD 2t57BemxtPME2NbgWzhoyvGp0Nbv3biSKVYvZNFx5Jpu7pwNKeCrK73eVejAg6sARCMz 0z8KFCkE5kjM7xJA08aIPff2buE1S9RqjrXIc6kO2k7T8IKN8rYXKK4yGqyy6UQ3uqDX iOc5vMt2gPvBSn/34Ris5tiwFuSCkVnCR4KzLP5TcUZ+RrcPiTDUnGvyZO78huZ/bgeh 9tEQ== X-Gm-Message-State: ALoCoQl8B3glcLulSpXbuvzM+rAyDEsvbL1da3bC+Ar/WHvoAKZcXo6j1EGTs8aoiPNQPCrQj/RP X-Received: by 10.170.190.68 with SMTP id h65mr898275yke.3.1433466320213; Thu, 04 Jun 2015 18:05:20 -0700 (PDT) Received: from wpg-ubiq154.hot.corp.google.com ([172.24.166.195]) by mx.google.com with ESMTPSA id o46sm4740237yhd.5.2015.06.04.18.05.17 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 04 Jun 2015 18:05:17 -0700 (PDT) From: Adam Goode To: patch@alsa-project.org Date: Thu, 4 Jun 2015 21:05:12 -0400 Message-Id: <1433466312-31444-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 - alsa-lib 1/1] Introduce snd_seq_client_info_get_card_number, for getting the card number of a seq client on recent kernels 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 Signed-off-by: Adam Goode diff --git a/configure.ac b/configure.ac index 9621d4e..01bb0fb 100644 --- a/configure.ac +++ b/configure.ac @@ -14,7 +14,7 @@ dnl remove API = c+1:0:0 dnl ************************************************* AC_CANONICAL_HOST AM_INIT_AUTOMAKE -eval LIBTOOL_VERSION_INFO="2:0:0" +eval LIBTOOL_VERSION_INFO="3:0:1" dnl ************************************************* AM_CONDITIONAL([INSTALL_M4], [test -n "${ACLOCAL}"]) diff --git a/include/seq.h b/include/seq.h index 9576822..e0f9b78 100644 --- a/include/seq.h +++ b/include/seq.h @@ -146,6 +146,7 @@ int snd_seq_client_info_get_error_bounce(const snd_seq_client_info_t *info); const unsigned char *snd_seq_client_info_get_event_filter(const snd_seq_client_info_t *info); int snd_seq_client_info_get_num_ports(const snd_seq_client_info_t *info); int snd_seq_client_info_get_event_lost(const snd_seq_client_info_t *info); +int snd_seq_client_info_get_card_number(const snd_seq_client_info_t *info); void snd_seq_client_info_set_client(snd_seq_client_info_t *info, int client); void snd_seq_client_info_set_name(snd_seq_client_info_t *info, const char *name); diff --git a/include/sound/asequencer.h b/include/sound/asequencer.h index 09c8a00..c2a659b 100644 --- a/include/sound/asequencer.h +++ b/include/sound/asequencer.h @@ -22,9 +22,10 @@ #ifndef _UAPI__SOUND_ASEQUENCER_H #define _UAPI__SOUND_ASEQUENCER_H +#include /** version of the sequencer */ -#define SNDRV_SEQ_VERSION SNDRV_PROTOCOL_VERSION (1, 0, 1) +#define SNDRV_SEQ_VERSION SNDRV_PROTOCOL_VERSION (1, 0, 2) /** * definition of sequencer event types @@ -356,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/src/seq/seq.c b/src/seq/seq.c index 620ca3f..bc39046 100644 --- a/src/seq/seq.c +++ b/src/seq/seq.c @@ -1651,6 +1651,18 @@ int snd_seq_client_info_get_event_lost(const snd_seq_client_info_t *info) } /** + * \brief Get the card number of a client_info container + * \param info client_info container + * \return the card number, -1 if no card associated with this client, or -ENOSYS if the + * kernel does not support reporting this field + */ +int snd_seq_client_info_get_card_number(const snd_seq_client_info_t *info) +{ + assert(info); + return info->card_number; +} + +/** * \brief Set the client id of a client_info container * \param info client_info container * \param client client id diff --git a/src/seq/seq_hw.c b/src/seq/seq_hw.c index d033367..8502d63 100644 --- a/src/seq/seq_hw.c +++ b/src/seq/seq_hw.c @@ -32,10 +32,11 @@ const char *_snd_module_seq_hw = ""; #ifndef DOC_HIDDEN #define SNDRV_FILE_SEQ ALSA_DEVICE_DIRECTORY "seq" #define SNDRV_FILE_ALOADSEQ ALOAD_DEVICE_DIRECTORY "aloadSEQ" -#define SNDRV_SEQ_VERSION_MAX SNDRV_PROTOCOL_VERSION(1, 0, 1) +#define SNDRV_SEQ_VERSION_MAX SNDRV_PROTOCOL_VERSION(1, 0, 2) typedef struct { int fd; + int version; } snd_seq_hw_t; #endif /* DOC_HIDDEN */ @@ -100,6 +101,10 @@ static int snd_seq_hw_get_client_info(snd_seq_t *seq, snd_seq_client_info_t * in /*SYSERR("SNDRV_SEQ_IOCTL_GET_CLIENT_INFO failed");*/ return -errno; } + /* The card_number field was added in protocol 1.0.2, so set to -ENOSYS if older. */ + if (hw->version < SNDRV_PROTOCOL_VERSION(1, 0, 2)) { + info->card_number = -ENOSYS; + } return 0; } @@ -368,6 +373,10 @@ static int snd_seq_hw_query_next_client(snd_seq_t *seq, snd_seq_client_info_t *i /*SYSERR("SNDRV_SEQ_IOCTL_QUERY_NEXT_CLIENT failed");*/ return -errno; } + /* The card_number field was added in protocol 1.0.2, so set to -ENOSYS if older. */ + if (hw->version < SNDRV_PROTOCOL_VERSION(1, 0, 2)) { + info->card_number = -ENOSYS; + } return 0; } @@ -480,6 +489,7 @@ int snd_seq_hw_open(snd_seq_t **handle, const char *name, int streams, int mode) return -ENOMEM; } hw->fd = fd; + hw->version = ver; if (streams & SND_SEQ_OPEN_OUTPUT) { seq->obuf = (char *) malloc(seq->obufsize = SND_SEQ_OBUF_SIZE); if (!seq->obuf) { diff --git a/test/seq.c b/test/seq.c index 34b000f..a4e5f1f 100644 --- a/test/seq.c +++ b/test/seq.c @@ -111,7 +111,7 @@ void show_port_info(snd_seq_t *handle, int client, int port) void show_client_info(snd_seq_t *handle, int client) { - int err, idx, min, max; + int err, idx, min, max, card_number; snd_seq_client_info_t *info; snd_seq_client_info_alloca(&info); @@ -124,11 +124,14 @@ void show_client_info(snd_seq_t *handle, int client) fprintf(stderr, "Client %i info error: %s\n", idx, snd_strerror(err)); exit(0); } + card_number = snd_seq_client_info_get_card_number(info); printf("Client %i info\n", idx); if (verbose) printf(" Client : %i\n", snd_seq_client_info_get_client(info)); printf(" Type : %s\n", snd_seq_client_info_get_type(info) == SND_SEQ_KERNEL_CLIENT ? "kernel" : "user"); printf(" Name : %s\n", snd_seq_client_info_get_name(info)); + if (card_number != -ENOSYS) + printf(" Card Number : %i\n", card_number); } }