在哪里可以找到 AOSP 项目中 Android HAL 实际实现的源代码?

Where can I find source code of actual implementation of Android HALs in AOSP project?

我开始从一个osp 项目中学习android os 内部知识。在阅读了 android HAL 之后,我有兴趣研究一些与内核驱动程序对话的 HAL 模块的实际实现。我在 android/hardware/interfaces 下找到的是某种胶水代码。这个胶水代码必须加载实际的 HAL 模块,它可以打开一些设备并与真实的硬件通信。

那么在哪里可以找到与真实硬件对话的 HAL 的实际实现?

我基本上是在查看图形堆栈,如果有人可以指出 hwcomposer 和 gralloc 的 HAL 实现,那就太好了。在 android 个模拟器中使用的通用或开源的。

我从另一个论坛上了解到,它是由 OEM 提供的。但是考虑到 android 模拟器,我希望在某个地方的 osp 下找到它们。至少对于一些通用组件。

考虑到 SOC 供应商提供了一些 HAL,并且还有相同 HAL 的开源版本(假设供应商 hwcomposer 和 drm_hwcomposer)这是在哪里配置的,要使用哪个?

了解 HAL 代码流的任何资源 link 也会有所帮助。

So where to find the Actual implementation of the HALs that talk to the real hardware?

HAL 实现必须由 vendor/OEM 提供。这是您可以找到来源的地方。

对于大多数 HAL,Android 附带一个虚拟实现,通常只提供最低限度以避免系统崩溃,这是非常少的。我还没有检查所有的 HAL。您可以在 hardware/interfaces/<hal>/<version>/default 中找到这些虚拟实现。有时他们将实现包装在 hardware/libhardware 下的旧 HAL 接口中。您找到真正 hardware/kernel 访问权限的最佳机会就在这里。但是,这些实现可能已过时且不再使用。

Considering SOC vendors provide some HALs and there is also open source version of the same HAL (lets say vendor hwcomposer and drm_hwcomposer) where is this configured, which one to use?

要包含在设备中的 HAL 实现必须在设备清单中配置(例如 device/<vendor>/<board>/device.mk),如下所示:

PRODUCT_PACKAGES += hwcomposer.<vendor>

Any resource link to understand the code flow of HALs would be also helpful.

https://source.android.com/devices/architecture/hidl 上的官方文档是一个很好的资源。

自从 Android 使用 Android 8 几乎更改了有关 HAL 接口的所有内容,您可以通过搜索讨论 Treble 的文章找到更多信息。