Debian Codegraph @

src/backend/driver.h

raw symbols SCIP
1 // SPDX-License-Identifier: MPL-2.0
2 // Copyright (c) Yuxuan Shui <[email protected]>
3
4 #pragma once
5
6 #include <stddef.h>
7 #include <stdio.h>
8 #include <xcb/xcb.h>
9
10 #include "config.h"
11 #include "utils/misc.h"
12
13 struct session;
14 struct backend_base;
15
16 // A list of known driver quirks:
17 // * NVIDIA driver doesn't like seeing the same pixmap under different
18 // ids, so avoid naming the pixmap again when it didn't actually change.
19
20 /// A list of possible drivers.
21 /// The driver situation is a bit complicated. There are two drivers we care about: the
22 /// DDX, and the OpenGL driver. They are usually paired, but not always, since there is
23 /// also the generic modesetting driver.
24 /// This enum represents _both_ drivers.
25 enum driver {
26 DRIVER_AMDGPU = 1, // AMDGPU for DDX, radeonsi for OpenGL
27 DRIVER_RADEON = 2, // ATI for DDX, mesa r600 for OpenGL
28 DRIVER_FGLRX = 4,
29 DRIVER_NVIDIA = 8,
30 DRIVER_NOUVEAU = 16,
31 DRIVER_INTEL = 32,
32 DRIVER_MODESETTING = 64,
33 };
34
35 static const char *driver_names[] = {
36 "AMDGPU", "Radeon", "fglrx", "NVIDIA", "nouveau", "Intel", "modesetting",
37 };
38
39 /// Return a list of all drivers currently in use by the X server.
40 /// Note, this is a best-effort test, so no guarantee all drivers will be detected.
41 enum driver detect_driver(xcb_connection_t *, struct backend_base *, xcb_window_t);
42
43 /// Apply driver specified global workarounds. It's safe to call this multiple times.
44 void apply_driver_workarounds(struct session *ps, enum driver);
45 /// Choose a vblank scheduler based on the driver.
46 enum vblank_scheduler_type choose_vblank_scheduler(enum driver driver);
47
48 // Print driver names to stdout, for diagnostics
49 static inline void print_drivers(enum driver drivers) {
50 const char *seen_drivers[ARR_SIZE(driver_names)];
51 int driver_count = 0;
52 for (size_t i = 0; i < ARR_SIZE(driver_names); i++) {
53 if (drivers & (1UL << i)) {
54 seen_drivers[driver_count++] = driver_names[i];
55 }
56 }
57
58 if (driver_count > 0) {
59 printf("%s", seen_drivers[0]);
60 for (int i = 1; i < driver_count; i++) {
61 printf(", %s", seen_drivers[i]);
62 }
63 }
64 printf("\n");
65 }