need help. asus-a6m+brightness control
Daniel Walter
d.walter at 0x90.at
Sat Feb 13 12:44:30 UTC 2010
On Sat, 13 Feb 2010, Sam Fourman Jr. wrote:
> On Sat, Feb 13, 2010 at 5:31 AM, Daniel Walter <d.walter at 0x90.at> wrote:
>> On Sat, 13 Feb 2010, Sam Fourman Jr. wrote:
>>
>>> On Tue, Feb 9, 2010 at 3:33 PM, Sergey V. Dyatko
>>> <sergey.dyatko at gmail.com> wrote:
>>>>
>>>> Hi,
>>>>
>>>> I have asus-a6m laptop running HEAD. But unfortunately brightness
>>>> control not working when I boot with acpi support.
>>>>
>>>> I made some changes on acpi_asus.c but it doesn't help -
>>>> brightness is still not regulated. Good news: the volume keys started
>>>> working and now I have /dev/led/wled, /dev/led/mled :)
>>>>
>>>> result of `acpidump -dt | gzip -c9 >asus_a6m.asl.gz`:
>>>> http://tiger.ipfw.ru/files/asus_a6m.asl.gz
>>>>
>>>> Thanks for any help
>>>
>>> I saw this acpidump command (dont know anything about ACPI) and
>>> thought I would run it on my Asus x83v laptop
>>> this notebook runs the following:
>>>
>>> MiniBSD# uname -a
>>> FreeBSD MiniBSD.PuffyBSD.Com 8.0-STABLE FreeBSD 8.0-STABLE #2: Thu Dec
>>> 24 21:13:20 CST 2009
>>> sfourman at MiniBSD.PuffyBSD.Com:/usr/obj/usr/src/sys/GENERIC amd64
>>>
>>>
>>> here is the output of `acpidump -dt | gzip -c9 >asus_x83v.asl.gz
>>>
>>> http://www.puffybsd.com/asus_x83v.asl.gz
>>>
>>> hopefully this will help FreeBSD devlopers better support Asus Laptops
>>>
>>> I am very willing to help devlopers and root on this notebook is
>>> available from public ssh .. just ask
>>>
>>>
>>> Sam Fourman Jr.
>>
>> Hi,
>>
>> there is support for brightness control in HEAD since yesterday. So you have
>> two options either switch to CURRENT or wait until acpi_video(4) is MFC'ed.
>
> so my asl file has the bits necessary to support the brightness
> control committed to HEAD yesterday?
>
> Sam
if i'm not completly wrong it should work. if you don't want to switch to current, you can apply attached patch. It should work with a actual STABLE.
hope this one helps
regards
Daniel Walter
-------------- next part --------------
--- acpi_video.c 2010-02-06 13:03:25.000000000 +0100
+++ acpi_video.c 2010-02-13 12:14:03.000000000 +0100
@@ -83,6 +83,7 @@
static void acpi_video_vo_bind(struct acpi_video_output *, ACPI_HANDLE);
static void acpi_video_vo_destroy(struct acpi_video_output *);
static int acpi_video_vo_check_level(struct acpi_video_output *, int);
+static void acpi_video_vo_notify_handler(ACPI_HANDLE, UINT32, void *);
static int acpi_video_vo_active_sysctl(SYSCTL_HANDLER_ARGS);
static int acpi_video_vo_bright_sysctl(SYSCTL_HANDLER_ARGS);
static int acpi_video_vo_presets_sysctl(SYSCTL_HANDLER_ARGS);
@@ -93,6 +94,7 @@
static int vid_enum_outputs(ACPI_HANDLE,
void(*)(ACPI_HANDLE, UINT32, void *), void *);
static int vo_get_brightness_levels(ACPI_HANDLE, int **);
+static int vo_get_brightness(ACPI_HANDLE);
static void vo_set_brightness(ACPI_HANDLE, int);
static UINT32 vo_get_device_status(ACPI_HANDLE);
static UINT32 vo_get_graphics_state(ACPI_HANDLE);
@@ -101,6 +103,10 @@
/* events */
#define VID_NOTIFY_SWITCHED 0x80
#define VID_NOTIFY_REPROBE 0x81
+#define VID_NOTIFY_CYC_BRN 0x85
+#define VID_NOTIFY_INC_BRN 0x86
+#define VID_NOTIFY_DEC_BRN 0x87
+#define VID_NOTIFY_ZRO_BRN 0x88
/* _DOS (Enable/Disable Output Switching) argument bits */
#define DOS_SWITCH_MASK 3
@@ -578,6 +583,9 @@
/* XXX - see above. */
vo->vo_economy = vo->vo_levels[BCL_ECONOMY];
}
+ if (vo->vo_levels != NULL)
+ AcpiInstallNotifyHandler(handle, ACPI_DEVICE_NOTIFY,
+ acpi_video_vo_notify_handler, vo);
ACPI_SERIAL_END(video_output);
}
@@ -591,8 +599,11 @@
vo->vo_sysctl_tree = NULL;
sysctl_ctx_free(&vo->vo_sysctl_ctx);
}
- if (vo->vo_levels != NULL)
+ if (vo->vo_levels != NULL) {
+ AcpiRemoveNotifyHandler(vo->handle, ACPI_DEVICE_NOTIFY,
+ acpi_video_vo_notify_handler);
AcpiOsFree(vo->vo_levels);
+ }
switch (vo->adr & DOD_DEVID_MASK) {
case DOD_DEVID_MONITOR:
@@ -628,6 +639,61 @@
return (EINVAL);
}
+static void
+acpi_video_vo_notify_handler(ACPI_HANDLE handle, UINT32 notify, void *context)
+{
+ struct acpi_video_output *vo;
+ int i, j, level, new_level;
+
+ vo = context;
+ ACPI_SERIAL_BEGIN(video_output);
+ if (vo->handle != handle) {
+ ACPI_SERIAL_END(video_output);
+ return;
+ }
+
+ switch (notify) {
+ case VID_NOTIFY_CYC_BRN:
+ case VID_NOTIFY_INC_BRN:
+ case VID_NOTIFY_DEC_BRN:
+ if (vo->vo_levels == NULL)
+ break;
+ level = vo_get_brightness(handle);
+ if (level < 0)
+ break;
+ new_level = level;
+ for (i = 0; i < vo->vo_numlevels; i++) {
+ j = vo->vo_levels[i];
+ if (notify == VID_NOTIFY_INC_BRN) {
+ if (j > level &&
+ (j < new_level || level == new_level))
+ new_level = j;
+ } else {
+ if (j < level &&
+ (j > new_level || level == new_level))
+ new_level = j;
+ }
+ }
+ if (notify == VID_NOTIFY_CYC_BRN && new_level == level)
+ new_level= vo->vo_levels[2];
+ if (new_level != level) {
+ vo_set_brightness(handle, new_level);
+ vo->vo_brightness = new_level;
+ }
+ break;
+ case VID_NOTIFY_ZRO_BRN:
+ if (acpi_video_vo_check_level(vo, 0) == 0) {
+ vo_set_brightness(handle, 0);
+ vo->vo_brightness = 0;
+ }
+ break;
+ default:
+ printf("unknown notify event 0x%x from %s\n",
+ notify, acpi_name(handle));
+ }
+ ACPI_SERIAL_END(video_output);
+}
+
/* ARGSUSED */
static int
acpi_video_vo_active_sysctl(SYSCTL_HANDLER_ARGS)
@@ -901,6 +967,25 @@
return (num);
}
+static int
+vo_get_brightness(ACPI_HANDLE handle)
+{
+ UINT32 level;
+ ACPI_STATUS status;
+
+ ACPI_SERIAL_ASSERT(video_output);
+ status = acpi_GetInteger(handle, "_BQC", &level);
+ if (ACPI_FAILURE(status)) {
+ printf("can't evaluate %s._BQC - %s\n", acpi_name(handle),
+ AcpiFormatException(status));
+ return (-1);
+ }
+ if (level > 100)
+ return (-1);
+
+ return (level);
+}
+
static void
vo_set_brightness(ACPI_HANDLE handle, int level)
{
More information about the freebsd-acpi
mailing list