Commit 9e05b2f4 authored by Alex Deucher's avatar Alex Deucher
Browse files

drm/radeon: add new AMD ACPI header and update relevant code (v2)



Add a new header that defines the AMD ACPI interface used
for laptops, PowerXpress, and chipset specific functionality
and update the current code to use it.

Todo:
- properly verify the ACPI interfaces
- hook up and handle ACPI notifications
- make PX code more robust
- implement PCIe Gen and width switching using ACPI

v2: fix typo in header

Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 9e9eb7c6
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@
#include "drm_sarea.h"
#include "drm_crtc_helper.h"
#include "radeon.h"
#include "radeon_acpi.h"

#include <linux/vga_switcheroo.h>

@@ -27,7 +28,7 @@ static int radeon_atif_call(acpi_handle handle)
	atif_arg.pointer = &atif_arg_elements[0];

	atif_arg_elements[0].type = ACPI_TYPE_INTEGER;
	atif_arg_elements[0].integer.value = 0;
	atif_arg_elements[0].integer.value = ATIF_FUNCTION_VERIFY_INTERFACE;
	atif_arg_elements[1].type = ACPI_TYPE_INTEGER;
	atif_arg_elements[1].integer.value = 0;

+439 −0

File added.

Preview size limit exceeded, changes collapsed.

+14 −21
Original line number Diff line number Diff line
@@ -12,18 +12,7 @@
#include <acpi/acpi_bus.h>
#include <linux/pci.h>

#define ATPX_VERSION 0
#define ATPX_GPU_PWR 2
#define ATPX_MUX_SELECT 3
#define ATPX_I2C_MUX_SELECT 4
#define ATPX_SWITCH_START 5
#define ATPX_SWITCH_END 6

#define ATPX_INTEGRATED 0
#define ATPX_DISCRETE 1

#define ATPX_MUX_IGD 0
#define ATPX_MUX_DISCRETE 1
#include "radeon_acpi.h"

static struct radeon_atpx_priv {
	bool atpx_detected;
@@ -43,10 +32,10 @@ static int radeon_atpx_get_version(acpi_handle handle)
	atpx_arg.pointer = &atpx_arg_elements[0];

	atpx_arg_elements[0].type = ACPI_TYPE_INTEGER;
	atpx_arg_elements[0].integer.value = ATPX_VERSION;
	atpx_arg_elements[0].integer.value = ATPX_FUNCTION_VERIFY_INTERFACE;

	atpx_arg_elements[1].type = ACPI_TYPE_INTEGER;
	atpx_arg_elements[1].integer.value = ATPX_VERSION;
	atpx_arg_elements[1].integer.value = 0;

	status = acpi_evaluate_object(handle, NULL, &atpx_arg, &buffer);
	if (ACPI_FAILURE(status)) {
@@ -96,27 +85,31 @@ static int radeon_atpx_execute(acpi_handle handle, int cmd_id, u16 value)

static int radeon_atpx_set_discrete_state(acpi_handle handle, int state)
{
	return radeon_atpx_execute(handle, ATPX_GPU_PWR, state);
	return radeon_atpx_execute(handle, ATPX_FUNCTION_POWER_CONTROL, state);
}

static int radeon_atpx_switch_mux(acpi_handle handle, int mux_id)
{
	return radeon_atpx_execute(handle, ATPX_MUX_SELECT, mux_id);
	return radeon_atpx_execute(handle, ATPX_FUNCTION_DISPLAY_MUX_CONTROL, mux_id);
}

static int radeon_atpx_switch_i2c_mux(acpi_handle handle, int mux_id)
{
	return radeon_atpx_execute(handle, ATPX_I2C_MUX_SELECT, mux_id);
	return radeon_atpx_execute(handle, ATPX_FUNCTION_I2C_MUX_CONTROL, mux_id);
}

static int radeon_atpx_switch_start(acpi_handle handle, int gpu_id)
{
	return radeon_atpx_execute(handle, ATPX_SWITCH_START, gpu_id);
	return radeon_atpx_execute(handle,
				   ATPX_FUNCTION_GRAPHICS_DEVICE_SWITCH_START_NOTIFICATION,
				   gpu_id);
}

static int radeon_atpx_switch_end(acpi_handle handle, int gpu_id)
{
	return radeon_atpx_execute(handle, ATPX_SWITCH_END, gpu_id);
	return radeon_atpx_execute(handle,
				   ATPX_FUNCTION_GRAPHICS_DEVICE_SWITCH_END_NOTIFICATION,
				   gpu_id);
}

static int radeon_atpx_switchto(enum vga_switcheroo_client_id id)
@@ -124,9 +117,9 @@ static int radeon_atpx_switchto(enum vga_switcheroo_client_id id)
	int gpu_id;

	if (id == VGA_SWITCHEROO_IGD)
		gpu_id = ATPX_INTEGRATED;
		gpu_id = ATPX_INTEGRATED_GPU;
	else
		gpu_id = ATPX_DISCRETE;
		gpu_id = ATPX_DISCRETE_GPU;

	radeon_atpx_switch_start(radeon_atpx_priv.atpx_handle, gpu_id);
	radeon_atpx_switch_mux(radeon_atpx_priv.atpx_handle, gpu_id);