10 #include <linux/slab.h>
13 #include <linux/pci.h>
33 static struct radeon_atpx_priv {
75 atpx_arg.
pointer = &atpx_arg_elements[0];
78 atpx_arg_elements[0].
integer.value =
function;
87 atpx_arg_elements[1].
integer.value = 0;
94 printk(
"failed to evaluate ATPX got %s\n",
136 static int radeon_atpx_verify_interface(
struct radeon_atpx *atpx)
147 memset(&output, 0,
sizeof(output));
151 printk(
"ATPX buffer is too small: %zu\n", size);
155 size =
min(
sizeof(output), size);
190 info = radeon_atpx_call(atpx->
handle,
211 static int radeon_atpx_switch_disp_mux(
struct radeon_atpx *atpx,
u16 mux_id)
222 info = radeon_atpx_call(atpx->
handle,
243 static int radeon_atpx_switch_i2c_mux(
struct radeon_atpx *atpx,
u16 mux_id)
254 info = radeon_atpx_call(atpx->
handle,
275 static int radeon_atpx_switch_start(
struct radeon_atpx *atpx,
u16 mux_id)
286 info = radeon_atpx_call(atpx->
handle,
307 static int radeon_atpx_switch_end(
struct radeon_atpx *atpx,
u16 mux_id)
318 info = radeon_atpx_call(atpx->
handle,
346 radeon_atpx_switch_start(&radeon_atpx_priv.atpx, gpu_id);
347 radeon_atpx_switch_disp_mux(&radeon_atpx_priv.atpx, gpu_id);
348 radeon_atpx_switch_i2c_mux(&radeon_atpx_priv.atpx, gpu_id);
349 radeon_atpx_switch_end(&radeon_atpx_priv.atpx, gpu_id);
371 radeon_atpx_set_discrete_state(&radeon_atpx_priv.atpx, state);
383 static bool radeon_atpx_pci_probe_handle(
struct pci_dev *pdev)
388 dhandle = DEVICE_ACPI_HANDLE(&pdev->
dev);
396 radeon_atpx_priv.dhandle = dhandle;
397 radeon_atpx_priv.atpx.handle = atpx_handle;
407 static int radeon_atpx_init(
void)
410 return radeon_atpx_verify_interface(&radeon_atpx_priv.atpx);
421 static int radeon_atpx_get_client_id(
struct pci_dev *pdev)
423 if (radeon_atpx_priv.dhandle == DEVICE_ACPI_HANDLE(&pdev->
dev))
430 .switchto = radeon_atpx_switchto,
431 .power_state = radeon_atpx_power_state,
432 .init = radeon_atpx_init,
433 .get_client_id = radeon_atpx_get_client_id,
442 static bool radeon_atpx_detect(
void)
444 char acpi_method_name[255] = { 0 };
445 struct acpi_buffer buffer = {
sizeof(acpi_method_name), acpi_method_name};
447 bool has_atpx =
false;
453 has_atpx |= (radeon_atpx_pci_probe_handle(pdev) ==
true);
456 if (has_atpx && vga_count == 2) {
458 printk(
KERN_INFO "VGA switcheroo: detected switching method %s handle\n",
460 radeon_atpx_priv.atpx_detected =
true;
476 r = radeon_atpx_detect();