Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
484
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. /*
  2. * timelinex_acpi.c
  3. *
  4. * Linux kernel module that disables the discrete graphics board for Acer
  5. * Aspire TimelineX 3820TG (Core i5). Other TimelineX laptops could work, but I don't know.
  6. *
  7. * Based on the original lenovo_acpi.c by Sylvain Joyeux <sylvain.joyeux@m4x.org>, 2009
  8. */
  9. #include <acpi/acpi.h>
  10.  
  11. MODULE_LICENSE("GPL");
  12.  
  13. static acpi_handle root_handle;
  14.  
  15. static int __init kill_ati(void)
  16. {
  17. int i;
  18. acpi_status status;
  19. // The device handle
  20. acpi_handle handle;
  21. // The package elements
  22. union acpi_object package_elements[3];
  23. // The arguments to ATPX
  24. union acpi_object atpx_arg_elements[2];
  25. struct acpi_object_list atpx_arg;
  26. // For the return value of ATPX
  27. struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
  28.  
  29. status = acpi_get_handle(root_handle, "\\_SB.PCI0.P0P2.PEGP._OFF", &handle); // status = acpi_get_handle(root_handle, "\\_SB_.PCI0.OVGA.ATPX", &handle);
  30. if (ACPI_FAILURE(status))
  31. {
  32. status = acpi_get_handle(root_handle, "\\_SB_.PCI0.OVGA.XTPX", &handle);
  33. if (ACPI_FAILURE(status))
  34. {
  35. printk("timelinex_acpi: cannot get ACPI handle: %s\n", acpi_format_exception(status));
  36. return -ENOSYS;
  37. }
  38. printk("timelinex_acpi: in discrete graphics mode\n");
  39. return 0;
  40. }
  41.  
  42. for (i = 0; i < 3; ++i)
  43. {
  44. package_elements[i].type = ACPI_TYPE_INTEGER;
  45. package_elements[i].integer.value = 0;
  46. }
  47.  
  48. atpx_arg.count = 0; // atpx_arg.count = 2;
  49. atpx_arg.pointer = &atpx_arg_elements[0];
  50.  
  51. atpx_arg_elements[0].type = ACPI_TYPE_INTEGER;
  52. atpx_arg_elements[0].integer.value = 2;
  53.  
  54. atpx_arg_elements[1].type = ACPI_TYPE_PACKAGE;
  55. atpx_arg_elements[1].package.count = 3;
  56. atpx_arg_elements[1].package.elements = &package_elements[0];
  57.  
  58. status = acpi_evaluate_object(handle, NULL, &atpx_arg, &buffer);
  59. if (ACPI_FAILURE(status))
  60. {
  61. printk("timelinex_acpi: ATPX method call failed: %s\n", acpi_format_exception(status));
  62. return -ENOSYS;
  63. }
  64. kfree(buffer.pointer);
  65.  
  66. printk("timelinex_acpi: disabled the discrete graphics card\n");
  67. return 0;
  68. }
  69.  
  70. static void dummy(void)
  71. {
  72. }
  73.  
  74. module_init(kill_ati);
  75. module_exit(dummy);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement