導航:首頁 > 操作系統 > androidgralloc

androidgralloc

發布時間:2022-08-29 11:09:45

android中camera的hal模塊怎麼被調用

CameraService.cpp (frameworks\base\services\camera\libcameraservice)

中調用hw_get_mole

[cpp] view plain print?
void CameraService::onFirstRef()
{
BnCameraService::onFirstRef();

<span style="color: rgb(255, 0, 0);">if (hw_get_mole(CAMERA_HARDWARE_MODULE_ID,
(const hw_mole_t **)&mMole) < 0)</span> {
LOGE("Could not load camera HAL mole");
mNumberOfCameras = 0;
}
else {
mNumberOfCameras = mMole->get_number_of_cameras();
if (mNumberOfCameras > MAX_CAMERAS) {
LOGE("Number of cameras(%d) > MAX_CAMERAS(%d).",
mNumberOfCameras, MAX_CAMERAS);
mNumberOfCameras = MAX_CAMERAS;
}
for (int i = 0; i < mNumberOfCameras; i++) {
setCameraFree(i);
}
}
}
void CameraService::onFirstRef()
{
BnCameraService::onFirstRef();

if (hw_get_mole(CAMERA_HARDWARE_MODULE_ID,
(const hw_mole_t **)&mMole) < 0) {
LOGE("Could not load camera HAL mole");
mNumberOfCameras = 0;
}
else {
mNumberOfCameras = mMole->get_number_of_cameras();
if (mNumberOfCameras > MAX_CAMERAS) {
LOGE("Number of cameras(%d) > MAX_CAMERAS(%d).",
mNumberOfCameras, MAX_CAMERAS);
mNumberOfCameras = MAX_CAMERAS;
}
for (int i = 0; i < mNumberOfCameras; i++) {
setCameraFree(i);
}
}
}

看一下hw_get_mole是怎麼回事

[cpp] view plain print?
int hw_get_mole(const char *id, const struct hw_mole_t **mole)
{
return <span style="color: rgb(255, 0, 0);">hw_get_mole_by_class(id, NULL, mole);
</span>}
int hw_get_mole(const char *id, const struct hw_mole_t **mole)
{
return hw_get_mole_by_class(id, NULL, mole);
}

他只是一個封裝實際調用了[email protected] (hardware\libhardware)
好在不長,看看吧

[cpp] view plain print?
int hw_get_mole_by_class(const char *class_id, const char *inst,
const struct hw_mole_t **mole)
{
int status;
int i;
const struct hw_mole_t *hmi = NULL;
<span style="color: rgb(255, 0, 0);"> char prop[PATH_MAX];//幾個關鍵的數組
char path[PATH_MAX];//在下面起了重要
char name[PATH_MAX];//作用
</span>
if (inst)
snprintf(name, PATH_MAX, "%s.%s", class_id, inst);
else
strlcpy(name, class_id, PATH_MAX);//走這里

/*
* Here we rely on the fact that calling dlopen multiple times on
* the same .so will simply increment a refcount (and not load
* a new of the library).
* We also assume that dlopen() is thread-safe.
*/

/* Loop through the configuration variants looking for a mole */
for (i=0 ; i<HAL_VARIANT_KEYS_COUNT+1 ; i++) {
if (i < HAL_VARIANT_KEYS_COUNT) {
if (property_get(variant_keys[i], prop, NULL) == 0)
<span style="color: rgb(255, 0, 0);">//在這里將prop的路徑得到,分別從
"ro.hardware[qcom]"
"ro.proct.board"[7x27],
"ro.board.platform"[msm7627a],
"ro.arch",
"ro.hw_platform"[QRD_SKU3-1100]
這幾個屬性文件中獲得硬體的信息
有些硬體信息的字元串會出現在編譯後生成的.so名字中</span>
{
continue;
}
snprintf(path, sizeof(path), "%s/%s.%s.so",
HAL_LIBRARY_PATH2, name, prop);
if (access(path, R_OK) == 0) break;

snprintf(path, sizeof(path), "%s/%s.%s.so",
HAL_LIBRARY_PATH1, name, prop);<span style="color: rgb(255, 0, 0);">//走這里,在這里得到/system/lib/hw/camera.msm7627a.so
這樣一個路徑,這個庫里有QualcommCamera.cpp,這是
camera模塊HAL代碼開始的地方</span>
if (access(path, R_OK) == 0) break;
} else {
snprintf(path, sizeof(path), "%s/%s.default.so",
HAL_LIBRARY_PATH1, name);
if (access(path, R_OK) == 0) break;
}
}

status = -ENOENT;
if (i < HAL_VARIANT_KEYS_COUNT+1) {
/* load the mole, if this fails, we're doomed, and we should not try
* to load a different variant. */
status = load(class_id, path, mole);<span style="color: rgb(255, 0, 0);">//這里關鍵,函數的三個參數可以串聯成一句話:
到path(/system/lib/hw/camera.msm7627a.so)這個路徑下找到一個id(camera)匹配的mole</span>
}

return status;
}
int hw_get_mole_by_class(const char *class_id, const char *inst,
const struct hw_mole_t **mole)
{
int status;
int i;
const struct hw_mole_t *hmi = NULL;
char prop[PATH_MAX];//幾個關鍵的數組
char path[PATH_MAX];//在下面起了重要
char name[PATH_MAX];//作用

if (inst)
snprintf(name, PATH_MAX, "%s.%s", class_id, inst);
else
strlcpy(name, class_id, PATH_MAX);//走這里

/*
* Here we rely on the fact that calling dlopen multiple times on
* the same .so will simply increment a refcount (and not load
* a new of the library).
* We also assume that dlopen() is thread-safe.
*/

/* Loop through the configuration variants looking for a mole */
for (i=0 ; i<HAL_VARIANT_KEYS_COUNT+1 ; i++) {
if (i < HAL_VARIANT_KEYS_COUNT) {
if (property_get(variant_keys[i], prop, NULL) == 0)
//在這里將prop的路徑得到,分別從
"ro.hardware[qcom]"
"ro.proct.board"[7x27],
"ro.board.platform"[msm7627a],
"ro.arch",
"ro.hw_platform"[QRD_SKU3-1100]
這幾個屬性文件中獲得硬體的信息
有些硬體信息的字元串會出現在編譯後生成的.so名字中
{
continue;
}
snprintf(path, sizeof(path), "%s/%s.%s.so",
HAL_LIBRARY_PATH2, name, prop);
if (access(path, R_OK) == 0) break;

snprintf(path, sizeof(path), "%s/%s.%s.so",
HAL_LIBRARY_PATH1, name, prop);//走這里,在這里得到/system/lib/hw/camera.msm7627a.so
這樣一個路徑,這個庫里有QualcommCamera.cpp,這是
camera模塊HAL代碼開始的地方
if (access(path, R_OK) == 0) break;
} else {
snprintf(path, sizeof(path), "%s/%s.default.so",
HAL_LIBRARY_PATH1, name);
if (access(path, R_OK) == 0) break;
}
}

status = -ENOENT;
if (i < HAL_VARIANT_KEYS_COUNT+1) {
/* load the mole, if this fails, we're doomed, and we should not try
* to load a different variant. */
status = load(class_id, path, mole);//這里關鍵,函數的三個參數可以串聯成一句話:
到path(/system/lib/hw/camera.msm7627a.so)這個路徑下找到一個id(camera)匹配的mole
}

return status;
}

再來看看load這個函數@hardware.c (hardware\libhardware)

[cpp] view plain print?
static int load(const char *id,
const char *path,
const struct hw_mole_t **pHmi)
{
int status;
void *handle;
struct hw_mole_t *hmi;

/*
* load the symbols resolving undefined symbols before
* dlopen returns. Since RTLD_GLOBAL is not or'd in with
* RTLD_NOW the external symbols will not be global
*/
handle = dlopen(path, RTLD_NOW);
if (handle == NULL) {
char const *err_str = dlerror();
LOGE("load: mole=%s\n%s", path, err_str?err_str:"unknown");
status = -EINVAL;
goto done;
}

<span style="color: rgb(255, 0, 0);"> /* Get the address of the struct hal_mole_info. */
const char *sym = HAL_MODULE_INFO_SYM_AS_STR;
hmi = (struct hw_mole_t *)dlsym(handle, sym);
</span> if (hmi == NULL) {
LOGE("load: couldn't find symbol %s", sym);
status = -EINVAL;
goto done;
}

/* Check that the id matches */
if (strcmp(id, hmi->id) != 0) {
LOGE("load: id=%s != hmi->id=%s", id, hmi->id);
status = -EINVAL;
goto done;
}

hmi->dso = handle;

/* success */
status = 0;

done:
if (status != 0) {
hmi = NULL;
if (handle != NULL) {
dlclose(handle);
handle = NULL;
}
} else {
LOGV("loaded HAL id=%s path=%s hmi=%p handle=%p",
id, path, *pHmi, handle);
}

*pHmi = hmi;

return status;
}
static int load(const char *id,
const char *path,
const struct hw_mole_t **pHmi)
{
int status;
void *handle;
struct hw_mole_t *hmi;

/*
* load the symbols resolving undefined symbols before
* dlopen returns. Since RTLD_GLOBAL is not or'd in with
* RTLD_NOW the external symbols will not be global
*/
handle = dlopen(path, RTLD_NOW);
if (handle == NULL) {
char const *err_str = dlerror();
LOGE("load: mole=%s\n%s", path, err_str?err_str:"unknown");
status = -EINVAL;
goto done;
}

/* Get the address of the struct hal_mole_info. */
const char *sym = HAL_MODULE_INFO_SYM_AS_STR;
hmi = (struct hw_mole_t *)dlsym(handle, sym);
if (hmi == NULL) {
LOGE("load: couldn't find symbol %s", sym);
status = -EINVAL;
goto done;
}

/* Check that the id matches */
if (strcmp(id, hmi->id) != 0) {
LOGE("load: id=%s != hmi->id=%s", id, hmi->id);
status = -EINVAL;
goto done;
}

hmi->dso = handle;

/* success */
status = 0;

done:
if (status != 0) {
hmi = NULL;
if (handle != NULL) {
dlclose(handle);
handle = NULL;
}
} else {
LOGV("loaded HAL id=%s path=%s hmi=%p handle=%p",
id, path, *pHmi, handle);
}

*pHmi = hmi;

return status;
}

在打開的.so(camera.msm7627a.so)中查找HMI符號的地址,並保存在hmi中。至此,.so中的hw_mole_t已經被成功獲取,從而可以根
據它獲取別的相關介面。
1)HAL通過hw_get_mole函數獲取hw_mole_t
2)HAL通過hw_mole_t->methods->open獲取hw_device_t指針,並在此open函數中初始化hw_device_t的包裝結構中的
函數及hw_device_t中的close函數,如gralloc_device_open。
3)三個重要的數據結構:
a) struct hw_device_t: 表示硬體設備,存儲了各種硬體設備的公共屬性和方法
b)struct hw_mole_t: 可用hw_get_mole進行載入的mole
c)struct hw_mole_methods_t: 用於定義操作設備的方法,其中只定義了一個打開設備的方法open.

⑵ 有沒有那本書介紹android hal層

書到沒見過,只有一些資料而已:
Android HAL層即硬體抽象層是Google響應廠家「希望不公開源碼」的要求推出的概念
1,源代碼和目標位置
源代碼: /hardware/libhardware目錄,該目錄的目錄結構如下:
/hardware/libhardware/hardware.c編譯成libhardware.so,目標位置為/system/lib目錄
Android.mk中lib文件默認使用LOCAL_MODULE_PATH是等於TARGET_OUT_SHARED_LIBRARIES的。
/hardware/libhardware/include/hardware目錄下包含如下頭文件:
hardware.h 通用硬體模塊頭文件hw_mole_t和hw_get_mole_by_class的定義
bit.h bit模塊頭文件
gralloc.h gralloc模塊頭文件
lights.h 背光模塊頭文件
overlay.h overlay模塊頭文件
qemud.h qemud模塊頭文件
sensors.h 感測器模塊頭文件
/hardware/libhardware/moles目錄下定義了很多硬體模塊
這些硬體模塊都編譯成xxx.xxx.so,目標位置為/system/lib/hw目錄

⑶ android下視頻文件從解碼到播放需要哪幾步,請簡述

Android通過軟解碼播放視頻
1, 一般情況下Android的平台都是硬解碼視頻的,尤其是在Arm平台這種成熟的硬體平台上面(硬解碼代碼由晶元廠商提供)。但是Android移植到
2, MIPS平台時間還不長,還不成熟,還需要自己實現硬體解碼的工作。為了早日讓Android在MIPS平台運行起來,我選擇了先用軟解碼播放視頻。
3,Android代碼是從Android on MIPS社區獲得的代碼。發現軟解碼視頻播放過程中會發生崩潰。經過分析好像是內存分配的問題。

4, 經過研究OpenCore庫(Android框架是通過OpenCore來播放視頻的,網上有很多關於OpenCore的介紹,這里就不多說了),並參考Android平台——Surfaceflinger機制。發現問題出在源文件:
frameworks/base/libs/surfaceflinger/LayerBuffer.cpp的LayerBuffer::BufferSource::postBuffer方法中:
............
buffer = new LayerBuffer::Buffer(buffers, offset);
............類LayerBuffer::Buffer的構造函數代碼如下:
LayerBuffer::Buffer::Buffer(const ISurface::BufferHeap& buffers, ssize_t offset)
: mBufferHeap(buffers)
{
NativeBuffer& src(mNativeBuffer);
g.handle = 0;
gralloc_mole_t const * mole = LayerBuffer::getGrallocMole();
if (mole && mole->perform) {
int err = mole->perform(mole,
GRALLOC_MODULE_PERFORM_CREATE_HANDLE_FROM_BUFFER,
buffers.heap->heapID(), buffers.heap->getSize(),
offset, buffers.heap->base(),
& g.handle);
if (err == NO_ERROR) {
op.l = 0;
op.t = 0;
op.r = buffers.w;
op.b = buffers.h;
g.w = buffers.hor_stride ?: buffers.w;
g.h = r_stride ?: buffers.h;
rmat = rmat;
se = (void*)(intptr_t(buffers.heap->base()) + offset);
}
}
}LayerBuffer::getGrallocMole方法的調用到的Gralloc為:
hardware/libhardware/moles/gralloc/gralloc.cpp因為的沒有實現在自己的硬體只能用通用的Gralloc,經過分析發現通用的Gralloc沒有實現
5, mole->perform函數指針,mole->perform為NULL,所以不會對Buffer進行必要的初始化(我覺得應該是一個疏忽,只是不知道是谷歌的疏忽,還是MIPS移植人員的疏忽,最起碼應該能夠讓通用硬體能跑起來)。參考其他的硬體實現一個perform函數指針到通用Gralloc中。
在源文件:
hardware/libhardware/moles/gralloc/mapper.cpp增加如下的函數定義:
int gralloc_perform(struct gralloc_mole_t const* mole,
int operation, ... )
{
int res = -EINVAL;
va_list args;
va_start(args, operation);
switch (operation) {
case GRALLOC_MODULE_PERFORM_CREATE_HANDLE_FROM_BUFFER: {
int fd = va_arg(args, int);
size_t size = va_arg(args, size_t);
size_t offset = va_arg(args, size_t);
void* base = va_arg(args, void*);
native_handle_t** handle = va_arg(args, native_handle_t**);
private_handle_t* hnd = (private_handle_t*)native_handle_create(
private_handle_t::sNumFds, private_handle_t::sNumInts);
hnd->magic = private_handle_t::sMagic;
hnd->fd = fd;
hnd->flags = private_handle_t::PRIV_FLAGS_USES_PMEM;
hnd->size = size;
hnd->offset = offset;
hnd->base = intptr_t(base) + offset;
hnd->lockState = private_handle_t::LOCK_STATE_MAPPED;
*handle = (native_handle_t *)hnd;
res = 0;
break;
}
}
va_end(args);
return res;
}然後在gralloc.cpp中增加,gralloc_perform的聲明:
extern int gralloc_perform(struct gralloc_mole_t const* mole,
int operation, ... );並修改HAL_MODULE_INFO_SYM的定義,增加perform欄位的定義:
struct private_mole_t HAL_MODULE_INFO_SYM = {
base: {
.......
perform: gralloc_perform,
},
......
}; 重新編譯gralloc模塊,再次用Gallary應用程序通過軟解碼播放視頻,就可以流暢的播放了,軟解碼的效率挺高的,沒有卡的感覺!

⑷ android手機GPU顯存有必要麼

實際上,現在android中用的是統一內存架構,GPU和CPU共享一個物理內存,通常我們有「顯存」和「內存」兩種叫法,可以認為是這塊物理內存的所有者不同,但這段映射到cpu,就是通常意義上的內存;當映射到gpu,就是通常意義上的顯存。並且同一時刻只會映射到一個device。

一個簡單的紋理創建,首先我們需要先把紋理數據載入到一段內存中A中,然後調用glTexImage2D來上傳紋理的時候,會調用gles驅動的內存分配介面來分配一段內存B(最終是調用gralloc分配),並且映射到cpu。然後會調用一個定製的memcpy來把A的數據拷貝到B。這里,雖然都是在同一塊物理內存中,但是OpenGL的spec如此,還是需要一次拷貝。渲染的時候,B會被映射到GPU上,讓GPU可以讀取。
而GPU渲染內容從APP到SF,是不會有搬運,至少Mali和sgx PowerVR不會。廠家的opengl實現,是調用BufferQueue這個類來獲取內存來渲染的,gpu渲染完畢再丟回BuffferQueue (Queue/Dequeue)。而surfaceFlinger會去請求有沒有可以已經渲染好的東西,以及會把顯示完的一幀丟回這個queue(Aquire/Release)。只要進程還活著,還可見,這個queue中往往有3塊格式相同的buffer會循環使用。

⑸ 怎麼看android frame buffer

1. Gralloc模塊的載入過程。
每一個HAL模塊都有一個ID值,以這些ID值為參數來調用硬體抽象層提供的函數hw_get_mole就可以將指定的模塊載入到內存來,並且獲得一個hw_mole_t介面來打開相應的設備。
Gralloc模塊的ID值定義在hardware/libhardware/include/hardware/gralloc.h文件中,如下所示:

[cpp] view plain
#define GRALLOC_HARDWARE_MODULE_ID "gralloc"
函數hw_get_mole實現在hardware/libhardware/hardware.c文件中,如下所示:

[cpp] view plain
/** Base path of the hal moles */
#define HAL_LIBRARY_PATH1 "/system/lib/hw"
#define HAL_LIBRARY_PATH2 "/vendor/lib/hw"

/**
* There are a set of variant filename for moles. The form of the filename
* is "<MODULE_ID>.variant.so" so for the led mole the Dream variants
* of base "ro.proct.board", "ro.board.platform" and "ro.arch" would be:
*
* led.trout.so
* led.msm7k.so
* led.ARMV6.so
* led.default.so
*/

static const char *variant_keys[] = {
"ro.hardware", /* This goes first so that it can pick up a different
file on the emulator. */
"ro.proct.board",
"ro.board.platform",
"ro.arch"
};

static const int HAL_VARIANT_KEYS_COUNT =
(sizeof(variant_keys)/sizeof(variant_keys[0]));

......

int hw_get_mole(const char *id, const struct hw_mole_t **mole)
{
int status;
int i;
const struct hw_mole_t *hmi = NULL;
char prop[PATH_MAX];
char path[PATH_MAX];

/*
* Here we rely on the fact that calling dlopen multiple times on
* the same .so will simply increment a refcount (and not load
* a new of the library).
* We also assume that dlopen() is thread-safe.
*/

/* Loop through the configuration variants looking for a mole */
for (i=0 ; i<HAL_VARIANT_KEYS_COUNT+1 ; i++) {
if (i < HAL_VARIANT_KEYS_COUNT) {
if (property_get(variant_keys[i], prop, NULL) == 0) {
continue;
}

snprintf(path, sizeof(path), "%s/%s.%s.so",
HAL_LIBRARY_PATH1, id, prop);
if (access(path, R_OK) == 0) break;

snprintf(path, sizeof(path), "%s/%s.%s.so",
HAL_LIBRARY_PATH2, id, prop);
if (access(path, R_OK) == 0) break;
} else {
snprintf(path, sizeof(path), "%s/%s.default.so",
HAL_LIBRARY_PATH1, id);
if (access(path, R_OK) == 0) break;
}
}

status = -ENOENT;
if (i < HAL_VARIANT_KEYS_COUNT+1) {
/* load the mole, if this fails, we're doomed, and we should not try
* to load a different variant. */
status = load(id, path, mole);
}

return status;
}
函數hw_get_mole依次在目錄/system/lib/hw和/vendor/lib/hw中查找一個名稱為"<MODULE_ID>.variant.so"的文件,其中,<MODULE_ID>是一個模塊ID,而variant表示"ro.hardware"、"ro.proct.board"、"ro.board.platform"和"ro.arch"四個系統屬性值之一。例如,對於Gralloc模塊來說,函數hw_get_mole依次在目錄/system/lib/hw和/vendor/lib/hw中檢查是否存在以下四個文件:

gralloc.<ro.hardware>.so
gralloc.<ro.proct.board>.so
gralloc.<ro.board.platform>.so
gralloc.<ro.arch>.so

只要其中的一個文件存在, 函數hw_get_mole就會停止查找過程,並且調用另外一個函數load來將這個文件載入到內存中來。另一方面,如果在/system/lib/hw和/vendor/lib/hw中均不存這些文件,那麼函數hw_get_mole就會在目錄/system/lib/hw中查找是否存在一個名稱為gralloc.default.so的文件。如果存在的話,那麼也會調用函數load將它載入到內存中來。

⑹ android 非上層程序怎麼調用sensor

Android上層應用apk到G-sensor driver的大致流程: Android HAL層,即硬體抽象層,是Google響應廠家「希望不公開源碼」的要求推出的新概念 1,源代碼和目標位置 源代碼: /hardware/libhardware目錄,該目錄的目錄結構如下: /hardware/libhardware/hardware.c編譯成libhardware.so,目標位置為/system/lib目錄 /hardware/libhardware/include/hardware目錄下包含如下頭文件: hardware.h 通用硬體模塊頭文件 bit.h bit模塊頭文件 gralloc.h gralloc模塊頭文件 qemud.h qemud模塊頭文件 sensors.h 感測器模塊頭文件 /hardware/libhardware/moles目錄下定義了很多硬體模塊 這些硬體模塊都編譯成xxx.xxx.so,目標位置為/system/lib/hw目錄 2,Android對於Sensor的API定義在 hardware/libhardware/include/hardware/sensor.h中,要求在sensor.so提供以下8個API函數 [控制方面] int (*open_data_source)(struct sensors_control_device_t *dev); int (*activate)(struct sensors_control_device_t *dev, int handle, int enabled); int (*set_delay)(struct sensors_control_device_t *dev, int32_t ms); int (*wake)(struct sensors_control_device_t *dev); [數據方面] int (*data_open)(struct sensors_data_device_t *dev, int fd); int (*data_close)(struct sensors_data_device_t *dev); int (*poll)(struct sensors_data_device_t *dev, sensors_data_t* data); [模塊方面] int (*get_sensors_list)(struct sensors_mole_t* mole, struct sensor_t const** list); 在java層Sensor的狀態控制由SensorService來負責,它的java代碼和JNI代碼分別位於: frameworks/base/services/java/com/Android/server/SensorService.java frameworks/base/services/jni/com_Android_server_SensorService.cpp 在Java層Sensor的數據控制由SensorManager來負責,它的java代碼和JNI代碼分別位於: frameworks/base/core/java/Android/hardware/SensorManager.java frameworks/base/core/jni/Android_hardware_SensorManager.cpp Android framework中與sensor通信的是sensorService.java和sensorManager.java。 sensorService.java的具體通信是通過JNI調用sensorService.cpp中的方法實現的。 sensorManager.java的具體通信是通過JNI調用sensorManager.cpp中的方法實現的。 sensorService.cpp和sensorManger.cpp通過hardware.c與sensor.so通信。其中sensorService.cpp實現對sensor的狀態控制,sensorManger.cpp實現對sensor的數據控制。 sensor.so通過ioctl控制sensor driver的狀態,通過打開sensor driver對應的設備文件讀取G-sensor採集的數據。 Android SDK提供了4個類來於sensor通信,分別為 sensor,sensorEvent,sensorEventListener,sensorManager。其中 sensorEventListener用來在sensorManager中注冊需要監聽的sensor類型。 sensorManager.java提供registrater(),unregistrater()介面供sensorEventListener使用。 sensorManager.java不斷輪詢從sensor.so中取數據。取到數據後送給負責監聽此類型sensor的 sensorEventListener.java。sensorEventListener.java通過在sensorManager.java中注冊可以監聽特定類型的sensor傳來的數據。 系統啟動時執行systemProcess,會啟動sensorService.java,在sensorService.java的構造函數中調用JNI方法_sensor_control_init()。 sensorService.cpp中相應的方法Android_int()會被執行。該函數會調用hardware.c中的方法hw_get_mole()此函數又通過調用load()函數在system/lib/hw下查找sensor.so 查找時會根據harware.c中定義好的sensor.*.so的擴展名的順序查找,找到第一個匹配的時候即停止,並將該sensor.so中定義好的一個全局變數HAL_MODULE_INFO_SYM帶回。該變數包含的一個 重要信息是它的一個成員結構變數中包含的一個函數指針open,該指針所指函數會對一個device結構變數賦值,從而帶出sensorService.cpp和sensorManager.cpp與sensor通信所需要的全部信息。 device結構變數有兩種變體分別供sensorService.cpp和sensorManaer.cpp使用。其中主要是一些函數指針指向與sensor通信的函數。 sensorService.cpp和sensorManager.cpp在得到HAL_MODULE_INFO_SYM結構後都會調用 sensors.h的inline函數open()通過HAL_MODULE_INFO_SYM的open函數指針將所需的device信息取回。 系統在啟動activityManager.java時,它會啟動sensorManager.java,它也會調用hardware.c中的方法hw_get_mole()帶回HAL_MODULE_INFO_SYM。

⑺ android 對地圖緩沖區分析怎麼做

GraphicBufferAllocator::GraphicBufferAllocator()
: mAllocDev(0)
{
hw_mole_t const* mole;
//根據模塊ID得到模塊描述符的首地址
int err = hw_get_mole(GRALLOC_HARDWARE_MODULE_ID, &mole);
ALOGE_IF(err, "FATAL: can't find the %s mole", GRALLOC_HARDWARE_MODULE_ID);
if (err == 0) {
//調用該硬體抽象層的open方法,創建hw_device_t對象,並且將hw_mole_t注冊到hw_device_t中
gralloc_open(mole, &mAllocDev);
}
}

閱讀全文

與androidgralloc相關的資料

熱點內容
zigbee加密演算法 瀏覽:461
柏楊版資治通鑒pdf 瀏覽:393
事業編程序員下班時間 瀏覽:8
linux中命令大全 瀏覽:36
pic單片機學習網站 瀏覽:163
843除6的演算法 瀏覽:376
arduino編程視頻 瀏覽:744
pdf背景綠色 瀏覽:612
記事本dos命令 瀏覽:274
伺服器如何搭建多個節點 瀏覽:326
acx演算法 瀏覽:258
幽冥詭匠漫畫全集用什麼app可以看 瀏覽:1002
租用伺服器為什麼越來越慢 瀏覽:962
演算法創新就業方向 瀏覽:424
演算法最優解作者 瀏覽:869
通達信紅綠寶塔線指標源碼 瀏覽:668
app是什麼東西合法嗎 瀏覽:233
怎麼鎖app視頻教程 瀏覽:842
迅捷pdf注冊碼生成器 瀏覽:750
androidsdkosx 瀏覽:304