自 2025 年 3 月 27 日起,我們建議您使用 android-latest-release
而非 aosp-main
建構及貢獻 AOSP。詳情請參閱「Android 開放原始碼計畫變更」。
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
hw_module_t 結構體參考資料
#include <
hardware.h
>
每個硬體模組都必須有名為 HAL_MODULE_INFO_SYM 的資料結構,且此資料結構的欄位必須以
hw_module_t
開頭,後面接著模組專屬資訊。
定義位於檔案
hardware.h
的
86
行。
uint16_t module_api_version
|
已實作模組的 API 版本。模組介面變更時,模組擁有者必須負責更新版本。
衍生模組 (例如 gralloc 和音訊) 會擁有並管理這個欄位。模組使用者必須解讀版本欄位,決定是否要與提供的模組實作項目進行互動。舉例來說,SurfaceFlinger 負責確保自己知道如何管理不同版本的 gralloc-module API,而 AudioFlinger 必須知道如何為 audio-module API 執行相同的操作。
模組 API 版本應包含主要和次要元件。舉例來說,1.0 版可表示為 0x0100。這個格式表示版本 0x0100-0x01ff 皆與 API 相容。
日後,libhardware 將公開 hw_get_module_version() (或同等) 函式,該函式會將支援的最低/最高版本做為引數,並可拒絕版本超出提供範圍的模組。
定義位於檔案
hardware.h
的
111
行。
這個結構體的說明文件是由下列檔案產生:
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-07-27 (世界標準時間)。"],[],[],null,["# Android Hardware Abstraction Layer: hw_module_t Struct Reference\n\nhw_module_t Struct Reference\n============================\n\n[Data Fields](#pub-attribs) \nhw_module_t Struct Reference \n\n`\n#include \u003c\n`[hardware.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/hardware.h)`\n\u003e\n`\n\n|------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------|\n| Data Fields ----------- ||\n| uint32_t | [tag](/reference/hal/structhw__module__t#a1c50fcd1195659821729f52af8f3bb7d) |\n| ||\n| uint16_t | [module_api_version](/reference/hal/structhw__module__t#a5b80425dcc298281d75edaa9a8083ccb) |\n| ||\n| uint16_t | [hal_api_version](/reference/hal/structhw__module__t#ab37ccc85f1197981a04116244354874f) |\n| ||\n| const char \\* | [id](/reference/hal/structhw__module__t#aeffa2f0815ce90fecbda9aac199143db) |\n| ||\n| const char \\* | [name](/reference/hal/structhw__module__t#a8f8f80d37794cde9472343e4487ba3eb) |\n| ||\n| const char \\* | [author](/reference/hal/structhw__module__t#adc89bc26ec139d32e904360eeef3cca8) |\n| ||\n| struct [hw_module_methods_t](/reference/hal/structhw__module__methods__t) \\* | [methods](/reference/hal/structhw__module__t#ae5b7afff8f18102ffd7577cd95e0ad83) |\n| ||\n| void \\* | [dso](/reference/hal/structhw__module__t#a8586652230f2639b4ee04adaf37e8348) |\n| ||\n| uint32_t | [reserved](/reference/hal/structhw__module__t#a41d9ba252fcb951e005e4b8c3bfc6803) \\[32-7\\] |\n| ||\n\n\nDetailed Description\n--------------------\n\n\nEvery hardware module must have a data structure named HAL_MODULE_INFO_SYM and the fields of this data structure must begin with\n[hw_module_t](/reference/hal/structhw__module__t)\nfollowed by module specific information.\n\n\nDefinition at line\n[86](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/hardware.h)\nof file\n[hardware.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/hardware.h)\n.\n\nField Documentation\n-------------------\n\n\n|---------------------|\n| const char\\* author |\n\n\nAuthor/owner/implementor of the module\n\n\nDefinition at line\n[139](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/hardware.h)\nof file\n[hardware.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/hardware.h)\n.\n\n|------------|\n| void\\* dso |\n\n\nmodule's dso\n\n\nDefinition at line\n[145](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/hardware.h)\nof file\n[hardware.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/hardware.h)\n.\n\n|--------------------------|\n| uint16_t hal_api_version |\n\n\nversion_major/version_minor defines are supplied here for temporary source code compatibility. They will be removed in the next version. ALL clients must convert to the new version format. The API version of the HAL module interface. This is meant to version the\n[hw_module_t](/reference/hal/structhw__module__t)\n,\n[hw_module_methods_t](/reference/hal/structhw__module__methods__t)\n, and\n[hw_device_t](/reference/hal/structhw__device__t)\nstructures and definitions.\n\n\nThe HAL interface owns this field. Module users/implementations must NOT rely on this value for version information.\n\n\nPresently, 0 is the only valid value.\n\n\nDefinition at line\n[129](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/hardware.h)\nof file\n[hardware.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/hardware.h)\n.\n\n|-----------------|\n| const char\\* id |\n\n\nIdentifier of module\n\n\nDefinition at line\n[133](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/hardware.h)\nof file\n[hardware.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/hardware.h)\n.\n\n|--------------------------------------------------------------------------------------|\n| struct [hw_module_methods_t](/reference/hal/structhw__module__methods__t) \\* methods |\n\n\nModules methods\n\n\nDefinition at line\n[142](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/hardware.h)\nof file\n[hardware.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/hardware.h)\n.\n\n|-----------------------------|\n| uint16_t module_api_version |\n\n\nThe API version of the implemented module. The module owner is responsible for updating the version when a module interface has changed.\n\n\nThe derived modules such as gralloc and audio own and manage this field. The module user must interpret the version field to decide whether or not to inter-operate with the supplied module implementation. For example, SurfaceFlinger is responsible for making sure that it knows how to manage different versions of the gralloc-module API, and AudioFlinger must know how to do the same for audio-module API.\n\n\nThe module API version should include a major and a minor component. For example, version 1.0 could be represented as 0x0100. This format implies that versions 0x0100-0x01ff are all API-compatible.\n\n\nIn the future, libhardware will expose a hw_get_module_version() (or equivalent) function that will take minimum/maximum supported versions as arguments and would be able to reject modules with versions outside of the supplied range.\n\n\nDefinition at line\n[111](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/hardware.h)\nof file\n[hardware.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/hardware.h)\n.\n\n|-------------------|\n| const char\\* name |\n\n\nName of this module\n\n\nDefinition at line\n[136](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/hardware.h)\nof file\n[hardware.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/hardware.h)\n.\n\n|---------------------------|\n| uint32_t reserved\\[32-7\\] |\n\n\npadding to 128 bytes, reserved for future use\n\n\nDefinition at line\n[151](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/hardware.h)\nof file\n[hardware.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/hardware.h)\n.\n\n|--------------|\n| uint32_t tag |\n\n\ntag must be initialized to HARDWARE_MODULE_TAG\n\n\nDefinition at line\n[88](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/hardware.h)\nof file\n[hardware.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/hardware.h)\n.\n\n*** ** * ** ***\n\nThe documentation for this struct was generated from the following file:\n\n- hardware/libhardware/include/hardware/ [hardware.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/hardware.h)"]]