Hi,
this patch adds support for set brightness on machines which supported by the
omnibook kernel module [1] and support set brightness.
Please review.
Cheers,
Danny
[1] http://sourceforge.net/projects/omke/
brightness.cpp | 86 +++++++++++++++++++++++++++++++++++++++++++++++++
brightness.h | 15 ++++++++
2 files changed, 101 insertions(+)
Index: daemon/brightness.h
===================================================================
--- daemon/brightness.h (revision 2004)
+++ daemon/brightness.h (working copy)
@@ -32,6 +32,7 @@
#define ACPI_SONY "/proc/acpi/sony/brightness"
#define ACPI_TOSHIBA "/proc/acpi/toshiba/lcd"
#define ACPI_PANASONIC "/proc/acpi/panasonic/"
+#define LCD_OMNIBOOK "/proc/omnibook/lcd"
/* merge #include "powersaved.h" */
@@ -138,3 +139,17 @@
int GetLevels();
};
#endif /* POWERSAVE_BRIGHTNESS_H */
+
+class BrightnessOmnibook:public Brightness {
+ public:
+ void Init();
+
+ int Get();
+ void Set(int);
+
+ void Min();
+ void Med();
+
+ int GetLevels();
+};
+
Index: daemon/brightness.cpp
===================================================================
--- daemon/brightness.cpp (revision 2004)
+++ daemon/brightness.cpp (working copy)
@@ -5,6 +5,7 @@
* Copyright (C) 2004,2005 SUSE Linux Products GmbH *
* *
* Author(s): Timo Hoenig <[EMAIL PROTECTED]> *
+ * Danny Kukawka <[EMAIL PROTECTED]> *
* *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
@@ -70,6 +71,11 @@
return new BrightnessPanasonic();
}
+ if ((fd = open(LCD_OMNIBOOK, O_RDONLY)) > 0) {
+ close(fd);
+ return new BrightnessOmnibook();
+ }
+
if (fd) {
close(fd);
}
@@ -641,3 +647,83 @@
{
return (brt_max - brt_min) * 10 / brt_scale + 1;
}
+
+/* Brightness (Omnibook object) */
+
+void BrightnessOmnibook::Init()
+{
+ last_percent = -1;
+ iface = LCD_OMNIBOOK;
+ return;
+}
+
+int BrightnessOmnibook::Get()
+{
+ char value[19];
+ int level;
+
+ if ((fd = open(iface, O_RDONLY)) < 0) {
+ perror(iface);
+ level = -1;
+ goto out;
+ }
+
+ if (read(fd, &value, 18) == -1) {
+ level = -1;
+ goto out;
+ }
+
+ sscanf(value, "LCD brightness: %d", &level);
+
+out:
+ if (fd) {
+ close(fd);
+ }
+ return level;
+}
+
+void BrightnessOmnibook::Set(int level)
+{
+ char value[3];
+ int n;
+
+ if ((fd = open(iface, O_RDWR)) < 1) {
+ perror(iface);
+ goto out;
+ }
+
+ if (level > 10)
+ level = 10;
+ else if (level < 0)
+ level = 0;
+ n = sprintf(value, "%d", level);
+ if (write(fd, value, n) < 0) {
+ pDebug(DBG_WARN,
+ "Unable to write to Omnibook brightness interface");
+ goto out;
+ }
+
+out:
+ if (fd) {
+ close(fd);
+ }
+ return;
+}
+
+void BrightnessOmnibook::Min()
+{
+ Set(1);
+ return;
+}
+
+void BrightnessOmnibook::Med()
+{
+ Set(5);
+ return;
+}
+
+int BrightnessOmnibook::GetLevels()
+{
+ return 10;
+}
+
_______________________________________________
powersave-devel mailing list
[email protected]
http://forge.novell.com/mailman/listinfo/powersave-devel