3 # Patch managed by http://www.holgerschurig.de/patcher.html
6 --- linux-2.4.27/drivers/video/mq200fb.c~simpad-backlight-if
7 +++ linux-2.4.27/drivers/video/mq200fb.c
12 +#ifdef CONFIG_SA1100_SIMPAD
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);
19 +static struct file_operations proc_light_operations = {
20 + read: proc_read_light,
21 + write: proc_write_light
26 typedef struct sa1110_reg_entry {
33 +#ifdef CONFIG_SA1100_SIMPAD
34 + entry = create_proc_entry("backlight",
35 + S_IRWXU | S_IRWXG | S_IRWXO,
38 + entry->proc_fops = &proc_light_operations;
42 + "mq200fb: can't create /proc/" MQ200_DIRNAME
51 static void writeBrightness(void *pMQMMIO, int brightness)
53 unsigned long dutyCycle, pwmcontrol;
54 - int MAX_BRIGHT_REG = 0x000000fc; /* int 254 */
55 + int MAX_BRIGHT_REG = 0x000000fe; /* int 254 */
57 if(brightness > MAX_BRIGHT_REG)
59 @@ -1961,3 +1989,43 @@
60 return (count+endp-buffer);
63 +#ifdef CONFIG_SA1100_SIMPAD
65 +#define SIMPAD_BACKLIGHT_MASK 0x00a10044
67 +static int proc_read_light(struct file * file, char * buf,
68 + size_t nbytes, loff_t *ppos)
73 + if (*ppos>0) /* Assume reading completed in previous read*/
76 + pwmctl = *((volatile *) mq200_p2v(0x4be0e03c));
77 + pwmctl &= ~SIMPAD_BACKLIGHT_MASK;
78 + pwmctl = pwmctl >> 8;
79 + pwmctl = 254 - pwmctl;
81 + count = sprintf(outputbuf, "%d\n",pwmctl);
83 + if (count>nbytes) /* Assume output can be read at one time */
85 + if (copy_to_user(buf, outputbuf, count))
90 +static ssize_t proc_write_light(struct file * file, const char * buffer,
91 + size_t count, loff_t *ppos)
93 + void * pMQMMIO = (void *) mqMmioAddr;
95 + unsigned long newvalue = simple_strtoul(buffer,&endp,0);
98 + writeBrightness(pMQMMIO,newvalue);
99 + mq200_backlight(pMQMMIO,(int)newvalue);
100 + return (count+endp-buffer);