]> pilppa.org Git - familiar-h63xx-build.git/blob - org.handhelds.familiar/packages/linux/opensimpad/simpad-backlight-if.patch
OE tree imported from monotone branch org.openembedded.oz354fam083 at revision 8b12e3...
[familiar-h63xx-build.git] / org.handhelds.familiar / packages / linux / opensimpad / simpad-backlight-if.patch
1
2 #
3 # Patch managed by http://www.holgerschurig.de/patcher.html
4 #
5
6 --- linux-2.4.27/drivers/video/mq200fb.c~simpad-backlight-if
7 +++ linux-2.4.27/drivers/video/mq200fb.c
8 @@ -82,6 +82,20 @@
9         write:  proc_write_reg
10  };
11  
12 +#ifdef CONFIG_SA1100_SIMPAD
13 +
14 +static ssize_t proc_read_light(struct file * file, char * buf,
15 +               size_t nbytes, loff_t *ppos);
16 +static ssize_t proc_write_light(struct file * file, const char * buffer,
17 +               size_t count, loff_t *ppos);
18 +
19 +static struct file_operations proc_light_operations = {
20 +       read:   proc_read_light,
21 +       write:  proc_write_light
22 +};
23 +#endif
24 +
25 +
26  typedef struct sa1110_reg_entry {
27         u32 phyaddr;
28         char* name;
29 @@ -622,6 +636,20 @@
30         }
31      }
32  
33 +#ifdef CONFIG_SA1100_SIMPAD
34 +       entry = create_proc_entry("backlight",
35 +                                S_IRWXU | S_IRWXG | S_IRWXO,
36 +                                mq200dir);
37 +       if(entry) {
38 +         entry->proc_fops = &proc_light_operations;
39 +       } 
40 +    else {
41 +         printk( KERN_ERR
42 +                 "mq200fb: can't create /proc/" MQ200_DIRNAME
43 +                 "/backlight\n");
44 +         return(-ENOMEM);
45 +    }
46 + #endif
47  
48  #ifdef MQ_SA1110
49  
50 @@ -1879,7 +1907,7 @@
51  static void writeBrightness(void *pMQMMIO, int brightness)
52  {
53      unsigned long dutyCycle, pwmcontrol;
54 -    int MAX_BRIGHT_REG = 0x000000fc; /* int 254 */
55 +    int MAX_BRIGHT_REG = 0x000000fe; /* int 254 */
56      
57      if(brightness > MAX_BRIGHT_REG)
58        return;
59 @@ -1961,3 +1989,43 @@
60         return (count+endp-buffer);
61  }
62  
63 +#ifdef CONFIG_SA1100_SIMPAD
64 +
65 +#define SIMPAD_BACKLIGHT_MASK  0x00a10044
66 +
67 +static int proc_read_light(struct file * file, char * buf,
68 +               size_t nbytes, loff_t *ppos)
69 +{
70 +       char outputbuf[15];
71 +       int count;
72 +       u32 pwmctl;
73 +       if (*ppos>0) /* Assume reading completed in previous read*/
74 +               return 0;
75 +
76 +       pwmctl = *((volatile *) mq200_p2v(0x4be0e03c));
77 +       pwmctl &= ~SIMPAD_BACKLIGHT_MASK;
78 +       pwmctl = pwmctl >> 8;   
79 +       pwmctl = 254 - pwmctl;
80 +               
81 +       count = sprintf(outputbuf, "%d\n",pwmctl);
82 +       *ppos+=count;
83 +       if (count>nbytes)  /* Assume output can be read at one time */
84 +               return -EINVAL;
85 +       if (copy_to_user(buf, outputbuf, count))
86 +               return -EFAULT;
87 +       return count;
88 +}
89 +
90 +static ssize_t proc_write_light(struct file * file, const char * buffer,
91 +               size_t count, loff_t *ppos)
92 +{
93 +       void * pMQMMIO = (void *) mqMmioAddr;
94 +       char *endp;
95 +       unsigned long newvalue = simple_strtoul(buffer,&endp,0);
96 +       if (newvalue > 254)
97 +               newvalue = 254;
98 +       writeBrightness(pMQMMIO,newvalue);
99 +       mq200_backlight(pMQMMIO,(int)newvalue);
100 +       return (count+endp-buffer);
101 +}
102 +#endif