Debian Codegraph @

src/drivers/lenovo/hybrid_graphics/hybrid_graphics.c

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 #include <console/console.h>
4 #include <device/device.h>
5 #include <gpio.h>
6 #include <option.h>
7 #include "chip.h"
8
9 /*
10 * Switch panel mux or backlight mux to active GPU.
11 * In case both GPUs are active switch panel mux to integrated.
12 */
13 static void lenovo_hybrid_graphics_enable(struct device *dev)
14 {
15 const struct drivers_lenovo_hybrid_graphics_config *config;
16 enum hybrid_graphics_req mode;
17
18 /* Don't confuse anyone else and disable the fake device */
19 dev->enabled = 0;
20
21 config = dev->chip_info;
22 if (!config || (gpio_get(config->detect_gpio) == DGPU_NOT_INSTALLED)) {
23 printk(BIOS_DEBUG, "Hybrid graphics: Not installed\n");
24 return;
25 }
26
27 mode = get_uint_option("hybrid_graphics_mode", HYBRID_GRAPHICS_DEFAULT_GPU);
28
29 if (mode == HYBRID_GRAPHICS_DISCRETE) {
30 printk(BIOS_DEBUG, "Hybrid graphics:"
31 " Switching panel to discrete GPU.\n");
32
33 if (config->has_panel_hybrid_gpio)
34 gpio_set(config->panel_hybrid_gpio,
35 !config->panel_integrated_lvl);
36
37 if (config->has_backlight_gpio)
38 gpio_set(config->backlight_gpio,
39 !config->backlight_integrated_lvl);
40 } else {
41 printk(BIOS_DEBUG, "Hybrid graphics:"
42 " Switching panel to integrated GPU.\n");
43
44 if (config->has_panel_hybrid_gpio)
45 gpio_set(config->panel_hybrid_gpio,
46 config->panel_integrated_lvl);
47
48 if (config->has_backlight_gpio)
49 gpio_set(config->backlight_gpio,
50 config->backlight_integrated_lvl);
51 }
52 }
53
54 struct chip_operations drivers_lenovo_hybrid_graphics_ops = {
55 .name = "Lenovo hybrid graphics driver",
56 .enable_dev = lenovo_hybrid_graphics_enable
57 };