Skip to content

Switching on backlight #1179

Closed
Closed

Description

@pssc

[ 165.533763] rpi-backlight rpi_backlight: Backlight change failed
[ 167.085803] rpi-backlight rpi_backlight: Backlight change failed
[ 168.281433] rpi-backlight rpi_backlight: Backlight change failed
[ 169.628353] rpi-backlight rpi_backlight: Backlight change failed
[ 169.742678] rpi-backlight rpi_backlight: Backlight change failed

Linux screenpi 4.1.12-v7+ #824 SMP PREEMPT Wed Oct 28 16:46:35 GMT 2015 armv7l GNU/Linux

I have an application controling the backlight via the

/sys/class/backlight/rpi_backlight/bl_power

Powering off writing 4 into the file seems reliable however power on fails.

I can sometime prod it into life via echoing more stuff into the file manually but its not reliable.

       val = level == 0 and "4" or "0"
        if self:getSettings()["backlight"] and (not only or only == "backlight") then
                dirNodeSetValue("/sys/class/backlight","bl_power",val,skipbacklight)
        end
end

function dirNodeSetValue(dir,node,val,skip)
        for entry in lfs.dir(dir) do repeat
                local entrydir = dir.."/"..entry

                if skip and skip[entry] then
                        break
                end
                local entrymode = lfs.attributes(entrydir, "mode")
                log:debug("dirNodeSetValue: ",entrydir," is ", entrymode)
                if entry:match("^%.") or (entrymode ~= "directory") then
                        break
                end

                local fblank = entrydir.."/"..node
                local mode = lfs.attributes(fblank,"mode")
                log:debug("dirNodeSetValue: ",fblank," mode is ", mode)
                if mode == "file" then
                        local fh = io.open(fblank,"w")
                        if fh then
                                log:info("dirNodeSetValue: ",fblank," to ",val)
                                fh:write(val)
                                fh:flush()
                                fh:close()
                        end
                end
                break -- oddness as we are in a double loop
        until true end
end

Code works on gpio_backlight for fbtft displays (adafruit28rt).

Activity

  1. changed the title [-]Switching on baclight [/-] [+]Switching on baclkight[/+] on Oct 30, 2015
  2. changed the title [-]Switching on baclkight[/-] [+]Switching on backlight[/+] on Oct 30, 2015
  3. P33M commented on Oct 31, 2015

    @P33M
    Contributor

    There's a known bug with the firmware glue switching the DSI backlight. A fix is in the patch queue.

  4. pssc commented on Oct 31, 2015

    @pssc
    Author

    Ok thanks, will retest then as soon as its pushed out...

  5. popcornmix commented on Nov 1, 2015

    @popcornmix
    Collaborator

    Firmware is pushed. Please test after running rpi-update.

  6. pssc commented on Nov 1, 2015

    @pssc
    Author

    @popcornmix one on off cycle then off and back to:-

    [   94.898890] rpi-backlight rpi_backlight: Backlight change failed
    [   95.883632] rpi-backlight rpi_backlight: Backlight change failed
    [   98.683035] rpi-backlight rpi_backlight: Backlight change failed
    [  102.183071] rpi-backlight rpi_backlight: Backlight change failed
    [  102.465310] rpi-backlight rpi_backlight: Backlight change failed
    [  104.654344] rpi-backlight rpi_backlight: Backlight change failed
    [  114.677035] rpi-backlight rpi_backlight: Backlight change failed
    

    And if i leave it a while it seems to toggle again sometimes

  7. P33M commented on Nov 2, 2015

    @P33M
    Contributor

    You're switching the backlight at a fast interval. I can see two entries in the log that are less than 500ms apart.

    Switching the backlight on and off that quickly will hit the ratelimit built into the firmware.

    Is the issue still present if your do .. until loop incorporates a ~1 second delay?

  8. pssc commented on Nov 2, 2015

    @pssc
    Author

    @P33M I am triggering on a key press (activating soft off), I left the install overnight and tired triggering again no joy, I am also toggling the frame buffer blanking? at the same time. Even if it skips a setting it should fix after a pause and timer reset, is that rate limit there for any real reason? and as said this code path works fine for backlights provided via gpio_backlight and fbtft,

    I will go back and generate an a application log and corresponding kernel log a am fairly sure that I only wrote once in a second to the sysfs bl power file but i didn't save the logs.

    Phill.

  9. P33M commented on Nov 2, 2015

    @P33M
    Contributor

    Setting framebuffer blanking as well as backlight power is unnecessary - blanking the fb will turn off the backlight.

  10. pssc commented on Nov 2, 2015

    @pssc
    Author

    @P33M ok yes that's probably whats causing the backlight setting in rapid succession though it really should recover gracefully as left overnight and just switching on failed? i am not sure if toggling the blanking on a fbtft frame buffer toggles the bl(and not all display have bl control) which is why the codes in there for the blanking and of course blanking the HDMI output before calling vcgencmd display_power to cause HDMI screen power saving.

  11. P33M commented on Nov 2, 2015

    @P33M
    Contributor

    Part of the problem is that it appears the linux-side expects a backlight change to never fail - the backlight update function can return a value, but this value is ignored by the framebuffer update.
    c.f. http://lxr.free-electrons.com/source/drivers/video/backlight/backlight.c#L40
    Therefore there's the possibility that the backlight state and framebuffer blank/unblank could get out of sync until the next time the backlight is set.

    I'll think about this a bit more.

  12. pssc commented on Nov 2, 2015

    @pssc
    Author

    @P33M something doesn't smell right in my case I am setting blank and power off then unblank and poweron, so it shouldn't matter that the second op failed as it would be set to the same state by either call...
    I am doing a complete open close for each file toggle and not keeping the descriptor open.

  13. P33M commented on Nov 2, 2015

    @P33M
    Contributor

    Hm. That's right actually - even with the limit you should still be seeing the backlight actually switch state.

    Can you post the full script you use so I can replicate the behaviour?

  14. 69 remaining items

  15. GreenEyes2796 commented on Mar 13, 2017

    @GreenEyes2796

    I should add that the sometimes the screen will not wake up on touch or keyboard, but then a few minutes later it seems to work fine.

  16. popcornmix commented on Mar 13, 2017

    @popcornmix
    Collaborator

    @GreenEyes2796 what does vcgencmd version report for you?

  17. GreenEyes2796 commented on Mar 13, 2017

    @GreenEyes2796

    Nov 25 2016 16:03:50
    Copyright (c) 2012 Broadcam
    version (long hex string) (clean) (releases)

    Do you need the hex string version number? Thanks

  18. popcornmix commented on Mar 13, 2017

    @popcornmix
    Collaborator

    Your firmware is too old. The dist-upgrade version should be newer than that (with a March date).

  19. GreenEyes2796 commented on Mar 13, 2017

    @GreenEyes2796

    Hmm. Just ran update and upgrade again and the version did not change. Known working internet connection. Any idea why I'm stuck in Nov. 2016?

  20. popcornmix commented on Mar 13, 2017

    @popcornmix
    Collaborator

    I assume you rebooted after updating?
    Have you ever run rpi-update or otherwise manually updated firmware?
    You could try:

    sudo apt-get update && sudo apt-get upgrade --reinstall raspberrypi-bootloader
    
  21. GreenEyes2796 commented on Mar 13, 2017

    @GreenEyes2796

    Yes. Did reboot after update and dist-upgrade.
    I'll try your reinstall.

  22. GreenEyes2796 commented on Mar 13, 2017

    @GreenEyes2796

    It failed. I think all the dist-upgrades are failing, Maybe I should just download a current distribution?

  23. popcornmix commented on Mar 13, 2017

    @popcornmix
    Collaborator

    Yes, I think installing the latest raspbian jessie image is probably advisable.

    Something is wrong on your image. It may be possible to fix it, but that will probably be harder than reinstalling, and you'll never know if you have fixed everything.

  24. GreenEyes2796 commented on Mar 13, 2017

    @GreenEyes2796
  25. GreenEyes2796 commented on Mar 14, 2017

    @GreenEyes2796
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions