[PATCH] intel_display.c: make acpi_video last in backlight_interfaces
Alon Levy
alevy at redhat.com
Sun Aug 26 06:45:42 PDT 2012
On Sun, Aug 26, 2012 at 12:51:44PM +0100, Chris Wilson wrote:
> On Sun, 26 Aug 2012 21:46:01 +1000, Dave Airlie <airlied at gmail.com> wrote:
> > On Sun, Aug 26, 2012 at 9:43 PM, Alon Levy <alevy at redhat.com> wrote:
> > > ACPI is meant as a fallback, so it should be last.
> >
> > eh no, acpi is never the fallback, its always the preferred way.
I guess I was confused by the comment:
"acpi_video1", /* finally fallback to the generic acpi drivers */
>
> Right, acpi works on far more machines than intel_backlight. If you want
> to override the automaticlly choose interface, how about an
> Option "backlight" "intel_backlight"
> ?
Works for me, patch below. But I'm confused - wouldn't the
intel_backlight sys directory be non existant if the kernel found the
machine didn't support it? at least I thought that was the point - then
checking acpi last makes sense.
> -Chris
>
> --
> Chris Wilson, Intel Open Source Technology Centre
commit 26abd7bb55f0962bd2cac0f7ed25c82dff746534
Author: Alon Levy <alevy at redhat.com>
Date: Sun Aug 26 13:15:29 2012 +0200
add OPTION_INTEL_BACKLIGHT
Allow setting intel_backlight as the preferred backlight interface.
This allows my Lenovo T510 to reach the minimal backlight (switched
off), by using intel_backlight instead of acpi.
Signed-off-by: Alon Levy <alevy at redhat.com>
diff --git a/src/intel_display.c b/src/intel_display.c
index 6580c8c..a3934bb 100644
--- a/src/intel_display.c
+++ b/src/intel_display.c
@@ -41,6 +41,7 @@
#include "intel.h"
#include "intel_bufmgr.h"
+#include "intel_options.h"
#include "xf86drm.h"
#include "xf86drmMode.h"
#include "X11/Xatom.h"
@@ -248,26 +249,43 @@ intel_output_backlight_get_max(xf86OutputPtr output)
return max;
}
+static Bool
+intel_output_try_backlight(xf86OutputPtr output, const char *interface)
+{
+ struct intel_output *intel_output = output->driver_private;
+ char path[BACKLIGHT_PATH_LEN];
+ struct stat buf;
+
+ sprintf(path, "%s/%s", BACKLIGHT_CLASS, interface);
+ if (!stat(path, &buf)) {
+ intel_output->backlight_iface = interface;
+ intel_output->backlight_max = intel_output_backlight_get_max(output);
+ if (intel_output->backlight_max > 0) {
+ intel_output->backlight_active_level = intel_output_backlight_get(output);
+ xf86DrvMsg(output->scrn->scrnIndex, X_INFO,
+ "found backlight control interface %s\n", path);
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
static void
intel_output_backlight_init(xf86OutputPtr output)
{
struct intel_output *intel_output = output->driver_private;
+ intel_screen_private *intel = intel_get_screen_private(output->scrn);
int i;
+ if (xf86ReturnOptValBool(intel->Options, OPTION_INTEL_BACKLIGHT, FALSE)) {
+ if (intel_output_try_backlight(output, "intel_backlight")) {
+ return;
+ }
+ }
+
for (i = 0; backlight_interfaces[i] != NULL; i++) {
- char path[BACKLIGHT_PATH_LEN];
- struct stat buf;
-
- sprintf(path, "%s/%s", BACKLIGHT_CLASS, backlight_interfaces[i]);
- if (!stat(path, &buf)) {
- intel_output->backlight_iface = backlight_interfaces[i];
- intel_output->backlight_max = intel_output_backlight_get_max(output);
- if (intel_output->backlight_max > 0) {
- intel_output->backlight_active_level = intel_output_backlight_get(output);
- xf86DrvMsg(output->scrn->scrnIndex, X_INFO,
- "found backlight control interface %s\n", path);
- return;
- }
+ if (intel_output_try_backlight(output, backlight_interfaces[i])) {
+ return;
}
}
intel_output->backlight_iface = NULL;
diff --git a/src/intel_options.c b/src/intel_options.c
index 7dbbc7e..c15b661 100644
--- a/src/intel_options.c
+++ b/src/intel_options.c
@@ -15,7 +15,8 @@ const OptionInfoRec intel_options[] = {
{OPTION_SWAPBUFFERS_WAIT, "SwapbuffersWait", OPTV_BOOLEAN, {0}, 1},
{OPTION_PREFER_OVERLAY, "XvPreferOverlay", OPTV_BOOLEAN, {0}, 0},
{OPTION_HOTPLUG, "HotPlug", OPTV_BOOLEAN, {0}, 1},
- {OPTION_RELAXED_FENCING,"RelaxedFencing", OPTV_BOOLEAN, {0}, 1},
+ {OPTION_RELAXED_FENCING, "RelaxedFencing", OPTV_BOOLEAN, {0}, 1},
+ {OPTION_INTEL_BACKLIGHT, "IntelBacklight", OPTV_BOOLEAN, {0}, 0},
#ifdef INTEL_XVMC
{OPTION_XVMC, "XvMC", OPTV_BOOLEAN, {0}, 1},
#endif
diff --git a/src/intel_options.h b/src/intel_options.h
index 6c16a07..0d6f4f6 100644
--- a/src/intel_options.h
+++ b/src/intel_options.h
@@ -22,6 +22,7 @@ enum intel_options {
OPTION_PREFER_OVERLAY,
OPTION_HOTPLUG,
OPTION_RELAXED_FENCING,
+ OPTION_INTEL_BACKLIGHT,
#ifdef INTEL_XVMC
OPTION_XVMC,
#endif
More information about the xorg-devel
mailing list