Changes between Version 1 and Version 2 of LCDManagement

Show
Ignore:
Timestamp:
12/15/09 17:48:25 (3 years ago)
Author:
kevin
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • LCDManagement

    v1 v2  
    1 '''LCD and backlight management''' 
     1'''LCD and backlight power management''' 
    22 
    3 Blah blah 
     3The backlight is control by ioctl() calls on /dev/disp. All calls take the form 
     4 
     5{{{ 
     6typedef struct { 
     7        int reg; 
     8        int val; 
     9        int par1; 
     10        int par2; 
     11        } lcd_disp_t; 
     12 
     13 
     14int op = /* operation code */ 
     15lcd_disp_t  t = { /* parameters*/ }; 
     16int f = open (DEV_DISP, O_RDONLY); 
     17ioctl (f, op, &t); 
     18}}} 
     19 
     20The following operation codes are useful 
     21 
     22{{{ 
     23// Set brightness 
     24#define  DISP_SET_BCKL_LEV              _IOWR ( 'D', 9, lcd_disp_t*) 
     25// Enable display hardware 
     26#define  DISP_ENABLE_DISP               _IOWR ( 'D', 10, lcd_disp_t*) 
     27// Enable backlight 
     28#define  DISP_ENABLE_BCKL               _IOWR ( 'D', 11, lcd_disp_t*) 
     29}}} 
     30 
     31 
     32Each of these takes a single value in the par1 member of struct lcd_disp_t. Parameter values are as follows: 
     33 
     34DISP_ENABLE_DISP: 1 (on) or 0 (off) 
     35 
     36DISP_ENABLE_BCKL: 1 (on) or 0 (off) 
     37 
     38DISP_SET_BCKL_LEVEl: 0 (off) to probably 500. 
     39 
     40There is some uncertainty about what values are appropriate for display brightness. Minimum brightness is 1, and maximum is probably 500, although there does not appear to be a uniform spread of useful values between these extremes. There isn't a huge range of brightness anyway. AVOS only provides 3 levels and, although there probably are more, it isn't obvious that there are _usefully_ more. 
     41 
     42 
     43The display power itself is controlled by ioctl() calls on the framebuffer device /dev/fb. I am unsure of the exact purpose of all of these. However, the following piece of code, derived from a sample provided by Archos, should shut the display and backlight down completely. 
     44 
     45{{{ 
     46#define  FBIO_OUTPUT_ENABLE             _IOW ( 'F', 0x25, u_int32_t) 
     47#define  VESA_NOBLANKING                0 
     48#define  VESA_POWERDOWN                 3 
     49#define  FBIOBLANK                      0x4611 
     50#define  FB_BLANK_POWERDOWN             VESA_POWERDOWN + 1  
     51#define  FB_BLANK_NORMAL                VESA_NOBLANKING + 1  
     52#define  FB_BLANK_UNBLANK               VESA_NOBLANKING + 0  
     53 
     54void turnOffDisplay() 
     55  { 
     56  int osd_fd = open (DEV_FB, O_RDONLY); 
     57  if (osd_fd <= 0) 
     58    { 
     59    // Handle error 
     60   return; 
     61    } 
     62  int disp_fd = open (DEV_DISP, O_RDONLY); 
     63  if (disp_fd <= 0) 
     64    { 
     65    close (osd_fd); 
     66    // Handle error 
     67    return; 
     68    } 
     69  int fls = 0; 
     70  lcd_disp_t lcdOff = { .par1 = 0 }; 
     71  ioctl (disp_fd, DISP_ENABLE_BCKL, &lcdOff); 
     72  ioctl (osd_fd, FBIO_GFX_LAYER_ENABLE, &fls); 
     73  ioctl (osd_fd, FBIOBLANK, FB_BLANK_POWERDOWN); 
     74  ioctl (osd_fd, FBIO_OUTPUT_ENABLE, &fls); 
     75  ioctl (disp_fd, DISP_ENABLE_DISP, &lcdOff); 
     76  } 
     77}}} 
     78 
     79And to switch it back on again: 
     80 
     81{{{ 
     82void turnOnDisplay() 
     83  { 
     84  int osd_fd = open (DEV_FB, O_RDONLY); 
     85  if (osd_fd <= 0) 
     86    { 
     87    // Handle error 
     88    return; 
     89    } 
     90  int disp_fd = open (DEV_DISP, O_RDONLY); 
     91  if (disp_fd <= 0) 
     92    { 
     93    // Handle error 
     94    close (osd_fd); 
     95    return; 
     96    } 
     97  int t = 1; 
     98  lcd_disp_t lcdOn = { .par1 = 1 }; 
     99  ioctl (disp_fd, DISP_ENABLE_DISP, &lcdOn); 
     100  ioctl (osd_fd, FBIO_OUTPUT_ENABLE, &t); 
     101  ioctl (osd_fd, FBIOBLANK, FB_BLANK_UNBLANK); 
     102  ioctl (osd_fd, FBIO_GFX_LAYER_ENABLE, &t); 
     103  ioctl (disp_fd, DISP_ENABLE_BCKL, &lcdOn); 
     104  close (osd_fd); 
     105  close (disp_fd); 
     106  } 
     107}}} 
     108 
     109Note that the backlight level and backlight on/off status are independent. This is very important because, so far as I know, there is no way to _read_ the backlight level from the Archos driver. So applications that switch the backlight for power saving can do so, to some extent, without changing the user's preferred brightness. 
     110