1 // SPDX-License-Identifier: GPL-2.0-or-later 1 2 /* 3 */ 4 5 #include <linux/init.h> 6 #include <linux/usb.h> 7 8 #include <sound/core.h> 9 #include <sound/info.h> 10 #include <sound/pcm.h> 11 12 #include "usbaudio.h" 13 #include "helper.h" 14 #include "card.h" 15 #include "endpoint.h" 16 #include "proc.h" 17 18 /* convert our full speed USB rate into sampli 19 static inline unsigned get_full_speed_hz(unsig 20 { 21 return (usb_rate * 125 + (1 << 12)) >> 22 } 23 24 /* convert our high speed USB rate into sampli 25 static inline unsigned get_high_speed_hz(unsig 26 { 27 return (usb_rate * 125 + (1 << 9)) >> 28 } 29 30 /* 31 * common proc files to show the usb device in 32 */ 33 static void proc_audio_usbbus_read(struct snd_ 34 { 35 struct snd_usb_audio *chip = entry->pr 36 if (!atomic_read(&chip->shutdown)) 37 snd_iprintf(buffer, "%03d/%03d 38 } 39 40 static void proc_audio_usbid_read(struct snd_i 41 { 42 struct snd_usb_audio *chip = entry->pr 43 if (!atomic_read(&chip->shutdown)) 44 snd_iprintf(buffer, "%04x:%04x 45 USB_ID_VENDOR(chip 46 USB_ID_PRODUCT(chi 47 } 48 49 void snd_usb_audio_create_proc(struct snd_usb_ 50 { 51 snd_card_ro_proc_new(chip->card, "usbb 52 proc_audio_usbbus 53 snd_card_ro_proc_new(chip->card, "usbi 54 proc_audio_usbid_ 55 } 56 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 89 /* 90 * proc interface for list the supported pcm f 91 */ 92 static void proc_dump_substream_formats(struct 93 { 94 struct audioformat *fp; 95 static const char * const sync_types[4 96 "NONE", "ASYNC", "ADAPTIVE", " 97 }; 98 99 list_for_each_entry(fp, &subs->fmt_lis 100 snd_pcm_format_t fmt; 101 102 snd_iprintf(buffer, " Interfa 103 snd_iprintf(buffer, " Altse 104 snd_iprintf(buffer, " Forma 105 pcm_for_each_format(fmt) 106 if (fp->formats & pcm_ 107 snd_iprintf(bu 108 sn 109 snd_iprintf(buffer, "\n"); 110 snd_iprintf(buffer, " Chann 111 snd_iprintf(buffer, " Endpo 112 fp->endpoint, 113 fp->endpoint & USB 114 fp->endpoint & USB 115 sync_types[(fp->ep 116 if (fp->rates & SNDRV_PCM_RATE 117 snd_iprintf(buffer, " 118 fp->rate_m 119 } else { 120 unsigned int i; 121 snd_iprintf(buffer, " 122 for (i = 0; i < fp->nr 123 if (i > 0) 124 snd_ip 125 snd_iprintf(bu 126 } 127 snd_iprintf(buffer, "\ 128 } 129 if (subs->speed != USB_SPEED_F 130 snd_iprintf(buffer, " 131 125 * (1 < 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 168 // snd_iprintf(buffer, " EP 169 } 170 } 171 172 static void proc_dump_ep_status(struct snd_usb 173 struct snd_usb 174 struct snd_usb 175 struct snd_inf 176 { 177 if (!data_ep) 178 return; 179 snd_iprintf(buffer, " Packet Size = 180 snd_iprintf(buffer, " Momentary fre 181 subs->speed == USB_SPEED_F 182 ? get_full_speed_hz(data_e 183 : get_high_speed_hz(data_e 184 data_ep->freqm >> 16, data 185 if (sync_ep && data_ep->freqshift != I 186 int res = 16 - data_ep->freqsh 187 snd_iprintf(buffer, " Feedb 188 (sync_ep->syncmaxs 189 } 190 } 191 192 static void proc_dump_substream_status(struct 193 struct 194 struct 195 { 196 mutex_lock(&chip->mutex); 197 if (subs->running) { 198 snd_iprintf(buffer, " Status: 199 if (subs->cur_audiofmt) { 200 snd_iprintf(buffer, " 201 snd_iprintf(buffer, " 202 } 203 proc_dump_ep_status(subs, subs 204 } else { 205 snd_iprintf(buffer, " Status: 206 } 207 mutex_unlock(&chip->mutex); 208 } 209 210 static void proc_pcm_format_read(struct snd_in 211 { 212 struct snd_usb_stream *stream = entry- 213 struct snd_usb_audio *chip = stream->c 214 215 snd_iprintf(buffer, "%s : %s\n", chip- 216 217 if (stream->substream[SNDRV_PCM_STREAM 218 snd_iprintf(buffer, "\nPlaybac 219 proc_dump_substream_status(chi 220 proc_dump_substream_formats(&s 221 } 222 if (stream->substream[SNDRV_PCM_STREAM 223 snd_iprintf(buffer, "\nCapture 224 proc_dump_substream_status(chi 225 proc_dump_substream_formats(&s 226 } 227 } 228 229 void snd_usb_proc_pcm_format_add(struct snd_us 230 { 231 char name[32]; 232 struct snd_card *card = stream->chip-> 233 234 sprintf(name, "stream%d", stream->pcm_ 235 snd_card_ro_proc_new(card, name, strea 236 } 237 238
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.