aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/linux/opensimpad/simpad-backlight-if.patch
diff options
context:
space:
mode:
Diffstat (limited to 'recipes/linux/opensimpad/simpad-backlight-if.patch')
-rw-r--r--recipes/linux/opensimpad/simpad-backlight-if.patch102
1 files changed, 102 insertions, 0 deletions
diff --git a/recipes/linux/opensimpad/simpad-backlight-if.patch b/recipes/linux/opensimpad/simpad-backlight-if.patch
new file mode 100644
index 0000000000..4e04afb5e9
--- /dev/null
+++ b/recipes/linux/opensimpad/simpad-backlight-if.patch
@@ -0,0 +1,102 @@
+
+#
+# Patch managed by http://www.holgerschurig.de/patcher.html
+#
+
+--- linux-2.4.27/drivers/video/mq200fb.c~simpad-backlight-if
++++ linux-2.4.27/drivers/video/mq200fb.c
+@@ -82,6 +82,20 @@
+ write: proc_write_reg
+ };
+
++#ifdef CONFIG_SA1100_SIMPAD
++
++static ssize_t proc_read_light(struct file * file, char * buf,
++ size_t nbytes, loff_t *ppos);
++static ssize_t proc_write_light(struct file * file, const char * buffer,
++ size_t count, loff_t *ppos);
++
++static struct file_operations proc_light_operations = {
++ read: proc_read_light,
++ write: proc_write_light
++};
++#endif
++
++
+ typedef struct sa1110_reg_entry {
+ u32 phyaddr;
+ char* name;
+@@ -622,6 +636,20 @@
+ }
+ }
+
++#ifdef CONFIG_SA1100_SIMPAD
++ entry = create_proc_entry("backlight",
++ S_IRWXU | S_IRWXG | S_IRWXO,
++ mq200dir);
++ if(entry) {
++ entry->proc_fops = &proc_light_operations;
++ }
++ else {
++ printk( KERN_ERR
++ "mq200fb: can't create /proc/" MQ200_DIRNAME
++ "/backlight\n");
++ return(-ENOMEM);
++ }
++ #endif
+
+ #ifdef MQ_SA1110
+
+@@ -1879,7 +1907,7 @@
+ static void writeBrightness(void *pMQMMIO, int brightness)
+ {
+ unsigned long dutyCycle, pwmcontrol;
+- int MAX_BRIGHT_REG = 0x000000fc; /* int 254 */
++ int MAX_BRIGHT_REG = 0x000000fe; /* int 254 */
+
+ if(brightness > MAX_BRIGHT_REG)
+ return;
+@@ -1961,3 +1989,43 @@
+ return (count+endp-buffer);
+ }
+
++#ifdef CONFIG_SA1100_SIMPAD
++
++#define SIMPAD_BACKLIGHT_MASK 0x00a10044
++
++static int proc_read_light(struct file * file, char * buf,
++ size_t nbytes, loff_t *ppos)
++{
++ char outputbuf[15];
++ int count;
++ u32 pwmctl;
++ if (*ppos>0) /* Assume reading completed in previous read*/
++ return 0;
++
++ pwmctl = *((volatile *) mq200_p2v(0x4be0e03c));
++ pwmctl &= ~SIMPAD_BACKLIGHT_MASK;
++ pwmctl = pwmctl >> 8;
++ pwmctl = 254 - pwmctl;
++
++ count = sprintf(outputbuf, "%d\n",pwmctl);
++ *ppos+=count;
++ if (count>nbytes) /* Assume output can be read at one time */
++ return -EINVAL;
++ if (copy_to_user(buf, outputbuf, count))
++ return -EFAULT;
++ return count;
++}
++
++static ssize_t proc_write_light(struct file * file, const char * buffer,
++ size_t count, loff_t *ppos)
++{
++ void * pMQMMIO = (void *) mqMmioAddr;
++ char *endp;
++ unsigned long newvalue = simple_strtoul(buffer,&endp,0);
++ if (newvalue > 254)
++ newvalue = 254;
++ writeBrightness(pMQMMIO,newvalue);
++ mq200_backlight(pMQMMIO,(int)newvalue);
++ return (count+endp-buffer);
++}
++#endif