Skip to contentSkip to conversation

platform/x86: thinkpad_acpi: Accept flat mode for type 4 multi mode status

PATCH In review Benjamin Berg 3 participants 5 messages Nov 14, 2017 – Dec 18, 2017 x86 platform drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 platform/x86: thinkpad_acpi: Accept flat mode for type 4 multi mode status

On the X1 Yoga 2nd Generation and most likely other notebooks the FLAT mode is reported. Decode it correctly rather than warning about an unexpected multi mode status to be reported.

---
 drivers/platform/x86/thinkpad_acpi.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/platform/x86/thinkpad_acpi.c +3 -5
index 91fab1a13a6d..d23c84222e9f 100644
@@ -2106,26 +2106,24 @@ static int hotkey_gmms_get_tablet_mode(int s, int *has_tablet_mode)
 			      TP_ACPI_MULTI_MODE_FLAT |
 			      TP_ACPI_MULTI_MODE_TABLET |
 			      TP_ACPI_MULTI_MODE_STAND |
 			      TP_ACPI_MULTI_MODE_TENT;
 		break;
 	case 3:
 		valid_modes = TP_ACPI_MULTI_MODE_LAPTOP |
 			      TP_ACPI_MULTI_MODE_FLAT;
 		break;
 	case 4:
-		valid_modes = TP_ACPI_MULTI_MODE_LAPTOP |
-			      TP_ACPI_MULTI_MODE_TABLET |
-			      TP_ACPI_MULTI_MODE_STAND |
-			      TP_ACPI_MULTI_MODE_TENT;
-		break;
 	case 5:
+		/* In mode 4, FLAT is not specified as a valid mode. However,
+		 * it can be seen at least on the X1 Yoga 2nd Generation.
+		 */
 		valid_modes = TP_ACPI_MULTI_MODE_LAPTOP |
 			      TP_ACPI_MULTI_MODE_FLAT |
 			      TP_ACPI_MULTI_MODE_TABLET |
 			      TP_ACPI_MULTI_MODE_STAND |
 			      TP_ACPI_MULTI_MODE_TENT;
 		break;
 	default:
 		pr_err("Unknown multi mode status type %d with value 0x%04X, please report this to %s\n",
 		       type, value, TPACPI_MAIL);
 		return 0;
Signature · 1 line
2.13.6
#1 lore raw
Quoted 3 lines · Benjamin Berg

On the X1 Yoga 2nd Generation and most likely other notebooks the FLAT mode is reported. Decode it correctly rather than warning about an unexpected multi mode status to be reported.

If we can't check on all available hardware, better to avoid "doing for all" fixes.
I suppose DMI match can help here.

It would be nice to hear from Henrique and others as well.

drivers/platform/x86/thinkpad_acpi.c static int hotkey_gmms_get_tablet_mode(int s, int *has_tablet_mode) · line 2120

Quoted 6 lines
        case 4:
drivers/platform/x86/thinkpad_acpi.c +0 -5
-               valid_modes = TP_ACPI_MULTI_MODE_LAPTOP |
-                             TP_ACPI_MULTI_MODE_TABLET |
-                             TP_ACPI_MULTI_MODE_STAND |
-                             TP_ACPI_MULTI_MODE_TENT;
-               break;

The common practice is to put
/* fallthrough */
instead.

drivers/platform/x86/thinkpad_acpi.c static int hotkey_gmms_get_tablet_mode(int s, int *has_tablet_mode) · line 2119

Quoted 5 lines
        case 5:
drivers/platform/x86/thinkpad_acpi.c +3 -0
+               /* In mode 4, FLAT is not specified as a valid mode. However,
+                * it can be seen at least on the X1 Yoga 2nd Generation.
+                */

We don't use network subsystem style of comments.

Quoted 6 lines
                valid_modes = TP_ACPI_MULTI_MODE_LAPTOP |
                              TP_ACPI_MULTI_MODE_FLAT |
                              TP_ACPI_MULTI_MODE_TABLET |
                              TP_ACPI_MULTI_MODE_STAND |
                              TP_ACPI_MULTI_MODE_TENT;
                break;
Signature · 2 lines
With Best Regards,
Andy Shevchenko
Reviewed-by on v1 1/1
#3 lore raw
In reply to Benjamin Berg

lgtm.

Quoted 49 lines · Benjamin Berg

On the X1 Yoga 2nd Generation and most likely other notebooks the FLAT mode is reported. Decode it correctly rather than warning about an unexpected multi mode status to be reported.

---
 drivers/platform/x86/thinkpad_acpi.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/platform/x86/thinkpad_acpi.c +3 -5
index 91fab1a13a6d..d23c84222e9f 100644
@@ -2106,26 +2106,24 @@ static int hotkey_gmms_get_tablet_mode(int s, int
 *has_tablet_mode)
 			      TP_ACPI_MULTI_MODE_FLAT |
 			      TP_ACPI_MULTI_MODE_TABLET |
 			      TP_ACPI_MULTI_MODE_STAND |
 			      TP_ACPI_MULTI_MODE_TENT;
 		break;
 	case 3:
 		valid_modes = TP_ACPI_MULTI_MODE_LAPTOP |
 			      TP_ACPI_MULTI_MODE_FLAT;
 		break;
 	case 4:
-		valid_modes = TP_ACPI_MULTI_MODE_LAPTOP |
-			      TP_ACPI_MULTI_MODE_TABLET |
-			      TP_ACPI_MULTI_MODE_STAND |
-			      TP_ACPI_MULTI_MODE_TENT;
-		break;
 	case 5:
+		/* In mode 4, FLAT is not specified as a valid mode.
 However,
+		 * it can be seen at least on the X1 Yoga 2nd Generation.
+		 */
 		valid_modes = TP_ACPI_MULTI_MODE_LAPTOP |
 			      TP_ACPI_MULTI_MODE_FLAT |
 			      TP_ACPI_MULTI_MODE_TABLET |
 			      TP_ACPI_MULTI_MODE_STAND |
 			      TP_ACPI_MULTI_MODE_TENT;
 		break;
 	default:
 		pr_err("Unknown multi mode status type %d with value

0x%04X, please report this to %s\n",

drivers/platform/x86/thinkpad_acpi.c +0 -0
 		       type, value, TPACPI_MAIL);
 		return 0;
#2 lore raw
In reply to Andy Shevchenko
Quoted 10 lines · Andy Shevchenko
Quoted 4 lines · Benjamin Berg

On the X1 Yoga 2nd Generation and most likely other notebooks the FLAT
mode is reported. Decode it correctly rather than warning about an unexpected multi mode status to be reported.

If we can't check on all available hardware, better to avoid "doing for all" fixes.
I suppose DMI match can help here.

The documentation I saw suggests that the flat mode cannot be detected by machines reporting a multi mode status of type 4. This is why the original patch excluded the FLAT mode in the list of valid modes on those devices.

I think it is safe to simply assume that all laptops reporting type 4 can actually detect the flat state. Doing so will not affect actual state reporting on machines that may not be able to detect it. And I don't think that the information whether the flat state can be detected or not is interesting enough to bother with DMI matches.

Benjamin

Quoted 31 lines

It would be nice to hear from Henrique and others as well.

drivers/platform/x86/thinkpad_acpi.c static int hotkey_gmms_get_tablet_mode(int s, int *has_tablet_mode) · line 2120

Quoted 6 lines
        case 4:
drivers/platform/x86/thinkpad_acpi.c +0 -5
-               valid_modes = TP_ACPI_MULTI_MODE_LAPTOP |
-                             TP_ACPI_MULTI_MODE_TABLET |
-                             TP_ACPI_MULTI_MODE_STAND |
-                             TP_ACPI_MULTI_MODE_TENT;
-               break;

The common practice is to put
/* fallthrough */
instead.

Quoted 6 lines
        case 5:

+ /* In mode 4, FLAT is not specified as a valid
mode. However,
+ * it can be seen at least on the X1 Yoga 2nd
Generation.
+ */

We don't use network subsystem style of comments.

Quoted 6 lines
                valid_modes = TP_ACPI_MULTI_MODE_LAPTOP |
                              TP_ACPI_MULTI_MODE_FLAT |
                              TP_ACPI_MULTI_MODE_TABLET |
                              TP_ACPI_MULTI_MODE_STAND |
                              TP_ACPI_MULTI_MODE_TENT;
                break;
#4 lore raw
In reply to Benjamin Berg
Quoted 7 lines · Benjamin Berg

On the X1 Yoga 2nd Generation and most likely other notebooks the FLAT mode is reported. Decode it correctly rather than warning about an unexpected multi mode status to be reported.

Applied to my review and testing queue, thanks!

Quoted 41 lines
---
 drivers/platform/x86/thinkpad_acpi.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/platform/x86/thinkpad_acpi.c +3 -6
index 91fab1a13a6d..d23c84222e9f 100644
@@ -2106,26 +2106,24 @@ static int hotkey_gmms_get_tablet_mode(int s, int *has_tablet_mode)
                              TP_ACPI_MULTI_MODE_FLAT |
                              TP_ACPI_MULTI_MODE_TABLET |
                              TP_ACPI_MULTI_MODE_STAND |
                              TP_ACPI_MULTI_MODE_TENT;
                break;
        case 3:
                valid_modes = TP_ACPI_MULTI_MODE_LAPTOP |
                              TP_ACPI_MULTI_MODE_FLAT;
                break;
        case 4:
-               valid_modes = TP_ACPI_MULTI_MODE_LAPTOP |
-                             TP_ACPI_MULTI_MODE_TABLET |
-                             TP_ACPI_MULTI_MODE_STAND |
-                             TP_ACPI_MULTI_MODE_TENT;
-               break;
        case 5:
+               /* In mode 4, FLAT is not specified as a valid mode. However,
+                * it can be seen at least on the X1 Yoga 2nd Generation.
+                */
                valid_modes = TP_ACPI_MULTI_MODE_LAPTOP |
                              TP_ACPI_MULTI_MODE_FLAT |
                              TP_ACPI_MULTI_MODE_TABLET |
                              TP_ACPI_MULTI_MODE_STAND |
                              TP_ACPI_MULTI_MODE_TENT;
                break;
        default:
                pr_err("Unknown multi mode status type %d with value 0x%04X, please report this to %s\n",
                       type, value, TPACPI_MAIL);
                return 0;
--

2.13.6

Signature · 2 lines
With Best Regards,
Andy Shevchenko