Re: [PATCH 1/1] Add support for the ATIF ACPI method to the radeon driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 21 June 2010 16:39, Alex Deucher <alexdeucher@xxxxxxxxx> wrote:
> On Mon, Jun 21, 2010 at 10:21 AM, Alberto Milone
> <alberto.milone@xxxxxxxxxxxxx> wrote:
>> Hi all,
>>
>> Thanks to the help of Alex Deucher and Matthew Garrett, I've added
>> support for calling the ATIF ACPI method to the radeon driver. This
>> makes the video switch hotkey work properly, as we get an ACPI event
>> when the key is pressed.
>>
>> Note: I guess it depends on the bios I'm working with, but I also need
>> to pass acpi_osi=\"!Windows 2009\" on boot in order to get the ACPI
>> event.
>
> This is due to windows 7 wanting win-p for display switch events:
> http://mjg59.livejournal.com/121851.html
>
> Couple of minor nits:
>
> +/* radeon_acpi.c */
> +#if defined(CONFIG_ACPI)
> +extern int radeon_acpi_init(struct radeon_device *rdev);
> +#else
> +static inline int radeon_acpi_init(struct radeon_device *rdev) { return 1; }
> +#endif
> +
>
> We probably want to return 0 in the non CONFIG_ACPI case?  On systems
> like ppc without acpi, there's no need for the acpi stuff so the
> warning would be needless.  On systems with acpi that are compiled
> without it, well, they will probably have issues anyway...
>
> +
> +       /* No need to proceed if we're sure that ATIF is not supported */
> +       if (!ASIC_IS_AVIVO(rdev) || !rdev->bios)
> +               return 0;
> +
>
> Move this check to radeon_acpi_init() for now and there's no need to
> pass rdev to radeon_atif_call() anymore.
>
> With those changes:
>
> Reviewed-by: Alex Deucher <alexdeucher@xxxxxxxxx>
>
> Alex
>

You made some really good points.

Thanks for reviewing the patch. Here's the attached patch with the
changes that you requested.

Regards,

-- 
Alberto Milone
Sustaining Engineer (system)
Foundations Team
Canonical OEM Services
From de093510d4e6f65a23b6c53ebc222e5d11e492ca Mon Sep 17 00:00:00 2001
From: Alberto Milone <alberto.milone@xxxxxxxxxxxxx>
Date: Mon, 21 Jun 2010 18:02:29 +0200
Subject: [PATCH 1/1] Add support for the ATIF ACPI method to the radeon driver

By calling the ATIF method in the radeon driver we can make sure
that hotkeys such as the video switch key emit ACPI events when
pressed.

Signed-off-by: Alberto Milone <alberto.milone@xxxxxxxxxxxxx>
---
 drivers/gpu/drm/radeon/Makefile      |    1 +
 drivers/gpu/drm/radeon/radeon.h      |    7 ++++
 drivers/gpu/drm/radeon/radeon_acpi.c |   67 ++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/radeon/radeon_kms.c  |    8 ++++-
 4 files changed, 82 insertions(+), 1 deletions(-)
 create mode 100644 drivers/gpu/drm/radeon/radeon_acpi.c

diff --git a/drivers/gpu/drm/radeon/Makefile b/drivers/gpu/drm/radeon/Makefile
index 84b1f27..aebe008 100644
--- a/drivers/gpu/drm/radeon/Makefile
+++ b/drivers/gpu/drm/radeon/Makefile
@@ -69,5 +69,6 @@ radeon-y += radeon_device.o radeon_asic.o radeon_kms.o \
 
 radeon-$(CONFIG_COMPAT) += radeon_ioc32.o
 radeon-$(CONFIG_VGA_SWITCHEROO) += radeon_atpx_handler.o
+radeon-$(CONFIG_ACPI) += radeon_acpi.o
 
 obj-$(CONFIG_DRM_RADEON)+= radeon.o
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 8e1d44c..029c526 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -1412,6 +1412,13 @@ extern void r700_cp_fini(struct radeon_device *rdev);
 extern void evergreen_disable_interrupt_state(struct radeon_device *rdev);
 extern int evergreen_irq_set(struct radeon_device *rdev);
 
+/* radeon_acpi.c */ 
+#if defined(CONFIG_ACPI) 
+extern int radeon_acpi_init(struct radeon_device *rdev); 
+#else 
+static inline int radeon_acpi_init(struct radeon_device *rdev) { return 0; } 
+#endif 
+
 /* evergreen */
 struct evergreen_mc_save {
 	u32 vga_control[6];
diff --git a/drivers/gpu/drm/radeon/radeon_acpi.c b/drivers/gpu/drm/radeon/radeon_acpi.c
new file mode 100644
index 0000000..11c389a
--- /dev/null
+++ b/drivers/gpu/drm/radeon/radeon_acpi.c
@@ -0,0 +1,67 @@
+#include <linux/pci.h>
+#include <linux/acpi.h>
+#include <linux/slab.h>
+#include <acpi/acpi_drivers.h>
+#include <acpi/acpi_bus.h>
+
+#include "drmP.h"
+#include "drm.h"
+#include "drm_sarea.h"
+#include "drm_crtc_helper.h"
+#include "radeon.h"
+
+#include <linux/vga_switcheroo.h>
+
+/* Call the ATIF method
+ *
+ * Note: currently we discard the output
+ */
+static int radeon_atif_call(acpi_handle handle)
+{
+	acpi_status status;
+	union acpi_object atif_arg_elements[2];
+	struct acpi_object_list atif_arg;
+	struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL};
+
+	atif_arg.count = 2;
+	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[1].type = ACPI_TYPE_INTEGER;
+	atif_arg_elements[1].integer.value = NULL;
+
+	status = acpi_evaluate_object(handle, "ATIF", &atif_arg, &buffer);
+
+	/* Fail only if calling the method fails and ATIF is supported */
+	if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
+		printk(KERN_INFO "failed to evaluate ATIF got %s\n", acpi_format_exception(status));
+		kfree(buffer.pointer);
+		return 1;
+	}
+
+	kfree(buffer.pointer);
+	return 0;
+}
+
+/* Call all ACPI methods here */
+int radeon_acpi_init(struct radeon_device *rdev)
+{
+	acpi_handle handle;
+	int ret;
+
+	/* No need to proceed if we're sure that ATIF is not supported */
+	if (!ASIC_IS_AVIVO(rdev) || !rdev->bios)
+		return 0;
+
+	/* Get the device handle */
+	handle = DEVICE_ACPI_HANDLE(&rdev->pdev->dev);
+
+	/* Call the ATIF method */
+	ret = radeon_atif_call(handle);
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c
index 6a70c0d..70fda63 100644
--- a/drivers/gpu/drm/radeon/radeon_kms.c
+++ b/drivers/gpu/drm/radeon/radeon_kms.c
@@ -49,7 +49,7 @@ int radeon_driver_unload_kms(struct drm_device *dev)
 int radeon_driver_load_kms(struct drm_device *dev, unsigned long flags)
 {
 	struct radeon_device *rdev;
-	int r;
+	int r, acpi_status;
 
 	rdev = kzalloc(sizeof(struct radeon_device), GFP_KERNEL);
 	if (rdev == NULL) {
@@ -77,6 +77,12 @@ int radeon_driver_load_kms(struct drm_device *dev, unsigned long flags)
 		dev_err(&dev->pdev->dev, "Fatal error during GPU init\n");
 		goto out;
 	}
+
+	/* Call ACPI methods */
+	acpi_status = radeon_acpi_init(rdev);
+	if (acpi_status)
+		dev_err(&dev->pdev->dev, "Error during ACPI methods call\n");
+
 	/* Again modeset_init should fail only on fatal error
 	 * otherwise it should provide enough functionalities
 	 * for shadowfb to run
-- 
1.7.0.4

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/dri-devel

[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux