All example in this article is based on camera sensor 'mt9v113' and rowboat-android release.(http://focus./docs/toolsw/folders/print/androidsdk-sitara.html) Contents[hide]Android's Camera Sub SystemAndroid's camera application connect with android HAL through camera binding interface. HAL inturns connect physical camera sensor and provides control & data interface between application and camera sensor. The diagram below illustrates the structure of the camera subsystem. In the diagram proprietary camera libraries are nothing but camera HAL in current context. source : http://source./porting/camera.html Adding Camera Module to Linux Kernel
$vim <Kernel>/drivers/media/video/Makefile Add driver file to get compiled. e.x. obj-$(CONFIG_VIDEO_MT9V113) += mt9v113.o
$vim <Kernel>/drivers/media/video/Kconfig Add config entry for the driver. e.x. config VIDEO_MT9V113 tristate "Aptina MT9V113 VGA CMOS IMAGE SENSOR" depends on VIDEO_V4L2 && I2C ---help--- This is a Video4Linux2 sensor-level driver for the Aptina MT9V113 image sensor. To compile this driver as a module, choose M here: the module will be called mt9v113.
$vim <Kernel>/arch/arm/mach-omap2/board-omap3beagle.c /* Add i2c init data and regulator declaration for camera sensor. For more detail refer file - '<Kernel>/arch/arm/mach-omap2/board-omap3beagle.c' */ e.x. static struct i2c_board_info __initdata beagle_i2c2_boardinfo[] = { #if defined(CONFIG_VIDEO_MT9V113) || defined(CONFIG_VIDEO_MT9V113_MODULE) { I2C_BOARD_INFO("mt9v113", MT9V113_I2C_ADDR), .platform_data = &mt9v113_pdata, }, #endif
$vim <Kernel>/arch/arm/mach-omap2/Makefile Add board file for build obj-$(CONFIG_MACH_OMAP3_BEAGLE) += board-omap3beagle.o board-omap3beagle-camera.o \ Enable Camera Module to Kernel Config
$cd <Kernel> $make CROSS_COMPILE=arm-eabi- ARCH=arm menuconfig
General setup ---> [*] Enable loadable module support ---> [*] Enable the block layer ---> System Type ---> Bus support ---> Kernel Features ---> Boot options ---> CPU Power Management ---> Floating point emulation ---> Userspace binary formats ---> Power management options ---> [*] Networking support ---> Device Drivers ---> CBUS support ---> File systems ---> *** Multimedia core support *** <*> Video For Linux [*] Enable Video For Linux API 1 (DEPRECATED) < > DVB for Linux *** Multimedia drivers *** [ ] Load and attach frontend and tuner driver modules as needed [ ] Customize analog and hybrid tuner modules to build ---> [*] Video capture adapters ---> [*] Radio Adapters ---> [ ] DAB adapters [ ] Enable advanced debug functionality [ ] Enable old-style fixed minor ranges for video devices [ ] Autoselect pertinent encoders/decoders and other helper chips Encoders/decoders and other helper chips ---> < > Virtual Video Driver < > CPiA Video For Linux < > CPiA2 Video For Linux < > SAA5246A, SAA5281 Teletext processor < > OmniVision OV7670 sensor support <*> Micron mt9v011 sensor support <*> Aptina MT9V113 VGA CMOS IMAGE SENSOR < > TCM825x camera sensor support < > Micron MT9P012 raw sensor driver (5MP) Patch referenceKindly find patch reference at http://processors.wiki./images/a/aa/0001-camera-sensor-support-mt9v113-for-beagleboard.patch.gz This patch will add camera sensor mt9v113 to kernel. Build KernelKindly refer - How to build kernel: http://processors.wiki./index.php/TI-Android-FroYo-DevKit-V2_UserGuide#Kernel Android Camera HAL Referencehttp://processors.wiki./images/6/6c/0001-HAL-camera-support-added-for-beagleboard.patch.gz Android Camera HAL brief
e.g. In rowboat android - froyo release for omap3 ; it is at <ANDROID_ROOT>/hardware/ti/omap3/camera Steps
<ANDROID_ROOT>/hardware/ti/omap3/camera/CameraHardware.cpp
/* constructor */ CameraHardware::CameraHardware() : mParameters(), mPreviewHeap(0), mRawHeap(0), mCamera(0), mPreviewFrameSize(0), mNotifyCb(0), mDataCb(0), mDataCbTimestamp(0), mCallbackCookie(0), mMsgEnabled(0), previewStopped(true) { /* create camera, open camera sensor */ /* init default paramets e.x. CameraParameters p; p.setPreviewSize(320, 240); p.set(CameraParameters::KEY_JPEG_QUALITY, 100); p.setPreviewFormat(CameraParameters::PIXEL_FORMAT_YUV422SP); */ initDefaultParameters(); } /* destructor */ CameraHardware::~CameraHardware() { /* close device and delete instance created */ } sp<IMemoryHeap> CameraHardware::getPreviewHeap() const { /* return preview frame pointer */ return mPreviewHeap; } void CameraHardware::setCallbacks(notify_callback notify_cb, data_callback data_cb, data_callback_timestamp data_cb_timestamp, void* user) { /* store callback to local pointers, need to callback at the time of preview/image capture e.x. mNotifyCb = notify_cb; mDataCb = data_cb; mDataCbTimestamp = data_cb_timestamp; mCallbackCookie = user;*/ } void CameraHardware::enableMsgType(int32_t msgType) { /* set local message flag. Application will give this notification to perform certain action while previewing. ex.start video, image caputure etc. */ mMsgEnabled |= msgType; } void CameraHardware::disableMsgType(int32_t msgType) { mMsgEnabled &= ~msgType; } bool CameraHardware::msgTypeEnabled(int32_t msgType) { /* return message value - presently enable at HAL return (mMsgEnabled & msgType); */ } /* start preview */ status_t CameraHardware::startPreview() { /* configure device and start preview thread */ /* in preview thread call - check message type - fill preview frame pointer with valid preview data - call data callback with data */ } void CameraHardware::stopPreview() { /* stop preview */ } status_t CameraHardware::startRecording() { /* configure device & start record thread */ /* record thread - check message type - if message type contains - CAMERA_MSG_VIDEO_FRAME then call 'mDataCbTimestamp' with video frame captured */ } void CameraHardware::stopRecording() { /* stop recording */ } status_t CameraHardware::takePicture() { /* - configure camera device - take a current frame - check message type - call callback */ } status_t CameraHardware::setParameters(const CameraParameters& params) { /* - configure device as per parameters */ } CameraParameters CameraHardware::getParameters() const { /* - return current value of parameter set */ }
LOCAL_PATH:= $(call my-dir) # # libcamera # include $(CLEAR_VARS) LOCAL_SRC_FILES:= source1.cpp source2.cpp ... LOCAL_MODULE:= libcamera LOCAL_SHARED_LIBRARIES:= libcutils libui libutils libbinder libjpeg libcamera_client libsurfaceflinger_client LOCAL_C_INCLUDES += external/jpeg include $(BUILD_SHARED_LIBRARY) include $(all-subdir-makefiles)
Go to module directory $cd /projects/rowboat-android/hardware/ti/omap3/camera $source <ANDROID_ROOT>/build/envsetup.sh $mm TARGET_PRODUCT= <TARGET PRODUCT NAME> e.g.$ mm TARGET_PRODUCT=beagleboard copy libcamera.so to out/target/product/<boardname>/system/lib
http://processors.wiki./index.php/TI-Android-FroYo-DevKit-V2_UserGuide
|
|