NOTICE: The Processors Wiki will End-of-Life in December of 2020. It is recommended to download any files or other content you may need that are hosted on The site is now set to read only.

TI-Android-DevKit-Camera Porting Guide

From Texas Instruments Wiki
Jump to: navigation, search

This is a porting guide of - How to enable/add camera sensor on Android. Document will highlight on how to

  • Add camera module to linux kernel
  • Enable camera module to kernel config
  • Enable camera port on android

All example in this article is based on camera sensor 'mt9v113' and rowboat-android release.(

Android's Camera Sub System

Android'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 :


Adding Camera Module to Linux Kernel

  • Write/Get camera driver. (mt9v113.c/mt9v113.h)
  • Put driver files at <Kernel>/drivers/media/video. Good to have header files at <Kernel>/include/media
  • Open & Edit <Kernel>drivers/media/video/Makefile

<syntaxhighlight lang="bash"> $vim <Kernel>/drivers/media/video/Makefile Add driver file to get compiled. e.x. obj-$(CONFIG_VIDEO_MT9V113) += mt9v113.o </syntaxhighlight>

  • Open & Edit <Kernel>/drivers/media/video/Kconfig

<syntaxhighlight lang="bash"> $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
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.


  • Open & Edit <Kernel>/arch/arm/mach-omap2/board-omap3beagle.c

<syntaxhighlight lang="bash"> $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[] = {

  1. if defined(CONFIG_VIDEO_MT9V113) || defined(CONFIG_VIDEO_MT9V113_MODULE)
I2C_BOARD_INFO("mt9v113", MT9V113_I2C_ADDR),
.platform_data = &mt9v113_pdata,
  1. endif


  • Open & Edit <Kernel>/arch/arm/mach-omap2/board-omap3beagle-camera.c
    • Add board specific power settings for camera sensor
    • For the reference refer file - '<Kernel>/arch/arm/mach-omap2/board-omap3beagle-camera.c'
  • Open & Edit <Kernel>/arch/arm/mach-omap2/Makefile

<syntaxhighlight lang="bash"> $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

  • Configure kernel and enable camera sensor

<syntaxhighlight lang='bash'> $cd <Kernel> $make CROSS_COMPILE=arm-eabi- ARCH=arm menuconfig </syntaxhighlight>

  • Go to device drivers -> multimedia support -> video capture adapters -> encoders/decoders and other helper chips
  • select added camera driver
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
< > TCM825x camera sensor support
< > Micron MT9P012 raw sensor driver (5MP)

Patch reference

Kindly find patch reference at

This patch will add camera sensor mt9v113 to kernel.

Build Kernel

Kindly refer - How to build kernel:

Android Camera HAL Reference

Android Camera HAL brief

  • To implement a camera HAL ( also consider as driver between android camera subsystem and V4L2 kernel driver) ; one need to create a shared library (named as that implements the interface defined at “<ANDROID_ROOT>/frameworks/base/include/camera/CameraHardwareInterface.h”.
  • Location of the shared library should be at <ANDROID_ROOT>/hardware/<vendor>/<boardname>/camera

e.g. In rowboat android - froyo release for omap3 ; it is at <ANDROID_ROOT>/hardware/ti/omap3/camera


  • Create camera HAL at location explained above
  • Create source files and implement interface defined at 'CameraHardwareInterface.h'. Kindly refer rowboat froyo release for the reference.


  • Following section brief above important interface needs to be defined under camera HAL.

<syntaxhighlight lang="bash"> /* constructor */ CameraHardware::CameraHardware()

: mParameters(),


/* create camera, open camera sensor */
/* init default paramets
CameraParameters p;
p.setPreviewSize(320, 240);
p.set(CameraParameters::KEY_JPEG_QUALITY, 100);

} /* 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
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

} </syntaxhighlight>

  • Create and configure file

<syntaxhighlight lang="bash"> LOCAL_PATH:= $(call my-dir)

  1. libcamera


source1.cpp \
source2.cpp ...


libcutils \
libui \
libutils \
libbinder \
libjpeg \
libcamera_client \



include $(BUILD_SHARED_LIBRARY) include $(all-subdir-makefiles) </syntaxhighlight>

  • Compile android system or one can also compile individal subsystem by

<syntaxhighlight lang="bash"> Go to module directory $cd /projects/rowboat-android/hardware/ti/omap3/camera $source <ANDROID_ROOT>/build/ $mm TARGET_PRODUCT= <TARGET PRODUCT NAME> e.g.$ mm TARGET_PRODUCT=beagleboard copy to out/target/product/<boardname>/system/lib </syntaxhighlight>

  • Create file system and test on target
  • Kindly refer user guide for more information.