Re: [ibm-acpi-devel] [PATCH 1/2] platorm/x86: thinkpad_acpi: sysfs interface to reduce wlan tx power

2021-03-05 Thread Kevin Locke
On Fri, 2021-02-12 at 14:58 +0900, Nitin Joshi wrote:
> Some newer Thinkpads have the WLAN antenna placed close to the WWAN
> antenna. In these cases FCC certification requires that when WWAN is
> active we reduce WLAN transmission power. A new Dynamic Power
> Reduction Control (DPRC) method is available from the BIOS on these
> platforms to reduce or restore WLAN Tx power.
> 
> This patch provides a sysfs interface that userspace can use to adjust the
> WLAN power appropriately.

Question from a user: How does wlan_tx_strength_reduce relate to or
interact with ioctl(SIOCSIWTXPOW) (i.e. iwconfig txpower) and
NL80211_ATTR_WIPHY_TX_POWER_LEVEL (i.e. iw dev set txpower)?  If I
request 30 dBm then enable wlan_tx_strength_reduce, what happens?  Same
in the opposite order?  Will ioctl(SIOCGIWTXPOW) show the reduced
txpower?

Thanks,
Kevin


___
ibm-acpi-devel mailing list
ibm-acpi-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ibm-acpi-devel


Re: [ibm-acpi-devel] [External] Re: [PATCH v2 1/2] platorm/x86: thinkpad_acpi: sysfs interface to reduce wlan tx power

2021-03-05 Thread Nitin Joshi1
Hello Hans,

>-Original Message-
>From: Hans de Goede 
>Sent: Friday, March 5, 2021 5:51 PM
>To: Nitin Joshi1 ; Nitin Joshi 
>Cc: ibm-acpi-devel@lists.sourceforge.net; platform-driver-
>x...@vger.kernel.org; Mark RH Pearson 
>Subject: Re: [External] Re: [PATCH v2 1/2] platorm/x86: thinkpad_acpi: sysfs
>interface to reduce wlan tx power
>
>Hi,
>
>On 3/5/21 1:42 AM, Nitin Joshi1 wrote:
>> Hello Hans,
>>
>>> -Original Message-
>>> From: Hans de Goede 
>>> Sent: Thursday, March 4, 2021 8:44 PM
>>> To: Nitin Joshi 
>>> Cc: ibm-acpi-devel@lists.sourceforge.net; platform-driver-
>>> x...@vger.kernel.org; Nitin Joshi1 ; Mark RH
>>> Pearson 
>>> Subject: [External] Re: [PATCH v2 1/2] platorm/x86: thinkpad_acpi:
>>> sysfs interface to reduce wlan tx power
>>>
>>> Hi,
>>>
>>> On 2/16/21 8:36 AM, Nitin Joshi wrote:
 Some newer Thinkpads have the WLAN antenna placed close to the
>WWAN
 antenna. In these cases FCC certification requires that when WWAN is
 active we reduce WLAN transmission power. A new Dynamic Power
 Reduction Control (DPRC) method is available from the BIOS on these
 platforms to reduce or restore WLAN Tx power.

 This patch provides a sysfs interface that userspace can use to
 adjust the WLAN power appropriately.

 Reviewed-by: Mark Pearson 
 Signed-off-by: Nitin Joshi 
>>>
>>> Thank you for your patches, I'm afraid that there are still a couple
>>> of small issues which need to be fixed before I can apply these:
>>
>> Thank you for your comments and apologize for any inconvenience caused.
>>
>>>
>>> 1. Both patches have "platform" misspelled in the patch Subject.
>> Ack.  I will correct it in next version.
>>
>>> 2. The patches don't apply cleanly because your kbdlang patch has
>>>   been merged and these are based on a thinkpad_acpi version without
>>>   these.
>> Ack.  I will take latest file and correct it in next version.
>>
>>> 3. I've some review remarks about this patch, see my inline comments
>below.
>>>   Note some of these remarks apply to patch 2/2 too
>>>   (I've indicated when this is the case).
>> Ack with thanks
>>
>>>
 ---
  .../admin-guide/laptops/thinkpad-acpi.rst |  18 +++
  drivers/platform/x86/thinkpad_acpi.c  | 130 ++
  2 files changed, 148 insertions(+)

 diff --git a/Documentation/admin-guide/laptops/thinkpad-acpi.rst
 b/Documentation/admin-guide/laptops/thinkpad-acpi.rst
 index 5fe1ade88c17..10410811b990 100644
 --- a/Documentation/admin-guide/laptops/thinkpad-acpi.rst
 +++ b/Documentation/admin-guide/laptops/thinkpad-acpi.rst
 @@ -51,6 +51,7 @@ detailed description):
- UWB enable and disable
- LCD Shadow (PrivacyGuard) enable and disable
- Lap mode sensor
 +  - WLAN transmission power control

  A compatibility table by model and feature is maintained on the web
 site, http://ibm-acpi.sf.net/. I appreciate any success or failure
 @@
 -1447,6 +1448,23 @@ they differ between desk and lap mode.
  The property is read-only. If the platform doesn't have support the
 sysfs  class is not created.

 +WLAN transmission power control
 +
 +
 +sysfs: wlan_tx_strength_reduce
 +
 +Some newer Thinkpads have the WLAN antenna placed close to the
>WWAN
>>> antenna.
 +This interface will be used by userspace to reduce the WLAN Tx
 +power strength when WWAN is active, as is required for FCC certification.
 +
 +The available commands are::
 +
 +echo '0' >
>>> /sys/devices/platform/thinkpad_acpi/wlan_tx_strength_reduce
 +echo '1' >
 + /sys/devices/platform/thinkpad_acpi/wlan_tx_strength_reduce
 +
 +The first command restores the wlan transmission power and the
 +latter one reduces wlan transmission power.
 +
  EXPERIMENTAL: UWB
  -

 diff --git a/drivers/platform/x86/thinkpad_acpi.c
 b/drivers/platform/x86/thinkpad_acpi.c
 index f3e8eca8d86d..af90251d79d7 100644
 --- a/drivers/platform/x86/thinkpad_acpi.c
 +++ b/drivers/platform/x86/thinkpad_acpi.c
 @@ -9983,6 +9983,132 @@ static struct ibm_struct
 proxsensor_driver_data
>>> = {
.exit = proxsensor_exit,
  };


>>>
>+/***
>>> *
 +*
 + * DPRC(Dynamic Power Reduction Control) subdriver, for the Lenovo
 +WWAN
 + * and WLAN feature.
 + */
 +#define DPRC_GET_WLAN_STATE 0x2
 +#define DPRC_SET_WLAN_POWER_REDUCE  0x00030010
 +#define DPRC_SET_WLAN_POWER_FULL0x00030100
 +#define DPRC_WLAN_POWER_REDUCE_BIT  BIT(4)
 +#define DPRC_WLAN_POWER_FULL_BITBIT(8)
 +static bool has_wlantxreduce;
 +static int wlan_txreduce;
 +
 +static int dprc_command(int command, int *output) {
 +  acpi_handle dprc_handle;
 +
 + 

Re: [ibm-acpi-devel] [External] Re: [PATCH v2 1/2] platorm/x86: thinkpad_acpi: sysfs interface to reduce wlan tx power

2021-03-05 Thread Hans de Goede
Hi,

On 3/5/21 1:42 AM, Nitin Joshi1 wrote:
> Hello Hans,
> 
>> -Original Message-
>> From: Hans de Goede 
>> Sent: Thursday, March 4, 2021 8:44 PM
>> To: Nitin Joshi 
>> Cc: ibm-acpi-devel@lists.sourceforge.net; platform-driver-
>> x...@vger.kernel.org; Nitin Joshi1 ; Mark RH Pearson
>> 
>> Subject: [External] Re: [PATCH v2 1/2] platorm/x86: thinkpad_acpi: sysfs
>> interface to reduce wlan tx power
>>
>> Hi,
>>
>> On 2/16/21 8:36 AM, Nitin Joshi wrote:
>>> Some newer Thinkpads have the WLAN antenna placed close to the WWAN
>>> antenna. In these cases FCC certification requires that when WWAN is
>>> active we reduce WLAN transmission power. A new Dynamic Power
>>> Reduction Control (DPRC) method is available from the BIOS on these
>>> platforms to reduce or restore WLAN Tx power.
>>>
>>> This patch provides a sysfs interface that userspace can use to adjust
>>> the WLAN power appropriately.
>>>
>>> Reviewed-by: Mark Pearson 
>>> Signed-off-by: Nitin Joshi 
>>
>> Thank you for your patches, I'm afraid that there are still a couple of small
>> issues which need to be fixed before I can apply these:
> 
> Thank you for your comments and apologize for any inconvenience caused.
> 
>>
>> 1. Both patches have "platform" misspelled in the patch Subject.
> Ack.  I will correct it in next version.
> 
>> 2. The patches don't apply cleanly because your kbdlang patch has
>>   been merged and these are based on a thinkpad_acpi version without
>>   these.
> Ack.  I will take latest file and correct it in next version.
> 
>> 3. I've some review remarks about this patch, see my inline comments below.
>>   Note some of these remarks apply to patch 2/2 too
>>   (I've indicated when this is the case).
> Ack with thanks
> 
>>
>>> ---
>>>  .../admin-guide/laptops/thinkpad-acpi.rst |  18 +++
>>>  drivers/platform/x86/thinkpad_acpi.c  | 130 ++
>>>  2 files changed, 148 insertions(+)
>>>
>>> diff --git a/Documentation/admin-guide/laptops/thinkpad-acpi.rst
>>> b/Documentation/admin-guide/laptops/thinkpad-acpi.rst
>>> index 5fe1ade88c17..10410811b990 100644
>>> --- a/Documentation/admin-guide/laptops/thinkpad-acpi.rst
>>> +++ b/Documentation/admin-guide/laptops/thinkpad-acpi.rst
>>> @@ -51,6 +51,7 @@ detailed description):
>>> - UWB enable and disable
>>> - LCD Shadow (PrivacyGuard) enable and disable
>>> - Lap mode sensor
>>> +   - WLAN transmission power control
>>>
>>>  A compatibility table by model and feature is maintained on the web
>>> site, http://ibm-acpi.sf.net/. I appreciate any success or failure @@
>>> -1447,6 +1448,23 @@ they differ between desk and lap mode.
>>>  The property is read-only. If the platform doesn't have support the
>>> sysfs  class is not created.
>>>
>>> +WLAN transmission power control
>>> +
>>> +
>>> +sysfs: wlan_tx_strength_reduce
>>> +
>>> +Some newer Thinkpads have the WLAN antenna placed close to the WWAN
>> antenna.
>>> +This interface will be used by userspace to reduce the WLAN Tx power
>>> +strength when WWAN is active, as is required for FCC certification.
>>> +
>>> +The available commands are::
>>> +
>>> +echo '0' >
>> /sys/devices/platform/thinkpad_acpi/wlan_tx_strength_reduce
>>> +echo '1' >
>>> + /sys/devices/platform/thinkpad_acpi/wlan_tx_strength_reduce
>>> +
>>> +The first command restores the wlan transmission power and the latter
>>> +one reduces wlan transmission power.
>>> +
>>>  EXPERIMENTAL: UWB
>>>  -
>>>
>>> diff --git a/drivers/platform/x86/thinkpad_acpi.c
>>> b/drivers/platform/x86/thinkpad_acpi.c
>>> index f3e8eca8d86d..af90251d79d7 100644
>>> --- a/drivers/platform/x86/thinkpad_acpi.c
>>> +++ b/drivers/platform/x86/thinkpad_acpi.c
>>> @@ -9983,6 +9983,132 @@ static struct ibm_struct proxsensor_driver_data
>> = {
>>> .exit = proxsensor_exit,
>>>  };
>>>
>>>
>> +/***
>> *
>>> +*
>>> + * DPRC(Dynamic Power Reduction Control) subdriver, for the Lenovo
>>> +WWAN
>>> + * and WLAN feature.
>>> + */
>>> +#define DPRC_GET_WLAN_STATE 0x2
>>> +#define DPRC_SET_WLAN_POWER_REDUCE  0x00030010
>>> +#define DPRC_SET_WLAN_POWER_FULL0x00030100
>>> +#define DPRC_WLAN_POWER_REDUCE_BIT  BIT(4)
>>> +#define DPRC_WLAN_POWER_FULL_BITBIT(8)
>>> +static bool has_wlantxreduce;
>>> +static int wlan_txreduce;
>>> +
>>> +static int dprc_command(int command, int *output) {
>>> +   acpi_handle dprc_handle;
>>> +
>>> +   if (ACPI_FAILURE(acpi_get_handle(hkey_handle, "DPRC",
>> &dprc_handle))) {
>>> +   /* Platform doesn't support DPRC */
>>> +   return -ENODEV;
>>> +   }
>>> +
>>> +   if (!acpi_evalf(dprc_handle, output, NULL, "dd", command))
>>> +   return -EIO;
>>> +
>>> +   /*
>>> +* METHOD_ERR gets returned on devices where few commands are
>> not supported
>>> +* for example WLAN power reduce command is not supported on
>> some devices.
>>> +*/