Skip to contentSkip to conversation

apple-gmux: Add suspend/resume support for the backlight

PATCH Applied Seth Forshee 3 participants 9 messages Apr 19, 2012 – May 10, 2012 x86 platform drivers

v1 of 2 Applied Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 apple-gmux: Add suspend/resume support for the backlight

After S3, the brightness might not be restored to the pre-suspend value. Request status update calls from the backlight core on suspend/resume to ensure the brightness value is restored.

---
 drivers/platform/x86/apple-gmux.c |    4 ++++
 1 file changed, 4 insertions(+)
drivers/platform/x86/apple-gmux.c +4 -0
index 8a582bd..6dcef4f 100644
@@ -87,6 +87,9 @@ static int gmux_update_status(struct backlight_device *bd)
 	struct apple_gmux_data *gmux_data = bl_get_data(bd);
 	u32 brightness = bd->props.brightness;
 
+	if (bd->props.state & BL_CORE_SUSPENDED)
+		brightness = 0;
+
 	/*
 	 * Older gmux versions require writing out lower bytes first then
 	 * setting the upper byte to 0 to flush the values. Newer versions
@@ -102,6 +105,7 @@ static int gmux_update_status(struct backlight_device *bd)
 }
 
 static const struct backlight_ops gmux_bl_ops = {
+	.options = BL_CORE_SUSPENDRESUME,
 	.get_brightness = gmux_get_brightness,
 	.update_status = gmux_update_status,
 };
Signature · 1 line
1.7.9.5
#1 lore raw

Ping. Any chance of getting this into 3.4?

Quoted 39 lines · Seth Forshee

After S3, the brightness might not be restored to the pre-suspend value. Request status update calls from the backlight core on suspend/resume to ensure the brightness value is restored.

---
 drivers/platform/x86/apple-gmux.c |    4 ++++
 1 file changed, 4 insertions(+)
drivers/platform/x86/apple-gmux.c +4 -0
index 8a582bd..6dcef4f 100644
@@ -87,6 +87,9 @@ static int gmux_update_status(struct backlight_device *bd)
 	struct apple_gmux_data *gmux_data = bl_get_data(bd);
 	u32 brightness = bd->props.brightness;
 
+	if (bd->props.state & BL_CORE_SUSPENDED)
+		brightness = 0;
+
 	/*
 	 * Older gmux versions require writing out lower bytes first then
 	 * setting the upper byte to 0 to flush the values. Newer versions
@@ -102,6 +105,7 @@ static int gmux_update_status(struct backlight_device *bd)
 }
 
 static const struct backlight_ops gmux_bl_ops = {
+	.options = BL_CORE_SUSPENDRESUME,
 	.get_brightness = gmux_get_brightness,
 	.update_status = gmux_update_status,
 };
Signature · 6 lines
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe platform-driver-x86" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#4 lore raw
Quoted 1 line · Matthew Garrett

Applied to -next, thanks

I thought you were going to send this one for 3.4?

#5 lore raw
In reply to Seth Forshee

drivers/platform/x86/apple-gmux.c static int gmux_update_status(struct backlight_device *bd) · line 95

Quoted 12 lines · Seth Forshee
drivers/platform/x86/apple-gmux.c +3 -0
@@ -87,6 +87,9 @@ static int gmux_update_status(struct backlight_device *bd)
        struct apple_gmux_data *gmux_data = bl_get_data(bd);
        u32 brightness = bd->props.brightness;
 
+       if (bd->props.state & BL_CORE_SUSPENDED)
+               brightness = 0;
+
        /*
         * Older gmux versions require writing out lower bytes first then
         * setting the upper byte to 0 to flush the values. Newer versions

Is this part necessary? It's about to be turned off *anyway*, and turning it off sooner will achieve little other than to make it harder to debug suspend failures, surely?

Signature · 1 line
dwmw2
#6 lore raw
Quoted 7 lines · David Woodhouse
Quoted 6 lines · Seth Forshee
drivers/platform/x86/apple-gmux.c +0 -0
@@ -87,6 +87,9 @@ static int gmux_update_status(struct backlight_device *bd)
        struct apple_gmux_data *gmux_data = bl_get_data(bd);
        u32 brightness = bd->props.brightness;
 
Quoted 10 lines

drivers/platform/x86/apple-gmux.c static int gmux_update_status(struct backlight_device *bd) · line 95

Quoted 6 lines
drivers/platform/x86/apple-gmux.c +3 -0
+       if (bd->props.state & BL_CORE_SUSPENDED)
+               brightness = 0;
+
        /*
         * Older gmux versions require writing out lower bytes first then
         * setting the upper byte to 0 to flush the values. Newer versions

Is this part necessary? It's about to be turned off *anyway*, and turning it off sooner will achieve little other than to make it harder to debug suspend failures, surely?

No, I suppose it isn't strictly necessary. I added it to avoid having the backlight turned off when the lid is closed and then turned back on while suspending.

Seth

#7 lore raw
Quoted 19 lines · Seth Forshee
Quoted 7 lines · David Woodhouse
Quoted 6 lines · Seth Forshee
drivers/platform/x86/apple-gmux.c +0 -0
@@ -87,6 +87,9 @@ static int gmux_update_status(struct backlight_device *bd)
        struct apple_gmux_data *gmux_data = bl_get_data(bd);
        u32 brightness = bd->props.brightness;
 
Quoted 10 lines

drivers/platform/x86/apple-gmux.c static int gmux_update_status(struct backlight_device *bd) · line 95

Quoted 6 lines
drivers/platform/x86/apple-gmux.c +3 -0
+       if (bd->props.state & BL_CORE_SUSPENDED)
+               brightness = 0;
+
        /*
         * Older gmux versions require writing out lower bytes first then
         * setting the upper byte to 0 to flush the values. Newer versions

Is this part necessary? It's about to be turned off *anyway*, and turning it off sooner will achieve little other than to make it harder to debug suspend failures, surely?

Quoted 3 lines

No, I suppose it isn't strictly necessary. I added it to avoid having the backlight turned off when the lid is closed and then turned back on while suspending.

That's achievable with

if (bd->props.state & BL_CORE_SUSPENDED)

    return;

right?

Signature · 1 line
dwmw2
#8 lore raw
Quoted 24 lines · David Woodhouse
Quoted 19 lines · Seth Forshee
Quoted 7 lines · David Woodhouse
Quoted 6 lines · Seth Forshee
drivers/platform/x86/apple-gmux.c +0 -0
@@ -87,6 +87,9 @@ static int gmux_update_status(struct backlight_device *bd)
        struct apple_gmux_data *gmux_data = bl_get_data(bd);
        u32 brightness = bd->props.brightness;
 
Quoted 10 lines

drivers/platform/x86/apple-gmux.c static int gmux_update_status(struct backlight_device *bd) · line 95

Quoted 6 lines
drivers/platform/x86/apple-gmux.c +3 -0
+       if (bd->props.state & BL_CORE_SUSPENDED)
+               brightness = 0;
+
        /*
         * Older gmux versions require writing out lower bytes first then
         * setting the upper byte to 0 to flush the values. Newer versions

Is this part necessary? It's about to be turned off *anyway*, and turning it off sooner will achieve little other than to make it harder to debug suspend failures, surely?

Quoted 3 lines

No, I suppose it isn't strictly necessary. I added it to avoid having the backlight turned off when the lid is closed and then turned back on while suspending.

Quoted 6 lines

That's achievable with

if (bd->props.state & BL_CORE_SUSPENDED)

    return;

right?

Good point. I'll send an updated patch.

Seth