~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/sound/usb/proc.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /sound/usb/proc.c (Version linux-6.12-rc7) and /sound/usb/proc.c (Version linux-4.9.337)


  1 // SPDX-License-Identifier: GPL-2.0-or-later   << 
  2 /*                                                  1 /*
                                                   >>   2  *   This program is free software; you can redistribute it and/or modify
                                                   >>   3  *   it under the terms of the GNU General Public License as published by
                                                   >>   4  *   the Free Software Foundation; either version 2 of the License, or
                                                   >>   5  *   (at your option) any later version.
                                                   >>   6  *
                                                   >>   7  *   This program is distributed in the hope that it will be useful,
                                                   >>   8  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
                                                   >>   9  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                                                   >>  10  *   GNU General Public License for more details.
                                                   >>  11  *
                                                   >>  12  *   You should have received a copy of the GNU General Public License
                                                   >>  13  *   along with this program; if not, write to the Free Software
                                                   >>  14  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
                                                   >>  15  *
  3  */                                                16  */
  4                                                    17 
  5 #include <linux/init.h>                            18 #include <linux/init.h>
  6 #include <linux/usb.h>                             19 #include <linux/usb.h>
  7                                                    20 
  8 #include <sound/core.h>                            21 #include <sound/core.h>
  9 #include <sound/info.h>                            22 #include <sound/info.h>
 10 #include <sound/pcm.h>                             23 #include <sound/pcm.h>
 11                                                    24 
 12 #include "usbaudio.h"                              25 #include "usbaudio.h"
 13 #include "helper.h"                                26 #include "helper.h"
 14 #include "card.h"                                  27 #include "card.h"
 15 #include "endpoint.h"                              28 #include "endpoint.h"
 16 #include "proc.h"                                  29 #include "proc.h"
 17                                                    30 
 18 /* convert our full speed USB rate into sampli     31 /* convert our full speed USB rate into sampling rate in Hz */
 19 static inline unsigned get_full_speed_hz(unsig     32 static inline unsigned get_full_speed_hz(unsigned int usb_rate)
 20 {                                                  33 {
 21         return (usb_rate * 125 + (1 << 12)) >>     34         return (usb_rate * 125 + (1 << 12)) >> 13;
 22 }                                                  35 }
 23                                                    36 
 24 /* convert our high speed USB rate into sampli     37 /* convert our high speed USB rate into sampling rate in Hz */
 25 static inline unsigned get_high_speed_hz(unsig     38 static inline unsigned get_high_speed_hz(unsigned int usb_rate)
 26 {                                                  39 {
 27         return (usb_rate * 125 + (1 << 9)) >>      40         return (usb_rate * 125 + (1 << 9)) >> 10;
 28 }                                                  41 }
 29                                                    42 
 30 /*                                                 43 /*
 31  * common proc files to show the usb device in     44  * common proc files to show the usb device info
 32  */                                                45  */
 33 static void proc_audio_usbbus_read(struct snd_     46 static void proc_audio_usbbus_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer)
 34 {                                                  47 {
 35         struct snd_usb_audio *chip = entry->pr     48         struct snd_usb_audio *chip = entry->private_data;
 36         if (!atomic_read(&chip->shutdown))         49         if (!atomic_read(&chip->shutdown))
 37                 snd_iprintf(buffer, "%03d/%03d     50                 snd_iprintf(buffer, "%03d/%03d\n", chip->dev->bus->busnum, chip->dev->devnum);
 38 }                                                  51 }
 39                                                    52 
 40 static void proc_audio_usbid_read(struct snd_i     53 static void proc_audio_usbid_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer)
 41 {                                                  54 {
 42         struct snd_usb_audio *chip = entry->pr     55         struct snd_usb_audio *chip = entry->private_data;
 43         if (!atomic_read(&chip->shutdown))         56         if (!atomic_read(&chip->shutdown))
 44                 snd_iprintf(buffer, "%04x:%04x     57                 snd_iprintf(buffer, "%04x:%04x\n", 
 45                             USB_ID_VENDOR(chip     58                             USB_ID_VENDOR(chip->usb_id),
 46                             USB_ID_PRODUCT(chi     59                             USB_ID_PRODUCT(chip->usb_id));
 47 }                                                  60 }
 48                                                    61 
 49 void snd_usb_audio_create_proc(struct snd_usb_     62 void snd_usb_audio_create_proc(struct snd_usb_audio *chip)
 50 {                                                  63 {
 51         snd_card_ro_proc_new(chip->card, "usbb !!  64         struct snd_info_entry *entry;
 52                              proc_audio_usbbus !!  65         if (!snd_card_proc_new(chip->card, "usbbus", &entry))
 53         snd_card_ro_proc_new(chip->card, "usbi !!  66                 snd_info_set_text_ops(entry, chip, proc_audio_usbbus_read);
 54                              proc_audio_usbid_ !!  67         if (!snd_card_proc_new(chip->card, "usbid", &entry))
 55 }                                              !!  68                 snd_info_set_text_ops(entry, chip, proc_audio_usbid_read);
 56                                                !!  69 }
 57 static const char * const channel_labels[] = { << 
 58         [SNDRV_CHMAP_NA]        = "N/A",       << 
 59         [SNDRV_CHMAP_MONO]      = "MONO",      << 
 60         [SNDRV_CHMAP_FL]        = "FL",        << 
 61         [SNDRV_CHMAP_FR]        = "FR",        << 
 62         [SNDRV_CHMAP_FC]        = "FC",        << 
 63         [SNDRV_CHMAP_LFE]       = "LFE",       << 
 64         [SNDRV_CHMAP_RL]        = "RL",        << 
 65         [SNDRV_CHMAP_RR]        = "RR",        << 
 66         [SNDRV_CHMAP_FLC]       = "FLC",       << 
 67         [SNDRV_CHMAP_FRC]       = "FRC",       << 
 68         [SNDRV_CHMAP_RC]        = "RC",        << 
 69         [SNDRV_CHMAP_SL]        = "SL",        << 
 70         [SNDRV_CHMAP_SR]        = "SR",        << 
 71         [SNDRV_CHMAP_TC]        = "TC",        << 
 72         [SNDRV_CHMAP_TFL]       = "TFL",       << 
 73         [SNDRV_CHMAP_TFC]       = "TFC",       << 
 74         [SNDRV_CHMAP_TFR]       = "TFR",       << 
 75         [SNDRV_CHMAP_TRL]       = "TRL",       << 
 76         [SNDRV_CHMAP_TRC]       = "TRC",       << 
 77         [SNDRV_CHMAP_TRR]       = "TRR",       << 
 78         [SNDRV_CHMAP_TFLC]      = "TFLC",      << 
 79         [SNDRV_CHMAP_TFRC]      = "TFRC",      << 
 80         [SNDRV_CHMAP_LLFE]      = "LLFE",      << 
 81         [SNDRV_CHMAP_RLFE]      = "RLFE",      << 
 82         [SNDRV_CHMAP_TSL]       = "TSL",       << 
 83         [SNDRV_CHMAP_TSR]       = "TSR",       << 
 84         [SNDRV_CHMAP_BC]        = "BC",        << 
 85         [SNDRV_CHMAP_RLC]       = "RLC",       << 
 86         [SNDRV_CHMAP_RRC]       = "RRC",       << 
 87 };                                             << 
 88                                                    70 
 89 /*                                                 71 /*
 90  * proc interface for list the supported pcm f     72  * proc interface for list the supported pcm formats
 91  */                                                73  */
 92 static void proc_dump_substream_formats(struct     74 static void proc_dump_substream_formats(struct snd_usb_substream *subs, struct snd_info_buffer *buffer)
 93 {                                                  75 {
 94         struct audioformat *fp;                    76         struct audioformat *fp;
 95         static const char * const sync_types[4 !!  77         static char *sync_types[4] = {
 96                 "NONE", "ASYNC", "ADAPTIVE", "     78                 "NONE", "ASYNC", "ADAPTIVE", "SYNC"
 97         };                                         79         };
 98                                                    80 
 99         list_for_each_entry(fp, &subs->fmt_lis     81         list_for_each_entry(fp, &subs->fmt_list, list) {
100                 snd_pcm_format_t fmt;              82                 snd_pcm_format_t fmt;
101                                                    83 
102                 snd_iprintf(buffer, "  Interfa     84                 snd_iprintf(buffer, "  Interface %d\n", fp->iface);
103                 snd_iprintf(buffer, "    Altse     85                 snd_iprintf(buffer, "    Altset %d\n", fp->altsetting);
104                 snd_iprintf(buffer, "    Forma     86                 snd_iprintf(buffer, "    Format:");
105                 pcm_for_each_format(fmt)       !!  87                 for (fmt = 0; fmt <= SNDRV_PCM_FORMAT_LAST; ++fmt)
106                         if (fp->formats & pcm_     88                         if (fp->formats & pcm_format_to_bits(fmt))
107                                 snd_iprintf(bu     89                                 snd_iprintf(buffer, " %s",
108                                             sn     90                                             snd_pcm_format_name(fmt));
109                 snd_iprintf(buffer, "\n");         91                 snd_iprintf(buffer, "\n");
110                 snd_iprintf(buffer, "    Chann     92                 snd_iprintf(buffer, "    Channels: %d\n", fp->channels);
111                 snd_iprintf(buffer, "    Endpo !!  93                 snd_iprintf(buffer, "    Endpoint: %d %s (%s)\n",
112                             fp->endpoint,      << 
113                             fp->endpoint & USB     94                             fp->endpoint & USB_ENDPOINT_NUMBER_MASK,
114                             fp->endpoint & USB     95                             fp->endpoint & USB_DIR_IN ? "IN" : "OUT",
115                             sync_types[(fp->ep     96                             sync_types[(fp->ep_attr & USB_ENDPOINT_SYNCTYPE) >> 2]);
116                 if (fp->rates & SNDRV_PCM_RATE     97                 if (fp->rates & SNDRV_PCM_RATE_CONTINUOUS) {
117                         snd_iprintf(buffer, "      98                         snd_iprintf(buffer, "    Rates: %d - %d (continuous)\n",
118                                     fp->rate_m     99                                     fp->rate_min, fp->rate_max);
119                 } else {                          100                 } else {
120                         unsigned int i;           101                         unsigned int i;
121                         snd_iprintf(buffer, "     102                         snd_iprintf(buffer, "    Rates: ");
122                         for (i = 0; i < fp->nr    103                         for (i = 0; i < fp->nr_rates; i++) {
123                                 if (i > 0)        104                                 if (i > 0)
124                                         snd_ip    105                                         snd_iprintf(buffer, ", ");
125                                 snd_iprintf(bu    106                                 snd_iprintf(buffer, "%d", fp->rate_table[i]);
126                         }                         107                         }
127                         snd_iprintf(buffer, "\    108                         snd_iprintf(buffer, "\n");
128                 }                                 109                 }
129                 if (subs->speed != USB_SPEED_F    110                 if (subs->speed != USB_SPEED_FULL)
130                         snd_iprintf(buffer, "     111                         snd_iprintf(buffer, "    Data packet interval: %d us\n",
131                                     125 * (1 <    112                                     125 * (1 << fp->datainterval));
132                 snd_iprintf(buffer, "    Bits: << 
133                                                << 
134                 if (fp->dsd_raw)               << 
135                         snd_iprintf(buffer, "  << 
136                                     fp->dsd_do << 
137                                                << 
138                 if (fp->chmap) {               << 
139                         const struct snd_pcm_c << 
140                         int c;                 << 
141                                                << 
142                         snd_iprintf(buffer, "  << 
143                         for (c = 0; c < map->c << 
144                                 if (map->map[c << 
145                                     !channel_l << 
146                                         snd_ip << 
147                                 else           << 
148                                         snd_ip << 
149                                                << 
150                         }                      << 
151                         snd_iprintf(buffer, "\ << 
152                 }                              << 
153                                                << 
154                 if (fp->sync_ep) {             << 
155                         snd_iprintf(buffer, "  << 
156                                     fp->sync_e << 
157                                     fp->sync_e << 
158                                     fp->sync_e << 
159                         snd_iprintf(buffer, "  << 
160                                     fp->sync_i << 
161                         snd_iprintf(buffer, "  << 
162                                     fp->sync_a << 
163                         snd_iprintf(buffer, "  << 
164                                     fp->implic << 
165                 }                              << 
166                                                << 
167                 // snd_iprintf(buffer, "    Ma    113                 // snd_iprintf(buffer, "    Max Packet Size = %d\n", fp->maxpacksize);
168                 // snd_iprintf(buffer, "    EP    114                 // snd_iprintf(buffer, "    EP Attribute = %#x\n", fp->attributes);
169         }                                         115         }
170 }                                                 116 }
171                                                   117 
172 static void proc_dump_ep_status(struct snd_usb    118 static void proc_dump_ep_status(struct snd_usb_substream *subs,
173                                 struct snd_usb    119                                 struct snd_usb_endpoint *data_ep,
174                                 struct snd_usb    120                                 struct snd_usb_endpoint *sync_ep,
175                                 struct snd_inf    121                                 struct snd_info_buffer *buffer)
176 {                                                 122 {
177         if (!data_ep)                             123         if (!data_ep)
178                 return;                           124                 return;
179         snd_iprintf(buffer, "    Packet Size =    125         snd_iprintf(buffer, "    Packet Size = %d\n", data_ep->curpacksize);
180         snd_iprintf(buffer, "    Momentary fre    126         snd_iprintf(buffer, "    Momentary freq = %u Hz (%#x.%04x)\n",
181                     subs->speed == USB_SPEED_F    127                     subs->speed == USB_SPEED_FULL
182                     ? get_full_speed_hz(data_e    128                     ? get_full_speed_hz(data_ep->freqm)
183                     : get_high_speed_hz(data_e    129                     : get_high_speed_hz(data_ep->freqm),
184                     data_ep->freqm >> 16, data    130                     data_ep->freqm >> 16, data_ep->freqm & 0xffff);
185         if (sync_ep && data_ep->freqshift != I    131         if (sync_ep && data_ep->freqshift != INT_MIN) {
186                 int res = 16 - data_ep->freqsh    132                 int res = 16 - data_ep->freqshift;
187                 snd_iprintf(buffer, "    Feedb    133                 snd_iprintf(buffer, "    Feedback Format = %d.%d\n",
188                             (sync_ep->syncmaxs    134                             (sync_ep->syncmaxsize > 3 ? 32 : 24) - res, res);
189         }                                         135         }
190 }                                                 136 }
191                                                   137 
192 static void proc_dump_substream_status(struct  !! 138 static void proc_dump_substream_status(struct snd_usb_substream *subs, struct snd_info_buffer *buffer)
193                                        struct  << 
194                                        struct  << 
195 {                                                 139 {
196         mutex_lock(&chip->mutex);              << 
197         if (subs->running) {                      140         if (subs->running) {
198                 snd_iprintf(buffer, "  Status:    141                 snd_iprintf(buffer, "  Status: Running\n");
199                 if (subs->cur_audiofmt) {      !! 142                 snd_iprintf(buffer, "    Interface = %d\n", subs->interface);
200                         snd_iprintf(buffer, "  !! 143                 snd_iprintf(buffer, "    Altset = %d\n", subs->altset_idx);
201                         snd_iprintf(buffer, "  << 
202                 }                              << 
203                 proc_dump_ep_status(subs, subs    144                 proc_dump_ep_status(subs, subs->data_endpoint, subs->sync_endpoint, buffer);
204         } else {                                  145         } else {
205                 snd_iprintf(buffer, "  Status:    146                 snd_iprintf(buffer, "  Status: Stop\n");
206         }                                         147         }
207         mutex_unlock(&chip->mutex);            << 
208 }                                                 148 }
209                                                   149 
210 static void proc_pcm_format_read(struct snd_in    150 static void proc_pcm_format_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer)
211 {                                                 151 {
212         struct snd_usb_stream *stream = entry-    152         struct snd_usb_stream *stream = entry->private_data;
213         struct snd_usb_audio *chip = stream->c << 
214                                                   153 
215         snd_iprintf(buffer, "%s : %s\n", chip- !! 154         snd_iprintf(buffer, "%s : %s\n", stream->chip->card->longname, stream->pcm->name);
216                                                   155 
217         if (stream->substream[SNDRV_PCM_STREAM    156         if (stream->substream[SNDRV_PCM_STREAM_PLAYBACK].num_formats) {
218                 snd_iprintf(buffer, "\nPlaybac    157                 snd_iprintf(buffer, "\nPlayback:\n");
219                 proc_dump_substream_status(chi !! 158                 proc_dump_substream_status(&stream->substream[SNDRV_PCM_STREAM_PLAYBACK], buffer);
220                 proc_dump_substream_formats(&s    159                 proc_dump_substream_formats(&stream->substream[SNDRV_PCM_STREAM_PLAYBACK], buffer);
221         }                                         160         }
222         if (stream->substream[SNDRV_PCM_STREAM    161         if (stream->substream[SNDRV_PCM_STREAM_CAPTURE].num_formats) {
223                 snd_iprintf(buffer, "\nCapture    162                 snd_iprintf(buffer, "\nCapture:\n");
224                 proc_dump_substream_status(chi !! 163                 proc_dump_substream_status(&stream->substream[SNDRV_PCM_STREAM_CAPTURE], buffer);
225                 proc_dump_substream_formats(&s    164                 proc_dump_substream_formats(&stream->substream[SNDRV_PCM_STREAM_CAPTURE], buffer);
226         }                                         165         }
227 }                                                 166 }
228                                                   167 
229 void snd_usb_proc_pcm_format_add(struct snd_us    168 void snd_usb_proc_pcm_format_add(struct snd_usb_stream *stream)
230 {                                                 169 {
                                                   >> 170         struct snd_info_entry *entry;
231         char name[32];                            171         char name[32];
232         struct snd_card *card = stream->chip->    172         struct snd_card *card = stream->chip->card;
233                                                   173 
234         sprintf(name, "stream%d", stream->pcm_    174         sprintf(name, "stream%d", stream->pcm_index);
235         snd_card_ro_proc_new(card, name, strea !! 175         if (!snd_card_proc_new(card, name, &entry))
                                                   >> 176                 snd_info_set_text_ops(entry, stream, proc_pcm_format_read);
236 }                                                 177 }
237                                                   178 
238                                                   179 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php