2005-02-08 20:28:29 +00:00
|
|
|
/*
|
|
|
|
|
* optimized mixing code for i386
|
|
|
|
|
*/
|
|
|
|
|
|
2007-12-10 12:31:29 +01:00
|
|
|
#define MIX_AREAS_16 mix_areas_16
|
|
|
|
|
#define MIX_AREAS_16_MMX mix_areas_16_mmx
|
|
|
|
|
#define MIX_AREAS_32 mix_areas_32
|
|
|
|
|
#define MIX_AREAS_24 mix_areas_24
|
|
|
|
|
#define MIX_AREAS_24_CMOV mix_areas_24_cmov
|
2005-02-08 20:28:29 +00:00
|
|
|
#define LOCK_PREFIX ""
|
2008-01-10 10:01:14 +01:00
|
|
|
#define XADD "addl"
|
|
|
|
|
#define XSUB "subl"
|
2005-02-08 20:28:29 +00:00
|
|
|
#include "pcm_dmix_i386.h"
|
2007-12-10 12:31:29 +01:00
|
|
|
#undef MIX_AREAS_16
|
|
|
|
|
#undef MIX_AREAS_16_MMX
|
|
|
|
|
#undef MIX_AREAS_32
|
|
|
|
|
#undef MIX_AREAS_24
|
|
|
|
|
#undef MIX_AREAS_24_CMOV
|
2005-02-08 20:28:29 +00:00
|
|
|
#undef LOCK_PREFIX
|
2008-01-10 10:01:14 +01:00
|
|
|
#undef XADD
|
|
|
|
|
#undef XSUB
|
|
|
|
|
|
|
|
|
|
#define MIX_AREAS_16 remix_areas_16
|
|
|
|
|
#define MIX_AREAS_16_MMX remix_areas_16_mmx
|
|
|
|
|
#define MIX_AREAS_32 remix_areas_32
|
|
|
|
|
#define MIX_AREAS_24 remix_areas_24
|
|
|
|
|
#define MIX_AREAS_24_CMOV remix_areas_24_cmov
|
|
|
|
|
#define LOCK_PREFIX ""
|
|
|
|
|
#define XADD "subl"
|
|
|
|
|
#define XSUB "addl"
|
|
|
|
|
#include "pcm_dmix_i386.h"
|
|
|
|
|
#undef MIX_AREAS_16
|
|
|
|
|
#undef MIX_AREAS_16_MMX
|
|
|
|
|
#undef MIX_AREAS_32
|
|
|
|
|
#undef MIX_AREAS_24
|
|
|
|
|
#undef MIX_AREAS_24_CMOV
|
|
|
|
|
#undef LOCK_PREFIX
|
|
|
|
|
#undef XADD
|
|
|
|
|
#undef XSUB
|
2005-02-08 20:28:29 +00:00
|
|
|
|
2007-12-10 12:31:29 +01:00
|
|
|
#define MIX_AREAS_16 mix_areas_16_smp
|
|
|
|
|
#define MIX_AREAS_16_MMX mix_areas_16_smp_mmx
|
|
|
|
|
#define MIX_AREAS_32 mix_areas_32_smp
|
|
|
|
|
#define MIX_AREAS_24 mix_areas_24_smp
|
|
|
|
|
#define MIX_AREAS_24_CMOV mix_areas_24_smp_cmov
|
2005-02-08 20:28:29 +00:00
|
|
|
#define LOCK_PREFIX "lock ; "
|
2008-01-10 10:01:14 +01:00
|
|
|
#define XADD "addl"
|
|
|
|
|
#define XSUB "subl"
|
|
|
|
|
#include "pcm_dmix_i386.h"
|
|
|
|
|
#undef MIX_AREAS_16
|
|
|
|
|
#undef MIX_AREAS_16_MMX
|
|
|
|
|
#undef MIX_AREAS_32
|
|
|
|
|
#undef MIX_AREAS_24
|
|
|
|
|
#undef MIX_AREAS_24_CMOV
|
|
|
|
|
#undef LOCK_PREFIX
|
|
|
|
|
#undef XADD
|
|
|
|
|
#undef XSUB
|
|
|
|
|
|
|
|
|
|
#define MIX_AREAS_16 remix_areas_16_smp
|
|
|
|
|
#define MIX_AREAS_16_MMX remix_areas_16_smp_mmx
|
|
|
|
|
#define MIX_AREAS_32 remix_areas_32_smp
|
|
|
|
|
#define MIX_AREAS_24 remix_areas_24_smp
|
|
|
|
|
#define MIX_AREAS_24_CMOV remix_areas_24_smp_cmov
|
|
|
|
|
#define LOCK_PREFIX "lock ; "
|
|
|
|
|
#define XADD "subl"
|
|
|
|
|
#define XSUB "addl"
|
2005-02-08 20:28:29 +00:00
|
|
|
#include "pcm_dmix_i386.h"
|
2007-12-10 12:31:29 +01:00
|
|
|
#undef MIX_AREAS_16
|
|
|
|
|
#undef MIX_AREAS_16_MMX
|
|
|
|
|
#undef MIX_AREAS_32
|
|
|
|
|
#undef MIX_AREAS_24
|
|
|
|
|
#undef MIX_AREAS_24_CMOV
|
2005-02-08 20:28:29 +00:00
|
|
|
#undef LOCK_PREFIX
|
2008-01-10 10:01:14 +01:00
|
|
|
#undef XADD
|
|
|
|
|
#undef XSUB
|
2005-02-08 20:28:29 +00:00
|
|
|
|
2007-07-03 19:52:33 +02:00
|
|
|
#define i386_dmix_supported_format \
|
|
|
|
|
((1ULL << SND_PCM_FORMAT_S16_LE) |\
|
|
|
|
|
(1ULL << SND_PCM_FORMAT_S32_LE) |\
|
2010-03-02 14:01:32 +01:00
|
|
|
(1ULL << SND_PCM_FORMAT_S24_LE) |\
|
2007-07-03 19:52:33 +02:00
|
|
|
(1ULL << SND_PCM_FORMAT_S24_3LE))
|
|
|
|
|
|
|
|
|
|
#define dmix_supported_format \
|
|
|
|
|
(i386_dmix_supported_format | generic_dmix_supported_format)
|
2005-09-19 12:37:08 +00:00
|
|
|
|
2005-02-08 20:28:29 +00:00
|
|
|
static void mix_select_callbacks(snd_pcm_direct_t *dmix)
|
|
|
|
|
{
|
2007-07-03 19:52:33 +02:00
|
|
|
static int smp = 0, mmx = 0, cmov = 0;
|
|
|
|
|
|
pcm: dmix: Allow disabling x86 optimizations
The dmix plugin has some optimized implementations for x86 using the
direct memory accesses, which was rather the original version, in
addition to the "generic" implementation using the semaphore
blocking. The x86 implementation relies on the memory coherency *and*
the fast read/write on it.
For other architectures, this has been always disabled just because of
memory coherency. But, the recent LPE audio development revealed
that, even on x86 platforms, the read/write performance might become
extremely bad when the buffer is marked as uncached. Some drivers
already know the buffer is uncached, we need to switch to the generic
mode in such a case.
This patch introduces yet another flag to dmix configuration,
direct_memory_access, that indicates whether the x86-specific
optimization can be used or not. Each driver can set the flag in its
cards config namespace, and the default dmix config refers to it.
As of this patch, only HDMI LPE Audio driver sets it.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-02-10 12:16:12 +01:00
|
|
|
if (!dmix->direct_memory_access) {
|
|
|
|
|
generic_mix_select_callbacks(dmix);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2007-07-03 19:52:33 +02:00
|
|
|
if (!((1ULL<< dmix->shmptr->s.format) & i386_dmix_supported_format)) {
|
|
|
|
|
generic_mix_select_callbacks(dmix);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!smp) {
|
|
|
|
|
FILE *in;
|
|
|
|
|
char line[255];
|
2005-02-08 20:28:29 +00:00
|
|
|
|
2007-07-03 19:52:33 +02:00
|
|
|
/* try to determine the capabilities of the CPU */
|
|
|
|
|
in = fopen("/proc/cpuinfo", "r");
|
|
|
|
|
if (in) {
|
2022-06-15 08:45:19 +09:00
|
|
|
while (!feof(in) && (fgets(line, sizeof(line), in) != NULL)) {
|
2007-07-03 19:52:33 +02:00
|
|
|
if (!strncmp(line, "processor", 9))
|
|
|
|
|
smp++;
|
|
|
|
|
else if (!strncmp(line, "flags", 5)) {
|
|
|
|
|
if (strstr(line, " mmx"))
|
|
|
|
|
mmx = 1;
|
|
|
|
|
if (strstr(line, " cmov"))
|
|
|
|
|
cmov = 1;
|
|
|
|
|
}
|
2005-02-08 20:28:29 +00:00
|
|
|
}
|
2007-07-03 19:52:33 +02:00
|
|
|
fclose(in);
|
2005-02-08 20:28:29 +00:00
|
|
|
}
|
|
|
|
|
}
|
2007-07-03 19:52:33 +02:00
|
|
|
|
2005-02-08 20:28:29 +00:00
|
|
|
if (mmx) {
|
2007-12-10 12:31:29 +01:00
|
|
|
dmix->u.dmix.mix_areas_16 = smp > 1 ? mix_areas_16_smp_mmx : mix_areas_16_mmx;
|
2008-01-10 10:01:14 +01:00
|
|
|
dmix->u.dmix.remix_areas_16 = smp > 1 ? remix_areas_16_smp_mmx : remix_areas_16_mmx;
|
2005-02-08 20:28:29 +00:00
|
|
|
} else {
|
2007-12-10 12:31:29 +01:00
|
|
|
dmix->u.dmix.mix_areas_16 = smp > 1 ? mix_areas_16_smp : mix_areas_16;
|
2008-01-10 10:01:14 +01:00
|
|
|
dmix->u.dmix.remix_areas_16 = smp > 1 ? remix_areas_16_smp : remix_areas_16;
|
2005-02-08 20:28:29 +00:00
|
|
|
}
|
2007-12-10 12:31:29 +01:00
|
|
|
dmix->u.dmix.mix_areas_32 = smp > 1 ? mix_areas_32_smp : mix_areas_32;
|
2008-01-10 10:01:14 +01:00
|
|
|
dmix->u.dmix.remix_areas_32 = smp > 1 ? remix_areas_32_smp : remix_areas_32;
|
2005-12-19 07:39:03 +00:00
|
|
|
if (cmov) {
|
2007-12-10 12:31:29 +01:00
|
|
|
dmix->u.dmix.mix_areas_24 = smp > 1 ? mix_areas_24_smp_cmov : mix_areas_24_cmov;
|
2008-01-10 10:01:14 +01:00
|
|
|
dmix->u.dmix.remix_areas_24 = smp > 1 ? remix_areas_24_smp_cmov : remix_areas_24_cmov;
|
2005-12-19 07:39:03 +00:00
|
|
|
} else {
|
2007-12-10 12:31:29 +01:00
|
|
|
dmix->u.dmix.mix_areas_24 = smp > 1 ? mix_areas_24_smp: mix_areas_24;
|
2008-01-10 10:01:14 +01:00
|
|
|
dmix->u.dmix.remix_areas_24 = smp > 1 ? remix_areas_24_smp: remix_areas_24;
|
2005-12-19 07:39:03 +00:00
|
|
|
}
|
2020-06-19 18:40:46 +02:00
|
|
|
dmix->u.dmix.use_sem = 0;
|
2005-02-08 20:28:29 +00:00
|
|
|
}
|