coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
hybrid_graphics.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <option.h>
4 #include <device/device.h>
5 
7 #include <console/console.h>
8 #include "chip.h"
9 
10 /*
11  * Switch panel mux or backlight mux to active GPU.
12  * In case both GPUs are active switch panel mux to integrated.
13  */
14 static void lenovo_hybrid_graphics_enable(struct device *dev)
15 {
17  enum hybrid_graphics_req mode;
18 
19  /* Don't confuse anyone else and disable the fake device */
20  dev->enabled = 0;
21 
22  config = dev->chip_info;
23  if (!config || (get_gpio(config->detect_gpio) == DGPU_NOT_INSTALLED)) {
24  printk(BIOS_DEBUG, "Hybrid graphics: Not installed\n");
25  return;
26  }
27 
28  mode = get_uint_option("hybrid_graphics_mode", HYBRID_GRAPHICS_DEFAULT_GPU);
29 
30  if (mode == HYBRID_GRAPHICS_DISCRETE) {
31  printk(BIOS_DEBUG, "Hybrid graphics:"
32  " Switching panel to discrete GPU.\n");
33 
34  if (config->has_panel_hybrid_gpio)
35  set_gpio(config->panel_hybrid_gpio,
36  !config->panel_integrated_lvl);
37 
38  if (config->has_backlight_gpio)
39  set_gpio(config->backlight_gpio,
40  !config->backlight_integrated_lvl);
41  } else {
42  printk(BIOS_DEBUG, "Hybrid graphics:"
43  " Switching panel to integrated GPU.\n");
44 
45  if (config->has_panel_hybrid_gpio)
46  set_gpio(config->panel_hybrid_gpio,
47  config->panel_integrated_lvl);
48 
49  if (config->has_backlight_gpio)
50  set_gpio(config->backlight_gpio,
51  config->backlight_integrated_lvl);
52  }
53 }
54 
56  CHIP_NAME("Lenovo hybrid graphics driver")
57  .enable_dev = lenovo_hybrid_graphics_enable
58 };
#define printk(level,...)
Definition: stdlib.h:16
#define HYBRID_GRAPHICS_DEFAULT_GPU
Definition: chip.h:21
@ DGPU_NOT_INSTALLED
Definition: chip.h:18
hybrid_graphics_req
Definition: chip.h:10
@ HYBRID_GRAPHICS_DISCRETE
Definition: chip.h:12
int get_gpio(int community_base, int pad0_offset)
Definition: gpio_support.c:148
struct chip_operations drivers_lenovo_hybrid_graphics_ops
static void lenovo_hybrid_graphics_enable(struct device *dev)
#define CHIP_NAME(X)
Definition: device.h:32
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition: loglevel.h:128
enum board_config config
Definition: memory.c:448
unsigned int get_uint_option(const char *name, const unsigned int fallback)
Definition: option.c:116
void set_gpio(int gpio_num, int value)
Definition: gpio.c:125
Definition: device.h:107
DEVTREE_CONST void * chip_info
Definition: device.h:164
unsigned int enabled
Definition: device.h:122