From: Janusz Krzysztofik <hidden> Date: 2010-12-09 13:42:43
This patch extends the LED backlight tirgger driver with an option that allows
for inverting the trigger output polarity.
With the invertion option provided, I (ab)use the backlight trigger for
driving a LED that indicates LCD display blank condtition on my Amstrad Delta
videophone. Since the machine has no dedicated power LED, it was not possible
to distinguish if the display was blanked, or the machine was turned off,
without touching it.
The invert sysfs control is patterned after a similiar function of the GPIO
trigger driver.
Created and tested against linux-2.6.36-rc5 on Amstrad Delta.
Retested on linux-2.6.37-rc4.
Signed-off-by: Janusz Krzysztofik <redacted>
Cc: Richard Purdie <redacted>
---
Resent because I still can't see any response received, while yet another
merge window is going to pass away soon.
Applies cleanly on top of 2.6.37-rc4, so no need for yet another refresh. Only
tried to clean up the commit message slightly - maybe my English is not good
enough to bother with, if not the code?
v1 -> v2 changes:
- improve some conditional expressions to be more readable; thanks to Ralph
Corderoy (from e3-hacking) and Lars-Peter Clausen for their suggestions,
- refresh against linux-2.6.36-rc5.
drivers/leds/ledtrig-backlight.c | 60
++++++++++++++++++++++++++++++++++++---
1 file changed, 56 insertions(+), 4 deletions(-)
diff -upr linux-2.6.36-rc5.orig/drivers/leds/ledtrig-backlight.c linux-2.6.36-rc5/drivers/leds/ledtrig-backlight.c
@@ -36,23 +37,63 @@ static int fb_notifier_callback(struct nstructled_classdev*led=n->led;structfb_event*fb_event=data;int*blank=fb_event->data;+intnew_status=*blank?BLANK:UNBLANK;switch(event){caseFB_EVENT_BLANK:-if(*blank&&n->old_status=UNBLANK){+if(new_status=n->old_status)+break;++if((n->old_status=UNBLANK)^n->invert){n->brightness=led->brightness;led_set_brightness(led,LED_OFF);-n->old_status=BLANK;-}elseif(!*blank&&n->old_status=BLANK){+}else{led_set_brightness(led,n->brightness);-n->old_status=UNBLANK;}++n->old_status=new_status;+break;}return0;}+staticssize_tbl_trig_invert_show(structdevice*dev,+structdevice_attribute*attr,char*buf)+{+structled_classdev*led=dev_get_drvdata(dev);+structbl_trig_notifier*n=led->trigger_data;++returnsprintf(buf,"%s\n",n->invert?"yes":"no");+}++staticssize_tbl_trig_invert_store(structdevice*dev,+structdevice_attribute*attr,constchar*buf,size_tnum)+{+structled_classdev*led=dev_get_drvdata(dev);+structbl_trig_notifier*n=led->trigger_data;+unsignedinvert;+intret;++ret=sscanf(buf,"%u",&invert);+if(ret<1){+dev_err(dev,"invalid value\n");+return-EINVAL;+}++n->invert=!!invert;++/* After inverting, we need to update the LED. */+if((n->old_status=BLANK)^n->invert)+led_set_brightness(led,LED_OFF);+else+led_set_brightness(led,n->brightness);++returnnum;+}+staticDEVICE_ATTR(invert,0644,bl_trig_invert_show,bl_trig_invert_store);+staticvoidbl_trig_activate(structled_classdev*led){intret;
From: Paul Mundt <hidden> Date: 2011-01-06 07:10:17
(Trying an alternate address for Richard, and adding Andrew to Cc..)
On Thu, Dec 09, 2010 at 02:41:50PM +0100, Janusz Krzysztofik wrote:
quoted hunk
This patch extends the LED backlight tirgger driver with an option that allows
for inverting the trigger output polarity.
With the invertion option provided, I (ab)use the backlight trigger for
driving a LED that indicates LCD display blank condtition on my Amstrad Delta
videophone. Since the machine has no dedicated power LED, it was not possible
to distinguish if the display was blanked, or the machine was turned off,
without touching it.
The invert sysfs control is patterned after a similiar function of the GPIO
trigger driver.
Created and tested against linux-2.6.36-rc5 on Amstrad Delta.
Retested on linux-2.6.37-rc4.
Signed-off-by: Janusz Krzysztofik <redacted>
Cc: Richard Purdie <redacted>
---
Resent because I still can't see any response received, while yet another
merge window is going to pass away soon.
Applies cleanly on top of 2.6.37-rc4, so no need for yet another refresh. Only
tried to clean up the commit message slightly - maybe my English is not good
enough to bother with, if not the code?
v1 -> v2 changes:
- improve some conditional expressions to be more readable; thanks to Ralph
Corderoy (from e3-hacking) and Lars-Peter Clausen for their suggestions,
- refresh against linux-2.6.36-rc5.
drivers/leds/ledtrig-backlight.c | 60
++++++++++++++++++++++++++++++++++++---
1 file changed, 56 insertions(+), 4 deletions(-)
diff -upr linux-2.6.36-rc5.orig/drivers/leds/ledtrig-backlight.c linux-2.6.36-rc5/drivers/leds/ledtrig-backlight.c
@@ -36,23 +37,63 @@ static int fb_notifier_callback(struct nstructled_classdev*led=n->led;structfb_event*fb_event=data;int*blank=fb_event->data;+intnew_status=*blank?BLANK:UNBLANK;switch(event){caseFB_EVENT_BLANK:-if(*blank&&n->old_status=UNBLANK){+if(new_status=n->old_status)+break;++if((n->old_status=UNBLANK)^n->invert){n->brightness=led->brightness;led_set_brightness(led,LED_OFF);-n->old_status=BLANK;-}elseif(!*blank&&n->old_status=BLANK){+}else{led_set_brightness(led,n->brightness);-n->old_status=UNBLANK;}++n->old_status=new_status;+break;}return0;}+staticssize_tbl_trig_invert_show(structdevice*dev,+structdevice_attribute*attr,char*buf)+{+structled_classdev*led=dev_get_drvdata(dev);+structbl_trig_notifier*n=led->trigger_data;++returnsprintf(buf,"%s\n",n->invert?"yes":"no");+}++staticssize_tbl_trig_invert_store(structdevice*dev,+structdevice_attribute*attr,constchar*buf,size_tnum)+{+structled_classdev*led=dev_get_drvdata(dev);+structbl_trig_notifier*n=led->trigger_data;+unsignedinvert;+intret;++ret=sscanf(buf,"%u",&invert);+if(ret<1){+dev_err(dev,"invalid value\n");+return-EINVAL;+}++n->invert=!!invert;++/* After inverting, we need to update the LED. */+if((n->old_status=BLANK)^n->invert)+led_set_brightness(led,LED_OFF);+else+led_set_brightness(led,n->brightness);++returnnum;+}+staticDEVICE_ATTR(invert,0644,bl_trig_invert_show,bl_trig_invert_store);+staticvoidbl_trig_activate(structled_classdev*led){intret;
To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
From: Richard Purdie <hidden> Date: 2011-01-06 12:15:26
On Thu, 2011-01-06 at 16:08 +0900, Paul Mundt wrote:
(Trying an alternate address for Richard, and adding Andrew to Cc..)
On Thu, Dec 09, 2010 at 02:41:50PM +0100, Janusz Krzysztofik wrote:
quoted
This patch extends the LED backlight tirgger driver with an option that allows
for inverting the trigger output polarity.
With the invertion option provided, I (ab)use the backlight trigger for
driving a LED that indicates LCD display blank condtition on my Amstrad Delta
videophone. Since the machine has no dedicated power LED, it was not possible
to distinguish if the display was blanked, or the machine was turned off,
without touching it.
The invert sysfs control is patterned after a similiar function of the GPIO
trigger driver.
Created and tested against linux-2.6.36-rc5 on Amstrad Delta.
Retested on linux-2.6.37-rc4.
Signed-off-by: Janusz Krzysztofik <redacted>
Cc: Richard Purdie <redacted>
Acked-by: Richard Purdie <redacted>
I'll let Andrew take the patch though.
quoted
---
Resent because I still can't see any response received, while yet another
merge window is going to pass away soon.
Applies cleanly on top of 2.6.37-rc4, so no need for yet another refresh. Only
tried to clean up the commit message slightly - maybe my English is not good
enough to bother with, if not the code?
v1 -> v2 changes:
- improve some conditional expressions to be more readable; thanks to Ralph
Corderoy (from e3-hacking) and Lars-Peter Clausen for their suggestions,
- refresh against linux-2.6.36-rc5.
drivers/leds/ledtrig-backlight.c | 60
++++++++++++++++++++++++++++++++++++---
1 file changed, 56 insertions(+), 4 deletions(-)
diff -upr linux-2.6.36-rc5.orig/drivers/leds/ledtrig-backlight.c linux-2.6.36-rc5/drivers/leds/ledtrig-backlight.c
@@ -36,23 +37,63 @@ static int fb_notifier_callback(struct nstructled_classdev*led=n->led;structfb_event*fb_event=data;int*blank=fb_event->data;+intnew_status=*blank?BLANK:UNBLANK;switch(event){caseFB_EVENT_BLANK:-if(*blank&&n->old_status=UNBLANK){+if(new_status=n->old_status)+break;++if((n->old_status=UNBLANK)^n->invert){n->brightness=led->brightness;led_set_brightness(led,LED_OFF);-n->old_status=BLANK;-}elseif(!*blank&&n->old_status=BLANK){+}else{led_set_brightness(led,n->brightness);-n->old_status=UNBLANK;}++n->old_status=new_status;+break;}return0;}+staticssize_tbl_trig_invert_show(structdevice*dev,+structdevice_attribute*attr,char*buf)+{+structled_classdev*led=dev_get_drvdata(dev);+structbl_trig_notifier*n=led->trigger_data;++returnsprintf(buf,"%s\n",n->invert?"yes":"no");+}++staticssize_tbl_trig_invert_store(structdevice*dev,+structdevice_attribute*attr,constchar*buf,size_tnum)+{+structled_classdev*led=dev_get_drvdata(dev);+structbl_trig_notifier*n=led->trigger_data;+unsignedinvert;+intret;++ret=sscanf(buf,"%u",&invert);+if(ret<1){+dev_err(dev,"invalid value\n");+return-EINVAL;+}++n->invert=!!invert;++/* After inverting, we need to update the LED. */+if((n->old_status=BLANK)^n->invert)+led_set_brightness(led,LED_OFF);+else+led_set_brightness(led,n->brightness);++returnnum;+}+staticDEVICE_ATTR(invert,0644,bl_trig_invert_show,bl_trig_invert_store);+staticvoidbl_trig_activate(structled_classdev*led){intret;
To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
From: Andrew Morton <akpm@linux-foundation.org> Date: 2011-01-06 21:05:51
On Thu, 9 Dec 2010 14:41:50 +0100
Janusz Krzysztofik [off-list ref] wrote:
quoted hunk
This patch extends the LED backlight tirgger driver with an option that allows
for inverting the trigger output polarity.
With the invertion option provided, I (ab)use the backlight trigger for
driving a LED that indicates LCD display blank condtition on my Amstrad Delta
videophone. Since the machine has no dedicated power LED, it was not possible
to distinguish if the display was blanked, or the machine was turned off,
without touching it.
The invert sysfs control is patterned after a similiar function of the GPIO
trigger driver.
Created and tested against linux-2.6.36-rc5 on Amstrad Delta.
Retested on linux-2.6.37-rc4.
Signed-off-by: Janusz Krzysztofik <redacted>
Cc: Richard Purdie <redacted>
---
Resent because I still can't see any response received, while yet another
merge window is going to pass away soon.
Applies cleanly on top of 2.6.37-rc4, so no need for yet another refresh. Only
tried to clean up the commit message slightly - maybe my English is not good
enough to bother with, if not the code?
v1 -> v2 changes:
- improve some conditional expressions to be more readable; thanks to Ralph
Corderoy (from e3-hacking) and Lars-Peter Clausen for their suggestions,
- refresh against linux-2.6.36-rc5.
drivers/leds/ledtrig-backlight.c | 60
++++++++++++++++++++++++++++++++++++---
1 file changed, 56 insertions(+), 4 deletions(-)
diff -upr linux-2.6.36-rc5.orig/drivers/leds/ledtrig-backlight.c linux-2.6.36-rc5/drivers/leds/ledtrig-backlight.c
And here it would be better to disallow any input other than 0 or 1.
Because "2" makes no sense and who knows, some time in the future we
might *want* to permit 2.
So...
@@ -73,16 +73,17 @@ static ssize_t bl_trig_invert_store(stru{structled_classdev*led=dev_get_drvdata(dev);structbl_trig_notifier*n=led->trigger_data;-unsignedinvert;+unsignedlonginvert;intret;-ret=sscanf(buf,"%u",&invert);-if(ret<1){-dev_err(dev,"invalid value\n");+ret=strict_strtoul(buf,10,&invert);+if(ret<0)+returnret;++if(invert>1)return-EINVAL;-}-n->invert=!!invert;+n->invert=invert;/* After inverting, we need to update the LED. */if((n->old_status=BLANK)^n->invert)
This new sysfs file should be documented. Where would be an
appropriate place for that? Documentation/leds-class.txt doesn't
mention a sysfs API at all.
This new sysfs file should be documented. Where would be an
appropriate place for that? Documentation/leds-class.txt doesn't
mention a sysfs API at all.
--
in Documentation/ABI/, where all sysfs interface info lives.
---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***
This new sysfs file should be documented. Where would be an
appropriate place for that? Documentation/leds-class.txt doesn't
mention a sysfs API at all.
--
in Documentation/ABI/, where all sysfs interface info lives.
Spose so. Documentation/ABI/stable/sysfs-class-backlight does have
some stuff in it.
Personally I tend to regard Documentation/ABI/ as fairly useless
incomprehensible stuff, maintained to keep Greg happy ;) It'd be better
to have a nice little well-maintained document for a subsystem such as
this which actually explains its operation in a useful-to-humans way.
Rather than just mechanically filling out forms.
But a Documentation/ABI update is a heck of a lot better than nothing.
This new sysfs file should be documented. Where would be an
appropriate place for that? Documentation/leds-class.txt doesn't
mention a sysfs API at all.
--
in Documentation/ABI/, where all sysfs interface info lives.
Spose so. Documentation/ABI/stable/sysfs-class-backlight does have
some stuff in it.
Personally I tend to regard Documentation/ABI/ as fairly useless
incomprehensible stuff, maintained to keep Greg happy ;) It'd be better
to have a nice little well-maintained document for a subsystem such as
this which actually explains its operation in a useful-to-humans way.
Rather than just mechanically filling out forms.
But a Documentation/ABI update is a heck of a lot better than nothing.
Yes, I was giving you the "where it currently lives", not "what is best."
I agree with you.
--
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***
From: Janusz Krzysztofik <hidden> Date: 2011-01-10 04:56:47
This patch extends the LED backlight tirgger driver with an option that
allows for inverting the trigger output polarity.
With the invertion option provided, I (ab)use the backlight trigger for
driving a LED that indicates LCD display blank condtition on my Amstrad
Delta videophone. Since the machine has no dedicated power LED, it was
not possible to distinguish if the display was blanked, or the machine
was turned off, without touching it.
The invert sysfs control is patterned after a similiar function of the
GPIO trigger driver.
Created and tested against linux-2.6.37 on Amstrad Delta.
Signed-off-by: Janusz Krzysztofik <redacted>
Cc: Richard Purdie <redacted>
---
v2 -> v3 changes, all provided, requested or inspired by Andrew Morton
(thanks!):
- sysfs file should show "0" or "1" to match the thing which the user
wrote there,
- use strict_strtoul() so the kernel correctly rejects non-numerical
input,
- disallow any input other than 0 or 1,
- new sysfs file should be documented,
- the new sysfs file name could be consistent with the one already used
by the gpio trigger for a similiar function.
v1 -> v2 changes:
- improve some conditional expressions to be more readable; thanks to
Ralph Corderoy (from e3-hacking) and Lars-Peter Clausen for their
suggestions,
- refresh against linux-2.6.36-rc5.
Documentation/ABI/testing/sysfs-class-led | 10 ++++
drivers/leds/ledtrig-backlight.c | 61 ++++++++++++++++++++++++++++--
2 files changed, 67 insertions(+), 4 deletions(-)
@@ -36,23 +37,64 @@ static int fb_notifier_callback(struct nstructled_classdev*led=n->led;structfb_event*fb_event=data;int*blank=fb_event->data;+intnew_status=*blank?BLANK:UNBLANK;switch(event){caseFB_EVENT_BLANK:-if(*blank&&n->old_status=UNBLANK){+if(new_status=n->old_status)+break;++if((n->old_status=UNBLANK)^n->invert){n->brightness=led->brightness;led_set_brightness(led,LED_OFF);-n->old_status=BLANK;-}elseif(!*blank&&n->old_status=BLANK){+}else{led_set_brightness(led,n->brightness);-n->old_status=UNBLANK;}++n->old_status=new_status;+break;}return0;}+staticssize_tbl_trig_invert_show(structdevice*dev,+structdevice_attribute*attr,char*buf)+{+structled_classdev*led=dev_get_drvdata(dev);+structbl_trig_notifier*n=led->trigger_data;++returnsprintf(buf,"%u\n",n->invert);+}++staticssize_tbl_trig_invert_store(structdevice*dev,+structdevice_attribute*attr,constchar*buf,size_tnum)+{+structled_classdev*led=dev_get_drvdata(dev);+structbl_trig_notifier*n=led->trigger_data;+unsignedlonginvert;+intret;++ret=strict_strtoul(buf,10,&invert);+if(ret<0)+returnret;++if(invert>1)+return-EINVAL;++n->invert=invert;++/* After inverting, we need to update the LED. */+if((n->old_status=BLANK)^n->invert)+led_set_brightness(led,LED_OFF);+else+led_set_brightness(led,n->brightness);++returnnum;+}+staticDEVICE_ATTR(inverted,0644,bl_trig_invert_show,bl_trig_invert_store);+staticvoidbl_trig_activate(structled_classdev*led){intret;