Support INT3406 Display thermal device
Subsystems (5)
v3 cover Support INT3406 Display thermal device
v3:
Split patch 3/3 in v2 into 2 patches: one makes changes to acpi_video and one adds the int3406 driver as suggested by Rafael. There should be no functionality change compared to v2.
v2:
The display thermal device represents the LED/LCD display panel that may or may not include touch support. The main function of the display thermal device is to allow control of the display brightness in order to address a thermal condition or to reduce power consumed by display device.
Due to the way this thermal device changes brightness level is said to be deprecated so we are using the raw interface to do the actual backlight change. This requires the backlight core support so two new APIs are added and exported in patch 1/3. With this, the previous API backlight_device_registered can be removed and this is done in patch 2/3. Patch 3/3 adds the new int3406 thermal driver.
The 1st version is here:
http://thread.gmane.org/gmane.linux.acpi.devel/72619
This whole series should go through the thermal tree if applied.
Aaron Lu (3):
video / backlight: add two APIs for drivers to use video / backlight: remove the backlight_device_registered API
Thermal: add INT3406 thermal driver
drivers/acpi/acpi_video.c | 83 ++++---- drivers/acpi/video_detect.c | 2 +- drivers/thermal/Kconfig | 28 +-- drivers/thermal/int340x_thermal/Kconfig | 42 ++++ drivers/thermal/int340x_thermal/Makefile | 1 + drivers/thermal/int340x_thermal/int3406_thermal.c | 236 ++++++++++++++++++++++ drivers/video/backlight/backlight.c | 39 ++-- include/acpi/video.h | 20 ++ include/linux/backlight.h | 3 +- 9 files changed, 374 insertions(+), 80 deletions(-) create mode 100644 drivers/thermal/int340x_thermal/Kconfig create mode 100644 drivers/thermal/int340x_thermal/int3406_thermal.c
Signature · 1 line
2.5.5
PATCH v3 1/4 video / backlight: add two APIs for drivers to use
It is useful to get the backlight device's pointer and use it to set backlight in some cases(the following patch will make use of it) so add the two APIs and export them.
--- drivers/video/backlight/backlight.c | 43 +++++++++++++++++++++++++------------ include/linux/backlight.h | 2 ++ 2 files changed, 31 insertions(+), 14 deletions(-)
drivers/video/backlight/backlight.c +29 -14
@@ -164,18 +164,10 @@ static ssize_t brightness_show(struct device *dev,return sprintf (buf,"%d\n" , bd->props.brightness); } -static ssize_t brightness_store (struct device *dev, -struct device_attribute *attr,const char *buf,size_t count) +int backlight_device_set_brightness (struct backlight_device *bd, +unsigned long brightness) { -int rc; -struct backlight_device *bd =to_backlight_device (dev); -unsigned long brightness; - - rc =kstrtoul (buf,0 , &brightness); -if (rc) -return rc; - - rc = -ENXIO ; +int rc = -ENXIO ;mutex_lock (&bd->ops_lock);if (bd->ops) {
@@ -185,7 +177,7 @@ static ssize_t brightness_store(struct device *dev,pr_debug ("set brightness to %lu\n" , brightness); bd->props.brightness = brightness;backlight_update_status (bd); - rc = count; + rc =0 ; } }mutex_unlock (&bd->ops_lock);
@@ -194,6 +186,23 @@ static ssize_t brightness_store(struct device *dev,return rc; } +EXPORT_SYMBOL (backlight_device_set_brightness); + +static ssize_t brightness_store (struct device *dev, +struct device_attribute *attr,const char *buf,size_t count) +{ +int rc; +struct backlight_device *bd =to_backlight_device (dev); +unsigned long brightness; + + rc =kstrtoul (buf,0 , &brightness); +if (rc) +return rc; + + rc =backlight_device_set_brightness (bd, brightness); + +return rc ? rc : count; +}static DEVICE_ATTR_RW (brightness); static ssize_t type_show(struct device *dev, struct device_attribute *attr,
@@ -380,7 +389,7 @@ struct backlight_device *backlight_device_register(const char *name, }EXPORT_SYMBOL (backlight_device_register); -bool backlight_device_registered (enum backlight_type type) +struct backlight_device *backlight_device_get_by_type (enum backlight_type type) {bool found = false;struct backlight_device *bd;
@@ -394,7 +403,13 @@ bool backlight_device_registered(enum backlight_type type) }mutex_unlock (&backlight_dev_list_mutex); -return found; +return found ? bd :NULL ; +} +EXPORT_SYMBOL (backlight_device_get_by_type); + +bool backlight_device_registered (enum backlight_type type) +{ +return backlight_device_get_by_type (type) ? true : false; }EXPORT_SYMBOL (backlight_device_registered);
include/linux/backlight.h +2 -0
@@ -144,6 +144,8 @@ extern void backlight_force_update(struct backlight_device *bd,extern bool backlight_device_registered (enum backlight_type type);extern int backlight_register_notifier (struct notifier_block *nb);extern int backlight_unregister_notifier (struct notifier_block *nb); +extern struct backlight_device *backlight_device_get_by_type (enum backlight_type type); +extern int backlight_device_set_brightness (struct backlight_device *bd,unsigned long brightness);#define to_backlight_device (obj) container_of(obj, struct backlight_device, dev)
Signature · 1 line
2.5.5
PATCH v3 2/4 video / backlight: remove the backlight_device_registered API
In reply to Aaron LuSince we will need the backlight_device_get_by_type API, we can use it instead of the backlight_device_registered API whenever necessary so remove the backlight_device_registered API.
--- drivers/acpi/video_detect.c | 2 +- drivers/video/backlight/backlight.c | 6 ------ include/linux/backlight.h | 1 - 3 files changed, 1 insertion(+), 8 deletions(-)
drivers/acpi/video_detect.c +1 -1
@@ -358,7 +358,7 @@ enum acpi_backlight_type acpi_video_get_backlight_type(void)if (!(video_caps &ACPI_VIDEO_BACKLIGHT ))return acpi_backlight_vendor; -if (acpi_osi_is_win8 () &&backlight_device_registered (BACKLIGHT_RAW )) +if (acpi_osi_is_win8 () &&backlight_device_get_by_type (BACKLIGHT_RAW ))return acpi_backlight_native;return acpi_backlight_video;
drivers/video/backlight/backlight.c +0 -6
@@ -407,12 +407,6 @@ struct backlight_device *backlight_device_get_by_type(enum backlight_type type) }EXPORT_SYMBOL (backlight_device_get_by_type); -bool backlight_device_registered (enum backlight_type type) -{ -return backlight_device_get_by_type (type) ? true : false; -} -EXPORT_SYMBOL (backlight_device_registered); -/** * backlight_device_unregister - unregisters a backlight device object. * @bd: the backlight device object to be unregistered and freed.
include/linux/backlight.h +0 -1
@@ -141,7 +141,6 @@ extern void devm_backlight_device_unregister(struct device *dev, struct backlight_device *bd);extern void backlight_force_update (struct backlight_device *bd,enum backlight_update_reason reason); -extern bool backlight_device_registered (enum backlight_type type);extern int backlight_register_notifier (struct notifier_block *nb);extern int backlight_unregister_notifier (struct notifier_block *nb);extern struct backlight_device *backlight_device_get_by_type (enum backlight_type type);
Signature · 1 line
2.5.5
PATCH v3 3/4 ACPI/video: export acpi_video_get_levels
In reply to Aaron LuThe acpi_video_get_levels is useful for other drivers, i.e. the to-be-added int3406 thermal driver, so export it.
--- drivers/acpi/acpi_video.c | 83 +++++++++++++++++++++++++---------------------- include/acpi/video.h | 20 ++++++++++++ 2 files changed, 65 insertions(+), 38 deletions(-)
drivers/acpi/acpi_video.c +45 -38
@@ -191,19 +191,6 @@ struct acpi_video_device_cap { u8 _DDC:1; /* Return the EDID for this device */ }; -struct acpi_video_brightness_flags { -u8 _BCL_no_ac_battery_levels:1 ;/* no AC/Battery levels in _BCL */ -u8 _BCL_reversed:1 ;/* _BCL package is in a reversed order */ -u8 _BQC_use_index:1 ;/* _BQC returns an index value */ -}; - -struct acpi_video_device_brightness { -int curr; -int count; -int *levels; -struct acpi_video_brightness_flags flags; -}; -struct acpi_video_device {unsigned long device_id;struct acpi_video_device_flags flags;
@@ -325,7 +312,7 @@ static const struct thermal_cooling_device_ops video_cooling_ops = {*/ static int -acpi_video_device_lcd_query_levels (struct acpi_video_device *device, +acpi_video_device_lcd_query_levels (acpi_handle handle,union acpi_object **levels) {int status;
@@ -335,7 +322,7 @@ acpi_video_device_lcd_query_levels(struct acpi_video_device *device, *levels =NULL ; - status =acpi_evaluate_object (device->dev->handle,"_BCL" ,NULL , &buffer); + status =acpi_evaluate_object (handle,"_BCL" ,NULL , &buffer);if (!ACPI_SUCCESS (status))return status; obj = (union acpi_object *)buffer.pointer;
@@ -766,36 +753,28 @@ static int acpi_video_bqc_quirk(struct acpi_video_device *device,return 0 ; } - -/* -* Arg: -* device : video output device (LCD, CRT, ..) -* -* Return Value: -* Maximum brightness level -* -* Allocate and initialize device->brightness. -*/ - -static int -acpi_video_init_brightness (struct acpi_video_device *device) +int acpi_video_get_levels (struct acpi_device *device, +struct acpi_video_device_brightness **dev_br) {union acpi_object *obj =NULL ;int i, max_level =0 , count =0 , level_ac_battery =0 ; -unsigned long long level, level_old;union acpi_object *o;struct acpi_video_device_brightness *br =NULL ; -int result = -EINVAL ; +int result =0 ;u32 value; -if (!ACPI_SUCCESS (acpi_video_device_lcd_query_levels (device, &obj))) { +if (!ACPI_SUCCESS (acpi_video_device_lcd_query_levels (device->handle, + &obj))) {ACPI_DEBUG_PRINT ((ACPI_DB_INFO ,"Could not query available " "LCD brightness level\n" )); + result = -ENODEV ; goto out; } -if (obj->package.count <2 ) +if (obj->package.count <2 ) { + result = -EINVAL ; goto out; + } br =kzalloc (sizeof (*br),GFP_KERNEL );if (!br) {
@@ -861,6 +840,38 @@ acpi_video_init_brightness(struct acpi_video_device *device) "Found unordered _BCL package")); br->count = count; + *dev_br = br; + +out: +kfree (obj); +return result; +out_free: +kfree (br); + goto out; +} +EXPORT_SYMBOL (acpi_video_get_levels); + +/* +* Arg: +* device : video output device (LCD, CRT, ..) +* +* Return Value: +* Maximum brightness level +* +* Allocate and initialize device->brightness. +*/ + +static int +acpi_video_init_brightness (struct acpi_video_device *device) +{ +int i, max_level =0 ; +unsigned long long level, level_old; +struct acpi_video_device_brightness *br =NULL ; +int result = -EINVAL ; + + result =acpi_video_get_levels (device->dev, &br); +if (result) +return result; device->brightness = br;/* _BQC uses INDEX while _BCL uses VALUE in some laptops */
@@ -903,17 +914,13 @@ set_level: goto out_free_levels;ACPI_DEBUG_PRINT ((ACPI_DB_INFO , -"found %d brightness levels\n" , count -2 )); -kfree (obj); -return result; +"found %d brightness levels\n" , br->count -2 )); +return 0 ; out_free_levels:kfree (br->levels); -out_free:kfree (br); -out: device->brightness =NULL ; -kfree (obj);return result; }
include/acpi/video.h +20 -0
@@ -4,6 +4,19 @@#include <linux/errno.h> /* for ENODEV */ #include <linux/types.h> /* for bool */ +struct acpi_video_brightness_flags { +u8 _BCL_no_ac_battery_levels:1 ;/* no AC/Battery levels in _BCL */ +u8 _BCL_reversed:1 ;/* _BCL package is in a reversed order */ +u8 _BQC_use_index:1 ;/* _BQC returns an index value */ +}; + +struct acpi_video_device_brightness { +int curr; +int count; +int *levels; +struct acpi_video_brightness_flags flags; +}; +struct acpi_device ;#define ACPI_VIDEO_CLASS "video"
@@ -37,6 +50,8 @@ extern void acpi_video_set_dmi_backlight_type(enum acpi_backlight_type type);* may change over time and should not be cached. */ extern bool acpi_video_handles_brightness_key_presses (void ); +extern int acpi_video_get_levels (struct acpi_device *device, +struct acpi_video_device_brightness **dev_br);#else static inline int acpi_video_register (void ) {return 0 ; }static inline void acpi_video_unregister (void ) {return ; }
@@ -56,6 +71,11 @@ static inline bool acpi_video_handles_brightness_key_presses(void) {return false; } +static int acpi_video_get_levels (struct acpi_device *device, +struct acpi_video_device_brightness **dev_br) +{ +return -ENODEV ; +}#endif #endif
Signature · 1 line
2.5.5
PATCH v3 4/4 Thermal: add INT3406 thermal driver
In reply to Aaron LuINT3406 ACPI device object resembles an ACPI video output device, but its _BCM is said to be deprecated and should not be used. So we will make use of the raw interface to do the actual cooling.
--- drivers/thermal/Kconfig | 28 +-- drivers/thermal/int340x_thermal/Kconfig | 42 ++++ drivers/thermal/int340x_thermal/Makefile | 1 + drivers/thermal/int340x_thermal/int3406_thermal.c | 236 ++++++++++++++++++++++ 4 files changed, 282 insertions(+), 25 deletions(-) create mode 100644 drivers/thermal/int340x_thermal/Kconfig create mode 100644 drivers/thermal/int340x_thermal/int3406_thermal.c
drivers/thermal/Kconfig +3 -25
@@ -338,31 +338,9 @@ config INTEL_QUARK_DTS_THERMAL hot & critical. The critical trip point default value is set by underlying BIOS/Firmware. -config INT340X_THERMAL - tristate "ACPI INT340X thermal drivers" - depends on X86 && ACPI - select THERMAL_GOV_USER_SPACE - select ACPI_THERMAL_REL - select ACPI_FAN - select INTEL_SOC_DTS_IOSF_CORE - select THERMAL_WRITABLE_TRIPS - help - Newer laptops and tablets that use ACPI may have thermal sensors and - other devices with thermal control capabilities outside the core - CPU/SOC, for thermal safety reasons. - They are exposed for the OS to use via the INT3400 ACPI device object - as the master, and INT3401~INT340B ACPI device objects as the slaves. - Enable this to expose the temperature information and cooling ability - from these objects to userspace via the normal thermal framework. - This means that a wide range of applications and GUI widgets can show - the information to the user or use this information for making - decisions. For example, the Intel Thermal Daemon can use this - information to allow the user to select his laptop to run without - turning on the fans. - -config ACPI_THERMAL_REL - tristate - depends on ACPI +menu "ACPI INT340X thermal drivers" +source drivers/thermal/int340x_thermal/Kconfig +endmenu config INTEL_PCH_THERMAL tristate "Intel PCH Thermal Reporting Driver"
drivers/thermal/int340x_thermal/Kconfig new file +42 -0
42 lines not on this page · raw message
drivers/thermal/int340x_thermal/Makefile +1 -0
@@ -3,4 +3,5 @@ obj-$(CONFIG_INT340X_THERMAL) += int340x_thermal_zone.o obj-$(CONFIG_INT340X_THERMAL) += int3402_thermal.o obj-$(CONFIG_INT340X_THERMAL) += int3403_thermal.o obj-$(CONFIG_INT340X_THERMAL) += processor_thermal_device.o +obj-$(CONFIG_INT3406_THERMAL) += int3406_thermal.o obj-$(CONFIG_ACPI_THERMAL_REL) += acpi_thermal_rel.o
drivers/thermal/int340x_thermal/int3406_thermal.c new file +236 -0
236 lines not on this page · raw message
Signature · 1 line
2.5.5
Quoted 29 lines · Aaron Lu
v3:
Split patch 3/3 in v2 into 2 patches: one makes changes toacpi_videoand one adds the int3406 driver as suggested by Rafael. There should be no functionality change compared to v2.v2:
The display thermal device represents the LED/LCD display panel that may or may not include touch support. The main function of the display thermal device is to allow control of the display brightness in order to address a thermal condition or to reduce power consumed by display device.Due to the way this thermal device changes brightness level is said to be deprecated so we are using the raw interface to do the actual backlight change. This requires the backlight core support so two new APIs are added and exported in patch 1/3. With this, the previous API
backlight_device_registeredcan be removed and this is done in patch 2/3. Patch 3/3 adds the new int3406 thermal driver.The 1st version is here:
http://thread.gmane.org/gmane.linux.acpi.devel/72619This whole series should go through the thermal tree if applied.
Aaron Lu (3):
video / backlight: add two APIs for drivers to use video / backlight: remove thebacklight_device_registeredAPI
Thermal: add INT3406 thermal driver
Quoted 12 lines
drivers/acpi/acpi_video.c | 83 ++++---- drivers/acpi/video_detect.c | 2 +- drivers/thermal/Kconfig | 28 +-- drivers/thermal/int340x_thermal/Kconfig | 42 ++++ drivers/thermal/int340x_thermal/Makefile | 1 + drivers/thermal/int340x_thermal/int3406_thermal.c | 236 ++++++++++++++++++++++ drivers/video/backlight/backlight.c | 39 ++-- include/acpi/video.h | 20 ++ include/linux/backlight.h | 3 +- 9 files changed, 374 insertions(+), 80 deletions(-) create mode 100644 drivers/thermal/int340x_thermal/Kconfig create mode 100644 drivers/thermal/int340x_thermal/int3406_thermal.c
The first three patches in this series look OK to me, so
for the [1-3/4].
That said it may be better if those three go in via ACPI. I can put them into a separate branch for Rui to pull from.
Please let me know what you think.
Quoted 45 lines · Rafael J. Wysocki
Quoted 29 lines · Aaron Lu
v3:
Split patch 3/3 in v2 into 2 patches: one makes changes toacpi_videoand one adds the int3406 driver as suggested by Rafael. There should be no functionality change compared to v2.v2:
The display thermal device represents the LED/LCD display panel that may or may not include touch support. The main function of the display thermal device is to allow control of the display brightness in order to address a thermal condition or to reduce power consumed by display device.Due to the way this thermal device changes brightness level is said to be deprecated so we are using the raw interface to do the actual backlight change. This requires the backlight core support so two new APIs are added and exported in patch 1/3. With this, the previous API
backlight_device_registeredcan be removed and this is done in patch 2/3. Patch 3/3 adds the new int3406 thermal driver.The 1st version is here:
http://thread.gmane.org/gmane.linux.acpi.devel/72619This whole series should go through the thermal tree if applied.
Aaron Lu (3):
video / backlight: add two APIs for drivers to use video / backlight: remove thebacklight_device_registeredAPI
Thermal: add INT3406 thermal driverQuoted 12 lines
drivers/acpi/acpi_video.c | 83 ++++---- drivers/acpi/video_detect.c | 2 +- drivers/thermal/Kconfig | 28 +-- drivers/thermal/int340x_thermal/Kconfig | 42 ++++ drivers/thermal/int340x_thermal/Makefile | 1 + drivers/thermal/int340x_thermal/int3406_thermal.c | 236 ++++++++++++++++++++++ drivers/video/backlight/backlight.c | 39 ++-- include/acpi/video.h | 20 ++ include/linux/backlight.h | 3 +- 9 files changed, 374 insertions(+), 80 deletions(-) create mode 100644 drivers/thermal/int340x_thermal/Kconfig create mode 100644 drivers/thermal/int340x_thermal/int3406_thermal.cThe first three patches in this series look OK to me, so
Quoted 8 lines
for the [1-3/4].
That said it may be better if those three go in via ACPI. I can put them into a separate branch for Rui to pull from.
Please let me know what you think.
I have no problem with that.
Regards,
Aaron
Quoted 48 lines · Aaron Lu
Quoted 47 lines · Rafael J. Wysocki
Quoted 29 lines · Aaron Lu
v3:
Split patch 3/3 in v2 into 2 patches: one makes changes toacpi_videoand one adds the int3406 driver as suggested by Rafael. There should be no functionality change compared to v2.v2:
The display thermal device represents the LED/LCD display panel that may or may not include touch support. The main function of the display thermal device is to allow control of the display brightness in order to address a thermal condition or to reduce power consumed by display device.Due to the way this thermal device changes brightness level is said to be deprecated so we are using the raw interface to do the actual backlight change. This requires the backlight core support so two new APIs are added and exported in patch 1/3. With this, the previous API
backlight_device_registeredcan be removed and this is done in patch 2/3. Patch 3/3 adds the new int3406 thermal driver.The 1st version is here:
http://thread.gmane.org/gmane.linux.acpi.devel/72619This whole series should go through the thermal tree if applied.
Aaron Lu (3):
video / backlight: add two APIs for drivers to use video / backlight: remove thebacklight_device_registeredAPI
Thermal: add INT3406 thermal driverQuoted 12 lines
drivers/acpi/acpi_video.c | 83 ++++---- drivers/acpi/video_detect.c | 2 +- drivers/thermal/Kconfig | 28 +-- drivers/thermal/int340x_thermal/Kconfig | 42 ++++ drivers/thermal/int340x_thermal/Makefile | 1 + drivers/thermal/int340x_thermal/int3406_thermal.c | 236 ++++++++++++++++++++++ drivers/video/backlight/backlight.c | 39 ++-- include/acpi/video.h | 20 ++ include/linux/backlight.h | 3 +- 9 files changed, 374 insertions(+), 80 deletions(-) create mode 100644 drivers/thermal/int340x_thermal/Kconfig create mode 100644 drivers/thermal/int340x_thermal/int3406_thermal.cThe first three patches in this series look OK to me, so
Quoted 8 lines
Quoted 6 lines
for the [1-3/4].
That said it may be better if those three go in via ACPI. I can put them into a separate branch for Rui to pull from.
Please let me know what you think.
I have no problem with that.
OK
[1-3/4] have been queued up for 4.7 in my tree. Please let me know if you want me to expose the branch containing them.
Thanks,
Rafael
Quoted 54 lines · Rafael J. Wysocki
Quoted 53 lines · Aaron Lu
Quoted 52 lines · Rafael J. Wysocki
Quoted 29 lines · Aaron Lu
v3:
Split patch 3/3 in v2 into 2 patches: one makes changes toacpi_videoand one adds the int3406 driver as suggested by Rafael. There should be no functionality change compared to v2.v2:
The display thermal device represents the LED/LCD display panel that may or may not include touch support. The main function of the display thermal device is to allow control of the display brightness in order to address a thermal condition or to reduce power consumed by display device.Due to the way this thermal device changes brightness level is said to be deprecated so we are using the raw interface to do the actual backlight change. This requires the backlight core support so two new APIs are added and exported in patch 1/3. With this, the previous API
backlight_device_registeredcan be removed and this is done in patch 2/3. Patch 3/3 adds the new int3406 thermal driver.The 1st version is here:
http://thread.gmane.org/gmane.linux.acpi.devel/72619This whole series should go through the thermal tree if applied.
Aaron Lu (3):
video / backlight: add two APIs for drivers to use video / backlight: remove thebacklight_device_registeredAPI
Thermal: add INT3406 thermal driverQuoted 12 lines
drivers/acpi/acpi_video.c | 83 ++++---- drivers/acpi/video_detect.c | 2 +- drivers/thermal/Kconfig | 28 +-- drivers/thermal/int340x_thermal/Kconfig | 42 ++++ drivers/thermal/int340x_thermal/Makefile | 1 + drivers/thermal/int340x_thermal/int3406_thermal.c | 236 ++++++++++++++++++++++ drivers/video/backlight/backlight.c | 39 ++-- include/acpi/video.h | 20 ++ include/linux/backlight.h | 3 +- 9 files changed, 374 insertions(+), 80 deletions(-) create mode 100644 drivers/thermal/int340x_thermal/Kconfig create mode 100644 drivers/thermal/int340x_thermal/int3406_thermal.cThe first three patches in this series look OK to me, so
for the [1-3/4].
That said it may be better if those three go in via ACPI. I can put them into a separate branch for Rui to pull from.
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
Please let me know what you think.
I have no problem with that.
OK
[1-3/4] have been queued up for 4.7 in my tree. Please let me know if you want me to expose the branch containing them.
Thanks a lot!
Rui,
Do you need a branch so that you can pull and merge 4/4 on top of that?
Regards,
Aaron
Zhang, Rui
reviewerRe: [PATCH v3 4/4] Thermal: add INT3406 thermal driver
In reply to Aaron LuT24gV2VkLCAyMDE2LTA0LTI3IGF0IDIwOjQ1ICswODAwLCBBYXJvbi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aCBteSBvdGhlciB0aGVybWFsIG1hdGVyaWFsLg0KDQp0aGFua3MsDQpydWkNCg=
PATCH v3 4/4 Thermal: add INT3406 thermal driver
In reply to Zhang, RuiINT3406 ACPI device object resembles an ACPI video output device, but its _BCM is said to be deprecated and should not be used. So we will make use of the raw interface to do the actual cooling.
---
update: change copyright to 2016 and license to GPL v2 as suggested by Rui.
drivers/thermal/Kconfig | 28 +-- drivers/thermal/int340x_thermal/Kconfig | 42 ++++ drivers/thermal/int340x_thermal/Makefile | 1 + drivers/thermal/int340x_thermal/int3406_thermal.c | 236 ++++++++++++++++++++++ 4 files changed, 282 insertions(+), 25 deletions(-) create mode 100644 drivers/thermal/int340x_thermal/Kconfig create mode 100644 drivers/thermal/int340x_thermal/int3406_thermal.c
drivers/thermal/Kconfig +3 -25
@@ -338,31 +338,9 @@ config INTEL_QUARK_DTS_THERMAL hot & critical. The critical trip point default value is set by underlying BIOS/Firmware. -config INT340X_THERMAL - tristate "ACPI INT340X thermal drivers" - depends on X86 && ACPI - select THERMAL_GOV_USER_SPACE - select ACPI_THERMAL_REL - select ACPI_FAN - select INTEL_SOC_DTS_IOSF_CORE - select THERMAL_WRITABLE_TRIPS - help - Newer laptops and tablets that use ACPI may have thermal sensors and - other devices with thermal control capabilities outside the core - CPU/SOC, for thermal safety reasons. - They are exposed for the OS to use via the INT3400 ACPI device object - as the master, and INT3401~INT340B ACPI device objects as the slaves. - Enable this to expose the temperature information and cooling ability - from these objects to userspace via the normal thermal framework. - This means that a wide range of applications and GUI widgets can show - the information to the user or use this information for making - decisions. For example, the Intel Thermal Daemon can use this - information to allow the user to select his laptop to run without - turning on the fans. - -config ACPI_THERMAL_REL - tristate - depends on ACPI +menu "ACPI INT340X thermal drivers" +source drivers/thermal/int340x_thermal/Kconfig +endmenu config INTEL_PCH_THERMAL tristate "Intel PCH Thermal Reporting Driver"
drivers/thermal/int340x_thermal/Kconfig new file +42 -0
42 lines not on this page · raw message
drivers/thermal/int340x_thermal/Makefile +1 -0
@@ -3,4 +3,5 @@ obj-$(CONFIG_INT340X_THERMAL) += int340x_thermal_zone.o obj-$(CONFIG_INT340X_THERMAL) += int3402_thermal.o obj-$(CONFIG_INT340X_THERMAL) += int3403_thermal.o obj-$(CONFIG_INT340X_THERMAL) += processor_thermal_device.o +obj-$(CONFIG_INT3406_THERMAL) += int3406_thermal.o obj-$(CONFIG_ACPI_THERMAL_REL) += acpi_thermal_rel.o
drivers/thermal/int340x_thermal/int3406_thermal.c new file +236 -0
236 lines not on this page · raw message
Signature · 1 line
2.5.5
Rafael J. Wysocki
maintainerQuoted 65 lines · Rui
Quoted 64 lines · Aaron Lu
Quoted 62 lines · Rafael J. Wysocki
Quoted 48 lines · Aaron Lu
Quoted 47 lines · Rafael J. Wysocki
Quoted 29 lines · Aaron Lu
v3:
Split patch 3/3 in v2 into 2 patches: one makes changes toacpi_videoand one adds the int3406 driver as suggested by Rafael. There should be no functionality change compared to v2.v2:
The display thermal device represents the LED/LCD display panel that may or may not include touch support. The main function of the display thermal device is to allow control of the display brightness in order to address a thermal condition or to reduce power consumed by display device.Due to the way this thermal device changes brightness level is said to be deprecated so we are using the raw interface to do the actual backlight change. This requires the backlight core support so two new APIs are added and exported in patch 1/3. With this, the previous API
backlight_device_registeredcan be removed and this is done in patch 2/3. Patch 3/3 adds the new int3406 thermal driver.The 1st version is here:
http://thread.gmane.org/gmane.linux.acpi.devel/72619This whole series should go through the thermal tree if applied.
Aaron Lu (3):
video / backlight: add two APIs for drivers to use video / backlight: remove thebacklight_device_registeredAPI
Thermal: add INT3406 thermal driverQuoted 12 lines
drivers/acpi/acpi_video.c | 83 ++++---- drivers/acpi/video_detect.c | 2 +- drivers/thermal/Kconfig | 28 +-- drivers/thermal/int340x_thermal/Kconfig | 42 ++++ drivers/thermal/int340x_thermal/Makefile | 1 + drivers/thermal/int340x_thermal/int3406_thermal.c | 236 ++++++++++++++++++++++ drivers/video/backlight/backlight.c | 39 ++-- include/acpi/video.h | 20 ++ include/linux/backlight.h | 3 +- 9 files changed, 374 insertions(+), 80 deletions(-) create mode 100644 drivers/thermal/int340x_thermal/Kconfig create mode 100644 drivers/thermal/int340x_thermal/int3406_thermal.cThe first three patches in this series look OK to me, so
Quoted 8 lines
Quoted 6 lines
for the [1-3/4].
That said it may be better if those three go in via ACPI. I can put them into a separate branch for Rui to pull from.
Please let me know what you think.
I have no problem with that.
OK
[1-3/4] have been queued up for 4.7 in my tree. Please let me know if you want me to expose the branch containing them.
Quoted 8 lines
Quoted 6 lines
Thanks a lot!
Rui,
Do you need a branch so that you can pull and merge 4/4 on top of that?
Rafael, can you please take patch 4/4 as well? It should not conflict with my other thermal material.
I can do that, but can you please ACK it for me?
Re: [PATCH v3 update 4/4] Thermal: add INT3406 thermal driver
In reply to Aaron LuQuoted 5 lines · Aaron Lu
INT3406 ACPI device object resembles an ACPI video output device, but its
_BCMis said to be deprecated and should not be used. So we will make use of the raw interface to do the actual cooling.Signed-off-by Aaron Lu <[email protected]>
Quoted 350 lines
---
update: change copyright to 2016 and license to GPL v2 as suggested by Rui.drivers/thermal/Kconfig | 28 +-- drivers/thermal/int340x_thermal/Kconfig | 42 ++++ drivers/thermal/int340x_thermal/Makefile | 1 + drivers/thermal/int340x_thermal/int3406_thermal.c | 236 ++++++++++++++++++++++ 4 files changed, 282 insertions(+), 25 deletions(-) create mode 100644 drivers/thermal/int340x_thermal/Kconfig create mode 100644 drivers/thermal/int340x_thermal/int3406_thermal.cdrivers/thermal/Kconfig +3
-25@@ -338,31 +338,9 @@ config INTEL_QUARK_DTS_THERMAL hot & critical. The critical trip point default value is set by underlying BIOS/Firmware. -config INT340X_THERMAL - tristate "ACPI INT340X thermal drivers" - depends on X86 && ACPI - select THERMAL_GOV_USER_SPACE - select ACPI_THERMAL_REL - select ACPI_FAN - select INTEL_SOC_DTS_IOSF_CORE - select THERMAL_WRITABLE_TRIPS - help - Newer laptops and tablets that use ACPI may have thermal sensors and - other devices with thermal control capabilities outside the core - CPU/SOC, for thermal safety reasons. - They are exposed for the OS to use via the INT3400 ACPI device object - as the master, and INT3401~INT340B ACPI device objects as the slaves. - Enable this to expose the temperature information and cooling ability - from these objects to userspace via the normal thermal framework. - This means that a wide range of applications and GUI widgets can show - the information to the user or use this information for making - decisions. For example, the Intel Thermal Daemon can use this - information to allow the user to select his laptop to run without - turning on the fans. - -config ACPI_THERMAL_REL - tristate - depends on ACPI +menu "ACPI INT340X thermal drivers" +source drivers/thermal/int340x_thermal/Kconfig +endmenu config INTEL_PCH_THERMAL tristate "Intel PCH Thermal Reporting Driver"drivers/thermal/int340x_thermal/Kconfig new file +42
-0@@ -0,0 +1,42 @@ +# +# ACPI INT340x thermal drivers configuration +# + +config INT340X_THERMAL + tristate "ACPI INT340X thermal drivers" + depends on X86 && ACPI + select THERMAL_GOV_USER_SPACE + select ACPI_THERMAL_REL + select ACPI_FAN + select INTEL_SOC_DTS_IOSF_CORE + help + Newer laptops and tablets that use ACPI may have thermal sensors and + other devices with thermal control capabilities outside the core + CPU/SOC, for thermal safety reasons. + They are exposed for the OS to use via the INT3400 ACPI device object + as the master, and INT3401~INT340B ACPI device objects as the slaves. + Enable this to expose the temperature information and cooling ability + from these objects to userspace via the normal thermal framework. + This means that a wide range of applications and GUI widgets can show + the information to the user or use this information for making + decisions. For example, the Intel Thermal Daemon can use this + information to allow the user to select his laptop to run without + turning on the fans. + +config ACPI_THERMAL_REL + tristate + depends on ACPI + +if INT340X_THERMAL + +config INT3406_THERMAL + tristate "ACPI INT3406 display thermal driver" + depends on ACPI_VIDEO + help + The display thermal device represents the LED/LCD display panel + that may or may not include touch support. The main function of + the display thermal device is to allow control of the display + brightness in order to address a thermal condition or to reduce + power consumed by display device. + +endifdrivers/thermal/int340x_thermal/Makefile +1
-0@@ -3,4 +3,5 @@ obj-$(CONFIG_INT340X_THERMAL) += int340x_thermal_zone.o obj-$(CONFIG_INT340X_THERMAL) += int3402_thermal.o obj-$(CONFIG_INT340X_THERMAL) += int3403_thermal.o obj-$(CONFIG_INT340X_THERMAL) += processor_thermal_device.o +obj-$(CONFIG_INT3406_THERMAL) += int3406_thermal.o obj-$(CONFIG_ACPI_THERMAL_REL) += acpi_thermal_rel.odrivers/thermal/int340x_thermal/int3406_thermal.c new file +236
-0@@ -0,0 +1,236 @@ +/* +* INT3406 thermal driver for display participant device +* +* Copyright (C) 2016, Intel Corporation +* Authors: Aaron Lu <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +*/ + +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/acpi.h> +#include <linux/backlight.h> +#include <linux/thermal.h> +#include <acpi/video.h> + +#define INT3406_BRIGHTNESS_LIMITS_CHANGED 0x80 + +struct int3406_thermal_data { +int upper_limit; +int upper_limit_index; +int lower_limit; +int lower_limit_index; +acpi_handle handle; +struct acpi_video_device_brightness *br; +struct backlight_device *raw_bd; +struct thermal_cooling_device *cooling_dev; +}; + +static int int3406_thermal_to_raw (int level,struct int3406_thermal_data *d) +{ +int max_level = d->br->levels[d->br->count -1 ]; +int raw_max = d->raw_bd->props.max_brightness; + +return level * raw_max / max_level; +} + +static int int3406_thermal_to_acpi (int level,struct int3406_thermal_data *d) +{ +int raw_max = d->raw_bd->props.max_brightness; +int max_level = d->br->levels[d->br->count -1 ]; + +return level * max_level / raw_max; +} + +static int +int3406_thermal_get_max_state (struct thermal_cooling_device *cooling_dev, +unsigned long *state) +{ +struct int3406_thermal_data *d = cooling_dev->devdata; +int index = d->lower_limit_index ? d->lower_limit_index :2 ; + + *state = d->br->count -1 - index; +return 0 ; +} + +static int +int3406_thermal_set_cur_state (struct thermal_cooling_device *cooling_dev, +unsigned long state) +{ +struct int3406_thermal_data *d = cooling_dev->devdata; +int level, raw_level; + +if (state > d->br->count -3 ) +return -EINVAL ; + + state = d->br->count -1 - state; + level = d->br->levels[state]; + +if ((d->upper_limit && level > d->upper_limit) || + (d->lower_limit && level < d->lower_limit)) +return -EINVAL ; + + raw_level =int3406_thermal_to_raw (level, d); +return backlight_device_set_brightness (d->raw_bd, raw_level); +} + +static int +int3406_thermal_get_cur_state (struct thermal_cooling_device *cooling_dev, +unsigned long *state) +{ +struct int3406_thermal_data *d = cooling_dev->devdata; +int raw_level, level, i; +int *levels = d->br->levels; + + raw_level = d->raw_bd->props.brightness; + level =int3406_thermal_to_acpi (raw_level, d); + +/* +* There is no 1:1 mapping between the firmware interface level with the +* raw interface level, we will have to find one that is close enough. +*/ +for (i =2 ; i < d->br->count; i++) { +if (level < levels[i]) { +if (i ==2 ) +break ; +if ((level - levels[i -1 ]) < (levels[i] - level)) + i--; +break ; + } + } + + *state = d->br->count -1 - i; +return 0 ; +} + +static const struct thermal_cooling_device_ops video_cooling_ops = { + .get_max_state = int3406_thermal_get_max_state, + .get_cur_state = int3406_thermal_get_cur_state, + .set_cur_state = int3406_thermal_set_cur_state, +}; + +static int int3406_thermal_get_index (int *array,int nr,int value) +{ +int i; + +for (i =0 ; i < nr; i++) { +if (array[i] == value) +break ; + } +return i == nr ? -ENOENT : i; +} + +static void int3406_thermal_get_limit (struct int3406_thermal_data *d) +{ +acpi_status status; +unsigned long long lower_limit, upper_limit; +int index; + + status =acpi_evaluate_integer (d->handle,"DDDL" ,NULL , &lower_limit); +if (ACPI_SUCCESS (status)) { + index =int3406_thermal_get_index (d->br->levels, d->br->count, + lower_limit); +if (index >0 ) { + d->lower_limit = (int )lower_limit; + d->lower_limit_index = index; + } + } + + status =acpi_evaluate_integer (d->handle,"DDPC" ,NULL , &upper_limit); +if (ACPI_SUCCESS (status)) { + index =int3406_thermal_get_index (d->br->levels, d->br->count, + upper_limit); +if (index >0 ) { + d->upper_limit = (int )upper_limit; + d->upper_limit_index = index; + } + } +} + +static void int3406_notify (acpi_handle handle,u32 event,void *data) +{ +if (event ==INT3406_BRIGHTNESS_LIMITS_CHANGED ) +int3406_thermal_get_limit (data); +} + +static int int3406_thermal_probe (struct platform_device *pdev) +{ +struct acpi_device *adev =ACPI_COMPANION (&pdev->dev); +struct int3406_thermal_data *d; +struct backlight_device *bd; +int ret; + +if (!ACPI_HANDLE (&pdev->dev)) +return -ENODEV ; + + d =devm_kzalloc (&pdev->dev,sizeof (*d),GFP_KERNEL ); +if (!d) +return -ENOMEM ; + d->handle =ACPI_HANDLE (&pdev->dev); + + bd =backlight_device_get_by_type (BACKLIGHT_RAW ); +if (!bd) +return -ENODEV ; + d->raw_bd = bd; + + ret =acpi_video_get_levels (ACPI_COMPANION (&pdev->dev), &d->br); +if (ret) +return ret; + +int3406_thermal_get_limit (d); + + d->cooling_dev =thermal_cooling_device_register (acpi_device_bid (adev), + d, &video_cooling_ops); +if (IS_ERR (d->cooling_dev)) + goto err; + + ret =acpi_install_notify_handler (adev->handle,ACPI_DEVICE_NOTIFY , + int3406_notify, d); +if (ret) + goto err_cdev; + +platform_set_drvdata (pdev, d); + +return 0 ; + +err_cdev: +thermal_cooling_device_unregister (d->cooling_dev); +err: +kfree (d->br); +return -ENODEV ; +} + +static int int3406_thermal_remove (struct platform_device *pdev) +{ +struct int3406_thermal_data *d =platform_get_drvdata (pdev); + +thermal_cooling_device_unregister (d->cooling_dev); +kfree (d->br); +return 0 ; +} + +static const struct acpi_device_id int3406_thermal_match[] = { + {"INT3406" ,0 }, + {} +}; + +MODULE_DEVICE_TABLE (acpi, int3406_thermal_match); + +static struct platform_driver int3406_thermal_driver = { + .probe = int3406_thermal_probe, + .remove = int3406_thermal_remove, + .driver = { + .name ="int3406 thermal" , + .owner =THIS_MODULE , + .acpi_match_table = int3406_thermal_match, + }, +}; + +module_platform_driver (int3406_thermal_driver); + +MODULE_DESCRIPTION ("INT3406 Thermal driver" ); +MODULE_LICENSE ("GPL v2" );
Rafael J. Wysocki
AppliedRe: [PATCH v3 update 4/4] Thermal: add INT3406 thermal driver
Quoted 8 lines · Rui
Quoted 5 lines · Aaron Lu
INT3406 ACPI device object resembles an ACPI video output device, but its
_BCMis said to be deprecated and should not be used. So we will make use of the raw interface to do the actual cooling.Signed-off-by Aaron Lu <[email protected]>Acked-by Zhang Rui <[email protected]>
Applied, thanks!