diff options
Diffstat (limited to 'sound/isa/sb/sb16_csp.c')
| -rw-r--r-- | sound/isa/sb/sb16_csp.c | 44 |
1 files changed, 21 insertions, 23 deletions
diff --git a/sound/isa/sb/sb16_csp.c b/sound/isa/sb/sb16_csp.c index b62920eead3d..d64790bcd831 100644 --- a/sound/isa/sb/sb16_csp.c +++ b/sound/isa/sb/sb16_csp.c | |||
| @@ -42,8 +42,6 @@ MODULE_LICENSE("GPL"); | |||
| 42 | #else | 42 | #else |
| 43 | #define CSP_HDR_VALUE(a,b,c,d) ((d) | ((c)<<8) | ((b)<<16) | ((a)<<24)) | 43 | #define CSP_HDR_VALUE(a,b,c,d) ((d) | ((c)<<8) | ((b)<<16) | ((a)<<24)) |
| 44 | #endif | 44 | #endif |
| 45 | #define LE_SHORT(v) le16_to_cpu(v) | ||
| 46 | #define LE_INT(v) le32_to_cpu(v) | ||
| 47 | 45 | ||
| 48 | #define RIFF_HEADER CSP_HDR_VALUE('R', 'I', 'F', 'F') | 46 | #define RIFF_HEADER CSP_HDR_VALUE('R', 'I', 'F', 'F') |
| 49 | #define CSP__HEADER CSP_HDR_VALUE('C', 'S', 'P', ' ') | 47 | #define CSP__HEADER CSP_HDR_VALUE('C', 'S', 'P', ' ') |
| @@ -56,20 +54,20 @@ MODULE_LICENSE("GPL"); | |||
| 56 | /* | 54 | /* |
| 57 | * RIFF data format | 55 | * RIFF data format |
| 58 | */ | 56 | */ |
| 59 | typedef struct riff_header { | 57 | struct riff_header { |
| 60 | __u32 name; | 58 | __u32 name; |
| 61 | __u32 len; | 59 | __u32 len; |
| 62 | } riff_header_t; | 60 | }; |
| 63 | 61 | ||
| 64 | typedef struct desc_header { | 62 | struct desc_header { |
| 65 | riff_header_t info; | 63 | struct riff_header info; |
| 66 | __u16 func_nr; | 64 | __u16 func_nr; |
| 67 | __u16 VOC_type; | 65 | __u16 VOC_type; |
| 68 | __u16 flags_play_rec; | 66 | __u16 flags_play_rec; |
| 69 | __u16 flags_16bit_8bit; | 67 | __u16 flags_16bit_8bit; |
| 70 | __u16 flags_stereo_mono; | 68 | __u16 flags_stereo_mono; |
| 71 | __u16 flags_rates; | 69 | __u16 flags_rates; |
| 72 | } desc_header_t; | 70 | }; |
| 73 | 71 | ||
| 74 | /* | 72 | /* |
| 75 | * prototypes | 73 | * prototypes |
| @@ -302,9 +300,9 @@ static int snd_sb_csp_riff_load(snd_sb_csp_t * p, snd_sb_csp_microcode_t __user | |||
| 302 | unsigned char __user *data_end; | 300 | unsigned char __user *data_end; |
| 303 | unsigned short func_nr = 0; | 301 | unsigned short func_nr = 0; |
| 304 | 302 | ||
| 305 | riff_header_t file_h, item_h, code_h; | 303 | struct riff_header file_h, item_h, code_h; |
| 306 | __u32 item_type; | 304 | __u32 item_type; |
| 307 | desc_header_t funcdesc_h; | 305 | struct desc_header funcdesc_h; |
| 308 | 306 | ||
| 309 | unsigned long flags; | 307 | unsigned long flags; |
| 310 | int err; | 308 | int err; |
| @@ -316,12 +314,12 @@ static int snd_sb_csp_riff_load(snd_sb_csp_t * p, snd_sb_csp_microcode_t __user | |||
| 316 | if (copy_from_user(&file_h, data_ptr, sizeof(file_h))) | 314 | if (copy_from_user(&file_h, data_ptr, sizeof(file_h))) |
| 317 | return -EFAULT; | 315 | return -EFAULT; |
| 318 | if ((file_h.name != RIFF_HEADER) || | 316 | if ((file_h.name != RIFF_HEADER) || |
| 319 | (LE_INT(file_h.len) >= SNDRV_SB_CSP_MAX_MICROCODE_FILE_SIZE - sizeof(file_h))) { | 317 | (le32_to_cpu(file_h.len) >= SNDRV_SB_CSP_MAX_MICROCODE_FILE_SIZE - sizeof(file_h))) { |
| 320 | snd_printd("%s: Invalid RIFF header\n", __FUNCTION__); | 318 | snd_printd("%s: Invalid RIFF header\n", __FUNCTION__); |
| 321 | return -EINVAL; | 319 | return -EINVAL; |
| 322 | } | 320 | } |
| 323 | data_ptr += sizeof(file_h); | 321 | data_ptr += sizeof(file_h); |
| 324 | data_end = data_ptr + LE_INT(file_h.len); | 322 | data_end = data_ptr + le32_to_cpu(file_h.len); |
| 325 | 323 | ||
| 326 | if (copy_from_user(&item_type, data_ptr, sizeof(item_type))) | 324 | if (copy_from_user(&item_type, data_ptr, sizeof(item_type))) |
| 327 | return -EFAULT; | 325 | return -EFAULT; |
| @@ -331,7 +329,7 @@ static int snd_sb_csp_riff_load(snd_sb_csp_t * p, snd_sb_csp_microcode_t __user | |||
| 331 | } | 329 | } |
| 332 | data_ptr += sizeof (item_type); | 330 | data_ptr += sizeof (item_type); |
| 333 | 331 | ||
| 334 | for (; data_ptr < data_end; data_ptr += LE_INT(item_h.len)) { | 332 | for (; data_ptr < data_end; data_ptr += le32_to_cpu(item_h.len)) { |
| 335 | if (copy_from_user(&item_h, data_ptr, sizeof(item_h))) | 333 | if (copy_from_user(&item_h, data_ptr, sizeof(item_h))) |
| 336 | return -EFAULT; | 334 | return -EFAULT; |
| 337 | data_ptr += sizeof(item_h); | 335 | data_ptr += sizeof(item_h); |
| @@ -344,7 +342,7 @@ static int snd_sb_csp_riff_load(snd_sb_csp_t * p, snd_sb_csp_microcode_t __user | |||
| 344 | case FUNC_HEADER: | 342 | case FUNC_HEADER: |
| 345 | if (copy_from_user(&funcdesc_h, data_ptr + sizeof(item_type), sizeof(funcdesc_h))) | 343 | if (copy_from_user(&funcdesc_h, data_ptr + sizeof(item_type), sizeof(funcdesc_h))) |
| 346 | return -EFAULT; | 344 | return -EFAULT; |
| 347 | func_nr = LE_SHORT(funcdesc_h.func_nr); | 345 | func_nr = le16_to_cpu(funcdesc_h.func_nr); |
| 348 | break; | 346 | break; |
| 349 | case CODE_HEADER: | 347 | case CODE_HEADER: |
| 350 | if (func_nr != info.func_req) | 348 | if (func_nr != info.func_req) |
| @@ -370,11 +368,11 @@ static int snd_sb_csp_riff_load(snd_sb_csp_t * p, snd_sb_csp_microcode_t __user | |||
| 370 | if (code_h.name != INIT_HEADER) | 368 | if (code_h.name != INIT_HEADER) |
| 371 | break; | 369 | break; |
| 372 | data_ptr += sizeof(code_h); | 370 | data_ptr += sizeof(code_h); |
| 373 | err = snd_sb_csp_load_user(p, data_ptr, LE_INT(code_h.len), | 371 | err = snd_sb_csp_load_user(p, data_ptr, le32_to_cpu(code_h.len), |
| 374 | SNDRV_SB_CSP_LOAD_INITBLOCK); | 372 | SNDRV_SB_CSP_LOAD_INITBLOCK); |
| 375 | if (err) | 373 | if (err) |
| 376 | return err; | 374 | return err; |
| 377 | data_ptr += LE_INT(code_h.len); | 375 | data_ptr += le32_to_cpu(code_h.len); |
| 378 | } | 376 | } |
| 379 | /* main microcode block */ | 377 | /* main microcode block */ |
| 380 | if (copy_from_user(&code_h, data_ptr, sizeof(code_h))) | 378 | if (copy_from_user(&code_h, data_ptr, sizeof(code_h))) |
| @@ -386,17 +384,17 @@ static int snd_sb_csp_riff_load(snd_sb_csp_t * p, snd_sb_csp_microcode_t __user | |||
| 386 | } | 384 | } |
| 387 | data_ptr += sizeof(code_h); | 385 | data_ptr += sizeof(code_h); |
| 388 | err = snd_sb_csp_load_user(p, data_ptr, | 386 | err = snd_sb_csp_load_user(p, data_ptr, |
| 389 | LE_INT(code_h.len), 0); | 387 | le32_to_cpu(code_h.len), 0); |
| 390 | if (err) | 388 | if (err) |
| 391 | return err; | 389 | return err; |
| 392 | 390 | ||
| 393 | /* fill in codec header */ | 391 | /* fill in codec header */ |
| 394 | strlcpy(p->codec_name, info.codec_name, sizeof(p->codec_name)); | 392 | strlcpy(p->codec_name, info.codec_name, sizeof(p->codec_name)); |
| 395 | p->func_nr = func_nr; | 393 | p->func_nr = func_nr; |
| 396 | p->mode = LE_SHORT(funcdesc_h.flags_play_rec); | 394 | p->mode = le16_to_cpu(funcdesc_h.flags_play_rec); |
| 397 | switch (LE_SHORT(funcdesc_h.VOC_type)) { | 395 | switch (le16_to_cpu(funcdesc_h.VOC_type)) { |
| 398 | case 0x0001: /* QSound decoder */ | 396 | case 0x0001: /* QSound decoder */ |
| 399 | if (LE_SHORT(funcdesc_h.flags_play_rec) == SNDRV_SB_CSP_MODE_DSP_WRITE) { | 397 | if (le16_to_cpu(funcdesc_h.flags_play_rec) == SNDRV_SB_CSP_MODE_DSP_WRITE) { |
| 400 | if (snd_sb_qsound_build(p) == 0) | 398 | if (snd_sb_qsound_build(p) == 0) |
| 401 | /* set QSound flag and clear all other mode flags */ | 399 | /* set QSound flag and clear all other mode flags */ |
| 402 | p->mode = SNDRV_SB_CSP_MODE_QSOUND; | 400 | p->mode = SNDRV_SB_CSP_MODE_QSOUND; |
| @@ -426,12 +424,12 @@ static int snd_sb_csp_riff_load(snd_sb_csp_t * p, snd_sb_csp_microcode_t __user | |||
| 426 | p->mode = 0; | 424 | p->mode = 0; |
| 427 | snd_printd("%s: Unsupported CSP codec type: 0x%04x\n", | 425 | snd_printd("%s: Unsupported CSP codec type: 0x%04x\n", |
| 428 | __FUNCTION__, | 426 | __FUNCTION__, |
| 429 | LE_SHORT(funcdesc_h.VOC_type)); | 427 | le16_to_cpu(funcdesc_h.VOC_type)); |
| 430 | return -EINVAL; | 428 | return -EINVAL; |
| 431 | } | 429 | } |
| 432 | p->acc_channels = LE_SHORT(funcdesc_h.flags_stereo_mono); | 430 | p->acc_channels = le16_to_cpu(funcdesc_h.flags_stereo_mono); |
| 433 | p->acc_width = LE_SHORT(funcdesc_h.flags_16bit_8bit); | 431 | p->acc_width = le16_to_cpu(funcdesc_h.flags_16bit_8bit); |
| 434 | p->acc_rates = LE_SHORT(funcdesc_h.flags_rates); | 432 | p->acc_rates = le16_to_cpu(funcdesc_h.flags_rates); |
| 435 | 433 | ||
| 436 | /* Decouple CSP from IRQ and DMAREQ lines */ | 434 | /* Decouple CSP from IRQ and DMAREQ lines */ |
| 437 | spin_lock_irqsave(&p->chip->reg_lock, flags); | 435 | spin_lock_irqsave(&p->chip->reg_lock, flags); |
