sl@0: // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0: // All rights reserved.
sl@0: // This component and the accompanying materials are made available
sl@0: // under the terms of the License "Eclipse Public License v1.0"
sl@0: // which accompanies this distribution, and is available
sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0: //
sl@0: // Initial Contributors:
sl@0: // Nokia Corporation - initial contribution.
sl@0: //
sl@0: // Contributors:
sl@0: //
sl@0: // Description:
sl@0: // e32\include\d32camerasc.h
sl@0: // User side class definition for the shared chunk camera driver.
sl@0: // 
sl@0: //
sl@0: 
sl@0: /**
sl@0:  @file
sl@0:  @internalAll
sl@0:  @prototype
sl@0: */
sl@0: 
sl@0: #ifndef __D32CAMERASC_H__
sl@0: #define __D32CAMERASC_H__
sl@0: 
sl@0: #include <e32cmn.h>
sl@0: #include <e32ver.h>
sl@0: #include <pixelformats.h>
sl@0: 
sl@0: _LIT(KDevCameraScName,"CameraSc");
sl@0: 
sl@0: /**
sl@0: Camera capability constants - bitmasks of possible flash modes. @see TCameraCapsV02.
sl@0: */
sl@0: /** Flash will automatically fire when required. */
sl@0: const TUint KCamFlashAuto = 0x0001;
sl@0: /** Flash will always fire. */
sl@0: const TUint KCamFlashForced = 0x0002;
sl@0: /** Reduced flash for general lighting */
sl@0: const TUint KCamFlashFillIn = 0x0004;
sl@0: /** Red-eye reduction mode. */
sl@0: const TUint KCamFlashRedEyeReduce = 0x0008;
sl@0: /** Flash at the moment when shutter opens. */
sl@0: const TUint KCamFlashSlowFrontSync = 0x0010;
sl@0: /** Flash at the moment when shutter closes. */
sl@0: const TUint KCamFlashSlowRearSync = 0x0020;
sl@0: /** User configurable setting */
sl@0: const TUint KCamFlashManual = 0x0040;
sl@0: 
sl@0: /**
sl@0: Camera capability constants - bitmasks of possible exposure modes. @see TCameraCapsV02.
sl@0: */
sl@0: /** Night-time setting for long exposures. */
sl@0: const TUint KCamExposureNight = 0x0001;
sl@0: /** Backlight setting for bright backgrounds. */
sl@0: const TUint KCamExposureBacklight = 0x0002;
sl@0: /** Centered mode for ignoring surroundings. */
sl@0: const TUint KCamExposureCenter = 0x0004;
sl@0: /** Sport setting for very short exposures. */
sl@0: const TUint KCamExposureSport = 0x0008;
sl@0: /** Generalised setting for very long exposures. */
sl@0: const TUint KCamExposureVeryLong = 0x0010;
sl@0: /** Snow setting for daylight exposure. */
sl@0: const TUint KCamExposureSnow = 0x0020;
sl@0: /** Beach setting for daylight exposure with reflective glare. */
sl@0: const TUint KCamExposureBeach = 0x0040;
sl@0: /** Programmed exposure setting. */
sl@0: const TUint KCamExposureProgram = 0x0080;
sl@0: /** Aperture setting is given priority. */
sl@0: const TUint KCamExposureAperturePriority = 0x0100;
sl@0: /** Shutter speed setting is given priority. */
sl@0: const TUint KCamExposureShutterPriority = 0x0200;
sl@0: /** User selectable exposure value setting. */
sl@0: const TUint KCamExposureManual = 0x0400;
sl@0: /** Exposure night setting with colour removed to get rid of colour noise. */
sl@0: const TUint KCamExposureSuperNight = 0x0800;
sl@0: /** Exposure for infra-red sensor on the camera */
sl@0: const TUint KCamExposureInfra = 0x1000;
sl@0: 
sl@0: /**
sl@0: Camera capability constants - bitmasks of possible white balance modes. @see TCameraCapsV02.
sl@0: */
sl@0: /** Normal daylight. */
sl@0: const TUint KCamWBDaylight = 0x0001;
sl@0: /** Overcast daylight. */
sl@0: const TUint KCamWBCloudy = 0x0002;
sl@0: /** Tungsten filament lighting. */
sl@0: const TUint KCamWBTungsten = 0x0004;
sl@0: /** Fluorescent tube lighting */
sl@0: const TUint KCamWBFluorescent = 0x0008;
sl@0: /** Flash lighting. */
sl@0: const TUint KCamWBFlash = 0x0010;
sl@0: /** High contrast daylight primarily snowy */
sl@0: const TUint KCamWBSnow = 0x0020;
sl@0: /** High contrast daylight primarily near the sea */
sl@0: const TUint KCamWBBeach = 0x0040;
sl@0: /** User configurable mode */
sl@0: const TUint KCamWBManual = 0x0080;
sl@0: 
sl@0: /**
sl@0: Camera capability constants - bitmasks of other miscellaneous camera capabilities supported. @see TCameraCapsV02.
sl@0: */
sl@0: /** The camera has zoom capability. */
sl@0: const TUint KCamMiscZoom = 0x0001;
sl@0: /** The camera supports contrast adjustment. */
sl@0: const TUint KCamMiscContrast = 0x0002;
sl@0: /** The camera supports brightness adjustment. */
sl@0: const TUint KCamMiscBrightness = 0x0004;
sl@0: /** The camera supports color effect adjustment. */
sl@0: const TUint KCamMiscColorEffect = 0x0008;
sl@0: 
sl@0: 
sl@0: /**
sl@0: Enumeration of capture modes in which to run the sensor.
sl@0: */
sl@0: enum TDevCamCaptureMode
sl@0: 	{
sl@0: 	/** Used to specify that still image mode is to be used. */
sl@0: 	ECamCaptureModeImage,
sl@0: 	/** Used to specify that streaming video mode is to be used. */
sl@0: 	ECamCaptureModeVideo,
sl@0: 	/** Used to specify that streaming viewfinder mode is to be used. */
sl@0: 	ECamCaptureModeViewFinder,
sl@0: 	/** The last value here, helps keep track of the number of capture modes. */
sl@0: 	ECamCaptureModeMax
sl@0: 	};
sl@0: 
sl@0: /**
sl@0: Enumeration of camera flash modes. @see TCameraConfigV02.
sl@0: */
sl@0: enum TDevCamFlashMode
sl@0: 	{
sl@0: 	/** No flash, always supported. */
sl@0: 	ECamFlashNone=0x0000,
sl@0: 	/** Flash will automatically fire when required. */
sl@0: 	ECamFlashAuto=0x0001,
sl@0: 	/** Flash will always fire. */
sl@0: 	ECamFlashForced=0x0002,
sl@0: 	/** Reduced flash for general lighting */
sl@0: 	ECamFlashFillIn=0x0004,
sl@0: 	/** Red-eye reduction mode. */
sl@0: 	ECamFlashRedEyeReduce=0x0008,
sl@0: 	/** Flash at the moment when shutter opens. */
sl@0: 	ECamFlashSlowFrontSync=0x0010,
sl@0: 	/** Flash at the moment when shutter closes. */
sl@0: 	ECamFlashSlowRearSync=0x0020,
sl@0: 	/** User configurable setting */
sl@0: 	ECamFlashManual=0x0040
sl@0: 	};
sl@0: 
sl@0: /**
sl@0: Enumeration of camera exposure modes. @see TCameraConfigV02.
sl@0: */
sl@0: enum TDevCamExposureMode
sl@0: 	{
sl@0: 	/** Set exposure automatically. Default, always supported. */
sl@0: 	ECamExposureAuto=0x0000,
sl@0: 	/** Night-time setting for long exposures. */
sl@0: 	ECamExposureNight=0x0001,
sl@0: 	/** Backlight setting for bright backgrounds. */
sl@0: 	ECamExposureBacklight=0x0002,
sl@0: 	/** Centered mode for ignoring surroundings. */
sl@0: 	ECamExposureCenter=0x0004,
sl@0: 	/** Sport setting for very short exposures. */
sl@0: 	ECamExposureSport=0x0008,
sl@0: 	/** Generalised setting for very long exposures. */
sl@0: 	ECamExposureVeryLong=0x0010,
sl@0: 	/** Snow setting for daylight exposure. */
sl@0: 	ECamExposureSnow=0x0020,
sl@0: 	/** Beach setting for daylight exposure with reflective glare. */
sl@0: 	ECamExposureBeach=0x0040,
sl@0: 	/** Programmed exposure setting. */
sl@0: 	ECamExposureProgram=0x0080,
sl@0: 	/** Aperture setting is given priority. */
sl@0: 	ECamExposureAperturePriority=0x0100,
sl@0: 	/** Shutter speed setting is given priority. */
sl@0: 	ECamExposureShutterPriority=0x0200,
sl@0: 	/** User selectable exposure value setting. */
sl@0: 	ECamExposureManual=0x0400,
sl@0: 	/** Exposure night setting with colour removed to get rid of colour noise. */
sl@0: 	ECamExposureSuperNight=0x0800,
sl@0: 	/** Exposure for infra-red sensor on the camera */
sl@0: 	ECamExposureInfra=0x1000
sl@0: 	};
sl@0: 
sl@0: /**
sl@0: Enumeration of camera white balance modes. @see TCameraConfigV02.
sl@0: */
sl@0: enum TDevCamWhiteBalanceMode
sl@0: 	{
sl@0: 	/** Set white balance automatically. Default, always supported. */
sl@0: 	ECamWBAuto=0x0000,
sl@0: 	/** Normal daylight. */
sl@0: 	ECamWBDaylight=0x0001,
sl@0: 	/** Overcast daylight. */
sl@0: 	ECamWBCloudy=0x0002,
sl@0: 	/** Tungsten filament lighting. */
sl@0: 	ECamWBTungsten=0x0004,
sl@0: 	/** Fluorescent tube lighting */
sl@0: 	ECamWBFluorescent=0x0008,
sl@0: 	/** Flash lighting. */
sl@0: 	ECamWBFlash=0x0010,
sl@0: 	/** High contrast daylight primarily snowy */
sl@0: 	ECamWBSnow=0x0020,
sl@0: 	/** High contrast daylight primarily near the sea */
sl@0: 	ECamWBBeach=0x0040,
sl@0: 	/** User configurable mode */
sl@0: 	ECamWBManual=0x0080
sl@0: 	};
sl@0: 
sl@0: /**
sl@0: Enumeration of possible directions in which the camera may point. @see TCameraCapsV02.
sl@0: */
sl@0: enum TDevCamOrientation
sl@0: 	{
sl@0: 	/** Outward pointing camera for taking pictures. Camera is directed away from the user. */
sl@0: 	ECamOrientationOutwards,
sl@0: 	/** Inward pointing camera for conferencing. Camera is directed towards the user. */
sl@0: 	ECamOrientationInwards,
sl@0: 	/** Mobile camera capable of multiple orientations. Camera orientation may be changed by the user. */
sl@0: 	ECamOrientationMobile,
sl@0: 	/** Camera orientation is not known. */
sl@0: 	ECamOrientationUnknown
sl@0: 	};
sl@0: 
sl@0: /**
sl@0: Each item in the iPixelFormatSupported array is represented by an instance of this structure.
sl@0: */
sl@0: struct SDevCamPixelFormat
sl@0: 	{
sl@0: 	/** The UID of the pixel format supported */
sl@0: 	TUidPixelFormat iPixelFormat;
sl@0: 	/** The number of frame sizes represented by the pixel format. */
sl@0: 	TUint iNumFrameSizes;
sl@0: 	/** The pixel width in number of bytes */
sl@0: 	TUint iPixelWidthInBytes;
sl@0: 	};
sl@0: 
sl@0: /**
sl@0: Each frame size supported is represented by an instance of this structure.
sl@0: */
sl@0: struct SDevCamFrameSize
sl@0: 	{
sl@0: 	/** Width of the frame in pixels. */
sl@0: 	TUint iWidth;
sl@0: 	/** Height of the frame in pixels. */
sl@0: 	TUint iHeight;
sl@0: 	/** Minimum frame rate supported by this frame size. */
sl@0: 	TUint iMinFrameRate;
sl@0: 	/** Maximum frame rate supported by this frame size. */
sl@0: 	TUint iMaxFrameRate;
sl@0: 	};
sl@0: 
sl@0: /**
sl@0: Lets us associate buffers to their mode when working out the buffer offset in a chunk.
sl@0: **/
sl@0: class TDevCamBufferModeAndId
sl@0: 	{
sl@0: public:
sl@0: 	TDevCamCaptureMode iCaptureMode;
sl@0: 	TInt iId;
sl@0: 	};
sl@0: typedef TPckgBuf<TDevCamBufferModeAndId> TDevCamBufferModeAndIdBuf;
sl@0: 
sl@0: /**
sl@0: The general driver capabilites class - returned by the LDD factory in response to RDevice::GetCaps().
sl@0: */
sl@0: class TCapsDevCameraV01
sl@0: 	{
sl@0: public:
sl@0: 	TVersion iVersion;
sl@0: 	};
sl@0: 
sl@0: /**
sl@0: Defines a list of settings that are changable often (dynamically) within a single use of the device.
sl@0: */
sl@0: enum TDevCamDynamicAttribute
sl@0: 	{
sl@0: 	ECamAttributeBrightness,
sl@0: 	ECamAttributeContrast,
sl@0: 	ECamAttributeColorEffect,
sl@0: 	ECamAttributeMax
sl@0: 	};
sl@0: 
sl@0: /**
sl@0: Holds the range and interval (rate of change) values for a dynamic capability.
sl@0: An array of these would be indexed by TDevCamDynamicAttribute
sl@0: */
sl@0: struct TDynamicRange
sl@0: 	{
sl@0: 	TUint iMin;
sl@0: 	TUint iMax;
sl@0: 	TUint iDefault;
sl@0: 	};
sl@0: 
sl@0: /**
sl@0: The main camera capabilities class. This is used to get the capabilities of a specific camera
sl@0: device once a channel to it has been opened.
sl@0: */
sl@0: class TCameraCapsV02
sl@0: 	{
sl@0: public :
sl@0: 	/** The flash modes supported - a bit field. */
sl@0: 	TUint iFlashModes;
sl@0: 	/** The exposure modes supported - a bit field. */
sl@0: 	TUint iExposureModes;
sl@0: 	/** The white balance modes supported - a bit field. */
sl@0: 	TUint iWhiteBalanceModes;
sl@0: 	/** The orientation of the camera device. */
sl@0: 	TDevCamOrientation iOrientation;
sl@0: 	/** The minimum value that may be set for the zoom factor. Must be negative or zero. Negative values
sl@0: 	represent macro functionality. @see TCameraCapsV02::iCapsMisc. @see TCameraConfigV02::iZoom. */
sl@0: 	TUint iMinZoom;
sl@0: 	/** The maximum value that may be set for the zoom factor. Must be positive or zero.
sl@0: 	@see TCameraCapsV02::iCapsMisc. @see TCameraConfigV02::iZoom. */
sl@0: 	TUint iMaxZoom;
sl@0: 	/** Whether other miscellaneous capabilities are supported - a bitfield. These
sl@0: 	capabilities include whether the device supports simultaneous capture modes, zoom capabilities, contrast
sl@0: 	adjustment, brightness, and color effect adjustment. */
sl@0: 	TUint iCapsMisc;
sl@0: 	/** Number of pixel formats supported in still image capture mode.
sl@0: 	Will be set to 0 if image capture is not supported. */
sl@0: 	TUint iNumImagePixelFormats;
sl@0: 	/** Number of pixel formats supported in video capture mode.
sl@0: 	Will be set to 0 if image capture is not supported. */
sl@0: 	TUint iNumVideoPixelFormats;
sl@0: 	/** Number of pixel formats supported in view finder capture mode.
sl@0: 	Will be set to 0 if image capture is not supported. */
sl@0: 	TUint iNumViewFinderPixelFormats;
sl@0: 	
sl@0: 	/** An array specifying the range in values for settings as defined by TDevCamDynamicAttribute.
sl@0: 		Indices for settings are in the order defined in TDevCamDynamicAttribute.
sl@0: 		If the setting is not supported then the entry is still present for performance reasons,
sl@0: 		i.e. indexing over searching.
sl@0: 		@see TDevCamDynamicAttribute
sl@0: 		@see TDynamicRange
sl@0: 	*/
sl@0: 	TDynamicRange iDynamicRange[ECamAttributeMax];
sl@0: 	
sl@0: 	/** A variable length array specifying the pixel formats supported by the sensor.
sl@0: 		The size of the TCameraCapsV02 structure is determined by each sensor's capabilities
sl@0: 		thus the array of supported pixel formats is of variable length. It is stored in memory
sl@0: 		exactly after TCameraCapsV02 whenever memory is allocated for it and the array cannot be
sl@0: 		accessed by a private member.
sl@0: 	SDevCamPixelFormat iPixelFormatsSupported[];
sl@0: 	*/
sl@0: 	};
sl@0: 
sl@0: typedef TPckgBuf<TCameraCapsV02> TCameraCapsV02Buf;
sl@0: 
sl@0: /**
sl@0: The camera configuration class. This is used to get and set the current
sl@0: configuration of the camera. @see SDevCamFrameSize and @see SDevCamPixelFormat.
sl@0: */
sl@0: class TCameraConfigV02
sl@0: 	{
sl@0: public:
sl@0: 	/** The size of the image to get from the sensor. */
sl@0: 	SDevCamFrameSize iFrameSize;
sl@0: 	/** The pixel format (RGB, YUV, RGB Bayer etc). */
sl@0: 	SDevCamPixelFormat iPixelFormat;
sl@0: 	/** The frame rate (in frame/s). */
sl@0: 	TUint iFrameRate;
sl@0: 	/** The flash mode setting. */
sl@0: 	TDevCamFlashMode iFlashMode;
sl@0: 	/** The exposure mode setting. */
sl@0: 	TDevCamExposureMode iExposureMode;
sl@0: 	/** The white balance mode setting. */
sl@0: 	TDevCamWhiteBalanceMode iWhiteBalanceMode;
sl@0: 	/** The zoom factor. Can be zero, positive or negative, Negative values represent macro functionality.*/
sl@0: 	TInt iZoom;
sl@0: 	/** Specifies the number of bytes used to store one pixel's worth of data. */
sl@0: 	TInt iPixelWidthInBytes;
sl@0: 	};
sl@0: typedef TPckgBuf<TCameraConfigV02> TCameraConfigV02Buf;
sl@0: 
sl@0: /** A structure used to assemble arguments for the function RDevCameraSc::SetBufConfigChunkOpen() and to pass
sl@0: these to the driver. */
sl@0: struct SSetBufConfigChunkOpenInfo
sl@0: 	{
sl@0: 	const TDesC8* iBufferConfigBuf;
sl@0: 	TInt iChunkHandle;
sl@0: 	};
sl@0: 
sl@0: /** A structure used to assemble arguments for the function RDevCameraSc::FrameSizeCaps() and to pass
sl@0: these to the driver. */
sl@0: struct SFrameSizeCapsInfo
sl@0: 	{
sl@0: 	TUidPixelFormat iUidPixelFormat;
sl@0: 	TDevCamCaptureMode iCaptureMode;
sl@0: 	};
sl@0: 
sl@0: /**
sl@0: The camera device driver API supporting shared chunks. This is the principle interface to communicate with
sl@0: an attached camera.
sl@0: */
sl@0: class RDevCameraSc : public RBusLogicalChannel
sl@0: 	{
sl@0: public:
sl@0: 	enum TRequest
sl@0: 	/**
sl@0: 	 Asynchronous request types
sl@0: 	*/
sl@0: 		{
sl@0: 		EMsgRequestMax=3,				// All requests less than this value are handled in the driver DFC thread.
sl@0: 		ERequestNotifyNewImage,
sl@0: 		ENumRequests,
sl@0: 		EAllRequests = (1<<ENumRequests)-1
sl@0: 		};
sl@0: 
sl@0: 	enum TControl
sl@0: 	/**
sl@0: 	 Synchronous request types
sl@0: 	*/
sl@0: 		{
sl@0: 		EControlSetBufConfigChunkCreate,
sl@0: 		EControlSetBufConfigChunkOpen,
sl@0: 		EControlStart,
sl@0: 		EControlStop,
sl@0: 		EControlSetCamConfig,
sl@0: 		EControlSetCaptureMode,
sl@0: 		EControlChunkClose,
sl@0: 		EMsgControlMax=100,				// All requests less than this value are handled in the driver DFC thread.
sl@0: 		EControlCaps,
sl@0: 		EControlGetCamConfig,
sl@0: 		EControlGetBufferConfig,
sl@0: 		EControlReleaseBuffer,
sl@0: 		EControlNotifyNewImageSpecificCancel,
sl@0: 		EControlBufferIdToOffset,
sl@0: 		EControlCapsSize,
sl@0: 		EControlFrameSizeCaps,
sl@0: 		EControlSetDynamicAttribute,
sl@0: 		EControlGetDynamicAttribute
sl@0: 		};
sl@0: 
sl@0: public:
sl@0: 	/**
sl@0: 	Get the version number of camera driver interface.
sl@0: 	@return The camera driver interface version number.
sl@0: 	*/
sl@0: 	inline static TVersion VersionRequired();
sl@0: 
sl@0: #ifndef __KERNEL_MODE__
sl@0: 	
sl@0: 	/**
sl@0: 	 Constructor.
sl@0: 	 Initialises private members.
sl@0: 	 */
sl@0: 	inline RDevCameraSc();
sl@0: 	
sl@0: 	/**
sl@0: 	Open a channel on a specified camera device. This driver only allows one channel to be opened on each device.
sl@0: 	@param aUnit The unit number of the camera device.
sl@0: 	@return KErrNone, if successful;
sl@0: 			KErrInUse, if a channel is already opened on the unit concerned;
sl@0: 			otherwise one of the other system-wide error codes.
sl@0: 	*/
sl@0: 	inline TInt Open(TInt aUnit);
sl@0: 
sl@0: 	/**
sl@0: 	Close the Channel and clean up.
sl@0: 	*/
sl@0: 	inline void Close();
sl@0: 
sl@0: 	/**
sl@0: 	Get the capabilities of the camera device.
sl@0: 	@param aCapsBuf A packaged TCameraCapsV02 object which on return will be filled with the capabilities of the device.
sl@0: 	@return KErrNone, if successful;
sl@0: 			KErrArgument, if aCapsBuf is too small.
sl@0: 	@see TCameraCapsV02.
sl@0: 	*/
sl@0: 	inline TInt Caps(TDes8& aCapsBuf);
sl@0: 
sl@0: 	/**
sl@0: 	Get the capabilities of the camera device.
sl@0: 	@return TPtrC8 pointing to a locally held TCameraCapsV02 structure owned by the driver.
sl@0: 	@see TCameraCapsV02.
sl@0: 	*/
sl@0: 	inline TPtrC8 Caps();
sl@0: 
sl@0: 	/**
sl@0: 	Set the camera configuration settings.
sl@0: 	@param aCaptureMode	The capture mode that camera will be configured for.
sl@0: 	@param aConfigBuf	A packaged TCameraConfigV02 object which contains the configuration settings.
sl@0: 	@see TCameraConfigV02.
sl@0: 	*/
sl@0: 	inline TInt SetCamConfig(TDevCamCaptureMode aCaptureMode, const TDesC8& aConfigBuf);
sl@0: 
sl@0: 	/**
sl@0: 	Trigger the buffer allocation and configuration setting - creating a shared chunk.
sl@0: 	From the frame size, pixel format (already supplied) and the number of camera buffers specified,
sl@0: 	the driver will	calculate the size of the shared chunk this requires. It will create such
sl@0: 	a shared chunk containing the specified number of buffers within it (each with memory committed to them).
sl@0: 	This will replace a previous shared chunk created by this driver.
sl@0: 	A handle to the chunk will then be created for the client thread which will be assigned to the
sl@0: 	RChunk object supplied by the client.The configuration cannot be changed unless image capture is disabled.
sl@0: 	@param aCaptureMode	The capture mode that camera will be configured for.
sl@0: 	@param aNumBuffers	The desired number of buffers that is going to be used.
sl@0: 	@param aChunk		An RChunk object to which the chunk handle will be assigned.
sl@0: 	@return KErrNone if successful;
sl@0: 			KErrInUse if image capturing is already in progress;
sl@0: 			KErrArgument if any configuration values are invalid;
sl@0: 			KErrNoMemory if the driver failed allocate memory for the shared chunk specified;
sl@0: 			otherwise one of the other system-wide error codes.
sl@0: 	*/
sl@0: 	inline TInt SetBufConfigChunkCreate(TDevCamCaptureMode aCaptureMode, TInt aNumBuffers, RChunk& aChunk);
sl@0: 
sl@0: 	/**
sl@0: 	Get the current camera configuration settings.
sl@0: 	@param aCaptureMode	The capture mode that the user requested the configuration settings of.
sl@0: 	@param aConfigBuf	A packaged TCameraConfigV02 object which will be filled with the configuration settings.
sl@0: 	@see TCameraConfigV02.
sl@0: 	*/
sl@0: 	inline void GetCamConfig(TDevCamCaptureMode aCaptureMode, TDes8& aConfigBuf);
sl@0: 
sl@0: 	/**
sl@0: 	Get the current buffer configuration settings.
sl@0: 	@param aCaptureMode	The capture mode that the configuration request is for.
sl@0: 	@param aConfigBuf	A packaged TSharedChunkBufConfigBase derived object which will be filled with the configuration settings.
sl@0: 	@see TSharedChunkBufConfigBase.
sl@0: 	*/
sl@0: 	inline void GetBufferConfig(TDevCamCaptureMode aCaptureMode, TDes8& aConfigBuf);
sl@0: 
sl@0: 	/**
sl@0: 	Set the current buffer configuration settings - using an existing shared chunk.
sl@0: 	The client supplies an existing shared chunk which is to be used by the driver as the play buffer.
sl@0: 	Any shared chunk previously created by the driver will be closed by it.
sl@0: 	The configuration cannot be changed unless image capture is disabled.
sl@0: 	@param aCaptureMode	The capture mode that the configuration is for.
sl@0: 	@param aBufferConfigBuf	A packaged TSharedChunkBufConfigBase derived object holding information on the buffer configuration
sl@0: 							settings of the chunk supplied.
sl@0: 	@param aChunk			A handle to the shared chunk which is to be used as the buffer. (This must be a
sl@0: 							valid handle for the calling thread).
sl@0: 	@return KErrNone if successful;
sl@0: 			KErrInUse if the playing of data is in progress;
sl@0: 			KErrBadHandle if the chunk handle was invalid;
sl@0: 			KErrArgument if any configuration values are invalid;
sl@0: 			otherwise one of the other system-wide error codes.
sl@0: 	@see TCameraConfigV02.
sl@0: 	*/
sl@0: 	inline TInt SetBufConfigChunkOpen(TDevCamCaptureMode aCaptureMode, const TDesC8& aBufferConfigBuf, RChunk& aChunk);
sl@0: 
sl@0: 	/**
sl@0: 	Closes the chunk associated with a given capture mode, and frees the associated buffers.  The chunk being closed,
sl@0: 	should have been allocated by the device driver by a call to SetBufConfigChunkCreate().
sl@0: 	@param aCaptureMode The capture mode for which to close the chunk.
sl@0: 	@return	KErrNone if successful.
sl@0: 			KErrInUse if an attempt has been made to free the memory and chunk while they are in use.
sl@0: 			Otherwise one of the other system-wide error codes.
sl@0: 	*/
sl@0: 	inline TInt ChunkClose(TDevCamCaptureMode aCaptureMode);
sl@0: 
sl@0: 	/**
sl@0: 	Start the image capture process in the capture mode supplied.
sl@0: 	If the driver is in free running mode then it will commence capturing frames - cycling between
sl@0: 	each buffer available to it until Stop() is called. In one shot mode the driver postpones the capturing
sl@0: 	of frames until a NotifyNewImage() request is received.
sl@0: 	@return KErrNone if successful;
sl@0: 			KErrNotReady if SetConfig() has not been previously called;
sl@0: 			otherwise one of the other system-wide error codes.
sl@0: 	@pre The driver must have been previousely initialised by a call to SetConfigNN()
sl@0: 	*/
sl@0: 	inline TInt Start();
sl@0: 
sl@0: 	/**
sl@0: 	End the image capturing process.
sl@0: 	Also performs NotifyNewImageCancel()
sl@0: 	@return KErrGeneral if Start() has not been previously called;
sl@0: 			KErrNone otherwise.
sl@0: 	*/
sl@0: 	inline TInt Stop();
sl@0: 
sl@0: 	/**
sl@0: 	Get the next available image.
sl@0: 	More than one request may be pending at any time.
sl@0: 	If the camera is enabled for image capture and image capture is not already in progress then the issuing
sl@0: 	of this request will start image capture mode.
sl@0: 	@param aStatus 	The request status which is signaled when an image is available (or an error occurs).
sl@0: 					If the request is successful then this result value is the offset within the shared chunk
sl@0: 					where the capture image resides. Alternatively, if an error occurs it will be set to one of
sl@0: 					the system wide error values:
sl@0: 				 	KErrNotReady if Start() hasn't been previousely called;
sl@0: 				 	KErrInUse if the client already has all the images buffers.
sl@0: 	@pre Image capturing must have been started with Start().
sl@0: 	*/
sl@0: 	inline void NotifyNewImage(TRequestStatus& aStatus);
sl@0: 
sl@0: 	/**
sl@0: 	Cancels all outstanding NotifyNewImage() requests.
sl@0: 	All outstanding requests complete with KErrCancel.
sl@0: 	*/
sl@0: 	inline void NotifyNewImageCancel();
sl@0: 
sl@0: 	/**
sl@0: 	Cancels a specific NotifyNewImage() request.
sl@0: 	The outstanding request completes with KErrCancel.
sl@0: 	@param aStatus The request status object associated with the request to be cancelled.
sl@0: 	*/
sl@0: 	inline void NotifyNewImageCancel(const TRequestStatus& aStatus);
sl@0: 
sl@0: 	/**
sl@0: 	Release a buffer - making it available again for the driver to capture images into.
sl@0: 	@param aBufferId	The buffer id of the buffer that the image to be released is stored.
sl@0: 						This is a value returned by the NotifyNewImage() request when
sl@0: 						the buffer was claimed by the client.
sl@0: 	@return KErrNone if successful;
sl@0: 			KErrNotFound if the buffer id is invalid;
sl@0: 			otherwise one of the other system-wide error codes.
sl@0: 	*/
sl@0: 	inline TInt ReleaseBuffer(TInt aBufferId);
sl@0: 
sl@0: 	/**
sl@0: 	Retrieves the offset to the start of the buffer using its id, in the specified capture mode.
sl@0: 	@param aCaptureMode	The capture mode that the buffer in the chunk is related to.
sl@0: 	@param aId			The id of the buffer in the chunk.
sl@0: 	@param aOffset		The offset, in bytes, of the start of the buffer within the chunk.
sl@0: 	@return KErrNone if successful;
sl@0: 			KErrNotFound if the id doesn't exist;
sl@0: 			otherwise one of the other system-wide error codes.
sl@0: 	*/
sl@0: 	inline TInt BufferIdToOffset(TDevCamCaptureMode aCaptureMode, TInt aId, TInt& aOffset);
sl@0: 
sl@0: 	/**
sl@0: 	Sets the current capture mode. Submits the camera configuration	to the PDD.
sl@0: 	@param aCaptureMode	The capture mode that the camera switches to.	@see TDevCamCaptureMode.
sl@0: 	@return KErrNone if successful;
sl@0: 			otherwise one of the other system-wide error codes.
sl@0: 	*/
sl@0: 	inline TInt SetCaptureMode(TDevCamCaptureMode aCaptureMode);
sl@0: 
sl@0: 	/**
sl@0: 	Queries the driver for the size of the structure to be passed to Caps().
sl@0: 	@return The size of the structure required to hold all capability information.
sl@0: 			otherwise one of the system-wide error codes.
sl@0: 	*/
sl@0: 	inline TInt CapsSize();
sl@0: 
sl@0: 	/**
sl@0: 	Gets information regarding the frame sizes and frame rates supported for a given combination of capture mode and pixel format.
sl@0: 	The capture mode and pixel format chosen will be dependent upon the information returned by RDevCameraSc::Caps().
sl@0: 	@param	aCaptureMode The capture mode concerned.
sl@0: 	@param	aUidPixelFormat The UID of the pixel format mode concerned.
sl@0: 	@param	aFrameSizeCapsBuf	A packaged array of SDevCamFrameSize structures.
sl@0: 								This is a variable length array and must be large enough to hold all entries.
sl@0: 								Its size is determined by SDevCamPixelFormat::iNumFrameSizes, returned by RDevCameraSc::Caps(),
sl@0: 								multiplied by the size of SDevCamFrameSize.
sl@0: 	@return	KErrNone if successful;
sl@0: 			KErrArgument if an invalid capture mode or pixel format is specified, or if aFrameSizeCapsBuf is too small.
sl@0: 			otherwise one of the other system-wide error codes.
sl@0: 	*/
sl@0: 	inline TInt FrameSizeCaps(TDevCamCaptureMode aCaptureMode, TUidPixelFormat aUidPixelFormat, TDes8& aFrameSizeCapsBuf);
sl@0: 	
sl@0: 
sl@0: 	/**
sl@0: 	Allows changing of the dynamic settings as specified in TDevCamDynamicAttribute.
sl@0: 	Checks locally the validity of the arguments passed so as to increase performance by not
sl@0: 	forcing a context switch.
sl@0: 	Check the allowable range of the settings via the TCameraCapsV02::iDynamicRange member.
sl@0: 
sl@0: 	@param aAttribute An enum identifying the dynamic attribute to change.
sl@0: 	@param aValue The attributes value within a valid range.
sl@0: 	@return KErrNone if successful, KErrNotSupported if not supported, 
sl@0: 			KErrArgument if aValue is out of range.
sl@0: 			Otherwise, one of the system wide error codes.
sl@0: 	@see TDevCamDynamicAttribute
sl@0: 	@see TCameraCapsV02
sl@0: 	*/
sl@0: 	TInt SetDynamicAttribute(TDevCamDynamicAttribute aAttribute, TUint aValue);
sl@0: 
sl@0: 	/**
sl@0: 	Queries the driver for a dynamic setting's value.
sl@0: 	This function does not force a context switch by reading the values from a cache.
sl@0: 	
sl@0: 	@param aAttribute An enum identifying the dynamic attribute to query.
sl@0: 	@param aValue A reference to a variable that will be set to the queried attribute's value.
sl@0: 	@return KErrNone if successful, KErrNotFound if aAttribute is not supported by the driver.
sl@0: 		Otherwise, one of the system-wide error codes.
sl@0: 
sl@0: 	@see TDevCamDynamicAttribute
sl@0: 	@see TCameraCapsV02
sl@0: 	*/
sl@0: 	TInt GetDynamicAttribute(TDevCamDynamicAttribute aAttribute, TUint& aValue);
sl@0: 
sl@0: protected:
sl@0: 	TInt CheckAttributeSupported(TDevCamDynamicAttribute aAttribute);
sl@0: 
sl@0: 
sl@0: private:
sl@0: 	/** 
sl@0: 	Capability of Sensor. 
sl@0: 	Kept here for performance issues, i.e. to avoid context switches.
sl@0: 	*/
sl@0: 	TCameraCapsV02 *iCameraCaps;
sl@0: 
sl@0: 	/** 
sl@0: 	Size of Camera Capabiliy struct. 
sl@0: 	Kept here for performance issues, i.e. to avoid context switches.
sl@0: 	*/
sl@0: 	TInt iCapsSize;
sl@0: 	
sl@0: #endif	// __KERNEL_MODE__
sl@0: 	};
sl@0: 
sl@0: 
sl@0: 
sl@0: 
sl@0: #include <d32camerasc.inl>
sl@0: 
sl@0: #endif	// __D32CAMERASC_H__