FreeBSDDesktop / DEPRECATED-freebsd-base-graphics

Fork of FreeBSD's base repository to work on graphics-stack-related projects
Other
49 stars 13 forks source link

Any outlook on i915 backlight support #84

Closed neelchauhan closed 7 years ago

neelchauhan commented 8 years ago

A month ago, you committed https://github.com/FreeBSDDesktop/freebsd-base-graphics/commit/620b88921d6c6cebafa60787a991d1621335d5b4 and https://github.com/FreeBSDDesktop/freebsd-base-graphics/commit/50d21cc6cc63f6f87fffc859b87c8a64c4c48665 to add i915 backlight support, but since then, no progress has been made (from what I know) this.

On TrueOS 2016-08-31 (which uses drm-next-4.7), there is no way to set the amount of backlight on the Dell Inspiron 7352 (which unlike ThinkPad models, handles brightness through the GPU).

So is there any outlook on finishing the i915 backlight support (eg. add the acpi_video bits)?

mattmacy commented 8 years ago

So is there any outlook on finishing the i915 backlight support (eg. add the acpi_video bits)?

Yes, it's just taken a backseat to stability and image corruption issues.

abishai commented 8 years ago

Maybe this port can set backlight? http://www.freshports.org/graphics/intel-backlight/

neelchauhan commented 8 years ago

It does not work on my laptop. Looking at the source, it only works up to Intel Haswell.

Update: I have also tried this, without success. Looks like my laptop will be running Arch for a bit longer.

yanko-yankulov commented 7 years ago

Here is a quick patch to make intel_backlight work on my skylake system

If you are interested give it a try. There should be no dependency on the drm code.

diff -u intel_backlight_fbsd-93e1fe4/intel_backlight.c intel_backlight-patched/intel_backlight.c
--- intel_backlight_fbsd-93e1fe4/intel_backlight.c      2015-07-06 01:32:27.000000000 +0300
+++ intel_backlight-patched/intel_backlight.c   2017-01-21 12:32:30.000000000 +0200
@@ -69,12 +69,29 @@
 int main(int argc, char** argv)
 {
        uint32_t current, max, min;
+       uint32_t currentReg, maxReg;
        int result;
-
+       
        intel_get_mmio(intel_get_pci_device());
-
-       current = reg_read(BLC_PWM_CPU_CTL) & BACKLIGHT_DUTY_CYCLE_MASK;
-       max = reg_read(BLC_PWM_PCH_CTL2) >> 16;
+       intel_check_pch();
+       
+       switch( pch )
+       {
+           case PCH_LPT:
+           case PCH_SPT:
+           case PCH_KBP:
+               currentReg = 0xc8254;
+               maxReg = 0xc8254;
+               break;
+               
+           default:
+               currentReg = BLC_PWM_CPU_CTL;
+               maxReg = BLC_PWM_PCH_CTL2;
+               break;
+       }
+       
+       current = reg_read(currentReg) & BACKLIGHT_DUTY_CYCLE_MASK;
+       max = reg_read(maxReg) >> 16;

        min = 0.5 + 0.5 * max / 100.0;  // 0.5%
        /*
@@ -99,9 +116,9 @@
                        v = min;
                else if (v > max)
                        v = max;
-               reg_write(BLC_PWM_CPU_CTL,
-                         (reg_read(BLC_PWM_CPU_CTL) &~ BACKLIGHT_DUTY_CYCLE_MASK) | v);
-               (void) reg_read(BLC_PWM_CPU_CTL);
+               reg_write(currentReg,
+                         (reg_read(currentReg) &~ BACKLIGHT_DUTY_CYCLE_MASK) | v);
+               (void) reg_read(currentReg);
                result = 0.5 + v * 100.0 / max;
                printf ("set backlight to %d%% (%d/%d)\n", result, v, max);
        }
diff -u intel_backlight_fbsd-93e1fe4/intel_gpu_tools.h intel_backlight-patched/intel_gpu_tools.h
--- intel_backlight_fbsd-93e1fe4/intel_gpu_tools.h      2015-07-06 01:32:27.000000000 +0300
+++ intel_backlight-patched/intel_gpu_tools.h   2017-01-21 12:28:13.000000000 +0200
@@ -103,6 +103,8 @@
        PCH_IBX,
        PCH_CPT,
        PCH_LPT,
+       PCH_SPT,
+       PCH_KBP,
 };

 extern enum pch_type pch;
diff -u intel_backlight_fbsd-93e1fe4/intel_pci.c intel_backlight-patched/intel_pci.c
--- intel_backlight_fbsd-93e1fe4/intel_pci.c    2015-07-06 01:32:27.000000000 +0300
+++ intel_backlight-patched/intel_pci.c 2017-01-21 12:29:09.000000000 +0200
@@ -115,6 +115,13 @@
        case 0x9c00:
                pch = PCH_LPT;
                break;
+       case 0xA100:
+       case 0x9D00:
+               pch = PCH_SPT;
+               break;
+       case 0xA200:
+               pch = PCH_KBP;
+               break;
        default:
                pch = PCH_NONE;
                return;
neelchauhan commented 7 years ago

I don't know if it will work on Broadwell, but since I posted this I switched to an IvyBridge HP EliteBook 2570p.

yanko-yankulov commented 7 years ago

Honestly I dont know either. However if someome is willing to test it I might be able to help in case it fails. The proper way would deffinitely be to handle it in the driver, as there are multiple cases in the code. However the intel-backlight seems to do it most of the time.

trombonehero commented 7 years ago

Fantastic: this works on my Skylake system. I didn't know that I'd been running at something like 30% brightness all this time. Thanks!

Jon

On 21 January 2017 at 14:07, yanko-yankulov notifications@github.com wrote:

Honestly I dont know either. However if someome is willing to test it I might be able to help in case it fails. The proper way would deffinitely be to handle it in the driver, as there are multiple cases in the code. However the intel-backlight seems to do it most of the time.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/FreeBSDDesktop/freebsd-base-graphics/issues/84#issuecomment-274275929, or mute the thread https://github.com/notifications/unsubscribe-auth/AAFPSaRV2Vh6jFI6mxhcyfsdRjrVWm7Yks5rUkJcgaJpZM4J4hsR .

-- Jonathan Anderson

jonathan.anderson@ieee.org

grahamperrin commented 7 years ago

Might https://github.com/FreeBSDDesktop/freebsd-base-graphics/issues/84#issuecomment-274253630 work where KMS is used for Intel graphics?

yanko-yankulov commented 7 years ago

Yes. I am using it with kms

martin-beran commented 7 years ago

Your patch works perfectly on my Lenovo ThinkPad E460 with Skylake running FreeBSD 11.0. With acpi_ibm kernel module and a call of intel_backlight from /etc/devd.conf, I am even able to use brightness control buttons. Could you please propagate your patch to the graphics/intel-backlight port?

Martin Beran

johalun commented 7 years ago

We need to update the port to use this repo instead https://github.com/FreeBSDDesktop/intel_backlight_fbsd

It's fixed for newer systems and added some argument validation checks.

mattmacy commented 7 years ago

@johalun please close this if resolved

johalun commented 7 years ago

Still need to update the port to use our repo.

mattmacy commented 7 years ago

@johalun That's a bug that should be filed with the port maintainer. Not us.