diff --git a/hw/xfree86/compat/log.c b/hw/xfree86/compat/log.c index 0a904f6a3..97f238071 100644 --- a/hw/xfree86/compat/log.c +++ b/hw/xfree86/compat/log.c @@ -5,6 +5,7 @@ #include "include/os.h" #undef xf86Msg +#undef xf86MsgVerb /* * this is specifically for NVidia proprietary driver: they're again lagging @@ -26,3 +27,24 @@ void xf86Msg(MessageType type, const char *format, ...) LogVMessageVerb(type, 1, format, ap); va_end(ap); } + + +/* + * this is only needed for the 570.x nvidia drivers + */ + +_X_EXPORT void xf86MsgVerb(MessageType type, int verb, const char *format, ...) + _X_ATTRIBUTE_PRINTF(3, 4); + +void +xf86MsgVerb(MessageType type, int verb, const char *format, ...) +{ + LogMessageVerb(X_WARNING, 0, "Outdated driver still using xf86MsgVerb() !\n"); + LogMessageVerb(X_WARNING, 0, "File a bug report to driver vendor or use a FOSS driver.\n"); + LogMessageVerb(X_WARNING, 0, "Proprietary drivers are inherently unstable, they just can't be done right.\n"); + + va_list ap; + va_start(ap, format); + LogVMessageVerb(type, verb, format, ap); + va_end(ap); +} diff --git a/hw/xfree86/compat/meson.build b/hw/xfree86/compat/meson.build index fab631ca2..d863ab2d8 100644 --- a/hw/xfree86/compat/meson.build +++ b/hw/xfree86/compat/meson.build @@ -1,6 +1,8 @@ srcs_xorg_compat = [ 'clientexception.c', 'log.c', + 'ones.c', + 'xf86Helper.c', ] xorg_compat = static_library('xorg_compat', diff --git a/hw/xfree86/compat/ones.c b/hw/xfree86/compat/ones.c new file mode 100644 index 000000000..7e2dce864 --- /dev/null +++ b/hw/xfree86/compat/ones.c @@ -0,0 +1,33 @@ +#include + +#include + +#undef Ones + +/* + * this is specifically for NVidia proprietary driver: they're again lagging + * behind a year, doing at least some minimal cleanup of their code base. + * All attempts to get in direct contact with them have failed. + */ + +/* + * this is only needed for the 570.x nvidia drivers + */ + +_X_EXPORT int Ones(unsigned long /*mask */ ); + +int +Ones(unsigned long mask) +{ /* HACKMEM 169 */ + /* can't add a message here because this should be fast */ +#if __has_builtin(__builtin_popcountl) + return __builtin_popcountl (mask); +#else + unsigned long y; + + y = (mask >> 1) & 033333333333; + y = mask - y - ((y >> 1) & 033333333333); + /* x & 077 == x % 077 */ + return (((y + (y >> 3)) & 030707070707) & 077); +#endif +} diff --git a/hw/xfree86/compat/xf86Helper.c b/hw/xfree86/compat/xf86Helper.c new file mode 100644 index 000000000..fd88e0e18 --- /dev/null +++ b/hw/xfree86/compat/xf86Helper.c @@ -0,0 +1,32 @@ +#include + +#include + + +#include "xf86Priv.h" +#include "xf86Bus.h" + + +/* + * this is specifically for NVidia proprietary driver: they're again lagging + * behind a year, doing at least some minimal cleanup of their code base. + * All attempts to get in direct contact with them have failed. + */ + +/* + * this is only needed for the 570.x nvidia drivers + */ + +_X_EXPORT Bool xf86IsScreenPrimary(ScrnInfoPtr pScrn); + +Bool +xf86IsScreenPrimary(ScrnInfoPtr pScrn) +{ + int i; + + for (i = 0; i < pScrn->numEntities; i++) { + if (xf86IsEntityPrimary(i)) + return TRUE; + } + return FALSE; +}