文件最后提交记录最后更新时间
add thermal log param watch dac for other process Signed-off-by: 零初 <1751382099@qq.com>1 年前
fix: resolve UB in CanonicalizeSpecPath error handling When src is nullptr, using it as fprintf argument causes undefined behavior. Fix by removing the null pointer from the error message. Closes #6728 Co-Authored-By: Agent Change-Id: I2a13a2024dcca627085387126e16e9f9ba017b66 Signed-off-by: cjw123qq <chenjunwu4@huawei.com> 19 天前
!8333 merge flexArch into master feat: changed resource location for flex arch Created-by: z30053694 Commit-by: z30053694 Merged-by: openharmony_ci Description: ### 相关的Issue https://gitcode.com/openharmony/powermgr_power_manager/issues/1604 ### 原因(目的、解决的问题等) 系统和芯片组件互相访问资源整改 ### 描述(做了什么,变更了什么) 系统和芯片组件互相访问资源整改 ### 测试用例(新增、改动、可能影响的功能) See merge request: openharmony/drivers_peripheral!83335 个月前
fix: rename idl target group name Signed-off-by: yuanbo <yuanbo@huawei.com> 3 年前
fix: add readme docs Signed-off-by: kong-wei-111 <kongwei13@h-partners.com> Co-Authored-By: Agent 1 个月前
fix: add readme docs Signed-off-by: kong-wei-111 <kongwei13@h-partners.com> Co-Authored-By: Agent 1 个月前
feat: data hisysevent Signed-off-by: yanghang <kongwei13@h-partners.com> 1 年前
feat: data hisysevent Signed-off-by: yanghang <kongwei13@h-partners.com> 1 年前
feat: data hisysevent Signed-off-by: yanghang <kongwei13@h-partners.com> 1 年前
README.md

Thermal

Introduction

This repository contains the Thermal module HDI (Hardware Driver Interface) definitions and implementations, providing temperature management driver capability interfaces for upper-layer system services. The Thermal HDI interfaces mainly include:

  • Thermal Zone: Responsible for obtaining thermal zone temperature information.
  • Thermal Mitigation: Responsible for thermal mitigation strategy management, including CPU frequency adjustment, GPU frequency adjustment, battery current limit, etc.
  • CPU Isolation: Responsible for CPU core isolation management.
  • Callback: Responsible for thermal event callback notifications.

Directory

The source code directory structure is as follows:

/drivers/peripheral/thermal
├── etc                      # Thermal module configuration files
├── interfaces              # Thermal module driver capability interfaces for upper-layer services
│   └── hdi_service          # HDI layer framework code
│       ├── include          # Header files
│       ├── profile          # Configuration files
│       └── src              # HDI layer source code
├── test                     # Thermal module test code
│   ├── unittest             # Unit tests
│   └── fuzztest             # Fuzz tests
└── utils                    # Utility code

Interface Description

The Thermal driver module provides interfaces to upper-layer system services through the HDI layer, with main functions including: obtaining thermal zone information, setting thermal mitigation strategies, CPU isolation, etc. The provided interfaces are shown in Table1 Thermal HDI Interface List:

Table 1 Thermal HDI Interface List

Header File

Interface Name

Function Description

v1_1/ithermal_interface.h

int32_t SetCpuFreq(int32_t freq);

Set CPU frequency

int32_t SetGpuFreq(int32_t freq);

Set GPU frequency

int32_t SetBatteryCurrent(int32_t current);

Set battery current

int32_t GetThermalZoneInfo(HdfThermalCallbackInfo& event);

Get thermal zone info

int32_t IsolateCpu(int32_t num);

Isolate CPU core

int32_t Register(const sptr& callbackObj);

Register thermal callback

int32_t Unregister();

Unregister thermal callback

int32_t RegisterFanCallback(const sptr& callbackObj);

Register fan callback

int32_t UnregisterFanCallback();

Unregister fan callback

Usage Instructions

The core function of this repository is to provide temperature management driver capability interfaces for upper-layer system services. The provided driver capability interfaces are unified as HDI interface layer.

The following sample code demonstrates how to use the Thermal HDI interface:

#include "v1_1/ithermal_interface.h"
#include "thermal_hdi_client.h"

using namespace OHOS::HDI::Thermal::V1_1;

class ThermalCallbackImpl : public IThermalCallback {
public:
    int32_t OnThermalCallback(HdfThermalCallbackInfo& event) override
    {
        HDF_LOGI("ThermalCallback: zoneId=%{public}d, temp=%{public}d", 
                 event.zoneId, event.temperature);
        return 0;
    }
};

static int32_t ThermalHdiSample(void)
{
    int32_t ret;
    sptr<IThermalInterface> g_thermalInterface = ThermalHdiClient::GetInstance();

    if (g_thermalInterface == nullptr) {
        HDF_LOGE("get thermal interface failed");
        return HDF_FAILURE;
    }

    // Register thermal callback
    sptr<IThermalCallback> callback = new (std::nothrow) ThermalCallbackImpl();
    ret = g_thermalInterface->Register(callback);
    if (ret != HDF_SUCCESS) {
        HDF_LOGE("register thermal callback failed");
        return ret;
    }

    // Set CPU frequency
    ret = g_thermalInterface->SetCpuFreq(2000000);
    if (ret != HDF_SUCCESS) {
        HDF_LOGE("set cpu freq failed");
        return ret;
    }

    // Set GPU frequency
    ret = g_thermalInterface->SetGpuFreq(800000);
    if (ret != HDF_SUCCESS) {
        HDF_LOGE("set gpu freq failed");
        return ret;
    }

    // Set battery current
    ret = g_thermalInterface->SetBatteryCurrent(1000);
    if (ret != HDF_SUCCESS) {
        HDF_LOGE("set battery current failed");
        return ret;
    }

    // Isolate CPU core
    ret = g_thermalInterface->IsolateCpu(4);
    if (ret != HDF_SUCCESS) {
        HDF_LOGE("isolate cpu failed");
        return ret;
    }

    // Get thermal zone info
    HdfThermalCallbackInfo event;
    ret = g_thermalInterface->GetThermalZoneInfo(event);
    if (ret != HDF_SUCCESS) {
        HDF_LOGE("get thermal zone info failed");
        return ret;
    }

    // Unregister thermal callback
    ret = g_thermalInterface->Unregister();
    if (ret != HDF_SUCCESS) {
        HDF_LOGE("unregister thermal callback failed");
        return ret;
    }

    return HDF_SUCCESS;
}

Driver Subsystem

drivers_framework

drivers_adapter

drivers_interface

drivers_peripheral