From patchwork Sun Jul 29 19:33:07 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Tettamanti X-Patchwork-Id: 1252781 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork2.kernel.org (Postfix) with ESMTP id 01BDEDF25A for ; Sun, 29 Jul 2012 19:33:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 424039F03D for ; Sun, 29 Jul 2012 12:33:27 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wg0-f43.google.com (mail-wg0-f43.google.com [74.125.82.43]) by gabe.freedesktop.org (Postfix) with ESMTP id 5FE379E8C0 for ; Sun, 29 Jul 2012 12:33:15 -0700 (PDT) Received: by wgbdr1 with SMTP id dr1so3481995wgb.12 for ; Sun, 29 Jul 2012 12:33:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=3K0XIpBY8cLwkV19B39UnduiEbZ3dXapT3OUkaWR5p8=; b=iMwVT7vdbJI7jsq/TvR7KF3ikp8mgpvoMKDX7wCXBO1AFKwO+ne9Z1BQ+GzaClGJrw 7Rp6ittxCrRB2Dh3M7IQ6YzzMMnxqn998LhL3t1kl0Jhi83RrnhbHFdl2uKKBVMZb9OY fhiCy3ZK/YJmms0bh+lQqfpKC1b5wVnC4IwZgB3gZzX/mpfEfzyZyZDsLrcypSDBiPU7 umz5C0yx5DvzShFp/nrjwzkN7YRVGWCmsoSk19rxz8yUwTlxQBNSfuvUYaqMBteJtsWu Q+z0V1sDjHp+eBN4iolTRMMI3X5IZCsqBfje7kVT4NHNBZXbCOZXw2KZ18AdeRpUD5uN YfMw== Received: by 10.180.97.135 with SMTP id ea7mr36953548wib.11.1343590394754; Sun, 29 Jul 2012 12:33:14 -0700 (PDT) Received: from growl (dynamic-adsl-78-14-226-138.clienti.tiscali.it. [78.14.226.138]) by mx.google.com with ESMTPS id h9sm12348794wiz.1.2012.07.29.12.33.12 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 29 Jul 2012 12:33:13 -0700 (PDT) Date: Sun, 29 Jul 2012 21:33:07 +0200 From: Luca Tettamanti To: Alex Deucher Subject: Re: [PATCH] drm/radeon: add new AMD ACPI header and update relevant code Message-ID: <20120729193307.GA5512@growl> References: <1343237889-5220-1-git-send-email-alexdeucher@gmail.com> <20120726125838.GA28853@growl> <20120726193346.GA11288@growl> <20120728145626.GA6304@growl> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Cc: Alex Deucher , joeyli , dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Hi, I'm attaching a first draft of my work. The first 3 patches are infrastructure work, the fourth wires the notification handler and retrieves the requests from the system BIOS, but it does not actually change brightness yet. The problem here is how to get the correct encoder: should I just scan encoder_list checking for ATOM_DEVICE_LCD_SUPPORT and see if it has a backlight device attached? Hopefully there is only one encoder with it, right? I'm also toying with the idea of creating structures matching the output of the various ACPI methods, this would remove some ugly pointer arithmetics, but it _might_ make it easier to read past the buffer if one does not check the size before using the struct. What do you think? Luca From 29937c81f1449d136c85145ceeeb7de24bfcc4c8 Mon Sep 17 00:00:00 2001 From: Luca Tettamanti Date: Sun, 29 Jul 2012 21:00:51 +0200 Subject: [PATCH 4/4] drm/radeon: implement skeleton handler for ACPI events Signed-off-by: Luca Tettamanti --- drivers/gpu/drm/radeon/radeon_acpi.c | 72 ++++++++++++++++++++++++++++++++++ drivers/gpu/drm/radeon/radeon_acpi.h | 5 +++ drivers/gpu/drm/radeon/radeon_pm.c | 4 +- 3 files changed, 80 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/radeon/radeon_acpi.c b/drivers/gpu/drm/radeon/radeon_acpi.c index 94f8255..8b1fed7 100644 --- a/drivers/gpu/drm/radeon/radeon_acpi.c +++ b/drivers/gpu/drm/radeon/radeon_acpi.c @@ -18,6 +18,11 @@ #define ATIF_NOTIFICATION_81 1 #define ATIF_NOTIFICATION_N 2 +struct radeon_atif_sbios_requests { + bool brightness_change; + int brightness_target; +}; + /* Call the ATIF method */ static union acpi_object* radeon_atif_call(acpi_handle handle, int function) @@ -152,6 +157,73 @@ out: return err; } +static int radeon_atif_get_sbios_requests(acpi_handle handle, + struct radeon_atif_sbios_requests *req) +{ + union acpi_object *info; + void *buffer; + u16 size; + u32 pending; + int count = 0; + + memset(req, 0, sizeof(*req)); + + info = radeon_atif_call(handle, ATIF_FUNCTION_GET_SYSTEM_BIOS_REQUESTS); + if (!info) + return -EIO; + + buffer = info->buffer.pointer; + + size = *(u16 *)buffer; + if (size < 0xd) { + count = -EINVAL; + goto out; + } + + pending = *(u32 *)(buffer + 2); + + if (pending & ATIF_PANEL_BRIGHTNESS_CHANGE_REQUEST_SUPPORTED) { + count++; + req->brightness_change = true; + req->brightness_target = *(u8 *)(buffer + 12); + } + + /* TODO check other requests */ + +out: + kfree(info); + return count; +} + +int radeon_atif_handler(struct radeon_device *rdev, struct acpi_bus_event *event) +{ + struct radeon_atif *atif = &rdev->atif; + struct radeon_atif_sbios_requests req; + acpi_handle handle; + int count; + + if (!atif->notification_cfg.enabled || + event->type != atif->notification_cfg.command_code) + /* Not our event */ + return NOTIFY_DONE; + + /* Check pending SBIOS requests */ + handle = DEVICE_ACPI_HANDLE(&rdev->pdev->dev); + count = radeon_atif_get_sbios_requests(handle, &req); + + if (count <= 0) + return NOTIFY_DONE; + + DRM_DEBUG_DRIVER("ATIF: %d pending SBIOS requests\n", count); + + if (req.brightness_change) { + /* TODO */ + printk(KERN_INFO "Changing brightness to %d\n", req.brightness_target); + } + + return NOTIFY_OK; +} + /* Call all ACPI methods here */ int radeon_acpi_init(struct radeon_device *rdev) { diff --git a/drivers/gpu/drm/radeon/radeon_acpi.h b/drivers/gpu/drm/radeon/radeon_acpi.h index a42288d..513894e 100644 --- a/drivers/gpu/drm/radeon/radeon_acpi.h +++ b/drivers/gpu/drm/radeon/radeon_acpi.h @@ -24,6 +24,11 @@ #ifndef RADEON_ACPI_H #define RADEON_ACPI_H +struct radeon_device; +struct acpi_bus_event; + +int radeon_atif_handler(struct radeon_device *rdev, struct acpi_bus_event *event); + /* AMD hw uses four ACPI control methods: * 1. ATIF * ARG0: (ACPI_INTEGER) function code diff --git a/drivers/gpu/drm/radeon/radeon_pm.c b/drivers/gpu/drm/radeon/radeon_pm.c index 5b37e28..8621748 100644 --- a/drivers/gpu/drm/radeon/radeon_pm.c +++ b/drivers/gpu/drm/radeon/radeon_pm.c @@ -22,6 +22,7 @@ */ #include "drmP.h" #include "radeon.h" +#include "radeon_acpi.h" #include "avivod.h" #include "atom.h" #ifdef CONFIG_ACPI @@ -95,7 +96,8 @@ static int radeon_acpi_event(struct notifier_block *nb, } } - return NOTIFY_OK; + /* Check for pending SBIOS requests */ + return radeon_atif_handler(rdev, entry); } #endif -- 1.7.10.4