diff options
Diffstat (limited to 'sound/core/pcm_misc.c')
-rw-r--r-- | sound/core/pcm_misc.c | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/sound/core/pcm_misc.c b/sound/core/pcm_misc.c index 434af3c56d52..88f02e3866e0 100644 --- a/sound/core/pcm_misc.c +++ b/sound/core/pcm_misc.c | |||
@@ -35,7 +35,10 @@ struct pcm_format_data { | |||
35 | unsigned char silence[8]; /* silence data to fill */ | 35 | unsigned char silence[8]; /* silence data to fill */ |
36 | }; | 36 | }; |
37 | 37 | ||
38 | static struct pcm_format_data pcm_formats[SNDRV_PCM_FORMAT_LAST+1] = { | 38 | /* we do lots of calculations on snd_pcm_format_t; shut up sparse */ |
39 | #define INT __force int | ||
40 | |||
41 | static struct pcm_format_data pcm_formats[(INT)SNDRV_PCM_FORMAT_LAST+1] = { | ||
39 | [SNDRV_PCM_FORMAT_S8] = { | 42 | [SNDRV_PCM_FORMAT_S8] = { |
40 | .width = 8, .phys = 8, .le = -1, .signd = 1, | 43 | .width = 8, .phys = 8, .le = -1, .signd = 1, |
41 | .silence = {}, | 44 | .silence = {}, |
@@ -215,9 +218,9 @@ static struct pcm_format_data pcm_formats[SNDRV_PCM_FORMAT_LAST+1] = { | |||
215 | int snd_pcm_format_signed(snd_pcm_format_t format) | 218 | int snd_pcm_format_signed(snd_pcm_format_t format) |
216 | { | 219 | { |
217 | int val; | 220 | int val; |
218 | if (format < 0 || format > SNDRV_PCM_FORMAT_LAST) | 221 | if ((INT)format < 0 || (INT)format > (INT)SNDRV_PCM_FORMAT_LAST) |
219 | return -EINVAL; | 222 | return -EINVAL; |
220 | if ((val = pcm_formats[format].signd) < 0) | 223 | if ((val = pcm_formats[(INT)format].signd) < 0) |
221 | return -EINVAL; | 224 | return -EINVAL; |
222 | return val; | 225 | return val; |
223 | } | 226 | } |
@@ -266,9 +269,9 @@ EXPORT_SYMBOL(snd_pcm_format_linear); | |||
266 | int snd_pcm_format_little_endian(snd_pcm_format_t format) | 269 | int snd_pcm_format_little_endian(snd_pcm_format_t format) |
267 | { | 270 | { |
268 | int val; | 271 | int val; |
269 | if (format < 0 || format > SNDRV_PCM_FORMAT_LAST) | 272 | if ((INT)format < 0 || (INT)format > (INT)SNDRV_PCM_FORMAT_LAST) |
270 | return -EINVAL; | 273 | return -EINVAL; |
271 | if ((val = pcm_formats[format].le) < 0) | 274 | if ((val = pcm_formats[(INT)format].le) < 0) |
272 | return -EINVAL; | 275 | return -EINVAL; |
273 | return val; | 276 | return val; |
274 | } | 277 | } |
@@ -304,9 +307,9 @@ EXPORT_SYMBOL(snd_pcm_format_big_endian); | |||
304 | int snd_pcm_format_width(snd_pcm_format_t format) | 307 | int snd_pcm_format_width(snd_pcm_format_t format) |
305 | { | 308 | { |
306 | int val; | 309 | int val; |
307 | if (format < 0 || format > SNDRV_PCM_FORMAT_LAST) | 310 | if ((INT)format < 0 || (INT)format > (INT)SNDRV_PCM_FORMAT_LAST) |
308 | return -EINVAL; | 311 | return -EINVAL; |
309 | if ((val = pcm_formats[format].width) == 0) | 312 | if ((val = pcm_formats[(INT)format].width) == 0) |
310 | return -EINVAL; | 313 | return -EINVAL; |
311 | return val; | 314 | return val; |
312 | } | 315 | } |
@@ -323,9 +326,9 @@ EXPORT_SYMBOL(snd_pcm_format_width); | |||
323 | int snd_pcm_format_physical_width(snd_pcm_format_t format) | 326 | int snd_pcm_format_physical_width(snd_pcm_format_t format) |
324 | { | 327 | { |
325 | int val; | 328 | int val; |
326 | if (format < 0 || format > SNDRV_PCM_FORMAT_LAST) | 329 | if ((INT)format < 0 || (INT)format > (INT)SNDRV_PCM_FORMAT_LAST) |
327 | return -EINVAL; | 330 | return -EINVAL; |
328 | if ((val = pcm_formats[format].phys) == 0) | 331 | if ((val = pcm_formats[(INT)format].phys) == 0) |
329 | return -EINVAL; | 332 | return -EINVAL; |
330 | return val; | 333 | return val; |
331 | } | 334 | } |
@@ -358,11 +361,11 @@ EXPORT_SYMBOL(snd_pcm_format_size); | |||
358 | */ | 361 | */ |
359 | const unsigned char *snd_pcm_format_silence_64(snd_pcm_format_t format) | 362 | const unsigned char *snd_pcm_format_silence_64(snd_pcm_format_t format) |
360 | { | 363 | { |
361 | if (format < 0 || format > SNDRV_PCM_FORMAT_LAST) | 364 | if ((INT)format < 0 || (INT)format > (INT)SNDRV_PCM_FORMAT_LAST) |
362 | return NULL; | 365 | return NULL; |
363 | if (! pcm_formats[format].phys) | 366 | if (! pcm_formats[(INT)format].phys) |
364 | return NULL; | 367 | return NULL; |
365 | return pcm_formats[format].silence; | 368 | return pcm_formats[(INT)format].silence; |
366 | } | 369 | } |
367 | 370 | ||
368 | EXPORT_SYMBOL(snd_pcm_format_silence_64); | 371 | EXPORT_SYMBOL(snd_pcm_format_silence_64); |
@@ -382,16 +385,16 @@ int snd_pcm_format_set_silence(snd_pcm_format_t format, void *data, unsigned int | |||
382 | int width; | 385 | int width; |
383 | unsigned char *dst, *pat; | 386 | unsigned char *dst, *pat; |
384 | 387 | ||
385 | if (format < 0 || format > SNDRV_PCM_FORMAT_LAST) | 388 | if ((INT)format < 0 || (INT)format > (INT)SNDRV_PCM_FORMAT_LAST) |
386 | return -EINVAL; | 389 | return -EINVAL; |
387 | if (samples == 0) | 390 | if (samples == 0) |
388 | return 0; | 391 | return 0; |
389 | width = pcm_formats[format].phys; /* physical width */ | 392 | width = pcm_formats[(INT)format].phys; /* physical width */ |
390 | pat = pcm_formats[format].silence; | 393 | pat = pcm_formats[(INT)format].silence; |
391 | if (! width) | 394 | if (! width) |
392 | return -EINVAL; | 395 | return -EINVAL; |
393 | /* signed or 1 byte data */ | 396 | /* signed or 1 byte data */ |
394 | if (pcm_formats[format].signd == 1 || width <= 8) { | 397 | if (pcm_formats[(INT)format].signd == 1 || width <= 8) { |
395 | unsigned int bytes = samples * width / 8; | 398 | unsigned int bytes = samples * width / 8; |
396 | memset(data, *pat, bytes); | 399 | memset(data, *pat, bytes); |
397 | return 0; | 400 | return 0; |