This repository has been archived on 2025-06-06. You can view files and clone it, but cannot push or open issues or pull requests.
Files
android-g900/Start_WM/test6/inc/GFCamera.h
2010-10-16 00:02:07 +06:00

368 lines
14 KiB
C
Executable File

/* Copyright (c) 2006 NVIDIA Corporation. All rights reserved.
*
* NVIDIA Corporation and its licensors retain all intellectual property
* and proprietary rights in and to this software, related documentation
* and any modifications thereto. Any use, reproduction, disclosure or
* distribution of this software and related documentation without an
* express license agreement from NVIDIA Corporation is strictly prohibited.
*/
/** @file GFCamera.h
GFSDK Camera API header file.
*/
#ifndef __CAMERA_H__
#define __CAMERA_H__
#include "GF.h"
#include "GFVx.h"
#include "GFCameraScr.h"
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
/** @addtogroup groupCamera CameraAPI Camera API
<ul>
<li> @ref pageCameraAppNotes
<ul>
<li> @ref pageCameraAppNotes1
</ul>
</ul>
*/
/*@{*/
/* Helper Macros - Do not assume bytes are properly aligned! */
#ifndef MAKENvU8S16
#define MAKENvU8S16( data16 ) \
(NvU8)((data16) & 0xFF), (NvU8)(((data16) >> 8) & 0xFF)
#endif /* MAKENvU8S16 */
#ifndef MAKENvU8S32
#define MAKENvU8S32( data32 ) \
(NvU8)((data32) & 0xFF), \
(NvU8)(((data32) >> 8) & 0xFF), \
(NvU8)(((data32) >> 16) & 0xFF), \
(NvU8)(((data32) >> 24) & 0xFF)
#endif /* MAKENvU8S32 */
#ifndef MAKE16
#define MAKE16( ptr ) \
((NvU16)(*ptr) | ((NvU16)(*(ptr+1)) << 8))
#endif /* MAKE16 */
#ifndef MAKE32
#define MAKE32( ptr ) \
((NvU32)MAKE16( ptr ) | (NvU32)MAKE16( (ptr+2) ) << 16)
#endif /* MAKE32 */
/* GFCAMERA instruction (special) */
#define GFCAMERA_NONE 0x00
#define GFCAMERA_NORMAL_WRITE 0x01
#define GFCAMERA_DELAY_MSEC 0x02
#define GFCAMERA_NEED_MCLOCK 0x03
/* GFCameraSetResolution Options */
#define GFCAMERA_POWERON_OPTION 0x00000001
/* GFCAMERA Error codes */
#define GFCAM_ERROR_ILLEGAL_PARAMETER (GFCAM_ERROR | 0x00000001L)
#define GFCAM_ERROR_ALLOC_FAILED (GFCAM_ERROR | 0x00000002L)
#define GFCAM_ERROR_VM_ALLOC_FAILED (GFCAM_ERROR | 0x00000003L)
#define GFCAM_ERROR_SCRIPT_ACCESS_FAILED (GFCAM_ERROR | 0x00000004L)
#define GFCAM_ERROR_NATIVE_FUNCTION_FAILED (GFCAM_ERROR | 0x00000005L)
#define GFCAM_ERROR_GETTING_COMPONENT (GFCAM_ERROR | 0x00000006L)
#define GFCAM_ERROR_VM_BUFFER_ALLOC_FAILED (GFCAM_ERROR | 0x00000007L)
#define GFCAM_ERROR_CAMERA_SCRIPT_NOT_PRESENT (GFCAM_ERROR | 0x00000008L)
#define GFCAM_ERROR_FUNCTION_NOT_SUPPORTED (GFCAM_ERROR | 0x00000009L)
/* GFCAMERAINSTRTYPE */
typedef struct _GFCAMERAINSTRTYPE
{
NvU16 skip; // IMPORTANT: Multiple instructions
// must be in ascending skip order
NvU8 type;
NvU16 size;
NvU32 data;
} GFCAMERAINSTRTYPE, *PGFCAMERAINSTRTYPE;
/* GFCAMERABAYERINFO - BayerInfo struct */
typedef struct _GFCAMERABAYERINFO
{
NvU16 ScanWidth;
NvU16 ScanHeight;
NvU16 ActiveLineStart;
NvU16 ActiveLineWidth;
NvU16 ActiveFrameStart;
NvU16 ActiveFrameHeight;
NvU8 hSyncEdge;
NvU8 vSyncEdge;
NvU16 bayerSel;
} GFCAMERABAYERINFO, *PGFCAMERABAYERINFO;
/* GFCAMERARESOLUTIONTYPE - Resolution struct */
typedef struct _GFCAMERARESOLUTIONTYPE
{
NvU16 x;
NvU16 y;
NvU8 numInstr;
GFCAMERAINSTRTYPE *pInstr;
GFCAMERABAYERINFO *pBayerInfo;
} GFCAMERARESOLUTIONTYPE, *PGFCAMERARESOLUTIONTYPE;
/* GFCAMERATABLETYPE - Camera Table */
#define GFCAMERA_NAME_SIZE 32
typedef struct _GFCAMERATABLETYPE
{
NvU16 id;
NvU16 ver;
NvU32 scriptSubID;
char name[GFCAMERA_NAME_SIZE];
// variable name char string always
// ends with a '0'
NvU32 VIPFlag;
NvU32 VIPNewTiming;
NvU32 VIPColorFormat;
NvU8 VIPHOffset;
NvU8 VIPVOffset;
NvU8 numI2CBytes; //bytes per transfer/packet
NvU8 numRes;
GFCAMERARESOLUTIONTYPE *pResData;
NvU16 initDataSize;
NvU8 *pInitData;
// GFCAMERABAYERINFO *pBayerInfo;
struct _GFCAMERATABLETYPE *pNext;
} GFCAMERATABLETYPE, *PGFCAMERATABLETYPE;
// Typesafe functions for opening and closing this component
GF_RETTYPE GFCameraOpen(GFRmHandle hRm, GFCameraHandle *phCamera,
GF_STATE_TYPE state, GFRmChHandle hCh);
void GFCameraClose(GFCameraHandle *phCamera);
/** This routine returns the camera's properties and capabilities.
These properties are returned in the GFPROPERTY structure.
@param CameraHandle (#GFCameraHandle) Handle to CameraAPI
@param pProp (PGFPROPERTY) Pointer to GFPROPERTY structure.
@retval #GF_SUCCESS Success
@retval #GF_ERROR Some error occured
@see GFPROPERTY
*/
GF_RETTYPE GFCameraGetProperty(GFCameraHandle CameraHandle,
PGFPROPERTY pProp);
/** This routine programs the camera's registers based on the data
contained in the camera table.
@param CameraHandle (#GFCameraHandle) Handle to CameraAPI
@param pCamera (PGFCAMERATABLETYPE) Pointer to camera entry.
@param resX (NvU16) Horizontal resolution
@param resY (NvU16) Vertical resolution
@retval #GF_SUCCESS Success
@retval #GF_ERROR Some error occured
@see PGFCAMERATABLETYPE
*/
GF_RETTYPE GFCameraSetup(GFCameraHandle CameraHandle,
PGFCAMERATABLETYPE pCamera,
NvU16 resX,
NvU16 resY );
/** This routine programs the camera's registers for a resolution change.
The main difference from GFCameraSetup() is the lack of camera power on.
@param CameraHandle (#GFCameraHandle) Handle to CameraAPI
@param pCamera (PGFCAMERATABLETYPE) Pointer to camera entry.
@param resX (NvU16) Horizontal resolution
@param resY (NvU16) Vertical resolution
@param poweron (NvU32) flag indicates whether camera power on should be executed
@param option (NvU32) flag passed to camera script SetResolution function
@retval #GF_SUCCESS Success
@retval #GF_ERROR Some error occured
@see PGFCAMERATABLETYPE
*/
GF_RETTYPE GFCameraSetResolution(GFCameraHandle CameraHandle,
PGFCAMERATABLETYPE pCamera,
NvU16 resX,
NvU16 resY,
NvU32 poweron,
NvU32 option);
/** This routine allocates the run-time camera table structure from the
camera scripts.
@param CameraHandle (#GFCameraHandle) Handle to CameraAPI
@param *pTable (NvU8) Pointer to camera configuration table, ignored for GFSDK SC15.
Camera configurations are passed via scripts.
@param *ppCamera (PGFCAMERATABLETYPE) Returns pointer to linked list of camera description tables
@return On success the number of cameras in the linked list is returned. This can be 0.
On failure an error code is returned. To distinguish between success and failure,
use macro #ISGFERROR() or #ISGFSUCCESS().
@see PGFCAMERATABLETYPE
*/
GF_RETTYPE GFCameraTableAlloc(GFCameraHandle CameraHandle,
NvU8 *pTable,
PGFCAMERATABLETYPE *ppCamera);
/** This routine frees the camera table structure created by
GFCameraTableAlloc().
@param CameraHandle (#GFCameraHandle) Handle to CameraAPI
@param *ppCamera (PGFCAMERATABLETYPE) Pointer to camera entry.
@retval #GF_SUCCESS Success
@retval #GF_ERROR Some error occured
@see PGFCAMERATABLETYPE
*/
GF_RETTYPE GFCameraTableFree(GFCameraHandle CameraHandle,
PGFCAMERATABLETYPE *ppCamera);
GF_RETTYPE GFCameraTableDump(GFCameraHandle CameraHandle,
PGFCAMERATABLETYPE pCamera);
/** This routine finds a camera that is contained in the camera table structure.
It does so using various parameters that refer to entries in the table.
@param CameraHandle (#GFCameraHandle) Handle to CameraAPI
@param *pCamera (PGFCAMERATABLETYPE) Pointer to camera entry.
@param *pWanted (PGFCAMERATABLETYPE) Pointer to the found PGFCAMERATABLETYPE structure.
@param id (NvU32) Unique I2C slave ID for the camera.
@param *name (Char) pointer to name.
@param resX (NvU16) Horizontal resolution
@param resY (NvU16) Vertical resolution
@retval #GF_SUCCESS Success
@retval #GF_ERROR Some error occured
*/
GF_RETTYPE GFCameraFind(GFCameraHandle CameraHandle,
PGFCAMERATABLETYPE pCamera,
PGFCAMERATABLETYPE *pWanted,
NvU32 id,
char *name,
NvU16 resX,
NvU16 resY );
/** This routine scans for a camera that is contained in the
table structure created by GFCameraTableAlloc().
@param CameraHandle (#GFCameraHandle) Handle to CameraAPI
@param *pTable (NvU8) Pointer to camera table.
@retval #GF_SUCCESS Success
@retval #GF_ERROR Some error occured
*/
GF_RETTYPE GFCameraScan(GFCameraHandle CameraHandle,
PGFCAMERATABLETYPE pCamera);
/** This routine uses the script subID parameter to find a camera
that is contained in the camera table structure.
@param CameraHandle (#GFCameraHandle) Handle to CameraAPI
@param *pCamera (PGFCAMERATABLETYPE) Pointer to camera entry.
@param *pWanted (PGFCAMERATABLETYPE) Pointer to the found PGFCAMERATABLETYPE structure.
@param subID (NvU32) Camera script subID.
@retval #GF_SUCCESS Success
@retval #GF_ERROR Some error occured
*/
GF_RETTYPE GFCameraScriptFind(GFCameraHandle CameraHandle,
PGFCAMERATABLETYPE pCamera,
PGFCAMERATABLETYPE *pWanted,
NvU32 subID);
/** This routine calls the camera script function to operate on a user defined
camera attribute. A shared buffer is used to pass parameters to and from
the camera script function.
The shared buffer and may contain data used by the script function
to perform the requested operation. The first data should indicate
the primary setting of the operation. The convention is to use ranges
that are normalized from 0 to 100. Where specific data is required,
that data must match that which is allowable by the camera in use.
If not, the error code GFCAM_ERROR_ILLEGAL_PARAMETER is returned.
The attribute may be one of the defined flags listed below.
GFCAMERA_CAMERACONTROL_PAN
GFCAMERA_CAMERACONTROL_TILT
GFCAMERA_CAMERACONTROL_ROLL
GFCAMERA_CAMERACONTROL_ZOOM
GFCAMERA_CAMERACONTROL_EXPOSURE
GFCAMERA_CAMERACONTROL_IRIS
GFCAMERA_CAMERACONTROL_FOCUS
GFCAMERA_CAMERACONTROL_FLASH
GFCAMERA_VIDEOPROCAMP_BRIGHTNESS
GFCAMERA_VIDEOPROCAMP_CONTRAST
GFCAMERA_VIDEOPROCAMP_HUE
GFCAMERA_VIDEOPROCAMP_SATURATION
GFCAMERA_VIDEOPROCAMP_SHARPNESS
GFCAMERA_VIDEOPROCAMP_GAMMA
GFCAMERA_VIDEOPROCAMP_COLORENABLE
GFCAMERA_VIDEOPROCAMP_WHITEBALANCE
GFCAMERA_VIDEOPROCAMP_BACKLIGHT_COMPENSATION
GFCAMERA_VIDEOPROCAMP_GAIN
@param CameraHandle (#GFCameraHandle) Handle to CameraAPI
@param *pCamera (PGFCAMERATABLETYPE) Pointer to camera entry.
@param attribute (NvU32) Attribute flag indicates operation.
@param *sharedBuffer (NvU32) pointer to a shared buffer.
@param bufferSize (NvU32) Size of shared buffer.
@param *readValue (NvU32) pointer to the returned value from the camera script function.
@retval #GF_SUCCESS Success
@retval #GF_ERROR Some error occured
@retval #GFCAM_ERROR_FUNCTION_NOT_SUPPORTED Attribute not supported
@retval #GFCAM_ERROR_ILLEGAL_PARAMETER Parameter out of range
*/
GF_RETTYPE GFCameraScriptSetAttribute(GFCameraHandle CameraHandle,
PGFCAMERATABLETYPE pCamera,
NvU32 attribute,
NvU32 *sharedBuffer,
NvU32 bufferSize,
NvU32 *readValue);
/** This routine uses the camera script function to execute a powerup or
powerdown sequence.
@param CameraHandle (#GFCameraHandle) Handle to CameraAPI
@param *pCamera (PGFCAMERATABLETYPE) Pointer to camera entry.
@param poweron (NvU32) If set to '0' execute powerdown, if '1', execute powerup.
@retval #GF_SUCCESS Success
@retval #GF_ERROR Some error occured
*/
GF_RETTYPE GFCameraPower(GFCameraHandle CameraHandle,
PGFCAMERATABLETYPE pCamera,
NvU32 poweron);
/*@}*/
#ifdef __cplusplus
}
#endif /* __cplusplus */
/** @page pageCameraAppNotes CameraAPI Application Notes
@section pageCameraAppNotes1 Todo
*/
#endif /* __CAMERA_H__ */