aymanbagabas/Huawei-WMI

Huawei Matebook D15 AMD R7 from 2020

krysopath opened this issue ยท 13 comments

battery thresholds and external microphone

I recently purchased Matebook D15 and am really glad you pioneered support. Most features do work right out of the box. I am missing control over battery thresholds, and an issue with my external microphone audio jack.

To Reproduce battery
Steps to reproduce the behavior:

  1. run 5.4.0-42-generic in ubuntu 20.04
  2. Try to set battery charging thresholds in /sys/class/power_supply
  3. device does not expose that interface via kernel sysfs

Expected behavior

I want to set charging thresholds via sysfs interface to have less wear on the battery.

To Reproduce audio
Steps to reproduce the behavior:

  1. run 5.4.0-42-generic in ubuntu 20.04
  2. Plug a external headset
  3. pulseaudio will continue to record with internal microphone, as no external input is recognized

Expected behavior
I want to use external input source when plugging in external headset via that jack.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop:
Linux porta 5.4.0-42-generic #46-Ubuntu SMP Fri Jul 10 00:24:02 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux with ubuntu focal 20.04

[...]
processor	: 7
vendor_id	: AuthenticAMD
cpu family	: 23
model		: 24
model name	: AMD Ryzen 7 3700U with Radeon Vega Mobile Gfx
stepping	: 1
microcode	: 0x8108109
cpu MHz		: 1330.778
cache size	: 512 KB
physical id	: 0
siblings	: 8
core id		: 3
cpu cores	: 4
apicid		: 7
initial apicid	: 7
fpu		: yes
fpu_exception	: yes
cpuid level	: 13
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid aperfmperf pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb hw_pstate sme ssbd sev ibpb vmmcall fsgsbase bmi1 avx2 smep bmi2 rdseed adx smap clflushopt sha_ni xsaveopt xsavec xgetbv1 xsaves clzero irperf xsaveerptr arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif overflow_recov succor smca
bugs		: sysret_ss_attrs null_seg spectre_v1 spectre_v2 spec_store_bypass
bogomips	: 4591.32
TLB size	: 2560 4K pages
clflush size	: 64
cache_alignment	: 64
address sizes	: 43 bits physical, 48 bits virtual
power management: ts ttp tm hwpstate eff_freq_ro [13] [14]

the wmi related modules:

$ lsmod |grep wmi
snd_rawmidi            36864  1 snd_seq_midi
snd_seq_device         16384  3 snd_seq,snd_seq_midi,snd_rawmidi
wmi_bmof               16384  0
snd                    90112  27 snd_hda_codec_generic,snd_seq,snd_seq_device,snd_hda_codec_hdmi,snd_hwdep,snd_hda_intel,snd_hda_codec,snd_hda_codec_realtek,snd_timer,snd_compress,snd_soc_core,snd_pcm,snd_rawmidi
huawei_wmi             16384  0
ledtrig_audio          16384  3 snd_hda_codec_generic,huawei_wmi,snd_hda_codec_realtek
sparse_keymap          16384  1 huawei_wmi
wmi                    32768  2 huawei_wmi,wmi_bmof

dmesg.log

alsa-info: http://alsa-project.org/db/?f=6e2af66bedb483f0f613cae40382c90a4d590efa

lspci.txt

Additional context
I can help and will dedicate time if this behavior can be fixed via a contribution. Give me directions for more specific debug output.

Could you please provide an acpi dump? Refer to https://01.org/linux-acpi/utilities for more information.

Installed acpica-tools via apt.

$ sudo acpidump > acpi-tables.out
$ sha256sum acpi-tables.out 
775424a87f8e12e3f4047e8050237a9396465b1b268552d25268939433a5944c  acpi-tables.out

gzipped to satisfy github contraints.

acpi-tables.out.gz

I also updated
lspci.txt
by running it with uid 0. Now includes Capabilities for each device.

Can I help by further remote command execution or via learning how acpi actually does work?

Can you upload the output of dmidecode > dmidecode.txt

Could you please try building the module from the source and report what files get exposed under /sys/devices/platform/huawei-wmi/

$ modinfo huawei_wmi
filename:       /lib/modules/5.4.0-89-generic/extra/huawei-wmi.ko
license:        GPL v2
description:    Huawei WMI laptop extras driver
author:         Ayman Bagabas <ayman.bagabas@gmail.com>
alias:          wmi:ABBC0F5B-8EA1-11D1-A000-C90629100000
srcversion:     9EE027D22741953CF93ADF0
alias:          wmi:ABBC0F5C-8EA1-11D1-A000-C90629100000
alias:          wmi:59142400-C6A3-40fa-BADB-8A2652834100
depends:        ledtrig-audio,wmi,sparse-keymap
retpoline:      Y
name:           huawei_wmi
vermagic:       5.4.0-89-generic SMP mod_unload modversions 
parm:           battery_reset:Reset battery charge values to (0-0) before disabling it using (0-100) (bint)
parm:           report_brightness:Report brightness keys. (bint)

$ tree /sys/devices/platform/huawei-wmi/
/sys/devices/platform/huawei-wmi/
โ”œโ”€โ”€ charge_control_thresholds
โ”œโ”€โ”€ driver -> ../../../bus/platform/drivers/huawei-wmi
โ”œโ”€โ”€ driver_override
โ”œโ”€โ”€ fn_lock_state
โ”œโ”€โ”€ input
โ”‚   โ””โ”€โ”€ input8
โ”‚       โ”œโ”€โ”€ capabilities
โ”‚       โ”‚   โ”œโ”€โ”€ abs
โ”‚       โ”‚   โ”œโ”€โ”€ ev
โ”‚       โ”‚   โ”œโ”€โ”€ ff
โ”‚       โ”‚   โ”œโ”€โ”€ key
โ”‚       โ”‚   โ”œโ”€โ”€ led
โ”‚       โ”‚   โ”œโ”€โ”€ msc
โ”‚       โ”‚   โ”œโ”€โ”€ rel
โ”‚       โ”‚   โ”œโ”€โ”€ snd
โ”‚       โ”‚   โ””โ”€โ”€ sw
โ”‚       โ”œโ”€โ”€ device -> ../../../huawei-wmi
โ”‚       โ”œโ”€โ”€ event7
โ”‚       โ”‚   โ”œโ”€โ”€ dev
โ”‚       โ”‚   โ”œโ”€โ”€ device -> ../../input8
โ”‚       โ”‚   โ”œโ”€โ”€ power
โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ async
โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ autosuspend_delay_ms
โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ control
โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ runtime_active_kids
โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ runtime_active_time
โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ runtime_enabled
โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ runtime_status
โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ runtime_suspended_time
โ”‚       โ”‚   โ”‚   โ””โ”€โ”€ runtime_usage
โ”‚       โ”‚   โ”œโ”€โ”€ subsystem -> ../../../../../../class/input
โ”‚       โ”‚   โ””โ”€โ”€ uevent
โ”‚       โ”œโ”€โ”€ id
โ”‚       โ”‚   โ”œโ”€โ”€ bustype
โ”‚       โ”‚   โ”œโ”€โ”€ product
โ”‚       โ”‚   โ”œโ”€โ”€ vendor
โ”‚       โ”‚   โ””โ”€โ”€ version
โ”‚       โ”œโ”€โ”€ modalias
โ”‚       โ”œโ”€โ”€ name
โ”‚       โ”œโ”€โ”€ phys
โ”‚       โ”œโ”€โ”€ power
โ”‚       โ”‚   โ”œโ”€โ”€ async
โ”‚       โ”‚   โ”œโ”€โ”€ autosuspend_delay_ms
โ”‚       โ”‚   โ”œโ”€โ”€ control
โ”‚       โ”‚   โ”œโ”€โ”€ runtime_active_kids
โ”‚       โ”‚   โ”œโ”€โ”€ runtime_active_time
โ”‚       โ”‚   โ”œโ”€โ”€ runtime_enabled
โ”‚       โ”‚   โ”œโ”€โ”€ runtime_status
โ”‚       โ”‚   โ”œโ”€โ”€ runtime_suspended_time
โ”‚       โ”‚   โ””โ”€โ”€ runtime_usage
โ”‚       โ”œโ”€โ”€ properties
โ”‚       โ”œโ”€โ”€ subsystem -> ../../../../../class/input
โ”‚       โ”œโ”€โ”€ uevent
โ”‚       โ””โ”€โ”€ uniq
โ”œโ”€โ”€ leds
โ”‚   โ””โ”€โ”€ platform::micmute
โ”‚       โ”œโ”€โ”€ brightness
โ”‚       โ”œโ”€โ”€ device -> ../../../huawei-wmi
โ”‚       โ”œโ”€โ”€ max_brightness
โ”‚       โ”œโ”€โ”€ power
โ”‚       โ”‚   โ”œโ”€โ”€ async
โ”‚       โ”‚   โ”œโ”€โ”€ autosuspend_delay_ms
โ”‚       โ”‚   โ”œโ”€โ”€ control
โ”‚       โ”‚   โ”œโ”€โ”€ runtime_active_kids
โ”‚       โ”‚   โ”œโ”€โ”€ runtime_active_time
โ”‚       โ”‚   โ”œโ”€โ”€ runtime_enabled
โ”‚       โ”‚   โ”œโ”€โ”€ runtime_status
โ”‚       โ”‚   โ”œโ”€โ”€ runtime_suspended_time
โ”‚       โ”‚   โ””โ”€โ”€ runtime_usage
โ”‚       โ”œโ”€โ”€ subsystem -> ../../../../../class/leds
โ”‚       โ”œโ”€โ”€ trigger
โ”‚       โ””โ”€โ”€ uevent
โ”œโ”€โ”€ modalias
โ”œโ”€โ”€ power
โ”‚   โ”œโ”€โ”€ async
โ”‚   โ”œโ”€โ”€ autosuspend_delay_ms
โ”‚   โ”œโ”€โ”€ control
โ”‚   โ”œโ”€โ”€ runtime_active_kids
โ”‚   โ”œโ”€โ”€ runtime_active_time
โ”‚   โ”œโ”€โ”€ runtime_enabled
โ”‚   โ”œโ”€โ”€ runtime_status
โ”‚   โ”œโ”€โ”€ runtime_suspended_time
โ”‚   โ””โ”€โ”€ runtime_usage
โ”œโ”€โ”€ subsystem -> ../../../bus/platform
โ””โ”€โ”€ uevent

19 directories, 66 files

I'll try test on Huawei Matebook D15 with 3700U

@krysopath if you set "0 0" or "0 100" in charge_control_thresholds then it turn on smart charge
#55 (comment)

@sermart1234 @aymanbagabas

Still not working is pulseaudios recording device change, when a microphone jack is plugged into the laptop, but I was able to verify smart charge device node working. Thank you all. <3

Now my battery can breathe a bit more freely with the 55% capacity it has left.

Is it feasible to solve the audio jack problem here as well?

@krysopath test please
#64