Changeset 4581
- Timestamp:
- 08/05/08 08:08:47 (5 years ago)
- File:
-
- 1 edited
-
developers/raster/ompower/power.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
developers/raster/ompower/power.c
r4516 r4581 1 1 #include "main.h" 2 3 static void 4 file_write(const char *file, int val) 5 { 6 char buf[80]; 7 int fd; 8 9 snprintf(buf, sizeof(buf), "%i\n", val); 10 fd = open(file, O_RDWR); 11 if (fd < 0) return; 12 write(fd, buf, strlen(buf)); 13 close(fd); 14 } 15 16 static int 17 file_read(const char *file) 18 { 19 char buf[80]; 20 int fd, len; 21 22 fd = open(file, O_RDONLY); 23 if (fd < 0) return -1; 24 len = read(fd, buf, sizeof(buf) - 1); 25 if (len <= 0) 26 { 27 close(fd); 28 return -1; 29 } 30 buf[len] = 0; 31 close(fd); 32 return atoi(buf); 33 } 2 34 3 35 void … … 11 43 // hack - force activate screensaver 12 44 // system("xset s activate"); 13 fd = open("/sys/devices/platform/s3c2440-i2c/i2c-adapter/i2c-0/0-0073/backlight/pcf50633-bl ", O_RDWR);45 fd = open("/sys/devices/platform/s3c2440-i2c/i2c-adapter/i2c-0/0-0073/backlight/pcf50633-bl/bl_power", O_RDWR); 14 46 if (fd >= 0) 15 47 { … … 26 58 const char *string = "0\n"; 27 59 28 fd = open("/sys/devices/platform/s3c2440-i2c/i2c-adapter/i2c-0/0-0073/backlight/pcf50633-bl ", O_RDWR);60 fd = open("/sys/devices/platform/s3c2440-i2c/i2c-adapter/i2c-0/0-0073/backlight/pcf50633-bl/bl_power", O_RDWR); 29 61 if (fd >= 0) 30 62 { … … 37 69 } 38 70 71 int 72 brightness_get(void) 73 { 74 return file_read("/sys/devices/platform/s3c2440-i2c/i2c-adapter/i2c-0/0-0073/backlight/pcf50633-bl/brightness"); 75 } 76 77 void 78 brightness_set(int val) 79 { 80 file_write("/sys/devices/platform/s3c2440-i2c/i2c-adapter/i2c-0/0-0073/backlight/pcf50633-bl/brightness", val); 81 } 82 39 83 void 40 84 cpu_suspend(void) 41 85 { 42 86 int manual_resume = 0; 87 int prev_brightness; 88 89 prev_brightness = brightness_get(); 90 screen_off(); 43 91 44 s creen_off();92 sleep(1); 45 93 system("apm -s"); 46 94 … … 49 97 50 98 if (manual_resume) 51 screen_on(); 99 { 100 screen_on(); 101 brightness_set(prev_brightness); 102 } 52 103 } 53 104
Note: See TracChangeset
for help on using the changeset viewer.
