ALSA: usb-audio: Expose sample resolution through proc interface
authorJussi Laako <jussi@sonarnerd.net>
Sun, 17 Feb 2019 22:17:21 +0000 (00:17 +0200)
committerTakashi Iwai <tiwai@suse.de>
Mon, 18 Feb 2019 08:36:09 +0000 (09:36 +0100)
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 <jussi@sonarnerd.net>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/usb/card.h
sound/usb/format.c
sound/usb/proc.c

index ac785d15ced4d5d5e6095f64db5c6e586f91f89f..79fa2a19fb7b7262928a6df127c5f665b3d1005d 100644 (file)
@@ -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 */
index fd13ac11b13674e1c06500f7ab3eef151b1226e2..3ee7d6f853b71c3ab57262fa553da68e5d0afd23 100644 (file)
@@ -87,6 +87,8 @@ static u64 parse_audio_format_i_type(struct snd_usb_audio *chip,
        }
        }
 
+       fp->fmt_bits = sample_width;
+
        if ((pcm_formats == 0) &&
            (format == 0 || format == (1 << UAC_FORMAT_TYPE_I_UNDEFINED))) {
                /* some devices don't define this correctly... */
index e80c9d0749c9a3832bda8912f8a890d3115b5f48..ef9190530fd208ae9c0b3c122321300eb002c174 100644 (file)
@@ -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);
        }