Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


Table of Contents
maxLevel21

Anchor
_Ref54678306
_Ref54678306
Anchor
_Toc364859121
_Toc364859121

...

Introduction


A transport is the link between a camera device and the Aptina onsemi software libraries. The purpose of a transport is to implement the camera control (read and write registers, set modes) and image acquisition functions needed by the higher level software. With a Transport DLL you can:

  1. Support an Aptina onsemi sensor on a device other than the Demo System camera so DevWare or any other ApBase-based application will work with the device.
  2. Create a software simulated camera and sensor, simulating either an existing sensor or new sensor, and be able to use DevWare as the user interface for the simulation.

...

The functions you need to implement and export from your Transport DLL are described below.
The exported functions should use the C calling convention. If you are using C or C++ this would normally be the default, so no special syntax is needed. If it is not, the keyword to force a function to the C calling convention is normally __cdecl in most C/C++ compilers. The function prototypes in this document assume C calling convention is the default.
To make your functions export from the DLL in C or C++ you would normally precede the function declaration with __declspec(dllexport).
The symbols and data structures used by the Transport DLL interface are defined in the midlib2.h and midlib2_trans.h header files.
Several of these functions are required to be implemented and exported from your DLL. If they are not exported then the Aptina onsemi libraries will not load the DLL. The remaining functions are optional. If an optional function is not present then either a default handler will be provided to the application, of the feature will not be available. Whether a function is required or optional will be noted for each one below.

Anchor
_Ref7852008
_Ref7852008
Anchor
_Toc364859123
_Toc364859123
DLL Export SetHelpersDLL()

...

MI_CAMERA_SUCCESS

Initialization successful.

MI_SENSOR_FILE_PARSE_ERROR

A syntax error was found in the sensor data file.

MI_SENSOR_DOES_NOT_MATCH

No sensor data file was found that matches the current sensor.

MI_CAMERA_ERROR

Various other error conditions.

 


Anchor
_Toc364859125
_Toc364859125
Helper Function updateFrameSize()

Definition:
void updateFrameSize(mi_camera_t* pCamera , mi_u32 nWidth, mi_u32 nHeight, mi_s32 nBitsPerClock, mi_s32 nClocksPerPixel);
Summary:
Boilerplate code for UpdateFrameSizeDLL(). Sets pCamera->sensor->width, >height, ->pixelBits, and ->pixelBytes according to the parameters. Also sets BITS_PER_CLOCK and CLOCKS_PER_PIXEL in the camera context structure (see setContext() below). Sets pCamera>sensor->bufferSize to width * height * pixelBytes; you may need to fix up the bufferSize after calling this function. Call from UpdateFrameSizeDLL(). See sample code.
Parameters (same as UpdateFrameSizeDLL()):

pCamera

Pointer to a camera structure.

nWidth

New image width, or 0 to keep the current width.

nHeight

New image height, or 0 to keep the current height.

nBitsPerClock

New bits/pixel clock, or 0 to keep the current value.

nClocksPerPixel

New clocks/pixel, or 0 to keep the same value.


Returns:

void

 

 



Anchor
_Toc364859126
_Toc364859126
Helper Function updateImageType()

...

pCamera

Pointer to a camera structure.


Returns:

void 

 



Anchor
_Toc364859127
_Toc364859127
Helper Function errorLog()

...

errorcode

Always returns the first parameter.

 


Anchor
_Toc364859128
_Toc364859128
Helper Function log()

...

logType

A log message type defined in midlib2.h. The different log types can be turned on/off by the user on the DevWare Options dialog.
MI_LOG_SHIP – A SHiP (I2C) operation.
MI_LOG_USB – A USB command.
MI_LOG_DEBUG – Debug info.
MI_LOG – Any other kind of message.

logMsg

The text of the message.

szSource

Source code file name where this log() call is located. Normally _FILE_.

szFunc

Name of function where this log() call is located. Normally _FUNCTION_.

nLine

Source code line number of this log() call. Normally _LINE_.


Returns:

void

 

 



Anchor
_Toc364859129
_Toc364859129
Helper Function setMode()

...

MI_CAMERA_SUCCESS

Function was successful.

MI_CAMERA_ERROR

An error occurred.

 


Anchor
_Toc364859130
_Toc364859130
Helper Function getMode()

...

MI_CAMERA_SUCCESS

Function was successful.

MI_CAMERA_ERROR

An error occurred.

...


Anchor
_Toc364859131
_Toc364859131
Helper Function setContext()

...

MI_CAMERA_SUCCESS

Function was successful.

MI_CAMERA_ERROR

An error occurred.

...


Field MI_CONTEXT_PRIVATE_DATA

...

pCamera

Pointer to the camera structure.

pInBuffer

Pointer to the raw data


Returns:

void 

 



Anchor
_Toc364859134
_Toc364859134
Helper Function readReg()

...

Register or bitfield value

 

 



Anchor
_Toc364859135
_Toc364859135
Helper Function getBoardConfig()

Definition:
mi_s32 getBoardConfig(mi_camera_t *pCamera, const char *dir_or_file);
Summary:
If the camera is an Aptina onsemi Demo camera such as Demo2X or Demo3, this function fills in the chip[] array of the pCamera structure by loading .cdat files that correspond to FPGAs or peripherals on the camera system I2C bus.
Parameters:

...

MI_CAMERA_SUCCESS

Initialization successful (even if no matching cdat files were found).

MI_PARSE_FILE_ERROR

Error opening the config file.


Anchor
_Toc364859135
_Toc364859135
Helper Function freeBoardConfig()

Definition:
mi_s32 getBoardConfig(mi_camera_t *pCamera);
Summary:
Clean up after getBoardConfig(); removes all items in chip[] array of the pCamera structure.

...

 
Parameters:

void



Returns:

MI_CAMERA_SUCCESS

Initialization successful (even if no matching cdat files were found).

Anchor
_Toc364859136
_Toc364859136
DLL Export OpenCameraDLL()

Definition:
__declspec(dllexport) mi_s32 OpenCameraDLL(mi_camera_t *pCamera, const char *sensor_dir_file, int deviceIndex);
Summary:
This function is called when the DLL is loaded, repeatedly, once for each camera. The deviceIndex parameter will = 0 on the first call, 1 on the second call, and so on. For each camera, do any internal initialization you may need. Fill in pCamera fields including pCamera->sensor, but do not touch pCamera->context, which is already initialized and is used internally by the Aptina onsemi libraries. You can use the setContext() helper function to associate the deviceIndex and/or any other private per-camera data to the pCamera object. The sensor_dir_file parameter is the name of the sensor data file or directory passed by the application to ap_DeviceProbe(). You can quickly initialize your pCamera->sensor with the helper function getSensor().
If all cameras have already been initialized, return MI_CAMERA_ERROR to end the init process. For example, if there are two cameras, return MI_CAMERA_SUCCESS on deviceIndex = 0 and deviceIndex = 1, and return MI_CAMERA_ERROR on deviceIndex = 2.
Parameters:

...


Optional:
This function is not needed if there is no bus master on the main device, or if the main device is an Aptina onsemi product.

Anchor
_Toc364859150
_Toc364859150
DLL Export WriteFarRegistersDLL()

...


Optional:
This function is not needed if there is no bus master on the main device, or if the main device is an Aptina onsemi product.

Anchor
_Toc364859151
_Toc364859151
DLL Export GrabFrameDLL()

...


Returns:

device name string 



Optional:
This function is optional. However, if it's not implemented and the user opens two applications at the same time, the processes won't be synchronized, possibly causing unexpected results.

...

MI_CAMERA_SUCCESS

Message was received and accepted.

MI_CAMERA_ERROR

pCamera pointer does not match the application's pCamera.notifyCode value is not a recognized notification code.lParam value is illegal.Application is not ready.Illegal calling thread.

...


Anchor
_Toc364859166
_Toc364859166
MI_NOTIFY_PAUSE

...

To use your transport DLL, just copy it to the Plugins folder in the Demo Software installation location, typically C:\Aptina Imaging\Plugins.
Alternatively, the application can pass the filename of the DLL to ApBase using the ap_DeviceProbeDll() function. If the application passes in a DLL filename then the Plugins folder is not searched.
DevWare-specific: You can use a command line parameter to specify the DLL. DevWare will pass the given DLL path to the Aptina onsemi libraries.
DevWare.exe /DLL="C:\path\to\your\transport\yourdev.dll"

...