]> git.itanic.dy.fi Git - linux-stable/commitdiff
platform/x86: x86-android-tablets: Fix backlight ctrl for Lenovo Yoga Tab 3 Pro YT3...
authorHans de Goede <hdegoede@redhat.com>
Sat, 4 Nov 2023 20:58:28 +0000 (21:58 +0100)
committerHans de Goede <hdegoede@redhat.com>
Mon, 20 Nov 2023 12:20:34 +0000 (13:20 +0100)
Fix the maximum brightness being much too low on the Yoga Tab 3 Pro.

The LP8557 backlight controller can either be configured to multiply its
PWM input and the I2C register set level (requiring both to be at 100%
for 100% output); or to only take the I2C register set level into account.

Multiplying the 2 levels is useful because this will turn off the backlight
when the panel goes off and turns off its PWM output.

But on the YT3-X90F the panel's PWM output defaults to a duty-cycle of much
less then 100%, severely limiting max brightness. In this case the LP8557
should be configured to only take the I2C register into account and
the i915 driver must turn off the backlight separately using a VBT MIPI
sequence to turn off the backlight.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20231104205828.63139-4-hdegoede@redhat.com
drivers/platform/x86/x86-android-tablets/lenovo.c

index 0bc6a74b8bebfaa0b6f3cbc4a01c496ac2863258..f1c66a61bfc52786f1a6cd49da8ee88c423adbea 100644 (file)
  *
  * To avoid having to have a similar hack in the mainline kernel program the
  * LP8557 to directly set the level and use the lp855x_bl driver for control.
+ *
+ * The LP8557 can either be configured to multiply its PWM input and
+ * the I2C register set level (requiring both to be at 100% for 100% output);
+ * or to only take the I2C register set level into account.
+ *
+ * Multiplying the 2 levels is useful because this will turn off the backlight
+ * when the panel goes off and turns off its PWM output.
+ *
+ * But on some models the panel's PWM output defaults to a duty-cycle of
+ * much less then 100%, severely limiting max brightness. In this case
+ * the LP8557 should be configured to only take the I2C register into
+ * account and the i915 driver must turn off the panel and the backlight
+ * separately using e.g. VBT MIPI sequences to turn off the backlight.
  */
-static struct lp855x_platform_data lenovo_lp8557_pdata = {
+static struct lp855x_platform_data lenovo_lp8557_pwm_and_reg_pdata = {
        .device_control = 0x86,
        .initial_brightness = 128,
 };
 
+static struct lp855x_platform_data lenovo_lp8557_reg_only_pdata = {
+       .device_control = 0x85,
+       .initial_brightness = 128,
+};
+
 /* Lenovo Yoga Book X90F / X90L's Android factory img has everything hardcoded */
 
 static const struct property_entry lenovo_yb1_x90_wacom_props[] = {
@@ -122,7 +140,7 @@ static const struct x86_i2c_client_info lenovo_yb1_x90_i2c_clients[] __initconst
                        .type = "lp8557",
                        .addr = 0x2c,
                        .dev_name = "lp8557",
-                       .platform_data = &lenovo_lp8557_pdata,
+                       .platform_data = &lenovo_lp8557_pwm_and_reg_pdata,
                },
                .adapter_path = "\\_SB_.PCI0.I2C4",
        }, {
@@ -358,7 +376,7 @@ static struct x86_i2c_client_info lenovo_yoga_tab2_830_1050_i2c_clients[] __init
                        .type = "lp8557",
                        .addr = 0x2c,
                        .dev_name = "lp8557",
-                       .platform_data = &lenovo_lp8557_pdata,
+                       .platform_data = &lenovo_lp8557_pwm_and_reg_pdata,
                },
                .adapter_path = "\\_SB_.I2C3",
        },
@@ -655,7 +673,7 @@ static const struct x86_i2c_client_info lenovo_yt3_i2c_clients[] __initconst = {
                        .type = "lp8557",
                        .addr = 0x2c,
                        .dev_name = "lp8557",
-                       .platform_data = &lenovo_lp8557_pdata,
+                       .platform_data = &lenovo_lp8557_reg_only_pdata,
                },
                .adapter_path = "\\_SB_.PCI0.I2C1",
        }