Lines Matching +full:data +full:- +full:shift

1 // SPDX-License-Identifier: GPL-2.0-or-later
22 * allocate a sample block and copy data from userspace
27 const void __user *data, long count) in snd_emu10k1_sample_new() argument
31 int shift; in snd_emu10k1_sample_new() local
37 emu = rec->hw; in snd_emu10k1_sample_new()
39 return -EINVAL; in snd_emu10k1_sample_new()
41 if (sp->v.mode_flags & (SNDRV_SFNT_SAMPLE_BIDIR_LOOP | SNDRV_SFNT_SAMPLE_REVERSE_LOOP)) { in snd_emu10k1_sample_new()
42 /* should instead return -ENOTSUPP; but compatibility */ in snd_emu10k1_sample_new()
43 dev_warn(emu->card->dev, in snd_emu10k1_sample_new()
45 sp->v.sample); in snd_emu10k1_sample_new()
48 if (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_8BITS) { in snd_emu10k1_sample_new()
49 shift = 0; in snd_emu10k1_sample_new()
51 xor = (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_UNSIGNED) ? 0 : 0x80808080; in snd_emu10k1_sample_new()
53 shift = 1; in snd_emu10k1_sample_new()
55 xor = (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_UNSIGNED) ? 0x80008000 : 0; in snd_emu10k1_sample_new()
58 /* compute true data size to be loaded */ in snd_emu10k1_sample_new()
59 truesize = sp->v.size + BLANK_HEAD_SIZE; in snd_emu10k1_sample_new()
60 if (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_NO_BLANK) { in snd_emu10k1_sample_new()
63 if (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_SINGLESHOT) { in snd_emu10k1_sample_new()
64 sp->v.loopstart = sp->v.end + BLANK_LOOP_START; in snd_emu10k1_sample_new()
65 sp->v.loopend = sp->v.end + BLANK_LOOP_END; in snd_emu10k1_sample_new()
69 loop_start = sp->v.loopstart; in snd_emu10k1_sample_new()
70 loop_end = sp->v.loopend; in snd_emu10k1_sample_new()
71 loop_size = loop_end - loop_start; in snd_emu10k1_sample_new()
73 return -EINVAL; in snd_emu10k1_sample_new()
74 data_end = sp->v.end; in snd_emu10k1_sample_new()
77 sp->v.start += BLANK_HEAD_SIZE; in snd_emu10k1_sample_new()
78 sp->v.end += BLANK_HEAD_SIZE; in snd_emu10k1_sample_new()
79 sp->v.loopstart += BLANK_HEAD_SIZE; in snd_emu10k1_sample_new()
80 sp->v.loopend += BLANK_HEAD_SIZE; in snd_emu10k1_sample_new()
82 // Automatic pre-filling of the cache does not work in the presence in snd_emu10k1_sample_new()
90 while (sp->v.loopend < 64) { in snd_emu10k1_sample_new()
92 sp->v.loopstart += loop_size; in snd_emu10k1_sample_new()
93 sp->v.loopend += loop_size; in snd_emu10k1_sample_new()
94 sp->v.end += loop_size; in snd_emu10k1_sample_new()
99 blocksize = truesize << shift; in snd_emu10k1_sample_new()
100 sp->block = snd_emu10k1_synth_alloc(emu, blocksize); in snd_emu10k1_sample_new()
101 if (sp->block == NULL) { in snd_emu10k1_sample_new()
102 dev_dbg(emu->card->dev, in snd_emu10k1_sample_new()
105 return -ENOSPC; in snd_emu10k1_sample_new()
108 sp->v.truesize = blocksize; in snd_emu10k1_sample_new()
112 size = BLANK_HEAD_SIZE << shift; in snd_emu10k1_sample_new()
113 snd_emu10k1_synth_memset(emu, sp->block, offset, size, fill); in snd_emu10k1_sample_new()
118 size = loop_end << shift; in snd_emu10k1_sample_new()
119 if (snd_emu10k1_synth_copy_from_user(emu, sp->block, offset, data, size, xor)) in snd_emu10k1_sample_new()
123 data += loop_start << shift; in snd_emu10k1_sample_new()
124 while (--unroll > 0) { in snd_emu10k1_sample_new()
125 size = loop_size << shift; in snd_emu10k1_sample_new()
126 if (snd_emu10k1_synth_copy_from_user(emu, sp->block, offset, data, size, xor)) in snd_emu10k1_sample_new()
131 size = (data_end - loop_start) << shift; in snd_emu10k1_sample_new()
133 size = data_end << shift; in snd_emu10k1_sample_new()
135 if (snd_emu10k1_synth_copy_from_user(emu, sp->block, offset, data, size, xor)) in snd_emu10k1_sample_new()
141 snd_emu10k1_synth_memset(emu, sp->block, offset, blocksize - offset, fill); in snd_emu10k1_sample_new()
146 snd_emu10k1_synth_free(emu, sp->block); in snd_emu10k1_sample_new()
147 sp->block = NULL; in snd_emu10k1_sample_new()
148 return -EFAULT; in snd_emu10k1_sample_new()
160 emu = rec->hw; in snd_emu10k1_sample_free()
162 return -EINVAL; in snd_emu10k1_sample_free()
164 if (sp->block) { in snd_emu10k1_sample_free()
165 snd_emu10k1_synth_free(emu, sp->block); in snd_emu10k1_sample_free()
166 sp->block = NULL; in snd_emu10k1_sample_free()