From patchwork Sun Feb 17 22:17:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jussi Laako X-Patchwork-Id: 10817493 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 665B81869 for ; Mon, 18 Feb 2019 09:06:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 52CA3288AE for ; Mon, 18 Feb 2019 09:06:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4752B29F7B; Mon, 18 Feb 2019 09:06: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.9 required=2.0 tests=BAYES_00,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 495F129D92 for ; Mon, 18 Feb 2019 09:06:20 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 274F2266B48; Mon, 18 Feb 2019 09:55:49 +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 12EF626706A; Mon, 18 Feb 2019 09:55:47 +0100 (CET) Received: from mail.sonarnerd.net (rankki.sonarnerd.net [194.142.149.154]) by alsa0.perex.cz (Postfix) with ESMTP id 1B036266A9D for ; Mon, 18 Feb 2019 09:55:44 +0100 (CET) Received: from porkkala.uworld (porkkala.uworld [IPv6:fc00::2]) by mail.sonarnerd.net (Postfix) with ESMTP id C2E04231114; Mon, 18 Feb 2019 00:17:42 +0200 (EET) From: Jussi Laako To: tiwai@suse.de, alsa-devel@alsa-project.org Date: Mon, 18 Feb 2019 00:17:21 +0200 Message-Id: <20190217221721.6396-1-jussi@sonarnerd.net> X-Mailer: git-send-email 2.17.1 Cc: Jussi Laako Subject: [alsa-devel] [PATCH] ALSA: usb-audio: Expose sample resolution through proc interface 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 At least some USB devices use (MSB-aligned) audio format larger than the actual resolution of the device. In order to expose the actual device resolution (bBitResolution), add extra field to the procfs stream info interface. Signed-off-by: Jussi Laako --- sound/usb/card.h | 1 + sound/usb/format.c | 2 ++ sound/usb/proc.c | 1 + 3 files changed, 4 insertions(+) diff --git a/sound/usb/card.h b/sound/usb/card.h index ac785d15ced4..d9bb2c4a3bd9 100644 --- a/sound/usb/card.h +++ b/sound/usb/card.h @@ -14,6 +14,7 @@ struct audioformat { u64 formats; /* ALSA format bits */ unsigned int channels; /* # channels */ unsigned int fmt_type; /* USB audio format type (1-3) */ + unsigned int fmt_bits; /* number of significant bits */ unsigned int frame_size; /* samples per frame for non-audio */ int iface; /* interface number */ unsigned char altsetting; /* corresponding alternate setting */ diff --git a/sound/usb/format.c b/sound/usb/format.c index fd13ac11b136..d5b7cbcc2956 100644 --- a/sound/usb/format.c +++ b/sound/usb/format.c @@ -87,6 +87,8 @@ static u64 parse_audio_format_i_type(struct snd_usb_audio *chip, } } + fp->fmt_bits = (unsigned int) sample_width; + if ((pcm_formats == 0) && (format == 0 || format == (1 << UAC_FORMAT_TYPE_I_UNDEFINED))) { /* some devices don't define this correctly... */ diff --git a/sound/usb/proc.c b/sound/usb/proc.c index e80c9d0749c9..ef9190530fd2 100644 --- a/sound/usb/proc.c +++ b/sound/usb/proc.c @@ -109,6 +109,7 @@ static void proc_dump_substream_formats(struct snd_usb_substream *subs, struct s if (subs->speed != USB_SPEED_FULL) snd_iprintf(buffer, " Data packet interval: %d us\n", 125 * (1 << fp->datainterval)); + snd_iprintf(buffer, " Bits: %d\n", fp->fmt_bits); // snd_iprintf(buffer, " Max Packet Size = %d\n", fp->maxpacksize); // snd_iprintf(buffer, " EP Attribute = %#x\n", fp->attributes); }