mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-11 13:30:05 -05:00
dmix: add S24_3LE support
Add to the dmix plugin support for the S24_3LE sample format which is used by 24-bit USB devices. The optimized assembler version uses only 23 bits for sample data so that the lowest bit can be used for synchronization because there is no 24-bit cmpxchg instruction.
This commit is contained in:
parent
46f81f994b
commit
45f63a8735
8 changed files with 404 additions and 7 deletions
|
|
@ -237,3 +237,105 @@ static void MIX_AREAS2(unsigned int size,
|
|||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* 24-bit version
|
||||
*/
|
||||
static void MIX_AREAS3(unsigned int size,
|
||||
volatile unsigned char *dst, unsigned char *src,
|
||||
volatile signed int *sum, size_t dst_step,
|
||||
size_t src_step, size_t sum_step)
|
||||
{
|
||||
unsigned long long old_rbx;
|
||||
|
||||
/*
|
||||
* RSI - src
|
||||
* RDI - dst
|
||||
* RBX - sum
|
||||
* ECX - old sample
|
||||
* EAX - sample / temporary
|
||||
* EDX - temporary
|
||||
*/
|
||||
__asm__ __volatile__ (
|
||||
"\n"
|
||||
|
||||
"\tmovq %%rbx, %7\n"
|
||||
/*
|
||||
* initialization, load ESI, EDI, EBX registers
|
||||
*/
|
||||
"\tmovq %1, %%rdi\n"
|
||||
"\tmovq %2, %%rsi\n"
|
||||
"\tmovq %3, %%rbx\n"
|
||||
|
||||
/*
|
||||
* while (size-- > 0) {
|
||||
*/
|
||||
"\tcmpl $0, %0\n"
|
||||
"jz 6f\n"
|
||||
|
||||
"\t.p2align 4,,15\n"
|
||||
|
||||
"1:"
|
||||
|
||||
/*
|
||||
* sample = *src;
|
||||
* sum_sample = *sum;
|
||||
* if (test_and_set_bit(0, dst) == 0)
|
||||
* sample -= sum_sample;
|
||||
* *sum += sample;
|
||||
*/
|
||||
"\tmovsbl 2(%%rsi), %%eax\n"
|
||||
"\tmovswl (%%rsi), %%ecx\n"
|
||||
"\tmovl (%%rbx), %%edx\n"
|
||||
"\tsall $16, %%eax\n"
|
||||
"\t" LOCK_PREFIX "btsl $0, (%%rdi)\n"
|
||||
"\tleal (%%ecx,%%eax,1), %%ecx\n"
|
||||
"\tjc 2f\n"
|
||||
"\tsubl %%edx, %%ecx\n"
|
||||
"2:"
|
||||
"\t" LOCK_PREFIX "addl %%ecx, (%%rbx)\n"
|
||||
|
||||
/*
|
||||
* do {
|
||||
* sample = old_sample = *sum;
|
||||
* saturate(sample);
|
||||
* *dst = sample | 1;
|
||||
* } while (old_sample != *sum);
|
||||
*/
|
||||
|
||||
"3:"
|
||||
"\tmovl (%%rbx), %%ecx\n"
|
||||
|
||||
"\tmovl $0x7fffff, %%eax\n"
|
||||
"\tmovl $-0x7fffff, %%edx\n"
|
||||
"\tcmpl %%eax, %%ecx\n"
|
||||
"\tcmovng %%ecx, %%eax\n"
|
||||
"\tcmpl %%edx, %%ecx\n"
|
||||
"\tcmovl %%edx, %%eax\n"
|
||||
|
||||
"\torl $1, %%eax\n"
|
||||
"\tmovw %%ax, (%%rdi)\n"
|
||||
"\tshrl $16, %%eax\n"
|
||||
"\tmovb %%al, 2(%%rdi)\n"
|
||||
|
||||
"\tcmpl %%ecx, (%%rbx)\n"
|
||||
"\tjnz 3b\n"
|
||||
|
||||
/*
|
||||
* while (size-- > 0)
|
||||
*/
|
||||
"\tadd %4, %%rdi\n"
|
||||
"\tadd %5, %%rsi\n"
|
||||
"\tadd %6, %%rbx\n"
|
||||
"\tdecl %0\n"
|
||||
"\tjnz 1b\n"
|
||||
|
||||
"6:"
|
||||
"\tmovq %7, %%rbx\n"
|
||||
|
||||
: /* no output regs */
|
||||
: "m" (size), "m" (dst), "m" (src),
|
||||
"m" (sum), "m" (dst_step), "m" (src_step),
|
||||
"m" (sum_step), "m" (old_rbx)
|
||||
: "rsi", "rdi", "edx", "ecx", "eax"
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue