Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp374628pxk; Thu, 17 Sep 2020 05:35:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWwe2DhbQM07v29NvJn/ZSwUmAdgHbtwx134oaQXAqHpYxWbKVomAKDvXvTo/LWyxnrtxa X-Received: by 2002:a05:6402:202a:: with SMTP id ay10mr23204346edb.36.1600346155552; Thu, 17 Sep 2020 05:35:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600346155; cv=none; d=google.com; s=arc-20160816; b=SC6f8J6ctB7dbFBW7J3ChgN5l/CYh8qNTDXTL5xIrYUJWBsU6hH3DtlTQBTgE1SRMr YjV4rRVVsS0Rm8MboGXba7aen4IH4pbMMnb6xLMCNXOkOc8RFpeBcCkbr+ct67zgEmej dHhlTSEUPNlyuK5EOkxxHj9g4GCIWGtNN7P+e8k5VlChjDTXmBuA3eyFvCWjeRPE24uR mLVOzQGnqKxNl9nxWcb6ycts1Cjifs8jyupC/tUh4WH6tuMZ3ZunL1K02dP4zu1aEQDt IIhTQmUIYva7hP4gpSohgHyHvK0l+Nvk2bcFfbuDYiBzeE4EU/gP0umpCXyjECRe4lVu +EEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=EpwSRZwF6kCzeEsY4bUVgEiUx1sx1UhSc53TJLpGhZc=; b=YYqXVvh74ry/dVatABTOGfqUEmATdsdTZtfsCGym7F38g6jIjR5hiDvS/miM0AocZ/ DpD6NvDC/Y7cNcN7ONkqsfcpW5aJsLBNOXP4a/yvtI7/lkTAu8qI/0rPV6MHuimWD2jp CdP8TS2F7kLjyrFBx2HOit/i2l3ob/TI0LTXPlgOl2CVOI6PdA5wcNBIDXUPJKdnrTfQ rPPT90D2+AyzTqQNpEAebwUo8potqeiQbi5B9lao6SbTWALnS5XCM/Z6B7aooZ8NCK/T ObL0LOZTS1gGjLoSKljLA0m8FOUBlOtk7wtaYdiZNc2uanljCgVFfrXuJo7M2BB0iFaz 5aRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ROMZB3XF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u5si14720279edy.385.2020.09.17.05.35.31; Thu, 17 Sep 2020 05:35:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ROMZB3XF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726943AbgIQMdB (ORCPT + 99 others); Thu, 17 Sep 2020 08:33:01 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:40647 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726794AbgIQMbk (ORCPT ); Thu, 17 Sep 2020 08:31:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600345881; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EpwSRZwF6kCzeEsY4bUVgEiUx1sx1UhSc53TJLpGhZc=; b=ROMZB3XFafPtD8EK8gU+2i3iKuXzFvvuLRPxVE2rmswPCx67DVzXokWAqtSqV7x45cMUIR kXdvh9MuXXob/tGcAFsgyZNwGlkwIzO83P1bRb9h4iMC8jTmGjsBi0ntH0d4LneNr03zPF vufW5clIYiY7YOfYhcWD6+ulzP8/4S0= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-490-VMRKAMtaOxmxkVQo_FgJkA-1; Thu, 17 Sep 2020 08:23:15 -0400 X-MC-Unique: VMRKAMtaOxmxkVQo_FgJkA-1 Received: by mail-ej1-f69.google.com with SMTP id m24so794098ejx.22 for ; Thu, 17 Sep 2020 05:23:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=EpwSRZwF6kCzeEsY4bUVgEiUx1sx1UhSc53TJLpGhZc=; b=Ek4kBBbLg/6prVTewiu/+mzyNfsJfpMhFleo6x39EL7D0hzetdapLaWJei8JVffUcN ZsCLND/s+BR1arGgaju7F24Bk19672oNGDvGpxONGEY2d7GFdp3iJKOMdAwxqGlOZzd2 WiisPNcY16wt5E9CmXMvWSUh+TSGWGlp2LpuSRiKKIBRc8vLZZEzz3e8r4c86JiIbrqa i25XxUiaewWWdLZynCo61KnvzXSSkni20YbWsxgy22B8SOt7RiuY9BpuqASwDCulqtRR zfR3hxbjcU5yjz98NlascsrOi6cOQrwhvIWsqJaSXuo9mu4l4+u1ZGvigZFlKxpQXqUr ePOw== X-Gm-Message-State: AOAM532suHVUsw++Fd9AR7AxEN8010KQ7OSQtNZ75mvzLWikTYn6lVWP Dy74guGCiiL9yqnoVwRUf6DeJ1xZJztX/suvBkBnn3EjNGt8OefBwxoC3R4L6rrjaOoKC/+TvNJ O0u1x/vl9+fozvFnfvMXwrqe5 X-Received: by 2002:a17:906:7d5:: with SMTP id m21mr13155776ejc.538.1600345394017; Thu, 17 Sep 2020 05:23:14 -0700 (PDT) X-Received: by 2002:a17:906:7d5:: with SMTP id m21mr13155751ejc.538.1600345393714; Thu, 17 Sep 2020 05:23:13 -0700 (PDT) Received: from x1.localdomain ([2a0e:5700:4:11:334c:7e36:8d57:40cb]) by smtp.gmail.com with ESMTPSA id nh1sm14681428ejb.21.2020.09.17.05.23.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 17 Sep 2020 05:23:13 -0700 (PDT) Subject: Re: [PATCH] platform/x86: asus-wmi: Add support for SW_TABLET_MODE on UX360 To: =?UTF-8?Q?Samuel_=c4=8cavoj?= , Darren Hart , Andy Shevchenko , Corentin Chary Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org References: <20200916191232.1020318-1-samuel@cavoj.net> From: Hans de Goede Message-ID: <206d51c4-401d-e73b-b81a-fc57346a47ee@redhat.com> Date: Thu, 17 Sep 2020 14:23:12 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200916191232.1020318-1-samuel@cavoj.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 9/16/20 9:12 PM, Samuel Čavoj wrote: > The UX360CA has a WMI device id 0x00060062, which reports whether the > lid is flipped in tablet mode (1) or in normal laptop mode (0). > > This commit adds a quirk (quirk_asus_use_lid_flip_devid) for devices on > which this WMI device should be used to figure out the SW_TABLET_MODE > state, as opposed to the quirk_asus_use_kbd_dock_devid. > > It is assumed other UX360* models have the same WMI device. As such, the > quirk is applied to devices with DMI_MATCH(DMI_PRODUCT_NAME, "UX360"). > More devices with this feature need to be tested and added accordingly. > > The reason for using a whitelist via the quirk mechanism is that the new > WMI device (0x00060062) is also present on some models which do not have > a 360 degree hinge (at least FX503VD and GL503VD from Hans' DSTS > collection) and therefore its presence cannot be relied on. > > This patch is a followup to "platform/x86: asus-wmi: Fix SW_TABLET_MODE > always reporting 1 on many different models" by Hans de Goede. > > Signed-off-by: Samuel Čavoj > Cc: Hans de Goede > --- > drivers/platform/x86/asus-nb-wmi.c | 14 +++++++++++++ > drivers/platform/x86/asus-wmi.c | 23 ++++++++++++++++++++++ > drivers/platform/x86/asus-wmi.h | 1 + > include/linux/platform_data/x86/asus-wmi.h | 1 + > 4 files changed, 39 insertions(+) > > diff --git a/drivers/platform/x86/asus-nb-wmi.c b/drivers/platform/x86/asus-nb-wmi.c > index 345bd224494b..ae5501e07712 100644 > --- a/drivers/platform/x86/asus-nb-wmi.c > +++ b/drivers/platform/x86/asus-nb-wmi.c > @@ -119,6 +119,10 @@ static struct quirk_entry quirk_asus_use_kbd_dock_devid = { > .use_kbd_dock_devid = true, > }; > > +static struct quirk_entry quirk_asus_use_lid_flip_devid = { > + .use_lid_flip_devid = true, Note the default (quirk_asus_unknown) quirks set: .wmi_backlight_set_devstate = true, So you're changing that to false for all devices using that quirk now. I did not set this quirk for the transformer devices, since the quirk has to do with the handling of Fn + F7 (display off hotkey) by the embedded-controller. Since on transformer devices the keyboard is an USB device and not handled by the embedded-controller they do not need the wmi_backlight_set_devstate quirk, so I left it out. Chances are that your UX360 does need it. The purpose of the quirk is to make the embbedded controller send a KEY_DISPLAY_OFF event on FN + F7 and have it not do anything else (like turning off the backlight by itself). TL;DR: you should probably add: .wmi_backlight_set_devstate = true, to your new quirk_asus_use_lid_flip_devid quirk. > +}; > + > static int dmi_matched(const struct dmi_system_id *dmi) > { > pr_info("Identified laptop model '%s'\n", dmi->ident); > @@ -520,6 +524,16 @@ static const struct dmi_system_id asus_quirks[] = { > }, > .driver_data = &quirk_asus_use_kbd_dock_devid, > }, > + { > + .callback = dmi_matched, > + .ident = "ASUS ZenBook Flip UX360", > + .matches = { > + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), > + /* Match UX360* */ > + DMI_MATCH(DMI_PRODUCT_NAME, "UX360"), > + }, > + .driver_data = &quirk_asus_use_lid_flip_devid, > + }, > {}, > }; > > diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c > index ae6289d37faf..a628a7d9e066 100644 > --- a/drivers/platform/x86/asus-wmi.c > +++ b/drivers/platform/x86/asus-wmi.c > @@ -63,6 +63,7 @@ MODULE_LICENSE("GPL"); > #define NOTIFY_KBD_BRTTOGGLE 0xc7 > #define NOTIFY_KBD_FBM 0x99 > #define NOTIFY_KBD_TTP 0xae > +#define NOTIFY_LID_FLIP 0xfa > > #define ASUS_WMI_FNLOCK_BIOS_DISABLED BIT(0) > > @@ -375,6 +376,18 @@ static int asus_wmi_input_init(struct asus_wmi *asus) > } > } > > + if (asus->driver->quirks->use_lid_flip_devid) { > + result = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_LID_FLIP); > + if (result >= 0) { > + input_set_capability(asus->inputdev, EV_SW, SW_TABLET_MODE); > + input_report_switch(asus->inputdev, SW_TABLET_MODE, result); > + } else if (result == -ENODEV) { > + pr_err("This device has lid_flip quirk but got ENODEV checking it. This is a bug."); > + } else { > + pr_err("Error checking for lid-flip: %d\n", result); > + } > + } > + > err = input_register_device(asus->inputdev); > if (err) > goto err_free_dev; > @@ -2127,6 +2140,16 @@ static void asus_wmi_handle_event_code(int code, struct asus_wmi *asus) > return; > } > > + if (asus->driver->quirks->use_lid_flip_devid && code == NOTIFY_LID_FLIP) { > + result = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_LID_FLIP); > + > + if (result >= 0) { > + input_report_switch(asus->inputdev, SW_TABLET_MODE, result); > + input_sync(asus->inputdev); > + } > + return; > + } > + > if (asus->fan_boost_mode_available && code == NOTIFY_KBD_FBM) { > fan_boost_mode_switch_next(asus); > return; > diff --git a/drivers/platform/x86/asus-wmi.h b/drivers/platform/x86/asus-wmi.h > index 1a95c172f94b..b302415bf1d9 100644 > --- a/drivers/platform/x86/asus-wmi.h > +++ b/drivers/platform/x86/asus-wmi.h > @@ -34,6 +34,7 @@ struct quirk_entry { > bool wmi_backlight_set_devstate; > bool wmi_force_als_set; > bool use_kbd_dock_devid; > + bool use_lid_flip_devid; > int wapf; > /* > * For machines with AMD graphic chips, it will send out WMI event > diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/platform_data/x86/asus-wmi.h > index 897b8332a39f..2f274cf52805 100644 > --- a/include/linux/platform_data/x86/asus-wmi.h > +++ b/include/linux/platform_data/x86/asus-wmi.h > @@ -62,6 +62,7 @@ > > /* Misc */ > #define ASUS_WMI_DEVID_CAMERA 0x00060013 > +#define ASUS_WMI_DEVID_LID_FLIP 0x00060062 > > /* Storage */ > #define ASUS_WMI_DEVID_CARDREADER 0x00080013 > Otherwise the patch looks good to me, thank you for the patch. Regards, Hans