2 * Copyright © 2000 SuSE, Inc.
3 * Copyright © 2007 Red Hat, Inc.
5 * Permission to use, copy, modify, distribute, and sell this software and its
6 * documentation for any purpose is hereby granted without fee, provided that
7 * the above copyright notice appear in all copies and that both that
8 * copyright notice and this permission notice appear in supporting
9 * documentation, and that the name of SuSE not be used in advertising or
10 * publicity pertaining to distribution of the software without specific,
11 * written prior permission. SuSE makes no representations about the
12 * suitability of this software for any purpose. It is provided "as is"
13 * without express or implied warranty.
15 * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
17 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
19 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
20 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
26 #include "pixman-private.h"
28 #if defined(USE_MIPS_DSPR2) || defined(USE_LOONGSON_MMI)
34 have_feature (const char *search_string)
36 #if defined (__linux__) /* linux ELF */
37 /* Simple detection of MIPS features at runtime for Linux.
38 * It is based on /proc/cpuinfo, which reveals hardware configuration
39 * to user-space applications. According to MIPS (early 2010), no similar
40 * facility is universally available on the MIPS architectures, so it's up
41 * to individual OSes to provide such.
43 const char *file_name = "/proc/cpuinfo";
44 char cpuinfo_line[256];
47 if ((f = fopen (file_name, "r")) == NULL)
50 while (fgets (cpuinfo_line, sizeof (cpuinfo_line), f) != NULL)
52 if (strstr (cpuinfo_line, search_string) != NULL)
62 /* Did not find string in the proc file, or not Linux ELF. */
68 pixman_implementation_t *
69 _pixman_mips_get_implementations (pixman_implementation_t *imp)
71 #ifdef USE_LOONGSON_MMI
72 /* I really don't know if some Loongson CPUs don't have MMI. */
73 if (!_pixman_disabled ("loongson-mmi") && have_feature ("Loongson"))
74 imp = _pixman_implementation_create_mmx (imp);
78 if (!_pixman_disabled ("mips-dspr2"))
80 int already_compiling_everything_for_dspr2 = 0;
81 #if defined(__mips_dsp) && (__mips_dsp_rev >= 2)
82 already_compiling_everything_for_dspr2 = 1;
84 if (already_compiling_everything_for_dspr2 ||
85 /* Only currently available MIPS core that supports DSPr2 is 74K. */
86 have_feature ("MIPS 74K"))
88 imp = _pixman_implementation_create_mips_dspr2 (imp);