Changeset 4581


Ignore:
Timestamp:
08/05/08 08:08:47 (5 years ago)
Author:
raster
Message:

fix brightness/bl power setting.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • developers/raster/ompower/power.c

    r4516 r4581  
    11#include "main.h" 
     2 
     3static void 
     4file_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 
     16static int 
     17file_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} 
    234 
    335void 
     
    1143   // hack - force activate screensaver 
    1244//   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); 
    1446   if (fd >= 0) 
    1547     { 
     
    2658   const char *string = "0\n"; 
    2759 
    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); 
    2961   if (fd >= 0) 
    3062     { 
     
    3769} 
    3870 
     71int 
     72brightness_get(void) 
     73{ 
     74   return file_read("/sys/devices/platform/s3c2440-i2c/i2c-adapter/i2c-0/0-0073/backlight/pcf50633-bl/brightness"); 
     75} 
     76 
     77void 
     78brightness_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 
    3983void 
    4084cpu_suspend(void) 
    4185{ 
    4286   int manual_resume = 0; 
     87   int prev_brightness; 
     88 
     89   prev_brightness = brightness_get(); 
     90   screen_off(); 
    4391    
    44    screen_off(); 
     92   sleep(1); 
    4593   system("apm -s"); 
    4694    
     
    4997    
    5098   if (manual_resume) 
    51      screen_on(); 
     99     { 
     100        screen_on(); 
     101        brightness_set(prev_brightness); 
     102     } 
    52103} 
    53104 
Note: See TracChangeset for help on using the changeset viewer.