android4.0 camera hal 移植
2011-11-18 14:16
441 查看
先从Camera Hal提供给Camera Service 的接口(CameraHardwareInterface.h)开始看起。
从注释可以看出,基本的流程是没有变的。
/**
* CameraHardwareInterface.h defines the interface to the
* camera hardware abstraction layer, used for setting and getting
* parameters, live previewing, and taking pictures.
*
* It is a referenced counted interface with RefBase as its base class.
* CameraService calls openCameraHardware() to retrieve a strong pointer to the
* instance of this interface and may be called multiple times. The
* following steps describe a typical sequence:
*
* -# After CameraService calls openCameraHardware(), getParameters() and
* setParameters() are used to initialize the camera instance.
* CameraService calls getPreviewHeap() to establish access to the
* preview heap so it can be registered with SurfaceFlinger for
* efficient display updating while in preview mode.
* -# startPreview() is called. The camera instance then periodically
* sends the message CAMERA_MSG_PREVIEW_FRAME (if enabled) each time
* a new preview frame is available. If data callback code needs to use
* this memory after returning, it must copy the data.
*
* Prior to taking a picture, CameraService calls autofocus(). When auto
* focusing has completed, the camera instance sends a CAMERA_MSG_FOCUS notification,
* which informs the application whether focusing was successful. The camera instance
* only sends this message once and it is up to the application to call autoFocus()
* again if refocusing is desired.
*
* CameraService calls takePicture() to request the camera instance take a
* picture. At this point, if a shutter, postview, raw, and/or compressed callback
* is desired, the corresponding message must be enabled. As with CAMERA_MSG_PREVIEW_FRAME,
* any memory provided in a data callback must be copied if it's needed after returning.
*/
但是在具体的实现上,做了改动。一个C++的风格,一个C的风格。现在Hal层也越来越像linux了。
在froyo的Hal层,主要是去实现一个继承自CameraHardwareInterface抽象类的子类,在这个类里去实现父类的(纯)虚函数。
但是在ICS里,CameraHarwareInterface类的方法实现变了,现在是通过hw_module_t结构体获得hw_device_t的结构体,而这个结构体里包括Hal层的各方法回调。也就是froyo里的sensor架构。
看一下initialize函数:
有了这个,也就可以摒弃froyo中的openCameraHardware()接口了。
再看一下两个版本之间,CameraHardwareInterface类中各方法实现的变化。以startPreview为例。
froyo:
越来越像linux风络了。
另外,ICS的CameraHardwareInterface又添加了一些private的成员。
data_callback函数,也多加了一个参数*metadata。
从注释可以看出,基本的流程是没有变的。
/**
* CameraHardwareInterface.h defines the interface to the
* camera hardware abstraction layer, used for setting and getting
* parameters, live previewing, and taking pictures.
*
* It is a referenced counted interface with RefBase as its base class.
* CameraService calls openCameraHardware() to retrieve a strong pointer to the
* instance of this interface and may be called multiple times. The
* following steps describe a typical sequence:
*
* -# After CameraService calls openCameraHardware(), getParameters() and
* setParameters() are used to initialize the camera instance.
* CameraService calls getPreviewHeap() to establish access to the
* preview heap so it can be registered with SurfaceFlinger for
* efficient display updating while in preview mode.
* -# startPreview() is called. The camera instance then periodically
* sends the message CAMERA_MSG_PREVIEW_FRAME (if enabled) each time
* a new preview frame is available. If data callback code needs to use
* this memory after returning, it must copy the data.
*
* Prior to taking a picture, CameraService calls autofocus(). When auto
* focusing has completed, the camera instance sends a CAMERA_MSG_FOCUS notification,
* which informs the application whether focusing was successful. The camera instance
* only sends this message once and it is up to the application to call autoFocus()
* again if refocusing is desired.
*
* CameraService calls takePicture() to request the camera instance take a
* picture. At this point, if a shutter, postview, raw, and/or compressed callback
* is desired, the corresponding message must be enabled. As with CAMERA_MSG_PREVIEW_FRAME,
* any memory provided in a data callback must be copied if it's needed after returning.
*/
但是在具体的实现上,做了改动。一个C++的风格,一个C的风格。现在Hal层也越来越像linux了。
在froyo的Hal层,主要是去实现一个继承自CameraHardwareInterface抽象类的子类,在这个类里去实现父类的(纯)虚函数。
但是在ICS里,CameraHarwareInterface类的方法实现变了,现在是通过hw_module_t结构体获得hw_device_t的结构体,而这个结构体里包括Hal层的各方法回调。也就是froyo里的sensor架构。
看一下initialize函数:
status_t initialize(hw_module_t *module) { LOGI("Opening camera %s", mName.string()); int rc = module->methods->open(module, mName.string(), (hw_device_t **)&mDevice); if (rc != OK) { LOGE("Could not open camera %s: %d", mName.string(), rc); return rc; } initHalPreviewWindow(); return rc; }
有了这个,也就可以摒弃froyo中的openCameraHardware()接口了。
/** factory function to instantiate a camera hardware object */ extern "C" sp<CameraHardwareInterface> openCameraHardware();
再看一下两个版本之间,CameraHardwareInterface类中各方法实现的变化。以startPreview为例。
froyo:
/** * Start preview mode. */ virtual status_t startPreview() = 0;ICS:
status_t startPreview() { LOGV("%s(%s)", __FUNCTION__, mName.string()); if (mDevice->ops->start_preview) return mDevice->ops->start_preview(mDevice); return INVALID_OPERATION; }
越来越像linux风络了。
另外,ICS的CameraHardwareInterface又添加了一些private的成员。
data_callback函数,也多加了一个参数*metadata。
typedef void (*data_callback)(int32_t msgType, const sp<IMemory> &dataPtr, camera_frame_metadata_t *metadata, void* user);
相关文章推荐
- android4.0 camera hal 移植
- android4.0 camera hal 移植
- 华为3GE261在Android4.0、linux3.0.8内核上的移植记录2
- android4.0移植gstreamer多媒体框架
- 移植android4.0内核时,Starting kernel ...没反应问题解决方法
- android4.0移植,拨号异常
- android4.0电容屏移植
- [odroid-pc] ubuntu12.04 android4.0移植到odroid-pc过程
- Android4.0 声卡配置-高通msm8916移植
- 深入浅出 - Android系统移植与平台开发(三)- 编译并运行Android4.0模拟器
- S3C6410移植android4.0 ice scream
- android4.0移植,拨号异常
- Linux3.4.0 Yaffs2文件系统移植-支持Android4.0
- bluez4.99 glib2.29移植到android4.0 移植记录
- 深入浅出 - Android系统移植与平台开发(三)- 编译并运行Android4.0模拟器
- 移植live555到android4.0
- ARM开发板移植android4.0流程
- android4.0移植tslib
- 深入浅出 - Android系统移植与平台开发(三)- 编译并运行Android4.0模拟器
- 将boa移植到android4.0平台跟踪报告